Skip to content

Instantly share code, notes, and snippets.

@glueckpress
Last active November 16, 2020 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glueckpress/9603f7e3797180224cba to your computer and use it in GitHub Desktop.
Save glueckpress/9603f7e3797180224cba to your computer and use it in GitHub Desktop.
[WordPress] Offer filterable text strings in WordPress themes and child themes. Makes it easy to adjust original text, fully translatable. Example footer.php borrowed from _s (underscores) starter theme by @Automattic. http://glck.be/5740/
<?php
/**
* Your _s child theme functions.php.
*
* For sake of example only. Remember _s is made for hacking, not for child themes.
*
*/
function _s_child_theme_setup() {
load_child_theme_textdomain( '_s-child-theme', get_stylesheet_directory( . '/languages' );
}
add_action( 'after_setup_theme', '_s_child_theme_setup' );
/**
* Filter text from footer.php
*/
function _s_child_theme_template_footer_text( $strings ) {
$strings[1] = sprintf(
__( 'Super-proudly powered by %s', '_s' ),
__( 'WordPress and the good gods of the internet.', '_s-child-theme' )
);
return $strings;
}
add_filter( '_s_template_footer_text_strings', '_s_child_theme_template_footer_text', 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment