Pearkins received one of UBC's first Computer Science degrees in 1974, then held technical and management positions in Edmonton's I.T. community until he retired in 2007. Since then, he has added 7 WordPress Plugins to the Plugin Directory, answered 1200 Support Forum questions, and volunteers as web- master and technical hosting guru for 6 web sites, having built his first web site in 1995.
is software written in the PHP computer programming language. English is the language used for PHP instructions and comments embedded by the WordPress developers. Knowledge of English and PHP lets you do a lot more with WordPress. Without it, you can still create a nice web site using WordPress, if you know and accept some limitations.
By my count, there are eight levels of WordPress web site development activities. They are numbered based on the amount of PHP and associated technical knowledge required to accomplish each. In fact, the first three can usually be done quite successfully without any such knowledge. Most Levels include tips on reducing Risk.
Just like written English, PHP has words and punctuation. And rules about how to put those words and punctuation together. We will cover the basics. And some common mistakes to avoid. There are lots of free software tools and information sources that will help get you started, and soon become friends for life.
sites, from HTML to PHP • HTML • Style language and Cascading Style Sheets (.css) • JavaScript reacts instantly on your browser • PHP generates each web site page's HTML, Style and Javascript specifically for each web site visitor, based on his or her individual needs • .php files, not .html files
Out of the Box 2. Using a Theme not written by WordPress 3. Installing Plugins 4. Writing a Child Theme 5. Writing a Shortcode 6. Changing a Plugin 7. Writing Your Own Plugin 8. Writing Your Own Theme
and settings provided by the WordPress Core • The WordPress Core keeps growing • Six Themes to choose from, with a seventh on the way: Twenty Thirteen Twenty Twelve Twenty Eleven Twenty Ten Classic Default Twenty Fourteen – available next year
define the look of your site, some add new functionality/features, while others are specialized, e.g. - Real Estate listings • Over two thousand free themes in the WordPress Theme Directory • Thousands more, including a few Free ones, available elsewhere on-line • Some Paid sites are just “Front Men” for independent authors, taking no responsibility
• Nearly 30,000 free plugins in the WordPress Plugin Directory, though thousands do not work with the current version of WordPress • More, including a few Free ones, available elsewhere on-line, some by Theme authors to add functionality to their Themes • Some free plugins are used to sell paid plugins
• Different Admin or Visitor Usage exposes bug • A published security issue invites Hackers • The next version of the Plugin or Theme • The next version of WordPress • Changes to your web hosting software • Conflict with another Plugin or Theme
• Finding the Guy or Girl who wrote it – moved on AKA “Abandoned Plugins/Themes” • Author lacks the time, interest or knowledge • DIY: find a fix on-line or figure it out yourself • Paid Themes and Plugins are no guarantee; some argue they are, in fact, a bigger risk
from the WordPress Plugin and Theme Directories: • Number of Downloads, both total and recent • Review Recent Support threads – Author responds? How helpful are the responses? • Supports your WordPress Version? – Only listed for Plugins in WordPress directories • Date last updated
directly modify a Theme; you will lose your changes when the Theme is updated • Create a Child Theme instead • Cross-Browser Testing is Essential • The scope of the changes to the Theme determines the required knowledge of PHP, CSS (Style definitions), HTML and WordPress Theme structure
brackets • [gallery] shows images attached to a Post/Page • Shortcodes insert PHP into a Page, Post or, using Widgets, into a Sidebar, Header or Footer • Shortcodes are normally defined by writing your own Plugin, but.... • the Shortcode Exec PHP plugin provides a Tools page in WordPress Admin panels where Shortcodes can be defined
the sense of doing exactly what you need • Getting the Plugin Author to change the next version of the plugin is often impossible • Looking at the plugin's files is the only way to know how difficult making the changes will be, as plugins vary in size from 10 to 10,000 lines • Archive all the plugin files BEFORE and AFTER you make the changes, for later reference • Test thoroughly, preferably on a test web server
Directory • Custom functionality just for your web site(s) • The best way to tightly integrate an App into any WordPress-powered web site • Success or Failure often depends on Timing: most Plugins are mainly Event Driven, e.g. - triggered just before the Footer is displayed • WordPress Action and Filter Hooks knowledge
Everything you need to know to write a complex Plugin, plus another layer of knowledge • Cross Browser Testing is the Key to Success – Only exception: if all Site Visitors use the same browser and browser version • But coding with multiple browsers and devices in mind is an essential part of that body of knowledge required to write a Theme
every different version of every different browser on every different device? – Internet Explorer, Firefox, Chrome, Safari, ... – Desktop, Laptop, Tablet, SmartPhone, ... – iPhone, Android, WindowsPhone, ... – Screen resolutions and Browser Window widths
Lab – Virtual Machine on one computer with some tablets and smartphones • Use an on-line Cross Browser Testing service – Probably need one each for traditional workstations and mobile devices • Combination probably works best
Just like written English, PHP has words and punctuation. And rules about how to put those words and punctuation together. We will cover the basics. And some common mistakes to avoid. There are lots of free software tools and information sources that will help get you started, and soon become friends for life.
can code HTML, including embedded JavaScript and Style statements, just as you would in a .html file. No PHP code allowed. • <?php switches to PHP mode, where only valid PHP statements can be coded. • ?> switches to HTML mode
Level 1 heading: echo '<h1>'; • Every PHP statement ends with a semi-colon “;” • Quotes and brackets must match – opening and closing: ' ', " ", { }, [ ], ( ) – must be the same type
commonly known as Values • $start is a variable called “start” • global $start; indicates that $start is available to all functions and .php files that also contain a global $start; statement • DEFINE( 'START', 1 ); defines a global constant with a value of One
$start of type Integer and Value of One? • Two == $start == 1 Is $start a String or Number type of value One? • One = $start = 1 // $start is set to One Set $start to type Integer and Value of One.
if ( $start = 1 ) is always wrong In fact, WordPress Coding Standards would have you write it, correctly, as: if ( 1 === $start ) Because, if you miswrote it with one =, it would fail if ( 1 = $start ) generates an error message
$low, $high ) { return ( $var >= $low ) && ( $var <= $high ); } function doesn't do anything until you actually use the function you have just defined: if ( between( $month, 1, 12 ) ) { echo 'valid month'; Note: function sometimes defined after it is used
to anyone reading their PHP code /** * Add the WordPress logo menu. * * @param WP_Admin_Bar $wp_admin_bar */ function wp_admin_bar_wp_menu( $wp_admin_bar ) { // Add WordPress.org link $wp_admin_bar->add_menu( array(
reference manual • http://codex.wordpress.org/Function_Reference lists the PHP functions that WordPress adds, some of which are known as Template Tags because they are used in Themes • http://codex.wordpress.org is the official WordPress documentation