The WordPress University 2012
-
Upload
stephanie-leary -
Category
Technology
-
view
4.584 -
download
2
Transcript of The WordPress University 2012
Stephanie Leary @sleary stephanieleary.com
The WordPress University
New book coming Fall 2014!
Content Strategy for WordPressdemonstrates how to build structured
content for higher ed sites.
Sign up to be notified when it’s out:http://sleary.me/list
Steph’s Stuff• @sleary
• stephanieleary.com
• profiles.wordpress.org/sillybean
• slideshare.net/stephanieleary
Why WordPress?
Common Situation• No staff
• No budget
• No server
• Thousands of HTML files
• ... and broken links
• No search
• No RSS feeds
Advantages• Easy UI for managing posts and pages
• Scheduled publishing
• Clean URLs
• Feeds for everything
• One-click upgrades
• Widgets and menus
• Thousands of free plugins and themes
Weaknesses• Lacks native reusable content & network-
wide internal linking system
• Requires caching plugin, not included, to optimize speed
• Critical plugins can fail as WP advances
• Disjointed and incomplete advanced documentation
• Heavy use of pages can be problematic
• Lacks robust native workflow
Compared to other CMSs
• Fast development cycles
• WP 3.0 to 3.1: 8 months
• 5-6 months more typical
• Drupal 6.0 to 7.0: 3 years
• Joomla 1.5 to 1.6: 3 years
• Cohesive, disciplined core developer group
• UI focused on ease of use
Compared to other CMSs
• Core features work very well
• Comments
• RSS and Atom feeds
• Permalinks
• File uploads
• Nonessential features relegated to plugins
WordPress Tour
Media Uploads• Limited to unpublicized list of MIMEs
• Easy to add or remove MIMEs
• Size/space limited by PHP, site settings
• Grouped into folders by date:
• wp-content/uploads/2012/10/file.jpg
• files/2012/10/file.jpg
oEmbed
• YouTube
• DailyMotion
• Vimeo
• Flickr
• Scribd
Check this out:
http://www.youtube.com/watch?v=nTDNLUzjkpg
Hooray!
Basic Roles• Administrator
• Editor
• edits pages, publishes others’ posts
• Author
• publishes their own posts
• Contributor
• submits their own posts to editor
• Subscriber
Posts vs. Pages• Posts
• date-based
• non-hierarchical
• categorized and tagged
• Pages
• hierarchical
Custom Fields, Taxonomies, and
Post Types
Custom Fields• Adding more information to posts
• Default input vs. custom meta boxes
• Examples: content audit notes
• Custom Meta Boxes class on GitHub
Taxonomies• Extra sets of categories and tags
• tags, people, locations, departments
• People
• Locations
• Departments
Taxonomies• Default taxonomies
• Categories
• Post Tags
• Menus
• Link categories
• Custom examples
• People
• Locations
• Departments
• Colleges
Custom Post Types
• Default post types
• Posts
• Pages
• Attachments
• Revisions
• Menu Items
• Custom examples
• Courses
• Faculty profiles
• Specimen inventory
• Reference catalogue
Post Types• Things that are not
• blog posts, news
• pages, information about your office
• Anything that needs to be catalogued and displayed separately
Course Post Type• Custom fields: arbitrary entry
• professor name
• phone
• course code
• Taxonomies: selecting items from a list
• college
• department
Feeds
Feed Clean URL
Basic /feed/feed/atom
Comments /comments/feed
Category(slug: news)
/category/news/feed
Tag(slug: book)
/tag/book/feed
Multiple Tags(slugs: book, dvd)
/tag/book+dvd/feed
Feed Clean URL
Author(nickname: Joe)
/author/joe/feed
Post Type(slug: course)
/feed/?post_type=course
Taxonomy(genre: mystery)
/genre/mystery/feed
Search Term(wordpress)
/feed/?s=wordpress
5 Minute Installation!
Unless your campus infrastructure sucks.
Basic Installation• Gather database information: name,
username, password
• Unzip files to server
• View in browser
• Fill in values
• Pass Go, collect $200
Network Setup• Decide: subdirectories or subdomains?
• Wildcard DNS is not required if you are not letting people sign up for new sites on their own.
• Users already in the system can be added to the new site.
• http://codex.wordpress.org/Create_A_Network
Domain Mapping• snoopy.wordpress.com ->
snoopycorp.com
• snoopy.webserver-1.school.edu -> snoopy.school.edu
• WordPress MU Domain Mapping
Network Sites
U ofFoo
LiberalArts
Science
Business
Agriculture
Law
Network Domains
U ofFoo
LiberalArts
Science
Business
Agriculture
Law
foo.edu
law.foo.edu
arts.foo.edubusiness.foo.edu
science.foo.edu
ag.foo.edu
Child Themes
ParentTheme
Law Child Theme
Arts Child ThemeBusiness Child Theme
Science Child Theme
Ag Child Theme
Campus Network
Colleges
Clubs
Administration
Blogs
Sports
Break
Themes
Basic Theme Setup• styles.css and index.php
• More specific files for each archive type:
• Single post, page, or custom post type
• Category and tag archives; custom taxonomies
• Date-based archives (day, month, year)
• functions.php turns on feature support; works like mini-plugin
• header.php, footer.php, sidebar.php -- basic includes
• comments.php
get_header()
Loopwhile (have_posts()): the_post(); the_title(); the_content(); comments_template();endwhile;
get_sidebar()
get_footer()
The Loop• while (have_posts()) ... endwhile;
• Translation:
• if the invisible query found posts, then for each post, print the following:
• the_title();
• the_content();
• etc.
Have Posts?
• What was requested?
• What was returned?
• How many posts were returned, and how many are displayed on this page?
global $wp_query;var_dump( $wp_query );
How this comes together...
• You click a category link on a post.
• Based on your permalink structure, WordPress knows you are requesting a list of posts in that category. It queries the database.
• It finds 53 posts. Your Reading setting says 20 per page.
• WordPress assembles the first 20 posts' data, plus links to two more pages.
Which template?• Which theme file is used?
• category-slug.php
• category-id.php
• category.php
• archive.php
• index.php
• See Show Template plugin
Advanced ThemesPage templates
Conditional tags
Multiple sidebars
Widget areas
Theme options
Editor styles
Tips:
handling subcategories without tons of files
conditional sidebars
Child Themes/* Theme Name: My Child Theme Description: A child of Parent Theme Version: 1.0 Author: Stephanie Leary Template: parent */ @import url(../parent/style.css); /* Overrides: */
Other Child Theme Files
• If template is present in child theme, it will be used instead of parent theme’s file
• BOTH functions.php files will be used
get_header()
Loopwhile (have_posts()): the_post(); the_title(); the_content(); comments_template();endwhile;
get_sidebar()
get_footer()
Child theme contains sidebar.php
get_header()
echo do_shortcode('[gallery]');get_sidebar(
)
get_footer()
Child theme contains page templateor loop template part
Theme Frameworks
• A complete theme with many options• Page templates• Specific archives• Many widget areas• SEO features
• custom fields for keywords• title filters• Genesis Google snippet preview
• Can be overridden by child themes
Building a Theme1.Craft your HTML structure2.Drop in WordPress template tags
• the_title()• the_content()• etc.
3.Move common elements into include templates• Header• Footer• Sidebars• Search form
Building a Theme4.Create widget areas5.Handle comments and comment
forms6.Don't forget 404.php!
Conditional TagsConditional ID Slug Title Array Other
is_single X X X X
is_sticky X
is_page X X
is_page_template Filename
is_category X X X X
in_category X
is_tag X X X
has_tag X X X
is_tax X X X
is_author X Username Nickname X
has_excerpt X
Conditional Tags
is_home is_search is_day is_feed is_404 is_comments_popup
is_front_page is_time is_month is_attachment is_trackback is_active_sidebar
is_archive is_date is_year is_singular is_preview is_admin
comments_open pings_open is_paged in_the_loop
Developing for WordPress
Hooks• Actions: places you can run your own
functions
• wp_head
• wp_footer
• Filters: things that can be altered with your own functions
• the_title
• the_content
Using Hooks
Excerpts for Pagesfunction excerpts_for_pages() {
add_post_type_support( 'page', 'excerpt' );
}
add_action( 'init', 'excerpts_for_pages' );
[rules]function the_rules( $atts ) {
return "These are the rules!";
}
add_shortcode( 'rules', 'the_rules' );
Capital P, dangit!function capital_P_dangit( $text ) {
return str_replace( 'Wordpress', 'WordPress', $text );
}
add_filter( ‘the_content’, ‘capital_P_dangit’);
add_filter( ‘the_title’, ‘capital_P_dangit’);
Admin Bar Linkfunction linkme( $admin_bar ){
$admin_bar->add_menu( array('id' => 'my-item','title' => 'My Item','href' => '#','meta' => array(
'title' => __('My Item'),
),));
add_action( 'admin_bar_menu', ‘linkme', 100 );
Settings API• Register settings
• form action=”options.php”
• update_option(‘foo’, ‘new value’);
• get_option(‘foo’);
Troubleshooting• define('WP_DEBUG', true);
• Debug Bar plugin
• View hooks
• See Nacin on debugging WordPress
Evaluating Themes and Plugins
• Search code for:
• base64()
• eval()
• include(../../wp-config.php)
• include(../../wp-load.php)
• Does it use updated libraries?
• wp_deregister_script( ‘jquery’ )
Evaluating Themes and Plugins
• Are wp_head() and wp_footer() missing?
• Does it insert links you can’t remove?
• Does it pester you for commercial upgrades?
Writing Secure Themes and
Plugins• Use the Settings API
• Check user capabilities
• Check nonces and referrers
• Validate user input
• Escape output
Developer References
• Mark Jaquith’s WordCamp Phoenix presentation
• Professional WordPress Plugin Development
Theme & Plugin Q&A
???
Performance and Security
Backing Up• WP DB Backup (single sites, database
only)
• Backup Buddy (network, database and files, $$)
Upgrading• Do it! (But back up first.)
• If the FTP Settings screen appears, add direct file method to your config file. (See Codex page on wp-config.php.)
• Upgrading via Subversion
Caching• WP Super Cache
• W3 Total Cache
• Hyper Cache
• Batcache
Security Precautions
• Make sure WP files are group-writeable, not world
• directories: 644 or 664
• files: 755 or 775
• Set up permalinks and caching, then make .htaccess not writeable
• Change admin username
• Change database table prefix from wp_
• Create a database user other than root
Security Precautions
• Move wp-config.php up one directory
• Limit administrators
• Use Members to create less privileged roles
• Prevent bogus login attempts with Login Lockdown
• Run WP Security Scan and Exploit Scanner
• Monitor filesystem with File Monitor Plus
More With WordPress
BuddyPressSocial Network Layer
BuddyPress• Campus wide social network
• Company-wide internal communication tool
• Niche social network for interest topic
BuddyPress Plugins
• Welcome Pack
• Achievements
• BuddyPress Share It
• Group Suggest Widget
• Simple Google Map Plugin
ScholarPressA Learning Management System for
BuddyPress
Content Audit"Now we’re talking real CMS capability!"
The WordPress Community
Development Philosophy
• 2.9, 3.0, 3.1, 3.5 are all major releases.
• 3.3.1 is a bugfix and security update.
• Old releases do not get security updates.
• Core developers set feature agenda for major releases based on Trac tickets, known problems, and user surveys.
Development Philosophy
• Development schedule kept on make.wordpress.org/core.
• Meetings once a week in #wordpress-dev.
• If it can be covered by a plugin, let it. Core is for features most people need, or frameworks developers can build on.
• If you want it fixed sooner, patch it yourself.
Documentation• Codex
• Forum
• WP StackExchange
• Trac
• Developers’ blogs
Support• Active user forums on wordpress.org
• Individual plugin & theme developers
• Groups on LinkedIn
• huge Twitter population
• IRC channels
Support• VIP Automattic (core creators)
• Third party vendors such as MUSupport.net
• Core developers are also consultants
• WP-only hosts
• WP Engine
• Page.ly
• Sucuri.net security specialists
DiscussionIRC channels
• #wordpress
• #wordpress-dev
• #buddypress
• #bbpress
Mailing Lists
• WP-Hackers
• WP-Edu
wp-edu.org
Development blogs
• make/core
• make/ui
• make/themes
• make/accessibility
• make/wppolyglots
News EventsWordCamps
• San Francisco
• New York
• local: central.wordcamp.org
• WP Candy
• Planet WordPress
• wpMail.me
• wpBeginner
• wpTuts
Making the Case for WordPress
LAMP vs. IIS 7• mod_rewrite
• .htaccess
• PHP-FPM
• Postfix
• URL Rewrite 1.1
• PHP running as FastCGI
Nginx
Open Source vs. Commercial
Open Source
Low or no initial budget outlay
Premium support options available
Variety of custom development options--------------------------------Shelley launched in 2009 with $2k
Commercial
High startup costs
Enterprise support contracts available
Often contracted to the CMS company for customization
-------------------------------Texas 2yr launching OmniUpdate this year: $52k+
Importing• Many importers other than built-in list
• Writing your own MySQL-based import
• HTML Import
• Merging single installs into networks
Q&A
Demos?• Network administration• Plugins
• BuddyPress• Content Audit• HTML Import