PHP W ORD P RESS C USTOMIZATION Take the Good Parts, Then Bend It To Your Will By David F. Carr

Slides:



Advertisements
Similar presentations
WordPress Installation for Beginners Sheila Bergman
Advertisements

PHP: Date() Function The PHP date() function formats a timestamp to a more readable date and time.
JQuery MessageBoard. Lets use jQuery and AJAX in combination with a database to update and retrieve information without refreshing the page. Here we will.
WordPress from Start to Finish Day 1: Installing and Using WordPress Looking at the WordPress database.
© 2012 Entrinsik, Inc. Informer Administration Exploring the system menu and functions PRESENTER: Jason Vorenkamp| Informer Software Engineer| March 2012.
USING WORDPRESS. WEEK 1 1.Why WP? 2.Setting Up WP 3.Exploring the Admin screen 4.Page Organization 5.Posting 6.Polls.
Accessible WordPress Theme Development AccessU 2011 Pat Ramsey slash25 code
1.  Understanding about How to Working with Server Side Scripting using PHP Framework (CodeIgniter) 2.
Seattle Drupal Clinic Introduction to Drupal and Web Content Management.
Easy Website Creation Using WordPress Welcome and Thank You to our Sponsors.
Content Management, Working with WordPress Pavel Ivanov Telerik Corporation
Content Management, Working with WordPress Svetlin Nakov Telerik Corporation
WPML Translation plugin is the best option when you need to translate your Wordpress website into multiple languages. The plugin makes it easy to translate.
Creating Wordpress Plugins. Who is Here? PHP GTA Meetup Wordpress Toronto Meetup East Toronto Web Design Meetup.
Wordpress as a content management system Building a better website with content management systems | June 12, 2009.
Server-Side vs. Client-Side Scripting Languages
INSTALLATION OF WORDPRESS. WORDPRESS WordPress is an open source CMS, often used as a blog publishing application powered by PHP and MySQL. It has many.
Drupal Create a website/web app quickly with this Content Management System Jiaying Xu Spring 2011 COMS E6125 Web-enHanced Information.
Final Presentation WordPress 3.0+ Leonard Bogdonoff 12/6/11 T. DEDONNO CIM225.
Content Management, Working with WordPress Svetlin Nakov Telerik Corporation
Getting an account with WordPress.com Open your web browser ( mozilla firefox, internet explorer, opera, etc.,)
Build a WordPress theme from HTML5 template Mario Peshev Devrix Devrix OnTheGo OnTheGo.
Wordpress Tutorial 22 – 24 April Table of Contents Introduction Designing blog Writing and Publishing blog Pages Posts Categories Tags Links Comments.
November 3, 2011 Deborah de Bruin Building Digital Libraries.
Drupal Workshop Introduction to Drupal Part 1: Web Content Management, Advantages/Disadvantages of Drupal, Drupal terminology, Drupal technology, directories.
Basics of Administration & Theming - Smarajit Dasgupta.
© 2012 Boise State University1 WordPress Training February 14, 2013.
WordPress Web. WordPress Blogging system with full content management Personal publishing system Built on PHP scripting language and MySQL relational.
#psuweb13 WORDPRESS THEMES 101 A WORDPRESS THEME INTRO WORKSHOP.
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
WaveMaker Visual AJAX Studio 4.0 Training Troubleshooting.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Dynamic Action with Macromedia Dreamweaver MX Barry Sosinsky Valda Hilley.
Advanced Web 2012 Lecture 12 Sean Costain Course Summary Sean Costain 2012 To develop skills in web design and authoring  Html 5 / CSS 3 / PHP.
© 2012 Boise State University1 WordPress Training February 14, 2013.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
Google Analytics for Small Business Presented by: Keidra Chaney.
WordPress Plugin Development A Starter Guide For Beginners.
WordPress Architecture ► Core files – PHP ► MySQL database  Configured by the installation script ► wp-content directory  themes subdirectory: layout.
Seattle Drupal Clinic Introduction to Drupal Part 1: Web Content Management, Advantages/Disadvantages of Drupal, Drupal terminology.
Communicating with staff. Objectives that will be covered: 1.Setting up the staffroom communitySetting up the staffroom community 2.Sharing documents.
Post-Module WordPress Plugins BTM 395: Internet Programming.
Advanced Web 2012 Lecture 11 Sean Costain 2012.
Unit 13 –JQuery Basics Instructor: Brent Presley.
#eduguruSummit WORDPRESS THEMES 101 SOME SIMPLE STARTER TIPS FOR WORDPRESS THEMES dotEduGuru Summit 2013.
National Aeronautics and Space Administration TablePress Evaluation & Section 508 Accessible Tables with Visual Editor WP Workshop, 3/19/2014.
+ Publishing Your First Post USING WORDPRESS. + A CMS (content management system) is an application that allows you to publish, edit, modify, organize,
Intro to APACHE, MySQL, and PHP & freely available (hackable) Packages Aonghus Sugrue 04 Oct 2012.
Embedding a Video, Image or Other Content Another way to add video or other content into your pages is through embedding. A popular example of this is.
Workshop Partner:. Saad Amin Cofounder and CTO Inspire Chittagong Cofounder & Managing Director Codework Builders and Assets Ltd.
How to use Drupal Awdhesh Kumar (Team Leader) Presentation Topic.
Learn What’s New in WordPress4.0 Presented by: SunTecOSS.
Introduction To Simple WordPress Plugin Development
Intro to WordPress (Using XAMPP)
Developing WordPress Plugins
How to use.
CONTENT MANAGEMENT SYSTEM CSIR-NISCAIR, New Delhi
Ultimate Guide to WordPress Plugin Development
PHP Training at GoLogica in Bangalore
WordPress Development
WordPress Plugin Development
Build a WordPress theme from HTML5 template
Easy Website Creation Using WordPress
Title: Tech Training Certificate: Ace of Initiative Program
WordPress Development
How to Maintain Your ARS Websites
Consult America Technology Consulting Services
Chapter 7 Searching Your Products
Wordpress test.cs.edinboro.edu.
Doing AJAX in WordPress
WordPress Development
Presentation transcript:

PHP W ORD P RESS C USTOMIZATION Take the Good Parts, Then Bend It To Your Will By David F. Carr

S ELF I NTRODUCTION Freelance writer, editor, and web consultant Write for Forbes.com on cloud computing, technology for small to midsize businesses Technology Editor for WebWeek / Internet World Magazine in1990s, Baseline Magazine Webmaster for small businesses, community organizations, political campaigns WordPress replaced a lot of custom hacks Will mostly be talking about plugins to modify the behavior of the system

O VERVIEW Why start with WordPress? A Plugin Is Just PHP, a Theme Is PHP/CSS JavaScript / AJAX, too Files, system load, and The Loop Hooking into Filters and Actions Customizing the admin screens Customizing the front end Creating a custom post type Where to learn more

W HEN A P LUGIN M AKES Y OU P OPULAR

W HY S TART W ITH W ORD P RESS ? Faster than starting from a clean sheet of paper (blank screen of code) Content management for blogs, web pages SEO friendly Availability of vast array of free themes and plugins, plus commercial options Lots of tutorial material Strong developer community

A P LUGIN I S J UST PHP

A NATOMY OF A T HEME Themes have a similar header in style.css. Theme loads index.php (or page.php, single.php, archive.php) to execute “the loop.” Each also loads header.php, footer.php, and usually sidebar.php

T HE L OOP

G LOBALS AND L OOKUP F UNCTIONS site_url() admin_url() content_url() or WP_CONTENT_URL plugins_url() or WP_PLUGIN_URL includes_url() home_url() WP_PLUGIN_DIR WP_CONTENT_DIR ABSPATH – directory including trailing / None of the rest include trailing / So $url = plugins_url(). /demo/report.php

M ORE G LOBALS, C ONDITIONAL F UNCTIONS Need to use global keyword at top of function to access global $wpdb – database object global $post $post-ID, $post->post_type global $current_user $current_user->first_name Conditional functions is_user_logged_in() is_single() or is_single(10) is_page or is_page(10) or is_page('about_us') is_admin() – is this an admin page?

W ORD P RESS F ILE H IERARCHY The wp-content directory has subdirectories for plugins and themes The index.php in web root loads the system, loads activated plugins and themes Plugins: functionality Themes: look and feel functions.php – theme-specific behavior

H OOKING I NTO W ORD P RESS Core WordPress API built around 2 kinds of hooks: Filter hooks – intercept some bit of content, modify it, return it. Mostly UI but also some back end filters. A filter on ‘the content’ modifies the content of a post. A filter on ‘posts_orderby’ modifies the ORDER BY clause in the SQL for retrieving posts. Action hooks – triggered by an event in WordPress initialization or loading of template files. The ‘init’ action comes after database is loaded but before page display starts. Can be used to act on a $_POST, then redirect. The ‘wp_header’ and ‘wp_footer’ actions called from header.php and footer.php output custom content Other actions specific to admin screens, like ‘admin_menu’

K EY A CTIONS P UBLIC P AGE muplugins_loaded plugins_loaded setup_theme load_textdomain set_current_user init wp_loaded parse_request send_headers parse_query pre_get_posts posts_selection wp template_redirect wp_head wp_enqueue_scripts wp_print_styles wp_print_scripts loop_start the_post loop_end get_sidebar wp_footer wp_print_footer_script s shutdown

S AMPLE F ILTERS wp_title (page title) the_title (post title) the_content the_content_feed the_excerpt the_excerpt_rss the_category the_tags the_time the_date the_weekday comment_text comment_save_pre the_editor_content wp_list_pages save_post wp_insert_post_data login_redirect cron_schedules mce_css (rich text editor) posts_request posts_join posts_orderby posts_where

M ODIFYING A DMIN S CREENS The Default Dashboard

C USTOM D ASHBOARD

C USTOM A DMIN M ENUS

F UNCTION TO OUTPUT MENU PAGE

A DMIN D ATA E NTRY P AGE

N ONCE S ECURITY N umber used once Make sure requests coming from authenticated user with unique code $nonce= wp_create_nonce ('my-nonce'); wp_nonce_field("qday","qnonce") is the same as: ”> Test: Code: if(wp_verify_nonce($_POST["qnonce"], "qday") )

C ATCHING $_POST AT INIT / ADMIN - INIT

P ROCESS, T HEN R EDIRECT Separate UI from server processing Helps avoid double-submit issues Redirect with different parameters for success / failure Exit after redirect Similar pattern can be used for AJAX (echo json, then exit)

W RAPPER F UNCTIONS F OR WP D ATABASE Create a post with code using wp_insert_post Retrieve and change settings using get_option and update_option

S ETTINGS API

T HE W ORD P RESS D ATABASE

D ATABASE P ROGRAMMING WITH W ORD P RESS Global $wpdb data access object Get results with $wpdb->get_results Get row with $wpdb->get_row Format/quote SQL with $wpdb->prepare

I NSERT / U PDATE Remember security Check nonce Filter values Compensate for “magic quotes” with $postdata = array_map( 'stripslashes_deep', $_POST ); Use $wpdb->prepare to quote properly Execute insert / update with $wpdb->query($sql)

DB P ROGRAMMING P ITFALLS Forgetting to declare $wpdb as global Use ARRAY_A parameter to get associative array from $wpdb->get_results or $wpdb- >get_row if you want results to be accessible as $row["field_name"] Default is object format $row->field_name Use $wpdb->show_errors() to debug SQL Return value from $wpdb->query is false on error, or number of rows affected (could be 0) Test for error: if($return_value == false) echo ‘error’;

A LLOW F OR A LTERNATE T ABLE N AMES Default table names like wp_posts can have alternate prefixes, so use $wpdb->posts instead Custom table $wpdb->prefix. "rsvpmaker"

S HORTCODES Placeholder codes site editors can include in pages and posts Standard: [embed] Custom: [demotag title="Date" date="r"] Date in RFC822 Format [/demotag]

C ONTACT F ORM E XAMPLE Use a shortcode to display form Process $_POST on ‘init’ then redirect Use JavaScript jQuery library to enhance

E NQUEUE B UNDLED / C USTOM J AVA S CRIPT Load scripts in right order with wp_enqueue_script Register custom scripts, dependencies with wp_register_script

J Q UERY AND F RIENDS “No Conflict” mode so start with jQuery(document).ready(function($) Warning: Textbook jQuery examples usually start with this shortcut: $(document).ready(function()

L IVE E XAMPLE - RSVPM AKER

C REATING A C USTOM P OST T YPE Add a content type that can use common editing controls but be organized separately

E DITING S CREEN W ITH C USTOM O PTIONS Standard formatting / uploading controls Custom panels: add_meta_box Process $_POST on save_post action Save custom data: update_post_met a

C USTOM D ISPLAY FOR C USTOM P OST T YPE Filter ‘the_content’, check post type, look up and format dates for events, display form if is_single() otherwise show RSVP Now! button

S UMMARY WordPress provides a foundation / framework Create / customize themes to change look and feel Download or create your own plugins to alter WordPress system behavior Filters hooks alter content, return results Action hooks triggered by initialization stages, function calls in theme templates, administration screen access Create your own administration reports / data entry screens. Use wrapper functions and $wpdb global to update DB Use shortcodes, filters, output functions for JavaScript and CSS to enhance public website

F OLLOW U P Recommended book: WordPress Plugin Development – Beginner’s Guide by Vladimir Prelovac Presentation/Code/Links: plugins/ plugins/ Developer documentation codex.wordpress.orgcodex.wordpress.org Forums wordpress.org/support/wordpress.org/support/ Mailing lists (wp-hackers etc.) lists.automattic.com lists.automattic.com