Home › Forums › WoodMart support forum › How can I wrap the Wishlist text in another tag › Reply To: How can I wrap the Wishlist text in another tag
January 31, 2024 at 1:39 pm
#535450
Chingiz
Participant
Please tell me what can be done. I’m not good at PHP. I’m trying to inherit from the ui class, but I’m not getting anywhere.
namespace XTS\WC_Wishlist;
if ( ! defined( 'ABSPATH' ) ) {
exit( 'No direct script access allowed' );
}
use XTS\Ui;
class New_Ui extends Ui {
public function add_to_wishlist_btn( $classes = '' ) {
woodmart_enqueue_js_script( 'wishlist' );
if ( woodmart_get_opt( 'wishlist_expanded' ) && 'disable' !== woodmart_get_opt( 'wishlist_show_popup', 'disable' ) && is_user_logged_in() ) {
woodmart_enqueue_js_script( 'wishlist-group' );
}
$added = false;
$link_classes = '';
$text = esc_html__( 'Add to wishlist', 'woodmart' );
$product_id = apply_filters( 'wpml_object_id', get_the_ID(), 'product', true, apply_filters( 'wpml_default_language', null ) );
if ( $this->wishlist && $this->wishlist->get_all() && woodmart_get_opt( 'wishlist_save_button_state', '0' ) ) {
$products = $this->wishlist->get_all();
foreach ( $products as $product ) {
if ( (int) get_the_ID() === (int) $product['product_id'] ) {
$added = true;
}
}
}
if ( $added ) {
$link_classes .= ' added';
$text = esc_html__( 'Browse Wishlist', 'woodmart' );
}
$classes .= woodmart_get_old_classes( ' woodmart-wishlist-btn' );
?>
<div class="wd-wishlist-btn <?php echo esc_attr( $classes ); ?>">
<a class="<?php echo esc_attr( $link_classes ); ?>" href="<?php echo esc_url( woodmart_get_wishlist_page_url() ); ?>" data-key="<?php echo esc_attr( wp_create_nonce( 'woodmart-wishlist-add' ) ); ?>" data-product-id="<?php echo esc_attr( $product_id ); ?>" rel="nofollow" data-added-text="<?php esc_html_e( 'Browse Wishlist', 'woodmart' ); ?>">
<noindex><span><?php echo esc_html( $text ); ?></span></noindex>
</a>
</div>
<?php
}
}