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

WordCamp Sydney: Contributing to WordPress Core

Peter Wilson
September 24, 2016

WordCamp Sydney: Contributing to WordPress Core

Almost everyone will have heard the phrase “don’t hack WordPress core” before, what’s less known is that it’s only the start of the saying. Don’t hack WordPress core, without contributing the hacks back.

Contributing to WordPress core is like riding a bike, it takes a little effort to get started but once you learn it’s a skill you’ll never forget.

You will be given a jump start on contributing, from how to use the bug tracker all the way to contributing a patch and getting your first props.

Peter Wilson

September 24, 2016
Tweet

More Decks by Peter Wilson

Other Decks in Technology

Transcript

  1. Dr. Mirko Junge / Wikimedia Commons (CC)

    View full-size slide

  2. Public domain

    View full-size slide

  3. Brooklyn Museum / Wikimedia Commons

    View full-size slide

  4. Brooklyn Museum / Wikimedia Commons

    View full-size slide

  5. Christophe Finot / Wikimedia Commons (CC)

    View full-size slide

  6. Contributing to WordPress Core
    Peter Wilson • peterwilson.cc • @pwcc

    View full-size slide

  7. Contributing to WordPress
    Peter Wilson • peterwilson.cc • @pwcc

    View full-size slide

  8. Contributing to WordPress Core
    Peter Wilson • peterwilson.cc • @pwcc

    View full-size slide

  9. } else {
    $classes[] = 'page-template-default';
    Index: /trunk/wp-includes/post-template.php
    =================================================================
    --- /trunk/wp-includes/post-template.php (revision 18411)
    +++ /trunk/wp-includes/post-template.php (revision 18412)
    @@ -490,4 +490,6 @@
    $classes[] = 'page-template';
    $classes[] = 'page-template-' . sanitize_html_class( str_repla
    + } else {
    + $classes[] = 'page-template-default';
    }
    } elseif ( is_search() ) {

    View full-size slide

  10. Sites using WordPress
    Jan 2011 onward (%)
    5.0%
    10.0%
    15.0%
    20.0%
    25.0%
    30.0%
    1 Jan 2011 1 Jan 2012 1 Jan 2013 1 Jan 2014 1 Jan 2015 1 Jan 2016 30 Jul 2016
    w3techs.com, July 2016

    View full-size slide

  11. wordpress.org/about/philosophy/

    View full-size slide

  12. WordPress Core Trac
    core.trac.wordpress.org

    View full-size slide

  13. core.trac.wordpress.org

    View full-size slide

  14. core.trac.wordpress.org/browser

    View full-size slide

  15. make.wordpress.org/core/reports/

    View full-size slide

  16. core.trac.wordpress.org/my-comments

    View full-size slide

  17. core.trac.wordpress.org/tickets/major

    View full-size slide

  18. Sites using WordPress
    5.0%
    10.0%
    15.0%
    20.0%
    25.0%
    30.0%
    1 Jan 2011 1 Jan 2012 1 Jan 2013 1 Jan 2014 1 Jan 2015 1 Jan 2016 30 Jul 2016
    Boring

    View full-size slide

  19. Checkout WordPress Core
    A version control love story.

    View full-size slide

  20. Checkout WordPress via SVN
    wordpress-develop
    https://develop.svn.wordpress.org/trunk/ ↩
    svn checkout ↩

    View full-size slide

  21. Checkout WordPress Core
    A version control love story.

    View full-size slide

  22. Clone WordPress via Git
    wordpress-develop
    git://develop.git.wordpress.org ↩
    git clone ↩

    View full-size slide

  23. Contribute with
    SVN or Git

    View full-size slide

  24. Public domain

    View full-size slide

  25. Public domain

    View full-size slide

  26. Contributing within
    five minutes

    View full-size slide

  27. localhost/phpmyadmin

    View full-size slide

  28. localhost/phpmyadmin

    View full-size slide

  29. localhost/phpmyadmin

    View full-size slide

  30. localhost/phpmyadmin

    View full-size slide

  31. localhost/phpmyadmin

    View full-size slide

  32. localhost/phpmyadmin

    View full-size slide

  33. DB username: root
    DB password: root

    View full-size slide

  34. core.trac.wordpress.org/tickets/good-first-bugs

    View full-size slide

  35. Creating a patch

    View full-size slide

  36. ~$ git pull
    Updating 470a9fa..e7a6afc
    Fast-forward
    src/wp-includes/js/swfupload/swfupload.js|2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)
    ~$

    View full-size slide

  37. WordCamp Easter Egg
    // Inside get_body_class()
    $title = get_the_title($post_id);
    if ($title == "WordCamp Sydney")
    $classes[] = "September, 2016";

    View full-size slide

  38. WordCamp Easter Egg

    View full-size slide

  39. WordCamp Easter Egg


    View full-size slide

  40. WordCamp Easter Egg
    // Inside get_body_class()
    $title = get_the_title($post_id);
    if ($title == "WordCamp Sydney")
    $classes[] = sanitize_html_class("September, 2016");

    View full-size slide


  41. WordCamp Easter Egg

    View full-size slide



  42. WordCamp Easter Egg

    View full-size slide

  43. Public domain

    View full-size slide

  44. Malcolm Best (CC)

    View full-size slide

  45. This is what happens in a world
    without standards.

    View full-size slide

  46. Saroar Zubair (CC), flic.kr/p/a1ePPd

    View full-size slide

  47. WordPress Coding Standards
    // Inside get_body_class()
    $title = get_the_title($post_id);
    if ($title == "WordCamp Sydney")
    $classes[] = sanitize_html_class("September, 2016");

    View full-size slide

  48. make.wordpress.org/core/coding-standards/

    View full-size slide

  49. WordPress Coding Standards
    // Inside get_body_class()
    $title = get_the_title($post_id);
    if ($title == "WordCamp Sydney")
    $classes[] = sanitize_html_class("September, 2016");

    View full-size slide

  50. Spaces
    // Inside get_body_class()
    $title = get_the_title( $post_id );
    if ( $title == "WordCamp Sydney" )
    $classes[] = sanitize_html_class( "September, 2016" );

    View full-size slide

  51. No inline control structures
    // Inside get_body_class()
    $title = get_the_title( $post_id );
    if ( $title == "WordCamp Sydney" ) {
    $classes[] = sanitize_html_class( "September, 2016" );
    }

    View full-size slide

  52. No inline control structures
    // Inside get_body_class()
    $title = get_the_title( $post_id );
    if ( $title == "WordCamp Sydney" ) {
    $classes[] = sanitize_html_class( "September, 2016" );
    $classes[] = sanitize_html_class( "all-welcome" );
    }

    View full-size slide

  53. No inline control structures
    // Inside get_body_class()
    $title = get_the_title( $post_id );
    if ( $title == "WordCamp Sydney" ) {
    $classes[] = sanitize_html_class( "September, 2016" );
    }

    View full-size slide

  54. Single quotes preferred
    // Inside get_body_class()
    $title = get_the_title( $post_id );
    if ( $title == 'WordCamp Sydney' ) {
    $classes[] = sanitize_html_class( 'September, 2016' );
    }

    View full-size slide

  55. Yoda Conditions
    // Inside get_body_class()
    $title = get_the_title( $post_id );
    if ( 'WordCamp Sydney' == $title ) {
    $classes[] = sanitize_html_class( 'September, 2016' );
    }

    View full-size slide

  56. === != ==
    // Inside get_body_class()
    $title = get_the_title( $post_id );
    if ( 'WordCamp Sydney' === $title ) {
    $classes[] = sanitize_html_class( 'September, 2016' );
    }

    View full-size slide

  57. Uploading a patch

    View full-size slide

  58. WordCamp Easter Egg
    }
    }
    $title = get_the_title( $post_id );
    if ( 'WordCamp Sydney' === $title ) {
    $classes[] = sanitize_html_class( 'September, 2016' );
    }
    if ( is_attachment() ) {
    $mime_type = get_post_mime_type($post_id);

    View full-size slide

  59. WordCamp Easter Egg
    }
    }
    $title = get_the_title( $post_id );
    if ( 'WordCamp Sydney' === $title ) {
    $classes[] = sanitize_html_class( 'September, 2016' );
    }
    if ( is_attachment() ) {
    $mime_type = get_post_mime_type($post_id);
    src/wp-includes/post-template.php

    View full-size slide

  60. WordCamp Easter Egg
    git diff

    View full-size slide

  61. WordCamp Easter Egg
    diff --git a/src/wp-includes/post-template.php b/src/wp-includes/post-template.php
    index 7994f89..f1a0cad 100644
    --- a/src/wp-includes/post-template.php
    +++ b/src/wp-includes/post-template.php
    @@ -614,6 +614,11 @@ function get_body_class( $class = '' ) {
    }
    }
    + $title = get_the_title( $post_id );
    + if ( 'WordCamp Sydney' === $title ) {
    + $classes[] = sanitize_html_class( 'September, 2016' );
    + }
    +
    if ( is_attachment() ) {
    $mime_type = get_post_mime_type($post_id);
    $mime_prefix = array( 'application/', 'image/', 'text/', 'audio/', 'video/'...

    View full-size slide

  62. WordCamp Easter Egg
    diff --git a/src/wp-includes/post-template.php b/src/wp-includes/post-template.php
    index 7994f89..f1a0cad 100644
    --- a/src/wp-includes/post-template.php
    +++ b/src/wp-includes/post-template.php
    @@ -614,6 +614,11 @@ function get_body_class( $class = '' ) {
    }
    }
    + $title = get_the_title( $post_id );
    + if ( 'WordCamp Sydney' === $title ) {
    + $classes[] = sanitize_html_class( 'September, 2016' );
    + }
    +
    if ( is_attachment() ) {
    $mime_type = get_post_mime_type($post_id);
    $mime_prefix = array( 'application/', 'image/', 'text/', 'audio/', 'video/'...

    View full-size slide

  63. WordCamp Easter Egg
    diff --git a/src/wp-includes/post-template.php b/src/wp-includes/post-template.php
    index 7994f89..f1a0cad 100644
    --- a/src/wp-includes/post-template.php
    +++ b/src/wp-includes/post-template.php
    @@ -614,6 +614,11 @@ function get_body_class( $class = '' ) {
    }
    }
    + $title = get_the_title( $post_id );
    + if ( 'WordCamp Sydney' === $title ) {
    + $classes[] = sanitize_html_class( 'September, 2016' );
    + }
    +
    if ( is_attachment() ) {
    $mime_type = get_post_mime_type($post_id);
    $mime_prefix = array( 'application/', 'image/', 'text/', 'audio/', 'video/'...

    View full-size slide

  64. WordCamp Easter Egg
    diff --git a/src/wp-includes/post-template.php b/src/wp-includes/post-template.php
    index 7994f89..f1a0cad 100644
    --- a/src/wp-includes/post-template.php
    +++ b/src/wp-includes/post-template.php
    @@ -614,6 +614,11 @@ function get_body_class( $class = '' ) {
    }
    }
    + $title = get_the_title( $post_id );
    + if ( 'WordCamp Sydney' === $title ) {
    + $classes[] = sanitize_html_class( 'September, 2016' );
    + }
    +
    if ( is_attachment() ) {
    $mime_type = get_post_mime_type($post_id);
    $mime_prefix = array( 'application/', 'image/', 'text/', 'audio/', 'video/'...

    View full-size slide

  65. WordCamp Easter Egg
    diff --git a/src/wp-includes/post-template.php b/src/wp-includes/post-template.php
    index 7994f89..f1a0cad 100644
    --- a/src/wp-includes/post-template.php
    +++ b/src/wp-includes/post-template.php
    @@ -614,6 +614,11 @@ function get_body_class( $class = '' ) {
    }
    }
    + $title = get_the_title( $post_id );
    + if ( 'WordCamp Sydney' === $title ) {
    + $classes[] = sanitize_html_class( 'September, 2016' );
    + }
    +
    if ( is_attachment() ) {
    $mime_type = get_post_mime_type($post_id);
    $mime_prefix = array( 'application/', 'image/', 'text/', 'audio/', 'video/'...

    View full-size slide

  66. WordCamp Easter Egg
    diff --git a/src/wp-includes/post-template.php b/src/wp-includes/post-template.php
    index 7994f89..f1a0cad 100644
    --- a/src/wp-includes/post-template.php
    +++ b/src/wp-includes/post-template.php
    @@ -614,6 +614,11 @@ function get_body_class( $class = '' ) {
    }
    }
    + $title = get_the_title( $post_id );
    + if ( 'WordCamp Sydney' === $title ) {
    + $classes[] = sanitize_html_class( 'September, 2016' );
    + }
    +
    if ( is_attachment() ) {
    $mime_type = get_post_mime_type($post_id);
    $mime_prefix = array( 'application/', 'image/', 'text/', 'audio/', 'video/'...

    View full-size slide

  67. Generating a patch
    > ~/Downloads/37941.diff
    git diff

    View full-size slide

  68. git diff
    Generating a patch
    > ~/Downloads/37941.diff

    View full-size slide

  69. You retain the copyright.
    You license your code to WordPress

    View full-size slide

  70. Let the code reviews begin

    View full-size slide

  71. flic.kr/p/y35dEE (CC)

    View full-size slide

  72. Hack WordPress core,
    contribute code back.

    View full-size slide

  73. Hack WordPress docs,
    contribute docs back.

    View full-size slide

  74. Translate WordPress,
    help spread the word.

    View full-size slide

  75. Contribute however you can,
    however you feel comfortable.

    View full-size slide

  76. Thank you
    Peter Wilson • peterwilson.cc • @pwcc

    View full-size slide