53
Building Custom CMS Applications on W ordPress mitcho (Michael 貴 Erlewine)

Building custom CMS applications on WordPress

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Building custom CMS applications on WordPress

Building Custom CMS Applications on WordPressmitcho (Michael 芳貴 Erlewine)

Page 3: Building custom CMS applications on WordPress

CMS

Page 4: Building custom CMS applications on WordPress

There’s no such thing as a CMS success story.The  Trouble  With  Back-­‐EndsErin  Griffith,  Adweek,  August  9,  2011adweek.com/print/133917

Page 5: Building custom CMS applications on WordPress

it’s all about the C and M

CMS

Page 6: Building custom CMS applications on WordPress

FALSE

Page 8: Building custom CMS applications on WordPress

1. Content2. Management1. C2. M

Today:

Page 9: Building custom CMS applications on WordPress

1. Content

Page 10: Building custom CMS applications on WordPress

The essence of man is discontent, divine discontent...

the essence of web is content, divine content.

José Ortega y Gasset

Page 11: Building custom CMS applications on WordPress

1. Content

what is the content?is the metadata?

where is the data?

Page 12: Building custom CMS applications on WordPress

Text?That’s so 2000s.

Page 13: Building custom CMS applications on WordPress

Global ShakespearesMIT Shakespeare Projectglobalshakespeares.org

Page 14: Building custom CMS applications on WordPress

Hundreds of productions with video

Page 15: Building custom CMS applications on WordPress

Document Revisions by Ben Balterwordpress.org/extend/plugins/wp-document-revisions

Page 16: Building custom CMS applications on WordPress

pressfs by Joseph Scottjosephscott.org/pressfs-a-wordpress-filesystem

Page 17: Building custom CMS applications on WordPress

Build featuresnot post types

Page 18: Building custom CMS applications on WordPress

In development: Shakespeare scripts

Page 19: Building custom CMS applications on WordPress

Scripts are XML files, not content text in WordPressNo editor needed

Page 20: Building custom CMS applications on WordPress
Page 21: Building custom CMS applications on WordPress
Page 22: Building custom CMS applications on WordPress

Registering scripts

register_post_type('script', array( 'label' => 'Scripts', 'public' => true, 'hierarchical' => false, 'supports' => array('title', 'xmldoc', 'comments'), 'taxonomies' => array('post_tag')));

XML Documents with XSLT stylesheetswordpress.org/extend/plugins/xml-documents

instead of ‘editor’

Page 23: Building custom CMS applications on WordPress

Post Type Features

post type features

post title, editor, author, thumbnail, excerpt, trackbacks, custom-fields, comments, revisions, post-formats

page title, editor, author, thumbnail, page-attributes, custom-fields, comments, revisions

attachment comments

default title, editor

Page 24: Building custom CMS applications on WordPress

// if ( 'script' == $post_type )

Check for features

if ( post_type_supports( $post_type, 'xmldoc' ) )if ( 'script' == $post_type )

Page 25: Building custom CMS applications on WordPress

Get meta.Define your metadata.

Page 26: Building custom CMS applications on WordPress

metadata in WordPress{taxonomy

organizationalsearch, sortingcan be hierarchicallike tags, categories

post metanon-organizationalspecific to the content itemlike custom fields

Page 28: Building custom CMS applications on WordPress

Taxonomy Queriesquery_posts( array( 'post_type' => 'production', 'tax_query' => array( array( 'taxonomy' => 'play', 'terms' => array( 'hamlet' ), 'field' => 'slug' ), array( 'taxonomy' => 'language', 'terms' => array( 'japanese', 'mandarin' ), 'field' => 'slug' ) ));

Page 29: Building custom CMS applications on WordPress

WordPressis not an island

Page 30: Building custom CMS applications on WordPress

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

Page 31: Building custom CMS applications on WordPress

12000 photos, 8000 notebook pages

Page 32: Building custom CMS applications on WordPress

All assets from the MIT Museum databasein MIMSY, a commercial collection management app

Page 33: Building custom CMS applications on WordPress

Edgerton

• Custom post type for museum assets• Specify ID, get image and metadata

from museum DB• Site-specific metadata (comments,

tags) in WordPress

Page 34: Building custom CMS applications on WordPress

Remote data

• Hit external APIs with wp_remote_request() and friends

• Cache results in Post Meta, Object Cache, Transients, as appropriate

Page 35: Building custom CMS applications on WordPress

Search integration

• Simple trick: put searchable text versions of custom content in post_content

• Roll out a separate search

Page 36: Building custom CMS applications on WordPress

1. Content

what is the content?is the metadata?

where is the data?

Page 37: Building custom CMS applications on WordPress

2. Management

Page 38: Building custom CMS applications on WordPress

who contributes/edits/curates/maintains it?

2. Management

how will it be managed?

Page 39: Building custom CMS applications on WordPress

Who’s who?

Page 40: Building custom CMS applications on WordPress

Work for the weekend

add_filter( 'user_has_cap', 'workweek', 10, 3 );

function workweek( $allcaps, $caps, $args ) { $user = get_userdata( $args[1] ); $weekend = ( date( 'N' ) > 5 ); if ( $args[0] == 'publish_posts' && $user->user_email = '[email protected]' && $weekend ) $allcaps['publish_posts'] = false; return $allcaps;}

Page 41: Building custom CMS applications on WordPress

Keep It Simple,Smartypants.

Page 42: Building custom CMS applications on WordPress

Shakespeare: rich metadata on each production

Page 43: Building custom CMS applications on WordPress

Production metadata consolidated into one meta boxUse add_meta_box(), intercept data with ‘save_post’ filter.

Page 44: Building custom CMS applications on WordPress

KISS

add_filter( 'default_hidden_meta_boxes', function( $hidden ) { $hidden[] = 'myboxid'; $hidden[] = 'anotherboxid'; //... return $hidden; });

Page 45: Building custom CMS applications on WordPress

The right tool (?)for the job

Page 46: Building custom CMS applications on WordPress

Shakespeare: some video datasubmitted by researchers in Excel format

Page 47: Building custom CMS applications on WordPress

Solution: a simple (custom) CSV file importer

Page 48: Building custom CMS applications on WordPress

$id = wp_insert_post( array( 'post_title' => 'WP Hamlet', 'post_status' => 'publish', 'post_type' => 'production', 'tax_input' => array( 'play' => 'hamlet', 'director' => 'matt-mullenweg', 'language' => 'php' )) );

Add post meta separately.

Insert the post

Page 49: Building custom CMS applications on WordPress

WARNING:

• This is a balancing act• Moving to WordPress can be a great

way to build new sustainable habits• Not all traditions are constructive

Page 50: Building custom CMS applications on WordPress

what is the content?is the metadata?

where is the data?who contributes/edits/

curates/maintains it?how will it be managed?

Page 51: Building custom CMS applications on WordPress

kick-ass CMS applications

Page 52: Building custom CMS applications on WordPress

Discontent is the first step in the progress of a man or nation...content is the first concern in the progress of a website.

Oscar Wilde

Page 53: Building custom CMS applications on WordPress

thank you.Q?

mitcho (Michael 芳貴 Erlewine)mitcho.com; @themitcho; slideshare.net/mitcho