Last active
August 29, 2015 13:56
-
-
Save deckerweb/9134266 to your computer and use it in GitHub Desktop.
DE: Benutzerdefinierte Begriffsänderung (String Swap) für "Warenkorb-Zwischensumme" in WooCommerce - setzt Plugin "WooCommerce German (de_DE)" voraus! // EN: Custom String Swap for "Cart Subtotal" in WooCommerce - relies on active plugin "WooCommerce German (de_DE)"!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** Do NOT include the opening php tag */ | |
add_action( 'get_header', 'wcde_custom_string_swap_cart_subtotal', 99 ); | |
/** | |
* String swap for "Cart Subtotal:"/ "Cart Subtotal" string in WooCommerce. | |
* | |
* NOTE: This snippet relies on active "WooCommerce German (de_DE)" plugin, | |
* version 3.1.0 or higher! | |
* | |
* @author David Decker - DECKERWEB | |
* @link http://deckerweb.de/twitter | |
* @link https://gist.github.com/deckerweb/9134266 | |
* | |
* @uses wcde_is_german() To determine if in German-locale based environment. | |
* @uses ddw_wcde_custom_strings_via_l10n_global() WCDE helper function for doing the string swap. | |
*/ | |
function wcde_custom_string_swap_cart_subtotal() { | |
/** Bail early if no WCDE, and no German-based enviroment */ | |
if ( ! function_exists( 'ddw_wcde_custom_strings_via_l10n_global' ) | |
&& ! wcde_is_german() | |
) { | |
return; | |
} // end if | |
/** | |
* Helper filter, allows for custom disabling of string swaps. | |
* | |
* Usage: add_filter( 'wcde_filter_do_string_swaps', '__return_false' ); | |
*/ | |
$wcde_do_string_swaps = (bool) apply_filters( 'wcde_filter_do_string_swaps', '__return_true' ); | |
/** | |
* Bail early if our helper filter returns false. | |
*/ | |
if ( ! $wcde_do_string_swaps ) { | |
return; | |
} // end if | |
/** Set up our array of planned string swap keys/ strings */ | |
$wcde_labels = array( | |
/** Variant 1: "Cart Subtotal:" */ | |
'cart_subtotal_string_one' => array( | |
'option_key' => 'cart_subtotal_string_one', | |
'strings' => array( 'Cart Subtotal:' ), | |
'translation' => 'Zwischensumme:', | |
), | |
/** Variant 2: "Cart Subtotal" */ | |
'cart_subtotal_string_two' => array( | |
'option_key' => 'cart_subtotal_string_two', | |
'strings' => array( 'Cart Subtotal' ), | |
'translation' => 'Zwischensumme', | |
), | |
); // end of array | |
/** Apply our string swapper for each string or our array */ | |
foreach ( $wcde_labels as $wcde_label => $label_id ) { | |
/** Actually load the various new label strings for display */ | |
ddw_wcde_custom_strings_via_l10n_global( | |
$label_id[ 'option_key' ], | |
(array) $label_id[ 'strings' ], | |
$label_id[ 'translation' ], | |
'woocommerce' | |
); | |
} // end foreach | |
} // end function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this. In which directory I must put in this file?