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

Writing Your First WordPress Plugin Part 4

Posted on October 5, 2011 by Pippin in Beginner, Free Members, Member Restricted, Tutorials, Video Tutorials, Writing Plugins 22 Comments
Home» Tutorials » Beginner » Writing Your First WordPress Plugin Part 4
Tweet
Love It - 0
This entry is part 4 of 7 in the Writing Your First WordPress Plugins, Basic to Advanced Series
← Writing Your First WordPress Plugin Part 3Writing Your First WordPress Plugin Part 5 →
  • How to Begin Writing Your First WordPress plugin
  • Structuring Your First WordPress Plugin
  • Writing Your First WordPress Plugin Part 3
  • Writing Your First WordPress Plugin Part 4
  • Writing Your First WordPress Plugin Part 5
  • Writing Your First WordPress Plugin Part 6
  • Writing Your First WordPress Plugin Part 7 – Final

In part four of Writing Your First WordPress Plugin, I demonstrate how to load style sheets with your plugin. I also walk you through some best practices in terms of efficiency in regards to when you should, and should not, load styles/scripts with your plugin.

You must be logged in to view the rest of this content. Register or login from the sidebar.

Tweet Follow @pippinsplugins
add_action, CSS, wp_enqueue_script, wp_enqueue_style

22 comments on “Writing Your First WordPress Plugin Part 4”

  1. mohalam says:
    October 31, 2011 at 4:44 am

    I am following you. You really gave me the appetite to start a plugin that I was dreaming of!

    Reply
    • Pippin says:
      October 31, 2011 at 11:21 am

      Excellent! Glad I’ve inspired you!

  2. mohalam says:
    November 5, 2011 at 2:04 am

    I am waiting for the rest of the series!

    Reply
    • Pippin says:
      November 5, 2011 at 9:46 am

      Next part should be coming soon.

  3. GP says:
    December 8, 2011 at 2:58 am

    Hi Pippin,
    This is my first ever stint with plugin development having not so strong php background. But, I am following your series and finding now plugin-development not so difficult. Actually, I am stuck at a point(part 4)where we load the css files in the scripts.php. Either my stylesheet is not loading because the style I applied does not reflect there. I used proper file path names, file name is also correct, checked them several times.Dunno what the problem might be?

    Reply
    • Pippin says:
      December 8, 2011 at 10:15 am

      @GP – Plugin development is definitely not that difficult. It seems a lot more difficult than it really is. Hopefully this series will help other people as well who believe it’s more difficult than it is.

      Can you show me the code you have for the script loading? Use http://snippi.com and paste the URL here.

  4. GP says:
    December 9, 2011 at 1:10 am

    Hey Pippin, you know what, I figured that out. It was my silly mistake of misspelling of get_options() instead of get_option in the main plugin file.

    Thnx Anyways.
    And, Thnx for your serial tutorials. I have successfully developed my first ever plugin in wp.A treat for beginners like me.

    Reply
    • Pippin says:
      December 9, 2011 at 8:56 am

      Yep, that will cause it :)

  5. GP says:
    December 13, 2011 at 1:00 am

    Hi Pippin,My form data which i fill on the plugins admin area(plugins settings page) shows ‘Setting Saved’ on clicking Save button. But, after that, the text field gets empty and nothing gets affected, I mean when I click on Follow me on Twitter , it takes me to same area which I hard coded before. So, i mean to say that plugin is not saving the data in the database.Cud u tell me why and also, where the form info goes to get saved(which table particularly).

    Reply
    • Pippin says:
      December 13, 2011 at 10:24 am

      @GP – Can you please post the code from your settings page into a pastebin.com and put the link here?

  6. Dannymh says:
    March 13, 2012 at 7:25 am

    Pippin I am a long time Joomla extension developer coming over to WordPress for a few projects, your methodology is good, and structuring things the way you have, has been useful.

    One thing I would say is wouldn’t it be better to put conditional statements around the add_actions that way you wont be jumping into additional functions, hooks and calls wen they wont be used.

    I mean I know you use if(is)singular()) inside the function, but wouldn’t it be best to avoid the overhead of loading the hook and function if it isn’t needed.

    It may only save you a tiny, tiny bit of performance, but I know that on one of my sites, every bit of performance I can squeeze out of it is of the utmost importance due to the activity on the site.

    Just some thoughts and would like to hear your thouights

    Reply
    • Pippin says:
      March 13, 2012 at 9:03 am

      Daniel, you’re definitely right. I chose to not use add_action() hooks as much in this series because they can be very difficult for beginners to grasp a good understanding of. If this were not for beginners, then I would definitely feel that doing it with add_action() hooks would be better.

  7. Dannymh says:
    March 13, 2012 at 4:17 pm

    no problem thanks for that.

    One thing I am having trouble finding and understanding is how to output plugin data to pages of their own.

    I am writing a twist on a link directory, I have all the database and admin side all ready to go and working perfectly. However I need to have a page for this to be output to, generally in Joomla you have the MVC which I tend to loathe and find it hinders rapid development rather than helps it.

    Do you have a tutorial or can you point me towards one that will help me create the user side of the plugin, with front-end user interaction that is not dependent on the wordpress custom post types?

    Reply
    • Pippin says:
      March 13, 2012 at 4:37 pm

      You will want to use short codes. I did a very basic tutorial here: http://pippinsplugins.com/add-a-short-code-to-your-plugin/

    • Dannymh says:
      March 13, 2012 at 4:40 pm

      Thanks a bunch mate, great work. The plugin I am creating is a private one but once the site is up I’ll shoot you a link.

  8. Keely says:
    May 2, 2012 at 7:53 pm

    Fantastic tutorials … clear and great for beginners. Enjoying watching the vids and learning without a lot of frowning. Thanks Pippin!

    Reply
    • Pippin says:
      May 2, 2012 at 8:04 pm

      Great! I’m glad you’re enjoying them!

  9. kshitiz says:
    September 13, 2012 at 4:53 am

    Hi, where is the final code? I am unable to download… please help

    Reply
    • Pippin says:
      September 13, 2012 at 12:02 pm

      It’s at the bottom of the post, where it says “Download WIP Plugin”.

  10. Martin says:
    November 16, 2012 at 2:18 pm

    Great tuts Pippin, I am having trouble adding a predefined function to the top of the content and top ‘n’ bottom, it appears to work and then a few different plugins/ themes show my links at the top of the page as well. Any thoughts what could cause this? I am using for to add to top
    function m8m_top($content){
    if(is_single() && is_main_query()){
    $output = get_link_code();//predefined function
    $content .= $output;
    }
    return $content;
    }
    add_filter(‘the_content’, m8m_top’);

    Reply
    • Pippin says:
      November 16, 2012 at 7:27 pm

      What happens with that code? Anything?

  11. Taleeb Ahmad says:
    December 26, 2012 at 11:35 am

    Pippin can you help me little bit in writting a plugin.i want to write a sign up plugin

    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

  • Plugin Development 101 – Intro to Actions
  • Ensure Your Scripts and Styles Are Not Cached with Updates
  • Plugin Thoughts Episode 7 – Remember Core CSS
  • Using pre_get_posts to Modify Queries for Meta Data and More
  • Let’s Talk Extensible Code

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 (5)

    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

  • @om4james That&#039;s what I was looking for, thanks. That was not easy to find @woothemes
    May 24, 2013
  • @om4james Whoops, sorry, I meant the WooCommerce ones @woothemes
    May 24, 2013
  • @woothemes What&#039;s up with not having basic documentation on short codes on the docs page? Am I just blind?
    May 24, 2013

Topics

shortcodes the_content get_user_meta Sugar Event Calendar register_setting contextual help attachments add_shortcode hook featured campaign monitor wp_enqueue_script Rémi Corson short codes do_action Related posts mail chimp plugin authors attachment image forms login bbpress comments recent posts apply_filters post types taxonomies short code custom post type images gallery Ajax Stripe taxonomy jquery users widgets 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