plugin_file = $plugin_file; $this->plugin_slug = basename(dirname($plugin_file)); $this->load_config(); if (!is_admin()) { return; } else { add_action('admin_init', array($this, 'init')); } } // __construct function load_config() { $config = array(); require_once plugin_dir_path($this->plugin_file) . 'wf-flyout/config.php'; $defaults = array( 'plugin_screen' => '', 'icon_border' => '#0000ff', 'icon_right' => '40px', 'icon_bottom' => '40px', 'icon_image' => '', 'icon_padding' => '2px', 'icon_size' => '55px', 'menu_accent_color' => '#ca4a1f', 'custom_css' => '', 'menu_items' => array(), ); $config = array_merge($defaults, $config); if (!is_array($config['plugin_screen'])) { $config['plugin_screen'] = array($config['plugin_screen']); } $this->config = $config; } // load_config function is_plugin_screen() { $screen = get_current_screen(); if (in_array($screen->id, $this->config['plugin_screen'])) { return true; } else { return false; } } // is_plugin_screen function init() { add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); add_action('admin_head', array($this, 'admin_head')); add_action('admin_footer', array($this, 'admin_footer')); } // init function admin_enqueue_scripts() { if (false === $this->is_plugin_screen()) { return; } wp_enqueue_style('wf_flyout', plugin_dir_url($this->plugin_file) . 'wf-flyout/wf-flyout.css', array(), $this->ver); wp_enqueue_script('wf_flyout', plugin_dir_url($this->plugin_file) . 'wf-flyout/wf-flyout.js', array(), $this->ver, true);; } // admin_enqueue_scripts function admin_head() { if (false === $this->is_plugin_screen()) { return; } $out = ''; UCP::wp_kses_wf($out); } // admin_head function admin_footer() { if (false === $this->is_plugin_screen()) { return; } $out = ''; $icons_url = plugin_dir_url($this->plugin_file) . 'wf-flyout/icons/'; $default_link_item = array('class' => '', 'href' => '#', 'target' => '_blank', 'label' => '', 'icon' => '', 'data' => ''); $out .= '
'; $out .= '
'; $out .= ''; $out .= 'Open Quick Links'; $out .= ''; $out .= 'Open Quick Links'; $out .= ''; $out .= ''; $out .= '
'; $i = 0; foreach (array_reverse($this->config['menu_items']) as $item) { $i++; $item = array_merge($default_link_item, $item); if (!empty($item['icon']) && substr($item['icon'], 0, 9) != 'dashicons') { $item['class'] .= ' wff-custom-icon'; $item['class'] = trim($item['class']); } $out .= ''; $out .= '' . esc_html($item['label']) . ''; if (substr($item['icon'], 0, 9) == 'dashicons') { $out .= ''; } elseif (!empty($item['icon'])) { $out .= ''; } $out .= ''; } // foreach $out .= '
'; // #wff-menu $out .= '
'; // #wf-flyout UCP::wp_kses_wf($out); } // admin_footer } // wf_flyout } // if class exists