/** * Setup the Yoast SEO premium plugin */ private function setup() { WPSEO_Premium::autoloader(); $this->load_textdomain(); $this->instantiate_redirects(); if (is_admin()) { $query_var = ($page = filter_input(INPUT_GET, 'page')) ? $page : ''; // Only add the helpscout beacon on Yoast SEO pages. if (substr($query_var, 0, 5) === 'wpseo') { new WPSEO_HelpScout_Beacon($query_var); } // Add custom fields plugin to post and page edit pages. global $pagenow; if (in_array($pagenow, array('post-new.php', 'post.php', 'edit.php'))) { new WPSEO_Custom_Fields_Plugin(); } // Disable Yoast SEO. add_action('admin_init', array($this, 'disable_wordpress_seo'), 1); // Add Sub Menu page and add redirect page to admin page array. // This should be possible in one method in the future, see #535. add_filter('wpseo_submenu_pages', array($this, 'add_submenu_pages'), 9); // Add Redirect page as admin page. add_filter('wpseo_admin_pages', array($this, 'add_admin_pages')); // Post to Get on search. add_action('admin_init', array($this, 'list_table_search_post_to_get')); // Add input fields to page meta post types. add_action('wpseo_admin_page_meta_post_types', array($this, 'admin_page_meta_post_types_checkboxes'), 10, 2); // Add page analysis fields to variable array key patterns. add_filter('wpseo_option_titles_variable_array_key_patterns', array($this, 'add_variable_array_key_pattern')); // Settings. add_action('admin_init', array($this, 'register_settings')); // Check if we need to save files after updating options. add_action('update_option_wpseo_redirect', array($this, 'save_redirect_files'), 10, 2); // Catch option save. add_action('admin_init', array($this, 'catch_option_redirect_save')); // Screen options. switch ($query_var) { case 'wpseo_redirects': add_filter('set-screen-option', array('WPSEO_Page_Redirect', 'set_screen_option'), 11, 3); break; } // Enqueue Post and Term overview script. add_action('admin_enqueue_scripts', array($this, 'enqueue_overview_script')); // Licensing part. $license_manager = new Yoast_Plugin_License_Manager(new WPSEO_Product_Premium()); // Setup constant name. $license_manager->set_license_constant_name('WPSEO_LICENSE'); // Setup license hooks. $license_manager->setup_hooks(); // Add this plugin to licensing form. add_action('wpseo_licenses_forms', array($license_manager, 'show_license_form')); if ($license_manager->license_is_valid()) { add_action('admin_head', array($this, 'admin_css')); } // Add Premium imports. $premium_import_manager = new WPSEO_Premium_Import_Manager(); // Allow option of importing from other 'other' plugins. add_filter('wpseo_import_other_plugins', array($premium_import_manager, 'filter_add_premium_import_options')); // Handle premium imports. add_action('wpseo_handle_import', array($premium_import_manager, 'do_premium_imports')); // Add htaccess import block. add_action('wpseo_import_tab_content', array($premium_import_manager, 'add_htaccess_import_block')); add_action('wpseo_import_tab_header', array($premium_import_manager, 'htaccess_import_header')); // Only activate post and term watcher if permalink structure is enabled. if (get_option('permalink_structure')) { add_action('admin_init', array($this, 'init_watchers')); // Check if we need to display an admin message. if ($redirect_created = filter_input(INPUT_GET, 'yoast-redirect-created')) { // Message object. $message = new WPSEO_Message_Redirect_Created($redirect_created); add_action('all_admin_notices', array($message, 'display')); } } } else { // Add 404 redirect link to WordPress toolbar. add_action('admin_bar_menu', array($this, 'admin_bar_menu'), 96); add_filter('redirect_canonical', array($this, 'redirect_canonical_fix'), 1, 2); } add_action('admin_init', array($this, 'enqueue_multi_keyword')); }
/** * If we have notifications, make sure we can deal with them too, for which we need the scripts. */ public function enqueue() { if (count($this->notifications) > 0) { WPSEO_Premium::enqueue(); } }