WordPress Development at PHP Quebec - Nov 2009
Upcoming SlideShare
Loading in...5
×
 

WordPress Development at PHP Quebec - Nov 2009

on

  • 5,196 views

Is WordPress PHP? We will look at how WP uses PHP, discuss what Template tags are and how to extend them. We will also convert a basic PHP function into a WP Plugin.

Is WordPress PHP? We will look at how WP uses PHP, discuss what Template tags are and how to extend them. We will also convert a basic PHP function into a WP Plugin.

Statistics

Views

Total Views
5,196
Views on SlideShare
5,106
Embed Views
90

Actions

Likes
3
Downloads
51
Comments
0

5 Embeds 90

http://dropthedigibomb.com 52
http://annefrancis.biz 29
http://www.slideshare.net 4
http://digibombinc.com 4
http://swazzy.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

WordPress Development at PHP Quebec - Nov 2009 WordPress Development at PHP Quebec - Nov 2009 Presentation Transcript

  • Development PHP Quebec – November 09 Gathering
  • full-time now!
  • What is ? We’ll skip the basics and head straight to the code…. … if you’re interested you can check out Some of my other presentations later http://digibombinc.com/events
  • Getting started
  • What you need PHP version 4.3 or greater MySQL version 4.0 or greater Creativity and Passion
  • Theming
    • Create or download a Photoshop design. Create a static HTML+CSS template of each page .
  • Theming
    • Why Create a Static HTML File First?
    • Mainly because it will make the development process a lot
    • easier. I usually create a HTML file for every template that I
    • need, test it across all browsers, validate both HTML and CSS
    • markups, then all I have to do is cut & paste the WordPress
    • code. By doing so, I don’t have to worry about HTML or CSS
    • bugs during my theme making process.
  • Yes, I know, this is PHP Quebec… Ok, back to the code.
  • Templating How it all works If you go the default theme folder ( wp-content/themes/default ), you will see many PHP files (these are template files) and one style.css file. When you are viewing the front page, WordPress actually uses several template files to generate the page ( index.php << header.php , sidebar.php , and footer.php ).
  • Templating The front page
  • Templating Splitting the file
  • Templating Let’s start with the Template System Template Tags Conditional Tags PHP Function Calls
  • Templating <?php // syntax #1: curly braces if ( condition to check ){ // code to execute if the condition is true } // syntax #2: colon and endif if ( condition to check ): // code to execute if the condition is true endif; ?> <?php if ( is_home() ): ?> <h3>Main Page</h3> <?php elseif( is_archive() ): ?> <h3>Archives Page</h3> <?php else: ?> <h3>Welcome to my blog!!</h3> <?php endif; ?> Standard PHP WordPress
  • Templating Template Tags Include tags
    • get_header
    • get_sidebar
    • get_search_form
    • comments_template
    • get_footer
    Blog info tags
    • bloginfo
    • bloginfo_rss
    • get_bloginfo
    • get_bloginfo_rss
    Lists & Dropdown tags
    • wp_list_authors
    • wp_list_categories
    • wp_list_pages
    • wp_list_bookmarks
    • wp_list_comments
    • wp_get_archives
    • wp_page_menu
    • wp_dropdown_pages
    • wp_dropdown_categories
    • wp_dropdown_users
    Login/Logout tags
    • is_user_logged_in
    • wp_login_url
    • wp_logout_url
    • wp_lostpassword_url
    • wp_registration_url
    • wp_logout
    • wp_loginout
    • wp_register
    Post tags
    • the_ID
    • the_title
    • the_title_rss
    • the_title_attribute
    • single_post_title
    • the_content
    • the_content_rss
    • the_excerpt
    • the_excerpt_rss
    • wp_link_pages
    • posts_nav_link
    • next_post_link
    • next_posts_link
    • previous_post_link
    • previous_posts_link
    • next_image_link
    • previous_image_link
    • sticky_class
    • the_category
    • the_category_rss
    • the_tags
    • the_meta
    Comment tags
    • wp_list_comments
    • comments_number
    • comments_link
    • comments_rss_link
    • comments_popup_script
    • comments_popup_link
    • comment_ID
    • comment_id_fields
    • comment_author
    • comment_author_link
    • comment_author_email
    • comment_author_email_link
    • comment_author_url
    • comment_author_url_link
    • comment_author_IP
    • comment_type
    • comment_text
    • comment_excerpt
    • comment_date
    • comment_time
    • comment_form_title
    • comment_author_rss
    • comment_text_rss
    • get_avatar
    • permalink_comments_rss
    • comment_reply_link
    • cancel_comment_reply_link
    • previous_comments_link
    • next_comments_link
    • paginate_comments_links
  • Templating Template Tags Category tags
    • the_category
    • the_category_rss
    • single_cat_title
    • category_description
    • wp_dropdown_categories
    • wp_list_categories
    Tag tags
    • the_tags
    • tag_description
    • single_tag_title
    • wp_tag_cloud
    • wp_generate_tag_cloud
    Author tags
    • the_author
    • the_author_link
    • the_author_posts
    • the_author_posts_link
    • the_author_meta
    • wp_list_authors
    • wp_dropdown_users
    Date and Time tags
    • the_time
    • the_date
    • the_date_xml
    • the_modified_time
    • the_modified_date
    • the_modified_author
    • single_month_title
    Edit Link tags
    • edit_post_link
    • edit_comment_link
    • edit_tag_link
    • edit_bookmark_link
    Permalink tags
    • permalink_anchor
    • get_permalink
    • the_permalink
    • permalink_single_rss
    Links Manager tags
    • wp_list_bookmarks
    • get_bookmarks
    • get_bookmark
    • get_bookmark_field
    Trackback tags
    • trackback_url
    • trackback_rdf
    Title tags
    • wp_title
    • single_post_title
    • single_cat_title
    • single_tag_title
    • single_month_title
    • the_search_query
    Query tags
    • get_posts
    • query_posts
  • Templating The Loop The Loop is used to display posts and it also lets you control what to display. Basically, The Loop checks if there are posts in your blog, while there are posts, display it, if no post found, say &quot;Not Found&quot;.
  • Templating A complete template In this example we are using some standard Template Tags to display the title of the post the_title() and we are linking it using the_permalink() . We call use the_date() and display the_content() . Finally for fun we call link_pages() .
  • Templating Playing with the code <?php wp_list_categories('show_count=1&title_li=<h2>Categories</h2>'); ?> Most blogs display categories somewhere, usually the side bar. The easiest way to do this is with the wp_list_categories() Template Tag.
  • Templating Playing with the code <ul> <li id=&quot;categories&quot;> <?php wp_dropdown_categories('title_li=&hierarchical=0&show_count=1&child_of=9'); ?> <script type=&quot;text/javascript&quot;> <!-- var dropdown = document.getElementById(&quot;cat&quot;); function onCatChange() { if ( dropdown.options[dropdown.selectedIndex].value > 0 ) { location.href = &quot;<?php echo get_option('home'); ?>/?cat=&quot;+dropdown.options[dropdown.selectedIndex].value; } } dropdown.onchange = onCatChange; --> </script> </li> </ul> What if I wanted to display specific categories and have them in a dropdown box? * See the full tutorial at dropthedigibomb.com
  • Templating Playing with the code <?php if(is_page(&quot;landing&quot;)) : ?> <h5 class=&quot;tagline&quot;> Hello! I'm Brendan Sera-Shriar A.K.A. <span class=&quot;blue&quot;>digibomb</span>, a freelance web designer from Montreal, Canada. </h5> <?php elseif(is_page(&quot;work&quot;) || is_page(&quot;branding&quot;) || is_page(&quot;other-projects&quot;) || is_page(&quot;client-list&quot;)) : ?> <h5 class=&quot;tagline&quot;> I don't just build <span class=&quot;blue&quot;>websites</span> I build <span class=&quot;blue&quot;>communities</span>! </h5> <?php endif; ?> What if I wanted to display different taglines on each page? * See it in action at digibombinc.com
  • Theming
    • Loop Resources
    • The Loop in Action
    • Template Tags
    • Using the Loop in Template Files
    • Matt Read Loop Article
    • MaxPower Dynamic Sticky Tutorial
    • IfElse Query_post Redux
    • 1001 WordPression Loops
    • Global Variables and the WordPress Loop
    • WordPress Triple Loop Tutorial
    • Multiple Loops with Multiple Columns
    • WordPress - modified, dependent and extra Loops
    • Super Loop: Exclude Categories and Limit Number of Posts
    • Easily Adaptable WordPress Loop Templates: Basic Loops, Mullet Loops, and More
    * See my presentation on WordPress Theme Design
  • Writing Plugins “ Plug-ins can extend WordPress to do almost anything you can imagine.” -WordPress.org * See my presentation on WordPress Plugin Development and Making the Most of Plugins
    • Conventions
    • For each new plug-in I create a folder in the /wp-content/plugins/ pluginname / and then in that folder I create the main plug-in file with the same name as the folder + .php so the plug-in file is /wp-content/plugins/pluginname/ pluginname.php .
    • I usually start by converting a php function that I have built or found and convert it by adding the necessary WP code.
    • Main Elements
      • Header Stuff (Name, version, etc…)
      • Add Menu Option
      • Set Up the Options Page
      • Register the Activation and Deactivation Hooks
      • The Main Function
      • *Always make sure to include a readme.txt with your plug-in package.
  • Writing Plugins The PHP Function function randomflashloader(){ srand(microtime() *1000000); $num= rand (0,3); $project = array(); $project[0] = &quot;http://pv3world.com/labs/PV3interactive/pv3world_cube.swf&quot;; $project[1] = &quot;http://pv3world.com/labs/rays/rays.swf&quot;; $project[2] = &quot;http://pv3world.com/labs/PV3Galaxy/galaxy_cubes_interactive.swf&quot;; $project[3] = &quot;http://pv3world.com/labs/graffitiplane/graffiti_plane2.swf&quot;; $frame.= &quot;<center>&quot;; $frame.= &quot;<embed src=&quot;$project[$num]&quot; &quot;; $frame.= &quot;width =&quot;300&quot; height=&quot;250&quot; bgcolor=&quot;#000000&quot; border=&quot;0&quot;/>&quot;; $frame.= &quot;</a>&quot;; echo($frame); }
  • Writing Plugins The WordPress Plugin Hooks //Check install directory $rfl_directory = 'wp-content/plugins/randomflashloader/'; if ((!strstr(dirname(__FILE__).'/', $rfl_directory)) && (!strstr(dirname(__FILE__).'apos;, str_replace('/', 'apos;, $rfl_directory)))) { trigger_error(sprintf(__('<b>Random Flash Loader is not installed in the proper directory!</b><br />It won't work until installed in <b>%s</b><br />', 'randomflashloader'), $rfl_directory), E_USER_ERROR); return; } // Add the Options Menu add_action('admin_menu', 'random_flash_loader_options_setup'); // Setup the Options Page function random_flash_loader_options_setup() { global $random_flash_loader_data; add_options_page($random_flash_loader_data['Name'], 'RandomFlashLoader', 8, basename(__FILE__), 'random_flash_loader_page'); } // Activation and Deactivation Hooks register_deactivation_hook(__FILE__, 'random_flash_loader_deactivate'); register_activation_hook(__FILE__, 'random_flash_loader_activate'); * Download plugin here http://www.dropthedigibomb.com/randomflashloader.rar
  • Essential Plugins
    • Ad Rotator - http://kpumuk.info/projects/wordpress-plugins/ad-rotator
    • Advanced Random Post - http://www.danielesalamina.it/advanced-random-post
    • AFD Admin Theme - http://aenonfiredesign.com/blog/afd-wordpress2-admin-theme
    • Akismet - http://akismet.com/
    • All in One SEO Pack - http://semperfiwebdesign.com
    • Article Templates - http://www.bin-co.com/tools/wordpress/plugins/article_templates
    • Audio player - http://www.1pixelout.net/code/audio-player-wordpress-plugin
    • Blogroll Page - http://www.byte-me.org
    • Different Posts Per Page - http://www.maxblogpress.com/plugins/dppp
    • Disable WordPress Core Update - http://lud.icro.us/disable-wordpress-core-update
    • Executable PHP widget - http://wordpress.org/extend/plugins/php-code-widget
    • Kimili Flash Embed - http://www.kimili.com/plugins/kml_flashembed
    • Lightbox 2 - http://www.stimuli.ca/lightbox
    • Maintenance Mode - http://sw-guide.de/wordpress/plugins/maintenance-mode/
    • myStatus - http://eightface.com/code/wp-mystatus
    • NextGEN Gallery - http://alexrabe.boelinger.com/?page_id=80
  • Essential Plugins
    • p2pConverter - http://www.briandgoad.com/blog/p2pConverter
    • Post2pdf - http://wordpress.org/extend/plugins/post2pdf
    • PXS Mail Form - http://www.phrixus.co.uk/pxsmail
    • QuickTime Embed - http://www.channel-ai.com/blog/plugins/quicktime-embed
    • Random Featured Post - http://www.mydollarplan.com/random-featured-post-plugin
    • Riffly Video/Audio Comments - http://riffly.com
    • Role Manager - http://www.im-web-gefunden.de/wordpress-plugins/role-manag er
    • Widget Logic - http://freakytrigger.co.uk/wordpress-setup
    • WordPress Database Backup - http://www.ilfilosofo.com/blog/wp-db-backup
    • Wordpress Download Monitor - http://wordpress.org/extend/plugins/download-monitor
    • WP Cache - http://mnm.uib.es/gallir/wp-cache-2
    • WP e-commerce - http://www.instinct.co.nz/e-commerce
    • WP Polls - http://lesterchan.net/portfolio/programming/php
    • WP SpamFree - http://www.hybrid6.com/webgeek/plugins/wp-spamfree
    • WP-Sticky - http://lesterchan.net/portfolio/programming/php
    • WP Shopping Cart - http://www.instinct.co.nz
  • Resources
    • Documentation
    • Codex - http://codex.wordpress.org/Main_Page
    • Site Architecture – http://codex.wordpress.org/Site_Architecture_1.5
    • Template Hierarchy - http://codex.wordpress.org/Template_Hierarchy
    • WordPress Plugins - http://www.webdesignerwall.com/general/useful-wordpress-plugins/
    • WordPress Theme Hacks - http://www.webdesignerwall.com/tutorials/wordpress-theme-hacks/
    • Tutorials
    • Web Designer Wall - http://www.webdesignerwall.com
    • Six Revisions – http://www.sixrevisions.com
    • NetTuts - http://net.tutsplus.com/
    • Tutorial 9 – http://www.tutorial9.net
    • WPTopics - http://www.wptopics.com/
    • WordPress Tutorials - http://www.wp-tutorials.org/
    • Themes
    • Function - http://wefunction.com
    • WPSnap - http://www.wpsnap.com/
    • WooThemes – http://www.woothemes.com
    • StyleShout - http://www.styleshout.com
  • Resources
    • Plugins
    • Simplified AJAX For WordPress Plugin Developers using Jquery
    • “Desenvolvendo Plugins para WordPress” by Rafael Dohms (in Brazilian Portuguese)
    • 12 part “How to Write a Wordpress Plugin” at DevLounge.net by Ronald Huereca ( PDF )
    • How to create WordPress Plugin from a scratch
    • Using AJAX with your WordPress Plugin , also at DevLounce.net
    • How to Write a Simple WordPress Plugin at ATD
    • Other
    • BuddyPress - http://buddypress.org/
    • WordPress MU – http://mu.wordpress.org/
    • WP e-Commerce – http://www.instinct.co.nz/e-commerce/
    • Thematic – http://themeshaper.com/
    • WpTouch – http://www.bravenewcode.com/wptouch/
    • WordPress Mobile – http://en.blog.wordpress.com/2009/10/20/the-hero-is-in-your-pocket/
    • Where to find me…
    • Thank You
    • http://www.brendanserashriar.com
    • http://www.dropthedigibomb.com
    • [email_address]
    • http://www.twitter.com/digibomb