Advertisement
SergeyBiryukov

Customize WooCommerce Strings

Jan 1st, 2017
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.64 KB | None | 0 0
  1. function vk_customize_woocommerce_strings( $translation, $text, $domain ) {
  2.     if ( 'woocommerce' !== $domain ) {
  3.         return $translation;
  4.     }
  5.  
  6.     // Массив точных соответствий
  7.     $custom_text = array(
  8.         'Товар' => 'Продукт',
  9.         'Товары' => 'Продукты',
  10.     );
  11.  
  12.     if ( isset( $custom_text[ $translation ] ) ) {
  13.         $translation = $custom_text[ $translation ];
  14.     } else {
  15.         // Правила для гибкой замены
  16.         $translation = str_ireplace( 'товар', 'продукт', $translation );
  17.     }
  18.  
  19.     return $translation;
  20. }
  21. add_filter( 'gettext', 'vk_customize_woocommerce_strings', 10, 3 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement