我正在使用WooCommerce愿望清单,并想将添加产品更改为其他内容。这是代码段:
public static function add_to_wishlist_button( $url, $product_type, $exists ) {
_deprecated_function( 'add_to_wishlist_button', '2.0.0', 'add-to-wishlist-button.php template' );
global $yith_wcwl, $product;
$product_id = yit_get_product_id( $product );
$label_option = get_option( 'yith_wcwl_add_to_wishlist_text' );
$localize_label = function_exists( 'icl_translate' ) ? icl_translate( 'Plugins', 'plugin_yit_wishlist_button', $label_option ) : $label_option;
$label = apply_filters( 'yith_wcwl_button_label', $localize_label );
$icon = get_option( 'yith_wcwl_add_to_wishlist_icon' ) != 'none' ? '<i class="fa ' . get_option( 'yith_wcwl_add_to_wishlist_icon' ) . '"></i>' : '';
$classes = get_option( 'yith_wcwl_use_button' ) == 'yes' ? 'class="add_to_wishlist single_add_to_wishlist button alt"' : 'class="add_to_wishlist"';
$html = '<div class="yith-wcwl-add-to-wishlist">';
$html .= '<div class="yith-wcwl-add-button'; // the class attribute is closed in the next row
$html .= $exists ? ' hide" style="display:none;"' : ' show"';
$html .= '><a href="' . esc_url( add_query_arg( 'add_to_wishlist', $product_id ) ) . '" data-product-id="' . $product_id . '" data-product-type="' . $product_type . '" ' . $classes . ' >' . $icon . $label . '</a>';
$html .= '<img src="' . esc_url( admin_url( 'images/wpspin_light.gif' ) ) . '" class="ajax-loading" alt="loading" width="16" height="16" style="visibility:hidden" />';
$html .= '</div>';
$html .= '<div class="yith-wcwl-wishlistaddedbrowse hide" style="display:none;"><span class="feedback">' . __( 'Product added!','yith-woocommerce-wishlist' ) . '</span> <a href="' . esc_url( $url ) . '">' . apply_filters( 'yith-wcwl-browse-wishlist-label', __( 'Browse Wishlist', 'yith-woocommerce-wishlist' ) ) . '</a></div>';
$html .= '<div class="yith-wcwl-wishlistexistsbrowse ' . ( $exists ? 'show' : 'hide' ) . '" style="display:' . ( $exists ? 'block' : 'none' ) . '"><span class="feedback">' . __( 'The product is already in the wishlist!', 'yith-woocommerce-wishlist' ) . '</span> <a href="' . esc_url( $url ) . '">' . apply_filters( 'yith-wcwl-browse-wishlist-label', __( 'Browse Wishlist', 'yith-woocommerce-wishlist' ) ) . '</a></div>';
$html .= '<div style="clear:both"></div><div class="yith-wcwl-wishlistaddresponse"></div>';
$html .= '</div>';
$html .= '<div class="clear"></div>';
return $html;
}
从function.php更改文本的最佳实践是什么?>
我正在使用WooCommerce愿望清单,并希望更改添加到其他产品的产品。这是代码段:公共静态函数add_to_wishlist_button($ url,$ product_type,$ exists){...
由于字符串已经包装在函数__($string, $domain)
中,因此您可以轻松转换它,而无需使用任何代码或编辑functions.php。您需要的只是一个翻译插件(我建议使用Loco Translate)。
我看到您已经接受了一个答案,但是您询问是否将其放入函数中,所以这是方法。过滤器gettext
接受3个参数gettext Hook