コード例 #1
0
ファイル: module.php プロジェクト: alfredpp/sarath-portfolio
 function thb_seo()
 {
     if (is_404()) {
         return;
     }
     if (!thb_get_option('seo_enable')) {
         return;
     }
     echo "<!-- SEO -->\n";
     // SEO global data
     $url = is_front_page() ? home_url('/') : get_permalink();
     $author = thb_get_option('seo_author');
     $robots = thb_get_option('seo_robots');
     $description = thb_get_option('seo_description');
     $keywords = thb_get_option('seo_keywords');
     $google_verification = thb_get_option('google_site_verification');
     $title = is_front_page() ? get_bloginfo('name') : get_the_title();
     $logo = thb_get_option('main_logo');
     // Robots
     thb_meta('robots', $robots);
     // Author
     thb_meta('author', $author);
     // Description
     if (is_single() || is_page()) {
         $single_description = thb_get_post_meta(thb_get_page_ID(), 'seo_description');
         if (!empty($single_description)) {
             $description = $single_description;
         } else {
             $post = get_post(thb_get_page_ID());
             $description = thb_get_the_excerpt($post);
         }
     }
     thb_meta('description', $description);
     // Keywords
     if (is_single() || is_page()) {
         $single_keywords = thb_get_post_meta(thb_get_page_ID(), 'seo_keywords');
         if (!empty($single_keywords)) {
             $keywords .= ', ' . $single_keywords;
         }
     }
     thb_meta('keywords', $keywords);
     // News keywords
     if (is_single()) {
         $tags = '';
         $post_tags = get_the_tags();
         if (!empty($post_tags)) {
             $i = 0;
             foreach (get_the_tags() as $tag) {
                 $tags .= ($i == 0 ? '' : ',') . $tag->name;
                 $i++;
             }
             thb_meta('news_keywords', $tags);
         }
     }
     // Google site verification
     thb_meta('google-site-verification', $google_verification);
     // Facebook Open Graph
     // See: http://developers.facebook.com/docs/opengraph/
     echo "<!-- Open Graph -->\n";
     thb_meta('og:locale', get_bloginfo('language'));
     thb_meta('og:url', $url);
     thb_meta('og:site_name', get_bloginfo('name'));
     if (!empty($logo)) {
         thb_meta('og:image', thb_image_get_size($logo['id'], 'full'));
     }
     thb_meta('og:title', $title);
     thb_meta('og:description', $description);
     thb_meta('og:type', is_single() ? 'article' : 'website');
 }
コード例 #2
0
 function thb_the_excerpt($post, $truncate_at = null, $truncate_char = '&hellip;')
 {
     echo apply_filters('the_excerpt', thb_get_the_excerpt($post, $truncate_at, $truncate_char));
 }