169
mitcho (Michael 貴 Erlewine) http://mitcho.com, @themitcho D.C. WordPress Meetup, March 18, 2011 Extending WordPress beyond! CC-BY-NC flickr.com/photos/28634332@N05/

Extending WordPress beyond!

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Extending WordPress beyond!

mitcho (Michael 芳貴 Erlewine)

http://mitcho.com, @themitchoD.C. WordPress Meetup, March 18, 2011

Extending WordPress beyond!

CC-BY-NC flickr.com/photos/28634332@N05/

Page 2: Extending WordPress beyond!

follow slides onhttp://slideshare.net/mitcho

Page 3: Extending WordPress beyond!

Today: extend WordPress...

Page 4: Extending WordPress beyond!

Today: extend WordPress...

beyond the blog

Page 5: Extending WordPress beyond!

Today: extend WordPress...

beyond the blogbeyond the hack

Page 6: Extending WordPress beyond!

Today: extend WordPress...

beyond the blogbeyond the hackbeyond your site

Page 7: Extending WordPress beyond!

Introduction

Page 8: Extending WordPress beyond!

Introduction

• Hi, I’m mitcho.

Page 9: Extending WordPress beyond!

Introduction

• Hi, I’m mitcho.• Linguist, coder, teacher.

Page 10: Extending WordPress beyond!

Introduction

• Hi, I’m mitcho.• Linguist, coder, teacher.

• http://mitcho.com; @themitcho

Page 11: Extending WordPress beyond!

Introduction

• Hi, I’m mitcho.• Linguist, coder, teacher.

• http://mitcho.com; @themitcho• Linguistics PhD student at MIT

Page 12: Extending WordPress beyond!

Introduction

• Hi, I’m mitcho.• Linguist, coder, teacher.

• http://mitcho.com; @themitcho• Linguistics PhD student at MIT• Mozilla, Automattic, MIT

Page 13: Extending WordPress beyond!

Yet Another Related Posts Plugin (YARPP)

Page 14: Extending WordPress beyond!

• smart “related posts” listings with lots of customization

Yet Another Related Posts Plugin (YARPP)

Page 15: Extending WordPress beyond!

• smart “related posts” listings with lots of customization

• mitcho.com/code/yarpp or search for “YARPP”; @yarpp

Yet Another Related Posts Plugin (YARPP)

Page 16: Extending WordPress beyond!

• smart “related posts” listings with lots of customization

• mitcho.com/code/yarpp or search for “YARPP”; @yarpp

• over 850k downloads

Yet Another Related Posts Plugin (YARPP)

Page 17: Extending WordPress beyond!

HookPress

Page 18: Extending WordPress beyond!

HookPress• opens up the WordPress hook

system to remote scripts

Page 19: Extending WordPress beyond!

HookPress• opens up the WordPress hook

system to remote scripts• extend WP with other languages

Page 20: Extending WordPress beyond!

HookPress• opens up the WordPress hook

system to remote scripts• extend WP with other languages• now on WordPress.com!

Page 21: Extending WordPress beyond!

HookPress• opens up the WordPress hook

system to remote scripts• extend WP with other languages• now on WordPress.com!• mitcho.com/code/hookpress;

@hookpress

Page 22: Extending WordPress beyond!

ShrimpTest

Page 23: Extending WordPress beyond!

ShrimpTest

• A/B testing, built right into WP

Page 24: Extending WordPress beyond!

ShrimpTest

• A/B testing, built right into WP• joint project with Automattic

Page 25: Extending WordPress beyond!

ShrimpTest

• A/B testing, built right into WP• joint project with Automattic• currently in perpetual beta:

Page 26: Extending WordPress beyond!

ShrimpTest

• A/B testing, built right into WP• joint project with Automattic• currently in perpetual beta:• shrimptest.com; @shrimptest

Page 27: Extending WordPress beyond!

ShrimpTest

• A/B testing, built right into WP• joint project with Automattic• currently in perpetual beta:• shrimptest.com; @shrimptest

• video of talk up on wordpress.tv

Page 29: Extending WordPress beyond!

WordPress at MIT

Page 30: Extending WordPress beyond!

WordPress at MIT

• Becoming the platform of choice

Page 31: Extending WordPress beyond!

WordPress at MIT

• Becoming the platform of choice• Free, flexible, easy, well-known

Page 32: Extending WordPress beyond!

WordPress at MIT

• Becoming the platform of choice• Free, flexible, easy, well-known• Academic to administrative;

public and private

Page 33: Extending WordPress beyond!

WordPress at MIT

• Becoming the platform of choice• Free, flexible, easy, well-known• Academic to administrative;

public and private• But... is it more than just a blog?

Page 34: Extending WordPress beyond!

take WordPressbeyond the blog

Page 35: Extending WordPress beyond!

three examples from MIT

Page 36: Extending WordPress beyond!

Edgerton Digital CollectionsMIT Museum and MIT Edgerton Centerhttp://edgerton-digital-collections.org

Page 37: Extending WordPress beyond!

12000 photos, 8000 notebook pagesDynamic custom UI and search

Page 38: Extending WordPress beyond!

Transcriptions and commentsMetadata direct from museum data store

Page 39: Extending WordPress beyond!

Global ShakespearesMIT Shakespeare Project

http://globalshakespeares.org

Page 40: Extending WordPress beyond!

Rich custom metadataAll managed through WordPress

Page 41: Extending WordPress beyond!

Dynamic searchCalls WordPress search via AJAX

DOM built client-side; data in localstorage

Page 42: Extending WordPress beyond!

Educational Collaboration SpaceMIT Dept. of Mathematics, NSFmore info at http://ecs.mit.edu

Page 43: Extending WordPress beyond!

Management of “File Groups”Content linked through tags

Notification by tags

Page 44: Extending WordPress beyond!

WP beyond blogs?

Page 45: Extending WordPress beyond!

WP beyond blogs?

• A solid foundation

Page 46: Extending WordPress beyond!

WP beyond blogs?

• A solid foundation• Faster development cycle

Page 47: Extending WordPress beyond!

WP beyond blogs?

• A solid foundation• Faster development cycle

• Cohesive structure and navigation

Page 48: Extending WordPress beyond!

WP beyond blogs?

• A solid foundation• Faster development cycle

• Cohesive structure and navigation• A great community

Page 49: Extending WordPress beyond!

WP beyond blogs?

• A solid foundation• Faster development cycle

• Cohesive structure and navigation• A great community• Plugins and themes you can use

Page 50: Extending WordPress beyond!

CONTENT

CC-BY-NC-SA flickr.com/photos/bikeracer/6740232/

Page 51: Extending WordPress beyond!

Details, details, details

Page 52: Extending WordPress beyond!

Details, details, details

• Navigation, permalinks, RSS

Page 53: Extending WordPress beyond!

Details, details, details

• Navigation, permalinks, RSS• User roles and permissions

Page 54: Extending WordPress beyond!

Details, details, details

• Navigation, permalinks, RSS• User roles and permissions• External data? AJAX-heavy UI?

Page 55: Extending WordPress beyond!

Details, details, details

• Navigation, permalinks, RSS• User roles and permissions• External data? AJAX-heavy UI?• Ask me about it. :)

Page 56: Extending WordPress beyond!

take WordPressbeyond the blog

Page 57: Extending WordPress beyond!

You customized WordPressfor a project.

Page 58: Extending WordPress beyond!

what if...

Page 60: Extending WordPress beyond!

•they move servers...

CC-BY-NC-SA flickr.com/photos/slworking/1704538333

Page 61: Extending WordPress beyond!

•they move servers...•they want to reuse some of it...

CC-BY-NC-SA flickr.com/photos/slworking/1704538333

Page 62: Extending WordPress beyond!

•they move servers...•they want to reuse some of it...

•they want modifications...

CC-BY-NC-SA flickr.com/photos/slworking/1704538333

Page 63: Extending WordPress beyond!

•they move servers...•they want to reuse some of it...

•they want modifications...disaster!

CC-BY-NC-SA flickr.com/photos/slworking/1704538333

Page 64: Extending WordPress beyond!

take your codebeyond the hack

Page 65: Extending WordPress beyond!
Page 66: Extending WordPress beyond!

Abstraction!

Page 67: Extending WordPress beyond!

Abstraction arises from the recognition of similarities between certain objects, situations, or processes in the real world and the decision to concentrate on these similarities and to ignore, for the time being, their differences.

— C.A.R. Hoare

Page 68: Extending WordPress beyond!

Abstraction

Page 69: Extending WordPress beyond!

Abstraction=

thinking about the more general problem

Page 70: Extending WordPress beyond!

result=

Page 71: Extending WordPress beyond!

result=

code that you and others can reuse

Page 72: Extending WordPress beyond!

How?

Page 73: Extending WordPress beyond!

Think abstractly

Page 74: Extending WordPress beyond!

• Produce “functionalities”

Think abstractly

Page 75: Extending WordPress beyond!

• Produce “functionalities”• One functionality = one plugin

Think abstractly

Page 76: Extending WordPress beyond!

• Produce “functionalities”• One functionality = one plugin• Interrelated code can be

modularized

Think abstractly

Page 77: Extending WordPress beyond!

• Produce “functionalities”• One functionality = one plugin• Interrelated code can be

modularized• introduce new hooks and filters

with do_action(), apply_filters()

Think abstractly

Page 78: Extending WordPress beyond!

Use WP abstractions

Page 79: Extending WordPress beyond!

Use WP abstractions

• DB query? $wpdb, not mysql_*

Page 80: Extending WordPress beyond!

Use WP abstractions

• DB query? $wpdb, not mysql_*• Caching? Object Cache and

Transients API

Page 81: Extending WordPress beyond!

Use WP abstractions

• DB query? $wpdb, not mysql_*• Caching? Object Cache and

Transients API• Options? set_option() not db

Page 82: Extending WordPress beyond!

Use WP abstractions

Page 83: Extending WordPress beyond!

Use WP abstractions• Posts? get_posts() not SQL

Page 84: Extending WordPress beyond!

Use WP abstractions• Posts? get_posts() not SQL• Custom data? Custom taxonomy

or fields

Page 85: Extending WordPress beyond!

Use WP abstractions• Posts? get_posts() not SQL• Custom data? Custom taxonomy

or fields• New entities? Custom post types!

Page 86: Extending WordPress beyond!

Use WP abstractions• Posts? get_posts() not SQL• Custom data? Custom taxonomy

or fields• New entities? Custom post types!• External request?

wp_remote_post() not curl

Page 87: Extending WordPress beyond!

© 2008 Drew and Natalie Dee, toothpastefordinner.com

Don’t reinvent the wheel.

Page 88: Extending WordPress beyond!

Be mobile

Page 89: Extending WordPress beyond!

• Don’t expect to be in a particular place

Be mobile

Page 90: Extending WordPress beyond!

• Don’t expect to be in a particular place

• Use __FILE__, plugins_url(), etc.

Be mobile

Page 91: Extending WordPress beyond!

• Don’t expect to be in a particular place

• Use __FILE__, plugins_url(), etc.• Get info with get_bloginfo()

Be mobile

Page 92: Extending WordPress beyond!

• Don’t expect to be in a particular place

• Use __FILE__, plugins_url(), etc.• Get info with get_bloginfo()• Use $wpdb so you can forget

about database settings

Be mobile

Page 93: Extending WordPress beyond!

Be classy

Page 94: Extending WordPress beyond!

Be classy• OOP is perfect for abstracting

“functionality”

Page 95: Extending WordPress beyond!

Be classy• OOP is perfect for abstracting

“functionality”• Write your functionality as a

class with some defaults

Page 96: Extending WordPress beyond!

Be classy• OOP is perfect for abstracting

“functionality”• Write your functionality as a

class with some defaults• Easy for others to extend

Page 97: Extending WordPress beyond!

Be classy• OOP is perfect for abstracting

“functionality”• Write your functionality as a

class with some defaults• Easy for others to extend• Clean, legible code

Page 98: Extending WordPress beyond!

Give yourself options

Page 99: Extending WordPress beyond!

Give yourself options

• Don’t hard code the project name, URLs, emails, etc.

Page 100: Extending WordPress beyond!

Give yourself options

• Don’t hard code the project name, URLs, emails, etc.

• Bare minimum: declare as overrideable constants

Page 101: Extending WordPress beyond!

Give yourself options

• Don’t hard code the project name, URLs, emails, etc.

• Bare minimum: declare as overrideable constants

• Ideally: create an options screen

Page 102: Extending WordPress beyond!

Learn from the masters

Page 103: Extending WordPress beyond!

• http://codex.wordpress.org

Learn from the masters

Page 104: Extending WordPress beyond!

• http://codex.wordpress.org• Read others’ code.

Learn from the masters

Page 105: Extending WordPress beyond!

• http://codex.wordpress.org• Read others’ code.• Borrow and adapt from other

plugins, themes, and the Core

Learn from the masters

Page 106: Extending WordPress beyond!

• http://codex.wordpress.org• Read others’ code.• Borrow and adapt from other

plugins, themes, and the Core• “free as in freedom!”

Learn from the masters

Page 107: Extending WordPress beyond!

CC-BY-NC xkcd.com/292/

Good practice matters

Page 108: Extending WordPress beyond!

Results

Page 109: Extending WordPress beyond!

• Won’t [Less likely to] break when you move or upgrade

Results

Page 110: Extending WordPress beyond!

• Won’t [Less likely to] break when you move or upgrade

• Easier to maintain

Results

Page 111: Extending WordPress beyond!

• Won’t [Less likely to] break when you move or upgrade

• Easier to maintain• Easier to build on

Results

Page 112: Extending WordPress beyond!

• Won’t [Less likely to] break when you move or upgrade

• Easier to maintain• Easier to build on• Easier to reuse elsewhere

Results

Page 113: Extending WordPress beyond!

More FTW = less WTF

Page 114: Extending WordPress beyond!

take your codebeyond the hack

Page 115: Extending WordPress beyond!

but wait, there’s more...

Page 117: Extending WordPress beyond!

CC-BY-NC-SA flickr.com/photos/z6p6tist6/500048151/

is not a one way street.

Free software

Page 118: Extending WordPress beyond!

CC-BY-NC-SA flickr.com/photos/z6p6tist6/500048151/

is not a one way street.

WordPress

Page 119: Extending WordPress beyond!

Think:

Page 120: Extending WordPress beyond!

• You just customized WordPress for a client

Think:

Page 121: Extending WordPress beyond!

• You just customized WordPress for a client

• Others could benefit from this

Think:

Page 122: Extending WordPress beyond!

• You just customized WordPress for a client

• Others could benefit from this• You and the client have benefited

from free software: WordPress

Think:

Page 123: Extending WordPress beyond!

Consider open-sourcing your client-requested

functionality.

Page 124: Extending WordPress beyond!
Page 125: Extending WordPress beyond!

take your codebeyond your site

Page 126: Extending WordPress beyond!

Do people really do this?

Page 127: Extending WordPress beyond!

success stories:

Page 128: Extending WordPress beyond!

success stories:

My own work at MIT

Page 129: Extending WordPress beyond!

Open source from MIT

Page 130: Extending WordPress beyond!

• Shakespeare: Redirect by Custom Field, Require First and Last Name

Open source from MIT

Page 131: Extending WordPress beyond!

• Shakespeare: Redirect by Custom Field, Require First and Last Name

• Educational Collaboration Space: File Groups, Distinct Preview, Allow LaTeX Uploads, Notifications By Tag, License

Open source from MIT

Page 132: Extending WordPress beyond!
Page 133: Extending WordPress beyond!

LicenseEducational Collaboration Space

Page 134: Extending WordPress beyond!

LicenseEducational Collaboration Space

Page 135: Extending WordPress beyond!

ECS and Shibboleth

Page 136: Extending WordPress beyond!

ECS and Shibboleth

• Shibboleth authentication

Page 137: Extending WordPress beyond!

ECS and Shibboleth

• Shibboleth authentication• now contributing to the pre-

existing Shibboleth plugin

Page 138: Extending WordPress beyond!

ECS and Shibboleth

• Shibboleth authentication• now contributing to the pre-

existing Shibboleth plugin• MIT customizations can be

reused in other MIT projects

Page 139: Extending WordPress beyond!

Brad Williamsco-founder, WebDevStudios.com

success stories:

Page 140: Extending WordPress beyond!

Brad Williams

Page 141: Extending WordPress beyond!

• NextGEN Public Uploader

Brad Williams

Page 142: Extending WordPress beyond!

• NextGEN Public Uploader• Post Google Map

Brad Williams

Page 143: Extending WordPress beyond!

• NextGEN Public Uploader• Post Google Map• sponsored by injersey.com

Brad Williams

Page 144: Extending WordPress beyond!

Brad Williams

Page 145: Extending WordPress beyond!

• no client has said no

Brad Williams

Page 146: Extending WordPress beyond!

• no client has said no• many clients want to give back

Brad Williams

Page 147: Extending WordPress beyond!

• no client has said no• many clients want to give back• plugins have brought in new

clients

Brad Williams

Page 148: Extending WordPress beyond!

John James Jacobynow at Automattic

success stories:

Page 149: Extending WordPress beyond!
Page 150: Extending WordPress beyond!

BuddyPress Member Filterdevelopment supported by LOGOI Ministries

Page 151: Extending WordPress beyond!
Page 152: Extending WordPress beyond!

BuddyPress Edit Group Slugdevelopment supported by We Heart This

Page 153: Extending WordPress beyond!

John James Jacoby

Page 154: Extending WordPress beyond!

John James Jacoby• educate client about community

role and open-source

Page 155: Extending WordPress beyond!

John James Jacoby• educate client about community

role and open-source• sometimes appropriate to just

open-source the backend w/o UI

Page 156: Extending WordPress beyond!

John James Jacoby• educate client about community

role and open-source• sometimes appropriate to just

open-source the backend w/o UI• community contributions got

him noticed

Page 157: Extending WordPress beyond!

John James Jacoby• educate client about community

role and open-source• sometimes appropriate to just

open-source the backend w/o UI• community contributions got

him noticed• BuddyPress Core, Automattic

Page 158: Extending WordPress beyond!

Tips

Page 159: Extending WordPress beyond!

Tips• bring up open-sourcing early

Page 160: Extending WordPress beyond!

Tips• bring up open-sourcing early• if they say no, respect that

Page 161: Extending WordPress beyond!

Tips• bring up open-sourcing early• if they say no, respect that• don’t pass cost back to client

Page 162: Extending WordPress beyond!

Tips• bring up open-sourcing early• if they say no, respect that• don’t pass cost back to client• acknowledge the funding

Page 163: Extending WordPress beyond!

Tips• bring up open-sourcing early• if they say no, respect that• don’t pass cost back to client• acknowledge the funding• don’t forget you can contribute

to existing projects as well

Page 164: Extending WordPress beyond!

take your codebeyond your site

Page 165: Extending WordPress beyond!

Today: extend WordPress...

Page 166: Extending WordPress beyond!

Today: extend WordPress...

beyond the blog

Page 167: Extending WordPress beyond!

Today: extend WordPress...

beyond the blogbeyond the hack

Page 168: Extending WordPress beyond!

Today: extend WordPress...

beyond the blogbeyond the hackbeyond your site

Page 169: Extending WordPress beyond!

Thank you!Questions?

Slides up on slideshare.net/mitcho.

mitcho (Michael 芳貴 Erlewine)

mitcho.com; @themitcho