Exemple #1
0
 /**
  * Sets up and runs the functionality for getting the attachment meta.
  *
  * @since 1.0.0
  * @access public
  * @param array $args
  * @return void
  */
 public function __construct($args = array())
 {
     $defaults = array('post_id' => get_the_ID(), 'labels' => array(), 'echo' => true);
     $this->args = apply_filters('hoot_media_meta_args', wp_parse_args($args, $defaults));
     /* Get the attachment metadata. */
     $this->meta = wp_get_attachment_metadata($this->args['post_id']);
     /* If the attachment is an image. */
     if (wp_attachment_is_image($this->args['post_id'])) {
         $this->image_meta();
     } elseif (hoot_attachment_is_audio($this->args['post_id'])) {
         $this->audio_meta();
     } elseif (hoot_attachment_is_video($this->args['post_id'])) {
         $this->video_meta();
     }
 }
/**
 * Post <article> element attributes.
 *
 * @since 1.0.0
 * @access public
 * @param array $attr
 * @return array
 */
function hoot_attr_post($attr)
{
    $post = get_post();
    /* Make sure we have a real post first. */
    if (!empty($post)) {
        $attr['id'] = 'post-' . get_the_ID();
        $attr['class'] = join(' ', get_post_class());
        $attr['itemscope'] = 'itemscope';
        if ('post' === get_post_type()) {
            $attr['itemtype'] = 'http://schema.org/BlogPosting';
            $attr['itemprop'] = 'blogPost';
        } elseif ('attachment' === get_post_type() && wp_attachment_is_image()) {
            $attr['itemtype'] = 'http://schema.org/ImageObject';
        } elseif ('attachment' === get_post_type() && hoot_attachment_is_audio()) {
            $attr['itemtype'] = 'http://schema.org/AudioObject';
        } elseif ('attachment' === get_post_type() && hoot_attachment_is_video()) {
            $attr['itemtype'] = 'http://schema.org/VideoObject';
        } else {
            $attr['itemtype'] = 'http://schema.org/CreativeWork';
        }
    } else {
        $attr['id'] = 'post-0';
        $attr['class'] = join(' ', get_post_class());
    }
    return $attr;
}