Last active
November 16, 2020 17:48
-
-
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/
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 | |
/** | |
* 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