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;
}
Exemplo n.º 2
0
function description()
{
    if (is_home() || is_front_page()) {
        echo trim(of_get_option('site_description'));
    } elseif (is_category()) {
        $description = strip_tags(category_description());
        echo trim($description);
    } elseif (is_single()) {
        if (get_the_excerpt()) {
            echo get_the_excerpt();
        } else {
            global $post;
            $description = trim(str_replace(array("\r\n", "\r", "\n", " ", " "), " ", str_replace("\"", "'", strip_tags($post->post_content))));
            echo mb_substr($description, 0, 220, 'utf-8');
        }
    } elseif (is_search()) {
        echo '“';
        the_search_query();
        echo '”为您找到结果 ';
        global $wp_query;
        echo $wp_query->found_posts;
        echo ' 个';
    } elseif (is_tag()) {
        $description = strip_tags(tag_description());
        echo trim($description);
    } else {
        $description = strip_tags(term_description());
        echo trim($description);
    }
}
Exemplo n.º 3
0
 function get_desc()
 {
     if (is_404()) {
         $desc = __("Sorry, but the page you were trying to view does not exist. \n\nIt looks like this was the result of either a mistyped address or an out-of-date link.", 'skrollr');
     } else {
         if (is_category()) {
             $desc = category_description();
         } else {
             if (is_tag()) {
                 $desc = tag_description();
             } else {
                 if (is_search()) {
                     global $wp_query;
                     if ($wp_query->found_posts == 0) {
                         $desc = __('Nothing found', 'skrollr');
                     } else {
                         $desc = sprintf(_n('One post found.', '%d posts found', $wp_query->found_posts, 'skrollr'), $wp_query->found_posts);
                     }
                 } else {
                     $desc = get_theme_mod('metadesc');
                 }
             }
         }
     }
     return wpautop(esc_html($desc));
 }
Exemplo n.º 4
0
function lo_description()
{
    global $s, $post;
    $description = '';
    $blog_name = get_bloginfo('name');
    if (is_singular()) {
        $ID = $post->ID;
        $title = $post->post_title;
        $author = $post->post_author;
        $user_info = get_userdata($author);
        $post_author = $user_info->display_name;
        if (!get_post_meta($ID, "meta-description", true)) {
            $description = $title . ' - 作者: ' . $post_author . ',首发于' . $blog_name;
        } else {
            $description = get_post_meta($ID, "meta-description", true);
        }
    } elseif (is_home()) {
        $description = lo_opt('index_description');
    } elseif (is_tag()) {
        $description = single_tag_title('', false) . " - " . trim(strip_tags(tag_description()));
    } elseif (is_category()) {
        $description = single_cat_title('', false) . " - " . trim(strip_tags(category_description()));
    } elseif (is_archive()) {
        $description = $blog_name . "'" . trim(wp_title('', false)) . "'";
    } elseif (is_search()) {
        $description = $blog_name . ": '" . esc_html($s, 1) . "' 的搜索結果";
    } else {
        $description = $blog_name . "'" . trim(wp_title('', false)) . "'";
    }
    $description = mb_substr($description, 0, 220, 'utf-8');
    echo "<meta name=\"description\" content=\"{$description}\">\n";
}
Exemplo n.º 5
0
    function gabfire_catNameDesc()
    {
        if (is_category()) {
            ?>
			<section class="row">
				<div class="col-md-12">
					<div class="post-lead">
						<?php 
            if (is_category()) {
                ?>
							<h1><?php 
                single_cat_title();
                ?>
</h1>
							<?php 
                echo category_description();
                ?>
						<?php 
            } else {
                ?>
							<h1 class="post-title"><?php 
                single_tag_title();
                ?>
</h1>
							<?php 
                echo tag_description();
                ?>
						<?php 
            }
            ?>
					</div>
				</div>
		</section><?php 
        } elseif (is_search()) {
            ?>
			<section class="row archive">
				<div class="col-md-12">
					<div class="post-lead">
						<h1><i class='fa fa-search'></i>  <?php 
            echo get_search_query();
            ?>
</h1>
						<?php 
            $search_query = get_search_query();
            ?>
						<p><?php 
            printf(esc_attr__('Search results for %1$s', 'gabfire'), $search_query);
            ?>
</p>
					</div>
				</div>
		</section><?php 
        }
    }
Exemplo n.º 6
0
/**
 * Shows appropriate title for each page
 *
 * @since 1.2
 */
function rolo_pageheader()
{
    if (is_single()) {
        $pagetitle = '<h2 class="page-title">' . __(get_the_term_list($post->ID, 'type', ' ', ', ', ': '), 'rolopress') . __(get_the_title(), 'rolopress') . "</h2>\n";
    } elseif (is_page()) {
        $pagetitle = '<h2 class="page-title page">' . __(get_the_title(), 'rolopress') . "</h2>\n";
    } elseif (is_404()) {
        $pagetitle = '<h2 class="page-title 404">' . __('Not Found', 'rolopress') . "</h2>\n";
    } elseif (is_home()) {
        $pagetitle = '<h2 class="page-title home">' . __('All Items', 'rolopress') . "</h2>\n";
    } elseif (is_search()) {
        $pagetitle = '<h2 class="page-title search">' . __('Search Results for: ', 'rolopress') . '"' . get_search_query() . '"' . "</h2>\n";
    } elseif (is_category()) {
        $current_category = single_cat_title("", false);
        $pagedesc = category_description();
        $pagetitle = '<h2 class="page-title category">' . __('Items Categorized As: ', 'rolopress') . '"' . $current_category . '"' . "</h2>\n";
    } elseif (is_tag()) {
        $current_tag = single_tag_title("", false);
        $pagedesc = tag_description();
        $pagetitle = '<h2 class="page-title tag">' . __('Items Tagged As: ', 'rolopress') . '"' . $current_tag . '"' . "</h2>\n";
    } elseif (is_tax()) {
        global $term;
        $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
        $pagedesc = $term->description;
        $pagetitle = '<h2 class="page-title taxonomy">' . __($term->name, 'rolopress') . __(' List', 'rolopress') . "</h2>\n";
    } elseif (is_author()) {
        global $wp_query;
        $curauth = $wp_query->get_queried_object();
        // get the authors name
        $pagetitle = '<h2 class="page-title author">' . __('Owned by: ', 'rolopress') . $curauth->display_name . "</h2>\n";
    } elseif (is_archive()) {
        if (is_day()) {
            $pagetitle = '<h2 class="page-title day">' . __('Items Created On: ', 'rolopress') . get_the_time(get_option('date_format')) . "</h2>\n";
        } elseif (is_month()) {
            $pagetitle = '<h2 class="page-title month">' . __('Items Created In: ', 'rolopress') . get_the_time('F Y') . "</h2>\n";
        } elseif (is_year()) {
            $pagetitle = '<h2 class="page-title year">' . __('Items Created In: ', 'rolopress') . get_the_time('Y') . "</h2>\n";
        }
    } else {
        $pagetitle = '<h2 class="page-title page">' . __(get_the_title(), 'rolopress') . "</h2>\n";
    }
    // show the page title
    echo $pagetitle;
    // show a description if set
    if (!empty($pagedesc)) {
        echo '<div class="archive-meta">' . $pagedesc . '</div>';
    }
}
Exemplo n.º 7
0
 function mytheme_description()
 {
     global $post;
     if (is_front_page()) {
         $description = get_bloginfo('description');
     } elseif (is_archive()) {
         $description = category_description();
     } elseif (is_tag()) {
         $description = tag_description();
     } else {
         setup_postdata($post);
         $content = get_the_excerpt();
         $author = get_userdata($post->post_author)->user_nicename;
         $description = htmlspecialchars($content);
     }
     echo '<meta name="description" content="' . strip_tags($description) . '">' . "\n";
 }
Exemplo n.º 8
0
      <div class="post_nav">
	  <div class="blog_desc">
	<h2>Dilettante</h2>
	<p>„Dilettante – teatr w ruchu” to działania Małopolskiego Instytutu Kultury, których celem jest wspieranie amatorskiego ruchu teatralnego. Wsparcie to polega na szkoleniu i podnoszeniu kompetencji animatorów grup teatralnych w ramach warsztatów z pedagogiki teatru, prowadzonych przez aktorów, pedagogów, teatrologów, a także na udostępnianiu materiałów dydaktycznych, udzielaniu konsultacji oraz informowaniu o wydarzeniach teatralnych w regionie.</p>
	</div>
	
	
        <div style="margin:1em 0;">
		<span class="spacer">Gdzie jestem?&nbsp;</span><span>Przeglądasz archiwa oznaczone tagiem&nbsp;</span><span class="spacer2">&nbsp;<?php 
    single_tag_title();
    ?>
</span>
		</div>

      <p><?php 
    echo tag_description($tag_id);
    ?>
</p>
      <h2 class="widgettitle">Tagi</h2>
      <ul>
        <li><?php 
    wp_tag_cloud('smallest=8&largest=16');
    ?>
</li>
      </ul>
    </div>
    <?php 
} elseif (is_month()) {
    ?>
      <div class="post_nav">
        <div style="margin:1em 0;">
Exemplo n.º 9
0
        function get_content_part()
        {
            global $post;
            ?>
			<div id="primary" class="content-area">
				<div id="content" class="site-content" role="main">	
			<?php 
            /* Start the Loop */
            $page_on_front = get_option('page_on_front');
            $page_for_posts = get_option('page_for_posts');
            if (is_page() && !empty($page_on_front) && !empty($page_for_posts) && $page_on_front == $page_for_posts) {
                echo '<div class="alert alert-danger"><strong>' . __("Front page displays Error.", 'fruitful') . '</strong> ' . __('Select different pages!', 'fruitful') . '</div>';
            } else {
                if (!is_archive() && !is_search() && !is_404()) {
                    if (is_home()) {
                        if (have_posts()) {
                            /* The loop */
                            while (have_posts()) {
                                the_post();
                                do_action('before_post_content_loop');
                                get_template_part('content', get_post_format());
                                do_action('after_post_content_loop');
                            }
                            fruitful_content_nav('nav-below');
                        } else {
                            get_template_part('no-results', 'index');
                        }
                    } else {
                        if (have_posts()) {
                            while (have_posts()) {
                                the_post();
                                if (is_page() && !is_front_page() && !is_home()) {
                                    get_template_part('content', 'page');
                                    if (fruitful_state_page_comment()) {
                                        comments_template('', true);
                                    }
                                } else {
                                    if (is_single()) {
                                        get_template_part('content', get_post_format());
                                        fruitful_content_nav('nav-below');
                                        if (fruitful_state_post_comment()) {
                                            if (comments_open() || '0' != get_comments_number()) {
                                                comments_template();
                                            }
                                        }
                                    } else {
                                        if (is_front_page()) {
                                            get_template_part('content', 'page');
                                        }
                                    }
                                }
                            }
                        }
                    }
                } else {
                    ?>
							<section id="primary" class="content-area">
								<div id="content" class="site-content" role="main">

								<?php 
                    if (have_posts()) {
                        ?>
										<header class="page-header">
											<h1 class="page-title">
												<?php 
                        if (is_archive()) {
                            if (is_category()) {
                                printf(__('Category Archives: %s', 'fruitful'), '<span>' . single_cat_title('', false) . '</span>');
                            } elseif (is_tag()) {
                                printf(__('Tag Archives: %s', 'fruitful'), '<span>' . single_tag_title('', false) . '</span>');
                            } elseif (is_author()) {
                                the_post();
                                printf(__('Author Archives: %s', 'fruitful'), '<span class="vcard"><a class="url fn n" href="' . get_author_posts_url(get_the_author_meta("ID")) . '" title="' . esc_attr(get_the_author()) . '" rel="me">' . get_the_author() . '</a></span>');
                                rewind_posts();
                            } elseif (is_day()) {
                                printf(__('Daily Archives: %s', 'fruitful'), '<span>' . get_the_date() . '</span>');
                            } elseif (is_month()) {
                                printf(__('Monthly Archives: %s', 'fruitful'), '<span>' . get_the_date('F Y') . '</span>');
                            } elseif (is_year()) {
                                printf(__('Yearly Archives: %s', 'fruitful'), '<span>' . get_the_date('Y') . '</span>');
                            } else {
                                _e('Archives', 'fruitful');
                            }
                        }
                        if (is_search()) {
                            printf(__('Search Results for: %s', 'fruitful'), '<span>' . get_search_query() . '</span>');
                        }
                        ?>
											</h1>
											<?php 
                        if (is_category()) {
                            $category_description = category_description();
                            if (!empty($category_description)) {
                                echo apply_filters('category_archive_meta', '<div class="taxonomy-description">' . $category_description . '</div>');
                            }
                        } elseif (is_tag()) {
                            $tag_description = tag_description();
                            if (!empty($tag_description)) {
                                echo apply_filters('tag_archive_meta', '<div class="taxonomy-description">' . $tag_description . '</div>');
                            }
                        }
                        ?>
										</header><!-- .page-header -->

										<?php 
                        /* Start the Loop */
                        while (have_posts()) {
                            the_post();
                            do_action('before_post_content_loop');
                            get_template_part('content', get_post_format());
                            do_action('after_post_content_loop');
                        }
                        fruitful_content_nav('nav-below');
                    } else {
                        if (is_404()) {
                            get_template_part('content', '404');
                        } else {
                            get_template_part('no-results', 'archive');
                        }
                    }
                    ?>

								</div><!-- #content .site-content -->
							</section><!-- #primary .content-area -->
						<?php 
                }
            }
            ?>
				</div>
			</div>	
		<?php 
        }
Exemplo n.º 10
0
		<?php 
if (have_posts()) {
    ?>
			<header class="archive-header">
				<h1 class="archive-title"><?php 
    printf(__('Tag Archives: %s', 'wpforge'), '<span>' . single_tag_title('', false) . '</span>');
    ?>
</h1>

			<?php 
    if (tag_description()) {
        // Show an optional tag description
        ?>
				<div class="archive-meta"><?php 
        echo tag_description();
        ?>
</div>
			<?php 
    }
    ?>
			</header><!-- .archive-header -->

			<?php 
    /* Start the Loop */
    while (have_posts()) {
        the_post();
        /* Include the post format-specific template for the content. If you want to
         * this in a child theme then include a file called called content-___.php
         * (where ___ is the post format) and that will be used instead.
         */
Exemplo n.º 11
0
get_header(); ?>

<section id="primary" class="span8">
	
	<?php tha_content_before(); ?>
	<div id="content" role="main">
		<?php tha_content_top();
		
		if ( have_posts() ) : ?>

			<header class="page-header">
				<h1 class="page-title"><?php
					printf( __( 'Tag Archives: %s', 'the-bootstrap' ), '<span>' . single_tag_title( '', false ) . '</span>' );
				?></h1>
	
				<?php if ( $tag_description = tag_description() ) {
					echo apply_filters( 'tag_archive_meta', '<div class="tag-archive-meta">' . $tag_description . '</div>' );
				} ?>
			</header><!-- .page-header -->
	
			<?php
			while ( have_posts() ) {
				the_post();
				get_template_part( '/partials/content', get_post_format() );
			}
			the_bootstrap_content_nav();
		else :
			get_template_part( '/partials/content', 'not-found' );
		endif;
		
		tha_content_bottom(); ?>
Exemplo n.º 12
0
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-3.0.txt
 */
global $wp_query, $post, $more;
$blog_type = yit_get_option('blog-type');
if (is_single()) {
    $blog_type = 'big';
}
if (is_category() || is_tag()) {
    if (is_category()) {
        echo do_shortcode(category_description());
    } elseif (is_tag()) {
        echo do_shortcode(tag_description());
    }
    echo '<div class="clear"></div>';
}
if (have_posts()) {
    if (is_category()) {
        if (yit_get_option('show-title-categories')) {
            ?>
            <h3><?php 
            echo apply_filters('yit_archive_category_title', sprintf(yit_get_option('page-categories-title'), single_cat_title('', false)));
            ?>
</h3>
        <?php 
        }
        ?>
        
Exemplo n.º 13
0
Arquivo: archive.php Projeto: 6226/wp
				</ul>
			</div>
			<h4>浏览<?php 
// If this is a category archive
if (is_category()) {
    printf('分类</h4>
			<h2>' . single_cat_title('', false) . '</h2>');
    if (category_description()) {
        echo '<p>' . category_description() . '</p>';
    }
    // If this is a tag archive
} elseif (is_tag()) {
    printf('标签</h4>
			<h2>' . single_tag_title('', false) . '</h2>');
    if (tag_description()) {
        echo '<p>' . tag_description() . '</p>';
    }
    // If this is a daily archive
} elseif (is_day()) {
    printf('日期存档</h4>
			<h2>' . get_the_time('Y年n月j日') . '</h2>');
    // If this is a monthly archive
} elseif (is_month()) {
    printf('月份存档</h4>
				<h2>' . get_the_time('Y年n月') . '</h2>');
    // If this is a yearly archive
} elseif (is_year()) {
    printf('年份存档</h4>
				<h2>' . get_the_time('Y年') . '</h2>');
    // If this is an author archive
} elseif (is_author()) {
/**
 * Generates basic metadata for the head area.
 *
 */
function amt_add_basic_metadata_head($post, $attachments, $embedded_media, $options)
{
    $do_description = $options["auto_description"] == "1" ? true : false;
    $do_keywords = $options["auto_keywords"] == "1" ? true : false;
    $do_noodp_description = $options["noodp_description"] == "1" ? true : false;
    // Array to store metadata
    $metadata_arr = array();
    // Robots Meta Tag.
    $robots_content = '';
    if ($do_noodp_description && (is_front_page() || is_singular())) {
        // Add NOODP on posts and pages
        $robots_content = 'NOODP,NOYDIR';
        // Allow filtering of the robots meta tag content.
        $robots_content = apply_filters('amt_robots_data', $robots_content);
    }
    // Add a robots meta tag if its content is not empty.
    if (!empty($robots_content)) {
        $metadata_arr[] = '<meta name="robots" content="' . $robots_content . '" />';
    }
    // Default front page displaying latest posts
    if (amt_is_default_front_page()) {
        // Description and Keywords from the Add-Meta-Tags settings override
        // default behaviour.
        // Description
        if ($do_description) {
            // Use the site description from the Add-Meta-Tags settings.
            // Fall back to the blog description.
            $site_description = $options["site_description"];
            if (empty($site_description)) {
                // Alternatively, use the blog description
                // Here we sanitize the provided description for safety
                $site_description = sanitize_text_field(amt_sanitize_description(get_bloginfo('description')));
            }
            // If we have a description, use it in the description meta-tag of the front page
            if (!empty($site_description)) {
                // Note: Contains multipage information through amt_process_paged()
                $metadata_arr[] = '<meta name="description" content="' . esc_attr(amt_process_paged($site_description)) . '" />';
            }
        }
        // Keywords
        if ($do_keywords) {
            // Use the site keywords from the Add-Meta-Tags settings.
            // Fall back to the blog categories.
            $site_keywords = $options["site_keywords"];
            if (empty($site_keywords)) {
                // Alternatively, use the blog categories
                // Here we sanitize the provided keywords for safety
                $site_keywords = sanitize_text_field(amt_sanitize_keywords(amt_get_all_categories()));
            }
            // If we have keywords, use them in the keywords meta-tag of the front page
            if (!empty($site_keywords)) {
                $metadata_arr[] = '<meta name="keywords" content="' . esc_attr($site_keywords) . '" />';
            }
        }
        // Attachments
    } elseif (is_attachment()) {
        // has to be before is_singular() since is_singular() is true for attachments.
        // Description
        if ($do_description) {
            $description = amt_get_content_description($post, $auto = $do_description);
            if (!empty($description)) {
                // Note: Contains multipage information through amt_process_paged()
                $metadata_arr[] = '<meta name="description" content="' . esc_attr(amt_process_paged($description)) . '" />';
            }
        }
        // No keywords
        // Content pages and static pages used as "front page" and "posts page"
        // This also supports products via is_singular()
    } elseif (is_singular() || amt_is_static_front_page() || amt_is_static_home()) {
        // Description
        if ($do_description) {
            $description = amt_get_content_description($post, $auto = $do_description);
            if (!empty($description)) {
                // Note: Contains multipage information through amt_process_paged()
                $metadata_arr[] = '<meta name="description" content="' . esc_attr(amt_process_paged($description)) . '" />';
            }
        }
        // Keywords
        if ($do_keywords) {
            $keywords = amt_get_content_keywords($post, $auto = $do_keywords);
            if (!empty($keywords)) {
                $metadata_arr[] = '<meta name="keywords" content="' . esc_attr($keywords) . '" />';
                // Static Posts Index Page
                // If no keywords have been set in the metabox and this is the static page,
                // which displayes the latest posts, use the categories of the posts in the loop.
            } elseif (amt_is_static_home()) {
                // Here we sanitize the provided keywords for safety
                $cats_from_loop = sanitize_text_field(amt_sanitize_keywords(implode(', ', amt_get_categories_from_loop())));
                if (!empty($cats_from_loop)) {
                    $metadata_arr[] = '<meta name="keywords" content="' . esc_attr($cats_from_loop) . '" />';
                }
            }
        }
        // 'news_keywords'
        $newskeywords = amt_get_post_meta_newskeywords($post->ID);
        if (!empty($newskeywords)) {
            $metadata_arr[] = '<meta name="news_keywords" content="' . esc_attr($newskeywords) . '" />';
        }
        // per post full meta tags
        $full_metatags_for_content = amt_get_post_meta_full_metatags($post->ID);
        if (!empty($full_metatags_for_content)) {
            $metadata_arr[] = html_entity_decode(stripslashes($full_metatags_for_content));
        }
        // Category based archives
    } elseif (is_category()) {
        if ($do_description) {
            // If set, the description of the category is used in the 'description' metatag.
            // Otherwise, a generic description is used.
            // Here we sanitize the provided description for safety
            $description_content = sanitize_text_field(amt_sanitize_description(category_description()));
            // Note: Contains multipage information through amt_process_paged()
            if (empty($description_content)) {
                // Add a filtered generic description.
                $generic_description = apply_filters('amt_generic_description_category_archive', __('Content filed under the %s category.', 'add-meta-tags'));
                $generic_description = sprintf($generic_description, single_cat_title($prefix = '', $display = false));
                $metadata_arr[] = '<meta name="description" content="' . esc_attr(amt_process_paged($generic_description)) . '" />';
            } else {
                $metadata_arr[] = '<meta name="description" content="' . esc_attr(amt_process_paged($description_content)) . '" />';
            }
        }
        if ($do_keywords) {
            // The category name alone is included in the 'keywords' metatag
            // Here we sanitize the provided keywords for safety
            $cur_cat_name = sanitize_text_field(amt_sanitize_keywords(single_cat_title($prefix = '', $display = false)));
            if (!empty($cur_cat_name)) {
                $metadata_arr[] = '<meta name="keywords" content="' . esc_attr($cur_cat_name) . '" />';
            }
        }
    } elseif (is_tag()) {
        if ($do_description) {
            // If set, the description of the tag is used in the 'description' metatag.
            // Otherwise, a generic description is used.
            // Here we sanitize the provided description for safety
            $description_content = sanitize_text_field(amt_sanitize_description(tag_description()));
            // Note: Contains multipage information through amt_process_paged()
            if (empty($description_content)) {
                // Add a filtered generic description.
                $generic_description = apply_filters('amt_generic_description_tag_archive', __('Content tagged with %s.', 'add-meta-tags'));
                $generic_description = sprintf($generic_description, single_tag_title($prefix = '', $display = false));
                $metadata_arr[] = '<meta name="description" content="' . esc_attr(amt_process_paged($generic_description)) . '" />';
            } else {
                $metadata_arr[] = '<meta name="description" content="' . esc_attr(amt_process_paged($description_content)) . '" />';
            }
        }
        if ($do_keywords) {
            // The tag name alone is included in the 'keywords' metatag
            // Here we sanitize the provided keywords for safety
            $cur_tag_name = sanitize_text_field(amt_sanitize_keywords(single_tag_title($prefix = '', $display = false)));
            if (!empty($cur_tag_name)) {
                $metadata_arr[] = '<meta name="keywords" content="' . esc_attr($cur_tag_name) . '" />';
            }
        }
        // Custom taxonomies - Should be after is_category() and is_tag(), as it would catch those taxonomies as well.
        // This also supports product groups via is_tax(). Only product groups that are WordPress custom taxonomies are supported.
    } elseif (is_tax()) {
        // Taxonomy term object.
        // When viewing taxonomy archives, the $post object is the taxonomy term object. Check with: var_dump($post);
        $tax_term_object = $post;
        //var_dump($tax_term_object);
        if ($do_description) {
            // If set, the description of the custom taxonomy term is used in the 'description' metatag.
            // Otherwise, a generic description is used.
            // Here we sanitize the provided description for safety
            $description_content = sanitize_text_field(amt_sanitize_description(term_description($tax_term_object->term_id, $tax_term_object->taxonomy)));
            // Note: Contains multipage information through amt_process_paged()
            if (empty($description_content)) {
                // Add a filtered generic description.
                // Construct the filter name. Template: ``amt_generic_description_TAXONOMYSLUG_archive``
                $taxonomy_description_filter_name = sprintf('amt_generic_description_%s_archive', $tax_term_object->taxonomy);
                // var_dump($taxonomy_description_filter_name);
                $generic_description = apply_filters($taxonomy_description_filter_name, __('Content filed under the %s taxonomy.', 'add-meta-tags'));
                $generic_description = sprintf($generic_description, single_term_title($prefix = '', $display = false));
                $metadata_arr[] = '<meta name="description" content="' . esc_attr(amt_process_paged($generic_description)) . '" />';
            } else {
                $metadata_arr[] = '<meta name="description" content="' . esc_attr(amt_process_paged($description_content)) . '" />';
            }
        }
        if ($do_keywords) {
            // The taxonomy term name alone is included in the 'keywords' metatag.
            // Here we sanitize the provided keywords for safety.
            $cur_tax_term_name = sanitize_text_field(amt_sanitize_keywords(single_term_title($prefix = '', $display = false)));
            if (!empty($cur_tax_term_name)) {
                $metadata_arr[] = '<meta name="keywords" content="' . esc_attr($cur_tax_term_name) . '" />';
            }
        }
    } elseif (is_author()) {
        // Author object
        // NOTE: Inside the author archives `$post->post_author` does not contain the author object.
        // In this case the $post (get_queried_object()) contains the author object itself.
        // We also can get the author object with the following code. Slug is what WP uses to construct urls.
        // $author = get_user_by( 'slug', get_query_var( 'author_name' ) );
        // Also, ``get_the_author_meta('....', $author)`` returns nothing under author archives.
        // Access user meta with:  $author->description, $author->user_email, etc
        // $author = get_queried_object();
        $author = $post;
        // If a bio has been set in the user profile, use it in the description metatag of the
        // first page of the author archive *ONLY*. The other pages of the author archive use a generic description.
        // This happens because the 1st page of the author archive is considered the profile page
        // by the other metadata modules.
        // Otherwise use a generic meta tag.
        if ($do_description) {
            // Here we sanitize the provided description for safety
            $author_description = sanitize_text_field(amt_sanitize_description($author->description));
            if (empty($author_description) || is_paged()) {
                // Note: Contains multipage information through amt_process_paged()
                // Add a filtered generic description.
                $generic_description = apply_filters('amt_generic_description_author_archive', __('Content published by %s.', 'add-meta-tags'));
                $generic_description = sprintf($generic_description, $author->display_name);
                $metadata_arr[] = '<meta name="description" content="' . esc_attr(amt_process_paged($generic_description)) . '" />';
            } else {
                $metadata_arr[] = '<meta name="description" content="' . esc_attr($author_description) . '" />';
            }
        }
        // For the keywords metatag use the categories of the posts the author has written and are displayed in the current page.
        if ($do_keywords) {
            // Here we sanitize the provided keywords for safety
            $cats_from_loop = sanitize_text_field(amt_sanitize_keywords(implode(', ', amt_get_categories_from_loop())));
            if (!empty($cats_from_loop)) {
                $metadata_arr[] = '<meta name="keywords" content="' . esc_attr($cats_from_loop) . '" />';
            }
        }
    }
    // Add site wide meta tags
    if (!empty($options["site_wide_meta"])) {
        $metadata_arr[] = html_entity_decode(stripslashes($options["site_wide_meta"]));
    }
    // On every page print the copyright head link
    if (!empty($options["copyright_url"])) {
        $metadata_arr[] = '<link rel="copyright" type="text/html" title="' . esc_attr(get_bloginfo('name')) . ' Copyright Information" href="' . esc_url_raw($options["copyright_url"]) . '" />';
    }
    // Filtering of the generated basic metadata
    $metadata_arr = apply_filters('amt_basic_metadata_head', $metadata_arr);
    return $metadata_arr;
}
Exemplo n.º 15
0
	</article><!--post -->
<?php 
    }
    $class = "";
    $information = "";
    if (in_array('category', $context)) {
        $information = $suf_cat_info_enabled == 'enabled' ? suffusion_get_category_information() : false;
        $class = 'info-category';
    } else {
        if (in_array('author', $context)) {
            $information = $suf_author_info_enabled == 'enabled' ? suffusion_get_author_information() : false;
            $class = 'author-profile';
        } else {
            if (in_array('tag', $context)) {
                $tag_id = get_query_var('tag_id');
                $information = $suf_tag_info_enabled == 'enabled' ? tag_description($tag_id) : false;
                $class = 'info-tag';
            }
        }
    }
    if ($suffusion_full_post_count_for_view == 0) {
        ?>
	<section class='post <?php 
        echo $class;
        ?>
 fix'>
<?php 
        if (!$hide_title) {
            ?>
		<header class="post-header">
			<h2 class="posttitle"><?php 
Exemplo n.º 16
0
        ?>
                    <div class="td-pb-span12 td-main-content">
                        <div class="td-ss-main-content">
                            <div class="td-page-header">
                                <h1 itemprop="name" class="entry-title td-page-title">
                                    <?php 
        /*<a itemprop="url" href="<?php echo get_tag_link(get_query_var('tag_id'));?>" rel="bookmark" title="<?php echo __td('Posts in ') . $current_tag_name?>"><?php echo $current_tag_name ?></a>*/
        ?>
                                    <span><?php 
        echo $current_tag_name;
        ?>
</span>
                                </h1>
                            </div>
                            <?php 
        $td_tag_description = tag_description();
        if (!empty($td_tag_description)) {
            echo '<div class="entry-content">';
            echo $td_tag_description;
            echo '</div>';
        }
        locate_template('loop.php', true);
        echo td_page_generator::get_pagination();
        ?>
                        </div>
                    </div>
                    <?php 
        break;
}
?>
        </div> <!-- /.td-pb-row -->
Exemplo n.º 17
0
function biz_vektor_getHeadDescription()
{
    global $wp_query;
    $post = $wp_query->get_queried_object();
    if (is_home() || is_page('home') || is_front_page()) {
        if (isset($post->post_excerpt) && $post->post_excerpt) {
            $metadescription = $post->post_excerpt;
        } else {
            $metadescription = get_bloginfo('description');
        }
    } else {
        if (is_category() || is_tax()) {
            $metadescription = $post->category_description;
            if (!$metadescription) {
                $metadescription = sprintf(__('About %s', 'biz-vektor'), single_cat_title()) . get_bloginfo('name') . ' ' . get_bloginfo('description');
            }
        } else {
            if (is_tag()) {
                $metadescription = strip_tags(tag_description());
                $metadescription = str_replace(array("\r\n", "\r", "\n"), '', $metadescription);
                // delete br
                if (!$metadescription) {
                    $metadescription = sprintf(__('About %s', 'biz-vektor'), single_tag_title()) . get_bloginfo('name') . ' ' . get_bloginfo('description');
                }
            } else {
                if (is_archive()) {
                    if (is_year()) {
                        $description_date = get_the_date(_x('Y', 'yearly archives date format', 'biz-vektor'));
                        $metadescription = sprintf(_x('Article of %s.', 'Yearly archive description', 'biz-vektor'), $description_date);
                        $metadescription .= ' ' . get_bloginfo('name') . ' ' . get_bloginfo('description');
                    } else {
                        if (is_month()) {
                            $description_date = get_the_date(_x('F Y', 'monthly archives date format', 'biz-vektor'));
                            $metadescription = sprintf(_x('Article of %s.', 'Archive description', 'biz-vektor'), $description_date);
                            $metadescription .= ' ' . get_bloginfo('name') . ' ' . get_bloginfo('description');
                        } else {
                            if (is_author()) {
                                $userObj = get_queried_object();
                                $metadescription = sprintf(_x('Article of %s.', 'Archive description', 'biz-vektor'), esc_html($userObj->display_name));
                                $metadescription .= ' ' . get_bloginfo('name') . ' ' . get_bloginfo('description');
                            } else {
                                $postType = get_post_type();
                                $metadescription = sprintf(_x('Article of %s.', 'Archive description', 'biz-vektor'), esc_html(get_post_type_object($postType)->labels->name));
                                $metadescription .= ' ' . get_bloginfo('name') . ' ' . get_bloginfo('description');
                            }
                        }
                    }
                } else {
                    if (is_page() || is_single()) {
                        $metaExcerpt = $post->post_excerpt;
                        if ($metaExcerpt) {
                            // $metadescription = strip_tags($post->post_excerpt);
                            $metadescription = strip_tags($post->post_excerpt);
                        } else {
                            $metadescription = mb_substr(strip_tags($post->post_content), 0, 240);
                            // kill tags and trim 240 chara
                            $metadescription = str_replace(array("\r\n", "\r", "\n"), ' ', $metadescription);
                            // delete br
                        }
                    } else {
                        $metadescription = get_bloginfo('description');
                    }
                }
            }
        }
    }
    global $paged;
    if ($paged != '0') {
        $metadescription = '[' . sprintf(__('Page of %s', 'biz-vektor'), $paged) . '] ' . $metadescription;
    }
    $metadescription = apply_filters('metadescriptionCustom', $metadescription);
    echo $metadescription;
}
Exemplo n.º 18
0
					printf( __( 'Yearly Archives: %s', 'pinktouch' ), '<span>' . get_the_date( 'Y' ) . '</span>' );
				elseif ( is_tag() ) :
					printf( __( 'Tag Archives: %s', 'pinktouch' ), '<span>' . single_tag_title( '', false ) . '</span>' );
				elseif ( is_author() ) :
					printf( __( 'Posted by: %s', 'pinktouch' ), '<span>' . get_the_author() . '</span>' );
				elseif ( is_category() ) :
					printf( __( 'Category Archives: %s', 'pinktouch' ), '<span>' . single_cat_title( '', false ) . '</span>' );
				else :
					_e( 'Archives', 'pinktouch' );
				endif;
			?>
			</h1>

			<?php $category_description = category_description(); if ( ! empty( $category_description ) ) echo apply_filters( 'archive_meta', '<div class="archive-meta">' . $category_description . '</div>' ); ?>

			<?php $tag_description = tag_description(); if ( ! empty( $tag_description ) ) echo apply_filters( 'tag_archive_meta', '<div class="archive-meta">' . $tag_description . '</div>' ); ?>

		</div>
	<?php endif; ?>

	<?php if ( is_search() ) : ?>
		<div class="page-header">
			<h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'pinktouch' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
		</div>
	<?php endif; ?>

	<?php rewind_posts(); ?>

	<?php if ( have_posts() ) : ?>

		<?php while ( have_posts() ) : the_post(); ?>
if (is_single() || is_page()) {
    $wipLayoutMeta = get_post_meta($post->ID, '_layout', true);
    $wipHeadMeta = get_post_meta($post->ID, 'head', true);
    $wipBodyMeta = get_post_meta($post->ID, 'body', true);
    if (is_page()) {
        $wipDynamicMeta = get_post_meta($post->ID, '_dynamic', true);
    }
} else {
    $wipDynamicMeta = false;
    $wipLayoutMeta = false;
    $wipHeadMeta = false;
    $wipBodyMeta = false;
}
// Taxonomy-specific variables
$catDesc = category_description();
$tagDesc = tag_description();
?>
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="<?php 
bloginfo('charset');
?>
">
		<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0">
		<title><?php 
wp_title('');
if (wp_title('', false)) {
    echo ' - ';
}
bloginfo('name');
Exemplo n.º 20
0
/**
 * 作用: header中追加description和keyword.
 * 来源: lifishake原创
 * URL:  http://pewae.com
 */
function apip_desc_tag()
{
    global $apip_options;
    if (is_home()) {
        $description = trim($apip_options['hd_home_text']);
        if ('' == $description) {
            $description = get_bloginfo('description');
        }
        $keywords = trim($apip_options['hd_home_keyword']);
        if ('' == $keywords) {
            $tags = get_tags(array('orderby' => 'count', 'order' => 'DESC', 'number' => '10'));
            foreach ($tags as $tag) {
                $keywords .= $tag->name . ',';
            }
        }
    } else {
        if (is_single()) {
            global $post;
            $description = substr(strip_tags($post->post_content), 0, 240) . "...";
            $keywords = "";
            $tags = wp_get_post_tags($post->ID);
            foreach ($tags as $tag) {
                $keywords .= $tag->name . ',';
            }
        } elseif (is_category()) {
            $description = category_description();
            $keywords = single_cat_title('', false);
        } elseif (is_tag()) {
            $description = tag_description();
            $keywords = single_tag_title('', false);
        } else {
            return;
        }
    }
    ?>
<meta name="description" content="<?php 
    echo $description;
    ?>
" />
<meta name="keywords" content="<?php 
    echo $keywords;
    ?>
" />
<?php 
}
Exemplo n.º 21
0
 /**
  * Gets the title that will be used by AIOSEOP for title rewrites or returns false.
  *
  * @param $post
  *
  * @return bool|string
  */
 function get_aioseop_title($post)
 {
     global $aioseop_options;
     // the_search_query() is not suitable, it cannot just return.
     global $s, $STagging;
     $opts = $this->meta_opts;
     if (is_front_page()) {
         if (!empty($aioseop_options['aiosp_use_static_home_info'])) {
             global $post;
             if (get_option('show_on_front') == 'page' && is_page() && $post->ID == get_option('page_on_front')) {
                 $title = $this->internationalize(get_post_meta($post->ID, '_aioseop_title', true));
                 if (!$title) {
                     $title = $this->internationalize($post->post_title);
                 }
                 if (!$title) {
                     $title = $this->internationalize($this->get_original_title('', false));
                 }
                 if (!empty($aioseop_options['aiosp_home_page_title_format'])) {
                     $title = $this->apply_page_title_format($title, $post, $aioseop_options['aiosp_home_page_title_format']);
                 }
                 $title = $this->paged_title($title);
                 $title = apply_filters('aioseop_home_page_title', $title);
             }
         } else {
             $title = $this->internationalize($aioseop_options['aiosp_home_title']);
             if (!empty($aioseop_options['aiosp_home_page_title_format'])) {
                 $title = $this->apply_page_title_format($title, null, $aioseop_options['aiosp_home_page_title_format']);
             }
         }
         if (empty($title)) {
             $title = $this->internationalize(get_option('blogname')) . ' | ' . $this->internationalize(get_bloginfo('description'));
         }
         global $post;
         $post_id = $post->ID;
         if (is_post_type_archive() && is_post_type_archive('product') && ($post_id = woocommerce_get_page_id('shop') && ($post = get_post($post_id)))) {
             $frontpage_id = get_option('page_on_front');
             if (woocommerce_get_page_id('shop') == get_option('page_on_front') && !empty($aioseop_options['aiosp_use_static_home_info'])) {
                 $title = $this->internationalize(get_post_meta($post->ID, '_aioseop_title', true));
             }
             // $title = $this->internationalize( $aioseop_options['aiosp_home_title'] );
             if (!$title) {
                 $title = $this->internationalize(get_post_meta($frontpage_id, '_aioseop_title', true));
             }
             // This is/was causing the first product to come through.
             if (!$title) {
                 $title = $this->internationalize($post->post_title);
             }
             if (!$title) {
                 $title = $this->internationalize($this->get_original_title('', false));
             }
             $title = $this->apply_page_title_format($title, $post);
             $title = $this->paged_title($title);
             $title = apply_filters('aioseop_title_page', $title);
             return $title;
         }
         return $this->paged_title($title);
         //this is returned for woo
     } else {
         if (is_attachment()) {
             if (null === $post) {
                 return false;
             }
             $title = get_post_meta($post->ID, '_aioseop_title', true);
             if (empty($title)) {
                 $title = $post->post_title;
             }
             if (empty($title)) {
                 $title = $this->get_original_title('', false);
             }
             if (empty($title)) {
                 $title = get_the_title($post->post_parent);
             }
             $title = apply_filters('aioseop_attachment_title', $this->internationalize($this->apply_post_title_format($title, '', $post)));
             return $title;
         } else {
             if (is_page() || $this->is_static_posts_page() || is_home() && !$this->is_static_posts_page()) {
                 if (null === $post) {
                     return false;
                 }
                 if ($this->is_static_front_page() && ($home_title = $this->internationalize($aioseop_options['aiosp_home_title']))) {
                     if (!empty($aioseop_options['aiosp_home_page_title_format'])) {
                         $home_title = $this->apply_page_title_format($home_title, $post, $aioseop_options['aiosp_home_page_title_format']);
                     }
                     // Home title filter.
                     return apply_filters('aioseop_home_page_title', $home_title);
                 } else {
                     $page_for_posts = '';
                     if (is_home()) {
                         $page_for_posts = get_option('page_for_posts');
                     }
                     if ($page_for_posts) {
                         $title = $this->internationalize(get_post_meta($page_for_posts, '_aioseop_title', true));
                         if (!$title) {
                             $post_page = get_post($page_for_posts);
                             $title = $this->internationalize($post_page->post_title);
                         }
                     } else {
                         $title = $this->internationalize(get_post_meta($post->ID, '_aioseop_title', true));
                         if (!$title) {
                             $title = $this->internationalize($post->post_title);
                         }
                     }
                     if (!$title) {
                         $title = $this->internationalize($this->get_original_title('', false));
                     }
                     $title = $this->apply_page_title_format($title, $post);
                     $title = $this->paged_title($title);
                     $title = apply_filters('aioseop_title_page', $title);
                     if ($this->is_static_posts_page()) {
                         $title = apply_filters('single_post_title', $title);
                     }
                     return $title;
                 }
             } else {
                 if (function_exists('woocommerce_get_page_id') && is_post_type_archive('product') && ($post_id = woocommerce_get_page_id('shop')) && ($post = get_post($post_id))) {
                     // Too far down? -mrt.
                     $title = $this->internationalize(get_post_meta($post->ID, '_aioseop_title', true));
                     if (!$title) {
                         $title = $this->internationalize($post->post_title);
                     }
                     if (!$title) {
                         $title = $this->internationalize($this->get_original_title('', false));
                     }
                     $title = $this->apply_page_title_format($title, $post);
                     $title = $this->paged_title($title);
                     $title = apply_filters('aioseop_title_page', $title);
                     return $title;
                 } else {
                     if (is_single()) {
                         // We're not in the loop :(.
                         if (null === $post) {
                             return false;
                         }
                         $categories = $this->get_all_categories();
                         $category = '';
                         if (count($categories) > 0) {
                             $category = $categories[0];
                         }
                         $title = $this->internationalize(get_post_meta($post->ID, '_aioseop_title', true));
                         if (!$title) {
                             $title = $this->internationalize(get_post_meta($post->ID, 'title_tag', true));
                             if (!$title) {
                                 $title = $this->internationalize($this->get_original_title('', false));
                             }
                         }
                         if (empty($title)) {
                             $title = $post->post_title;
                         }
                         if (!empty($title)) {
                             $title = $this->apply_post_title_format($title, $category, $post);
                         }
                         $title = $this->paged_title($title);
                         return apply_filters('aioseop_title_single', $title);
                     } else {
                         if (is_search() && isset($s) && !empty($s)) {
                             $search = esc_attr(stripslashes($s));
                             if (!empty($aioseop_options['aiosp_cap_titles'])) {
                                 $search = $this->capitalize($search);
                             }
                             $title_format = $aioseop_options['aiosp_search_title_format'];
                             $title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title_format);
                             if (strpos($title, '%blog_description%') !== false) {
                                 $title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $title);
                             }
                             if (strpos($title, '%search%') !== false) {
                                 $title = str_replace('%search%', $search, $title);
                             }
                             $title = $this->paged_title($title);
                             return $title;
                         } else {
                             if (is_tag()) {
                                 global $utw;
                                 $tag = $tag_description = '';
                                 if ($utw) {
                                     $tags = $utw->GetCurrentTagSet();
                                     $tag = $tags[0]->tag;
                                     $tag = str_replace('-', ' ', $tag);
                                 } else {
                                     if (AIOSEOPPRO) {
                                         if (!empty($opts) && !empty($opts['aiosp_title'])) {
                                             $tag = $opts['aiosp_title'];
                                         }
                                         if (!empty($opts)) {
                                             if (!empty($opts['aiosp_title'])) {
                                                 $tag = $opts['aiosp_title'];
                                             }
                                             if (!empty($opts['aiosp_description'])) {
                                                 $tag_description = $opts['aiosp_description'];
                                             }
                                         }
                                     }
                                     if (empty($tag)) {
                                         $tag = $this->get_original_title('', false);
                                     }
                                     if (empty($tag_description)) {
                                         $tag_description = tag_description();
                                     }
                                     $tag = $this->internationalize($tag);
                                     $tag_description = $this->internationalize($tag_description);
                                 }
                                 if ($tag) {
                                     if (!empty($aioseop_options['aiosp_cap_titles'])) {
                                         $tag = $this->capitalize($tag);
                                     }
                                     $title_format = $aioseop_options['aiosp_tag_title_format'];
                                     $title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title_format);
                                     if (strpos($title, '%blog_description%') !== false) {
                                         $title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $title);
                                     }
                                     if (strpos($title, '%tag%') !== false) {
                                         $title = str_replace('%tag%', $tag, $title);
                                     }
                                     if (strpos($title, '%tag_description%') !== false) {
                                         $title = str_replace('%tag_description%', $tag_description, $title);
                                     }
                                     if (strpos($title, '%taxonomy_description%') !== false) {
                                         $title = str_replace('%taxonomy_description%', $tag_description, $title);
                                     }
                                     $title = trim(wp_strip_all_tags($title));
                                     $title = str_replace(array('"', "\r\n", "\n"), array('&quot;', ' ', ' '), $title);
                                     $title = $this->paged_title($title);
                                     return $title;
                                 }
                             } else {
                                 if ((is_tax() || is_category()) && !is_feed()) {
                                     return $this->get_tax_title();
                                 } else {
                                     if (isset($STagging) && $STagging->is_tag_view()) {
                                         // Simple tagging support.
                                         $tag = $STagging->search_tag;
                                         if ($tag) {
                                             if (!empty($aioseop_options['aiosp_cap_titles'])) {
                                                 $tag = $this->capitalize($tag);
                                             }
                                             $title_format = $aioseop_options['aiosp_tag_title_format'];
                                             $title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title_format);
                                             if (strpos($title, '%blog_description%') !== false) {
                                                 $title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $title);
                                             }
                                             if (strpos($title, '%tag%') !== false) {
                                                 $title = str_replace('%tag%', $tag, $title);
                                             }
                                             $title = $this->paged_title($title);
                                             return $title;
                                         }
                                     } else {
                                         if (is_archive() || is_post_type_archive()) {
                                             if (is_author()) {
                                                 $author = $this->internationalize($this->get_original_title('', false));
                                                 $title_format = $aioseop_options['aiosp_author_title_format'];
                                                 $new_title = str_replace('%author%', $author, $title_format);
                                             } else {
                                                 if (is_date()) {
                                                     global $wp_query;
                                                     $date = $this->internationalize($this->get_original_title('', false));
                                                     $title_format = $aioseop_options['aiosp_date_title_format'];
                                                     $new_title = str_replace('%date%', $date, $title_format);
                                                     $day = get_query_var('day');
                                                     if (empty($day)) {
                                                         $day = '';
                                                     }
                                                     $new_title = str_replace('%day%', $day, $new_title);
                                                     $monthnum = get_query_var('monthnum');
                                                     $year = get_query_var('year');
                                                     if (empty($monthnum) || is_year()) {
                                                         $month = '';
                                                         $monthnum = 0;
                                                     }
                                                     $month = date('F', mktime(0, 0, 0, (int) $monthnum, 1, (int) $year));
                                                     $new_title = str_replace('%monthnum%', $monthnum, $new_title);
                                                     if (strpos($new_title, '%month%') !== false) {
                                                         $new_title = str_replace('%month%', $month, $new_title);
                                                     }
                                                     if (strpos($new_title, '%year%') !== false) {
                                                         $new_title = str_replace('%year%', get_query_var('year'), $new_title);
                                                     }
                                                 } else {
                                                     if (is_post_type_archive()) {
                                                         if (empty($title)) {
                                                             $title = $this->get_original_title('', false);
                                                         }
                                                         $new_title = apply_filters('aioseop_archive_title', $this->apply_archive_title_format($title));
                                                     } else {
                                                         return false;
                                                     }
                                                 }
                                             }
                                             $new_title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $new_title);
                                             if (strpos($new_title, '%blog_description%') !== false) {
                                                 $new_title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $new_title);
                                             }
                                             $title = trim($new_title);
                                             $title = $this->paged_title($title);
                                             return $title;
                                         } else {
                                             if (is_404()) {
                                                 $title_format = $aioseop_options['aiosp_404_title_format'];
                                                 $new_title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title_format);
                                                 if (strpos($new_title, '%blog_description%') !== false) {
                                                     $new_title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $new_title);
                                                 }
                                                 if (strpos($new_title, '%request_url%') !== false) {
                                                     $new_title = str_replace('%request_url%', $_SERVER['REQUEST_URI'], $new_title);
                                                 }
                                                 if (strpos($new_title, '%request_words%') !== false) {
                                                     $new_title = str_replace('%request_words%', $this->request_as_words($_SERVER['REQUEST_URI']), $new_title);
                                                 }
                                                 if (strpos($new_title, '%404_title%') !== false) {
                                                     $new_title = str_replace('%404_title%', $this->internationalize($this->get_original_title('', false)), $new_title);
                                                 }
                                                 return $new_title;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return false;
 }
Exemplo n.º 22
0
 function wp_head()
 {
     if (is_feed()) {
         return;
     }
     if (aioseop_mrt_exclude_this_page()) {
         return;
     }
     global $wp_query;
     global $aioseop_options;
     $post = $this->get_queried_object();
     $meta_string = null;
     if (is_single() || is_page()) {
         $aiosp_disable = htmlspecialchars(stripcslashes(get_post_meta($post->ID, '_aioseop_disable', true)));
         if ($aiosp_disable) {
             return;
         }
         if (empty($aioseop_options['aiosp_enablecpost'])) {
             $wp_post_types = get_post_types(array('_builtin' => true));
             // don't display meta if SEO isn't enabled on custom post types -- pdb
             if (!is_singular($wp_post_types)) {
                 return;
             }
         } else {
             if (!empty($aioseop_options['aiosp_cpostadvanced'])) {
                 $wp_post_types = $aioseop_options['aiosp_cpostactive'];
                 if (empty($aioseop_options['aiosp_cpostactive'])) {
                     return;
                 }
                 if (!is_singular($wp_post_types)) {
                     return;
                 }
             }
         }
     }
     $force_rewrites = 1;
     if (isset($aioseop_options['aiosp_force_rewrites'])) {
         $force_rewrites = $aioseop_options['aiosp_force_rewrites'];
     }
     if (!empty($aioseop_options['aiosp_rewrite_titles']) && $force_rewrites) {
         // make the title rewrite as short as possible
         if (function_exists('ob_list_handlers')) {
             $active_handlers = ob_list_handlers();
         } else {
             $active_handlers = array();
         }
         if (sizeof($active_handlers) > 0 && strtolower($active_handlers[sizeof($active_handlers) - 1]) == strtolower('All_in_One_SEO_Pack::output_callback_for_title')) {
             ob_end_flush();
         } else {
             $this->log("another plugin interfering?");
             // if we get here there *could* be trouble with another plugin :(
             $this->ob_start_detected = true;
             if (function_exists('ob_list_handlers')) {
                 foreach (ob_list_handlers() as $handler) {
                     $this->log("detected output handler {$handler}");
                 }
             }
         }
     }
     echo "\n<!-- All in One SEO Pack {$this->version} by Michael Torbert of Semper Fi Web Design";
     if ($this->ob_start_detected) {
         echo "ob_start_detected ";
     }
     echo "[{$this->title_start},{$this->title_end}] ";
     echo "-->\n";
     $is_front_page = is_front_page();
     $is_front_page_keywords = $is_front_page && $aioseop_options['aiosp_home_keywords'] && !$this->is_static_posts_page() || $this->is_static_front_page();
     $page_for_posts = get_option('page_for_posts');
     $blog_page = '';
     if ($page_for_posts && (!is_object($post) || $page_for_posts != $post->ID) && is_home()) {
         $blog_page = get_post($page_for_posts);
     }
     if ($is_front_page_keywords) {
         $keywords = trim($this->internationalize($aioseop_options['aiosp_home_keywords']));
     } elseif ($this->is_static_posts_page() && !$aioseop_options['aiosp_dynamic_postspage_keywords']) {
         // and if option = use page set keywords instead of keywords from recent posts
         $keywords = stripcslashes($this->internationalize(get_post_meta($post->ID, "_aioseop_keywords", true)));
     } elseif (!empty($blog_page) && !$aioseop_options['aiosp_dynamic_postspage_keywords']) {
         $keywords = stripcslashes($this->internationalize(get_post_meta($blog_page->ID, "_aioseop_keywords", true)));
     } else {
         $keywords = $this->get_all_keywords();
     }
     if (is_category() && $this->show_page_description()) {
         $description = $this->internationalize(category_description());
     } elseif (is_tag() && $this->show_page_description()) {
         $description = $this->internationalize(tag_description());
     } elseif (is_tax() && $this->show_page_description()) {
         $description = $this->internationalize(term_description());
     } elseif (is_author() && $this->show_page_description()) {
         $description = $this->internationalize(get_the_author_meta('description'));
     } else {
         if ($is_front_page) {
             $description = trim(stripcslashes($this->internationalize($aioseop_options['aiosp_home_description'])));
         } else {
             if (is_single() || is_page() || is_home() || $this->is_static_posts_page()) {
                 if ($this->is_static_front_page()) {
                     $description = trim(stripcslashes($this->internationalize($aioseop_options['aiosp_home_description'])));
                 } elseif (!empty($blog_page)) {
                     $description = $this->get_post_description($blog_page);
                 }
             }
         }
     }
     if (empty($description) && is_object($post) && !is_archive() && empty($blog_page)) {
         $description = $this->get_post_description($post);
     }
     $description = apply_filters('aioseop_description', $description);
     if (isset($description) && strlen($description) > $this->minimum_description_length && !($is_front_page && is_paged())) {
         $description = trim(strip_tags($description));
         $description = str_replace('"', '', $description);
         // replace newlines on mac / windows?
         $description = str_replace("\r\n", ' ', $description);
         // maybe linux uses this alone
         $description = str_replace("\n", ' ', $description);
         if (!isset($meta_string)) {
             $meta_string = '';
         }
         // description format
         $description_format = $aioseop_options['aiosp_description_format'];
         if (!isset($description_format) || empty($description_format)) {
             $description_format = "%description%";
         }
         $description = str_replace('%description%', apply_filters('aioseop_description_override', $description), $description_format);
         $description = str_replace('%blog_title%', get_bloginfo('name'), $description);
         $description = str_replace('%blog_description%', get_bloginfo('description'), $description);
         $description = str_replace('%wp_title%', $this->get_original_title(), $description);
         if ($aioseop_options['aiosp_can'] && is_attachment()) {
             $url = $this->aiosp_mrt_get_url($wp_query);
             if ($url) {
                 $matches = array();
                 preg_match_all('/(\\d+)/', $url, $matches);
                 if (is_array($matches)) {
                     $uniqueDesc = join('', $matches[0]);
                 }
             }
             $description .= ' ' . $uniqueDesc;
         }
         $meta_string .= sprintf("<meta name=\"description\" content=\"%s\" />\n", $description);
     }
     $keywords = apply_filters('aioseop_keywords', $keywords);
     if (isset($aioseop_options['aiosp_togglekeywords'])) {
         $togglekeywords = $aioseop_options['aiosp_togglekeywords'];
     } else {
         $togglekeywords = 0;
     }
     if (isset($keywords) && $togglekeywords == 0 && !empty($keywords) && !(is_home() && is_paged())) {
         if (isset($meta_string)) {
             $meta_string .= "\n";
         }
         $keywords = str_replace('"', '', $keywords);
         $meta_string .= sprintf("<meta name=\"keywords\" content=\"%s\" />\n", $keywords);
     }
     $is_tag = is_tag();
     if (is_category() && $aioseop_options['aiosp_category_noindex'] || !is_category() && is_archive() && !$is_tag && $aioseop_options['aiosp_archive_noindex'] || $aioseop_options['aiosp_tags_noindex'] && $is_tag) {
         $meta_string .= '<meta name="robots" content="noindex,follow" />' . "\n";
     } else {
         if (is_single() || is_page()) {
             $aiosp_noindex = htmlspecialchars(stripcslashes(get_post_meta($post->ID, '_aioseop_noindex', true)));
             $aiosp_nofollow = htmlspecialchars(stripcslashes(get_post_meta($post->ID, '_aioseop_nofollow', true)));
             if ($aiosp_noindex || $aiosp_nofollow) {
                 $noindex = "index";
                 $nofollow = "follow";
                 if ($aiosp_noindex) {
                     $noindex = "no" . $noindex;
                 }
                 if ($aiosp_nofollow) {
                     $nofollow = "no" . $nofollow;
                 }
                 $meta_string .= '<meta name="robots" content="' . $noindex . ',' . $nofollow . '" />' . "\n";
             }
         }
     }
     if ($is_front_page) {
         foreach (array('google' => 'google-site-verification', 'bing' => 'msvalidate.01', 'pinterest' => 'p:domain_verify') as $k => $v) {
             if (!empty($aioseop_options["aiosp_{$k}_verify"])) {
                 $meta_string .= '<meta name="' . $v . '" content="' . trim(strip_tags($aioseop_options["aiosp_{$k}_verify"])) . '" />' . "\n";
             }
         }
     }
     foreach (array('page_meta', 'post_meta', 'home_meta', 'front_meta') as $meta) {
         if (!empty($aioseop_options["aiosp_{$meta}_tags"])) {
             ${$meta} = html_entity_decode(stripcslashes($aioseop_options["aiosp_{$meta}_tags"]));
         } else {
             ${$meta} = '';
         }
     }
     if (is_page() && isset($page_meta) && !empty($page_meta) && (!$is_front_page || empty($front_meta))) {
         if (isset($meta_string)) {
             $meta_string .= "\n";
         }
         $meta_string .= $page_meta;
     }
     if (is_single() && isset($post_meta) && !empty($post_meta)) {
         if (isset($meta_string)) {
             $meta_string .= "\n";
         }
         $meta_string .= $post_meta;
     }
     if (!empty($post) && isset($post->post_author) && empty($aioseop_options['aiosp_google_disable_profile'])) {
         $googleplus = get_the_author_meta('googleplus', $post->post_author);
     }
     if (empty($googleplus) && !empty($aioseop_options['aiosp_google_publisher'])) {
         $googleplus = $aioseop_options['aiosp_google_publisher'];
     }
     if ($is_front_page && !empty($aioseop_options['aiosp_google_publisher'])) {
         $meta_string = '<link rel="publisher" href="' . $aioseop_options['aiosp_google_publisher'] . '" />' . "\n" . $meta_string;
     }
     if (is_singular() && $googleplus) {
         $meta_string = '<link rel="author" href="' . $googleplus . '" />' . "\n" . $meta_string;
     } else {
         if (!empty($aioseop_options['aiosp_google_publisher'])) {
             $meta_string = '<link rel="author" href="' . $aioseop_options['aiosp_google_publisher'] . '" />' . "\n" . $meta_string;
         }
     }
     if ($is_front_page && !empty($front_meta)) {
         if (isset($meta_string)) {
             $meta_string .= "\n";
         }
         $meta_string .= $front_meta;
     } else {
         if (is_home() && !empty($home_meta)) {
             if (isset($meta_string)) {
                 $meta_string .= "\n";
             }
             $meta_string .= $home_meta;
         }
     }
     if ($meta_string != null) {
         echo "{$meta_string}\n";
     }
     if ($aioseop_options['aiosp_can'] && ($url = $this->aiosp_mrt_get_url($wp_query))) {
         $url = apply_filters('aioseop_canonical_url', $url);
         echo "" . '<link rel="canonical" href="' . $url . '" />' . "\n";
     }
     do_action('aioseop_modules_wp_head');
     echo "<!-- /all in one seo pack -->\n";
 }
Exemplo n.º 23
0
                   <h1 <?php 
echo $ag_page['page_title_color'] ? 'style="color: ' . $ag_page['page_title_color'] . ';"' : '';
?>
><?php 
wp_title("", true);
?>
</h1>
                <?php 
if (tag_description()) {
    ?>
 
                    <h2 <?php 
    echo $ag_page['page_desc_color'] ? 'class="colored" style="color: ' . $ag_page['page_desc_color'] . ';"' : '';
    ?>
><?php 
    echo strip_tags(apply_filters('the_content', tag_description()));
    ?>
</h2>
                <?php 
}
?>
		
                </div>
            </div>
            <div class="verticalcenter cell">
            	<div class="six columns">
				   <?php 
echo $ag_page['button'];
?>
           		</div>
            </div>
Exemplo n.º 24
0
function dtthemes_mytheme_seo_meta()
{
    $status = dtthemes_mytheme_is_plugin_active('all-in-one-seo-pack/all_in_one_seo_pack.php') || dtthemes_mytheme_is_plugin_active('wordpress-seo/wp-seo.php');
    if (!$status) {
        global $post;
        $output = "";
        $meta_description = '';
        $meta_keywords = '';
        $pageid = get_option('page_on_front');
        $template = get_post_meta($pageid, '_wp_page_template', true);
        if (is_feed()) {
            return;
        }
        if (is_404() || is_search()) {
            return;
        }
        # meta robots Noindex ,NoFollow
        if (is_category() && dtthemes_mytheme_option('seo', 'use_noindex_in_cats_page')) {
            $output .= '<meta name="robots" content="noindex,follow" />' . "\r";
        } elseif (is_archive() && dtthemes_mytheme_option('seo', 'use_noindex_in_archives_page')) {
            $output .= '<meta name="robots" content="noindex,follow" />' . "\r";
        } elseif (is_tag() && !dtthemes_mytheme_option('seo', 'use_noindex_in_tags_archieve_page')) {
            $output .= '<meta name="robots" content="noindex,follow" />' . "\r";
        }
        #End
        ### Meta Description ###
        if (is_home() || is_front_page()) {
            $meta_description = get_post_meta($post->ID, '_seo_description', true);
        } elseif (is_page()) {
            $meta_description = get_post_meta($post->ID, '_seo_description', true);
            if (empty($meta_description) && dtthemes_mytheme_option('seo', 'auto_generate_desc')) {
                $meta_description = substr(strip_shortcodes(strip_tags($post->post_content)), 0, 155);
            }
            #post
        } elseif (is_singular() || is_single()) {
            $meta_description = get_post_meta($post->ID, '_seo_description', true);
            if (empty($meta_description) && dtthemes_mytheme_option('seo', 'auto_generate_desc')) {
                $meta_description = trim(substr(strip_shortcodes(strip_tags($post->post_content)), 0, 155));
            }
            #is_category()
        } elseif (is_category()) {
            #$categories = get_the_category();
            #$meta_description = $categories[0]->description;
            $meta_description = strip_tags(category_description());
            #is_tag()
        } elseif (is_tag()) {
            $meta_description = strip_tags(tag_description());
            #is_author
        } elseif (is_author()) {
            $author_id = get_query_var('author');
            if (!empty($author_id)) {
                $meta_description = get_the_author_meta('description', $author_id);
            }
        }
        if (!empty($meta_description)) {
            $meta_description = trim(substr($meta_description, 0, 155));
            $meta_description = htmlspecialchars($meta_description);
            $output .= "<meta name='description' content='{$meta_description}' />\r";
        }
        ### Meta Description End###
        if (is_home() || is_front_page()) {
            $meta_keywords = get_post_meta($post->ID, '_seo_keywords', true);
        } elseif (is_page()) {
            $meta_keywords = get_post_meta($post->ID, '_seo_keywords', true);
            #post
        } elseif (is_singular() || is_single()) {
            $meta_keywords = get_post_meta($post->ID, '_seo_keywords', true);
            #Use Categories in Keyword
            if (dtthemes_mytheme_option('seo', 'use_cats_in_meta_keword')) {
                $categories = get_the_category();
                $c = '';
                foreach ($categories as $category) {
                    $c .= $category->name . ',';
                }
                $c = substr(trim($c), "0", strlen(trim($c)) - 1);
                $meta_keywords = $meta_keywords . ',' . $c;
            }
            #Use Tags in Keyword
            if (dtthemes_mytheme_option('seo', 'use_tags_in_meta_keword')) {
                $posttags = get_the_tags();
                $ptags = '';
                if ($posttags) {
                    foreach ($posttags as $posttag) {
                        $ptags .= $posttag->name . ',';
                    }
                    $ptags = substr(trim($ptags), "0", strlen(trim($ptags)) - 1);
                    $meta_keywords = $meta_keywords . ',' . $ptags;
                }
            }
            #Archive
        } elseif (is_archive()) {
            global $posts;
            $keywords = array();
            foreach ($posts as $post) {
                # If attachment then use parent post id
                $id = is_attachment() ? $post->post_parent : (!empty($post->ID) ? $post->ID : '');
                $keywords_from_posts = get_post_meta($id, '_seo_keywords', true);
                if (!empty($keywords_from_posts)) {
                    $traverse = explode(',', $keywords_from_posts);
                    foreach ($traverse as $keyword) {
                        $keywords[] = $keyword;
                    }
                }
                #Use Tags in Keyword
                if (dtthemes_mytheme_option('seo', 'use_tags_in_meta_keword')) {
                    $tags = get_the_tags($id);
                    if ($tags && is_array($tags)) {
                        foreach ($tags as $tag) {
                            $keywords[] = $tag->name;
                        }
                    }
                }
                #Use categories in Keywords
                if (dtthemes_mytheme_option('seo', 'use_cats_in_meta_keword')) {
                    $categories = get_the_category($id);
                    foreach ($categories as $category) {
                        $keywords[] = $category->cat_name;
                    }
                }
            }
            # Make keywords lowercase
            $keywords = array_unique($keywords);
            $small_keywords = array();
            $final_keywords = array();
            foreach ($keywords as $word) {
                $final_keywords[] = strtolower($word);
            }
            if (!empty($final_keywords)) {
                $meta_keywords = implode(",", $final_keywords);
            }
            #search || 404 page
        } elseif (is_404() || is_search()) {
            $meta_keywords = '';
        }
        if (!empty($meta_keywords)) {
            $output .= "\t<meta name='keywords' content='{$meta_keywords}'/>\r";
        }
        ### Meta Keyword End###
        #Generate canonical_url
        if (dtthemes_mytheme_option('seo', 'use_canonical_urls')) {
            $url = dtthemes_mytheme_canonical();
            if ($url) {
                $output .= "<link rel='canonical' href='{$url}'/>\r";
            }
        }
        echo $output;
    }
}
Exemplo n.º 25
0
 function wp_head()
 {
     if (is_feed()) {
         return;
     }
     if (aioseop_mrt_exclude_this_page()) {
         return;
     }
     static $aioseop_dup_counter = 0;
     $aioseop_dup_counter++;
     if ($aioseop_dup_counter > 1) {
         echo "\n<!-- Debug Warning: All in One SEO Pack Pro meta data was included again from " . current_filter() . " filter. Called {$aioseop_dup_counter} times! -->\n";
         return;
     }
     if (is_home() && !is_front_page()) {
         $post = $this->get_blog_page();
     } else {
         $post = $this->get_queried_object();
     }
     global $wp_query;
     global $aioseop_options;
     $meta_string = null;
     $description = '';
     if (is_single() || is_page()) {
         $aiosp_disable = htmlspecialchars(stripslashes(get_post_meta($post->ID, '_aioseop_disable', true)));
         if ($aiosp_disable) {
             return;
         }
         if (empty($aioseop_options['aiosp_enablecpost'])) {
             $wp_post_types = get_post_types(array('_builtin' => true));
             // don't display meta if SEO isn't enabled on custom post types -- pdb
             if (!is_singular($wp_post_types) && !is_front_page()) {
                 return;
             }
         } else {
             if (!empty($aioseop_options['aiosp_cpostadvanced'])) {
                 $wp_post_types = $aioseop_options['aiosp_cpostactive'];
                 if (empty($aioseop_options['aiosp_cpostactive'])) {
                     return;
                 }
                 if (!is_singular($wp_post_types) && !is_front_page()) {
                     return;
                 }
             }
         }
     }
     $force_rewrites = 1;
     if (isset($aioseop_options['aiosp_force_rewrites'])) {
         $force_rewrites = $aioseop_options['aiosp_force_rewrites'];
     }
     if (!empty($aioseop_options['aiosp_rewrite_titles']) && $force_rewrites) {
         // make the title rewrite as short as possible
         if (function_exists('ob_list_handlers')) {
             $active_handlers = ob_list_handlers();
         } else {
             $active_handlers = array();
         }
         if (sizeof($active_handlers) > 0 && $this->strtolower($active_handlers[sizeof($active_handlers) - 1]) == $this->strtolower('All_in_One_SEO_Pack::output_callback_for_title')) {
             ob_end_flush();
         } else {
             $this->log("another plugin interfering?");
             // if we get here there *could* be trouble with another plugin :(
             $this->ob_start_detected = true;
             if (function_exists('ob_list_handlers')) {
                 foreach (ob_list_handlers() as $handler) {
                     $this->log("detected output handler {$handler}");
                 }
             }
         }
     }
     echo "\n<!-- All in One SEO Pack {$this->version} by Michael Torbert of Semper Fi Web Design";
     if ($this->ob_start_detected) {
         echo "ob_start_detected ";
     }
     echo "[{$this->title_start},{$this->title_end}] ";
     echo "-->\n";
     $is_front_page = is_front_page();
     $is_front_page_keywords = $is_front_page && $aioseop_options['aiosp_home_keywords'] && !$this->is_static_posts_page() || $this->is_static_front_page();
     $blog_page = $this->get_blog_page($post);
     if ($is_front_page_keywords) {
         $keywords = trim($this->internationalize($aioseop_options['aiosp_home_keywords']));
     } elseif ($this->is_static_posts_page() && !$aioseop_options['aiosp_dynamic_postspage_keywords']) {
         // and if option = use page set keywords instead of keywords from recent posts
         $keywords = stripslashes($this->internationalize(get_post_meta($post->ID, "_aioseop_keywords", true)));
     } elseif (!empty($blog_page) && !$aioseop_options['aiosp_dynamic_postspage_keywords']) {
         $keywords = stripslashes($this->internationalize(get_post_meta($blog_page->ID, "_aioseop_keywords", true)));
     } else {
         $keywords = $this->get_all_keywords();
     }
     if (is_category() && $this->show_page_description()) {
         $description = $this->internationalize(category_description());
     } elseif (is_tag() && $this->show_page_description()) {
         $description = $this->internationalize(tag_description());
     } elseif (is_tax() && $this->show_page_description()) {
         $description = $this->internationalize(term_description());
     } elseif (is_author() && $this->show_page_description()) {
         $description = $this->internationalize(get_the_author_meta('description'));
     } else {
         if ($is_front_page) {
             $description = trim(stripslashes($this->internationalize($aioseop_options['aiosp_home_description'])));
         } else {
             if (is_single() || is_page() || is_home() || $this->is_static_posts_page()) {
                 $description = $this->get_aioseop_description($post);
             }
         }
     }
     /*
     	if ( $this->is_static_front_page() )
     		$description = trim( stripslashes( $this->internationalize( $aioseop_options['aiosp_home_description'] ) ) );
     	elseif ( !empty( $blog_page ) )
     		$description = $this->get_post_description( $blog_page );
     if ( empty( $description ) && is_object( $post ) && !is_archive() && empty( $blog_page ) )
     	$description = $this->get_post_description( $post );
     
     $description = apply_filters( 'aioseop_description', $description );
     */
     if (isset($description) && $this->strlen($description) > $this->minimum_description_length && !($is_front_page && is_paged())) {
         $description = trim(strip_tags($description));
         $description = str_replace('"', '&quot;', $description);
         // replace newlines on mac / windows?
         $description = str_replace("\r\n", ' ', $description);
         // maybe linux uses this alone
         $description = str_replace("\n", ' ', $description);
         if (!isset($meta_string)) {
             $meta_string = '';
         }
         // description format
         $description_format = $aioseop_options['aiosp_description_format'];
         if (!isset($description_format) || empty($description_format)) {
             $description_format = "%description%";
         }
         $description = str_replace('%description%', apply_filters('aioseop_description_override', $description), $description_format);
         $description = str_replace('%blog_title%', get_bloginfo('name'), $description);
         $description = str_replace('%blog_description%', get_bloginfo('description'), $description);
         $description = str_replace('%wp_title%', $this->get_original_title(), $description);
         if ($aioseop_options['aiosp_can'] && is_attachment()) {
             $url = $this->aiosp_mrt_get_url($wp_query);
             if ($url) {
                 $matches = array();
                 preg_match_all('/(\\d+)/', $url, $matches);
                 if (is_array($matches)) {
                     $uniqueDesc = join('', $matches[0]);
                 }
             }
             $description .= ' ' . $uniqueDesc;
         }
         $meta_string .= sprintf("<meta name=\"description\" content=\"%s\" />\n", $description);
     }
     $keywords = apply_filters('aioseop_keywords', $keywords);
     if (isset($aioseop_options['aiosp_togglekeywords'])) {
         $togglekeywords = $aioseop_options['aiosp_togglekeywords'];
     } else {
         $togglekeywords = 0;
     }
     if (isset($keywords) && $togglekeywords == 0 && !empty($keywords) && !(is_home() && is_paged())) {
         if (isset($meta_string)) {
             $meta_string .= "\n";
         }
         $keywords = wp_filter_nohtml_kses(str_replace('"', '', $keywords));
         $meta_string .= sprintf("<meta name=\"keywords\" content=\"%s\" />\n", $keywords);
     }
     $is_tag = is_tag();
     $robots_meta = '';
     if (is_category() && !empty($aioseop_options['aiosp_category_noindex']) || !is_category() && is_archive() && !$is_tag && (is_date() && !empty($aioseop_options['aiosp_archive_date_noindex']) || is_author() && !empty($aioseop_options['aiosp_archive_author_noindex'])) || $is_tag && !empty($aioseop_options['aiosp_tags_noindex']) || is_search() && !empty($aioseop_options['aiosp_search_noindex'])) {
         $robots_meta = 'noindex,follow';
     } else {
         if (is_single() || is_page()) {
             $post_type = get_post_type();
             $aiosp_noindex = htmlspecialchars(stripslashes(get_post_meta($post->ID, '_aioseop_noindex', true)));
             $aiosp_nofollow = htmlspecialchars(stripslashes(get_post_meta($post->ID, '_aioseop_nofollow', true)));
             $aiosp_noodp = htmlspecialchars(stripslashes(get_post_meta($post->ID, '_aioseop_noodp', true)));
             $aiosp_noydir = htmlspecialchars(stripslashes(get_post_meta($post->ID, '_aioseop_noydir', true)));
             if ($aiosp_noindex || $aiosp_nofollow || $aiosp_noodp || $aiosp_noydir || !empty($aioseop_options['aiosp_cpostnoindex']) || !empty($aioseop_options['aiosp_cpostnofollow'])) {
                 $noindex = "index";
                 $nofollow = "follow";
                 $noodp = $noydir = '';
                 if ($aiosp_noindex == 'on' || $aiosp_noindex == '' && !empty($aioseop_options['aiosp_cpostnoindex']) && in_array($post_type, $aioseop_options['aiosp_cpostnoindex'])) {
                     $noindex = "no" . $noindex;
                 }
                 if ($aiosp_nofollow == 'on' || $aiosp_nofollow == '' && !empty($aioseop_options['aiosp_cpostnofollow']) && in_array($post_type, $aioseop_options['aiosp_cpostnofollow'])) {
                     $nofollow = "no" . $nofollow;
                 }
                 if ($aiosp_noodp) {
                     $nofollow .= ',noodp';
                 }
                 if ($aiosp_noydir) {
                     $nofollow .= ',noydir';
                 }
                 $robots_meta = $noindex . ',' . $nofollow;
             }
         }
     }
     $robots_meta = apply_filters('aioseop_robots_meta', $robots_meta);
     if (!empty($robots_meta)) {
         $meta_string .= '<meta name="robots" content="' . esc_attr($robots_meta) . '" />' . "\n";
     }
     if ($is_front_page) {
         foreach (array('google' => 'google-site-verification', 'bing' => 'msvalidate.01', 'pinterest' => 'p:domain_verify') as $k => $v) {
             if (!empty($aioseop_options["aiosp_{$k}_verify"])) {
                 $meta_string .= '<meta name="' . $v . '" content="' . trim(strip_tags($aioseop_options["aiosp_{$k}_verify"])) . '" />' . "\n";
             }
         }
     }
     foreach (array('page_meta', 'post_meta', 'home_meta', 'front_meta') as $meta) {
         if (!empty($aioseop_options["aiosp_{$meta}_tags"])) {
             ${$meta} = html_entity_decode(stripslashes($aioseop_options["aiosp_{$meta}_tags"]));
         } else {
             ${$meta} = '';
         }
     }
     if (is_page() && isset($page_meta) && !empty($page_meta) && (!$is_front_page || empty($front_meta))) {
         if (isset($meta_string)) {
             $meta_string .= "\n";
         }
         $meta_string .= $page_meta;
     }
     if (is_single() && isset($post_meta) && !empty($post_meta)) {
         if (isset($meta_string)) {
             $meta_string .= "\n";
         }
         $meta_string .= $post_meta;
     }
     $googleplus = $publisher = $author = '';
     if (!empty($post) && isset($post->post_author) && empty($aioseop_options['aiosp_google_disable_profile'])) {
         $googleplus = get_the_author_meta('googleplus', $post->post_author);
     }
     if (empty($googleplus) && !empty($aioseop_options['aiosp_google_publisher'])) {
         $googleplus = $aioseop_options['aiosp_google_publisher'];
     }
     if ($is_front_page && !empty($aioseop_options['aiosp_google_publisher'])) {
         $publisher = $aioseop_options['aiosp_google_publisher'];
     }
     $publisher = apply_filters('aioseop_google_publisher', $publisher);
     if (!empty($publisher)) {
         $meta_string = '<link rel="publisher" href="' . esc_url($publisher) . '" />' . "\n" . $meta_string;
     }
     if (is_singular() && !empty($googleplus)) {
         $author = $googleplus;
     } else {
         if (!empty($aioseop_options['aiosp_google_publisher'])) {
             $author = $aioseop_options['aiosp_google_publisher'];
         }
     }
     $author = apply_filters('aioseop_google_author', $author);
     if (!empty($author)) {
         $meta_string = '<link rel="author" href="' . esc_url($author) . '" />' . "\n" . $meta_string;
     }
     if ($is_front_page && !empty($front_meta)) {
         if (isset($meta_string)) {
             $meta_string .= "\n";
         }
         $meta_string .= $front_meta;
     } else {
         if (is_home() && !empty($home_meta)) {
             if (isset($meta_string)) {
                 $meta_string .= "\n";
             }
             $meta_string .= $home_meta;
         }
     }
     $prev = $next = '';
     if (is_home() || is_archive() || is_paged()) {
         global $wp_query;
         $max_page = $wp_query->max_num_pages;
         $page = $this->get_page_number();
         if ($page > 1) {
             $prev = get_previous_posts_page_link();
         }
         if ($page < $max_page) {
             //					$next = get_next_posts_page_link( $max_page );
             $paged = $GLOBALS['paged'];
             if (!is_single()) {
                 if (!$paged) {
                     $paged = 1;
                 }
                 $nextpage = intval($paged) + 1;
                 if (!$max_page || $max_page >= $nextpage) {
                     $next = get_pagenum_link($nextpage);
                 }
             }
         }
     } else {
         if (is_page() || is_single()) {
             $numpages = 1;
             $multipage = 0;
             $page = get_query_var('page');
             if (!$page) {
                 $page = 1;
             }
             if (is_single() || is_page() || is_feed()) {
                 $more = 1;
             }
             $content = $post->post_content;
             if (false !== strpos($content, '<!--nextpage-->')) {
                 if ($page > 1) {
                     $more = 1;
                 }
                 $content = str_replace("\n<!--nextpage-->\n", '<!--nextpage-->', $content);
                 $content = str_replace("\n<!--nextpage-->", '<!--nextpage-->', $content);
                 $content = str_replace("<!--nextpage-->\n", '<!--nextpage-->', $content);
                 // Ignore nextpage at the beginning of the content.
                 if (0 === strpos($content, '<!--nextpage-->')) {
                     $content = substr($content, 15);
                 }
                 $pages = explode('<!--nextpage-->', $content);
                 $numpages = count($pages);
                 if ($numpages > 1) {
                     $multipage = 1;
                 }
             }
             if (!empty($page)) {
                 if ($page > 1) {
                     $prev = _wp_link_page($page - 1);
                 }
                 if ($page + 1 <= $numpages) {
                     $next = _wp_link_page($page + 1);
                 }
             }
             if (!empty($prev)) {
                 $prev = $this->substr($prev, 9, -2);
             }
             if (!empty($next)) {
                 $next = $this->substr($next, 9, -2);
             }
         }
     }
     $prev = apply_filters('aioseop_prev_link', $prev);
     $next = apply_filters('aioseop_next_link', $next);
     if (!empty($prev)) {
         $meta_string .= "<link rel='prev' href='" . esc_url($prev) . "' />\n";
     }
     if (!empty($next)) {
         $meta_string .= "<link rel='next' href='" . esc_url($next) . "' />\n";
     }
     if ($meta_string != null) {
         echo "{$meta_string}\n";
     }
     if ($aioseop_options['aiosp_can'] && ($url = $this->aiosp_mrt_get_url($wp_query))) {
         $url = apply_filters('aioseop_canonical_url', $url);
         if (!empty($url)) {
             echo '<link rel="canonical" href="' . esc_url($url) . '" />' . "\n";
         }
     }
     do_action('aioseop_modules_wp_head');
     echo "<!-- /all in one seo pack -->\n";
 }
Exemplo n.º 26
0
/**
 * Generates basic metadata for the head area.
 *
 */
function amt_add_basic_metadata_head($post, $attachments, $embedded_media, $options)
{
    if (apply_filters('amt_exclude_basic_metadata', false)) {
        return array();
    }
    $do_description = $options["auto_description"] == "1" ? true : false;
    $do_keywords = $options["auto_keywords"] == "1" ? true : false;
    $do_noodp_description = $options["noodp_description"] == "1" ? true : false;
    // Array to store metadata
    $metadata_arr = array();
    // Pre-processing
    // Store hreflang links in array
    $hreflang_links_arr = array();
    // Store base robots options
    $robots_options = array();
    if ($do_noodp_description && (is_front_page() || is_singular() || is_category() || is_tag() || is_tax() || is_author())) {
        // Add NOODP on posts and pages
        $robots_options[] = 'noodp';
        $robots_options[] = 'noydir';
    }
    // Store full meta tags (site wide and post specific)
    // Add site wide meta tags
    $full_metatags_as_string = '';
    if (!empty($options['site_wide_meta'])) {
        $full_metatags_for_site = html_entity_decode(stripslashes($options['site_wide_meta']));
        $full_metatags_as_string .= apply_filters('amt_full_metatags_site', $full_metatags_for_site);
        $full_metatags_as_string .= PHP_EOL;
    }
    // Full meta tags
    if (is_singular() || amt_is_static_front_page() || amt_is_static_home()) {
        // per post full meta tags
        $full_metatags_for_content = amt_get_post_meta_full_metatags($post->ID);
        $full_metatags_for_content = html_entity_decode(stripslashes($full_metatags_for_content));
        $full_metatags_as_string .= apply_filters('amt_full_metatags_post', $full_metatags_for_content);
    } elseif (is_category() || is_tag() || is_tax()) {
        // Term specific full meta tags ($post is a term object)
        $full_metatags_for_term = amt_get_term_meta_full_metatags($post->term_id);
        $full_metatags_for_term = html_entity_decode(stripslashes($full_metatags_for_term));
        $full_metatags_as_string .= apply_filters('amt_full_metatags_term', $full_metatags_for_term);
    } elseif (is_author()) {
        // User specific full meta tags ($post is a user object)
        $full_metatags_for_user = amt_get_user_meta_full_metatags($post->ID);
        $full_metatags_for_user = html_entity_decode(stripslashes($full_metatags_for_user));
        $full_metatags_as_string .= apply_filters('amt_full_metatags_term', $full_metatags_for_user);
    }
    // Sanitize
    //$full_metatags_as_string = esc_textarea( wp_kses( $full_metatags_as_string, amt_get_allowed_html_kses() ) );
    $full_metatags_as_string = wp_kses($full_metatags_as_string, amt_get_allowed_html_kses());
    // Make array of full meta tags
    $full_meta_tags = preg_split('#\\R#', $full_metatags_as_string, NULL, PREG_SPLIT_NO_EMPTY);
    // Process
    if (apply_filters('amt_full_metatags_processor_enable', true)) {
        // Store processed meta tags here
        $processed_full_meta_tags = array();
        // Field substitutions currently take place only on content pages.
        // TODO: See if this can be expanded to terms, authors.
        // Store the post's custom fields
        $custom_fields = null;
        // Store the post object's custom fields.
        //
        if (is_singular() || amt_is_static_front_page() || amt_is_static_home()) {
            // Get an array of all custom fields names of the post object.
            $custom_fields = get_post_custom_keys($post->ID);
        }
        // Iterate over full meta tags
        foreach ($full_meta_tags as $single_meta_tag) {
            // Note: Field value substitutions take place first, outside the elseif clauses.
            // Process substitutions of special notation with data from Custom Fields
            // Supported special notation:
            //   [field=Field Name]
            // Notes:
            // - 'Field Name' is the name of custom field.
            // - If the custom field with name 'Field Name' does not exist, the meta tag
            //   that contains it is omitted.
            // - If the value of the field is an empty string, then the substitution
            //   takes place normally.
            //
            // The regex pattern fo our special notation.
            $special_notation_pattern = '#(?:\\[field\\=)([^\\]]+)(?:\\])#';
            // The following covers content pages, as $custom_fields is only set on content pages. See above.
            if (!empty($custom_fields) && isset($post->ID)) {
                // This also assumes that we have a post object since custom fields
                // are set only on content pages, otherwise it is null.
                // Check for special notation
                if (preg_match($special_notation_pattern, $single_meta_tag, $matches)) {
                    //var_dump($matches);
                    // If the field name of the special notation does not match
                    // any custom field name, omit the meta tag as per the rules above.
                    if (!in_array($matches[1], $custom_fields)) {
                        continue;
                    }
                    // Since there is special notation and the field name from the special
                    // notation exists in the $custom_fields array, iterate over the available
                    // custom fields and perform the substitutions.
                    foreach ($custom_fields as $custom_field) {
                        // Check if it matches the field name of the special notation
                        if ($custom_field == $matches[1]) {
                            // Fetch the custom field's value
                            $field_value = get_post_meta($post->ID, $custom_field, true);
                            // Sanitize value
                            // TODO: this can be a problem depending on the value and the used sanitization function.
                            $field_value = esc_attr(sanitize_text_field($field_value));
                            // Perform the substitution even if the the value is an empty string as per the rules above
                            $single_meta_tag = str_replace(sprintf('[field=%s]', $custom_field), $field_value, $single_meta_tag);
                        }
                    }
                }
            } else {
                // In any other case, just remove the meta tags which contain the special notation.
                if (preg_match($special_notation_pattern, $single_meta_tag, $tmp)) {
                    continue;
                }
            }
            // Process the PAGEINFO variable.
            // If the current page is the 1st page of any archive or of multipage content,
            // PAGEINFO is just stripped. For subsequent pages of archives or multipage
            // content, PAGEINFO is replaced with page based path (page/N/ for archives or N/ for multipage content)
            //
            // For paginated archives or paginated main page with latest posts.
            $has_paging_info = false;
            if (is_paged()) {
                $paged = get_query_var('paged');
                // paged
                if ($paged && $paged >= 2) {
                    $single_meta_tag = str_replace('PAGEINFO', 'page/' . $paged . '/', $single_meta_tag);
                    $has_paging_info = true;
                }
                // For a Post or Page that has been divided into pages using the <!--nextpage--> QuickTag
            } else {
                $paged = get_query_var('page');
                // page
                if ($paged && $paged >= 2) {
                    $single_meta_tag = str_replace('PAGEINFO', $paged . '/', $single_meta_tag);
                    $has_paging_info = true;
                }
            }
            // If this is not paged, strip PAGEINFO
            if ($has_paging_info === false) {
                $single_meta_tag = str_replace('PAGEINFO', '', $single_meta_tag);
            }
            // Process custom canonical link
            // If a rel="canonical" meta tags exists, we deactivate WordPress' 'rel_canonical' action,
            // Since it is assumed that a custom canonical link has been added.
            //if ( preg_match( '# rel="canonical" #', $post_full_meta_tags, $tmp ) ) {
            if (strpos($single_meta_tag, ' rel="canonical" ') !== false) {
                // Remove default WordPress action
                remove_action('wp_head', 'rel_canonical');
            } elseif (strpos($single_meta_tag, ' name="robots" ') !== false) {
                if (preg_match('# content="([^"]+)" #', $single_meta_tag, $matches)) {
                    $tmp_robots_opts = explode(',', $matches[1]);
                    foreach ($tmp_robots_opts as $single_robots_option) {
                        $single_robots_option_cleaned = strtolower(trim($single_robots_option));
                        if (!empty($single_robots_option_cleaned)) {
                            $robots_options[] = $single_robots_option_cleaned;
                        }
                    }
                }
                // We simply collect options. Do not add any robots meta tags to the processed meta tags array.
                continue;
            } elseif (strpos($single_meta_tag, ' hreflang="') !== false) {
                // Simply add to the hreflang links array for later processing
                $hreflang_links_arr[] = $single_meta_tag;
                // We simply collect hreflang links for later processing. Do not add them to the processed meta tags array.
                continue;
            }
            // If we have reached here, add the meta tags to the array with processed meta tags.
            $processed_full_meta_tags[] = $single_meta_tag;
        }
    } else {
        // Full meta tags processor not enabled
        $processed_full_meta_tags = $full_meta_tags;
    }
    //var_dump($full_meta_tags);
    //var_dump($processed_full_meta_tags);
    // Add Meta Tags
    // Add a robots meta tag if robots options exist.
    // Backwards compatible filter. TODO: This is deprecated. Needs to be deleted after a while.
    $old_options_as_string = apply_filters('amt_robots_data', '');
    if (!empty($old_options_as_string)) {
        foreach (explode(',', $old_options_as_string) as $single_robots_option) {
            $single_robots_option_cleaned = strtolower(trim($single_robots_option));
            if (!empty($single_robots_option_cleaned)) {
                $robots_options[] = $single_robots_option_cleaned;
            }
        }
    }
    // Add robot_options filtering
    $robots_options = apply_filters('amt_robots_options', $robots_options);
    if (version_compare(PHP_VERSION, '5.3', '<')) {
        // The flag is not supported
        $robots_options = array_unique($robots_options);
    } else {
        $robots_options = array_unique($robots_options, SORT_STRING);
    }
    if (!empty($robots_options)) {
        $metadata_arr['basic:robots'] = '<meta name="robots" content="' . esc_attr(implode(',', $robots_options)) . '" />';
    }
    // Add full meta tags
    // Merge meta tags
    $processed_full_meta_tags = apply_filters('amt_full_metatags_processed', $processed_full_meta_tags);
    if (!empty($processed_full_meta_tags)) {
        $metadata_arr = array_merge($metadata_arr, $processed_full_meta_tags);
    }
    // Add copyright link
    // On every page print the copyright head link
    $copyright_url = amt_get_site_copyright_url($options);
    //if ( empty($copyright_url)) {
    //    $copyright_url = trailingslashit( get_bloginfo('url') );
    //}
    if (!empty($copyright_url)) {
        $metadata_arr['basic:copyright'] = '<link rel="copyright" type="text/html" title="' . esc_attr(get_bloginfo('name')) . ' ' . __('copyright information', 'add-meta-tags') . '" href="' . esc_url($copyright_url) . '" />';
    }
    // hreflang link element
    // This section also expects an array of extra hreflang links that may have
    // been collected from the full meta tags boxes.
    if ($options['generate_hreflang_links'] == '1') {
        if (is_singular()) {
            $locale = amt_get_language_content($options, $post);
            $hreflang = amt_get_the_hreflang($locale, $options);
            $hreflang_url = amt_get_permalink_for_multipage($post);
        } else {
            $locale = amt_get_language_site($options);
            $hreflang = amt_get_the_hreflang($locale, $options);
            $hreflang_url = '';
            if (amt_is_default_front_page()) {
                $hreflang_url = trailingslashit(get_bloginfo('url'));
            } elseif (is_category() || is_tag() || is_tax()) {
                // $post is a term object
                $hreflang_url = get_term_link($post);
            } elseif (is_author()) {
                // $post is an author object
                $hreflang_url = get_author_posts_url($post->ID);
            } elseif (is_year()) {
                $archive_year = get_the_time('Y');
                $hreflang_url = get_year_link($archive_year);
            } elseif (is_month()) {
                $archive_year = get_the_time('Y');
                $archive_month = get_the_time('m');
                $hreflang_url = get_month_link($archive_year, $archive_month);
            } elseif (is_day()) {
                $archive_year = get_the_time('Y');
                $archive_month = get_the_time('m');
                $archive_day = get_the_time('d');
                $hreflang_url = get_day_link($archive_year, $archive_month, $archive_day);
            }
            // If paged information is available
            if (is_paged()) {
                //$hreflang_url = trailingslashit( $hreflang_url ) . get_query_var('paged') . '/';
                $hreflang_url = get_pagenum_link(get_query_var('paged'));
            }
        }
        // hreflang links array
        $hreflang_arr = array();
        // Add link element
        if (!empty($hreflang) && !empty($hreflang_url)) {
            $hreflang_arr[] = '<link rel="alternate" hreflang="' . esc_attr($hreflang) . '" href="' . esc_url_raw($hreflang_url) . '" />';
        }
        // Add extra hreflang links that have been collected from the full meta tags boxes
        if (!empty($hreflang_links_arr)) {
            $hreflang_arr = array_merge($hreflang_arr, $hreflang_links_arr);
        }
        // Allow filtering of the hreflang array
        $hreflang_arr = apply_filters('amt_hreflang_links', $hreflang_arr);
        // Add to to metadata array
        foreach ($hreflang_arr as $hreflang_link) {
            if (preg_match('# hreflang="([^"]+)" #', $hreflang_link, $matches)) {
                $metadata_arr['basic:hreflang:' . $matches[1]] = $hreflang_link;
            }
        }
    }
    // Basic Meta Tags
    // Custom content override
    if (amt_is_custom($post, $options)) {
        // Return metadata with:
        // add_filter( 'amt_custom_metadata_basic', 'my_function', 10, 5 );
        // Return an array of meta tags. Array item format: ['key_can_be_whatever'] = '<meta name="foo" content="bar" />'
        $metadata_arr = apply_filters('amt_custom_metadata_basic', $metadata_arr, $post, $options, $attachments, $embedded_media);
        // Default front page displaying latest posts
    } elseif (amt_is_default_front_page()) {
        // Description and Keywords from the Add-Meta-Tags settings override
        // default behaviour.
        // Description
        if ($do_description) {
            // Use the site description from the Add-Meta-Tags settings.
            // Fall back to the blog description.
            $site_description = amt_get_site_description($options);
            if (empty($site_description)) {
                // Alternatively, use the blog description
                // Here we sanitize the provided description for safety
                $site_description = sanitize_text_field(amt_sanitize_description(get_bloginfo('description')));
            }
            // If we have a description, use it in the description meta-tag of the front page
            if (!empty($site_description)) {
                // Note: Contains multipage information through amt_process_paged()
                $metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr(amt_process_paged($site_description)) . '" />';
            }
        }
        // Keywords
        if ($do_keywords) {
            // Use the site keywords from the Add-Meta-Tags settings.
            // Fall back to the blog categories.
            $site_keywords = amt_get_site_keywords($options);
            if (empty($site_keywords)) {
                // Alternatively, use the blog categories
                // Here we sanitize the provided keywords for safety
                $site_keywords = sanitize_text_field(amt_sanitize_keywords(amt_get_all_categories()));
            }
            // If we have keywords, use them in the keywords meta-tag of the front page
            if (!empty($site_keywords)) {
                $metadata_arr['basic:keywords'] = '<meta name="keywords" content="' . esc_attr($site_keywords) . '" />';
            }
        }
        // Attachments
    } elseif (is_attachment()) {
        // has to be before is_singular() since is_singular() is true for attachments.
        // Description
        if ($do_description) {
            $description = amt_get_content_description($post, $auto = $do_description);
            if (!empty($description)) {
                // Note: Contains multipage information through amt_process_paged()
                $metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr(amt_process_paged($description)) . '" />';
            }
        }
        // No keywords
        // Content pages and static pages used as "front page" and "posts page"
        // This also supports products via is_singular()
    } elseif (is_singular() || amt_is_static_front_page() || amt_is_static_home()) {
        // Description
        if ($do_description) {
            $description = amt_get_content_description($post, $auto = $do_description);
            if (!empty($description)) {
                // Note: Contains multipage information through amt_process_paged()
                $metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr(amt_process_paged($description)) . '" />';
            }
        }
        // Keywords
        if ($do_keywords) {
            $keywords = amt_get_content_keywords($post, $auto = $do_keywords);
            if (!empty($keywords)) {
                $metadata_arr['basic:keywords'] = '<meta name="keywords" content="' . esc_attr($keywords) . '" />';
                // Static Posts Index Page
                // If no keywords have been set in the metabox and this is the static page,
                // which displayes the latest posts, use the categories of the posts in the loop.
            } elseif (amt_is_static_home()) {
                // Here we sanitize the provided keywords for safety
                $cats_from_loop = sanitize_text_field(amt_sanitize_keywords(implode(', ', amt_get_categories_from_loop())));
                if (!empty($cats_from_loop)) {
                    $metadata_arr['basic:keywords'] = '<meta name="keywords" content="' . esc_attr($cats_from_loop) . '" />';
                }
            }
        }
        // 'news_keywords'
        $newskeywords = amt_get_post_meta_newskeywords($post->ID);
        if (!empty($newskeywords)) {
            $metadata_arr['basic:news_keywords'] = '<meta name="news_keywords" content="' . esc_attr($newskeywords) . '" />';
        }
        // Category based archives
    } elseif (is_category()) {
        if ($do_description) {
            // If set, the description of the category is used in the 'description' metatag.
            // Otherwise, a generic description is used.
            // Here we sanitize the provided description for safety
            $description_content = sanitize_text_field(amt_sanitize_description(category_description()));
            // Note: Contains multipage information through amt_process_paged()
            if (empty($description_content)) {
                // Add a filtered generic description.
                $generic_description = apply_filters('amt_generic_description_category_archive', __('Content filed under the %s category.', 'add-meta-tags'));
                $generic_description = sprintf($generic_description, single_cat_title($prefix = '', $display = false));
                $metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr(amt_process_paged($generic_description)) . '" />';
            } else {
                $metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr(amt_process_paged($description_content)) . '" />';
            }
        }
        if ($do_keywords) {
            // The category name alone is included in the 'keywords' metatag
            // Here we sanitize the provided keywords for safety
            $cur_cat_name = sanitize_text_field(amt_sanitize_keywords(single_cat_title($prefix = '', $display = false)));
            if (!empty($cur_cat_name)) {
                $metadata_arr['basic:keywords'] = '<meta name="keywords" content="' . esc_attr($cur_cat_name) . '" />';
            }
        }
    } elseif (is_tag()) {
        if ($do_description) {
            // If set, the description of the tag is used in the 'description' metatag.
            // Otherwise, a generic description is used.
            // Here we sanitize the provided description for safety
            $description_content = sanitize_text_field(amt_sanitize_description(tag_description()));
            // Note: Contains multipage information through amt_process_paged()
            if (empty($description_content)) {
                // Add a filtered generic description.
                $generic_description = apply_filters('amt_generic_description_tag_archive', __('Content tagged with %s.', 'add-meta-tags'));
                $generic_description = sprintf($generic_description, single_tag_title($prefix = '', $display = false));
                $metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr(amt_process_paged($generic_description)) . '" />';
            } else {
                $metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr(amt_process_paged($description_content)) . '" />';
            }
        }
        if ($do_keywords) {
            // The tag name alone is included in the 'keywords' metatag
            // Here we sanitize the provided keywords for safety
            $cur_tag_name = sanitize_text_field(amt_sanitize_keywords(single_tag_title($prefix = '', $display = false)));
            if (!empty($cur_tag_name)) {
                $metadata_arr['basic:keywords'] = '<meta name="keywords" content="' . esc_attr($cur_tag_name) . '" />';
            }
        }
        // Custom taxonomies - Should be after is_category() and is_tag(), as it would catch those taxonomies as well.
        // This also supports product groups via is_tax(). Only product groups that are WordPress custom taxonomies are supported.
    } elseif (is_tax()) {
        // Taxonomy term object.
        // When viewing taxonomy archives, the $post object is the taxonomy term object. Check with: var_dump($post);
        $tax_term_object = $post;
        //var_dump($tax_term_object);
        if ($do_description) {
            // If set, the description of the custom taxonomy term is used in the 'description' metatag.
            // Otherwise, a generic description is used.
            // Here we sanitize the provided description for safety
            $description_content = sanitize_text_field(amt_sanitize_description(term_description($tax_term_object->term_id, $tax_term_object->taxonomy)));
            // Note: Contains multipage information through amt_process_paged()
            if (empty($description_content)) {
                // Add a filtered generic description.
                // Construct the filter name. Template: ``amt_generic_description_TAXONOMYSLUG_archive``
                $taxonomy_description_filter_name = sprintf('amt_generic_description_%s_archive', $tax_term_object->taxonomy);
                // var_dump($taxonomy_description_filter_name);
                $generic_description = apply_filters($taxonomy_description_filter_name, __('Content filed under the %s taxonomy.', 'add-meta-tags'));
                $generic_description = sprintf($generic_description, single_term_title($prefix = '', $display = false));
                $metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr(amt_process_paged($generic_description)) . '" />';
            } else {
                $metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr(amt_process_paged($description_content)) . '" />';
            }
        }
        if ($do_keywords) {
            // The taxonomy term name alone is included in the 'keywords' metatag.
            // Here we sanitize the provided keywords for safety.
            $cur_tax_term_name = sanitize_text_field(amt_sanitize_keywords(single_term_title($prefix = '', $display = false)));
            if (!empty($cur_tax_term_name)) {
                $metadata_arr['basic:keywords'] = '<meta name="keywords" content="' . esc_attr($cur_tax_term_name) . '" />';
            }
        }
    } elseif (is_author()) {
        // Author object
        // NOTE: Inside the author archives `$post->post_author` does not contain the author object.
        // In this case the $post (get_queried_object()) contains the author object itself.
        // We also can get the author object with the following code. Slug is what WP uses to construct urls.
        // $author = get_user_by( 'slug', get_query_var( 'author_name' ) );
        // Also, ``get_the_author_meta('....', $author)`` returns nothing under author archives.
        // Access user meta with:  $author->description, $author->user_email, etc
        // $author = get_queried_object();
        $author = $post;
        // If a bio has been set in the user profile, use it in the description metatag of the
        // first page of the author archive *ONLY*. The other pages of the author archive use a generic description.
        // This happens because the 1st page of the author archive is considered the profile page
        // by the other metadata modules.
        // Otherwise use a generic meta tag.
        if ($do_description) {
            // Here we sanitize the provided description for safety
            $author_description = sanitize_text_field(amt_sanitize_description($author->description));
            if (empty($author_description) || is_paged()) {
                // Note: Contains multipage information through amt_process_paged()
                // Add a filtered generic description.
                $generic_description = apply_filters('amt_generic_description_author_archive', __('Content published by %s.', 'add-meta-tags'));
                $generic_description = sprintf($generic_description, $author->display_name);
                $metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr(amt_process_paged($generic_description)) . '" />';
            } else {
                $metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr($author_description) . '" />';
            }
        }
        // For the keywords metatag use the categories of the posts the author has written and are displayed in the current page.
        if ($do_keywords) {
            // Here we sanitize the provided keywords for safety
            $cats_from_loop = sanitize_text_field(amt_sanitize_keywords(implode(', ', amt_get_categories_from_loop())));
            if (!empty($cats_from_loop)) {
                $metadata_arr['basic:keywords'] = '<meta name="keywords" content="' . esc_attr($cats_from_loop) . '" />';
            }
        }
        // Custom Post Type Archive
    } elseif (is_post_type_archive()) {
        // Custom post type object.
        // When viewing custom post type archives, the $post object is the custom post type object. Check with: var_dump($post);
        $post_type_object = $post;
        //var_dump($post_type_object);
        if ($do_description) {
            // Description
            // Note: Contains multipage information through amt_process_paged()
            // Add a filtered generic description.
            // Construct the filter name. Template: ``amt_generic_description_posttype_POSTTYPESLUG_archive``
            $custom_post_type_description_filter_name = sprintf('amt_generic_description_posttype_%s_archive', $post_type_object->name);
            // var_dump($custom_post_type_description_filter_name);
            // Generic description
            $generic_description = apply_filters($custom_post_type_description_filter_name, __('%s archive.', 'add-meta-tags'));
            // Final generic description
            $generic_description = sprintf($generic_description, post_type_archive_title($prefix = '', $display = false));
            $metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr(amt_process_paged($generic_description)) . '" />';
        }
        // For the keywords metatag use the categories of the posts that are listed in the current page.
        if ($do_keywords) {
            // Here we sanitize the provided keywords for safety
            $cats_from_loop = sanitize_text_field(amt_sanitize_keywords(implode(', ', amt_get_categories_from_loop())));
            if (!empty($cats_from_loop)) {
                $metadata_arr['basic:keywords'] = '<meta name="keywords" content="' . esc_attr($cats_from_loop) . '" />';
            }
        }
    }
    // Filtering of the generated basic metadata
    $metadata_arr = apply_filters('amt_basic_metadata_head', $metadata_arr);
    return $metadata_arr;
}
Exemplo n.º 27
0
/**
 * Get the tagline for a tag.
 *
 * The tagline is parsed from Wordpress's "description" field for categories. It
 * consists of all text found after the first colon in the description. If no
 * colon is found, it returns the whole string. If the given tag ID does
 * not exist, it returns an empty string.
 *
 * @param $cat_ID (Int) The tag ID for which to get the tagline.
 *
 * @return (String) The tagline for the given tag, or the empty string on
 *                  failure.
 */
function tag_tagline($tag_ID)
{
    $tag_description = strip_tags(tag_description($tag_ID));
    $first_colon_index = strpos($tag_description, "\n");
    // If a colon was found, return the string after that point. If no colon was
    // found, return the whole string.
    if ($first_colon_index !== false) {
        return substr($tag_description, $first_colon_index + 1);
    } else {
        return $tag_description;
    }
}
    function tc_content_post_list_header()
    {
        /**
         * The template part for displaying additional header for posts list.
         *
         * @package Customizr
         * @since Customizr 1.0
         */
        ?>
    <?php 
        if (is_404()) {
            ?>
      <header class="entry-header">

        <h1 class="entry-title"><?php 
            _e('Ooops, page not found', 'customizr');
            ?>
</h1>

      </header>

    <?php 
        } elseif (is_search()) {
            ?>

      <header class="search-header">

        <h1 class="page-title">
          <?php 
            printf(__('%1sSearch Results for: %2s', 'customizr'), have_posts() ? '' : __('No', 'customizr') . '&nbsp;', '<span>' . get_search_query() . '</span>');
            ?>
        </h1>

      </header>

    <?php 
        } elseif (is_author()) {
            ?>

    <?php 
            /* Get the user ID. */
            $user_id = get_query_var('author');
            ?>
      <header class="archive-header">

        <h1 class="archive-title"><?php 
            printf(__('Author Archives: %s', 'customizr'), '<span class="vcard"><a class="url fn n" href="' . esc_url(get_author_posts_url($user_id)) . '" title="' . esc_attr(get_the_author_meta('display_name', $user_id)) . '" rel="me">' . get_the_author_meta('display_name', $user_id) . '</a></span>');
            ?>
</h1>
      
      </header><!-- .archive-header -->

    <?php 
        } elseif (is_category()) {
            ?>

      <header class="archive-header">

        <h1 class="archive-title"><?php 
            printf(__('Category Archives: %s', 'customizr'), '<span>' . single_cat_title('', false) . '</span>');
            ?>
</h1>

        <?php 
            if (category_description()) {
                // Show an optional category description
                ?>
          <div class="archive-meta"><?php 
                echo category_description();
                ?>
</div>
        <?php 
            }
            ?>
     
      </header><!-- .archive-header -->

    <?php 
        } elseif (is_tag()) {
            ?>

      <header class="archive-header">
        
        <h1 class="archive-title"><?php 
            printf(__('Tag Archives: %s', 'customizr'), '<span>' . single_tag_title('', false) . '</span>');
            ?>
</h1>

      <?php 
            if (tag_description()) {
                // Show an optional tag description
                ?>
        <div class="archive-meta"><?php 
                echo tag_description();
                ?>
</div>
      <?php 
            }
            ?>
      
      </header><!-- .archive-header -->

    <?php 
        } elseif (is_archive()) {
            ?>

      <header class="archive-header">

        <h1 class="archive-title"><?php 
            if (is_day()) {
                printf(__('Daily Archives: %s', 'customizr'), '<span>' . get_the_date() . '</span>');
            } elseif (is_month()) {
                printf(__('Monthly Archives: %s', 'customizr'), '<span>' . get_the_date(_x('F Y', 'monthly archives date format', 'customizr')) . '</span>');
            } elseif (is_year()) {
                printf(__('Yearly Archives: %s', 'customizr'), '<span>' . get_the_date(_x('Y', 'yearly archives date format', 'customizr')) . '</span>');
            } else {
                _e('Archives', 'customizr');
            }
            ?>
</h1>

      </header><!-- .archive-header -->

    <?php 
        }
        ?>

    <?php 
        if (!is_single() && !is_page() && (!is_home() || !is_front_page())) {
            ?>
      <hr class="featurette-divider">
    <?php 
        }
        ?>
    
    <?php 
    }
Exemplo n.º 29
0
        printf(__('Yearly Archives: %s', 'outlines'), '<span>' . get_the_date('Y') . '</span>');
    } else {
        _e('Archives', 'outlines');
    }
    ?>
					</h1>
					<?php 
    if (is_category()) {
        // show an optional category description
        $category_description = category_description();
        if (!empty($category_description)) {
            echo apply_filters('category_archive_meta', '<div class="taxonomy-description">' . $category_description . '</div>');
        }
    } elseif (is_tag()) {
        // show an optional tag description
        $tag_description = tag_description();
        if (!empty($tag_description)) {
            echo apply_filters('tag_archive_meta', '<div class="taxonomy-description">' . $tag_description . '</div>');
        }
    }
    ?>
				</header><!-- .page-header -->

				<?php 
    outlines_content_nav('nav-above');
    ?>

				<?php 
    /* Start the Loop */
    ?>
				<?php 
/**
 * @uses tag_description()
 * @link http://codex.wordpress.org/Template_Tags/tag_description
 *
 * @since 0.1.1
 */
function shortcode_tag_description($attr)
{
    return tag_description($attr['tag']);
}