0

Wordpress has a filter called the_content where one can, for example, change all occurrences of the word "foo" to "bar" in the callback function:

add_filter('the_content','callback');
function callback($content){
    $content = str_ireplace("foo","bar",$content);
    return $content;
}

My question is how can I do the same thing in the admin area?

We are rebranding a plugin, and if you've tackled that before, you know it gets a bit more involved than doing a simple "search and replace."

What I'd like to do in the meantime is find and replace "OldPluginBranding" with "NewPluginBranding" whereever it occurs in the wp-admin area. the_content filter doesn't seem to work in that area, however.

0

There's no filter for filtering all of the HTML output in the admin. The closest thing is the gettext filter:

function wpse_275812_filter_text( $translated_text, $text, $domain ) {
    $translate_text = str_ireplace( 'foo', 'bar', $translated_text );

    return $translated_text;
}
add_filter( 'gettext', 'wpse_275812_filter_text' );

This filters any text output by the internationalization functions (__(), _e(), etc.). So it will only work if the plugin you're trying to filter uses these functions to output its text.

If it doesn't, there's nothing you can really do.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.