Created
November 29, 2022 22:31
-
-
Save Pebblo/faef5dd32099e2ba06eee7ec733c06a9 to your computer and use it in GitHub Desktop.
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 if you already have one | |
function csv_header_change_filter_gettext( $translated, $original, $domain ) { | |
// This is an array of original strings | |
// and what they should be replaced with | |
$strings = array( | |
'Count of this registration in the group registration ' => 'Count', | |
'Registration\'s share of the transaction total' => 'SubTotal', | |
'Transaction Amount Due' => 'Total', | |
'Amount Paid' => 'Paid' | |
// Add some more strings here | |
); | |
// See if the current string is in the $strings array | |
// If so, replace its translation | |
if ( isset( $strings[$original] ) ) { | |
// This accomplishes the same thing as __() | |
// but without running it through the filter again | |
$translations = get_translations_for_domain( $domain ); | |
$translated = $translations->translate( $strings[$original] ); | |
} | |
return $translated; | |
} | |
add_filter( 'gettext', 'csv_header_change_filter_gettext', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment