/** * Product content filter */ public function product_single($content) { if (is_singular(array('art-store-work')) || is_post_type_archive(array('art-store-work')) || 'art-store-work' == get_post_type(get_the_ID())) { global $post; $product_information = get_art_store_info($post->ID); ob_start(); // display the featured image first if (art_store_get_option('show_featured_image')) { if (has_post_thumbnail($post->ID)) { echo get_the_post_thumbnail($post->ID, 'large'); } else { // if there's no featured image, tell someone about it _e('No image set for this product.', 'art-store'); } } // display the post content echo $content; echo $this->product_information($post->ID); return ob_get_clean(); } else { return $content; } }
/** * Function to either return a linked button, the button code or nothing for a product * * @param int $post_id The id of the post * @return string $output A hyperlinked image, html button code, or nothing if not for sale */ function art_store_display_button($post_id = 0) { // bail if no id was passed if (0 == $post_id) { return; } // get the product information $product_information = get_art_store_info($post_id); // bail if the product isn't foir sale if (in_array($product_information['status'], array('enquire', 'sold', 'nfs'))) { return; } if ('code' == art_store_get_option('code_or_url') && $product_information['btn_code']) { return wp_kses_post($product_information['btn_code']); } if ('url' == art_store_get_option('code_or_url') && $product_information['btn_url']) { if (get_art_store_button_url()) { return sprintf('<a href="%1$s"><img src="%2$s" title="%3$s" /></a>', $product_information['btn_url'], get_art_store_button_url(), get_the_title()); } else { return sprintf('<a href="%s">%2$s</a>', $product_information['btn_url'], __('Buy Now', 'art-store')); } } return; }