/** * Compile various meta tags. */ function meta() { global $thesis; // Public blogs need to give robots a little direction. if (get_option('blog_public') != 0) { $current_page = get_query_var('paged'); // Should robots be allowed to index the content? if (is_page() || is_single()) { global $post; if (get_post_meta($post->ID, 'thesis_noindex', true)) { $meta['robots'] = '<meta name="robots" content="noindex, nofollow" />'; } } elseif (is_search() || is_404() || is_category() && $thesis['head']['noindex']['category'] || is_tag() && $thesis['head']['noindex']['tag'] || is_author() && $thesis['head']['noindex']['author'] || is_day() && $thesis['head']['noindex']['day'] || is_month() && $thesis['head']['noindex']['month'] || is_year() && $thesis['head']['noindex']['year'] || $current_page > 1) { $meta['robots'] = '<meta name="robots" content="noindex, nofollow" />'; } } // Canonical URL if (!function_exists('yoast_canonical_link') && $thesis['head']['canonical'] && !is_404()) { if (is_single() || is_page()) { global $post; $url = is_page() && get_option('show_on_front') == 'page' && get_option('page_on_front') == $post->ID ? trailingslashit(get_permalink()) : get_permalink(); } elseif (is_author()) { $author = get_userdata(get_query_var('author')); $url = get_author_link(false, $author->ID, $author->user_nicename); } elseif (is_category()) { $url = get_category_link(get_query_var('cat')); } elseif (is_tag()) { $tag = get_term_by('slug', get_query_var('tag'), 'post_tag'); if (!empty($tag->term_id)) { $url = get_tag_link($tag->term_id); } } elseif (is_day()) { $url = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day')); } elseif (is_month()) { $url = get_month_link(get_query_var('year'), get_query_var('monthnum')); } elseif (is_year()) { $url = get_year_link(get_query_var('year')); } elseif (is_home()) { $url = get_option('show_on_front') == 'page' ? trailingslashit(get_permalink(get_option('page_for_posts'))) : trailingslashit(get_option('home')); } $meta['canonical'] = '<link rel="canonical" href="' . $url . '" />'; } // Is All-in-One SEO installed? If so, defer to it for SEO meta handling. if (!class_exists('All_in_One_SEO_Pack')) { if (is_single() || is_page()) { global $post; $custom_description = get_post_meta($post->ID, 'thesis_description', true); $deprecated_custom_meta = get_post_meta($post->ID, thesis_get_custom_field_key('meta'), true); $excerpt = trim(strip_tags(wp_specialchars($post->post_excerpt))); $custom_keywords = get_post_meta($post->ID, 'thesis_keywords', true); $deprecated_custom_keywords = get_post_meta($post->ID, thesis_get_custom_field_key('keywords'), true); if (strlen($custom_description)) { $meta['description'] = '<meta name="description" content="' . trim(wptexturize(strip_tags(stripslashes($custom_description)))) . '" />'; } elseif (strlen($deprecated_custom_meta)) { $meta['description'] = '<meta name="description" content="' . trim(wptexturize(strip_tags(stripslashes($deprecated_custom_meta)))) . '" />'; } elseif (strlen($excerpt)) { $meta['description'] = '<meta name="description" content="' . $excerpt . '" />'; } if (strlen($custom_keywords)) { $meta['keywords'] = '<meta name="keywords" content="' . trim(wptexturize(strip_tags(stripslashes($custom_keywords)))) . '" />'; } elseif (strlen($deprecated_custom_keywords)) { $meta['keywords'] = '<meta name="keywords" content="' . trim(wptexturize(strip_tags(stripslashes($deprecated_custom_keywords)))) . '" />'; } else { $tags = thesis_get_post_tags($post->ID); if ($tags) { $meta['keywords'] = '<meta name="keywords" content="' . implode(', ', $tags) . '" />'; } } } elseif (is_category()) { $category_description = trim(strip_tags(stripslashes(category_description()))); $meta['description'] = strlen($category_description) ? '<meta name="description" content="' . $category_description . '" />' : '<meta name="description" content="' . single_cat_title('', false) . '" />'; } else { if ($thesis['home']['meta']['description']) { $meta['description'] = '<meta name="description" content="' . trim(wptexturize(strip_tags(stripslashes($thesis['home']['meta']['description'])))) . '" />'; } elseif (strlen(get_bloginfo('description'))) { $meta['description'] = '<meta name="description" content="' . get_bloginfo('description') . '" />'; } if ($thesis['home']['meta']['keywords']) { $meta['keywords'] = '<meta name="keywords" content="' . $thesis['home']['meta']['keywords'] . '" />'; } } } if ($thesis['head']['version']) { $meta['version'] = '<meta name="wp_theme" content="Thesis ' . thesis_get_theme_version() . '" />'; } if ($meta) { $this->meta = $meta; } }
function meta() { global $thesis_site; global $thesis_pages; // robots meta if (get_option('blog_public') != 0) { #wp $noindex = $thesis_site->head['meta']['robots']['noindex']; $nofollow = $thesis_site->head['meta']['robots']['nofollow']; $noarchive = $thesis_site->head['meta']['robots']['noarchive']; if (is_home() && get_query_var('paged') > 1) { #wp $page_type = 'sub'; } elseif (is_author()) { #wp $page_type = 'author'; } elseif (is_day()) { #wp $page_type = 'day'; } elseif (is_month()) { #wp $page_type = 'month'; } elseif (is_year()) { #wp $page_type = 'year'; } if (!$page_type && (is_home() || is_front_page())) { if (get_option('show_on_front') == 'page' && is_front_page()) { #wp $page_id = get_option('page_on_front'); } elseif (get_option('show_on_front') == 'page' && is_home()) { #wp $page_id = get_option('page_for_posts'); } #wp $robots_meta = $page_id ? get_post_meta($page_id, 'thesis_robots', true) : $thesis_pages->home['head']['meta']['robots']; if ($page_id) { $robots_deprecated = get_post_meta($page_id, 'thesis_noindex', true); } if (is_array($robots_meta)) { foreach ($robots_meta as $meta_tag => $value) { if ($value) { $content[] = $meta_tag; } } } elseif ($robots_deprecated) { $content[] = 'noindex'; } } elseif (!$page_type && (is_page() || is_single())) { #wp global $post; #wp $robots_meta = get_post_meta($post->ID, 'thesis_robots', true); #wp $robots_deprecated = get_post_meta($post->ID, 'thesis_noindex', true); #wp if (is_array($robots_meta)) { foreach ($robots_meta as $meta_tag => $value) { if ($value) { $content[] = $meta_tag; } } } elseif ($robots_deprecated) { $content[] = 'noindex'; } } elseif (is_category()) { #wp global $wp_query; #wp $cat_noindex = $thesis_pages->categories[$wp_query->query_vars['cat']]['head']['meta']['robots']['noindex']; $cat_nofollow = $thesis_pages->categories[$wp_query->query_vars['cat']]['head']['meta']['robots']['nofollow']; $cat_noarchive = $thesis_pages->categories[$wp_query->query_vars['cat']]['head']['meta']['robots']['noarchive']; if (isset($cat_noindex) && $cat_noindex || !isset($cat_noindex) && $noindex['category']) { $content[] = 'noindex'; } if (isset($cat_nofollow) && $cat_nofollow || !isset($cat_nofollow) && $nofollow['category']) { $content[] = 'nofollow'; } if (isset($cat_noarchive) && $cat_noarchive || !isset($cat_noarchive) && $noarchive['category']) { $content[] = 'noarchive'; } } elseif (is_tag()) { #wp global $wp_query; #wp $tag_noindex = $thesis_pages->tags[$wp_query->query_vars['tag_id']]['head']['meta']['robots']['noindex']; $tag_nofollow = $thesis_pages->tags[$wp_query->query_vars['tag_id']]['head']['meta']['robots']['nofollow']; $tag_noarchive = $thesis_pages->tags[$wp_query->query_vars['tag_id']]['head']['meta']['robots']['noarchive']; if (isset($tag_noindex) && $tag_noindex || !isset($tag_noindex) && $noindex['tag']) { $content[] = 'noindex'; } if (isset($tag_nofollow) && $tag_nofollow || !isset($tag_nofollow) && $nofollow['tag']) { $content[] = 'nofollow'; } if (isset($tag_noarchive) && $tag_noarchive || !isset($tag_noarchive) && $noarchive['tag']) { $content[] = 'noarchive'; } } elseif (is_search() || is_404()) { #wp $content[] = 'noindex, nofollow, noarchive'; } elseif ($page_type) { if ($noindex[$page_type]) { $content[] = 'noindex'; } if ($nofollow[$page_type]) { $content[] = 'nofollow'; } if ($noarchive[$page_type]) { $content[] = 'noarchive'; } } if ($thesis_site->head['meta']['robots']['noodp']) { $content[] = 'noodp'; } if ($thesis_site->head['meta']['robots']['noydir']) { $content[] = 'noydir'; } $meta['robots'] = $content ? '<meta name="robots" content="' . implode(', ', $content) . '" />' : false; } // meta description and keywords if (!class_exists('All_in_One_SEO_Pack')) { if (is_home() || is_front_page()) { if (get_option('show_on_front') == 'page' && is_front_page()) { #wp $page_id = get_option('page_on_front'); } elseif (get_option('show_on_front') == 'page' && is_home()) { #wp $page_id = get_option('page_for_posts'); } #wp $keywords = $page_id ? get_post_meta($page_id, 'thesis_keywords', true) : urldecode($thesis_pages->home['head']['meta']['keywords']); if ($page_id && !get_post_meta($page_id, 'thesis_no_description', true)) { $description = strip_tags(stripslashes(get_post_meta($page_id, 'thesis_description', true))); } else { $description = $thesis_pages->home['head']['meta']['description'] ? urldecode($thesis_pages->home['head']['meta']['description']) : get_bloginfo('description'); } if ($description) { $meta['description'] = '<meta name="description" content="' . trim(wptexturize($description)) . '" />'; } #wp if ($keywords) { $meta['keywords'] = '<meta name="keywords" content="' . trim(wptexturize($keywords)) . '" />'; } } elseif (is_single() || is_page()) { #wp global $post; #wp $no_description = get_post_meta($post->ID, 'thesis_no_description', true); #wp $description = get_post_meta($post->ID, 'thesis_description', true); #wp $deprecated_description = get_post_meta($post->ID, thesis_get_custom_field_key('meta'), true); #wp $keywords = get_post_meta($post->ID, 'thesis_keywords', true); #wp $deprecated_keywords = get_post_meta($post->ID, thesis_get_custom_field_key('keywords'), true); #wp if (!$no_description) { if (strlen($description)) { $meta['description'] = '<meta name="description" content="' . trim(wptexturize(strip_tags(stripslashes($description)))) . '" />'; } elseif (strlen($deprecated_description)) { $meta['description'] = '<meta name="description" content="' . trim(wptexturize(strip_tags(stripslashes($deprecated_description)))) . '" />'; } else { setup_postdata($post); #wp add_filter('excerpt_length', 'thesis_meta_excerpt_length'); #wp #filter $excerpt = trim(str_replace('[...]', '', wp_trim_excerpt(''))); #wp remove_filter('excerpt_length', 'thesis_meta_excerpt_length'); #wp $meta['description'] = '<meta name="description" content="' . $excerpt . '" />'; } } if (strlen($keywords)) { $meta['keywords'] = '<meta name="keywords" content="' . trim(wptexturize(strip_tags(stripslashes($keywords)))) . '" />'; } elseif (strlen($deprecated_keywords)) { $meta['keywords'] = '<meta name="keywords" content="' . trim(wptexturize(strip_tags(stripslashes($deprecated_keywords)))) . '" />'; } else { $tags = thesis_get_post_tags($post->ID); if ($tags) { $meta['keywords'] = '<meta name="keywords" content="' . implode(', ', $tags) . '" />'; } } } elseif (is_category() || is_tag()) { #wp global $wp_query; #wp $description = is_category() ? urldecode($thesis_pages->categories[$wp_query->query_vars['cat']]['head']['meta']['description']) : urldecode($thesis_pages->tags[$wp_query->query_vars['tag_id']]['head']['meta']['description']); #wp $keywords = is_category() ? urldecode($thesis_pages->categories[$wp_query->query_vars['cat']]['head']['meta']['keywords']) : urldecode($thesis_pages->tags[$wp_query->query_vars['tag_id']]['head']['meta']['keywords']); #wp if ($description) { $meta['description'] = '<meta name="description" content="' . trim(wptexturize($description)) . '" />'; } #wp if ($keywords) { $meta['keywords'] = '<meta name="keywords" content="' . trim(wptexturize($keywords)) . '" />'; } #wp } } if ($meta) { $this->meta = $meta; } }