I’ve previously written a few posts about using WordPress Actions and Filters to better extend your plugins and/or themes. This time though, I want to talk about leading by example, and using your own hooks and filters to add functionality. What does this mean? It means where a hook or filter exists, you should use it to add your built in functionality. It’s probably easiest to explain by example…so here is a recent issue I ran into. I wanted the ability to create an arbitrary number of ‘tab’ sections in a plugin settings page I was building. Something like this:

Screen Shot 2014-08-15 at 3.16.04 PM

Now, hard coding a list of tabs is easy, but what if I didn’t want to always show the tabs, just the ones that were active? Well, I could simply make the action of outputting the tabs, an filter that get’s looped on. Like this:

[php light=true]
function ck_generate_tabs() {
$tabs = apply_filters( ‘ck_metabox_tabs’, array() );
foreach ( $tabs as $key => $values ) {
?>

  • Posted by Chris Klosowski

    Chris Klosowski is the Director of Technology at Sandhills Development, LLC, creators of fine WordPress plugins, and ecommerce solutions.

    26 Comments

    1. Thank you for the article Chris!

      Reply

    2. My brother suggested I may like this web site.

      He was once entirely right. This post actually made my day.

      You cann’t imagine just how a lot time I had spent for this information! Thank you!

      Reply

    3. viagra ustralia how to get viagra – best price viagra no presription

      Reply

    4. buy generic viagra in usa viagra vanessa hudgens oline ViagraCND100Mg – viagra online store review

      Reply

    5. cheap viagra in us online viagra trusted ViagraCND100Mg – viagra gel uk

      Reply

    6. buy doxycycline 100mg doxycycline for sale – online doxycycline

      Reply

    7. can i buy amoxicillin over the counter in australia amoxicillin generic brand – amoxicillin buy canada

      Reply

    8. amoxicillin 500 tablet generic amoxil – amoxicillin in india

      Reply

    9. ivermectin 80 mg ivermectin for sale humans – purchase stromectol online

      Reply

    10. ivermectin generic name best price on ivermectin pills – ivermectin cream

      Reply

    11. stromectol for humans stromectol tablets – ivermectin 1 topical cream

      Reply

    12. where to buy stromectol buy stromectol online – ivermectin buy

      Reply

    13. pet antibiotics without vet prescription prescription drugs online without – ed treatments

      Reply

    14. 100mg viagra without a doctor prescription prescription drugs without prior prescription – ed tablets

      Reply

    15. ed doctor prescription drugs online without – medications for

      Reply

    16. how to cure ed buy prescription drugs without doctor – ed tablets

      Reply

    17. ed treatment drugs prescription drugs online without doctor – best ed treatment

      Reply

    18. plaquenil 200mg price in india plaquenil price – plaquenil 250

      Reply

    19. lexapro 10mg lexapro – п»їlexapro

      Reply

    20. lipitor price coupon for lipitor – lipitor 10mg generic

      Reply

    21. purchase ivermectin stromectol – ivermectin 2mg

      Reply

    22. buy cheap lexapro online lexaprognr – generic lexapro australia

      Reply

    23. 100mg viagra viagra pills – viagra price

      Reply

    24. online meds for ed ed medication online – ed meds pills drugs

      Reply

    25. erection pills viagra online buy cheap prescription drugs online – ed doctor

      Reply

    Leave a reply

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.