Ejemplo n.º 1
0
 /**
  * Loads the License_Plugin_Manager class
  *
  * The class will take care of the rest: notices, license (de)activations, updates, etc..
  */
 public function load_license_manager()
 {
     // Instantiate license class
     $license_manager = new Yoast_Plugin_License_Manager(new Sample_Product());
     // Setup the required hooks
     $license_manager->setup_hooks();
 }
Ejemplo n.º 2
0
 /**
  * Post Connector constructor
  */
 public function __construct()
 {
     // Load autoloader
     require_once self::get_core_dir() . '/classes/class-autoloader.php';
     // Setup premium autoloader
     $autoloader = new SP_Autoloader(self::get_premium_dir());
     $autoloader = new SP_Autoloader(self::get_premium_dir());
     if (version_compare(PHP_VERSION, '5.3', '>=')) {
         spl_autoload_register(array($autoloader, 'load'), true, true);
     } else {
         spl_autoload_register(array($autoloader, 'load'), true);
     }
     // Do the parent int
     parent::init();
     // Load deprecated file
     require_once self::get_premium_dir() . 'deprecated.php';
     // Setup premium manager hooks
     $premium_manager_hook = new SP_Manager_Hook(self::get_premium_dir() . 'classes/hooks/');
     $premium_manager_hook->load_hooks();
     // Setup premium manager filters
     $manager_filter = new SP_Manager_Filter(self::get_premium_dir() . 'classes/filters/');
     $manager_filter->load_filters();
     // Widgets
     $manager_widget = new SP_Manager_Widget(self::get_premium_dir() . 'classes/widgets/');
     $manager_widget->load();
     // Setup the license hooks
     $license_manager = new Yoast_Plugin_License_Manager(new SP_Product_Post_Connector());
     $license_manager->setup_hooks();
     // Plugin upgrader
     if (is_admin()) {
         $premium_upgrade_manager = new SP_Premium_Upgrade_Manager();
         $premium_upgrade_manager->check_update();
     }
 }
 /**
  * Setting up the license manager
  *
  * @since 3.0
  */
 protected function setup_license_manager()
 {
     $license_manager = new Yoast_Plugin_License_Manager($this);
     $license_manager->setup_hooks();
     add_filter('yst_ga_extension_status', array($this, 'filter_extension_is_active'), 10, 1);
     add_action('yst_ga_show_license_form', array($this, 'action_show_license_form'));
     $this->license_manager = $license_manager;
 }
Ejemplo n.º 4
0
 /**
  * Setup the Yoast SEO premium 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()) {
         // 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'));
         // 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'));
         // 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 = ($page = filter_input(INPUT_GET, 'page')) ? $page : '';
         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);
     }
 }
Ejemplo n.º 5
0
 /**
  * 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'));
 }
Ejemplo n.º 6
0
 /**
  * Initialize the admin page
  */
 private function init_admin()
 {
     // Edit Post JS
     global $pagenow;
     if ('post.php' == $pagenow || 'post-new.php' == $pagenow) {
         add_action('admin_head', array($this, 'edit_post_css'));
         add_action('admin_enqueue_scripts', array($this, 'enqueue_edit_post'));
     }
     // Upgrade Manager
     $upgrade_manager = new WPSEO_News_Upgrade_Manager();
     $upgrade_manager->check_update();
     // License Manager
     $license_manager = new Yoast_Plugin_License_Manager(new WPSEO_News_Product());
     $license_manager->setup_hooks();
     add_action('wpseo_licenses_forms', array($license_manager, 'show_license_form'));
     // Setting action for removing the transient on update options
     if (method_exists('WPSEO_Utils', 'register_cache_clear_option')) {
         WPSEO_Utils::register_cache_clear_option('wpseo_news', $this->get_sitemap_name(false));
     }
 }
Ejemplo n.º 7
0
 /**
  * Constructor for the WPSEO_Video_Sitemap class.
  *
  * @todo  Deal with upgrade from license constant WPSEO_VIDEO_LICENSE
  * @since 0.1
  */
 public function __construct()
 {
     // Initialize the options
     $this->option_instance = WPSEO_Option_Video::get_instance();
     $options = get_option('wpseo_video');
     // run upgrade routine
     $this->upgrade();
     add_filter('wpseo_tax_meta_special_term_id_validation__video', array($this, 'validate_video_tax_meta'));
     if (!isset($GLOBALS['content_width']) && $options['content_width'] > 0) {
         $GLOBALS['content_width'] = $options['content_width'];
     }
     add_action('setup_theme', array($this, 'init'));
     add_action('admin_init', array($this, 'init'));
     add_action('init', array($this, 'register_sitemap'), 20);
     // Register sitemap after cpts have been added
     add_action('admin_bar_menu', array($this, 'add_admin_bar_item'), 97);
     add_filter('oembed_providers', array($this, 'sync_oembed_providers'));
     if (is_admin()) {
         add_action('admin_menu', array($this, 'register_settings_page'));
         add_filter('wpseo_admin_pages', array($this, 'style_admin'));
         add_action('save_post', array($this, 'update_video_post_meta'));
         if (in_array($GLOBALS['pagenow'], array('edit.php', 'post.php', 'post-new.php')) || apply_filters('wpseo_always_register_metaboxes_on_admin', false)) {
             $this->metabox_tab = new WPSEO_Video_Metabox();
         }
         // Licensing part
         $yoast_product = new Yoast_Product_WPSEO_Video();
         $license_manager = new Yoast_Plugin_License_Manager($yoast_product);
         // Setup constant name
         $license_manager->set_license_constant_name('WPSEO_VIDEO_LICENSE');
         // Setup hooks
         $license_manager->setup_hooks();
         // Add form
         add_action('wpseo_licenses_forms', array($license_manager, 'show_license_form'));
         add_action('admin_enqueue_scripts', array($this, 'admin_video_enqueue_scripts'));
         add_action('admin_init', array($this, 'admin_video_enqueue_styles'));
         add_action('wp_ajax_index_posts', array($this, 'index_posts_callback'));
         add_action('save_post', array($this, 'invalidate_sitemap'));
         // Setting action for removing the transient on update options
         if (method_exists('WPSEO_Utils', 'register_cache_clear_option')) {
             WPSEO_Utils::register_cache_clear_option('wpseo_video', $this->video_sitemap_basename());
         }
         // Maybe show 'Recommend re-index' admin notice
         if (get_transient('video_seo_recommend_reindex') === '1') {
             add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts_ignore'));
             add_action('all_admin_notices', array($this, 'recommend_force_index'));
             add_action('wp_ajax_videoseo_set_ignore', array($this, 'set_ignore'));
         }
     } else {
         // OpenGraph
         add_action('wpseo_opengraph', array($this, 'opengraph'));
         add_filter('wpseo_opengraph_type', array($this, 'opengraph_type'), 10, 1);
         add_filter('wpseo_opengraph_image', array($this, 'opengraph_image'), 5, 1);
         // XML Sitemap Index addition
         add_filter('wpseo_sitemap_index', array($this, 'add_to_index'));
         // Setting stylesheet for cached sitemap
         add_action('wpseo_sitemap_stylesheet_cache_video', array($this, 'set_stylesheet_cache'));
         // Content filter for non-detected videos
         add_filter('the_content', array($this, 'content_filter'), 5, 1);
         if ($options['fitvids'] === true) {
             // Fitvids scripting
             add_action('wp_head', array($this, 'fitvids'));
         }
         if ($options['disable_rss'] !== true) {
             // MRSS
             add_action('rss2_ns', array($this, 'mrss_namespace'));
             add_action('rss2_item', array($this, 'mrss_item'), 10, 1);
             add_filter('mrss_media', array($this, 'mrss_add_video'));
         }
     }
     // @todo Maybe enable ?
     // Run on low prio to allow other filters to add their extensions first
     //add_filter( 'wp_video_extensions', array( $this, 'filter_video_extensions' ), 99 );
 }
 /**
  * Loads the License Manager class
  * Takes care of remote license (de)activation and plugin updates.
  *
  * @return Yoast_Plugin_License_Manager
  */
 private function load_license_manager()
 {
     // we only need this on admin pages
     // we don't need this in AJAX requests
     if (!is_admin() || defined('DOING_AJAX') && DOING_AJAX) {
         return;
     }
     require_once dirname(__FILE__) . '/class-product-wpseo-woocommerce.php';
     $license_manager = new Yoast_Plugin_License_Manager(new Yoast_Product_WPSEO_WooCommerce());
     $license_manager->setup_hooks();
     return $license_manager;
 }