%s',
$parameters['browse_wishlist_text']
);
}
return $parameters;
}
add_filter( 'yith_wcwl_add_to_wishlist_params', 'themeoo_yith_wcwl_shortcode_parameters' );
}
/**
* @param int|false $product_id
* @param array $args
*
* @return void
*/
function themeoo_add_compare_link( $product_id = false, $args = array() ) {
global $yith_woocompare;
extract( $args ); // phpcs:ignore
if ( ! $product_id ) {
global $product;
$product_id = ! is_null( $product ) ? $product->get_id() : 0;
}
// Return if product doesn't exist.
if ( empty( $product_id ) || apply_filters( 'yith_woocompare_remove_compare_link_by_cat', false, $product_id ) ) {
return;
}
$is_button = ! isset( $button_or_link ) || ! $button_or_link ? get_option( 'yith_woocompare_is_button', 'button' ) : $button_or_link;
if ( ! isset( $button_text ) || 'default' === $button_text ) {
$button_text = get_option( 'yith_woocompare_button_text', __( 'Compare', 'ayyash' ) );
do_action( 'wpml_register_single_string', 'Plugins', 'plugin_yit_compare_button_text', $button_text );
$button_text = apply_filters( 'wpml_translate_single_string', $button_text, 'Plugins', 'plugin_yit_compare_button_text' );
}
printf( '', $yith_woocompare->obj->add_product_url( $product_id ), 'compare' . ( 'button' === $is_button ? ' button' : '' ), $product_id, $button_text ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
/**
* @return void
*/
function themeoo_handle_yith_compare_hooks() {
/** @var YITH_Woocompare $yith_woocompare */
global $yith_woocompare;
// Bail if yith compare not enabled.
if ( ! isset( $yith_woocompare ) ) { // @phpstan-ignore-line
return;
}
if ( ! $yith_woocompare->is_frontend() ) {
return;
}
if ( 'yes' === get_option( 'yith_woocompare_compare_button_in_product_page', 'yes' ) ) {
remove_action( 'woocommerce_single_product_summary', [ $yith_woocompare->obj, 'add_compare_link' ], 35 ); // @phpstan-ignore-line
add_action( 'woocommerce_single_product_summary', 'themeoo_add_compare_link', 35 );
}
if ( 'yes' === get_option( 'yith_woocompare_compare_button_in_products_list', 'no' ) ) {
remove_action( 'woocommerce_after_shop_loop_item', [ $yith_woocompare->obj, 'add_compare_link' ], 20 ); // @phpstan-ignore-line
add_action( 'woocommerce_after_shop_loop_item', 'themeoo_add_compare_link', 20 );
}
}
add_action( 'init', 'themeoo_handle_yith_compare_hooks', 12 );