From cbb8fa9c66430a51ce93a4eb5e0ad9120ea8f4ae Mon Sep 17 00:00:00 2001 From: James Koster Date: Mon, 21 Mar 2016 10:07:26 +0000 Subject: [PATCH] Move and style the product price in oEmbeds for better display on handheld devices. closes #10584 --- includes/class-wc-embed.php | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/includes/class-wc-embed.php b/includes/class-wc-embed.php index 36ab9f19db6..c64f2d0fbdd 100644 --- a/includes/class-wc-embed.php +++ b/includes/class-wc-embed.php @@ -29,7 +29,6 @@ class WC_Embed { public static function init() { // Filter all of the content that's going to be embedded. - add_filter( 'the_title', array( __CLASS__, 'the_title' ), 10 ); add_filter( 'the_excerpt_embed', array( __CLASS__, 'the_excerpt' ), 10 ); // Make sure no comments display. Doesn't make sense for products. @@ -42,26 +41,6 @@ class WC_Embed { add_action( 'embed_head', array( __CLASS__, 'print_embed_styles' ) ); } - /** - * Create the title for embedded products - we want to add the price to it. - * - * @since 2.4.11 - * @param string $title Embed title. - * @return string - */ - public static function the_title( $title ) { - // Make sure we're only affecting embedded products. - if ( self::is_embedded_product() ) { - - // Get product. - $_product = wc_get_product( get_the_ID() ); - - // Add the price. - $title = $title . '' . $_product->get_price_html() . ''; - } - return $title; - } - /** * Check if this is an embedded product - to make sure we don't mess up regular posts. * @@ -85,8 +64,13 @@ class WC_Embed { public static function the_excerpt( $excerpt ) { global $post; + // Get product. + $_product = wc_get_product( get_the_ID() ); + // Make sure we're only affecting embedded products. if ( self::is_embedded_product() ) { + echo '

' . $_product->get_price_html() . '

'; + if ( ! empty( $post->post_excerpt ) ) { ob_start(); woocommerce_template_single_excerpt(); @@ -161,7 +145,10 @@ class WC_Embed { margin: 0 0 1em; } .wc-embed-price { - float:right; + display: block; + opacity: .75; + font-weight: 700; + margin-top: -.75em; } .wc-embed-rating { display: inline-block;