Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I would like to make a plug-in that adds a widget. I would like it to be based on the current pages widget but add the ability to select either include OR exclude by drop down or checkbox then list pages by ID.

Following this guide I was able to change the exclude to include by hacking the core file located in wp-includes/default_widgets.php.

Here is the original code:

http://pastebin.com/Rg2vTMmK

How do I make the changes and turn it into a plugin?

Many Thanks

share|improve this question

2 Answers 2

Widgets are class based, so it is quite easy to extend them.

  1. Create your class by extending WP_Widget_Pages (just like it extends baseline Widget).

  2. Copy method(s) you want to modify into your class and make changes in there. You would probably want to extend and modify name and such so it is not confused/conflicted with native widget.

  3. Register your class using register_widget().

share|improve this answer
    
That is a great start, I googled "extends WP_Widget_Pages" and only found gist.github.com/967910 which is a start, but its not a plugin....Then I found this guide Not sure how to do it.... –  Anthony Oct 19 '11 at 12:32

Found a solution here: http://wordpress.org/extend/plugins/widgets-reloaded/

share|improve this answer
    
I would recommend that one, but you worded your question as plugin development issue, not plugin recommendation. Please mention that existing plugin would be viable answer if so when asking. –  Rarst Oct 20 '11 at 10:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.