bằng regex preg_match('/title="([^"]*)"/', $output, $matches); $title = $matches[1] ?? ''; $product = wc_get_product($attr['prod_id']); $price = $product->get_price_html($attr['prod_id']); $link = $product->get_permalink($attr['prod_id']); $image_html = wp_get_attachment_image( $product->get_image_id(), 'thumbnail', '', [ 'class' => 'adminz-hotspot-custom-image', 'style' => 'width: 75px; height: 75px;' ] ); // Tạo HTML mới $custom_html = <<
$image_html

$title

$price

HTML; $custom_html = apply_filters('adminz_custom_ux_hotspot_product',$custom_html, $attr['prod_id']); $output = preg_replace( '/title="([^"]*)"/', 'title="' . esc_attr($custom_html) . '"', // Chỉ update nội dung bên trong title $output ); } } return $output; }, 10, 4);