Skip to content

Instantly share code, notes, and snippets.

@joshfeck joshfeck/strings.php Secret
Created Jun 5, 2018

Embed
What would you like to do?
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
function tw_custom_filter_gettext( $translated, $original, $domain ) {
// This is an array of original strings
// and what they should be replaced with
$strings = array(
'Sold Out' => 'Class Full',
// 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', 'tw_custom_filter_gettext', 10, 3 );
function add_cap_to_access_message(
$text,
$ticket,
$ticket_price,
$ticket_status
) {
$cap_required = '';
$cap_required = $ticket->get_extra_meta('ee_ticket_cap_required', true);
$search = '_';
$replace = ' ';
$cap_required_display_name = str_replace( $search, $replace, $cap_required);
$text = 'This course is restricted to ' . $cap_required_display_name . ' employees.';
return $text;
}
add_filter(
'FHEE__EED_WP_Users_Ticket_Selector__maybe_restrict_ticket_option_by_cap__no_access_msg',
'add_cap_to_access_message',
10,
4
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.