예제 #1
1
 /**
  * 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');
         }
     }
 }
예제 #2
0
 /**
  * Get the singleton instance of this class
  *
  * @return object
  */
 public static function get_instance()
 {
     if (!self::$instance instanceof self) {
         self::$instance = new self();
     }
     return self::$instance;
 }
예제 #3
0
    /**
     * Generates the header for admin pages
     *
     * @param bool   $form             Whether or not the form start tag should be included.
     * @param string $option           The short name of the option to use for the current page.
     * @param bool   $contains_files   Whether the form should allow for file uploads.
     * @param bool   $option_long_name Group name of the option.
     */
    public function admin_header($form = true, $option = 'wpseo', $contains_files = false, $option_long_name = false)
    {
        if (!$option_long_name) {
            $option_long_name = WPSEO_Options::get_group_name($option);
        }
        ?>
		<div class="wrap wpseo-admin-page page-<?php 
        echo $option;
        ?>
">
		<?php 
        /**
         * Display the updated/error messages
         * Only needed as our settings page is not under options, otherwise it will automatically be included
         * @see settings_errors()
         */
        require_once ABSPATH . 'wp-admin/options-head.php';
        ?>
		<h1 id="wpseo-title"><?php 
        echo esc_html(get_admin_page_title());
        ?>
</h1>
		<div class="wpseo_content_wrapper">
		<div class="wpseo_content_cell" id="wpseo_content_top">
		<?php 
        if ($form === true) {
            $enctype = $contains_files ? ' enctype="multipart/form-data"' : '';
            echo '<form action="' . esc_url(admin_url('options.php')) . '" method="post" id="wpseo-conf"' . $enctype . ' accept-charset="' . esc_attr(get_bloginfo('charset')) . '">';
            settings_fields($option_long_name);
        }
        $this->set_option($option);
    }
예제 #4
0
 /**
  * Translate text strings for use in the meta box
  *
  * IMPORTANT: if you want to add a new string (option) somewhere, make sure you add that array key to
  * the main meta box definition array in the class WPSEO_Meta() as well!!!!
  */
 public static function translate_meta_boxes()
 {
     /* translators: %s expands to the social network's name */
     $title_text = __('If you don\'t want to use the post title for sharing the post on %s but instead want another title there, write it here.', 'wordpress-seo');
     /* translators: %s expands to the social network's name */
     $description_text = __('If you don\'t want to use the meta description for sharing the post on %s but want another description there, write it here.', 'wordpress-seo');
     /* translators: %s expands to the social network's name */
     $image_text = __('If you want to override the image used on %s for this post, upload / choose an image or add the URL here.', 'wordpress-seo');
     /* translators: %1$s expands to the social network, %2$s to the recommended image size */
     $image_size_text = __('The recommended image size for %1$s is %2$spx.', 'wordpress-seo');
     $options = WPSEO_Options::get_all();
     $social_networks = array('opengraph' => __('Facebook', 'wordpress-seo'), 'twitter' => __('Twitter', 'wordpress-seo'), 'googleplus' => __('Google+', 'wordpress-seo'));
     // Source: https://blog.bufferapp.com/ideal-image-sizes-social-media-posts.
     $recommended_image_sizes = array('opengraph' => '1200 x 628', 'twitter' => '1024 x 512', 'google-plus' => '800 x 1200');
     foreach ($social_networks as $network => $label) {
         if (true === $options[$network]) {
             if ('googleplus' == $network) {
                 $network = 'google-plus';
                 // Yuck, I know.
             }
             self::$meta_fields['social'][$network . '-title']['title'] = sprintf(__('%s Title', 'wordpress-seo'), $label);
             self::$meta_fields['social'][$network . '-title']['description'] = sprintf($title_text, $label);
             self::$meta_fields['social'][$network . '-description']['title'] = sprintf(__('%s Description', 'wordpress-seo'), $label);
             self::$meta_fields['social'][$network . '-description']['description'] = sprintf($description_text, $label);
             self::$meta_fields['social'][$network . '-image']['title'] = sprintf(__('%s Image', 'wordpress-seo'), $label);
             self::$meta_fields['social'][$network . '-image']['description'] = sprintf($image_text, $label) . ' ' . sprintf($image_size_text, $label, $recommended_image_sizes[$network]);
         }
     }
 }
 /**
  * Class constructor
  */
 public function __construct()
 {
     $this->options = WPSEO_Options::get_all();
     $this->shown_images = array();
     // Instantiate as empty array
     $this->twitter();
 }
 /**
  * Get Options
  *
  * @return array
  */
 protected function get_options()
 {
     if (!isset(self::$options)) {
         self::$options = WPSEO_Options::get_all();
     }
     return self::$options;
 }
예제 #7
0
 /**
  * Class constructor.
  */
 public function __construct()
 {
     $this->options = WPSEO_Options::get_all();
     global $fb_ver;
     if (isset($fb_ver) || class_exists('Facebook_Loader')) {
         add_filter('fb_meta_tags', array($this, 'facebook_filter'), 10, 1);
     } else {
         add_filter('language_attributes', array($this, 'add_opengraph_namespace'));
         add_action('wpseo_opengraph', array($this, 'locale'), 1);
         add_action('wpseo_opengraph', array($this, 'type'), 5);
         add_action('wpseo_opengraph', array($this, 'og_title'), 10);
         add_action('wpseo_opengraph', array($this, 'site_owner'), 20);
         add_action('wpseo_opengraph', array($this, 'description'), 11);
         add_action('wpseo_opengraph', array($this, 'url'), 12);
         add_action('wpseo_opengraph', array($this, 'site_name'), 13);
         add_action('wpseo_opengraph', array($this, 'website_facebook'), 14);
         if (is_singular() && !is_front_page()) {
             add_action('wpseo_opengraph', array($this, 'article_author_facebook'), 15);
             add_action('wpseo_opengraph', array($this, 'tags'), 16);
             add_action('wpseo_opengraph', array($this, 'category'), 17);
             add_action('wpseo_opengraph', array($this, 'publish_date'), 19);
         }
         add_action('wpseo_opengraph', array($this, 'image'), 30);
     }
     remove_action('wp_head', 'jetpack_og_tags');
     add_action('wpseo_head', array($this, 'opengraph'), 30);
 }
예제 #8
0
 /**
  * Class constructor
  */
 function __construct()
 {
     $this->options = WPSEO_Options::get_all();
     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->page_gsc = new WPSEO_GSC();
     $this->dashboard_widget = new Yoast_Dashboard_Widget();
     // 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_Utils::register_cache_clear_option('wpseo', '');
 }
예제 #9
0
 /**
  * Class constructor
  */
 public function __construct()
 {
     $this->options = WPSEO_Options::get_option('wpseo_xml');
     $GLOBALS['wpseo_admin'] = new WPSEO_Admin();
     $this->pagenow = $GLOBALS['pagenow'];
     $this->asset_manager = new WPSEO_Admin_Asset_Manager();
     add_action('admin_enqueue_scripts', array($this, 'enqueue_dismissible'));
     add_action('admin_init', array($this, 'tagline_notice'), 15);
     add_action('admin_init', array($this, 'blog_public_notice'), 15);
     add_action('admin_init', array($this, 'permalink_notice'), 15);
     add_action('admin_init', array($this, 'page_comments_notice'), 15);
     add_action('admin_init', array($this, 'ga_compatibility_notice'), 15);
     add_action('admin_init', array($this, 'yoast_plugin_compatibility_notification'), 15);
     add_action('admin_init', array($this, 'recalculate_notice'), 15);
     add_action('admin_init', array($this, 'ignore_tour'));
     add_action('admin_init', array($this, 'load_tour'));
     add_action('admin_init', array($this->asset_manager, 'register_assets'));
     add_action('admin_init', array($this, 'show_hook_deprecation_warnings'));
     add_action('admin_init', array('WPSEO_Plugin_Conflict', 'hook_check_for_plugin_conflicts'));
     $this->load_meta_boxes();
     $this->load_taxonomy_class();
     $this->load_admin_page_class();
     $this->load_admin_user_class();
     $this->load_xml_sitemaps_admin();
 }
 /**
  * Class constructor
  */
 public function __construct()
 {
     $this->options = WPSEO_Options::get_all();
     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);
 }
 /**
  * Determines if the content analysis is active or not.
  *
  * @return bool Whether or not the content analysis is active.
  */
 private function is_content_analysis_active()
 {
     $options = WPSEO_Options::get_option('wpseo_titles');
     if (!$options['content-analysis-active']) {
         return 0;
     }
     return !get_the_author_meta('wpseo_content_analysis_disable', get_current_user_id()) ? 1 : 0;
 }
예제 #12
0
 /**
  * Update the query vars with the redirect var when stripcategorybase is active
  *
  * @param array $query_vars Main query vars to filter.
  *
  * @return array
  */
 function query_vars($query_vars)
 {
     $options = WPSEO_Options::get_all();
     if ($options['stripcategorybase'] === true) {
         $query_vars[] = 'wpseo_category_redirect';
     }
     return $query_vars;
 }
 /**
  * @covers WPSEO_Rewrite::query_vars
  */
 public function test_query_vars()
 {
     $this->assertEquals(array(), self::$class_instance->query_vars(array()));
     $options = WPSEO_Options::get_all();
     $options['stripcategorybase'] = true;
     update_option(WPSEO_Option_Permalinks::get_instance()->option_name, $options);
     $this->assertEquals(array('wpseo_category_redirect'), self::$class_instance->query_vars(array()));
 }
 /**
  * Returns a base URL for use in the JS, takes permalink structure into account
  *
  * @return string
  */
 private function base_url_for_js()
 {
     $base_url = home_url('/', null);
     $options = WPSEO_Options::get_option('wpseo_permalinks');
     if (!$options['stripcategorybase']) {
         $base_url = trailingslashit($base_url . $this->taxonomy->rewrite['slug']);
     }
     return $base_url;
 }
 /**
  * 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'));
     }
 }
 /**
  * Add the inputs needed for SEO values to the User Profile page
  *
  * @param    object $user
  */
 public function user_profile($user)
 {
     if (!current_user_can('edit_users')) {
         return;
     }
     $options = WPSEO_Options::get_all();
     wp_nonce_field('wpseo_user_profile_update', 'wpseo_nonce');
     require_once 'views/user-profile.php';
 }
 /**
  * Set new data
  *
  * @param string $visible Visible (true) or hidden (false).
  *
  * @return bool
  */
 public function set_data($visible)
 {
     $post_type = $this->get_post_type();
     $option = WPSEO_Options::get_option('wpseo_xml');
     $option['post_types-' . $post_type . '-not_in_sitemap'] = $visible === 'false';
     update_option('wpseo_xml', $option);
     // Check if everything got saved properly.
     $saved_option = WPSEO_Options::get_option('wpseo_xml');
     return $visible === 'false' && $saved_option['post_types-' . $post_type . '-not_in_sitemap'] === true;
 }
 /**
  * Set the data in the options.
  *
  * @param {string} $data The data to set for the field.
  *
  * @return bool Returns true or false for successful storing the data.
  */
 public function set_data($data)
 {
     $value = $data === 'yes';
     $option = WPSEO_Options::get_option('wpseo');
     $option['has_multiple_authors'] = $value;
     update_option('wpseo', $option);
     // Check if everything got saved properly.
     $saved_option = WPSEO_Options::get_option('wpseo');
     return $saved_option['has_multiple_authors'] === $option['has_multiple_authors'];
 }
 /**
  * Set the data in the options.
  *
  * @param {string} $data The data to set for the field.
  *
  * @return bool Returns true or false for successful storing the data.
  */
 public function set_data($data)
 {
     $value = $data;
     $option = WPSEO_Options::get_option('wpseo');
     $option['website_name'] = $value;
     update_option('wpseo', $option);
     // Check if everything got saved properly.
     $saved_option = WPSEO_Options::get_option('wpseo');
     return $saved_option['website_name'] === $option['website_name'];
 }
 /**
  * Generates the html for the snippet preview containing dynamically generated text components.
  * Those components are included as properties which are set in the constructor.
  *
  * @param object $post
  * @param string $title
  * @param string $description
  */
 public function __construct($post, $title, $description)
 {
     $this->options = WPSEO_Options::get_all();
     $this->post = $post;
     $this->title = esc_html($title);
     $this->description = esc_html($description);
     $this->set_date();
     $this->set_url();
     $this->set_content();
 }
예제 #21
0
 public function wpseo_translate_options()
 {
     if (defined('WPSEO_VERSION') && !PLL_ADMIN && did_action('wp_loaded')) {
         global $wpseo_front;
         $options = version_compare(WPSEO_VERSION, '1.5', '<') ? get_wpseo_options_arr() : WPSEO_Options::get_option_names();
         foreach ($options as $opt) {
             $wpseo_front->options = array_merge($wpseo_front->options, (array) get_option($opt));
         }
     }
 }
 /**
  * Getting the posts from the database by doing a WP_Query.
  *
  * @param integer $paged The page.
  *
  * @return string
  */
 private function get_posts($paged)
 {
     $post_query = new WP_Query(array_merge($this->query_fields, array('posts_per_page' => $this->posts_per_page, 'paged' => $paged, 'posts' => array())));
     if ($posts = $post_query->get_posts()) {
         $this->options = WPSEO_Options::get_all();
         $parsed_posts = $this->parse_posts($posts);
         $response = array('posts' => $parsed_posts, 'total_posts' => count($parsed_posts), 'next_page' => $paged + 1);
         return json_encode($response);
     }
     return '';
 }
예제 #23
0
function ubik_seo_yoast_twitter_init()
{
    if (is_singular() && class_exists('WPSEO_Options')) {
        $options = WPSEO_Options::get_all();
        if ($options['twitter'] === true) {
            add_action('wpseo_head', 'ubik_seo_yoast_twitter_images', 41);
            add_filter('wpseo_twitter_image', '__return_empty_string');
            // Completely hijack the output; necessary as Yoast's Twitter class privatizes the functions we need access to
        }
    }
}
 /**
  * Set the data in the options.
  *
  * @param {string} $data The data to set for the field.
  *
  * @return bool Returns true or false for successful storing the data.
  */
 public function set_data($data)
 {
     $value = $data === 'yes';
     // Set multiple authors option.
     $result_multiple_authors = WPSEO_Options::save_option('wpseo', 'has_multiple_authors', $value);
     /*
      * Set disable author archives option. When multiple authors is set to true,
      * the disable author option has to be false. Because of this the $value is inversed.
      */
     $result_author_archives = WPSEO_Options::save_option('wpseo_titles', 'disable-author', !$value);
     return $result_multiple_authors === true && $result_author_archives === true;
 }
 /**
  * Clear all the facebook that has been set already
  *
  */
 private function clear_all()
 {
     $this->verify_nonce('fbclearall');
     // Reset to defaults, don't unset as otherwise the old values will be retained
     $this->options['fb_admins'] = WPSEO_Options::get_default('wpseo_social', 'fb_admins');
     $this->save_options();
     $this->success_notice(__('Successfully cleared all Facebook Data', 'wordpress-seo'));
     // Clean up the referrer url for later use
     if (filter_input(INPUT_SERVER, 'REQUEST_URI')) {
         $this->cleanup_referrer_url('nonce', 'fbclearall');
     }
 }
 /**
  * Retrieve all custom field names set in SEO ->
  *
  * @return array
  */
 private function get_custom_field_names()
 {
     $custom_field_names = array();
     $post = $this->get_post();
     $options = get_option(WPSEO_Options::get_option_instance('wpseo_titles')->option_name, array());
     if (is_object($post)) {
         $target_option = 'page-analyse-extra-' . $post->post_type;
         if (array_key_exists($target_option, $options)) {
             $custom_field_names = explode(',', $options[$target_option]);
         }
     }
     return $custom_field_names;
 }
예제 #27
0
 /**
  * Class constructor
  */
 public function __construct()
 {
     $this->options = WPSEO_Options::get_all();
     $GLOBALS['wpseo_admin'] = new WPSEO_Admin();
     $this->pagenow = $GLOBALS['pagenow'];
     $this->load_meta_boxes();
     $this->load_taxonomy_class();
     $this->load_admin_page_class();
     $this->load_admin_user_class();
     $this->load_yoast_tracking();
     $this->load_tour();
     $this->load_xml_sitemaps_admin();
 }
 /**
  * Set new data.
  *
  * @param string $environment_type The site's environment type.
  *
  * @return bool Returns whether the value is successfully set.
  */
 public function set_data($environment_type)
 {
     $option = WPSEO_Options::get_option('wpseo');
     if ($option['environment_type'] !== $environment_type) {
         $option['environment_type'] = $environment_type;
         update_option('wpseo', $option);
         if (!$this->set_indexation($environment_type)) {
             return false;
         }
     }
     $saved_environment_option = WPSEO_Options::get_option('wpseo');
     return $saved_environment_option['environment_type'] === $option['environment_type'];
 }
예제 #29
0
 /**
  * Gets the items to recalculate
  *
  * @param int $paged The current page number.
  *
  * @return array Items that can be recalculated.
  */
 public function get_items_to_recalculate($paged)
 {
     $return = array();
     $paged = abs($paged);
     $this->options = WPSEO_Options::get_all();
     $items = $this->get_items($paged);
     $return['items'] = $this->parse_items($items);
     $return['total_items'] = count($items);
     if ($return['total_items'] >= $this->items_per_page) {
         $return['next_page'] = $paged + 1;
     }
     return $return;
 }
 /**
  * Create the breadcrumb
  */
 private function __construct()
 {
     $this->options = WPSEO_Options::get_all();
     $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();
 }