Plugging into plugins

1,570 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,570
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Plugging into plugins

  1. 1. Plugging into Plugins Josh Harrison @joshh
  2. 2. About MeI work for 10up working on awesomeWordPress projectsI have a wife and 3 kids.I live in St. George UT.I just finished my backyard after working on itfor 4 months.
  3. 3. WordPress Plugins What comes to mind?
  4. 4. "Here is something I created. Maybesomebody else will find it useful."
  5. 5. Plugins are FrameworksNot Blueprints
  6. 6. It’s not about coreplugins, it’s aboutplugin developers making better plugins.
  7. 7. Make your pluginsextensible and be nice to other developers
  8. 8. Use the WordPress Core API.
  9. 9. WordPress Core APIs● Database API● HTTP API● Shortcode API● Transients API● Shortcode APIAnd many more....
  10. 10. Create your own actions and filters.
  11. 11. do_actionif ( $valid_request ) { if ( $status == approve ) { // dev can remove or add to do_action( new_user_approve_approve_user ); } else if ( $status == deny ) { do_action( new_user_approve_deny_user ); }}
  12. 12. apply_filters$welcome = sprintf( __( Welcome to %s. Thissite is accessible to approved users only.To be approved, you must first register.,new_user_approve ), get_option( blogname) );$welcome = apply_filters(new_user_approve_welcome_message, $welcome);
  13. 13. Allow theme developers to override plugin templates.
  14. 14. // Include template - can be overriden by a theme!$template_name = wp-core-contributions-widget-template.php;$path = locate_template( $template_name );if ( empty( $path ) ) { $path = WP_CORE_CONTRIBUTIONS_WIDGET_DIR . inc/ .$template_name;}
  15. 15. Create template functions.
  16. 16. /** * Display the permalink for the current post. * * @since 1.2.0 * @uses apply_filters() Calls the_permalink filter onthe permalink string. */function the_permalink() { echo apply_filters(the_permalink, get_permalink());}
  17. 17. Create utility methods.
  18. 18. /** * Creates a redirect post, this function will be usefulfor import/exports scripts * @param string $redirect_from * @param string $redirect_to * @param int $status_code * @since 1.3 * @uses wp_insert_post, update_post_meta * @return int */public function create_redirect( $redirect_from,$redirect_to, $status_code ) { ....}
  19. 19. Decisions not options.Actions and filters are even better.
  20. 20. /** If you hardcode a WP.com API key here, all key configscreens will be hidden */if ( defined(WPCOM_API_KEY) ) $wpcom_api_key = constant(WPCOM_API_KEY);else $wpcom_api_key = ;
  21. 21. Anything else?
  22. 22. Child PluginsPlugin Mashups
  23. 23. CautionYoull have to keep you plugin up to date
  24. 24. DisadvantagesThe wordpress.org repository does not supportplugin dependenciesWhat if a child plugin is installed, should theparent plugin be installed as well?
  25. 25. What can I do now?● Update your plugins● Send an update to plugin authors● Fork it
  26. 26. Resources● Pippin Williamson● Michael Fields● Brandon Dove - The Pluggable Plugin● WordPress Plugins as Frameworks

×