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'm not sure if this is the right place to ask for this kind of help since is not an actual question but hopefully I can learn a thing or two.

I'm developing a plugin (my first one) inspired in the Infinite Scroll Plugin, but instead of showing older posts when scrolling down, I'm showing them when you click a "Show more" link.

My intention is to make it public but I know there are a lot of things on it that I can improve before doing so, I tested it a bit in a couple themes and it worked fine but I'm not sure how it'll behave in the real world. Here's a link to it on github: https://github.com/javiervd/Click-and-Load-Pagination

Some concerns at the top of my head are: - How to handle users including and external jQuery library instead of the WP one? I'm currently queuing WP's jQuery but I'm not sure how good is this. - Simplicity? As I said this plugin is based on the Infinite Scroll Plugin so I used a similar but much simpler approach to set the options, hopefully this can be optimized as well. - Best practices? This is my first "real" plugin I'm sure I'm not following the best practices out there :(

I hope some of you guys can help me, I'll make sure to mention everyone who does when I release it, feel free to fork/request pulls if you wish.

Thanks in advance!

share|improve this question
    
While asking for code review is fine (although not that popular) I think you might get much better feedback by asking about some of your "concerns" as separate and more specific questions. –  Rarst Jun 22 '11 at 21:05
    
I think you're right, I was hoping though that someone would point out stuff that I might have overlooked which I know I have :( –  javiervd Jun 23 '11 at 4:36
add comment

1 Answer

up vote 4 down vote accepted

Ok, here are some pointers:

  • never run any meaningful code right from plugin body (especially don't start queuing jQuery everywhere like you do - that's asking for trouble), always do it at appropriate hooks;

  • learn how to use $default argument in get_option() will save you a lot of typing there;

  • learn how to use plugins_url() for reliable URL building to files;

  • learn submit_button(), not critical but nifty;

  • consider storing options in single array;

  • if you use options you should implement uninstall to delete them.

share|improve this answer
    
Thanks a lot Rarst, I'll start refactoring some code didn't know about the $default argument in get_option() –  javiervd Jun 23 '11 at 14:56
    
I'm being a newb here but what do you mean by "never run any meaningful code right from plugin body" ? –  javiervd Jun 24 '11 at 3:50
    
@javiervd most of the time you should not do anything right in plugin file, hook to init (or whatever appropriate, depending on what you are doing) and do things in hooked function. –  Rarst Jun 24 '11 at 7:44
add comment

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.