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 5

Posted on November 9, 2011 by Pippin in Free Members, Intermediate, Member Restricted, Tutorials, Writing Plugins 20 Comments
Home» Member Restricted » Free Members » Writing Your First WordPress Plugin Part 5
Tweet
Love It - 2
This entry is part 5 of 7 in the Writing Your First WordPress Plugins, Basic to Advanced Series
← Writing Your First WordPress Plugin Part 4Writing Your First WordPress Plugin Part 6 →
  • 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 5 of Writing Your First WordPress Plugin, I’m going to take you through the process of adding an admin options page to your first WordPress plugin. This options page will allow your user to configure the settings for the plugin very easily. In this case, we’re going to use it to allow the user to enter their Twitter url, which is displayed at the bottom of each post. The options page will allow more than that, but we will start simple.

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

The end result of these two functions should look like this:

Do NOT forget to include your new “admin-page.php” file into the main plugin file, just as we have the others.

In the next part of this series, we’re going to get a little more advanced and I’m going to show you how to create the option fields themselves. Once that is done, we’ll be able to add a lot more flexibility to our plugin.

Download WIP Plugin
Tweet Follow @pippinsplugins
add_options_page, admin_menu, register_setting

20 comments on “Writing Your First WordPress Plugin Part 5”

  1. mohalam says:
    November 10, 2011 at 6:34 pm

    Thank you for continuing this series. I was waiting for it.

    Reply
    • Pippin says:
      November 10, 2011 at 9:45 pm

      You’re welcome! Part 6 is scheduled for tomorrow :)

  2. feedmymedia says:
    April 3, 2012 at 4:39 am

    Not sure I understand the purpose of the output buffer. Removing ob_start() and echo ob_get_clean() returns the same result on the admin page. What are the advantages of using this function?

    Thanks for this useful series.

    Reply
    • Pippin says:
      April 3, 2012 at 9:43 am

      The advantage is when you need to return the entire content of the page (or store it in a variable), rather than just echo it.

  3. kub says:
    July 21, 2012 at 1:07 pm

    hi, why you don’t use ?> end of all php files?

    Reply
    • Pippin says:
      July 21, 2012 at 5:18 pm

      Because it is not needed. Since it’s not needed, there’s really no reason to include it.

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

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

    Reply
    • Pippin says:
      December 26, 2012 at 10:31 pm

      Please elaborate on the plugin you want to make.

    • Taleeb Ahmad says:
      December 27, 2012 at 8:31 am

      I want this…………..

      When a user signs up for a volunteer opportunity,the following happens:
      1. An email is sent to the volunteer with thanks.
      2. Th email address is checked against user list.If there is no user with that email address,a new user is created.
      3. The user is subscribed to receive updates on the project with a new comment is posted.

    • Pippin says:
      December 30, 2012 at 11:13 pm

      Are you looking for suggestions on how to write the plugin, or for me to do it for you?

  5. Jun Pratama says:
    January 9, 2013 at 2:41 pm

    Hi Pippin, I really enjoy your great tutorial. I have a question which is do we always have to use “ob_start();” for this method ? Since I think without “ob_start();” the code will work also.

    Reply
    • Pippin says:
      January 9, 2013 at 5:26 pm

      No, it is not required (except for some scenarios).

  6. Ilya Libin says:
    February 13, 2013 at 4:02 pm

    admin_menu
    Hi! Thank you very much for your tutorial!
    Can you please explain how can i display plugins settings in “Edit Post” window. Like it done in SEO Ultimate plugin
    It is like a widget in “Edit Post” window.

    Reply
    • Pippin says:
      February 13, 2013 at 7:35 pm

      That is a whole series of tutorials in and of itself. Take a look at this project: https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress It provides a pretty simple way to add meta boxes.

  7. Peter says:
    March 27, 2013 at 6:02 am

    Hi Pippin,
    I have been working through lesson 5 and get the following error:

    The plugin generated 407 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.

    This is my code:

    My first WordPress options
    why not working????

    <php
    echo ob_get_clean();
    }

    function mfwp_add_options_link(){
    add_options_page('My first WordPress function', 'My first plugin', 'manage_options', 'mfwp-options', 'mfwp_options_page');

    }
    add_action('admin_menu', 'mfwp_add_options_link');

    I have included it in the Index file. No other plugins are active.

    Any ideas?

    Thanks

    Reply
    • Peter says:
      March 27, 2013 at 6:32 am

      As it turns out the HTML worked in the comment so I have re-added with some full stops so you can see the full code.

      My first WordPress options
      why not working????

      <php
      echo ob_get_clean();
      }

      function mfwp_add_options_link(){
      add_options_page('My first WordPress function', 'Peters plugin', 'manage_options', 'mfwp-options', 'admin-page.php');

      }
      add_action('admin_menu', 'mfwp_add_options_link');

  8. Pippin says:
    March 28, 2013 at 10:47 pm

    That’s not the complete code. Can you paste the entire plugin into snippi.com and share the link?

    Reply
  9. Foxtracker says:
    March 29, 2013 at 1:26 am

    Hi pippin, link is:

    http://snippi.com/s/94tw3d0✖

    Cheers

    Reply
  10. Peter McInerney says:
    March 29, 2013 at 1:43 am

    Hello All, I have worked out the issue and it was so minor I can not believe I missed it.

    The problem was I had <php, NOT <?php.

    This seems to have caused the code to become output instead of identifing up coming code.

    It now works… :)

    Thanks

    Reply
    • Pippin says:
      March 29, 2013 at 9:24 am

      Great!

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

  • How I Built the Settings System for Easy Digital Downloads
  • Using Ajax in Your Plugin and WordPress Admin
  • Drag and Drop Order for Plugin Options
  • Add Menu Links to the New WordPress 3.3 Tool Bar
  • Writing Your First WordPress Plugin Part 6

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

  • RT @toscho: #WordPress: How post meta fields work. http://t.co/uDRaDu0EsS
    May 25, 2013
  • RT @strickland: Afternoon crowd: To celebrate Memorial Day weekend @gittyapp is on sale through Monday. Now is the time to join in! http:/…
    May 25, 2013
  • .@itsananderson wins!
    May 25, 2013

Topics

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