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

Latest Tutorials

  • Storing Session Data in WordPress without $_SESSION (19)

    The term Session in web development refers to...

  • Test Your Plugins with RTL (1)

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

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

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

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

WP Core Contributions

  • [24316]

View the ticket on Trac.

WP Codex Contributions

  • Function: shortcode exists
  • Function: has shortcode
  • Function: shortcode exists
  • Function: shortcode exists
  • Function: has shortcode

View all 41 changes in the Codex.

Latest Tweets

  • Could not fetch Twitter RSS feed.

Topics

contextual help featured register_setting shortcodes attachments add_options_page Tom McFarlin get_user_meta hook add_shortcode meta box Sugar Event Calendar wp_enqueue_script forms short codes plugin do_action login Related posts authors mail chimp attachment image recent posts post types apply_filters comments short code bbpress taxonomies custom post type Ajax gallery images Stripe taxonomy jquery 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