Move and style the product price in oEmbeds for better display on handheld devices. closes #10584
This commit is contained in:
parent
beedd1c930
commit
cbb8fa9c66
|
@ -29,7 +29,6 @@ class WC_Embed {
|
||||||
public static function init() {
|
public static function init() {
|
||||||
|
|
||||||
// Filter all of the content that's going to be embedded.
|
// 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 );
|
add_filter( 'the_excerpt_embed', array( __CLASS__, 'the_excerpt' ), 10 );
|
||||||
|
|
||||||
// Make sure no comments display. Doesn't make sense for products.
|
// 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' ) );
|
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 . '<span class="wc-embed-price">' . $_product->get_price_html() . '</span>';
|
|
||||||
}
|
|
||||||
return $title;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this is an embedded product - to make sure we don't mess up regular posts.
|
* 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 ) {
|
public static function the_excerpt( $excerpt ) {
|
||||||
global $post;
|
global $post;
|
||||||
|
|
||||||
|
// Get product.
|
||||||
|
$_product = wc_get_product( get_the_ID() );
|
||||||
|
|
||||||
// Make sure we're only affecting embedded products.
|
// Make sure we're only affecting embedded products.
|
||||||
if ( self::is_embedded_product() ) {
|
if ( self::is_embedded_product() ) {
|
||||||
|
echo '<p><span class="wc-embed-price">' . $_product->get_price_html() . '</span></p>';
|
||||||
|
|
||||||
if ( ! empty( $post->post_excerpt ) ) {
|
if ( ! empty( $post->post_excerpt ) ) {
|
||||||
ob_start();
|
ob_start();
|
||||||
woocommerce_template_single_excerpt();
|
woocommerce_template_single_excerpt();
|
||||||
|
@ -161,7 +145,10 @@ class WC_Embed {
|
||||||
margin: 0 0 1em;
|
margin: 0 0 1em;
|
||||||
}
|
}
|
||||||
.wc-embed-price {
|
.wc-embed-price {
|
||||||
float:right;
|
display: block;
|
||||||
|
opacity: .75;
|
||||||
|
font-weight: 700;
|
||||||
|
margin-top: -.75em;
|
||||||
}
|
}
|
||||||
.wc-embed-rating {
|
.wc-embed-rating {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|
Loading…
Reference in New Issue