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

The Fundamentals of Creating Sound Plugins

The Fundamentals of Creating Sound Plugins

Thanks to WordPress core making plugins to add functionality is not that difficult. However for each plugin you make, there are some sound principles you should follow in order to make your plugin the best it can be.

This talk will teach you some of the principles to follow when making your plugins, which will make it easier for you to develop and upgrade your plugin, as well as allowing other developers to make changes in a safer way and keep things secure. Ideal for beginners and intermediate developers in plugin development.

Mark Wilkinson

October 28, 2017
Tweet

More Decks by Mark Wilkinson

Other Decks in Technology

Transcript

  1. https://highrise.digital @wpmark <input type="text" name="title" value="" /> $title = sanitize_text_field(

    $_POST['title'] ); update_post_meta( $post_id, 'title', $title ); $title = get_post_meta( $post_id, 'title', true ); echo esc_html( $title );
  2. https://highrise.digital @wpmark Efficient Queries posts_per_page = -1 posts_per_page = 100

    meta_query = array( … ) tax_query = array( … ) https://10up.github.io/Engineering-Best-Practices/php/
  3. https://highrise.digital @wpmark uninstall.php Runs when a user deletes the plugin

    Clean up options, removing DB tables https://developer.wordpress.org/plugins/the-basics/uninstall-methods/
  4. https://highrise.digital @wpmark Template Overrides if ( file_exists( STYLESHEETPATH . '/file.php'

    ) { // load template from theme. } else { // load template from plugin. }