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

Getting Started with WordPress Development

Getting Started with WordPress Development

WordPress is an incredibly powerful platform and framework for development, but until you learn how to use it you won't be able to make full use of its flexibility. In this session you will learn the core principles of WordPress development that will enable you to start taking full advantage of everything that it offers.

This presentation is aimed at experienced PHP developers who have minimal experience with WordPress development. It was presented at the Cape Town PHP Meetup on 23 April 2015: http://www.meetup.com/Cape-Town-PHP-Group/events/221748419/

The full video of the presentation is available here: https://www.youtube.com/watch?v=JbEgsygOxKU

Hugh Lashbrooke

April 23, 2015
Tweet

More Decks by Hugh Lashbrooke

Other Decks in Technology

Transcript

  1. Getting Started With
    WordPress Development

    View Slide

  2. HTML PHP MVC WP

    View Slide

  3. View Slide

  4. View Slide

  5. Folder Structure
    Headers
    Events
    Plugin Development

    View Slide

  6. wp-content/plugins/plugin-slug
    plugin-slug.php
    readme.txt
    Folder Structure

    View Slide

  7. Headers
    /*
    * Plugin Name: Seriously Simple Podcasting
    * Version: 1.9.6
    * Plugin URI: https://wordpress.org/plugins/seriously-simple-podcasting/
    * Description: Podcasting the way it's meant to be.
    * Author: Hugh Lashbrooke
    * Author URI: http://www.hughlashbrooke.com/
    * Requires at least: 4.0
    * Tested up to: 4.2
    *
    * Text Domain: seriously-simple-podcasting
    * Domain Path: /lang/
    */

    View Slide

  8. PHP
    call_user_func()
    WordPress
    do_action()
    apply_filters()
    Events

    View Slide

  9. do_action( ‘hook’ );
    add_action( ‘hook’, ‘my_function’ );
    Events: Hooks

    View Slide

  10. add_action( ‘init’, ‘init_function’ );
    function init_function() {
    ...
    }
    Events: Hooks

    View Slide

  11. add_action( ‘hook’, ‘my_function’, 10 );
    Lower number == higher priority
    Events: Priorities

    View Slide

  12. add_action( ‘hook’, ‘my_function’, 10, 2 );
    function my_function ( $foo, $bar ) {
    ...
    }
    Events: Parameters

    View Slide

  13. apply_filters( ‘filter’, $foo );
    add_filter( ‘filter’, ‘my_function’ );
    Filters must always return a value
    Events: Filters

    View Slide

  14. add_filter( ‘body_class’, ‘my_function’ );
    function my_function( $classes ) {
    $classes[] = ‘my-class’;
    return $classes;
    }
    Events: Filters

    View Slide

  15. remove_action( ‘hook’, ‘function’ );
    remove_filter( ‘filter’, ‘function’ );
    Priorities must match original hook/filter
    Removing Hooks & Filters

    View Slide

  16. /*
    * Plugin Name: Google Redirect
    * Version: 1.0
    */
    add_action( ‘init’, ‘google_redirect’ );
    function google_redirect () {
    if( isset( $_GET[‘google_redirect’] ) ) {
    wp_redirect( ‘http://www.google.com’, 302 );
    exit;
    }
    }
    ?>
    Bringing it Together

    View Slide

  17. Plugin Developer Info: wordpress.org/plugins/about/
    Coding Standards: codex.wordpress.org/WordPress_Coding_Standards
    Action Reference: codex.wordpress.org/Plugin_API/Action_Reference
    Plugin Template: github.com/hlashbrooke/WordPress-Plugin-Template
    Helpful Links

    View Slide

  18. wpcapetown.co.za
    woothemes.com
    hughlashbrooke.com
    @hlashbrooke

    View Slide