/** * Return the widget/shortcode output * * @param array $atts Array of widget/shortcode attributes/args * @return string Widget output */ public static function get_widget($atts) { global $wp_query; $post = $wp_query->post; $widget = ''; // Set up default values for attributes $atts = shortcode_atts(array('before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => '', 'title' => '', 'price_label' => __('Price', 'art-store'), 'shipping_label' => __('Shipping Information', 'art-store'), 'width_label' => __('Width', 'art-store'), 'height_label' => __('Height', 'art-store'), 'depth_label' => __('Depth', 'art-store'), 'notes_label' => __('Notes', 'art-store')), (array) $atts, self::$shortcode); // Before widget hook $widget .= $atts['before_widget']; // Title $widget .= $atts['title'] ? $atts['before_title'] . esc_html($atts['title']) . $atts['after_title'] : ''; $widget .= the_art_store_product_information($post->ID, false); // After widget hook $widget .= $atts['after_widget']; // if we've decided to display product info in the main content or if the post type isn't art-store-work if ('content' == art_store_get_option('product_info') || 'art-store-work' !== $post->post_type) { return; } else { return $widget; } }
/** * Output the product information. * * @param int $post_id The id of the post to display information about * @return string $output The html-formatted product information */ public function product_information($post_id) { // bail if no post ID was passed if (0 == $post_id) { return; } $output = ''; ob_start(); ?> <div class="art-store-information product-information" id="art-work-<?php echo $post_id; ?> "> <dl> <?php // are we displaying the price and purchase info in the content? if ('content' == art_store_get_option('product_info')) { the_art_store_product_information($post_id); } ?> </dl> </div> <div class="art-store-meta product-metainfo"> <ul> <?php if (get_art_store_product_terms('art-store-subject', $post_id)) { ?> <li><?php the_art_store_themes(); ?> </li> <?php } ?> <?php if (get_art_store_product_terms('art-store-form', $post_id)) { ?> <li><?php the_art_store_forms(); ?> </li> <?php } ?> <?php if (get_art_store_product_terms('art-store-medium', $post_id)) { ?> <li><?php the_art_store_media(); ?> </li> <?php } ?> </ul> </div> <?php $output = ob_get_clean(); return $output; }