30
SO YOU WANT TO BUILD AND RELEASE A PLUGIN… Ryan Duff WordCamp Raleigh 2015

WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

Embed Size (px)

Citation preview

Page 1: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

SO YOU WANT TO BUILD AND RELEASE

A PLUGIN…

Ryan DuffWordCamp Raleigh 2015

Page 2: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

ABOUT ME• Started using and developing for WordPress in 2004

• Plugin Developer • Meetup Organizer

Page 3: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

A BIT OF PLUGIN HISTORY

Page 4: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

my-hacks.php

https://wordpress.org/news/2003/12/new-feature-my-hacksphp/

Page 5: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

VERSION 1.2(May 22, 2004)

Page 6: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

Plugin API

Page 7: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

THINGS TO CONSIDER

Page 8: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

YOUR CODE

Page 9: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

FILTERS

Page 10: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

apply_filters( $tag, $value, $var ... )

http://codex.wordpress.org/Function_Reference/apply_filters

Page 11: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

EXAMPLE$query_args = array(

'post_type' => 'books',‘posts_per_page' => 5,'author' => 3,

);

$books = new WP_Query( apply_filters('wcraleigh_books_query',$query_args

) );

Page 12: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

EXAMPLEadd_filter( 'wcraleigh_books_query',

'wcraleigh_modify_book_query'10,1

);

function wcraleigh_modify_book_query( $query_args ) {

$query_args['posts_per_page'] = 20;

return $query_args;

}

Page 13: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

ACTIONS

Page 14: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

do_action( $tag, $arg_a, $arg_b, $etc );

http://codex.wordpress.org/Function_Reference/do_action

Page 15: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

EXAMPLEdo_action( 'wcraleigh_books_before' );echo '<div class="wcraleigh_books">';

while( $books->have_posts() ) : $books->the_post()

echo '<div class="wcraleigh_book">';

do_action( 'wcraleigh_before_book_title', get_the_ID() );

echo '<h3 class="wcraleigh_book_title">' . get_the_title() . '</h3>';

do_action( 'wcraleigh_after_book_title', get_the_ID() );

echo '</div>';

endwhile;

echo '</div>';do_action( 'wcraleigh_books_after' );

Page 16: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

INTERNATIONALIZATION

Page 17: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

EXAMPLE

https://codex.wordpress.org/I18n_for_WordPress_Developers

/* * Plugin Name: i18n Test * Author: Ryan Duff * Text Domain: wcraleigh-demo-plugin */

$text = __( ‘This is a test', ‘wcraleigh-demo-plugin’ );

_e( ‘This test will echo', ‘wcraleigh-demo-plugin’ );

Page 18: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

PLUGIN SETTINGShttp://themeoptions.wordpress.com/

Page 19: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

Security

Page 20: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

Security• Nonce• Sanitization• Validation• Database Queries

https://vip.wordpress.com/documentation/best-practices/security/validating-sanitizing-escaping/ http://codex.wordpress.org/Data_Validation

Page 21: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

Custom Database Tables

https://pippinsplugins.com/custom-database-api-reasons-for-custom-tables-and-an-api/

Page 22: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

Clean Up

Page 23: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

Caching

Page 24: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

OTHER CONSIDERATIONS

• Code style• Documentation• Errors

Page 25: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

PLUGIN LICENSE

Page 26: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

COMMON LICENSES

• GPL v2/v3• MIT (X11)• Apache License v2• WTFPL v2

1) http://wordpress.org/plugins/about/ 2) http://www.gnu.org/licenses/license-list.html#GPLCompatibleLicenses

Page 27: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

PLUGIN HOSTING

Page 28: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

• WordPress.org • GitHub • Both?

Page 29: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

QUESTIONS?

Page 30: WordCamp Raleigh 2015 - So You Want to Build and Release a Plugin

RYAN DUFF

[email protected]

@RYANCDUFF