Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Extensible WordPress Plugins

Extensible WordPress Plugins

Some hints and tips about how to make your plugins and themes more extensible to other developers so they can build on them or modify them safely.

Mark Wilkinson

October 15, 2014
Tweet

More Decks by Mark Wilkinson

Other Decks in Technology

Transcript

  1. markwilkinson.me | @wpmark this talk will cover what is extensibility?

    why should you be making extensible plugins? how to make your plugin extensible? examples of good practice
  2. markwilkinson.me | @wpmark this talk will cover what is extensibility?

    why should you be making extensible plugins? how to make your plugin extensible? examples of good practice
  3. markwilkinson.me | @wpmark this talk will cover what is extensibility?

    why should you be making extensible plugins? how to make your plugin extensible? examples of good practice
  4. markwilkinson.me | @wpmark this talk will cover what is extensibility?

    why should you be making extensible plugins? how to make your plugin extensible? examples of good practice
  5. markwilkinson.me | @wpmark “one that can be modified or extended

    without changing the plugin code itself ”
  6. markwilkinson.me | @wpmark $q = new WP_Query( $q_args ); while(

    $q->have_posts() ) : $->the_post(); ?> <!-- // post output here --> <?php endwhile;
  7. markwilkinson.me | @wpmark $q = new WP_Query( $q_args ); while(

    $q->have_posts() ) : $->the_post(); do_action( ‘wpmark_before_post’, get_the_ID() ); ?> <!-- // post output here --> <?php endwhile;
  8. markwilkinson.me | @wpmark $q = new WP_Query( $q_args ); while(

    $q->have_posts() ) : $->the_post(); do_action( ‘wpmark_before_post’, get_the_ID() ); ?> <!-- // post output here --> <?php do_action( ‘wpmark_after_post’, get_the_ID() ); endwhile;
  9. markwilkinson.me | @wpmark function wpmark_add_before_post( $post_id ) { $meta =

    get_post_meta( $post_id, ‘key’, true ); /* do something with $meta */ } add_action( ‘wpmark_before_post’, ‘wpmark_add_before_post’, 10, 1 );
  10. markwilkinson.me | @wpmark function wpmark_edit_q_args( $args ) { $args[ ‘year’

    ] = ‘2014’; return $args; } add_filter( ‘wpmark_q_args’, ‘wpmark_edit_q_args’ 10, 1 );