/**
  * returns the item scope meta. It returns an empty string if the module is used in a loop (not on a single page)
  * 16 march 2015
  * @return string
  */
 function get_item_scope_meta()
 {
     if (!is_single()) {
         return '';
     }
     $buffy = '';
     //the vampire slayer
     $author_id = $this->post->post_author;
     $buffy .= '<meta itemprop="author" content = "' . get_the_author_meta('display_name', $author_id) . '">';
     $buffy .= '<meta itemprop="interactionCount" content="UserComments:' . get_comments_number($this->post->ID) . '"/>';
     if (td_review::has_review($this->td_review)) {
         $td_article_date_unix = get_the_time('U', $this->post->ID);
         $buffy .= '<meta itemprop="itemReviewed " content = "' . $this->title . '">';
         if (!empty($this->td_review['review'])) {
             $buffy .= '<meta itemprop="about" content = "' . esc_attr($this->td_review['review']) . '">';
         } else {
             //we have no review :|
             //get a damn excerpt for the metatag
             if ($this->post->post_excerpt != '') {
                 $td_post_excerpt = $this->post->post_excerpt;
             } else {
                 $td_post_excerpt = td_util::excerpt($this->post->post_content, 25);
             }
             $buffy .= '<meta itemprop="about" content = "' . esc_attr($td_post_excerpt) . '">';
         }
         $buffy .= '<meta itemprop="datePublished" content="' . date(DATE_W3C, $td_article_date_unix) . '">';
         $buffy .= '<span class="td-page-meta" itemprop="reviewRating" itemscope itemtype="' . td_global::$http_or_https . '://schema.org/Rating">';
         $buffy .= '<meta itemprop="worstRating" content = "1">';
         $buffy .= '<meta itemprop="bestRating" content = "5">';
         $buffy .= '<meta itemprop="ratingValue" content = "' . td_review::calculate_total_stars($this->td_review) . '">';
         $buffy .= ' </span>';
     }
     return $buffy;
 }
示例#2
0
 /**
  * This method outputs the item scope for SINGLE templates. If you are looking for the modules @see td_module::get_item_scope_meta()
  * @updated 23 july 2015
  *  - if the module that uses this class is not on a single page, we use the @see td_module::get_item_scope_meta() this allows
  * us to output normal module item scope insted of no item scope like it was before this update
  * @updated 16 december 2015
  * - removed structured data from modules, now it displays only on single and it returns the current post data
  * - no more interference with the itemprop's coming from modules
  * - all single structured data is now gathered here
  * @return string
  */
 function get_item_scope_meta()
 {
     // don't display meta on pages
     if (!is_single()) {
         return '';
     }
     // determine publisher name - use author name if there's no blog name
     $td_publisher_name = get_bloginfo('name');
     if (empty($td_publisher_name)) {
         $td_publisher_name = esc_attr(get_the_author_meta('display_name', $this->post->post_author));
     }
     // determine publisher logo
     $td_publisher_logo = td_util::get_option('tds_logo_upload');
     $buffy = '';
     //the vampire slayer
     // author
     $buffy .= '<span style="display: none;" itemprop="author" itemscope itemtype="https://schema.org/Person">';
     $buffy .= '<meta itemprop="name" content="' . esc_attr(get_the_author_meta('display_name', $this->post->post_author)) . '">';
     $buffy .= '</span>';
     // datePublished
     $td_article_date_unix = get_the_time('U', $this->post->ID);
     $buffy .= '<meta itemprop="datePublished" content="' . date(DATE_W3C, $td_article_date_unix) . '">';
     // dateModified
     $buffy .= '<meta itemprop="dateModified" content="' . the_modified_date('c', '', '', false) . '">';
     // mainEntityOfPage
     $buffy .= '<meta itemscope itemprop="mainEntityOfPage" itemType="https://schema.org/WebPage" itemid="' . get_permalink($this->post->ID) . '"/>';
     // publisher
     $buffy .= '<span style="display: none;" itemprop="publisher" itemscope itemtype="https://schema.org/Organization">';
     $buffy .= '<span style="display: none;" itemprop="logo" itemscope itemtype="https://schema.org/ImageObject">';
     $buffy .= '<meta itemprop="url" content="' . $td_publisher_logo . '">';
     $buffy .= '</span>';
     $buffy .= '<meta itemprop="name" content="' . $td_publisher_name . '">';
     $buffy .= '</span>';
     // headline @todo we may improve this one to use the subtitle or excerpt? - We could not find specs about what it should be.
     $buffy .= '<meta itemprop="headline " content="' . esc_attr($this->post->post_title) . '">';
     // featured image
     $td_image = array();
     if (!is_null($this->post_thumb_id)) {
         /**
          * from google documentation:
          * A URL, or list of URLs pointing to the representative image file(s). Images must be
          * at least 160x90 pixels and at most 1920x1080 pixels.
          * We recommend images in .jpg, .png, or. gif formats.
          * https://developers.google.com/structured-data/rich-snippets/articles
          */
         $td_image = wp_get_attachment_image_src($this->post_thumb_id, 'full');
     } else {
         // when the post has no image use the placeholder
         $td_image[0] = get_template_directory_uri() . '/images/no-thumb/td_meta_replacement.png';
         $td_image[1] = '1068';
         $td_image[2] = '580';
     }
     // ImageObject meta
     if (!empty($td_image[0])) {
         $buffy .= '<span style="display: none;" itemprop="image" itemscope itemtype="https://schema.org/ImageObject">';
         $buffy .= '<meta itemprop="url" content="' . $td_image[0] . '">';
         $buffy .= '<meta itemprop="width" content="' . $td_image[1] . '">';
         $buffy .= '<meta itemprop="height" content="' . $td_image[2] . '">';
         $buffy .= '</span>';
     }
     // if we have a review, we must add additional stuff
     if ($this->is_review) {
         // the item that is reviewd
         $buffy .= '<span style="display: none;" itemprop="itemReviewed" itemscope itemtype="https://schema.org/Thing">';
         $buffy .= '<meta itemprop="name " content = "' . $this->title_attribute . '">';
         $buffy .= '</span>';
         if (!empty($this->td_review['review'])) {
             $buffy .= '<meta itemprop="reviewBody" content = "' . esc_attr($this->td_review['review']) . '">';
         } else {
             //we have no review text :| get a excerpt for the about meta thing
             if ($this->post->post_excerpt != '') {
                 $td_post_excerpt = $this->post->post_excerpt;
             } else {
                 $td_post_excerpt = td_util::excerpt($this->post->post_content, 45);
             }
             $buffy .= '<meta itemprop="reviewBody" content = "' . esc_attr($td_post_excerpt) . '">';
         }
         // review rating
         $buffy .= '<span style="display: none;" class="td-page-meta" itemprop="reviewRating" itemscope itemtype="' . td_global::$http_or_https . '://schema.org/Rating">';
         $buffy .= '<meta itemprop="worstRating" content = "1">';
         $buffy .= '<meta itemprop="bestRating" content = "5">';
         $buffy .= '<meta itemprop="ratingValue" content = "' . td_review::calculate_total_stars($this->td_review) . '">';
         $buffy .= ' </span>';
     }
     return $buffy;
 }
 /**
  * This method outputs the item scope for SINGLE templates. If you are looking for the modules @see td_module::get_item_scope_meta()
  * @updated 23 july 2015
  *  - if the module that uses this class is not on a single page, we use the @see td_module::get_item_scope_meta() this allows
  * us to output normal module item scope insted of no item scope like it was before this update
  * @return string
  */
 function get_item_scope_meta()
 {
     if (!is_single()) {
         return parent::get_item_scope_meta();
         // get a normal item scope if we're in a loop - like on a blog style loop
     }
     $buffy = '';
     //the vampire slayer
     $buffy .= parent::get_item_scope_meta();
     // if we have a review, we must add additional stuff
     if (td_review::has_review($this->td_review)) {
         // the item that is reviewd
         $buffy .= '<meta itemprop="itemReviewed " content = "' . $this->title_attribute . '">';
         if (!empty($this->td_review['review'])) {
             $buffy .= '<meta itemprop="about" content = "' . esc_attr($this->td_review['review']) . '">';
         } else {
             //we have no review text :| get a excerpt for the about meta thing
             if ($this->post->post_excerpt != '') {
                 $td_post_excerpt = $this->post->post_excerpt;
             } else {
                 $td_post_excerpt = td_util::excerpt($this->post->post_content, 25);
             }
             $buffy .= '<meta itemprop="about" content = "' . esc_attr($td_post_excerpt) . '">';
         }
         // review rating
         $buffy .= '<span class="td-page-meta" itemprop="reviewRating" itemscope itemtype="' . td_global::$http_or_https . '://schema.org/Rating">';
         $buffy .= '<meta itemprop="worstRating" content = "1">';
         $buffy .= '<meta itemprop="bestRating" content = "5">';
         $buffy .= '<meta itemprop="ratingValue" content = "' . td_review::calculate_total_stars($this->td_review) . '">';
         $buffy .= ' </span>';
     }
     return $buffy;
 }
示例#4
0
 function get_item_scope_meta()
 {
     $buffy = '';
     //the vampire slayer
     $author_id = $this->post->post_author;
     $buffy .= '<meta itemprop="author" content = "' . get_the_author_meta('display_name', $author_id) . '">';
     $authorMetaGoogle = get_the_author_meta('googleplus', $author_id);
     if (!empty($authorMetaGoogle)) {
         echo '<a href="' . $authorMetaGoogle . '?rel=author"></a>';
     }
     if (td_review::has_review($this->td_review) and is_single()) {
         //show the review meta only on single posts that are reviews, the rest have to be article (in article lists)
         $td_article_date_unix = get_the_time('U', $this->post->ID);
         if (!empty($this->td_review['review'])) {
             $buffy .= '<meta itemprop="about" content = "' . $this->td_review['review'] . '">';
         } else {
             //we have no review :|
             $buffy .= '<meta itemprop="about" content = "' . $this->get_excerpt(25) . '">';
         }
         $buffy .= '<meta itemprop="itemreviewed" content = "' . $this->title . '">';
         $buffy .= '<meta itemprop="datePublished" content="' . date(DATE_W3C, $td_article_date_unix) . '">';
         //$buffy .= '<meta itemprop="url" rel="author" content = "' . get_author_posts_url($author_id) . '">';
         $buffy .= '<span class="td-page-meta" itemprop="reviewRating" itemscope itemtype="' . td_global::$http_or_https . '://schema.org/Rating">';
         $buffy .= '<meta itemprop="worstRating" content = "1">';
         $buffy .= '<meta itemprop="bestRating" content = "5">';
         $buffy .= '<meta itemprop="ratingValue" content = "' . td_review::calculate_total_stars($this->td_review) . '">';
         $buffy .= ' </span>';
     }
     return $buffy;
 }