Skip to content

Instantly share code, notes, and snippets.

@ipokkel
Last active January 2, 2024 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ipokkel/930b05cecc858fd3eaefcb9c858e540b to your computer and use it in GitHub Desktop.
Save ipokkel/930b05cecc858fd3eaefcb9c858e540b to your computer and use it in GitHub Desktop.
Change or translate text for PMPro Advanced Levels Shortcode using gettext filter #pmpro-advanced-levels-shortcode #translate
<?php
/**
* This recipe is an example of how to change or translate
* localized text strings for PMPro Advanced Levels Shortcode.
*
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function change_text_for_pmpro_advanced_levels_shortcode( $translated_text, $text, $domain ) {
if ( 'pmpro' === $domain || 'pmpro-advanced-levels-shortcode' === $domain ) {
switch ( $text ) {
case 'Membership Never Expires.':
$translated_text = __( 'Your translation here', 'pmpro-advanced-levels-shortcode' );
break;
case 'Membership never expires.':
$translated_text = __( 'Your translation here', 'pmpro-advanced-levels-shortcode' );
break;
case 'Free.':
$translated_text = __( 'Your translation here', 'pmpro-advanced-levels-shortcode' );
break;
case 'Free':
$translated_text = __( 'Your translation here', 'pmpro-advanced-levels-shortcode' );
break;
}
}
return $translated_text;
}
add_filter( 'gettext', 'change_text_for_pmpro_advanced_levels_shortcode', 20, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment