wordpress architecture ► core files – php ► mysql database configured by the installation...

12
WordPress Architecture WordPress Architecture Core files – PHP Core files – PHP MySQL database MySQL database Configured by the installation script Configured by the installation script wp-content directory wp-content directory themes subdirectory: layout themes subdirectory: layout plugins subdirectory: extensions plugins subdirectory: extensions uploads subdirectory: uploaded files uploads subdirectory: uploaded files Version updates relatively painless Version updates relatively painless

Upload: alexander-oneal

Post on 02-Jan-2016

230 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: WordPress Architecture ► Core files – PHP ► MySQL database  Configured by the installation script ► wp-content directory  themes subdirectory: layout

WordPress ArchitectureWordPress Architecture

►Core files – PHPCore files – PHP►MySQL database MySQL database

Configured by the installation scriptConfigured by the installation script

►wp-content directorywp-content directory themes subdirectory: layout themes subdirectory: layout plugins subdirectory: extensionsplugins subdirectory: extensions uploads subdirectory: uploaded filesuploads subdirectory: uploaded files

►Version updates relatively painlessVersion updates relatively painless

Page 2: WordPress Architecture ► Core files – PHP ► MySQL database  Configured by the installation script ► wp-content directory  themes subdirectory: layout

Presentation: Choose a Presentation: Choose a ThemeTheme

Current ThemeCurrent Theme

Default ThemesDefault Themes

100’s available100’s available

Administrator’s ViewAdministrator’s View

Page 3: WordPress Architecture ► Core files – PHP ► MySQL database  Configured by the installation script ► wp-content directory  themes subdirectory: layout

Theme ArchitectureTheme Architecture

►Set of files installed in a subdirectory Set of files installed in a subdirectory of wp-content/themesof wp-content/themes

►Typical theme set includesTypical theme set includes style.css and required imagesstyle.css and required images PHP template files defining parts of the pagesPHP template files defining parts of the pages

►header, footer, sidebar, commentsheader, footer, sidebar, comments

PHP template files defining entire pagesPHP template files defining entire pages►Runtime selection based on Runtime selection based on template hierarchytemplate hierarchy►Can also set page template when creating the pageCan also set page template when creating the page

Administrator’s ViewAdministrator’s View

Page 4: WordPress Architecture ► Core files – PHP ► MySQL database  Configured by the installation script ► wp-content directory  themes subdirectory: layout

Template ArchitectureTemplate Architecture

►Not Smarty Not Smarty But does serve to separate content But does serve to separate content

generation from presentationgeneration from presentation

►Dozens of predefined tagsDozens of predefined tags Simple example: get_header()Simple example: get_header()

►Called “tags,” but most are functionsCalled “tags,” but most are functions Example: list categoriesExample: list categories

►list_cats() – 18 positional parameterslist_cats() – 18 positional parameters►wp_list_cats() – arguments as name/value pairswp_list_cats() – arguments as name/value pairs

Administrator’s ViewAdministrator’s View

Page 5: WordPress Architecture ► Core files – PHP ► MySQL database  Configured by the installation script ► wp-content directory  themes subdirectory: layout

Editing TemplatesEditing Templates

Administrator’s ViewAdministrator’s View

Page 6: WordPress Architecture ► Core files – PHP ► MySQL database  Configured by the installation script ► wp-content directory  themes subdirectory: layout

Example template: page.phpExample template: page.php

<?php get_header(); ?><?php get_header(); ?>

<?php if (have_posts()) : while (have_posts()) : the_post(); ?><?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<h2 id="post-<?php the_ID(); ?>"><?php the_title(); ?<h2 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h2>></h2>

<?php the_content(__('Read the rest of this page <?php the_content(__('Read the rest of this page &raquo;')); ?>&raquo;')); ?>

<?php wp_link_pages(); ?><?php wp_link_pages(); ?>

<?php edit_post_link(__('Edit'), '<p>', '</p>'); ?><?php edit_post_link(__('Edit'), '<p>', '</p>'); ?>

<?php endwhile; endif; ?><?php endwhile; endif; ?>

<?php get_sidebar(); ?><?php get_sidebar(); ?>

<?php get_footer(); ?><?php get_footer(); ?>

Administrator’s ViewAdministrator’s View

Page 7: WordPress Architecture ► Core files – PHP ► MySQL database  Configured by the installation script ► wp-content directory  themes subdirectory: layout

►get_headerget_header►get_sidebarget_sidebar►the_titlethe_title►the_contentthe_content►edit_post_liedit_post_li

nknk►get_footerget_footer

Page 8: WordPress Architecture ► Core files – PHP ► MySQL database  Configured by the installation script ► wp-content directory  themes subdirectory: layout

Digression: The LoopDigression: The Loop

Administrator’s ViewAdministrator’s View

<?php if (have_posts()) : while (have_posts()) : the_post(); ?><?php if (have_posts()) : while (have_posts()) : the_post(); ?>

……..

<?php endwhile; endif; ?><?php endwhile; endif; ?>

►Applies to “WordPress Pages” as well as Applies to “WordPress Pages” as well as “pages” that display “WordPress Posts”“pages” that display “WordPress Posts”

►Many tags to control what happens insideMany tags to control what happens inside is_category()is_category() is_page()is_page() More More conditional tagsconditional tags

Page 9: WordPress Architecture ► Core files – PHP ► MySQL database  Configured by the installation script ► wp-content directory  themes subdirectory: layout

Extensibility: PluginsExtensibility: Plugins

Administrator’s ViewAdministrator’s View

Page 10: WordPress Architecture ► Core files – PHP ► MySQL database  Configured by the installation script ► wp-content directory  themes subdirectory: layout

Sample Plugin: Hello, DollySample Plugin: Hello, Dolly

Administrator’s ViewAdministrator’s View

$lyrics = explode("\n", $lyrics);$lyrics = explode("\n", $lyrics);

$chosen = wptexturize( $lyrics[ mt_rand(0, count($lyrics) ) ] );$chosen = wptexturize( $lyrics[ mt_rand(0, count($lyrics) ) ] );

function hello_dolly() {function hello_dolly() {

global $chosen;global $chosen;

echo "<p id='dolly'>$chosen</p>";echo "<p id='dolly'>$chosen</p>";

}}

add_action('admin_footer', 'hello_dolly');add_action('admin_footer', 'hello_dolly');

function dolly_css() {function dolly_css() {

echo "<style type='text/css'>echo "<style type='text/css'>

#dolly { … style attributes … }#dolly { … style attributes … }

</style>";</style>";

}}

add_action('admin_head', 'dolly_css');add_action('admin_head', 'dolly_css');

Page 11: WordPress Architecture ► Core files – PHP ► MySQL database  Configured by the installation script ► wp-content directory  themes subdirectory: layout

““Hello, Dolly” in actionHello, Dolly” in action► Before activationBefore activation

► After activationAfter activation

Administrator’s ViewAdministrator’s View

Page 12: WordPress Architecture ► Core files – PHP ► MySQL database  Configured by the installation script ► wp-content directory  themes subdirectory: layout

Customizing Your SiteCustomizing Your SiteOther OptionsOther Options

Links

Quotes

Calendar

RSS Feeds Book List