• Chris Huff

    (@brochris)


    Usually when I want to edit a plugin, I just edit the plugin. But this means that I need to edit it every time the plugin is updated. I like receiving plugin updates, because they often bring bug fixes or new functionality, but I don’t want to have to make the same edits to the same plugins over and over again. Is there a better way?

    For example, in the Social Connect plugin, I want to change the words “Connect with” to “Login with”

    Is the best way just to edit the plugin files, like I’ve done in the past, or something else?

Viewing 2 replies - 1 through 2 (of 2 total)
  • ishan001

    (@ishan001)

    Currently, there’s no way to do this. The best you can do is to request the plugin author to make the text configurable.

    Stagger Lee

    (@stagger-lee)

    Try to play with these:

    function replace_text_wps($text){
    	$replace = array(
    	// 'WORD TO REPLACE' => 'REPLACE WORD WITH THIS'
    	'Frei' => '<a href="https://mysite.com/myafflink">Frei</a>',
    	'studiopress' => '<a href="https://mysite.com/myafflink">studiopress</a>'
    	);
    	$text = str_replace(array_keys($replace), $replace, $text);
    	return $text;
    }
    
    add_filter('the_content', 'replace_text_wps');
    add_filter('the_excerpt', 'replace_text_wps');
    add_filter('tablepress_table_output', 'replace_text_wps');
    function replace_text($text) {
         $text = str_replace('look-for-this-string', 'replace-with-this-string', $text);
         $text = str_replace('look-for-that-string', 'replace-with-that-string', $text);
         return $text;
    }
    add_filter('the_content', 'replace_text');
    function replace_text_wps($text){
    $replace = array(
    // 'WORD TO REPLACE' => 'REPLACE WORD WITH THIS'
    'wordpress' => '<a href="#">wordpress</a>',
    'excerpt' => '<a href="#">excerpt</a>',
    'function' => '<a href="#">function</a>'
    );
    $text = str_replace(array_keys($replace), $replace, $text);
    return $text;
    }
    
    add_filter('the_content', 'replace_text_wps');
    add_filter('the_excerpt', 'replace_text_wps');
    function replace_content($content)
    {
    $content = str_replace('Company Name', '<span class="company">Company Name</span>',$content);
    return $content;
    }
    add_filter('the_content','replace_content');
    function replace_content($content)
    {
    $content = str_replace('##Replace Me##', '##With Something Else##',$content);
    return $content;
    }
    add_filter('the_content','replace_content');
    add_filter(  'gettext',  'wps_translate_words_array'  );
    add_filter(  'ngettext',  'wps_translate_words_array'  );
    function wps_translate_words_array( $translated ) {
         $words = array(
                            // 'word to translate' = > 'translation'
                            'Posts' => 'Article',
                            'Post' => 'Articles',
                            'Pages' => 'Stuffing',
                            'Media' => 'Upload Images',
                            'Links' => 'Blog Roll',
                        );
         $translated = str_ireplace(  array_keys($words),  $words,  $translated );
         return $translated;
    }
    add_filter('gettext', 'change_post_to_article');
    add_filter('ngettext', 'change_post_to_article');
    function change_post_to_article($translated) {
    $translated = str_ireplace('Post', 'Article', $translated);
    return $translated;
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change text of plugin’ is closed to new replies.