Example #1
0
 /**
  * Sets up and runs the functionality for getting the attachment meta.
  *
  * @since  2.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('hybrid_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 (hybrid_attachment_is_audio($this->args['post_id'])) {
         $this->audio_meta();
     } elseif (hybrid_attachment_is_video($this->args['post_id'])) {
         $this->video_meta();
     }
 }
Example #2
0
/**
 * Post <article> element attributes.
 *
 * @since  2.0.0
 * @access public
 * @param  array   $attr
 * @return array
 */
function hybrid_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() && hybrid_attachment_is_audio()) {
            $attr['itemtype'] = 'http://schema.org/AudioObject';
        } elseif ('attachment' === get_post_type() && hybrid_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;
}
Example #3
0
/**
 * Post <article> element attributes.
 *
 * @since  2.0.0
 * @access public
 * @param  array   $attr
 * @return array
 */
function hybrid_attr_post($attr)
{
    $post = get_post();
    /* Make sure we have a real post first. */
    if (!empty($post)) {
        $attr['itemscope'] = 'itemscope';
        if ('post' === get_post_type()) {
            $attr['itemtype'] = 'http://schema.org/BlogPosting';
            // Add itemprop if within the main query
            if (is_main_query() && !is_search()) {
                $attr['itemprop'] = 'blogPost';
            }
        } elseif ('attachment' === get_post_type() && wp_attachment_is_image()) {
            $attr['itemtype'] = 'http://schema.org/ImageObject';
        } elseif ('attachment' === get_post_type() && hybrid_attachment_is_audio()) {
            $attr['itemtype'] = 'http://schema.org/AudioObject';
        } elseif ('attachment' === get_post_type() && hybrid_attachment_is_video()) {
            $attr['itemtype'] = 'http://schema.org/VideoObject';
        } else {
            $attr['itemtype'] = 'http://schema.org/CreativeWork';
        }
    }
    return $attr;
}