Created
July 17, 2021 09:55
-
-
Save wpt00ls/9a2d56ed000bb5d0f3a0d58874b5eb62 to your computer and use it in GitHub Desktop.
WooCommerce Product Title Filter For Woo Product Carousel.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Custom Filter to add text after the woocommerce product title in ultimate product carousel | |
* | |
*/ | |
add_filter( | |
'udc_after_woo_product_title', | |
function ( | |
// product title in html | |
$product_title, | |
// product | |
$product, | |
// divi module props | |
$props, | |
// et_pb_multi_view_options | |
$multi_view | |
) { | |
$dimensions = $product->get_dimensions(); | |
if ($dimensions != 'N/A') { | |
$processed_title_level = isset($props['title_level']) ? $props['title_level'] : 'h4'; | |
$processed_title_level = et_pb_process_header_level($processed_title_level, 'h4'); | |
$processed_title_level = esc_html($processed_title_level); | |
$product_title = $multi_view->render_element( | |
[ | |
'tag' => et_core_intentionally_unescaped($processed_title_level, 'html'), | |
'content' => '{{title}}', | |
'attrs' => [ | |
'class' => 'wpt-image-card-title', | |
], | |
'custom_props' => [ | |
'title' => et_core_intentionally_unescaped(sprintf('%s (%s)', $product->get_name(), $dimensions), 'html'), | |
], | |
'required' => 'title', | |
] | |
); | |
} | |
return $product_title; | |
}, | |
10, | |
4 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment