SlideShare una empresa de Scribd logo
1 de 35
PLUGIN DEVELOPMENT
#wpmeetup010
BARRY KOOIJ
Twitter : @cageNL
Lead Developer WordPress @ INDICIA
Freelance @ Cageworks
Plugin developer
What The File
Sub Posts
Contributor EDD & extensies
Core contributor
Moderator WPNL forum
PLUGIN DEVELOPMENT
MIJN SETUP
Device
IDE
Versiebeheer

MacBook Air
PhpStorm
GIT, GitHub / private server
Commandline
ALTERNATIEVEN
IDE
GIT
SVN

NuSphere PhpED
Bitbucket, GitLab
Tower
Versions / Tortoise
DEBUGGIN
G
define( 'WP_DEBUG', true );
if ( WP_DEBUG ) {
define( 'SCRIPT_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', true );
@ini_set( 'display_errors', 0 );
}
display_errors = On;
error_reporting = E_ALL | E_STRICT;
CODE TEMPLATES
https://gist.github.com/barrykooij/7632945
WORDPRESS CORE
Open source, maak hier gebruik van!
API’s, API’S, API’s
Filters & Hooks
API’S
Dashboard Widgets API
Database API
HTTP API
File Header API
Filesystem API
Metadata API
Options API
Plugin API
Quicktags API

Rewrite API
Settings API
Shortcode API
Theme Modification API
Theme Customization API
Transients API
Widgets API
XML-RPC WordPress API
FILTERS & HOOKS
add_action( ‘hook_name’, ‘my_function’ );
do_action( ‘hook_name’ );
JS “HOOKS” (EVENTS)
$('body').bind(’event’, function(event,
the_value) {
});

$('body').trigger(’event', [ value ]);
BACKWARDS COMPATABILITY
Deprecate code
Pas later geen unit tests aan, maar voeg unit
tests toe
CODE STANDARDS
http://codex.wordpress.org/WordPress_Coding_Standards
NAMING CONVENTIONS
function some_name( $some_variable ) { [...] }
class Walker_Category extends Walker { [...] }
class WP_HTTP { [...] }
my-plugin-name.php
class-my-class.php
DATABASES
Gebruik altijd de API!
$wpdb->prepare
$wpdb->prepare( "SELECT * FROM {$wpdb>posts}" WHERE `ID` = %d", $special_id );
YODA CONDITIONS
if ( true == $the_force ) {
$victorious = you_will( $be );
}
A little bizarre, it is, to read. Get used to it, you will.
UNIT TESTING
PHPUnit
/**
* @ticket 22212
*/
function test_get_multiple_roles_by_user_query() {
$this->factory->user->create_many( 2, array( 'role' => 'subscriber’ ) );
$this->factory->user->create_many( 3, array( 'role' => 'editor’ ) );
$wp_user_search = new WP_User_Query( array( 'role' => array( 'subscriber’,
'editor' ) ) );
$users = $wp_user_search->get_results();
$this->assertEquals( 5, count( $users ) );
}
CHANGELOG
Hou bij wat je wanneer veranderd hebt
SUPPORT
Als je iets bouwt, support het dan
Geef op je website je support tijden aan
Support systemen
WORDPRESS.ORG REPO
Header afbeelding
Duidelijk omschrijving
Downloads i.c.m. rating
Vraag om ratings!
CONDITIONAL LOADING OF CODE
Laad code enkel waar nodig
is_admin()
DOCUMENTATION
Schrijf je code doc direct
Betere IDE suggesties
CODE
OBJECTGEORIËNTEERD
OOP
Singleton pattern
class My_Plugin {
private static $instance = null;
public static function get() {
if( null == self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}

private function __construct() {
}
}
function My_Plugin() {
return My_Plugin::get();
}
add_action( 'plugins_loaded', function() {My_Plugin::get(); });
PLUGIN DIR & FILE
if ( ! defined( ’X_PLUGIN_DIR' ) ) {
define( 'X_PLUGIN_DIR’, plugin_dir_path( __FILE__ ) );
}
if ( ! defined( ’X_PLUGIN_FILE' ) ) {
define( ’X_PLUGIN_FILE', __FILE__ );
}
PREFIXES
WordPress : PHP version 5.2.4 or greater
Namespaces : 5.3.0 or greater
Tot die tijd, prefixen.

class SP_Post_Link_Manager { [...] }
SANITIZE & ESCAPE
sanitize_title
is_email
http://codex.wordpress.org/Data_Validation#In
put_Validation
esc_url
esc_html
CAPABILITIES
if ( ! current_user_can( SP_Cap_Manager::get_capability(
$_GET['sp_post_link'] ) ) ) {
return;
}
NONCES
Number used ONCE
wp_nonce_field( plugin_basename( __FILE__ ),
'sp_sortable_nonce' );

if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce(
$_POST['nonce'], plugin_basename( __FILE__ ) ) ) {
return;
}
DIRECT ACCESS
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if
accessed directly
I18N
load_plugin_textdomain( 'sub-posts', false,
dirname( plugin_basename( __FILE__ ) ) .
'/languages/' );

_e( ‘my-string’, ‘sub-posts’ );
Q&
A
Twitter @cageNL
WordPress & Github: barrykooij
7 januari meetup in Tilburg

Más contenido relacionado

La actualidad más candente

Build website in_django
Build website in_django Build website in_django
Build website in_django
swee meng ng
 

La actualidad más candente (20)

WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015
 
WordPress Plugin Basics
WordPress Plugin BasicsWordPress Plugin Basics
WordPress Plugin Basics
 
Python Flask app deployed to OPenShift using Wercker CI
Python Flask app deployed to OPenShift using Wercker CIPython Flask app deployed to OPenShift using Wercker CI
Python Flask app deployed to OPenShift using Wercker CI
 
Code ceptioninstallation
Code ceptioninstallationCode ceptioninstallation
Code ceptioninstallation
 
Django cms best practices
Django cms best practicesDjango cms best practices
Django cms best practices
 
워드프레스 플러그인 개발 입문
워드프레스 플러그인 개발 입문워드프레스 플러그인 개발 입문
워드프레스 플러그인 개발 입문
 
What The Flask? and how to use it with some Google APIs
What The Flask? and how to use it with some Google APIsWhat The Flask? and how to use it with some Google APIs
What The Flask? and how to use it with some Google APIs
 
Ane for 9ria_cn
Ane for 9ria_cnAne for 9ria_cn
Ane for 9ria_cn
 
Eclipse Overview
Eclipse Overview Eclipse Overview
Eclipse Overview
 
The Future Of WordPress Presentation
The Future Of WordPress PresentationThe Future Of WordPress Presentation
The Future Of WordPress Presentation
 
JavaScript, React Native and Performance at react-europe 2016
JavaScript, React Native and Performance at react-europe 2016JavaScript, React Native and Performance at react-europe 2016
JavaScript, React Native and Performance at react-europe 2016
 
Webinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST APIWebinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST API
 
A Simple Plugin Architecture for Wicket
A Simple Plugin Architecture for WicketA Simple Plugin Architecture for Wicket
A Simple Plugin Architecture for Wicket
 
Introduction to VueJS & The WordPress REST API
Introduction to VueJS & The WordPress REST APIIntroduction to VueJS & The WordPress REST API
Introduction to VueJS & The WordPress REST API
 
Plugin Development Practices
Plugin Development PracticesPlugin Development Practices
Plugin Development Practices
 
First steps with django cms
First steps with django cmsFirst steps with django cms
First steps with django cms
 
WordPress Bootcamp Part 2 - Extending WordPress
WordPress Bootcamp Part 2 - Extending WordPressWordPress Bootcamp Part 2 - Extending WordPress
WordPress Bootcamp Part 2 - Extending WordPress
 
Behaviour Driven Development con Behat & Drupal
Behaviour Driven Development con Behat & DrupalBehaviour Driven Development con Behat & Drupal
Behaviour Driven Development con Behat & Drupal
 
WPtech: L'API Customizer pour les plugins
WPtech: L'API Customizer pour les pluginsWPtech: L'API Customizer pour les plugins
WPtech: L'API Customizer pour les plugins
 
Build website in_django
Build website in_django Build website in_django
Build website in_django
 

Destacado (6)

Unit testing @ WordPress Meetup Tilburg 7 januari 2014
Unit testing @ WordPress Meetup Tilburg 7 januari 2014Unit testing @ WordPress Meetup Tilburg 7 januari 2014
Unit testing @ WordPress Meetup Tilburg 7 januari 2014
 
Cmat 101 final project
Cmat 101 final projectCmat 101 final project
Cmat 101 final project
 
CMAT 101 Clubs
CMAT 101 ClubsCMAT 101 Clubs
CMAT 101 Clubs
 
Logosweldproducts
LogosweldproductsLogosweldproducts
Logosweldproducts
 
Related Content
Related ContentRelated Content
Related Content
 
Cmat 101 final project
Cmat 101 final projectCmat 101 final project
Cmat 101 final project
 

Similar a Plugin development wpmeetup010

Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress plugin
Anthony Montalbano
 
Frameworks da nova Era PHP FuelPHP
Frameworks da nova Era PHP FuelPHPFrameworks da nova Era PHP FuelPHP
Frameworks da nova Era PHP FuelPHP
Dan Jesus
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable Applications
Alessandro Molina
 
iOS App with Parse.com as RESTful Backend
iOS App with Parse.com as RESTful BackendiOS App with Parse.com as RESTful Backend
iOS App with Parse.com as RESTful Backend
Stefano Zanetti
 
Avinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPressAvinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPress
wpnepal
 

Similar a Plugin development wpmeetup010 (20)

[Bristol WordPress] Supercharging WordPress Development
[Bristol WordPress] Supercharging WordPress Development[Bristol WordPress] Supercharging WordPress Development
[Bristol WordPress] Supercharging WordPress Development
 
Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress plugin
 
Modular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJSModular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJS
 
Frameworks da nova Era PHP FuelPHP
Frameworks da nova Era PHP FuelPHPFrameworks da nova Era PHP FuelPHP
Frameworks da nova Era PHP FuelPHP
 
Plugin Development @ WordCamp Norway 2014
Plugin Development @ WordCamp Norway 2014Plugin Development @ WordCamp Norway 2014
Plugin Development @ WordCamp Norway 2014
 
Как получить чёрный пояс по WordPress?
Как получить чёрный пояс по WordPress?Как получить чёрный пояс по WordPress?
Как получить чёрный пояс по WordPress?
 
Webinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST APIWebinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST API
 
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
 
Codegnitorppt
CodegnitorpptCodegnitorppt
Codegnitorppt
 
Plugin Development - WP Meetup Antwerp
Plugin Development - WP Meetup AntwerpPlugin Development - WP Meetup Antwerp
Plugin Development - WP Meetup Antwerp
 
Gwt.create
Gwt.createGwt.create
Gwt.create
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application Framework
 
Pyramid deployment
Pyramid deploymentPyramid deployment
Pyramid deployment
 
Extend sdk
Extend sdkExtend sdk
Extend sdk
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable Applications
 
iOS App with Parse.com as RESTful Backend
iOS App with Parse.com as RESTful BackendiOS App with Parse.com as RESTful Backend
iOS App with Parse.com as RESTful Backend
 
WordPress Plugin development
WordPress Plugin developmentWordPress Plugin development
WordPress Plugin development
 
Becoming a better WordPress Developer
Becoming a better WordPress DeveloperBecoming a better WordPress Developer
Becoming a better WordPress Developer
 
IndexedDB and Push Notifications in Progressive Web Apps
IndexedDB and Push Notifications in Progressive Web AppsIndexedDB and Push Notifications in Progressive Web Apps
IndexedDB and Push Notifications in Progressive Web Apps
 
Avinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPressAvinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPress
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Plugin development wpmeetup010

Notas del editor

  1. Naastdocumentatiekan je dusook in je eigen IDE vaakdoorklikkennaar de bron