function webdados_fb_open_graph()
{
    global $webdados_fb_open_graph_plugin_settings, $webdados_fb_open_graph_plugin_name, $webdados_fb_open_graph_plugin_version, $webdados_fb_open_graph_settings;
    //Upgrade
    webdados_fb_open_graph_upgrade();
    //Get options - OLD (until 0.5.4)
    /*foreach($webdados_fb_open_graph_plugin_settings as $key) {
    		$$key=get_option('wonderm00n_open_graph_'.$key);
    	}*/
    //Get options - NEW (after 0.5.4)
    extract($webdados_fb_open_graph_settings);
    //Also set Title Tag?
    $fb_set_title_tag = 0;
    //Additional images
    $fb_image_additional = array();
    $fb_type = 'article';
    if (is_singular()) {
        //It's a Post or a Page or an attachment page - It can also be the homepage if it's set as a page
        global $post;
        $fb_title = esc_attr(strip_tags(stripslashes($post->post_title)));
        //SubHeading
        if ($fb_show_subheading == 1) {
            if (webdados_fb_open_graph_subheadingactive()) {
                $fb_title .= ' - ' . get_the_subheading();
            }
        }
        $fb_url = get_permalink();
        if (is_front_page()) {
            /* Fix homepage type when it's a static page */
            $fb_url = get_option('home') . (intval($fb_url_add_trailing) == 1 ? '/' : '');
            $fb_type = trim($fb_type_homepage == '' ? 'website' : $fb_type_homepage);
        }
        if (trim($post->post_excerpt) != '') {
            //If there's an excerpt that's what we'll use
            $fb_desc = trim($post->post_excerpt);
        } else {
            //If not we grab it from the content
            $fb_desc = trim($post->post_content);
        }
        $fb_desc = intval($fb_desc_chars) > 0 ? mb_substr(esc_attr(strip_tags(strip_shortcodes(stripslashes($fb_desc)))), 0, $fb_desc_chars) : esc_attr(strip_tags(strip_shortcodes(stripslashes($fb_desc))));
        if (intval($fb_image_show) == 1 || intval($fb_image_show_schema) == 1 || intval($fb_image_show_twitter) == 1) {
            $fb_image = webdados_fb_open_graph_post_image($fb_image_use_specific, $fb_image_use_featured, $fb_image_use_content, $fb_image_use_media, $fb_image_use_default, $fb_image);
        }
        //Author
        $author_id = $post->post_author;
        if ($author_id > 0) {
            $fb_author = get_the_author_meta('facebook', $author_id);
            $fb_author_meta = get_the_author_meta('display_name', $author_id);
            $fb_author_linkrelgp = get_the_author_meta('googleplus', $author_id);
            $fb_author_twitter = get_the_author_meta('twitter', $author_id);
        } else {
            $fb_author = '';
            $fb_author_meta = '';
            $fb_author_linkrelgp = '';
            $fb_author_twitter = '';
        }
        //Author - Hide on pages?
        if (is_page() && $fb_author_hide_on_pages == 1) {
            $fb_author = '';
            $fb_author_meta = '';
            $fb_author_linkrelgp = '';
            $fb_author_twitter = '';
        }
        //Published and Modified time
        if (is_singular('post')) {
            $fb_article_pub_date = get_the_date('c');
            $fb_article_mod_date = get_the_modified_date('c');
        } else {
            $fb_article_dates_show = 0;
            $fb_article_pub_date = '';
            $fb_article_mod_date = '';
        }
        //Categories
        if (is_singular('post')) {
            $cats = get_the_category();
            if (!is_wp_error($cats) && (is_array($cats) && count($cats) > 0)) {
                $fb_sections = array();
                foreach ($cats as $cat) {
                    $fb_sections[] = $cat->name;
                }
            }
        } else {
            $fb_article_sections_show = 0;
        }
        //Business Directory Plugin
        if ($fb_show_businessdirectoryplugin == 1) {
            @(include_once ABSPATH . 'wp-admin/includes/plugin.php');
            if (is_plugin_active('business-directory-plugin/wpbusdirman.php')) {
                global $wpbdp;
                //$bdpaction = _wpbdp_current_action();
                $bdpaction = $wpbdp->controller->get_current_action();
                switch ($bdpaction) {
                    case 'showlisting':
                        //Listing
                        $listing_id = get_query_var('listing') ? wpbdp_get_post_by_slug(get_query_var('listing'))->ID : wpbdp_getv($_GET, 'id', get_query_var('id'));
                        $bdppost = get_post($listing_id);
                        $fb_title = esc_attr(strip_tags(stripslashes($bdppost->post_title))) . ' - ' . $fb_title;
                        $fb_set_title_tag = 1;
                        $fb_url = get_permalink($listing_id);
                        if (trim($bdppost->post_excerpt) != '') {
                            //If there's an excerpt that's what we'll use
                            $fb_desc = trim($bdppost->post_excerpt);
                        } else {
                            //If not we grab it from the content
                            $fb_desc = trim($bdppost->post_content);
                        }
                        $fb_desc = intval($fb_desc_chars) > 0 ? mb_substr(esc_attr(strip_tags(strip_shortcodes(stripslashes($fb_desc)))), 0, $fb_desc_chars) : esc_attr(strip_tags(strip_shortcodes(stripslashes($fb_desc))));
                        if (intval($fb_image_show) == 1 || intval($fb_image_show_schema) == 1 || intval($fb_image_show_twitter) == 1) {
                            $thumbdone = false;
                            if (intval($fb_image_use_featured) == 1) {
                                //Featured
                                if ($id_attachment = get_post_thumbnail_id($bdppost->ID)) {
                                    //There's a featured/thumbnail image for this listing
                                    $fb_image = wp_get_attachment_url($id_attachment, false);
                                    $thumbdone = true;
                                }
                            }
                            if (!$thumbdone) {
                                //Main image loaded
                                if ($thumbnail_id = wpbdp_listings_api()->get_thumbnail_id($bdppost->ID)) {
                                    $fb_image = wp_get_attachment_url($thumbnail_id, false);
                                }
                            }
                        }
                        break;
                    case 'browsecategory':
                        //Categories
                        $term = get_term_by('slug', get_query_var('category'), wpbdp_categories_taxonomy());
                        $fb_title = esc_attr(strip_tags(stripslashes($term->name))) . ' - ' . $fb_title;
                        $fb_set_title_tag = 1;
                        $fb_url = get_term_link($term);
                        if (trim($term->description) != '') {
                            $fb_desc = trim($term->description);
                        }
                        break;
                    case 'main':
                        //Main page
                        //No changes
                        break;
                    default:
                        //No changes
                        break;
                }
            }
        }
    } else {
        global $wp_query;
        //Other pages - Defaults
        $fb_title = esc_attr(strip_tags(stripslashes(get_bloginfo('name'))));
        //$fb_url=get_option('home').(intval($fb_url_add_trailing)==1 ? '/' : ''); //2013-11-4 changed from 'siteurl' to 'home'
        $fb_url = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
        //Not really canonical but will work for now
        //These are only used in posts/pages
        $fb_article_sections_show = 0;
        $fb_article_dates_show = 0;
        $fb_author_show = 0;
        $fb_author_show_meta = 0;
        $fb_author_show_linkrelgp = 0;
        $fb_author_show_twitter = 0;
        switch (trim($fb_desc_homepage)) {
            case 'custom':
                $fb_desc = esc_attr(strip_tags(stripslashes($fb_desc_homepage_customtext)));
                //WPML?
                if (function_exists('icl_object_id') && function_exists('icl_register_string')) {
                    global $sitepress;
                    if (ICL_LANGUAGE_CODE != $sitepress->get_default_language()) {
                        $fb_desc = icl_t('wd-fb-og', 'wd_fb_og_desc_homepage_customtext', $fb_desc);
                    } else {
                        //We got it already
                    }
                }
                break;
            default:
                $fb_desc = esc_attr(strip_tags(stripslashes(get_bloginfo('description'))));
                break;
        }
        if (is_category()) {
            $fb_title = esc_attr(strip_tags(stripslashes(single_cat_title('', false))));
            $term = $wp_query->get_queried_object();
            $fb_url = get_term_link($term, $term->taxonomy);
            $cat_desc = trim(esc_attr(strip_tags(stripslashes(category_description()))));
            if (trim($cat_desc) != '') {
                $fb_desc = $cat_desc;
            }
        } else {
            if (is_tag()) {
                $fb_title = esc_attr(strip_tags(stripslashes(single_tag_title('', false))));
                $term = $wp_query->get_queried_object();
                $fb_url = get_term_link($term, $term->taxonomy);
                $tag_desc = trim(esc_attr(strip_tags(stripslashes(tag_description()))));
                if (trim($tag_desc) != '') {
                    $fb_desc = $tag_desc;
                }
            } else {
                if (is_tax()) {
                    $fb_title = esc_attr(strip_tags(stripslashes(single_term_title('', false))));
                    $term = $wp_query->get_queried_object();
                    $fb_url = get_term_link($term, $term->taxonomy);
                    //WooCommerce
                    if (intval($fb_image_show) == 1 || intval($fb_image_show_schema) == 1 || intval($fb_image_show_twitter) == 1) {
                        if (class_exists('woocommerce') && $fb_wc_usecategthumb == 1 && is_product_category()) {
                            if ($thumbnail_id = get_woocommerce_term_meta($term->term_id, 'thumbnail_id', true)) {
                                if ($image = wp_get_attachment_url($thumbnail_id)) {
                                    $fb_image = $image;
                                }
                            }
                        }
                    }
                } else {
                    if (is_search()) {
                        $fb_title = esc_attr(strip_tags(stripslashes(__('Search for') . ' "' . get_search_query() . '"')));
                        $fb_url = get_search_link();
                    } else {
                        if (is_author()) {
                            $fb_title = esc_attr(strip_tags(stripslashes(get_the_author_meta('display_name', get_query_var('author')))));
                            $fb_url = get_author_posts_url(get_query_var('author'), get_query_var('author_name'));
                        } else {
                            if (is_archive()) {
                                if (is_day()) {
                                    $fb_title = esc_attr(strip_tags(stripslashes(get_query_var('day') . ' ' . single_month_title(' ', false) . ' ' . __('Archives'))));
                                    $fb_url = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day'));
                                } else {
                                    if (is_month()) {
                                        $fb_title = esc_attr(strip_tags(stripslashes(single_month_title(' ', false) . ' ' . __('Archives'))));
                                        $fb_url = get_month_link(get_query_var('year'), get_query_var('monthnum'));
                                    } else {
                                        if (is_year()) {
                                            $fb_title = esc_attr(strip_tags(stripslashes(get_query_var('year') . ' ' . __('Archives'))));
                                            $fb_url = get_year_link(get_query_var('year'));
                                        }
                                    }
                                }
                            } else {
                                if (is_front_page()) {
                                    $fb_url = get_option('home') . (intval($fb_url_add_trailing) == 1 ? '/' : '');
                                    $fb_type = trim($fb_type_homepage == '' ? 'website' : $fb_type_homepage);
                                } else {
                                    //Others... Defaults already set up there
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    //If no description let's just add the title
    if (trim($fb_desc) == '') {
        $fb_desc = $fb_title;
    }
    //YOAST?
    if ($fb_show_wpseoyoast == 1) {
        if (defined('WPSEO_VERSION')) {
            $wpseo = WPSEO_Frontend::get_instance();
            //App ID - From our plugin
            //Admin ID - From our plugin
            //Locale - From our plugin
            //Sitename - From our plugin
            //Title - From WPSEO
            $fb_title = strip_tags($wpseo->title(false));
            //Title - SubHeading plugin
            if ($fb_show_subheading == 1) {
                if (webdados_fb_open_graph_subheadingactive()) {
                    $fb_title .= ' - ' . get_the_subheading();
                }
            }
            //URL - From WPSEO
            $fb_url = $wpseo->canonical(false);
            //Description - From WPSEO or our plugin
            $fb_desc_temp = $wpseo->metadesc(false);
            $fb_desc = strip_tags(trim($fb_desc_temp) != '' ? trim($fb_desc_temp) : $fb_desc);
            //Image - From our plugin
        }
    }
    //WooCommerce - Additional product images?
    if (intval($fb_image_show) == 1 && class_exists('woocommerce') && $fb_wc_useproductgallery == 1 && is_product()) {
        global $post;
        $product = new WC_Product($post->ID);
        if ($attachment_ids = $product->get_gallery_attachment_ids()) {
            foreach ($attachment_ids as $attachment_id) {
                if ($image_link = wp_get_attachment_url($attachment_id)) {
                    if (trim($image_link) != '') {
                        $fb_image_additional[] = trim($image_link);
                    }
                }
            }
        }
    }
    //Apply Filters
    $fb_title = apply_filters('fb_og_title', $fb_title);
    $fb_desc = apply_filters('fb_og_desc', $fb_desc);
    $fb_image = apply_filters('fb_og_image', $fb_image);
    $fb_image_additional = apply_filters('fb_og_image_additional', $fb_image_additional);
    $fb_locale = apply_filters('fb_og_locale', $fb_locale);
    $fb_image_size = false;
    if (intval($fb_image_show) == 1 && trim($fb_image) != '') {
        if (intval($fb_image_size_show) == 1) {
            if (isset($GLOBALS['webdados_fb_img_size'])) {
                //Already fetched
                $fb_image_size = $GLOBALS['webdados_fb_img_size'];
            } else {
                $fb_image_size = webdados_fb_open_graph_getimagesize($fb_image);
            }
        }
    } else {
        $fb_image_size_show = 0;
    }
    //No spaces on URLs
    if (isset($fb_url) && trim($fb_url) != '') {
        $fb_url = str_replace(' ', '%20', trim($fb_url));
    }
    if (isset($fb_publisher) && trim($fb_publisher) != '') {
        $fb_publisher = str_replace(' ', '%20', trim($fb_publisher));
    }
    if (isset($fb_publisher_schema) && trim($fb_publisher_schema) != '') {
        $fb_publisher_schema = str_replace(' ', '%20', trim($fb_publisher_schema));
    }
    if (isset($fb_author) && trim($fb_author) != '') {
        $fb_author = str_replace(' ', '%20', trim($fb_author));
    }
    if (isset($fb_author_linkrelgp) && trim($fb_author_linkrelgp) != '') {
        $fb_author_linkrelgp = str_replace(' ', '%20', trim($fb_author_linkrelgp));
    }
    if (isset($fb_image) && trim($fb_image) != '') {
        $fb_image = str_replace(' ', '%20', trim($fb_image));
    }
    if (isset($fb_image_additional) && is_array($fb_image_additional) && count($fb_image_additional)) {
        foreach ($fb_image_additional as $key => $value) {
            $fb_image_additional[$key] = str_replace(' ', '%20', trim($value));
        }
    }
    $html = '
<!-- START - ' . $webdados_fb_open_graph_plugin_name . ' ' . $webdados_fb_open_graph_plugin_version . ' -->
';
    if (intval($fb_app_id_show) == 1 && trim($fb_app_id) != '') {
        $html .= '<meta property="fb:app_id" content="' . trim(esc_attr($fb_app_id)) . '"/>
';
    }
    if (intval($fb_admin_id_show) == 1 && trim($fb_admin_id) != '') {
        $html .= '<meta property="fb:admins" content="' . trim(esc_attr($fb_admin_id)) . '"/>
';
    }
    if (intval($fb_locale_show) == 1) {
        $html .= '<meta property="og:locale" content="' . trim(esc_attr(trim($fb_locale) != '' ? trim($fb_locale) : trim(get_locale()))) . '"/>
';
    }
    if (intval($fb_sitename_show) == 1) {
        $html .= '<meta property="og:site_name" content="' . trim(esc_attr(get_bloginfo('name'))) . '"/>
';
    }
    if (intval($fb_title_show) == 1) {
        $html .= '<meta property="og:title" content="' . trim(esc_attr($fb_title)) . '"/>
';
    }
    if (intval($fb_set_title_tag) == 1) {
        //Does nothing so far. We try to create the <title> tag but it's too late now
    }
    if (intval($fb_title_show_schema) == 1) {
        $html .= '<meta itemprop="name" content="' . trim(esc_attr($fb_title)) . '"/>
';
    }
    if (intval($fb_title_show_twitter) == 1) {
        $html .= '<meta name="twitter:title" content="' . trim(esc_attr($fb_title)) . '"/>
';
    }
    if (intval($fb_url_show) == 1) {
        $html .= '<meta property="og:url" content="' . trim(esc_attr($fb_url)) . '"/>
';
    }
    if (intval($fb_url_show_twitter) == 1) {
        $html .= '<meta name="twitter:url" content="' . trim(esc_attr($fb_url)) . '"/>
';
    }
    if (intval($fb_url_canonical) == 1) {
        $html .= '<link rel="canonical" href="' . trim(esc_attr($fb_url)) . '"/>
';
    }
    if (intval($fb_type_show) == 1) {
        $html .= '<meta property="og:type" content="' . trim(esc_attr($fb_type)) . '"/>
';
    }
    if (intval($fb_article_dates_show) == 1 && trim($fb_article_pub_date) != '') {
        $html .= '<meta property="article:published_time" content="' . trim(esc_attr($fb_article_pub_date)) . '"/>
';
    }
    if (intval($fb_article_dates_show) == 1 && trim($fb_article_mod_date) != '') {
        $html .= '<meta property="article:modified_time" content="' . trim(esc_attr($fb_article_mod_date)) . '" />
<meta property="og:updated_time" content="' . trim(esc_attr($fb_article_mod_date)) . '" />
';
    }
    if (intval($fb_article_sections_show) == 1 && isset($fb_sections) && is_array($fb_sections) && count($fb_sections) > 0) {
        foreach ($fb_sections as $fb_section) {
            $html .= '<meta property="article:section" content="' . trim(esc_attr($fb_section)) . '"/>
';
        }
    }
    if (intval($fb_publisher_show) == 1 && trim($fb_publisher) != '') {
        $html .= '<meta property="article:publisher" content="' . trim(esc_attr($fb_publisher)) . '"/>
';
    }
    if (intval($fb_publisher_show_schema) == 1 && trim($fb_publisher_schema) != '') {
        $html .= '<link rel="publisher" href="' . trim(esc_attr($fb_publisher_schema)) . '"/>
';
    }
    if (intval($fb_publisher_show_twitter) == 1 && trim($fb_publisher_twitteruser) != '') {
        $html .= '<meta name="twitter:site" content="@' . trim(esc_attr($fb_publisher_twitteruser)) . '"/>
';
    }
    if (intval($fb_author_show) == 1 && $fb_author != '') {
        $html .= '<meta property="article:author" content="' . trim(esc_attr($fb_author)) . '"/>
';
    }
    if (intval($fb_author_show_meta) == 1 && $fb_author_meta != '') {
        $html .= '<meta name="author" content="' . trim(esc_attr($fb_author_meta)) . '"/>
';
    }
    if (intval($fb_author_show_linkrelgp) == 1 && trim($fb_author_linkrelgp) != '') {
        $html .= '<link rel="author" href="' . trim(esc_attr($fb_author_linkrelgp)) . '"/>
';
    }
    if (intval($fb_author_show_twitter) == 1 && (trim($fb_author_twitter) != '' || trim($fb_publisher_twitteruser) != '')) {
        $html .= '<meta name="twitter:creator" content="@' . trim(esc_attr(trim($fb_author_twitter) != '' ? trim($fb_author_twitter) : trim($fb_publisher_twitteruser))) . '"/>
';
    }
    if (intval($fb_desc_show) == 1) {
        $html .= '<meta property="og:description" content="' . trim(esc_attr($fb_desc)) . '"/>
';
    }
    if (intval($fb_desc_show_meta) == 1) {
        $html .= '<meta name="description" content="' . trim(esc_attr($fb_desc)) . '"/>
';
    }
    if (intval($fb_desc_show_schema) == 1) {
        $html .= '<meta itemprop="description" content="' . trim(esc_attr($fb_desc)) . '"/>
';
    }
    if (intval($fb_desc_show_twitter) == 1) {
        $html .= '<meta name="twitter:description" content="' . trim(esc_attr($fb_desc)) . '"/>
';
    }
    if (intval($fb_image_show) == 1 && trim($fb_image) != '') {
        $html .= '<meta property="og:image" content="' . trim(esc_attr($fb_image)) . '"/>
';
    }
    if (intval($fb_image_show) == 1 && isset($fb_image_additional) && is_array($fb_image_additional) && count($fb_image_additional) > 0) {
        foreach ($fb_image_additional as $fb_image_additional_temp) {
            $html .= '<meta property="og:image" content="' . trim(esc_attr($fb_image_additional_temp)) . '"/>
';
        }
    } else {
        //We only show the image size if we only have one image
        if (intval($fb_image_size_show) == 1 && isset($fb_image_size) && is_array($fb_image_size) != '') {
            $html .= '<meta property="og:image:width" content="' . intval(esc_attr($fb_image_size[0])) . '"/>
<meta property="og:image:height" content="' . intval(esc_attr($fb_image_size[1])) . '"/>
';
        }
    }
    if (intval($fb_image_show_schema) == 1 && trim($fb_image) != '') {
        $html .= '<meta itemprop="image" content="' . trim(esc_attr($fb_image)) . '"/>
';
    }
    if (intval($fb_image_show_twitter) == 1 && trim($fb_image) != '') {
        $html .= '<meta name="twitter:image:src" content="' . trim(esc_attr($fb_image)) . '"/>
';
    }
    if (intval($fb_title_show_twitter) == 1 || intval($fb_url_show_twitter) == 1 || $fb_author_show_twitter == 1 || $fb_publisher_show_twitter == 1 || $fb_image_show_twitter == 1) {
        $html .= '<meta name="twitter:card" content="' . trim(esc_attr($fb_twitter_card_type)) . '"/>
';
    }
    $html .= '<!-- END - ' . $webdados_fb_open_graph_plugin_name . ' -->

';
    echo $html;
}
 public function disable_seo_on_escaped_fragment()
 {
     if (!array_key_exists('_escaped_fragment_', $_GET) || !ecwid_page_has_productbrowser()) {
         return;
     }
     global $wpseo_front;
     // Canonical
     if (empty($wpseo_front)) {
         $wpseo_front = WPSEO_Frontend::get_instance();
     }
     remove_action('wpseo_head', array($wpseo_front, 'canonical'), 20);
     // Description
     remove_action('wpseo_head', array($wpseo_front, 'metadesc'), 10);
 }
Exemple #3
0
 public static function listing_og_description($listing_id)
 {
     if (self::is_wp_seo_enabled()) {
         $wpseo_front = null;
         if (isset($GLOBALS['wpseo_front'])) {
             $wpseo_front = $GLOBALS['wpseo_front'];
         } elseif (class_exists('WPSEO_Frontend') && method_exists('WPSEO_Frontend', 'get_instance')) {
             $wpseo_front = WPSEO_Frontend::get_instance();
         }
         global $post;
         $prev_post = $post;
         $post = get_post($listing_id);
         $desc = $wpseo_front->metadesc(false);
         $post = $prev_post;
         return $desc;
     }
     $listing = WPBDP_Listing::get($listing_id);
     return $listing->get_field_value('excerpt');
 }
 /**
  * Generate title
  *
  * @see get_title_from_options()
  * @scope front
  * @since 1.1.1		 
  *
  * @param string $text
  *
  * @return string
  */
 public static function filter__title($text)
 {
     $text = WPGlobus_Core::text_filter($text, WPGlobus::Config()->language);
     $wpseo_f = WPSEO_Frontend::get_instance();
     if (empty($text)) {
         global $post;
         $text = $post->post_title . ' ' . $wpseo_f->get_title_from_options('wpseo_titles');
     }
     return $text;
 }
Exemple #5
0
 public function wpseo_init()
 {
     global $polylang;
     if (!defined('WPSEO_VERSION') || PLL_ADMIN) {
         return;
     }
     // reloads options once the language has been defined to enable translations
     // useful only when the language is set from content
     if (did_action('wp_loaded')) {
         if (version_compare(WPSEO_VERSION, '1.7.2', '<')) {
             global $wpseo_front;
         } else {
             $wpseo_front = WPSEO_Frontend::get_instance();
         }
         $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));
         }
     }
     // one sitemap per language when using multiple domains or subdomains
     // because WPSEO does not accept several domains or subdomains in one sitemap
     if ($polylang->options['force_lang'] > 1) {
         add_filter('wpseo_enable_xml_sitemap_transient_caching', '__return_false');
         // disable cache! otherwise WPSEO keeps only one domain
         add_filter('home_url', array(&$this, 'wpseo_home_url'), 10, 2);
         // fix home_url
         add_filter('wpseo_posts_join', array(&$this, 'wpseo_posts_join'), 10, 2);
         add_filter('wpseo_posts_where', array(&$this, 'wpseo_posts_where'), 10, 2);
         add_filter('wpseo_typecount_join', array(&$this, 'wpseo_posts_join'), 10, 2);
         add_filter('wpseo_typecount_where', array(&$this, 'wpseo_posts_where'), 10, 2);
     } else {
         add_filter('get_terms_args', array(&$this, 'wpseo_remove_terms_filter'));
     }
     add_filter('pll_home_url_white_list', create_function('$arr', "return array_merge(\$arr, array(array('file' => 'wordpress-seo')));"));
     add_action('wpseo_opengraph', array(&$this, 'wpseo_ogp'), 2);
 }
 /**
  * Returns the Twitter title for any page
  *
  * @return string
  */
 private function fallback_title()
 {
     return WPSEO_Frontend::get_instance()->title('');
 }
 /**
  * @covers WPSEO_Twitter::url
  */
 public function test_twitter_url()
 {
     // create and go to post
     $post_id = $this->factory->post->create();
     $this->go_to(get_permalink($post_id));
     $expected = $this->metatag('url', esc_url(WPSEO_Frontend::get_instance()->canonical(false)));
     self::$class_instance->url();
     $this->expectOutput($expected);
 }
 /**
  * @param string $option_name
  * @param string $expected
  * @return void
  */
 private function run_webmaster_tools_authentication_option_test($option_name, $expected)
 {
     self::$class_instance->options[$option_name] = $option_name;
     $this->expectOutput($expected, self::$class_instance->webmaster_tools_authentication());
     self::$class_instance->options[$option_name] = '';
 }
 public function description()
 {
     $desc = wpseo_get_value('opengraph-description');
     if (!$desc) {
         $desc = WPSEO_Frontend::metadesc(false);
     }
     if ($desc && $desc != '') {
         echo "<meta property='og:description' content='" . esc_attr($desc) . "'/>\n";
     }
 }
 public function wpto_remove_yoast_information()
 {
     if (!empty($this->wpto_options['remove_yoast_information'])) {
         if (defined('WPSEO_VERSION')) {
             $instance = WPSEO_Frontend::get_instance();
             remove_action('wpseo_head', array($instance, 'debug_marker'), 2);
             remove_action('wp_head', array($instance, 'head'), 1);
             add_action('wp_head', 'custom_yoast_head', 1);
             function custom_yoast_head()
             {
                 global $wp_query;
                 $old_wp_query = null;
                 if (!$wp_query->is_main_query()) {
                     $old_wp_query = $wp_query;
                     wp_reset_query();
                 }
                 do_action('wpseo_head');
                 if (!empty($old_wp_query)) {
                     $GLOBALS['wp_query'] = $old_wp_query;
                     unset($old_wp_query);
                 }
                 return;
             }
         }
     }
 }
/**
 * 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')));
    }
}
foreach ($post_categories_array as $cats) {
    $cat = get_category($cats);
    if ($post_sections == '') {
        $post_sections .= $cat->name;
    } else {
        $post_sections .= ', ' . $cat->name;
    }
}
?>
            <meta itemprop="name headline" content="<?php 
the_title();
?>
" />
			<?php 
if (class_exists('WPSEO_Frontend')) {
    $wp_seo_object = WPSEO_Frontend::get_instance();
    $post_description = htmlentities($wp_seo_object->metadesc(false));
    echo '<meta itemprop="description" content="' . $post_description . '" />';
}
?>
			<meta itemprop="datePublished" content="<?php 
echo $post_date_iso;
?>
" />
			<span class="date published"><?php 
echo $post_date_iso;
?>
</span>
			<meta itemprop="dateModified" content="<?php 
echo $post_modified_date_iso;
?>
 /**
 		@brief		Use the correct canonical link.
 	**/
 public function wp_head()
 {
     // Only override the canonical if we're looking at a single post.
     $override = false;
     $override |= is_single();
     $override |= is_page();
     if (!$override) {
         return;
     }
     global $post;
     global $blog_id;
     // Find the parent, if any.
     $broadcast_data = $this->get_post_broadcast_data($blog_id, $post->ID);
     $linked_parent = $broadcast_data->get_linked_parent();
     if ($linked_parent === false) {
         return;
     }
     // Post has a parent. Get the parent's permalink.
     switch_to_blog($linked_parent['blog_id']);
     $url = get_permalink($linked_parent['post_id']);
     restore_current_blog();
     echo sprintf('<link rel="canonical" href="%s" />', $url);
     echo "\n";
     // Prevent Wordpress from outputting its own canonical.
     remove_action('wp_head', 'rel_canonical');
     // Remove Canonical Link Added By Yoast WordPress SEO Plugin
     if (class_exists('\\WPSEO_Frontend')) {
         $this->add_filter('wpseo_canonical', 'wp_head_remove_wordpress_seo_canonical');
         $wpseo_frontend = \WPSEO_Frontend::get_instance();
         remove_action('wpseo_head', array($wpseo_frontend, 'canonical'), 20);
     }
 }
function ampforwp_update_metadata($metadata, $post)
{
    global $redux_builder_amp;
    $structured_data_logo = $redux_builder_amp['amp-structured-data-logo']['url'];
    if ($structured_data_logo) {
        $structured_data_logo = $structured_data_logo;
    } else {
        $structured_data_logo = $redux_builder_amp['opt-media']['url'];
    }
    $metadata['publisher']['logo'] = array('@type' => 'ImageObject', 'url' => $structured_data_logo, 'height' => 36, 'width' => 190);
    //code for adding 'description' meta from Yoast SEO
    include_once ABSPATH . 'wp-admin/includes/plugin.php';
    if (is_plugin_active('wordpress-seo/wp-seo.php')) {
        $front = WPSEO_Frontend::get_instance();
        $desc = $front->metadesc(false);
        if ($desc) {
            $metadata['description'] = $desc;
        }
    }
    //End of code for adding 'description' meta from Yoast SEO
    return $metadata;
}
 /**
  * @covers WPSEO_Twitter::description
  */
 public function test_twitter_description_metadesc()
 {
     // create and go to post
     $post_id = $this->factory->post->create();
     // test wpseo meta
     WPSEO_Meta::set_value('metadesc', 'Meta description', $post_id);
     $this->go_to(get_permalink($post_id));
     $expected = $this->metatag('description', WPSEO_Frontend::get_instance()->metadesc(false));
     self::$class_instance->description();
     $this->expectOutput($expected);
 }
 /**
  * @covers WPSEO_OpenGraph::og_title
  */
 public function test_og_title()
 {
     // create and go to post
     $post_id = $this->factory->post->create();
     $this->go_to(get_permalink($post_id));
     $expected_title = WPSEO_Frontend::get_instance()->title('');
     $expected_html = '<meta property="og:title" content="' . $expected_title . '" />' . "\n";
     $this->assertTrue(self::$class_instance->og_title());
     $this->expectOutput($expected_html);
     $this->assertEquals(self::$class_instance->og_title(false), $expected_title);
 }
 /**
  * Yoast SEO
  * Translate options and add specific filters and actions
  *
  * @since 1.6.4
  */
 public function wpseo_init()
 {
     if (!defined('WPSEO_VERSION') || PLL_ADMIN) {
         return;
     }
     // Reloads options once the language has been defined to enable translations
     // Useful only when the language is set from content
     if (did_action('wp_loaded')) {
         if (version_compare(WPSEO_VERSION, '1.7.2', '<')) {
             global $wpseo_front;
         } else {
             $wpseo_front = WPSEO_Frontend::get_instance();
         }
         $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));
         }
     }
     // One sitemap per language when using multiple domains or subdomains
     // because WPSEO does not accept several domains or subdomains in one sitemap
     if (PLL()->options['force_lang'] > 1) {
         add_filter('wpseo_enable_xml_sitemap_transient_caching', '__return_false');
         // disable cache! otherwise WPSEO keeps only one domain (thanks to Junaid Bhura)
         add_filter('home_url', array(&$this, 'wpseo_home_url'), 10, 2);
         // fix home_url
         add_filter('wpseo_posts_join', array(&$this, 'wpseo_posts_join'), 10, 2);
         add_filter('wpseo_posts_where', array(&$this, 'wpseo_posts_where'), 10, 2);
         add_filter('wpseo_typecount_join', array(&$this, 'wpseo_posts_join'), 10, 2);
         add_filter('wpseo_typecount_where', array(&$this, 'wpseo_posts_where'), 10, 2);
     } else {
         add_filter('get_terms_args', array(&$this, 'wpseo_remove_terms_filter'));
         // Add the homepages for all languages to the sitemap when the front page displays posts
         if (!get_option('page_on_front')) {
             add_filter('wpseo_sitemap_post_content', array(&$this, 'add_language_home_urls'));
         }
     }
     add_filter('pll_home_url_white_list', array(&$this, 'wpseo_home_url_white_list'));
     add_action('wpseo_opengraph', array(&$this, 'wpseo_ogp'), 2);
     add_filter('wpseo_canonical', array(&$this, 'wpseo_canonical'));
 }
 /**
  * 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;
 }
 /**
  * Displays the URL for Twitter.
  *
  * Only used when OpenGraph is inactive.
  */
 protected function url()
 {
     /**
      * Filter: 'wpseo_twitter_url' - Allow changing the URL as output in the Twitter card by WP SEO
      *
      * @api string $unsigned Canonical URL
      */
     $url = apply_filters('wpseo_twitter_url', WPSEO_Frontend::get_instance()->canonical(false));
     if (is_string($url) && $url !== '') {
         $this->output_metatag('url', esc_url($url), true);
     }
 }
/**
 * 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')));
    }
}
 public function description()
 {
     $ogdesc = wpseo_get_value('opengraph-description');
     if (!$ogdesc) {
         $ogdesc = WPSEO_Frontend::metadesc(false);
     }
     if ($ogdesc && $ogdesc != '') {
         echo "<meta property='og:description' content='" . esc_attr($ogdesc) . "'/>\n";
     }
     //
     // $gplusdesc = wpseo_get_value('google-plus-description');
     //
     // if ( !$gplusdesc )
     // 	$gplusdesc = WPSEO_Frontend::metadesc( false );
     //
     // if ( $gplusdesc && $gplusdesc != '' )
     // 	echo "<meta itemprop='description' content='".esc_attr( $gplusdesc )."'/>\n";
 }
 /**
  * @param string $expected
  *
  * @return void
  */
 private function run_json_ld_test($expected)
 {
     $this->expectOutput($expected, self::$class_instance->internal_search_json_ld());
 }
 /**
  * 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()) {
         if (isset($this->options['og_frontpage_desc']) && $this->options['og_frontpage_desc'] !== '') {
             $ogdesc = wpseo_replace_vars($this->options['og_frontpage_desc'], null);
         } else {
             $ogdesc = WPSEO_Frontend::get_instance()->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 = WPSEO_Frontend::get_instance()->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 = WPSEO_Frontend::get_instance()->metadesc(false);
         if ('' == $ogdesc) {
             $ogdesc = trim(strip_tags(term_description()));
         }
         if ('' == $ogdesc) {
             $term = $GLOBALS['wp_query']->get_queried_object();
             $ogdesc = WPSEO_Taxonomy_Meta::get_term_meta($term, $term->taxonomy, 'desc');
         }
     }
     // Strip shortcodes if any
     $ogdesc = strip_shortcodes($ogdesc);
     /**
      * Filter: 'wpseo_opengraph_desc' - Allow changing the OpenGraph description
      *
      * @api string $ogdesc The description string.
      */
     $ogdesc = trim(apply_filters('wpseo_opengraph_desc', $ogdesc));
     if (is_string($ogdesc) && $ogdesc !== '') {
         if ($echo !== false) {
             $this->og_tag('og:description', $ogdesc);
         }
     }
     return $ogdesc;
 }
 public function _meta_keywords()
 {
     $wpseo_front = null;
     if (isset($GLOBALS['wpseo_front'])) {
         $wpseo_front = $GLOBALS['wpseo_front'];
     } elseif (class_exists('WPSEO_Frontend') && method_exists('WPSEO_Frontend', 'get_instance')) {
         $wpseo_front = WPSEO_Frontend::get_instance();
     }
     $current_action = $this->controller->get_current_action();
     switch ($current_action) {
         case 'showlisting':
             global $post;
             $listing_id = get_query_var('listing') ? wpbdp_get_post_by_slug(get_query_var('listing'))->ID : wpbdp_getv($_GET, 'id', get_query_var('id'));
             $prev_post = $post;
             $post = get_post($listing_id);
             if (is_object($wpseo_front)) {
                 $wpseo_front->metadesc();
                 $wpseo_front->metakeywords();
             }
             $post = $prev_post;
             break;
         case 'browsecategory':
         case 'browsetag':
             if ($current_action == 'browsetag') {
                 $term = get_term_by('slug', get_query_var('tag'), WPBDP_TAGS_TAX);
             } else {
                 $term = get_term_by('slug', get_query_var('category'), WPBDP_CATEGORY_TAX);
                 if (!$term && get_query_var('category_id')) {
                     $term = get_term_by('id', get_query_var('category_id'), WPBDP_CATEGORY_TAX);
                 }
             }
             if ($term) {
                 $metadesc = method_exists('WPSEO_Taxonomy_Meta', 'get_term_meta') ? WPSEO_Taxonomy_Meta::get_term_meta($term, $term->taxonomy, 'desc') : wpseo_get_term_meta($term, $term->taxonomy, 'desc');
                 if (!$metadesc && is_object($wpseo_front) && isset($wpseo_front->options['metadesc-tax-' . $term->taxonomy])) {
                     $metadesc = wpseo_replace_vars($wpseo_front->options['metadesc-tax-' . $term->taxonomy], (array) $term);
                 }
                 if ($metadesc) {
                     echo '<meta name="description" content="' . esc_attr(strip_tags(stripslashes($metadesc))) . '"/>' . "\n";
                 }
             }
             break;
         case 'main':
             if (is_object($wpseo_front)) {
                 $wpseo_front->metadesc();
                 $wpseo_front->metakeywords();
             }
             break;
         default:
             break;
     }
 }
 /**
  * Wraps frontend class.
  */
 function initialize_wpseo_front()
 {
     WPSEO_Frontend::get_instance();
 }
Exemple #26
0
function wplms_yoast_seo_title_fix()
{
    if (class_exists('WPSEO_Frontend')) {
        add_filter('wp_title', array(WPSEO_Frontend::get_instance(), 'title'), 25, 3);
    }
}
/**
 * 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 &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')));
    }
}
 /**
  * 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 = '';
     $frontend = WPSEO_Frontend::get_instance();
     if (is_front_page()) {
         if (isset($this->options['og_frontpage_desc']) && $this->options['og_frontpage_desc'] !== '') {
             $ogdesc = wpseo_replace_vars($this->options['og_frontpage_desc'], null);
         } else {
             $ogdesc = $frontend->metadesc(false);
         }
     }
     $is_posts_page = $frontend->is_posts_page();
     if (is_singular() || $is_posts_page) {
         $post_id = $is_posts_page ? get_option('page_for_posts') : get_the_ID();
         $post = get_post($post_id);
         $ogdesc = WPSEO_Meta::get_value('opengraph-description', $post_id);
         // Replace Yoast SEO Variables.
         $ogdesc = wpseo_replace_vars($ogdesc, $post);
         // Use metadesc if $ogdesc is empty.
         if ($ogdesc === '') {
             $ogdesc = $frontend->metadesc(false);
         }
         // Tag 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 = WPSEO_Taxonomy_Meta::get_meta_without_term('opengraph-description');
         if ($ogdesc === '') {
             $ogdesc = $frontend->metadesc(false);
         }
         if ($ogdesc === '') {
             $ogdesc = trim(strip_tags(term_description()));
         }
         if ($ogdesc === '') {
             $ogdesc = WPSEO_Taxonomy_Meta::get_meta_without_term('desc');
         }
     }
     // Strip shortcodes if any.
     $ogdesc = strip_shortcodes($ogdesc);
     /**
      * Filter: 'wpseo_opengraph_desc' - Allow changing the OpenGraph description
      *
      * @api string $ogdesc The description string.
      */
     $ogdesc = trim(apply_filters('wpseo_opengraph_desc', $ogdesc));
     if (is_string($ogdesc) && $ogdesc !== '') {
         if ($echo !== false) {
             $this->og_tag('og:description', $ogdesc);
         }
     }
     return $ogdesc;
 }
 /**
  * Prepares the organization or person markup
  */
 private function prepare_organization_person_markup()
 {
     $this->fetch_social_profiles();
     $this->data = array('@context' => 'http://schema.org', '@type' => '', 'url' => WPSEO_Frontend::get_instance()->canonical(false, true), 'sameAs' => $this->profiles);
 }
/**
 * 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;
    $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();
    }
    $focuskw = '';
    $score = '';
    $seo_url = '';
    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);
        $score = '<div class="' . esc_attr('wpseo-score-icon') . ' adminbar-seo-score"></div>';
        $seo_url = get_edit_post_link($post->ID);
    }
    if (WPSEO_Taxonomy::is_term_edit($GLOBALS['pagenow'])) {
        $score = '<div class="' . esc_attr('wpseo-score-icon') . ' adminbar-seo-score"></div>';
        $seo_url = get_edit_tag_link(filter_input(INPUT_GET, 'tag_ID'), 'category');
    }
    // Never display notifications for network admin.
    $counter = '';
    if ($admin_menu) {
        $seo_url = get_admin_url(null, 'admin.php?page=' . WPSEO_Admin::PAGE_IDENTIFIER);
        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.
                $counter = sprintf(' <div class="wp-core-ui wp-ui-notification yoast-issue-counter">%d</div>', $notification_count);
            }
            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 . '\');"></div>';
    $wp_admin_bar->add_menu(array('id' => 'wpseo-menu', 'title' => $title . $score . $counter, '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')));
        }
    }
    // @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')));
    }
}