/** * Hooked into transition_post_status. Will initiate search engine pings * if the post is being published, is a post type that a sitemap is built for * and is a post that is included in sitemaps. * * @param string $new_status New post status. * @param string $old_status Old post status. * @param \WP_Post $post Post object. */ function status_transition($new_status, $old_status, $post) { if ($new_status != 'publish') { return; } wp_cache_delete('lastpostmodified:gmt:' . $post->post_type, 'timeinfo'); // #17455. $options = WPSEO_Options::get_options(array('wpseo_xml', 'wpseo_titles')); if (isset($options['post_types-' . $post->post_type . '-not_in_sitemap']) && $options['post_types-' . $post->post_type . '-not_in_sitemap'] === true || $post->post_type === 'nav_menu_item') { return; } if (WP_CACHE) { wp_schedule_single_event(time() + 300, 'wpseo_hit_sitemap_index'); } /** * Filter: 'wpseo_allow_xml_sitemap_ping' - Check if pinging is not allowed (allowed by default) * * @api boolean $allow_ping The boolean that is set to true by default. */ if (apply_filters('wpseo_allow_xml_sitemap_ping', true) === false) { return; } // Allow the pinging to happen slightly after the hit sitemap index so the sitemap is fully regenerated when the ping happens. $excluded_posts = explode(',', $options['excluded-posts']); if (!in_array($post->ID, $excluded_posts)) { if (defined('YOAST_SEO_PING_IMMEDIATELY') && YOAST_SEO_PING_IMMEDIATELY) { wpseo_ping_search_engines(); } else { wp_schedule_single_event(time() + 300, 'wpseo_ping_search_engines'); } } }
/** * Class constructor */ public function __construct() { $this->options = WPSEO_Options::get_options(array('wpseo', 'wpseo_social')); add_action('wpseo_head', array($this, 'json_ld'), 90); add_action('wpseo_json_ld', array($this, 'website'), 10); add_action('wpseo_json_ld', array($this, 'organization_or_person'), 20); }
/** * Setting the class properties * * @param stdClass $term The current term. * @param array $options The options. */ public function __construct($term, array $options = null) { $this->term = $term; if ($options !== null) { $this->options = $options; } else { $this->options = WPSEO_Options::get_options(array('wpseo_titles', 'wpseo_internallinks', 'wpseo_social')); } }
/** * Create the breadcrumb */ private function __construct() { $this->options = WPSEO_Options::get_options(array('wpseo_titles', 'wpseo_internallinks', 'wpseo_xml')); $this->post = isset($GLOBALS['post']) ? $GLOBALS['post'] : null; $this->show_on_front = get_option('show_on_front'); $this->page_for_posts = get_option('page_for_posts'); $this->filter_element(); $this->filter_separator(); $this->filter_wrapper(); $this->set_crumbs(); $this->prepare_links(); $this->links_to_string(); $this->wrap_breadcrumb(); }
/** * Class constructor */ public function __construct() { add_action('add_meta_boxes', array($this, 'add_meta_box')); add_action('admin_enqueue_scripts', array($this, 'enqueue')); add_action('wp_insert_post', array($this, 'save_postdata')); add_action('edit_attachment', array($this, 'save_postdata')); add_action('add_attachment', array($this, 'save_postdata')); add_action('post_submitbox_start', array($this, 'publish_box')); add_action('admin_init', array($this, 'setup_page_analysis')); add_action('admin_init', array($this, 'translate_meta_boxes')); add_action('admin_footer', array($this, 'template_keyword_tab')); $this->options = WPSEO_Options::get_options(array('wpseo', 'wpseo_social')); // Check if on of the social settings is checked in the options, if so, initialize the social_admin object. if ($this->options['opengraph'] === true || $this->options['twitter'] === true || $this->options['googleplus'] === true) { $this->social_admin = new WPSEO_Social_Admin($this->options); } }
/** * 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(); } } }
/** * Hooked into transition_post_status. Will initiate search engine pings * if the post is being published, is a post type that a sitemap is built for * and is a post that is included in sitemaps. * * @param string $new_status New post status. * @param string $old_status Old post status. * @param \WP_Post $post Post object. */ public function status_transition($new_status, $old_status, $post) { if ($new_status !== 'publish') { return; } if (defined('WP_IMPORTING')) { $this->status_transition_bulk($new_status, $old_status, $post); return; } $post_type = get_post_type($post); wp_cache_delete('lastpostmodified:gmt:' . $post_type, 'timeinfo'); // #17455. // None of our interest.. if ('nav_menu_item' === $post_type) { return; } $options = WPSEO_Options::get_options(array('wpseo_xml', 'wpseo_titles')); // If the post type is excluded in options, we can stop. $option = sprintf('post_types-%s-not_in_sitemap', $post_type); if (isset($options[$option]) && $options[$option] === true) { return; } if (WP_CACHE) { wp_schedule_single_event(time() + 300, 'wpseo_hit_sitemap_index'); } /** * Filter: 'wpseo_allow_xml_sitemap_ping' - Check if pinging is not allowed (allowed by default) * * @api boolean $allow_ping The boolean that is set to true by default. */ if (apply_filters('wpseo_allow_xml_sitemap_ping', true) === false) { return; } // Allow the pinging to happen slightly after the hit sitemap index so the sitemap is fully regenerated when the ping happens. $excluded_posts = explode(',', $options['excluded-posts']); if (!in_array($post->ID, $excluded_posts)) { if (defined('YOAST_SEO_PING_IMMEDIATELY') && YOAST_SEO_PING_IMMEDIATELY) { WPSEO_Sitemaps::ping_search_engines(); } else { wp_schedule_single_event(time() + 300, 'wpseo_ping_search_engines'); } } }
/** * 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'); }
/** * Adds an SEO admin bar menu with several options. If the current user is an admin he can also go straight to several settings menu's from here. */ function wpseo_admin_bar_menu() { // If the current user can't write posts, this is all of no use, so let's not output an admin menu. if (!current_user_can('edit_posts')) { return; } $options = WPSEO_Options::get_options(array('wpseo', 'wpseo_ms')); if ($options['enable_admin_bar_menu'] !== true) { return; } global $wp_admin_bar, $post; // Determine is user is admin or network admin. $user_is_admin_or_networkadmin = current_user_can('manage_options'); if (!$user_is_admin_or_networkadmin && is_multisite()) { $user_is_admin_or_networkadmin = $options['access'] === 'superadmin' && is_super_admin(); } $focuskw = ''; $score = ''; // By default, the top level menu item has no link. $seo_url = ''; // By default, make the no-link top level menu item focusable. $top_level_link_tabindex = '0'; $analysis_seo = new WPSEO_Metabox_Analysis_SEO(); $analysis_readability = new WPSEO_Metabox_Analysis_Readability(); if ((is_singular() || is_admin() && WPSEO_Metabox::is_post_edit($GLOBALS['pagenow'])) && isset($post) && is_object($post) && apply_filters('wpseo_use_page_analysis', true) === true) { $focuskw = WPSEO_Meta::get_value('focuskw', $post->ID); if ($analysis_seo->is_enabled()) { $score = wpseo_adminbar_seo_score(); } elseif ($analysis_readability->is_enabled()) { $score = wpseo_adminbar_content_score(); } } if (is_category() || is_tag() || WPSEO_Taxonomy::is_term_edit($GLOBALS['pagenow']) && !WPSEO_Taxonomy::is_term_overview($GLOBALS['pagenow']) || is_tax()) { if ($analysis_seo->is_enabled()) { $score = wpseo_tax_adminbar_seo_score(); } elseif ($analysis_readability->is_enabled()) { $score = wpseo_tax_adminbar_content_score(); } } // Never display notifications for network admin. $counter = ''; // Set the top level menu item content for admins and network admins. if ($user_is_admin_or_networkadmin) { // Link the top level menu item to the Yoast Dashboard page. $seo_url = get_admin_url(null, 'admin.php?page=' . WPSEO_Admin::PAGE_IDENTIFIER); // Since admins will get a real link, there's no need for a tabindex attribute. $top_level_link_tabindex = false; if ('' === $score) { // Notification information. $notification_center = Yoast_Notification_Center::get(); $notification_count = $notification_center->get_notification_count(); $new_notifications = $notification_center->get_new_notifications(); $new_notifications_count = count($new_notifications); if ($notification_count > 0) { // Always show Alerts page when clicking on the main link. /* translators: %s: number of notifications */ $counter_screen_reader_text = sprintf(_n('%s notification', '%s notifications', $notification_count, 'wordpress-seo'), number_format_i18n($notification_count)); $counter = sprintf(' <div class="wp-core-ui wp-ui-notification yoast-issue-counter"><span aria-hidden="true">%d</span><span class="screen-reader-text">%s</span></div>', $notification_count, $counter_screen_reader_text); } if ($new_notifications_count) { $notification = sprintf(_n('You have a new issue concerning your SEO!', 'You have %d new issues concerning your SEO!', $new_notifications_count, 'wordpress-seo'), $new_notifications_count); $counter .= '<div class="yoast-issue-added">' . $notification . '</div>'; } } } // Yoast Icon. $icon_svg = WPSEO_Utils::get_icon_svg(); $title = '<div id="yoast-ab-icon" class="ab-item yoast-logo svg" style="background-image: url(\'' . $icon_svg . '\');"><span class="screen-reader-text">' . __('SEO', 'wordpress-seo') . '</span></div>'; $wp_admin_bar->add_menu(array('id' => 'wpseo-menu', 'title' => $title . $score . $counter, 'href' => $seo_url, 'meta' => array('tabindex' => $top_level_link_tabindex))); if (!empty($notification_count)) { $wp_admin_bar->add_menu(array('parent' => 'wpseo-menu', 'id' => 'wpseo-notifications', 'title' => __('Notifications', 'wordpress-seo') . $counter, 'href' => $seo_url, 'meta' => array('tabindex' => $top_level_link_tabindex))); } $wp_admin_bar->add_menu(array('parent' => 'wpseo-menu', 'id' => 'wpseo-kwresearch', 'title' => __('Keyword Research', 'wordpress-seo'), 'meta' => array('tabindex' => '0'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-kwresearch', 'id' => 'wpseo-adwordsexternal', 'title' => __('AdWords External', 'wordpress-seo'), 'href' => 'http://adwords.google.com/keywordplanner', 'meta' => array('target' => '_blank'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-kwresearch', 'id' => 'wpseo-googleinsights', 'title' => __('Google Trends', 'wordpress-seo'), 'href' => 'https://www.google.com/trends/explore#q=' . urlencode($focuskw), 'meta' => array('target' => '_blank'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-kwresearch', 'id' => 'wpseo-wordtracker', 'title' => __('SEO Book', 'wordpress-seo'), 'href' => 'http://tools.seobook.com/keyword-tools/seobook/?keyword=' . urlencode($focuskw), 'meta' => array('target' => '_blank'))); if (!is_admin()) { $url = WPSEO_Frontend::get_instance()->canonical(false); if (is_string($url)) { $wp_admin_bar->add_menu(array('parent' => 'wpseo-menu', 'id' => 'wpseo-analysis', 'title' => __('Analyze this page', 'wordpress-seo'), 'meta' => array('tabindex' => '0'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-inlinks-ose', 'title' => __('Check Inlinks (OSE)', 'wordpress-seo'), 'href' => '//moz.com/researchtools/ose/links?site=' . urlencode($url), 'meta' => array('target' => '_blank'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-kwdensity', 'title' => __('Check Keyword Density', 'wordpress-seo'), 'href' => 'http://www.zippy.co.uk/keyworddensity/index.php?url=' . urlencode($url) . '&keyword=' . urlencode($focuskw), 'meta' => array('target' => '_blank'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-cache', 'title' => __('Check Google Cache', 'wordpress-seo'), 'href' => '//webcache.googleusercontent.com/search?strip=1&q=cache:' . urlencode($url), 'meta' => array('target' => '_blank'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-header', 'title' => __('Check Headers', 'wordpress-seo'), 'href' => '//quixapp.com/headers/?r=' . urlencode($url), 'meta' => array('target' => '_blank'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-structureddata', 'title' => __('Google Structured Data Test', 'wordpress-seo'), 'href' => 'https://search.google.com/structured-data/testing-tool#url=' . urlencode($url), 'meta' => array('target' => '_blank'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-facebookdebug', 'title' => __('Facebook Debugger', 'wordpress-seo'), 'href' => '//developers.facebook.com/tools/debug/og/object?q=' . urlencode($url), 'meta' => array('target' => '_blank'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-pinterestvalidator', 'title' => __('Pinterest Rich Pins Validator', 'wordpress-seo'), 'href' => 'https://developers.pinterest.com/tools/url-debugger/?link=' . urlencode($url), 'meta' => array('target' => '_blank'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-htmlvalidation', 'title' => __('HTML Validator', 'wordpress-seo'), 'href' => '//validator.w3.org/check?uri=' . urlencode($url), 'meta' => array('target' => '_blank'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-cssvalidation', 'title' => __('CSS Validator', 'wordpress-seo'), 'href' => '//jigsaw.w3.org/css-validator/validator?uri=' . urlencode($url), 'meta' => array('target' => '_blank'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-pagespeed', 'title' => __('Google Page Speed Test', 'wordpress-seo'), 'href' => '//developers.google.com/speed/pagespeed/insights/?url=' . urlencode($url), 'meta' => array('target' => '_blank'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-microsoftedge', 'title' => __('Microsoft Edge Site Scan', 'wordpress-seo'), 'href' => 'https://developer.microsoft.com/en-us/microsoft-edge/tools/staticscan/?url=' . urlencode($url), 'meta' => array('target' => '_blank'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-google-mobile-friendly', 'title' => __('Mobile-Friendly Test', 'wordpress-seo'), 'href' => 'https://www.google.com/webmasters/tools/mobile-friendly/?url=' . urlencode($url), 'meta' => array('target' => '_blank'))); } } // @todo: add links to bulk title and bulk description edit pages. if ($user_is_admin_or_networkadmin) { $wp_admin_bar->add_menu(array('parent' => 'wpseo-menu', 'id' => 'wpseo-settings', 'title' => __('SEO Settings', 'wordpress-seo'), 'meta' => array('tabindex' => '0'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-general', 'title' => __('Dashboard', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_dashboard'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-titles', 'title' => __('Titles & Metas', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_titles'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-social', 'title' => __('Social', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_social'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-xml', 'title' => __('XML Sitemaps', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_xml'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-wpseo-advanced', 'title' => __('Advanced', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_advanced'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-tools', 'title' => __('Tools', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_tools'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-search-console', 'title' => __('Search Console', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_search_console'))); $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-licenses', 'title' => '<span style="color:#f18500">' . __('Extensions', 'wordpress-seo') . '</span>', 'href' => admin_url('admin.php?page=wpseo_licenses'))); } }
/** * Retrieve the meta box form field definitions for the given tab and post type. * * @static * * @param string $tab Tab for which to retrieve the field definitions. * @param string $post_type Post type of the current post. * * @return array Array containing the meta box field definitions */ public static function get_meta_field_defs($tab, $post_type = 'post') { if (!isset(self::$meta_fields[$tab])) { return array(); } $field_defs = self::$meta_fields[$tab]; switch ($tab) { case 'non-form': // Prevent non-form fields from being passed to forms. $field_defs = array(); break; case 'general': $options = WPSEO_Options::get_option('wpseo_titles'); if ($options['usemetakeywords'] === true) { /* Adjust the link in the keywords description text string based on the post type */ $field_defs['metakeywords']['description'] = sprintf($field_defs['metakeywords']['description'], '<a target="_blank" href="' . esc_url(admin_url('admin.php?page=wpseo_titles#top#post_types')) . '">', '</a>'); } else { /* Don't show the keywords field if keywords aren't enabled */ unset($field_defs['metakeywords']); } /** * Filter the WPSEO metabox form field definitions for the general tab, backward compatibility * * @deprecated 1.5.0 * @deprecated use the 'wpseo_metabox_entries_general' filter instead * @see WPSEO_Meta::get_meta_field_defs() * * @param array $field_defs Metabox orm definitions. * * @return array */ $field_defs = apply_filters('wpseo_metabox_entries', $field_defs); break; case 'advanced': global $post; $options = WPSEO_Options::get_options(array('wpseo', 'wpseo_titles', 'wpseo_internallinks')); if (!current_user_can('manage_options') && $options['disableadvanced_meta']) { return array(); } $post_type = ''; if (isset($post->post_type)) { $post_type = $post->post_type; } elseif (!isset($post->post_type) && isset($_GET['post_type'])) { $post_type = sanitize_text_field($_GET['post_type']); } /* Adjust the no-index 'default for post type' text string based on the post type */ $field_defs['meta-robots-noindex']['options']['0'] = sprintf($field_defs['meta-robots-noindex']['options']['0'], isset($options['noindex-' . $post_type]) && $options['noindex-' . $post_type] === true ? 'noindex' : 'index'); /* Adjust the robots advanced 'site-wide default' text string based on those settings */ if ($options['noodp'] !== false) { $robots_adv = array(); if ($options['noodp'] === true) { // Use translation from field def options - mind that $options and $field_def['options'] keys should be the same! $robots_adv[] = $field_defs['meta-robots-adv']['options']['noodp']; } $robots_adv = implode(', ', $robots_adv); } else { $robots_adv = __('None', 'wordpress-seo'); } $field_defs['meta-robots-adv']['options']['-'] = sprintf($field_defs['meta-robots-adv']['options']['-'], $robots_adv); unset($robots_adv); /* Don't show the breadcrumb title field if breadcrumbs aren't enabled */ if ($options['breadcrumbs-enable'] !== true && !current_theme_supports('yoast-seo-breadcrumbs')) { unset($field_defs['bctitle']); } global $post; if (empty($post->ID) || !empty($post->ID) && self::get_value('redirect', $post->ID) === '') { unset($field_defs['redirect']); } break; } /** * Filter the WPSEO metabox form field definitions for a tab * {tab} can be 'general', 'advanced' or 'social' * * @param array $field_defs Metabox form definitions. * @param string $post_type Post type of the post the metabox is for, defaults to 'post'. * * @return array */ return apply_filters('wpseo_metabox_entries_' . $tab, $field_defs, $post_type); }
/** * On plugins_loaded: load the minimum amount of essential files for this plugin */ function wpseo_init() { require_once WPSEO_PATH . 'inc/wpseo-functions.php'; // Make sure our option and meta value validation routines and default values are always registered and available. WPSEO_Options::get_instance(); WPSEO_Meta::init(); $options = WPSEO_Options::get_options(array('wpseo', 'wpseo_permalinks', 'wpseo_xml')); if (version_compare($options['version'], WPSEO_VERSION, '<')) { new WPSEO_Upgrade(); // Get a cleaned up version of the $options. $options = WPSEO_Options::get_options(array('wpseo', 'wpseo_permalinks', 'wpseo_xml')); } if ($options['stripcategorybase'] === true) { $GLOBALS['wpseo_rewrite'] = new WPSEO_Rewrite(); } if ($options['enablexmlsitemap'] === true) { $GLOBALS['wpseo_sitemaps'] = new WPSEO_Sitemaps(); } if (!defined('DOING_AJAX') || !DOING_AJAX) { require_once WPSEO_PATH . 'inc/wpseo-non-ajax-functions.php'; } // Init it here because the filter must be present on the frontend as well or it won't work in the customizer. new WPSEO_Customizer(); }
/** * @package WPSEO\Admin */ if (!defined('WPSEO_VERSION')) { header('Status: 403 Forbidden'); header('HTTP/1.1 403 Forbidden'); exit; } add_filter('yoast_option_tab_help_center_metas', 'yoast_option_tab_help_center_metas'); add_filter('yoast_option_tab_help_center_metas_general', 'yoast_option_tab_help_center_metas_general'); add_filter('yoast_option_tab_help_center_metas_home', 'yoast_option_tab_help_center_metas_home'); add_filter('yoast_option_tab_help_center_metas_post-types', 'yoast_option_tab_help_center_metas_post_types'); add_filter('yoast_option_tab_help_center_metas_taxonomies', 'yoast_option_tab_help_center_metas_taxonomies'); add_filter('yoast_option_tab_help_center_metas_archives', 'yoast_option_tab_help_center_metas_archives'); add_filter('yoast_option_tab_help_center_metas_other', 'yoast_option_tab_help_center_metas_other'); $options = WPSEO_Options::get_options(array('wpseo_titles', 'wpseo_permalinks', 'wpseo_internallinks')); $yform = Yoast_Form::get_instance(); $yform->admin_header(true, 'wpseo_titles'); $tabs = new WPSEO_Option_Tabs('metas'); $tabs->add_tab(new WPSEO_Option_Tab('general', __('General', 'wordpress-seo'), array('video_url' => 'https://yoa.st/screencast-metas'))); $tabs->add_tab(new WPSEO_Option_Tab('home', __('Homepage', 'wordpress-seo'), array('video_url' => 'https://yoa.st/screencast-metas-homepage'))); $tabs->add_tab(new WPSEO_Option_Tab('post-types', __('Post Types', 'wordpress-seo'), array('video_url' => 'https://yoa.st/screencast-metas-post-types'))); $tabs->add_tab(new WPSEO_Option_Tab('taxonomies', __('Taxonomies', 'wordpress-seo'), array('video_url' => 'https://yoa.st/screencast-metas-taxonomies'))); $tabs->add_tab(new WPSEO_Option_Tab('archives', __('Archives', 'wordpress-seo'), array('video_url' => 'https://yoa.st/screencast-metas-archives'))); $tabs->add_tab(new WPSEO_Option_Tab('other', __('Other', 'wordpress-seo'), array('video_url' => 'https://yoa.st/screencast-metas-other'))); $tabs->display($yform, $options); $yform->admin_footer(); /** * Add help tabs * * @param array $tabs Current help center tabs.
/** * Resets the entire class so canonicals, titles etc can be regenerated. */ public function reset() { foreach (get_class_vars(__CLASS__) as $name => $default) { if ($name == 'instance') { self::$instance = null; } else { $this->{$name} = $default; } } $this->options = WPSEO_Options::get_options($this->required_options); }
/** * Removes stopword from the sample permalink that is generated in an AJAX request * * @param array $permalink The permalink generated for this post by WordPress. * @param int $post_ID The ID of the post. * @param string $title The title for the post that the user used. * @param string $name The name for the post that the user used. * * @return array */ function wpseo_remove_stopwords_sample_permalink($permalink, $post_ID, $title, $name) { WPSEO_Options::get_instance(); $options = WPSEO_Options::get_options(array('wpseo_permalinks')); if ($options['cleanslugs'] !== true) { return $permalink; } /* * If the name is empty and the title is not, WordPress will generate a slug. In that case we want to remove stop * words from the slug. */ if (empty($name) && !empty($title)) { $stop_words = new WPSEO_Admin_Stop_Words(); // The second element is the slug. $permalink[1] = $stop_words->remove_in($permalink[1]); } return $permalink; }
/** * Class constructor */ function __construct() { if (!defined('ENT_XML1')) { define('ENT_XML1', 16); } add_action('after_setup_theme', array($this, 'reduce_query_load'), 99); add_action('pre_get_posts', array($this, 'redirect'), 1); add_filter('redirect_canonical', array($this, 'canonical')); add_action('wpseo_hit_sitemap_index', array($this, 'hit_sitemap_index')); add_filter('wpseo_sitemap_exclude_author', array($this, 'user_sitemap_remove_excluded_authors'), 8); // Default stylesheet. $this->stylesheet = '<?xml-stylesheet type="text/xsl" href="' . preg_replace('/(^http[s]?:)/', '', esc_url(home_url('main-sitemap.xsl'))) . '"?>'; $this->options = WPSEO_Options::get_options(array('wpseo_xml', 'wpseo_titles', 'wpseo_permalinks')); $this->max_entries = $this->options['entries-per-page']; $this->home_url = home_url(); $this->charset = get_bloginfo('charset'); $this->timezone = new WPSEO_Sitemap_Timezone(); }