Pippins Plugins
  • Email
  • Facebook
  • Feedburner
  • Github
  • Google
  • Twitter
  • Vimeo
  • Youtube
  • Rss
  • About
  • News
  • Join the Site
    • Member Benefits
    • Member Plugins
    • Email Notifications
  • Plugin Store
    • Affiliate Area
    • Checkout
  • Plugins
    • Plugin Portfolio
      • Plugin Portfolio – List View
    • Free
    • Premium
    • Member Plugins
    • Coding Standards
    • Get Plugin Support
  • Tutorials
    • Series
      • Plugin Development 101
      • Creating a User Follow System Plugin
      • Customizing Restrict Content Pro
      • Displaying Content with Easy Content Types
      • Writing Your First WordPress Plugins, Basic to Advanced
      • Working with Widgets
      • User Submitted Image Galleries
      • Plugin Thoughts
      • Integrating Stripe.com with WordPress
      • WordPress Rewrite API
    • Member Exclusive
      • Free Members
      • Subscriber Only
    • Difficulty
      • Beginner
      • Intermediate
      • Advanced
    • Action and Filter Hooks
    • Ajax
    • Custom Post Types
    • External APIs
    • Short Codes
    • Taxonomies
    • Video Tutorials
    • Widget Tutorials
    • WordPress Admin / Dashboard
    • Working with jQuery
    • WordPress Database
    • Writing Plugins
    • Tag Index
  • Reviews
  • Support Forum
  • Contact
    • Support the Site
    • Request Code Review
    • Plugin Support

Plugin Thoughts Episode Two – Use Filters for Plugin Text

Posted on February 22, 2012 by Pippin in Podcasts 7 Comments
Home» Podcasts » Plugin Thoughts Episode Two – Use Filters for Plugin Text
Tweet
Love It - 2
This entry is part 2 of 9 in the Plugin Thoughts Series
← Plugin Thoughts Episode 1: Making Your Plugins More ExtensiblePlugin Thoughts Episode 3 – Don’t Forget About Core Functions →
  • Plugin Thoughts Episode 1: Making Your Plugins More Extensible
  • Plugin Thoughts Episode Two – Use Filters for Plugin Text
  • Plugin Thoughts Episode 3 – Don’t Forget About Core Functions
  • Plugin Thoughts Episode 4 – Learn How Core Does It
  • Plugin Thoughts Episode 5 – Take Responsibility for Your Products
  • Plugin Thoughts Episode 6 – Contribute to the WordPress Codex
  • Plugin Thoughts Episode 7 – Remember Core CSS
  • Plugin Thoughts Episode 8 – Create Clean Code
  • Plugin Thoughts Episode 9 – Write Better Code; Release Better Plugins

In episode two of Plugin Thoughts, I talk about how and why to use filter hooks in your plugins to make it easy for your users and other developers to change text in your plugins.


Tweet Follow @pippinsplugins
add_filter, apply_filters

7 comments on “Plugin Thoughts Episode Two – Use Filters for Plugin Text”

  1. up84 says:
    April 1, 2012 at 6:54 am

    Hi Pippin. I just signed up, cool tutorials you have there. I’m not sure if we need to use filter in such case. Why can’t we use the main localization file to provide another text? We’re not translating the plugin doing this, but I think it’s ok. Curious to hear your thoughts.

    Reply
    • Pippin says:
      April 1, 2012 at 10:10 am

      I’ve heard both sides and personally feel it is better to provide both. Let’s say that a user using your plugin in the same language it was written in wants to change the text, it is much easier for them to change it via a filter than it is by translating the MO files, especially since they may only need to change that one line. If a user is using the plugin not in the language it was written, then they can translate the entire plugin AND change the text at the same time.

    • up84 says:
      April 1, 2012 at 10:22 am

      I see.

      I would just open the file ( en_US.po ) using PoEdit and “translate” Register New Account into “Membership Application”. It’s not a translation, but it seems to work :)

      Do you think it’s wrong if the user doesn’t want to translate a plugin, but just needs to modify the text using MO file? Is it ok to use MO files for something other than translations?

    • Pippin says:
      April 1, 2012 at 10:30 am

      I don’t know that either way is necessarily right or wrong, but they both definitely work.

    • up84 says:
      April 1, 2012 at 10:33 am

      Cool. Just wanted to know your opinion. Thanks ;)

  2. Andrew says:
    October 23, 2012 at 11:15 pm

    In your example, you have a parameter called $header – where does that come from? I think it’s something that always confuses me with filters. I couldn’t see a $header in member-forms.php either. Would it have worked without the $header?

    Reply
    • Pippin says:
      October 24, 2012 at 9:38 am

      $header comes from where the original filter was setup. In this case, Restrict Content Pro (the plugin being used as a demo), does this:

      1
      
      <?php echo apply_filters( 'rcp_registration_header_logged_in', __( 'Register New Account', 'rcp' ) ); ?>

      The first parameter in apply_filters() is the name of the filter and the second is the value passed to the filter ($header). So $header is this:

      1
      
      __( 'Register New Account', 'rcp' )

      Note that the name of the parameter can be anything. I used $header simply because it made logical sense, but you could have just as easily used $text.

      Make sense?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Login

Lost your password?

Please enter your username or e-mail address. You will receive a new password via e-mail.

  • Facebook Become a Fan Like

  • Twitter Subscribe on Twitter Follow

  • YouTube Follow my Videos Subscribe

  • RSS Feed Subscribe with RSS Subscribe

Easy Digital Downloads

Most Loved

  • Love It Pro for WordPress
  • Write a “Love It” Plugin with Ajax to Let Users Love Their Favorite Posts / Pages
  • Simple Notices Pro Plugin for WordPress
  • User Bookmarks for WordPress
  • Front End Registration and Login Forms Plugin

Similar Plugins and Posts

  • Plugin Development 101 – An Intro to Filters
  • Introduction to the gettext Filter in WordPress
  • Let’s Talk Extensible Code
  • Playing Nice with the “the_content” Filter
  • Adding Custom Fields to the Easy Digital Downloads Checkout

Latest Premium Content

  • Plugin Development 101 – Introduction to Adding Dashboard Menus
  • Plugin Development 101 – Intro to Loading Scripts and Styles
  • User Follow System – Part 5
  • Plugin Development 101 – Intro to Short Codes
  • Plugin Development 101 – Registering a Custom Post Type
  • Plugin Development 101 – Intro to Actions

Latest Tutorials

  • Test Your Plugins with RTL (0)

    Right-To-Left languages are those that...

  • Submitting Your First Pull Request to a WordPress Plugin on Github (4)

    Github is an extremely popular tool for managing WordPress plugins, and one...

  • Plugin Development 101 – Introduction to Adding Dashboard Menus (1)

    Adding new menus, both top level and sub level, to the WordPress Dashboard is a really common task for plugins...

Enter your email to receive automated updates when new posts are published

Latest Tweets

  • @SDavisMedia awesome! I will get it listed on the site soon
    May 23, 2013
  • @JS_Zao That&#039;s awesome!
    May 23, 2013
  • Whether it&#039;s membership plugins or ecommerce plugins, @WPSellNet can help you get them setup and maintained: http://t.co/R06sOj9yTl
    May 23, 2013

Topics

campaign monitor meta box Rémi Corson wp_enqueue_script featured shortcodes contextual help add_options_page register_setting Tom McFarlin attachments the_content hook forms Related posts do_action plugin short codes login mail chimp authors attachment image apply_filters recent posts comments post types bbpress short code taxonomies custom post type Ajax gallery images Stripe jquery taxonomy widgets users add_filter easy content types add_action widget restrict content pro easy digital downloads

Weekly Newsletter

Useful Links

  • Join the Site
  • Plugin Store
  • Affiliate Area
  • Tag Index
  • Support the Site
  • Suggest a Tutorial
  • Random Post
  • Contact

Monthly Archives

(c) 2013 Pippin's Plugins