68
WordPress 3.0 Andrew Nacin WordPress Core Developer twitter @nacin web andrewnacin.com email [email protected]

WordPress 3.0 at DC PHP

Embed Size (px)

DESCRIPTION

My August 2010 talk at the DC PHP meetup, hosted by Fathom Creative.

Citation preview

Page 1: WordPress 3.0 at DC PHP

WordPress 3.0

Andrew NacinWordPress Core Developer

twitter @nacin web andrewnacin.comemail [email protected]

Page 2: WordPress 3.0 at DC PHP

Make sure WP_CACHE is true. Props nacin.

Page 3: WordPress 3.0 at DC PHP

PHP 5.22011 Q2

WordPress 3.2

Page 4: WordPress 3.0 at DC PHP

In nine weeks,WordPress 3.0

was downloaded12,654,147 times

http://wordpress.org/download/counter/

Page 5: WordPress 3.0 at DC PHP

WordPress powers8.5 percent of the web

Acquia

Page 6: WordPress 3.0 at DC PHP

WordPress is a CMS

Page 7: WordPress 3.0 at DC PHP

Custompost types

Customtaxonomies

Theme development

The mergeof WPMU

Why WordPress is a CMS3.0

Page 8: WordPress 3.0 at DC PHP

Custompost types

Customtaxonomies

Theme development

The mergeof WPMU

Why WordPress is a CMS

Page 9: WordPress 3.0 at DC PHP

blogsite

Page 10: WordPress 3.0 at DC PHP

a post type isa content type

Page 11: WordPress 3.0 at DC PHP

What can post types be used for?

Everything.

Page 12: WordPress 3.0 at DC PHP

Core post types

PostsPages

AttachmentsRevisions

Menu Items

Page 13: WordPress 3.0 at DC PHP

They are your content and storage.

• Blog• Articles• News Releases• Portfolio• Products• Newsletter• Events• Tweets

• Employees• My Reading List• Documentation• Forums• Menu Items• Uploads• Logging• Revisions

Page 14: WordPress 3.0 at DC PHP

Why?

Some use cases are obvious.• Articles, Newsletters, Portfolio, Events

Some are not.• Logging, Menu items

Page 15: WordPress 3.0 at DC PHP

Leverage what WordPress does best

Performance• No direct queries• Utilize caching• Extremely light• Scalability

Ease• Full API• Full admin UI• Use existing

features• Why reinvent the

wheel?

Page 16: WordPress 3.0 at DC PHP

Leverage existing features

What can posts have?• Title, content, excerpt• Author• Categories, tags• Revisions• Comments, Pingbacks• Thumbnails• Attachments• Custom fields (meta)

What can you leverage?• Templating• URL Rewriting• WP_Query• Capabilities• Admin UI, meta boxes• Feeds

Page 17: WordPress 3.0 at DC PHP

Let’s put it togetheradd_action( 'init', 'my_employees_init' );function my_employees_init() {

register_post_type( 'my_employee', array( 'labels' => array(

'name' => 'Employees','singular_name' => 'Employee' ),

'public' => true, 'show_ui' => true, 'rewrite' => array( 'slug' => 'team' ), 'query_var' => 'team', 'hierarchical' => false, 'supports' => array(

'title', 'thumbnail', 'editor', 'excerpt' ),) );

}

Page 18: WordPress 3.0 at DC PHP

What’s it look like?

Page 19: WordPress 3.0 at DC PHP

Editing me

Page 20: WordPress 3.0 at DC PHP

Let’s create a quick templatequery_posts( array('post_type' => 'my_employee') );if ( have_posts() ) :

while ( have_posts() ) : the_post();

echo '<h2><a href="' . get_permalink() . '">' .

get_the_title() . '</a></h2>';the_post_thumbnail();the_content();echo '<p>Read posts by ';the_author_posts_link();echo '</p>';

endwhile; endif;

Page 21: WordPress 3.0 at DC PHP

Done.

/team//team/andrew-nacin//blog/author/andrew-nacin/

(excuse my CSS)

Page 22: WordPress 3.0 at DC PHP

Custom taxonomiesdescribe your content.

Page 23: WordPress 3.0 at DC PHP

Core taxonomies

Post TagsCategories

Link CategoriesMenus

Page 24: WordPress 3.0 at DC PHP

They describe your content.

The difference between tags and categories is hierarchy.

• Topics• People• Cities

• Cities– Content: Travel blog

• Cuisine– Content: Restaurants

• Songs– Content: Concerts

• Actors, Directors, Producers– Content: Movies

Page 25: WordPress 3.0 at DC PHP

Custom taxonomies are not new

• Database schema — WP 2.3, Sept. 2007• Custom taxonomies — WP 2.5, March 2008• Partial UI — WP 2.8, June 2009

• In WP 3.0 — full custom UI implementation

So basically, they’re now on steroids.

Page 26: WordPress 3.0 at DC PHP

Specialties taxonomy

register_taxonomy( 'my_specialties', 'nacin_employee', array('labels' => array(

'name' => 'Specialties', 'singular_name' => 'Specialty' ),

'public' => true,'show_ui' => true,'query_var' => false,'rewrite' => false,'hierarchical' => false,

) );

Page 27: WordPress 3.0 at DC PHP

Edit screen

Page 28: WordPress 3.0 at DC PHP

'hierarchical' => 'false'

Page 29: WordPress 3.0 at DC PHP

'hierarchical' => 'true'

Page 30: WordPress 3.0 at DC PHP

WordPress 3.0 makestheme development and

customizations easier.

Page 31: WordPress 3.0 at DC PHP

• Admin UI screenshot

Page 32: WordPress 3.0 at DC PHP
Page 33: WordPress 3.0 at DC PHP

How?

In our theme functions.php:

function my_theme_setup() {add_custom_background();

}add_action( 'after_setup_theme', 'my_theme_setup' );

1234

Page 34: WordPress 3.0 at DC PHP
Page 35: WordPress 3.0 at DC PHP

function my_theme_setup() {add_custom_background();define( 'NO_HEADER_TEXT', true );define( 'HEADER_IMAGE_WIDTH', 940 );define( 'HEADER_IMAGE_HEIGHT', 198 );define( 'HEADER_IMAGE', '%s/images/default.jpg' );add_custom_header( 'my_theme_header_style', 'my_theme_admin_header_style' );register_default_header( array(

'default' => array('url' => '%s/images/default.jpg','thumbnail_url' => '%s/images/default-

thumb.jpg', 'description' => 'Default Header' ),) );

}add_action( 'after_setup_theme', 'my_theme_setup' );

234567

8910111213

Page 36: WordPress 3.0 at DC PHP

Custom Header, cont.

function my_theme_admin_header_style() {echo '#headimg { height: ' . HEADER_IMAGE_HEIGHT . 'px; width: ' . HEADER_IMAGE_WIDTH . 'px; }';

}function my_theme_header_style() {echo '#header { background-image: url(' . header_image() . '); }';

}

12

345

6

Page 37: WordPress 3.0 at DC PHP

Menus

• Screenshot of menu admin

Page 38: WordPress 3.0 at DC PHP

In our theme functions.php:

function my_theme_setup() {add_custom_background();add_custom_header( 'my_theme_header_style', 'my_theme_admin_header_style' );// ...register_nav_menu('header', 'Primary Navigation');

}add_action( 'after_setup_theme', 'my_theme_setup' );

In our theme header.php:

wp_nav_menu( array( 'theme_location' => 'header' ) );

1234

567

Page 39: WordPress 3.0 at DC PHP

Menus

• Screenshot of menus in Twenty Ten

Page 40: WordPress 3.0 at DC PHP

Evolving Theme Development

get_template_part()It’s basically include() on steroids.

Example:get_template_part('loop', 'archive');

Process:• Check for loop-archive.php. Check the

child theme first, if applicable.• Otherwise, check for loop.php.

Less Redundancy FTW.

Page 41: WordPress 3.0 at DC PHP

get_template_part('header', 'home');

Is like calling:

get_header( 'home' );

Same deal: header-home.php,then header.php.

Page 42: WordPress 3.0 at DC PHP

What’s with the theme improvements?

In 3.0, we weretheme developers.

Page 43: WordPress 3.0 at DC PHP

Kubrick!

Page 44: WordPress 3.0 at DC PHP

Twenty Ten

Page 45: WordPress 3.0 at DC PHP

Power one site or 10 million.

Page 46: WordPress 3.0 at DC PHP

WordPress Multisite

• The WPMU fork was merged• Massive merge sprint, followed by cleanup• Terminology/concept nightmare• TODO: Network admin UI improvements• TODO: Easier to manage, use, and install (in

that order

Page 47: WordPress 3.0 at DC PHP

Oh no, please don’t.

define( 'WP_ALLOW_MULTISITE', true );

Page 48: WordPress 3.0 at DC PHP

Only if you insist.

Page 49: WordPress 3.0 at DC PHP
Page 50: WordPress 3.0 at DC PHP

A new Network Admin

• New MU screen

Page 51: WordPress 3.0 at DC PHP

Other cool features

• Pick a username/password during install• comment_form() and wp_login_form()

• Stronger authentication security by default• Bulk update plugins and themes• “Search Engines Blocked”• Rewritten initialization code

Page 52: WordPress 3.0 at DC PHP

Follow along

• #wordpress-dev on freenode.net• http://wpdevel.wordpress.com• http://core.trac.wordpress.org• wp-svn – mailing list for commits• wp-hackers – plugin and core developers• wp-testers

Page 53: WordPress 3.0 at DC PHP

What might be next

• Column sorting and a more AJAX feel• More features for custom post types and custom

taxonomies• Support for custom comment types• Better support for custom post statuses• Media/upload overhaul• Incremental admin, DRY, UX changes• Incremental improvements to multisite• Links as a post type• Roles/capabilities overhaul

Page 54: WordPress 3.0 at DC PHP

Our philosophies.

codex.wordpress.org/Release_Philosophy

Page 55: WordPress 3.0 at DC PHP

Decisions, not options.

Page 56: WordPress 3.0 at DC PHP

Preferences have a cost.

• Too many means you can't find any of them.

• They damage QA and testing.

• They make good UI difficult.

• They confuse users.

Do something specific and do it well.

Defaults that work will lead the UI in the right direction.

Page 57: WordPress 3.0 at DC PHP

The quality of an interface design is

inversely proportional to the number of designers.

Page 58: WordPress 3.0 at DC PHP

If you're too lazy to do the homework and think through the big-picture rationale, I'm too lazy to

add the feature.

Page 59: WordPress 3.0 at DC PHP

In the presence of good rationale, maintainers

should be willing to change their mind often.

Page 60: WordPress 3.0 at DC PHP

Let’s talk security.

Page 61: WordPress 3.0 at DC PHP

Qualys BlindElephant

BlindElephant is a web application fingerprinter.

Drupal, Joomla!, Liferay, Mediawiki, Moodle, MovableType, osCommerce, phpBB, phpMyAdmin, phpNuke, SPIP, WordPress

Page 62: WordPress 3.0 at DC PHP

Versions < 1.0.15 and < 1.5.17 are critically insecure. Version 1.5.17 was released 3 months ago.

Percentage of installs running a critically insecure version?

JOOMLA 1.5.20

96 percent

Page 63: WordPress 3.0 at DC PHP

Versions < 5.22 and < 6.16 are critically insecure. Version 6.16 was released in March. Versions 6.18 and 5.23 were critical security fixes released last week.

Percentage of installs running a critically insecure version?

DRUPAL 6.19

69 percent (and up)

Page 64: WordPress 3.0 at DC PHP

Versions < 2.5.1 are critically insecure. (Released in April 2008.)

Versions < 2.8.3 are insecure. (August 2009.) Percentage of installs running a critically insecure version?

WORDPRESS 3.0.1

4 percent

Page 65: WordPress 3.0 at DC PHP

Shared hosts suck.

Page 67: WordPress 3.0 at DC PHP

pre-release candidates for 3.0 were downloaded

75,000 times

QUALITY ASSURANCE

Page 68: WordPress 3.0 at DC PHP

Questions?

twitter @nacin web andrewnacin.comemail [email protected]