/**
  * Class constructor
  */
 public function __construct()
 {
     add_action('transition_post_status', array($this, 'status_transition'), 10, 3);
     add_action('admin_footer', array($this, 'status_transition_bulk_finished'));
     add_action('admin_init', array($this, 'delete_sitemaps'));
     WPSEO_Sitemaps_Cache::register_clear_on_option_update('wpseo_xml', '');
 }
Example #2
0
 /**
  * Class constructor
  */
 function __construct()
 {
     global $pagenow;
     $this->options = WPSEO_Options::get_options(array('wpseo', 'wpseo_permalinks'));
     if (is_multisite()) {
         WPSEO_Options::maybe_set_multisite_defaults(false);
     }
     if ($this->options['stripcategorybase'] === true) {
         add_action('created_category', array($this, 'schedule_rewrite_flush'));
         add_action('edited_category', array($this, 'schedule_rewrite_flush'));
         add_action('delete_category', array($this, 'schedule_rewrite_flush'));
     }
     $this->admin_features = array('google_search_console' => new WPSEO_GSC(), 'dashboard_widget' => new Yoast_Dashboard_Widget());
     if (WPSEO_Metabox::is_post_overview($pagenow) || WPSEO_Metabox::is_post_edit($pagenow)) {
         $this->admin_features['primary_category'] = new WPSEO_Primary_Term_Admin();
     }
     if (filter_input(INPUT_GET, 'page') === 'wpseo_tools' && filter_input(INPUT_GET, 'tool') === null) {
         new WPSEO_Recalculate_Scores();
     }
     // Needs the lower than default priority so other plugins can hook underneath it without issue.
     add_action('admin_menu', array($this, 'register_settings_page'), 5);
     add_action('network_admin_menu', array($this, 'register_network_settings_page'));
     add_filter('plugin_action_links_' . WPSEO_BASENAME, array($this, 'add_action_link'), 10, 2);
     add_action('admin_enqueue_scripts', array($this, 'config_page_scripts'));
     add_action('admin_enqueue_scripts', array($this, 'enqueue_global_style'));
     if ($this->options['cleanslugs'] === true) {
         add_filter('name_save_pre', array($this, 'remove_stopwords_from_slug'), 0);
     }
     add_filter('user_contactmethods', array($this, 'update_contactmethods'), 10, 1);
     add_action('after_switch_theme', array($this, 'switch_theme'));
     add_action('switch_theme', array($this, 'switch_theme'));
     add_filter('set-screen-option', array($this, 'save_bulk_edit_options'), 10, 3);
     add_action('admin_init', array('WPSEO_Plugin_Conflict', 'hook_check_for_plugin_conflicts'), 10, 1);
     add_action('admin_init', array($this, 'import_plugin_hooks'));
     add_filter('wpseo_submenu_pages', array($this, 'filter_settings_pages'));
     WPSEO_Sitemaps_Cache::register_clear_on_option_update('wpseo');
     if (WPSEO_Utils::is_yoast_seo_page()) {
         add_action('admin_enqueue_scripts', array($this, 'enqueue_assets'));
     }
     if (WPSEO_Utils::is_api_available()) {
         $configuration = new WPSEO_Configuration_Page();
         if (filter_input(INPUT_GET, 'page') === self::PAGE_IDENTIFIER) {
             $configuration->catch_configuration_request();
         }
     }
 }
Example #3
0
 /**
  * Class constructor
  */
 function __construct()
 {
     global $pagenow;
     $this->options = WPSEO_Options::get_options(array('wpseo', 'wpseo_permalinks'));
     if (is_multisite()) {
         WPSEO_Options::maybe_set_multisite_defaults(false);
     }
     if ($this->options['stripcategorybase'] === true) {
         add_action('created_category', array($this, 'schedule_rewrite_flush'));
         add_action('edited_category', array($this, 'schedule_rewrite_flush'));
         add_action('delete_category', array($this, 'schedule_rewrite_flush'));
     }
     $this->admin_features = array('google_search_console' => new WPSEO_GSC(), 'dashboard_widget' => new Yoast_Dashboard_Widget());
     if (in_array($pagenow, array('post-new.php', 'post.php', 'edit.php'))) {
         $this->admin_features['primary_category'] = new WPSEO_Primary_Term_Admin();
     }
     if (filter_input(INPUT_GET, 'page') === 'wpseo_tools' && filter_input(INPUT_GET, 'tool') === null) {
         new WPSEO_Recalculate_Scores();
     }
     // Needs the lower than default priority so other plugins can hook underneath it without issue.
     add_action('admin_menu', array($this, 'register_settings_page'), 5);
     add_action('network_admin_menu', array($this, 'register_network_settings_page'));
     add_filter('plugin_action_links_' . WPSEO_BASENAME, array($this, 'add_action_link'), 10, 2);
     add_action('admin_enqueue_scripts', array($this, 'config_page_scripts'));
     if ('0' === get_option('blog_public')) {
         add_action('admin_footer', array($this, 'blog_public_warning'));
     }
     if ((isset($this->options['theme_has_description']) && $this->options['theme_has_description'] === true || $this->options['theme_description_found'] !== '') && $this->options['ignore_meta_description_warning'] !== true) {
         add_action('admin_footer', array($this, 'meta_description_warning'));
     }
     if ($this->options['cleanslugs'] === true) {
         add_filter('name_save_pre', array($this, 'remove_stopwords_from_slug'), 0);
     }
     add_filter('user_contactmethods', array($this, 'update_contactmethods'), 10, 1);
     add_action('after_switch_theme', array($this, 'switch_theme'));
     add_action('switch_theme', array($this, 'switch_theme'));
     add_filter('set-screen-option', array($this, 'save_bulk_edit_options'), 10, 3);
     add_action('admin_init', array('WPSEO_Plugin_Conflict', 'hook_check_for_plugin_conflicts'), 10, 1);
     add_action('admin_init', array($this, 'import_plugin_hooks'));
     WPSEO_Sitemaps_Cache::register_clear_on_option_update('wpseo');
 }
Example #4
0
 /**
  * Runs the needed cleanup after an update, setting the DB version to latest version, flushing caches etc.
  */
 private function finish_up()
 {
     $this->options = WPSEO_Options::get_option('wpseo');
     // Re-get to make sure we have the latest version.
     update_option('wpseo', $this->options);
     // This also ensures the DB version is equal to WPSEO_VERSION.
     add_action('shutdown', 'flush_rewrite_rules');
     // Just flush rewrites, always, to at least make them work after an upgrade.
     WPSEO_Sitemaps_Cache::clear();
     // Flush the sitemap cache.
     WPSEO_Options::ensure_options_exist();
     // Make sure all our options always exist - issue #1245.
 }
Example #5
0
 /**
  * Build and save sitemap to cache.
  *
  * @param string $type        Sitemap type.
  * @param int    $page_number The page number to save to.
  *
  * @return bool
  */
 private function refresh_sitemap_cache($type, $page_number)
 {
     $this->set_n($page_number);
     $this->build_sitemap($type);
     return $this->cache->store_sitemap($type, $page_number, $this->sitemap, !$this->bad_sitemap);
 }
 /**
  * Check for relevant post type before invalidation.
  *
  * @param int $post_id Post ID to possibly invalidate for.
  */
 public function save_post($post_id)
 {
     if ($this->is_valid_post_type(get_post_type($post_id))) {
         WPSEO_Sitemaps_Cache::invalidate_post($post_id);
     }
 }
/**
 * Invalidate the XML sitemap cache for a post type when publishing or updating a post
 *
 * @deprecated
 * @see WPSEO_Sitemaps_Cache
 *
 * @param int $post_id Post ID to determine post type for invalidation.
 */
function wpseo_invalidate_sitemap_cache_on_save_post($post_id)
{
    WPSEO_Sitemaps_Cache::invalidate_post($post_id);
}
 /**
  * Invalidate storage for cache types queued to clear.
  */
 public static function clear_queued()
 {
     if (self::$clear_all) {
         WPSEO_Sitemaps_Cache_Validator::invalidate_storage();
         self::$clear_all = false;
         self::$clear_types = array();
         return;
     }
     foreach (self::$clear_types as $type) {
         WPSEO_Sitemaps_Cache_Validator::invalidate_storage($type);
     }
     self::$clear_types = array();
 }
 /**
  * Clear entire XML sitemap cache
  *
  * @deprecated
  * @see WPSEO_Sitemaps_Cache::clear()
  *
  * @param array $types Set of sitemap types to invalidate cache for.
  */
 public static function clear_sitemap_cache($types = array())
 {
     WPSEO_Sitemaps_Cache::clear($types);
 }