/** * Add Microdata to download description * * @since 1.5 * @author Sunny Ratilal * * @param $content * @return mixed|void New title */ function edd_microdata_description($content) { global $post; static $microdata_description = NULL; if (!edd_add_schema_microdata() || true === $microdata_description || !is_object($post)) { return $content; } if ($post && $post->post_type == 'download' && is_singular('download') && is_main_query()) { $microdata_description = true; $content = apply_filters('edd_microdata_wrapper', '<div itemprop="description">' . $content . '</div>'); } return $content; }
/** * Downloads Shortcode * * This shortcodes uses the WordPress Query API to get downloads with the * arguments specified when using the shortcode. A list of the arguments * can be found from the EDD Dccumentation. The shortcode will take all the * parameters and display the downloads queried in a valid HTML <div> tags. * * @since 1.0.6 * @internal Incomplete shortcode * @param array $atts Shortcode attributes * @param string $content * @return string $display Output generated from the downloads queried */ function edd_downloads_query($atts, $content = null) { $atts = shortcode_atts(array('category' => '', 'exclude_category' => '', 'tags' => '', 'exclude_tags' => '', 'relation' => 'OR', 'number' => 9, 'price' => 'no', 'excerpt' => 'yes', 'full_content' => 'no', 'buy_button' => 'yes', 'columns' => 3, 'thumbnails' => 'true', 'orderby' => 'post_date', 'order' => 'DESC', 'ids' => '', 'pagination' => 'true'), $atts, 'downloads'); $query = array('post_type' => 'download', 'orderby' => $atts['orderby'], 'order' => $atts['order']); if ('true' === $atts['pagination']) { $query['posts_per_page'] = (int) $atts['number']; if ($query['posts_per_page'] < 0) { $query['posts_per_page'] = abs($query['posts_per_page']); } } else { $query['nopaging'] = true; } switch ($atts['orderby']) { case 'price': $atts['orderby'] = 'meta_value'; $query['meta_key'] = 'edd_price'; $query['orderby'] = 'meta_value_num'; break; case 'title': $query['orderby'] = 'title'; break; case 'id': $query['orderby'] = 'ID'; break; case 'random': $query['orderby'] = 'rand'; break; default: $query['orderby'] = 'post_date'; break; } if ($atts['tags'] || $atts['category'] || $atts['exclude_category'] || $atts['exclude_tags']) { $query['tax_query'] = array('relation' => $atts['relation']); if ($atts['tags']) { $tag_list = explode(',', $atts['tags']); foreach ($tag_list as $tag) { if (is_numeric($tag)) { $term_id = $tag; } else { $term = get_term_by('slug', $tag, 'download_tag'); if (!$term) { continue; } $term_id = $term->term_id; } $query['tax_query'][] = array('taxonomy' => 'download_tag', 'field' => 'term_id', 'terms' => $term_id); } } if ($atts['category']) { $categories = explode(',', $atts['category']); foreach ($categories as $category) { if (is_numeric($category)) { $term_id = $category; } else { $term = get_term_by('slug', $category, 'download_category'); if (!$term) { continue; } $term_id = $term->term_id; } $query['tax_query'][] = array('taxonomy' => 'download_category', 'field' => 'term_id', 'terms' => $term_id); } } if ($atts['exclude_category']) { $categories = explode(',', $atts['exclude_category']); foreach ($categories as $category) { if (is_numeric($category)) { $term_id = $category; } else { $term = get_term_by('slug', $category, 'download_category'); if (!$term) { continue; } $term_id = $term->term_id; } $query['tax_query'][] = array('taxonomy' => 'download_category', 'field' => 'term_id', 'terms' => $term_id, 'operator' => 'NOT IN'); } } if ($atts['exclude_tags']) { $tag_list = explode(',', $atts['exclude_tags']); foreach ($tag_list as $tag) { if (is_numeric($tag)) { $term_id = $tag; } else { $term = get_term_by('slug', $tag, 'download_tag'); if (!$term) { continue; } $term_id = $term->term_id; } $query['tax_query'][] = array('taxonomy' => 'download_tag', 'field' => 'term_id', 'terms' => $term_id, 'operator' => 'NOT IN'); } } } if ($atts['exclude_tags'] || $atts['exclude_category']) { $query['tax_query']['relation'] = 'AND'; } if (!empty($atts['ids'])) { $query['post__in'] = explode(',', $atts['ids']); } if (get_query_var('paged')) { $query['paged'] = get_query_var('paged'); } else { if (get_query_var('page')) { $query['paged'] = get_query_var('page'); } else { $query['paged'] = 1; } } switch (intval($atts['columns'])) { case 0: $column_width = 'inherit'; break; case 1: $column_width = '100%'; break; case 2: $column_width = '50%'; break; case 3: $column_width = '33%'; break; case 4: $column_width = '25%'; break; case 5: $column_width = '20%'; break; case 6: $column_width = '16.6%'; break; default: $column_width = '33%'; break; } // Allow the query to be manipulated by other plugins $query = apply_filters('edd_downloads_query', $query, $atts); $downloads = new WP_Query($query); if ($downloads->have_posts()) { $i = 1; $wrapper_class = 'edd_download_columns_' . $atts['columns']; ob_start(); ?> <div class="edd_downloads_list <?php echo apply_filters('edd_downloads_list_wrapper_class', $wrapper_class, $atts); ?> "> <?php while ($downloads->have_posts()) { $downloads->the_post(); ?> <?php $schema = edd_add_schema_microdata() ? 'itemscope itemtype="http://schema.org/Product" ' : ''; ?> <div <?php echo $schema; ?> class="<?php echo apply_filters('edd_download_class', 'edd_download', get_the_ID(), $atts, $i); ?> " id="edd_download_<?php echo get_the_ID(); ?> " style="width: <?php echo $column_width; ?> ; float: left;"> <div class="edd_download_inner"> <?php do_action('edd_download_before'); if ('false' != $atts['thumbnails']) { edd_get_template_part('shortcode', 'content-image'); do_action('edd_download_after_thumbnail'); } edd_get_template_part('shortcode', 'content-title'); do_action('edd_download_after_title'); if ($atts['excerpt'] == 'yes' && $atts['full_content'] != 'yes') { edd_get_template_part('shortcode', 'content-excerpt'); do_action('edd_download_after_content'); } else { if ($atts['full_content'] == 'yes') { edd_get_template_part('shortcode', 'content-full'); do_action('edd_download_after_content'); } } if ($atts['price'] == 'yes') { edd_get_template_part('shortcode', 'content-price'); do_action('edd_download_after_price'); } if ($atts['buy_button'] == 'yes') { edd_get_template_part('shortcode', 'content-cart-button'); } do_action('edd_download_after'); ?> </div> </div> <?php if ($atts['columns'] != 0 && $i % $atts['columns'] == 0) { ?> <div style="clear:both;"></div><?php } ?> <?php $i++; } ?> <div style="clear:both;"></div> <?php wp_reset_postdata(); ?> <?php $pagination = false; if (is_single()) { $pagination = paginate_links(apply_filters('edd_download_pagination_args', array('base' => get_permalink() . '%#%', 'format' => '?paged=%#%', 'current' => max(1, $query['paged']), 'total' => $downloads->max_num_pages), $atts, $downloads, $query)); } else { $big = 999999; $search_for = array($big, '#038;'); $replace_with = array('%#%', '&'); $pagination = paginate_links(apply_filters('edd_download_pagination_args', array('base' => str_replace($search_for, $replace_with, get_pagenum_link($big)), 'format' => '?paged=%#%', 'current' => max(1, $query['paged']), 'total' => $downloads->max_num_pages), $atts, $downloads, $query)); } ?> <?php if (!empty($pagination)) { ?> <div id="edd_download_pagination" class="navigation"> <?php echo $pagination; ?> </div> <?php } ?> </div> <?php $display = ob_get_clean(); } else { $display = sprintf(_x('No %s found', 'download post type name', 'easy-digital-downloads'), edd_get_label_plural()); } return apply_filters('downloads_shortcode', $display, $atts, $atts['buy_button'], $atts['columns'], $column_width, $downloads, $atts['excerpt'], $atts['full_content'], $atts['price'], $atts['thumbnails'], $query); }
<?php $item_prop = edd_add_schema_microdata() ? ' itemprop="description"' : ''; ?> <div<?php echo $item_prop; ?> class="edd_download_full_content"> <?php echo apply_filters('edd_downloads_content', get_post_field('post_content', get_the_ID())); ?> </div>
/** * Add Microdata to download description * * @since 1.5 * @author Sunny Ratilal * * @param $content * @return mixed|void New title */ function edd_microdata_wrapper($content) { global $post; if (!edd_add_schema_microdata()) { return $content; } if ($post && $post->post_type == 'download' && is_singular() && is_main_query()) { $content = apply_filters('edd_microdata_wrapper', '<div itemscope itemtype="http://schema.org/Product" itemprop="description">' . $content . '</div>'); } return $content; }
<?php $item_prop = edd_add_schema_microdata() ? ' itemprop="name"' : ''; ?> <h3<?php echo $item_prop; ?> class="edd_download_title"> <a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a> </h3>
<?php if (!edd_has_variable_prices(get_the_ID())) { ?> <?php $item_props = edd_add_schema_microdata() ? ' itemprop="offers" itemscope itemtype="http://schema.org/Offer"' : ''; ?> <div<?php echo $item_props; ?> > <div itemprop="price" class="edd_price"> <?php edd_price(get_the_ID()); ?> </div> </div> <?php }