Changing a text from a Woocommerce 3rd party plugin

Arda Yilmaz :

I'm using WooCommerce Wishlist and want to change product added to something else. here is the snippet:

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;
}

What is the best practice to change that text from function.php

lupoyucc :

Since the string is already wrapped into the function __($string, $domain), you can easily translate it without using any code or editing your functions.php. All you need is a translator plugin (I suggest using Loco Translate).

  • Install the plugin
  • After installation go to "Loco Translate" > "Plugins" using the left column menu on WP dashboard
  • You will see a list of plugins currently installed on your website, select the one you use to manage WooCommerce Whislists
  • Then select your language from the list, or click on "New language" if your language isn't there (and insert the language settings if you are creating a new one)
  • Select the string you want to translate, and put the translation in the bottom text-area
  • Save

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=19993&siteId=1