Spelling WordPress Always Correctly

Sometimes it happens that you have misspelled WordPress in your article because you were in a rush. Since WordPress is a registered trademark, it should be natural to write WordPress the correct way. As Lorelle mentioned on her blog, Matt wrote a script, which forces WordPress into WordPress across all of the 5 million plus blogs on WordPress.com.

The following code snippet, which has to be insert in function.php, replaces wordpress, WordPress,wOrDPrESS and other spellings of WordPress:
Note: that function is PHP 5 only.

<?php
function writeWordPressCorrect($content) {
	$content = str_ireplace("wordpress","WordPress", $content);
	return $content;
}
add_filter('the_title', 'writeWordPressCorrect',1);
add_filter('the_content', 'writeWordPressCorrect',1);
?>

No more misspelling of WordPress. 馃檪


Posted

in

by

Comments

24 responses to “Spelling WordPress Always Correctly”

  1. Stefan Waidele Avatar

    Obviously, you do not use the snipplet in this article: “…which forces WordPress into WordPress across all…” 馃槈

  2. Michael Avatar

    We dont use it, but that little script shows how easy it is to modify WordPress.

  3. Wesley Avatar

    str_ireplace is PHP5 only. For a solution that also works in php4, do :

    preg_replace(‘/wordpress/i’, ‘WordPress’, $content);

    (untested)

  4. Michael Avatar

    Thanks Wesley, post updated.

  5. Rich Pedley Avatar

    Does either the php5, or php4 version affect url’s?

  6. Michael Avatar

    Rich, str_ireplace is only available in PHP5.
    But mine and Wesley’s snippets affects urls in the content and the title, not the permalink.
    But there is no problem, type WordPress.org in your browser and it works 馃槈

    Another option is to run those filters on saving the post. That saves alot performance.

  7. […] If you like to do things manually, you can add the code manually, as WPEngineer shows in “Spelling WordPress Always Correctly”. […]

  8. Frederick Avatar

    Indeed, running the filter upon saving the post would save a lot of performance.

    Also, using preg_replace as recommended above is not a suitable replacement for high-traffic sites, since Perl-regular-expression search-and-replace is slower than string search-and-replace… it adds up.

  9. Frederick Avatar

    Also, (sorry for the double post), just to point something out. If the function takes an incorrect rendition of ‘WordPress’ and makes it into the correct ‘WordPress’, shouldn’t the function be a bit more linguistically correct?

    What I mean is, ‘writeWordPressCorrect’ misuses an adjective in place of an adverb. It should be ‘writeWordPressCorrectly’.

  10. WPCult Avatar

    That would make Matt a happy boy.

  11. Claudius Coenen Avatar

    WordPress.org in your browser and it works

    That’s not fully correct. It works for domain-names, which are case-insensitive by definition. But it does not work if someone had wordpress as part of their path and runs a linux/unix server (which are case sensitive when it comes to paths).

    So this is really a difference:

    http://example.com/wordpress
    http://example.com/WordPress

    They will point to different directories or fail to do so.

  12. Christopher Ross Avatar

    Michael, thanks for this! I’ve been looking for a way to do something similar for one of my plugins. – Chris

  13. Michael Avatar

    Claudius, thats correct.

  14. […] Uma outra solu莽茫o, mais discreta e minimalista, 茅 incluir o c贸digo abaixo no arquivo functions.php do seu tema (caso o arquivo n茫o exista, crie-o). Funciona s贸 em servidores que rodem PHP 5, e os cr茅ditos v茫o para o WP Engineer: […]

  15. […] will, kann auch händisch ein Codesnippet in sein Theme einfügen, dass bei den WP-Engineers zu haben […]

  16. […] it really such a bad thing to standardize on the name? As Michael points out at WP Engineer, it is a trademark and it should always be presented correctly but should Matt and the boys at […]

  17. […] la pensate com Matt o per motivi vostri volete arrivare anche voi a questo risultato, su WpEngineer ho trovato questo codice da aggiungere al nostro […]

  18. Richard Avatar
    Richard

    Interesting function, you could do lots of things with this, like add a plugin function WriteMyPostalAddress
    change ” to ‘ …(‘myaddress’,’your html
    more html
    etc’, $content);
    add_filter ..WriteMyPostalAddress

    The question I have is say you do a series of plugin/function/shortcuts like this, is there an overhead?
    or is there any issues with that type of plugin shortcut?

    Is there any additional security or any additional code I should add to this type of simple admin-less plugin?

    As is, my WriteMyPostalAddress test using dreamweaver created wysiwyg table, code just plopped in, works great!

  19. Michael Avatar

    Richard: use this kind of functions carefully. Every filter slow down the peformance of your website.
    I don’t see any security problems with filters like that.

  20. Richard Avatar
    Richard

    Thanks Michael, so maybe the better bet is using QuickTags when possible.

    Is there a way to show a list of all filters being loaded?

  21. Michael Avatar

    Richard, not that i know.

  22. vijay Avatar
    vijay

    I have PHP4 and PHP5 on my server. Which one should I choose for running wordpress?

    And what needs to be changed in the default php.ini file?

  23. Michael Avatar

    vajay, i prefer to PHP5.

  24. Andrew C Avatar

    #1 – How can I Correct the spelling when I save/publish a post?

    #2 – As you can see (in the code below) I’m only changing the_title and looking for “exclusive” or “mp3” or both. How can I COMBINE this function?

    this is my code:

    # write EXCLUSIVE Correct
    function writeexclusiveCorrect($content) {
    $content = str_ireplace(“exclusive”,”EXCLUSIVE”, $content);
    return $content;
    }
    add_filter(‘the_title’, ‘writeexclusiveCorrect’,1);

    # write MP3 Correct
    function writemp3Correct($content) {
    $content = str_ireplace(“mp3″,”MP3”, $content);
    return $content;
    }
    add_filter(‘the_title’, ‘writemp3Correct’,1);