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 3 – Don’t Forget About Core Functions

Posted on February 27, 2012 by Pippin in Podcasts 10 Comments
Home» Podcasts » Plugin Thoughts Episode 3 – Don’t Forget About Core Functions
Tweet
Love It - 1
This entry is part 3 of 9 in the Plugin Thoughts Series
← Plugin Thoughts Episode Two – Use Filters for Plugin TextPlugin Thoughts Episode 4 – Learn How Core Does It →
  • 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

When developing for WordPress, both in themes and plugins, do not forget that many, many core functions exist and that it is not always necessary (or wise) to write your own custom methods. Most core functions have actions and filters included, so when you write your own function to replace the one in core, these filters and actions are often excluded, which results in other developers not being able to use the filters and actions when also using your plugin or theme.

This episode is a direct result of my experience while working with a theme (mentioned in the video) that has a custom function for displaying featured post thumbnails. I was attempting to modify the HTML of the featured thumbnail, though the core post_thumbnail_html filter, but since the theme used its own custom function, which did not include this filter, my filter function was useless.

Tweet Follow @pippinsplugins
Jason Bobich, post_thumbnail_html

10 comments on “Plugin Thoughts Episode 3 – Don’t Forget About Core Functions”

  1. Carlitoescobar says:
    February 27, 2012 at 2:38 pm

    Nicely done. I normally don’t sit though all of these video. This one was interesting to see the solution was simple and really it was made that way by looking at the core. WWCD?

    c.

    Reply
    • Pippin says:
      February 27, 2012 at 2:39 pm

      Thanks. Keeping WWCD (What Would Core DO) in mind during development of both themes and plugins will definitely result in fewer headaches in the end, for everyone involved.

  2. Xtence says:
    February 27, 2012 at 4:28 pm

    Very educatieve video, something to keep in mind, Thanks for sharing!

    Reply
  3. Jason says:
    February 27, 2012 at 4:38 pm

    After watching your video, it took me back to when I was creating the function and believe it or not, I did actually have a reason for doing that (which is now kind of irrelevant). I am aware of get_the_post_thumbnail obvously but chose not to use it. And trust me, it would have much easier to use that function, but then I was going to have also create an additional function that filtered WordPress’s thumbnail markup in some hacky way to accomplish what I needed. Let me explain.

    When you use get_the_post_thumbnail the HTML WordPress returns has the width/height of the image hardcoded in there. And with that, it screwed with the responsive design of the theme. If you notice, all images in the theme will compress down when you make your site smaller. This is possible because of this in my CSS:

    img {
    max-width:100%;
    }

    But this doesn’t work when you have a width/height attached to the image’s markup. However in the last month I’ve learned the simple little thing (that I probably should have known already) that I can override a width/height on the HTML markup by doing this:

    img {
    max-width:100%;
    width:auto;
    height:auto;
    }

    lol.. so no, I’m not anti-WordPress core, but yes, I will go ahead and make the change you’re suggesting, which is probably for the better. I probably wouldn’t have done it if it weren’t for your video, so thanks!

    Reply
    • Pippin says:
      February 27, 2012 at 4:52 pm

      That makes perfect sense, and, believe me, I know you’re not anti-core ;) AS you know I’m a huge fan of your themes.

      I’ve just looked through all of the core functions for outputting images, and, sadly, there is not a filter that allows you to remove the width=”" and height=”" attributes. But another way that it could be done (instead of relying on CSS, which should work just as well), would be to modify the HTML returned by get_the_post_thumbnail() with the “post_thumbnail_html” filter. You could pretty easily strip out the height and width tags with that filter. I’m not sure if there are any negative side-effects of doing this, however.

    • Jason says:
      February 27, 2012 at 4:59 pm

      Yea, I looked into all that when I was setting it up, and I settled on that being the option that made the most sense.

      But this is a good time that you’re bringing this up. I’m currently looking to add any changes in a push to release 2.1 of the framework. So far a lot of stuff has changed for 2.1. There’s a whole new API system in place for you to make changes to sliders, layout builder, theme options, etc from your child theme with some simple functions.

      This will be released with the new Jump Start project I’m not sure if you know about or not. Basically it’s going to be a simple version of the theme framework with a website dedicated to having tutorials on making child themes for it… hopefully eventually to take a run at Genesis in the coming years.

      So, ya if you have any more suggestions like this, feel free to send em over!

    • Pippin says:
      February 27, 2012 at 5:03 pm

      Version 2.1 should be sweet!

      I’ve heard you mention Jump Start, and it sounds great!

  4. orionrush says:
    July 2, 2012 at 1:12 pm

    Some very good points here Pippin – but for developers new to WP and frankly to development for that matter – what’s the best way to ensure your 1) not reinventing the wheel and 2) not omitting/breaking core functionality?

    Granted experience probably helps here – and exploring the core is good – but I just have trouble with the scope because WP is so huge.

    Reply
    • Pippin says:
      July 2, 2012 at 1:22 pm

      The first thing I would do whenever you attempting to build / use some functionality or other, is to do some google searches to see if you can find existing methods for doing what you want. Let’s look at a simple example: you are building a function that sends a user an email, and in order to get their email address (let’s say you only have their user name) you have to user their user login name. You might do a google search for “Find WordPress user data from login name”. This result will lead you to the

      get_user_by()

      function, which will do everything you need.

      It’s really about properly researching the task at hand.

  5. orionrush says:
    July 2, 2012 at 4:14 pm

    or of course I could always listen to part4 . . . doh!

    Reply

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

Sorry, no related items found.

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

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