/** * Setup the premium WordPress SEO plugin */ private function setup() { // Setup autoloader require_once dirname(__FILE__) . '/classes/class-premium-autoloader.php'; $autoloader = new WPSEO_Premium_Autoloader(); spl_autoload_register(array($autoloader, 'load')); if (is_admin()) { // Upgrade Manager $plugin_updater = new WPSEO_Upgrade_Manager(); $plugin_updater->check_update(); // Create pages $this->page_gwt = new WPSEO_Page_GWT(); // Disable WordPress 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')); // 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 the GWT crawl error post type add_action('admin_init', array($this, 'register_gwt_crawl_error_post_type')); // 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')); // Filter the Page Analysis content add_filter('wpseo_pre_analysis_post_content', array($this, 'filter_page_analysis'), 10, 2); // Check if WPSEO_DISABLE_PHP_REDIRECTS is defined if (defined('WPSEO_DISABLE_PHP_REDIRECTS') && true === WPSEO_DISABLE_PHP_REDIRECTS) { // Change the normal redirect autoload option $normal_redirect_manager = new WPSEO_URL_Redirect_Manager(); $normal_redirect_manager->redirects_change_autoload(false); // Change the regex redirect autoload option $regex_redirect_manager = new WPSEO_REGEX_Redirect_Manager(); $regex_redirect_manager->redirects_change_autoload(false); } else { $options = WPSEO_Redirect_Manager::get_options(); // If the disable_php_redirect option is not enabled we should enable auto loading redirects if ('off' == $options['disable_php_redirect']) { // Change the normal redirect autoload option $normal_redirect_manager = new WPSEO_URL_Redirect_Manager(); $normal_redirect_manager->redirects_change_autoload(true); // Change the regex redirect autoload option $regex_redirect_manager = new WPSEO_REGEX_Redirect_Manager(); $regex_redirect_manager->redirects_change_autoload(true); } } // 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 $query_var = !empty($_GET['page']) ? $_GET['page'] : ''; switch ($query_var) { case 'wpseo_redirects': add_filter('set-screen-option', array('WPSEO_Page_Redirect', 'set_screen_option'), 11, 3); break; case 'wpseo_webmaster_tools': add_filter('set-screen-option', array($this->page_gwt, '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')); } // Crawl Issue Manager AJAX hooks $crawl_issue_manager = new WPSEO_Crawl_Issue_Manager(); add_action('wp_ajax_wpseo_ignore_crawl_issue', array($crawl_issue_manager, 'ajax_ignore_crawl_issue')); add_action('wp_ajax_wpseo_unignore_crawl_issue', array($crawl_issue_manager, 'ajax_unignore_crawl_issue')); // 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', array($premium_import_manager, 'add_htaccess_import_block')); // Only activate post and term watcher if permalink structure is enabled if (get_option('permalink_structure')) { // The Post Watcher $post_watcher = new WPSEO_Post_Watcher(); // Add old URL field to post edit screen add_action('edit_form_advanced', array($post_watcher, 'old_url_field'), 10, 1); add_action('edit_page_form', array($post_watcher, 'old_url_field'), 10, 1); // Detect a post slug change add_action('post_updated', array($post_watcher, 'detect_slug_change'), 12, 3); // Detect a post trash add_action('trashed_post', array($post_watcher, 'detect_post_trash')); // Detect a post untrash add_action('untrashed_post', array($post_watcher, 'detect_post_untrash')); // Detect a post delete add_action('delete_post', array($post_watcher, 'detect_post_delete')); // The Term Watcher $term_watcher = new WPSEO_Term_Watcher(); // Get all taxonomies $taxonomies = get_taxonomies(); // Loop through all taxonomies if (count($taxonomies) > 0) { foreach ($taxonomies as $taxonomy) { // Add old URL field to term edit screen add_action($taxonomy . '_edit_form_fields', array($term_watcher, 'old_url_field'), 10, 2); } } // Detect the term slug change add_action('edited_term', array($term_watcher, 'detect_slug_change'), 10, 3); // Detect a term delete add_action('delete_term_taxonomy', array($term_watcher, 'detect_term_delete')); // Check if we need to display an admin message if (isset($_GET['yoast-redirect-created'])) { // Message object $message = new WPSEO_Message_Redirect_Created($_GET['yoast-redirect-created']); add_action('all_admin_notices', array($message, 'display')); } } } else { // Catch redirect $normal_redirect_manager = new WPSEO_URL_Redirect_Manager(); add_action('template_redirect', array($normal_redirect_manager, 'do_redirects')); // Catch redirect $regex_redirect_manager = new WPSEO_REGEX_Redirect_Manager(); add_action('template_redirect', array($regex_redirect_manager, 'do_redirects')); // 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); } // Normal Redirect AJAX $redirect_manager = new WPSEO_URL_Redirect_Manager(); add_action('wp_ajax_wpseo_save_redirect_url', array($redirect_manager, 'ajax_handle_redirect_save')); add_action('wp_ajax_wpseo_delete_redirect_url', array($redirect_manager, 'ajax_handle_redirect_delete')); add_action('wp_ajax_wpseo_create_redirect_url', array($redirect_manager, 'ajax_handle_redirect_create')); // Regex Redirect AJAX $redirect_manager = new WPSEO_REGEX_Redirect_Manager(); add_action('wp_ajax_wpseo_save_redirect_regex', array($redirect_manager, 'ajax_handle_redirect_save')); add_action('wp_ajax_wpseo_delete_redirect_regex', array($redirect_manager, 'ajax_handle_redirect_delete')); add_action('wp_ajax_wpseo_create_redirect_regex', array($redirect_manager, 'ajax_handle_redirect_create')); // Add URL reponse code check AJAX add_action('wp_ajax_wpseo_check_url', array('WPSEO_Url_Checker', 'check_url')); }
/** * Setup the premium WordPress SEO plugin */ private function setup() { // Setup autoloader require_once dirname(__FILE__) . '/classes/class-premium-autoloader.php'; $autoloader = new WPSEO_Premium_Autoloader(); spl_autoload_register(array($autoloader, 'load')); $this->load_textdomain(); $this->instantiate_redirects(); if (is_admin()) { // Upgrade Manager $plugin_updater = new WPSEO_Upgrade_Manager(); $plugin_updater->check_update(); // Create pages $this->page_gwt = new WPSEO_Page_GWT(); // Disable WordPress 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')); // 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 the GWT crawl error post type add_action('admin_init', array($this, 'register_gwt_crawl_error_post_type')); // 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')); // Filter the Page Analysis content add_filter('wpseo_pre_analysis_post_content', array($this, 'filter_page_analysis'), 10, 2); // 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 $query_var = !empty($_GET['page']) ? $_GET['page'] : ''; switch ($query_var) { case 'wpseo_redirects': add_filter('set-screen-option', array('WPSEO_Page_Redirect', 'set_screen_option'), 11, 3); break; case 'wpseo_webmaster_tools': add_filter('set-screen-option', array($this->page_gwt, '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')); } // Crawl Issue Manager AJAX hooks $crawl_issue_manager = new WPSEO_Crawl_Issue_Manager(); add_action('wp_ajax_wpseo_ignore_crawl_issue', array($crawl_issue_manager, 'ajax_ignore_crawl_issue')); add_action('wp_ajax_wpseo_unignore_crawl_issue', array($crawl_issue_manager, 'ajax_unignore_crawl_issue')); // 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', array($premium_import_manager, 'add_htaccess_import_block')); // 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 (isset($_GET['yoast-redirect-created'])) { // Message object $message = new WPSEO_Message_Redirect_Created($_GET['yoast-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); } }