Example #1
0
 /**
  * Run the Yoast SEO 1.5 upgrade routine
  *
  * @param string $version Current plugin version.
  */
 private function upgrade_15($version)
 {
     // Clean up options and meta.
     WPSEO_Options::clean_up(null, $version);
     WPSEO_Meta::clean_up();
     // Add new capabilities on upgrade.
     wpseo_add_capabilities();
 }
 /**
  * Helper function to check if the metabox functionality should be loaded
  *
  * @return bool
  */
 public function has_video()
 {
     if (isset($GLOBALS['post']->ID)) {
         $video = WPSEO_Meta::get_value('video_meta', $GLOBALS['post']->ID);
         if (is_array($video) && $video !== array()) {
             return true;
         }
     }
     return false;
 }
Example #3
0
 /**
  * Getting the wpSEO robot value and map this to Yoast SEO values.
  *
  * @param integer $post_id The post id of the current post.
  */
 private function import_post_robot($post_id)
 {
     $wpseo_robots = get_post_meta($post_id, '_wpseo_edit_robots', true);
     // Does the value exists in our mapping.
     if ($robot_value = $this->get_robot_value($wpseo_robots)) {
         // Saving the new meta values for Yoast SEO.
         WPSEO_Meta::set_value($robot_value['index'], 'meta-robots-noindex', $post_id);
         WPSEO_Meta::set_value($robot_value['follow'], 'meta-robots-nofollow', $post_id);
     }
     $this->delete_post_robot($post_id);
 }
 /**
  * Output the Google+ specific description
  */
 public function description()
 {
     if (is_singular()) {
         $desc = WPSEO_Meta::get_value('google-plus-description');
         /**
          * Filter: 'wpseo_googleplus_desc' - Allow developers to change the Google+ specific description output
          *
          * @api string $desc The description string
          */
         $desc = apply_filters('wpseo_googleplus_desc', $desc);
         if (is_string($desc) && '' !== $desc) {
             echo '<meta itemprop="description" content="' . $desc . '">' . "\n";
         }
     }
 }
Example #5
0
/**
 * Display post description for Open Graph and Twitter card
 * 
 * @return string A description text of post
 *
 * @todo Sanitize $excerpt http://codex.wordpress.org/Function_Reference/sanitize_text_field
 */
function italystrap_open_graph_desc()
{
    global $post;
    if (function_exists('aioseop_load_modules')) {
        $excerpt = get_post_meta($post->ID, '_aioseop_description', true);
    } else {
        if (class_exists('WPSEO_Meta')) {
            $excerpt = WPSEO_Meta::get_value('metadesc');
        } else {
            if ($post->post_excerpt) {
                $excerpt = trim(str_replace(array("\n", "\r", "\t"), ' ', substr(strip_tags($post->post_excerpt), 0, 200)));
            } else {
                $excerpt = trim(str_replace(array("\n", "\r", "\t", "[", "]", "\""), ' ', substr(strip_tags($post->post_content), 0, 200))) . ' ...';
            }
        }
    }
    echo $excerpt;
}
 /**
  * @covers WPSEO_GooglePlus::description
  */
 public function test_description()
 {
     self::$class_instance->description();
     $this->expectOutput('');
     // create and go to post
     $post_id = $this->factory->post->create();
     $this->go_to(get_permalink($post_id));
     // should be empty, didn't set google-plus-description
     self::$class_instance->description();
     $this->expectOutput('');
     // set meta
     $description = 'Google description';
     WPSEO_Meta::set_value('google-plus-description', $description, $post_id);
     // test output
     $expected = '<meta itemprop="description" content="' . $description . '">' . "\n";
     self::$class_instance->description();
     $this->expectOutput($expected);
 }
 /**
  * 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.
  */
 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_all();
     if (isset($options['post_types-' . $post->post_type . '-not_in_sitemap']) && $options['post_types-' . $post->post_type . '-not_in_sitemap'] === true) {
         return;
     }
     if (WP_CACHE) {
         wp_schedule_single_event(time() + 300, 'wpseo_hit_sitemap_index');
     }
     // Allow the pinging to happen slightly after the hit sitemap index so the sitemap is fully regenerated when the ping happens.
     if (WPSEO_Meta::get_value('sitemap-include', $post->ID) !== 'never') {
         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');
         }
     }
 }
 /**
  * If opengraph-image is set, call add_image and return true
  *
  * @return bool
  */
 private function get_opengraph_image()
 {
     $ogimg = WPSEO_Meta::get_value('opengraph-image');
     if ($ogimg !== '') {
         $this->add_image($ogimg);
         return true;
     }
 }
Example #9
0
     $posts = $wpdb->get_results("SELECT ID, robotsmeta FROM {$wpdb->posts}");
     if (is_array($posts) && $posts !== array()) {
         foreach ($posts as $post) {
             // sync all possible settings
             if ($post->robotsmeta) {
                 $pieces = explode(',', $post->robotsmeta);
                 foreach ($pieces as $meta) {
                     switch ($meta) {
                         case 'noindex':
                             WPSEO_Meta::set_value('meta-robots-noindex', '1', $post->ID);
                             break;
                         case 'index':
                             WPSEO_Meta::set_value('meta-robots-noindex', '2', $post->ID);
                             break;
                         case 'nofollow':
                             WPSEO_Meta::set_value('meta-robots-nofollow', '1', $post->ID);
                             break;
                     }
                 }
             }
         }
     }
     unset($posts, $post, $pieces, $meta);
     $msg .= __(sprintf('Robots Meta values imported. We recommend %sdisabling the Robots-Meta plugin%s to avoid any conflicts.', '<a href="' . esc_url(admin_url('admin.php?page=wpseo_import&deactivate_robots_meta=1')) . '">', '</a>'), 'wordpress-seo');
 }
 if (isset($_POST['wpseo']['importrssfooter'])) {
     $optold = get_option('RSSFooterOptions');
     $optnew = get_option('wpseo_rss');
     if ($optold['position'] == 'after') {
         if ($optnew['rssafter'] === '' || $optnew['rssafter'] === WPSEO_Options::get_default('wpseo_rss', 'rssafter')) {
             $optnew['rssafter'] = $optold['footerstring'];
 /**
  * Retrieve link url and text based on post id
  *
  * @param	int		$id		Post id
  *
  * @return	array	$link	Array of link text and url
  */
 private function get_link_info_for_id($id)
 {
     $link = array();
     $link['url'] = get_permalink($id);
     $link['text'] = WPSEO_Meta::get_value('bctitle', $id);
     if ($link['text'] === '') {
         $link['text'] = strip_tags(get_the_title($id));
     }
     /**
      * Filter: 'wp_seo_get_bc_title' - Allow developer to filter the WP SEO Breadcrumb title.
      *
      * @api string $link_text The Breadcrumb title text
      *
      * @param int $link_id The post ID
      */
     $link['text'] = apply_filters('wp_seo_get_bc_title', $link['text'], $id);
     return $link;
 }
 /**
  * Register our actions and filters
  *
  * @static
  * @return void
  */
 public static function init()
 {
     $options = WPSEO_Options::get_all();
     foreach (array('opengraph' => 'opengraph', 'twitter' => 'twitter', 'googleplus' => 'google-plus') as $option => $network) {
         if (true === $options[$option]) {
             foreach (array('title' => 'text', 'description' => 'textarea', 'image' => 'upload') as $box => $type) {
                 self::$meta_fields['social'][$network . '-' . $box] = array('type' => $type, 'title' => '', 'default_value' => '', 'description' => '');
             }
         }
     }
     /**
      * Allow add-on plugins to register their meta fields for management by this class
      * add_filter() calls must be made before plugins_loaded prio 14
      */
     $extra_fields = apply_filters('add_extra_wpseo_meta_fields', array());
     if (is_array($extra_fields)) {
         self::$meta_fields = self::array_merge_recursive_distinct($extra_fields, self::$meta_fields);
     }
     $register = function_exists('register_meta');
     foreach (self::$meta_fields as $subset => $field_group) {
         foreach ($field_group as $key => $field_def) {
             if ($field_def['type'] !== 'snippetpreview') {
                 /* register_meta() is undocumented and not used by WP internally, wrapped in
                    function_exists as a precaution in case they remove it. */
                 if ($register === true) {
                     register_meta('post', self::$meta_prefix . $key, array(__CLASS__, 'sanitize_post_meta'));
                 } else {
                     add_filter('sanitize_post_meta_' . self::$meta_prefix . $key, array(__CLASS__, 'sanitize_post_meta'), 10, 2);
                 }
                 // Set the $fields_index property for efficiency
                 self::$fields_index[self::$meta_prefix . $key] = array('subset' => $subset, 'key' => $key);
                 // Set the $defaults property for efficiency
                 if (isset($field_def['default_value'])) {
                     self::$defaults[self::$meta_prefix . $key] = $field_def['default_value'];
                 } else {
                     // meta will always be a string, so let's make the meta meta default also a string
                     self::$defaults[self::$meta_prefix . $key] = '';
                 }
             }
         }
     }
     add_filter('update_post_metadata', array(__CLASS__, 'remove_meta_if_default'), 10, 5);
     add_filter('add_post_metadata', array(__CLASS__, 'dont_save_meta_if_default'), 10, 4);
 }
/**
 * 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;
    }
    global $wp_admin_bar, $post;
    $focuskw = '';
    $score = '';
    $seo_url = get_admin_url(null, 'admin.php?page=wpseo_dashboard');
    if ((is_singular() || is_admin() && in_array($GLOBALS['pagenow'], array('post.php', 'post-new.php'), true)) && isset($post) && is_object($post) && apply_filters('wpseo_use_page_analysis', true) === true) {
        $focuskw = WPSEO_Meta::get_value('focuskw', $post->ID);
        $perc_score = WPSEO_Meta::get_value('linkdex', $post->ID);
        $txtscore = WPSEO_Utils::translate_score($perc_score);
        $title = WPSEO_Utils::translate_score($perc_score, false);
        $score = '<div title="' . esc_attr($title) . '" class="' . esc_attr('wpseo-score-icon ' . $txtscore . ' ' . $perc_score) . ' adminbar-seo-score' . '"></div>';
        $seo_url = get_edit_post_link($post->ID);
    }
    $wp_admin_bar->add_menu(array('id' => 'wpseo-menu', 'title' => __('SEO', 'wordpress-seo') . $score, 'href' => $seo_url));
    $wp_admin_bar->add_menu(array('parent' => 'wpseo-menu', 'id' => 'wpseo-kwresearch', 'title' => __('Keyword Research', 'wordpress-seo'), '#'));
    $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 Insights', 'wordpress-seo'), 'href' => 'http://www.google.com/insights/search/#q=' . urlencode($focuskw) . '&cmpt=q', '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'), '#'));
            $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' => '//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-richsnippets', 'title' => __('Check Rich Snippets', 'wordpress-seo'), 'href' => '//www.google.com/webmasters/tools/richsnippets?q=' . 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' => '//developers.pinterest.com/rich_pins/validator/?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-modernie', 'title' => __('Modern IE Site Scan', 'wordpress-seo'), 'href' => '//www.modern.ie/en-us/report#' . 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')));
        }
    }
    $admin_menu = current_user_can('manage_options');
    if (!$admin_menu && is_multisite()) {
        $options = get_site_option('wpseo_ms');
        $admin_menu = $options['access'] === 'superadmin' && is_super_admin();
    }
    // @todo: add links to bulk title and bulk description edit pages.
    if ($admin_menu) {
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-menu', 'id' => 'wpseo-settings', 'title' => __('SEO Settings', 'wordpress-seo')));
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-general', 'title' => __('General', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_dashboard')));
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-titles', 'title' => __('Titles &amp; 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')));
    }
}
/**
 * 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;
    }
    global $wp_admin_bar, $post;
    $url = WPSEO_Frontend::get_instance()->canonical(false);
    $focuskw = '';
    $score = '';
    $seo_url = get_admin_url(null, 'admin.php?page=wpseo_dashboard');
    if ((is_singular() || is_admin() && in_array($GLOBALS['pagenow'], array('post.php', 'post-new.php'), true)) && isset($post) && is_object($post) && apply_filters('wpseo_use_page_analysis', true) === true) {
        $focuskw = WPSEO_Meta::get_value('focuskw', $post->ID);
        $perc_score = WPSEO_Meta::get_value('linkdex', $post->ID);
        $calc_score = WPSEO_Utils::calc($perc_score, '/', 10, true);
        $txtscore = WPSEO_Utils::translate_score($calc_score);
        $title = WPSEO_Utils::translate_score($calc_score, false);
        $score = '<div title="' . esc_attr($title) . '" class="' . esc_attr('wpseo-score-icon ' . $txtscore . ' ' . $perc_score) . '"></div>';
        $seo_url = get_edit_post_link($post->ID);
        if ($txtscore !== 'na') {
            $seo_url .= '#wpseo_linkdex';
        }
    }
    $wp_admin_bar->add_menu(array('id' => 'wpseo-menu', 'title' => __('SEO', 'wordpress-seo') . $score, 'href' => $seo_url));
    $wp_admin_bar->add_menu(array('parent' => 'wpseo-menu', 'id' => 'wpseo-kwresearch', 'title' => __('Keyword Research', 'wordpress-seo'), '#'));
    $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 Insights', 'wordpress-seo'), 'href' => 'http://www.google.com/insights/search/#q=' . urlencode($focuskw) . '&cmpt=q', '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()) {
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-menu', 'id' => 'wpseo-analysis', 'title' => __('Analyze this page', 'wordpress-seo'), '#'));
        if (is_string($url)) {
            // @todo [JRF => whomever] check if this url shouldn't be encoded either with urlencode or with esc_url or something
            $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' => '//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-richsnippets', 'title' => __('Check Rich Snippets', 'wordpress-seo'), 'href' => '//www.google.com/webmasters/tools/richsnippets?q=' . 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' => '//developers.pinterest.com/rich_pins/validator/?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-modernie', 'title' => __('Modern IE Site Scan', 'wordpress-seo'), 'href' => '//www.modern.ie/en-us/report#' . urlencode($url), 'meta' => array('target' => '_blank')));
        }
    }
    $admin_menu = false;
    if (is_multisite()) {
        $options = get_site_option('wpseo_ms');
        if ($options['access'] === 'superadmin' && is_super_admin()) {
            $admin_menu = true;
        } elseif (current_user_can('manage_options')) {
            $admin_menu = true;
        }
    } elseif (current_user_can('manage_options')) {
        $admin_menu = true;
    }
    // @todo: add links to bulk title and bulk description edit pages
    if ($admin_menu) {
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-menu', 'id' => 'wpseo-settings', 'title' => __('SEO Settings', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_titles')));
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-titles', 'title' => __('Titles &amp; 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-permalinks', 'title' => __('Permalinks', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_permalinks')));
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-internal-links', 'title' => __('Internal Links', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_internal-links')));
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-rss', 'title' => __('RSS', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_rss')));
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-import', 'title' => esc_html__('Import & Export', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_import')));
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo_bulk-editor', 'title' => __('Bulk Editor', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_bulk-editor')));
        // Check where to add the edit files page
        if (WPSEO_Utils::allow_system_file_edit() === true) {
            $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-files', 'title' => __('Edit Files', 'wordpress-seo'), 'href' => network_admin_url('admin.php?page=wpseo_files')));
            // will auto-use admin_url if not in multi-site
        }
        $wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-licenses', 'title' => __('Extensions', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_licenses')));
    }
}
 /**
  * Import All In One SEO meta values
  */
 private function import_metas()
 {
     WPSEO_Meta::replace_meta('_aioseop_description', WPSEO_Meta::$meta_prefix . 'metadesc', $this->replace);
     WPSEO_Meta::replace_meta('_aioseop_keywords', WPSEO_Meta::$meta_prefix . 'metakeywords', $this->replace);
     WPSEO_Meta::replace_meta('_aioseop_title', WPSEO_Meta::$meta_prefix . 'title', $this->replace);
 }
 /**
  * Retrieve the post/page/cpt's focus keyword for use as replacement string.
  *
  * @return string|null
  */
 private function retrieve_focuskw()
 {
     $replacement = null;
     if (!empty($this->args->ID)) {
         $focus_kw = WPSEO_Meta::get_value('focuskw', $this->args->ID);
         if ($focus_kw !== '') {
             $replacement = $focus_kw;
         }
     }
     return $replacement;
 }
 /**
  * Test default value returned when non-existant $_POST key supplied
  * @covers WPSEO_Meta::get_post_value
  */
 public function test_get_post_value_default()
 {
     $this->assertEquals('', WPSEO_Meta::get_post_value('my_missing_test_key'));
 }
 /**
  * Defines the meta box inputs
  *
  * @since      0.1
  * @deprecated 1.6.0
  * @deprecated use WPSEO_Meta::get_meta_field_defs()
  * @see        WPSEO_Meta::get_meta_field_defs()
  *
  * @param string $post_type The current post type
  *
  * @return array            Meta box inputs
  */
 public function get_meta_boxes($post_type = 'post')
 {
     _deprecated_function(__METHOD__, 'Video SEO 1.6.0', 'WPSEO_Meta::get_meta_field_defs()');
     return WPSEO_Meta::get_meta_field_defs('video', $post_type);
 }
 /**
  * Output the OpenGraph description, specific OG description first, if not, grab the meta description.
  *
  * @param bool $echo Whether to echo or return the description
  *
  * @return string $ogdesc
  */
 public function description($echo = true)
 {
     $ogdesc = '';
     if (is_front_page()) {
         $ogdesc = $this->options['og_frontpage_desc'] !== '' ? $this->options['og_frontpage_desc'] : $this->metadesc(false);
     }
     if (is_singular()) {
         $ogdesc = WPSEO_Meta::get_value('opengraph-description');
         // Replace WP SEO Variables
         $ogdesc = wpseo_replace_vars($ogdesc, get_post());
         // Use metadesc if $ogdesc is empty
         if ($ogdesc === '') {
             $ogdesc = $this->metadesc(false);
         }
         // og:description is still blank so grab it from get_the_excerpt()
         if (!is_string($ogdesc) || is_string($ogdesc) && $ogdesc === '') {
             $ogdesc = str_replace('[&hellip;]', '&hellip;', strip_tags(get_the_excerpt()));
         }
     }
     if (is_category() || is_tag() || is_tax()) {
         $ogdesc = trim(strip_tags(term_description()));
     }
     // Strip shortcodes if any
     $ogdesc = strip_shortcodes($ogdesc);
     /**
      * Filter: 'wpseo_opengraph_desc' - Allow changing the OpenGraph description
      *
      * @api string $ogdesc The description string.
      */
     $ogdesc = apply_filters('wpseo_opengraph_desc', $ogdesc);
     if (is_string($ogdesc) && $ogdesc !== '') {
         if ($echo !== false) {
             $this->og_tag('og:description', $ogdesc);
         }
     }
     return $ogdesc;
 }
/**
 * 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();
}
Example #20
0
bloginfo('template_directory');
?>
/favicon/apple-touch-icon-72x72.png">
	<link rel="apple-touch-icon" sizes="114x114" href="<?php 
bloginfo('template_directory');
?>
/favicon/apple-touch-icon-114x114.png">
	
	<!-- Facebook open graph tags -->
	<meta property="og:title" content="<?php 
the_title();
?>
"/>
	<meta property="og:description" content="<?php 
if (function_exists('WPSEO_Meta::get_value()')) {
    echo WPSEO_Meta::get_value('metadesc');
} else {
    echo $post->post_excerpt;
}
?>
"/>

	<?php 
if (have_posts()) {
    while (have_posts()) {
        the_post();
    }
}
?>
		<meta property="fb:app_id" content="496408310403833" />
	<?php 
/**
 * Used for imports, both in dashboard and import settings pages, this functions either copies
 * $old_metakey into $new_metakey or just plain replaces $old_metakey with $new_metakey
 *
 * @deprecated 1.5.0
 * @deprecated use WPSEO_Meta::replace_meta()
 * @see        WPSEO_Meta::replace_meta()
 *
 * @param string $old_metakey The old name of the meta value.
 * @param string $new_metakey The new name of the meta value, usually the WP SEO name.
 * @param bool   $replace     Whether to replace or to copy the values.
 */
function replace_meta($old_metakey, $new_metakey, $replace = false)
{
    _deprecated_function(__FUNCTION__, 'WPSEO 1.5.0', 'WPSEO_Meta::replace_meta()');
    WPSEO_Meta::replace_meta($old_metakey, $new_metakey, $replace);
}
 /**
  * Displays the image for Twitter
  *
  * Only used when OpenGraph is inactive or Summary Large Image card is chosen.
  */
 public function image()
 {
     global $post;
     if (is_singular()) {
         if (is_front_page()) {
             if ($this->options['og_frontpage_image'] !== '') {
                 $this->image_output($this->options['og_frontpage_image']);
             }
         }
         $twitter_img = WPSEO_Meta::get_value('twitter-image');
         if ($twitter_img !== '') {
             $this->image_output($twitter_img);
             return;
         } elseif (function_exists('has_post_thumbnail') && has_post_thumbnail($post->ID)) {
             /**
              * Filter: 'wpseo_twitter_image_size' - Allow changing the Twitter Card image size
              *
              * @api string $featured_img Image size string
              */
             $featured_img = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), apply_filters('wpseo_twitter_image_size', 'full'));
             if ($featured_img) {
                 $this->image_output($featured_img[0]);
             }
         } elseif (preg_match_all('`<img [^>]+>`', $post->post_content, $matches)) {
             foreach ($matches[0] as $img) {
                 if (preg_match('`src=(["\'])(.*?)\\1`', $img, $match)) {
                     $this->image_output($match[2]);
                 }
             }
         }
     }
     if (count($this->shown_images) == 0 && $this->options['og_default_image'] !== '') {
         $this->image_output($this->options['og_default_image']);
     }
 }
Example #23
0
 /**
  * Counting the number of given keyword used for other posts than given post_id
  *
  * @return array
  */
 private function get_focus_keyword_usage()
 {
     $post = $this->get_metabox_post();
     if (is_object($post)) {
         $keyword = WPSEO_Meta::get_value('focuskw', $post->ID);
         return array($keyword => WPSEO_Meta::keyword_usage($keyword, $post->ID));
     }
     return array();
 }
/**
 * Returns the content score element for the adminbar.
 *
 * @return string
 */
function wpseo_adminbar_content_score()
{
    $rating = WPSEO_Meta::get_value('content_score', get_the_ID());
    return wpseo_adminbar_score($rating);
}
 /**
  * Import from Joost's old robots meta plugin
  */
 public function import_robots_meta()
 {
     global $wpdb;
     $posts = $wpdb->get_results("SELECT ID, robotsmeta FROM {$wpdb->posts}");
     if (!$posts) {
         $this->set_msg(__('Error: no Robots Meta data found to import.', 'wordpress-seo'));
         return;
     }
     if (is_array($posts) && $posts !== array()) {
         foreach ($posts as $post) {
             // sync all possible settings
             if ($post->robotsmeta) {
                 $pieces = explode(',', $post->robotsmeta);
                 foreach ($pieces as $meta) {
                     switch ($meta) {
                         case 'noindex':
                             WPSEO_Meta::set_value('meta-robots-noindex', '1', $post->ID);
                             break;
                         case 'index':
                             WPSEO_Meta::set_value('meta-robots-noindex', '2', $post->ID);
                             break;
                         case 'nofollow':
                             WPSEO_Meta::set_value('meta-robots-nofollow', '1', $post->ID);
                             break;
                     }
                 }
             }
         }
     }
     $this->set_msg(__(sprintf('Robots Meta values imported. We recommend %sdisabling the Robots-Meta plugin%s to avoid any conflicts.', '<a href="' . esc_url(admin_url('admin.php?page=wpseo_tools&tool=import-export&deactivate_robots_meta=1#top#import-other')) . '">', '</a>'), 'wordpress-seo'));
 }
 /**
  * WP SEO meta key.
  *
  * Hooked into wpseo_ hook already, so no need for function_exist.
  *
  * @access public
  * @return string
  */
 public function wpseo_metakey()
 {
     return WPSEO_Meta::get_value('metakey', wc_get_page_id('shop'));
 }
 /**
  * Retrieve images from the post meta values
  *
  * @return bool
  */
 private function image_from_meta_values_output()
 {
     foreach (array('twitter-image', 'opengraph-image') as $tag) {
         $img = WPSEO_Meta::get_value($tag);
         if ($img !== '') {
             $this->image_output($img);
             return true;
         }
     }
     return false;
 }
Example #28
0
 /**
  * Build a sub-sitemap for a specific post type -- example.com/post_type-sitemap.xml
  *
  * @param string $post_type Registered post type's slug
  */
 function build_post_type_map($post_type)
 {
     global $wpdb;
     if (isset($this->options['post_types-' . $post_type . '-not_in_sitemap']) && $this->options['post_types-' . $post_type . '-not_in_sitemap'] === true || in_array($post_type, array('revision', 'nav_menu_item')) || apply_filters('wpseo_sitemap_exclude_post_type', false, $post_type)) {
         $this->bad_sitemap = true;
         return;
     }
     $output = '';
     $steps = 25 > $this->max_entries ? $this->max_entries : 25;
     $n = (int) $this->n;
     $offset = $n > 1 ? ($n - 1) * $this->max_entries : 0;
     $total = $offset + $this->max_entries;
     $join_filter = '';
     $join_filter = apply_filters('wpseo_typecount_join', $join_filter, $post_type);
     $where_filter = '';
     $where_filter = apply_filters('wpseo_typecount_where', $where_filter, $post_type);
     $query = $wpdb->prepare("SELECT COUNT(ID) FROM {$wpdb->posts} {$join_filter} WHERE post_status IN ('publish','inherit') AND post_password = '' AND post_type = %s " . $where_filter, $post_type);
     $typecount = $wpdb->get_var($query);
     if ($total > $typecount) {
         $total = $typecount;
     }
     if ($n == 1) {
         $front_id = get_option('page_on_front');
         if (!$front_id && ($post_type == 'post' || $post_type == 'page')) {
             $output .= $this->sitemap_url(array('loc' => $this->home_url, 'pri' => 1, 'chf' => $this->filter_frequency('homepage', 'daily', $this->home_url)));
         } else {
             if ($front_id && $post_type == 'post') {
                 $page_for_posts = get_option('page_for_posts');
                 if ($page_for_posts) {
                     $page_for_posts_url = get_permalink($page_for_posts);
                     $output .= $this->sitemap_url(array('loc' => $page_for_posts_url, 'pri' => 1, 'chf' => $change_freq = $this->filter_frequency('blogpage', 'daily', $page_for_posts_url)));
                 }
             }
         }
         $archive = get_post_type_archive_link($post_type);
         if ($archive) {
             $output .= $this->sitemap_url(array('loc' => $archive, 'pri' => 0.8, 'chf' => $this->filter_frequency($post_type . '_archive', 'weekly', $archive), 'mod' => $this->get_last_modified($post_type)));
         }
     }
     if ($typecount == 0 && empty($archive)) {
         $this->bad_sitemap = true;
         return;
     }
     $stackedurls = array();
     // Make sure you're wpdb->preparing everything you throw into this!!
     $join_filter = apply_filters('wpseo_posts_join', false, $post_type);
     $where_filter = apply_filters('wpseo_posts_where', false, $post_type);
     $status = $post_type == 'attachment' ? 'inherit' : 'publish';
     /**
      * We grab post_date, post_name, post_author and post_status too so we can throw these objects
      * into get_permalink, which saves a get_post call for each permalink.
      */
     while ($total > $offset) {
         // Optimized query per this thread: http://wordpress.org/support/topic/plugin-wordpress-seo-by-yoast-performance-suggestion
         // Also see http://explainextended.com/2009/10/23/mysql-order-by-limit-performance-late-row-lookups/
         $query = $wpdb->prepare("\n\t\t\t\t\tSELECT l.ID, post_content, post_name, post_author, post_parent, post_modified_gmt,\n\t\t\t\t\t\tpost_date, post_date_gmt\n\t\t\t\t\tFROM (\n\t\t\t\t\t\tSELECT ID FROM {$wpdb->posts} {$join_filter}\n\t\t\t\t\t\t\tWHERE post_status = '%s'\n\t\t\t\t\t\t\tAND\tpost_password = ''\n\t\t\t\t\t\t\tAND post_type = '%s'\n\t\t\t\t\t\t\t{$where_filter}\n\t\t\t\t\t\t\tORDER BY post_modified ASC\n\t\t\t\t\t\t\tLIMIT %d OFFSET %d ) o\n\t\t\t\t\t\tJOIN {$wpdb->posts} l\n\t\t\t\t\t\tON l.ID = o.ID\n\t\t\t\t\t\tORDER BY l.ID\n\t\t\t\t\t", $status, $post_type, $steps, $offset);
         $posts = $wpdb->get_results($query);
         $offset = $offset + $steps;
         if (is_array($posts) && $posts !== array()) {
             foreach ($posts as $p) {
                 $p->post_type = $post_type;
                 $p->post_status = 'publish';
                 $p->filter = 'sample';
                 if (WPSEO_Meta::get_value('meta-robots-noindex', $p->ID) === '1' && WPSEO_Meta::get_value('sitemap-include', $p->ID) !== 'always') {
                     continue;
                 }
                 if (WPSEO_Meta::get_value('sitemap-include', $p->ID) === 'never') {
                     continue;
                 }
                 if (WPSEO_Meta::get_value('redirect', $p->ID) !== '') {
                     continue;
                 }
                 $url = array();
                 $url['mod'] = isset($p->post_modified_gmt) && $p->post_modified_gmt != '0000-00-00 00:00:00' && $p->post_modified_gmt > $p->post_date_gmt ? $p->post_modified_gmt : $p->post_date_gmt;
                 $url['loc'] = get_permalink($p);
                 /**
                  * Filter: 'wpseo_xml_sitemap_post_url' - Allow changing the URL WordPress SEO uses in the XML sitemap.
                  *
                  * Note that only absolute local URLs are allowed as the check after this removes external URLs.
                  *
                  * @api string $url URL to use in the XML sitemap
                  *
                  * @param object $p Post object for the URL
                  */
                 $url['loc'] = apply_filters('wpseo_xml_sitemap_post_url', $url['loc'], $p);
                 $url['chf'] = $this->filter_frequency($post_type . '_single', 'weekly', $url['loc']);
                 /**
                  * Do not include external URLs.
                  * @see https://wordpress.org/plugins/page-links-to/ can rewrite permalinks to external URLs.
                  */
                 if (false === strpos($url['loc'], $this->home_url)) {
                     continue;
                 }
                 $canonical = WPSEO_Meta::get_value('canonical', $p->ID);
                 if ($canonical !== '' && $canonical !== $url['loc']) {
                     /* Let's assume that if a canonical is set for this page and it's different from
                        the URL of this post, that page is either already in the XML sitemap OR is on
                        an external site, either way, we shouldn't include it here. */
                     continue;
                 } else {
                     if ($this->options['trailingslash'] === true && $p->post_type != 'post') {
                         $url['loc'] = trailingslashit($url['loc']);
                     }
                 }
                 $pri = WPSEO_Meta::get_value('sitemap-prio', $p->ID);
                 if (is_numeric($pri)) {
                     $url['pri'] = (double) $pri;
                 } else {
                     if ($p->post_parent == 0 && $p->post_type == 'page') {
                         $url['pri'] = 0.8;
                     } else {
                         $url['pri'] = 0.6;
                     }
                 }
                 if (isset($front_id) && $p->ID == $front_id) {
                     $url['pri'] = 1.0;
                 }
                 $url['images'] = array();
                 $content = $p->post_content;
                 $content = '<p>' . get_the_post_thumbnail($p->ID, 'full') . '</p>' . $content;
                 $host = str_replace('www.', '', parse_url(get_bloginfo('url'), PHP_URL_HOST));
                 if (preg_match_all('`<img [^>]+>`', $content, $matches)) {
                     foreach ($matches[0] as $img) {
                         if (preg_match('`src=["\']([^"\']+)["\']`', $img, $match)) {
                             $src = $match[1];
                             if (strpos($src, 'http') !== 0) {
                                 if ($src[0] != '/') {
                                     continue;
                                 }
                                 $src = get_bloginfo('url') . $src;
                             }
                             if (strpos($src, $host) === false) {
                                 continue;
                             }
                             if ($src != esc_url($src)) {
                                 continue;
                             }
                             if (isset($url['images'][$src])) {
                                 continue;
                             }
                             $image = array('src' => apply_filters('wpseo_xml_sitemap_img_src', $src, $p));
                             if (preg_match('`title=["\']([^"\']+)["\']`', $img, $match)) {
                                 $image['title'] = str_replace(array('-', '_'), ' ', $match[1]);
                             }
                             if (preg_match('`alt=["\']([^"\']+)["\']`', $img, $match)) {
                                 $image['alt'] = str_replace(array('-', '_'), ' ', $match[1]);
                             }
                             $image = apply_filters('wpseo_xml_sitemap_img', $image, $p);
                             $url['images'][] = $image;
                         }
                     }
                 }
                 if (strpos($p->post_content, '[gallery') !== false) {
                     $attachments = get_children(array('post_parent' => $p->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image'));
                     if (is_array($attachments) && $attachments !== array()) {
                         foreach ($attachments as $att_id => $attachment) {
                             $src = wp_get_attachment_image_src($att_id, 'large', false);
                             $image = array('src' => apply_filters('wpseo_xml_sitemap_img_src', $src[0], $p));
                             $alt = get_post_meta($att_id, '_wp_attachment_image_alt', true);
                             if ($alt !== '') {
                                 $image['alt'] = $alt;
                             }
                             unset($alt);
                             $image['title'] = $attachment->post_title;
                             $image = apply_filters('wpseo_xml_sitemap_img', $image, $p);
                             $url['images'][] = $image;
                         }
                     }
                     unset($attachments, $att_id, $attachment, $src, $image, $alt);
                 }
                 $url['images'] = apply_filters('wpseo_sitemap_urlimages', $url['images'], $p->ID);
                 if (!in_array($url['loc'], $stackedurls)) {
                     // Use this filter to adjust the entry before it gets added to the sitemap
                     $url = apply_filters('wpseo_sitemap_entry', $url, 'post', $p);
                     if (is_array($url) && $url !== array()) {
                         $output .= $this->sitemap_url($url);
                         $stackedurls[] = $url['loc'];
                     }
                 }
                 // Clear the post_meta and the term cache for the post, as we no longer need it now.
                 // wp_cache_delete( $p->ID, 'post_meta' );
                 // clean_object_term_cache( $p->ID, $post_type );
             }
         }
     }
     if (empty($output)) {
         $this->bad_sitemap = true;
         return;
     }
     $this->sitemap = '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" ';
     $this->sitemap .= 'xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" ';
     $this->sitemap .= 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
     $this->sitemap .= $output;
     // Filter to allow adding extra URLs, only do this on the first XML sitemap, not on all.
     if ($n == 0) {
         $this->sitemap .= apply_filters('wpseo_sitemap_' . $post_type . '_content', '');
     }
     $this->sitemap .= '</urlset>';
 }
Example #29
0
 /**
  * Based on the redirect meta value, this function determines whether it should redirect the current post / page.
  *
  * @return boolean
  */
 function page_redirect()
 {
     if (is_singular()) {
         global $post;
         if (!isset($post) || !is_object($post)) {
             return false;
         }
         $redir = WPSEO_Meta::get_value('redirect', $post->ID);
         if ($redir !== '') {
             wp_redirect($redir, 301);
             exit;
         }
     }
     return false;
 }
Example #30
0
/**
 * 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_all();
    if (version_compare($options['version'], WPSEO_VERSION, '<')) {
        new WPSEO_Upgrade();
        // get a cleaned up version of the $options
        $options = WPSEO_Options::get_all();
    }
    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';
    }
}