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

Preview:

Citation preview

SO YOU WANT TO BUILD AND RELEASE

A PLUGIN…

Ryan DuffWordCamp Raleigh 2015

ABOUT ME• Started using and developing for WordPress in 2004

• Plugin Developer • Meetup Organizer

A BIT OF PLUGIN HISTORY

my-hacks.php

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

VERSION 1.2(May 22, 2004)

Plugin API

THINGS TO CONSIDER

YOUR CODE

FILTERS

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

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

EXAMPLE$query_args = array(

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

);

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

) );

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;

}

ACTIONS

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

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

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' );

INTERNATIONALIZATION

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’ );

PLUGIN SETTINGShttp://themeoptions.wordpress.com/

Security

Security• Nonce• Sanitization• Validation• Database Queries

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

Custom Database Tables

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

Clean Up

Caching

OTHER CONSIDERATIONS

• Code style• Documentation• Errors

PLUGIN LICENSE

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

PLUGIN HOSTING

• WordPress.org • GitHub • Both?

QUESTIONS?

RYAN DUFF

RYAN@FUSIONIZED.COM

@RYANCDUFF

Recommended