0
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 othe...
Getting started
What you need PHP  version 4.3 or greater MySQL  version 4.0 or greater Creativity and Passion
Theming   <ul><li>Create or download a Photoshop design.  Create a static HTML+CSS template of each page . </li></ul>
Theming   <ul><li>Why Create a Static HTML File First? </li></ul><ul><li>Mainly because it will make the development proce...
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 fil...
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  }...
Templating   Template Tags Include tags   <ul><li>get_header   </li></ul><ul><li>get_sidebar   </li></ul><ul><li>get_searc...
Templating   Template Tags Category tags   <ul><li>the_category   </li></ul><ul><li>the_category_rss   </li></ul><ul><li>s...
Templating   The Loop The Loop is used to display posts and it also lets you  control what to display. Basically, The Loop...
Templating   A complete template In this example we are using some standard Template Tags to display the title of the post...
Templating   Playing with the code <?php wp_list_categories('show_count=1&title_li=<h2>Categories</h2>'); ?> Most blogs di...
Templating   Playing with the code <ul>  <li id=&quot;categories&quot;>  <?php wp_dropdown_categories('title_li=&hierarchi...
Templating   Playing with the code <?php if(is_page(&quot;landing&quot;)) : ?> <h5 class=&quot;tagline&quot;>  Hello! I'm ...
Theming   <ul><li>Loop Resources </li></ul><ul><li>The Loop in Action  </li></ul><ul><li>Template Tags   </li></ul><ul><li...
Writing   Plugins “ Plug-ins can extend WordPress to do almost anything you can imagine.” -WordPress.org * See my presenta...
Writing   Plugins The PHP Function function randomflashloader(){ srand(microtime() *1000000); $num= rand (0,3); $project =...
Writing   Plugins The WordPress Plugin Hooks //Check install directory $rfl_directory = 'wp-content/plugins/randomflashloa...
Essential  Plugins <ul><li>Ad Rotator -  http://kpumuk.info/projects/wordpress-plugins/ad-rotator   </li></ul><ul><li>Adva...
Essential  Plugins <ul><li>p2pConverter -  http://www.briandgoad.com/blog/p2pConverter   </li></ul><ul><li>Post2pdf -  htt...
Resources <ul><li>Documentation </li></ul><ul><li>Codex -  http://codex.wordpress.org/Main_Page </li></ul><ul><li>Site Arc...
Resources <ul><li>Plugins </li></ul><ul><li>Simplified AJAX For WordPress Plugin Developers using Jquery </li></ul><ul><li...
<ul><li>Where to find me… </li></ul><ul><li>Thank You </li></ul><ul><li>http://www.brendanserashriar.com </li></ul><ul><li...
Upcoming SlideShare
Loading in...5
×

WordPress Development at PHP Quebec - Nov 2009

4,172

Published on

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.

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,172
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
55
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Transcript of "WordPress Development at PHP Quebec - Nov 2009"

  1. 1. Development PHP Quebec – November 09 Gathering
  2. 2. full-time now!
  3. 3. 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
  4. 4. Getting started
  5. 5. What you need PHP version 4.3 or greater MySQL version 4.0 or greater Creativity and Passion
  6. 6. Theming <ul><li>Create or download a Photoshop design. Create a static HTML+CSS template of each page . </li></ul>
  7. 7. Theming <ul><li>Why Create a Static HTML File First? </li></ul><ul><li>Mainly because it will make the development process a lot </li></ul><ul><li>easier. I usually create a HTML file for every template that I </li></ul><ul><li>need, test it across all browsers, validate both HTML and CSS </li></ul><ul><li>markups, then all I have to do is cut & paste the WordPress </li></ul><ul><li>code. By doing so, I don’t have to worry about HTML or CSS </li></ul><ul><li>bugs during my theme making process. </li></ul>
  8. 8. Yes, I know, this is PHP Quebec… Ok, back to the code.
  9. 9. 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 ).
  10. 10. Templating The front page
  11. 11. Templating Splitting the file
  12. 12. Templating Let’s start with the Template System Template Tags Conditional Tags PHP Function Calls
  13. 13. 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
  14. 14. Templating Template Tags Include tags <ul><li>get_header </li></ul><ul><li>get_sidebar </li></ul><ul><li>get_search_form </li></ul><ul><li>comments_template </li></ul><ul><li>get_footer </li></ul>Blog info tags <ul><li>bloginfo </li></ul><ul><li>bloginfo_rss </li></ul><ul><li>get_bloginfo </li></ul><ul><li>get_bloginfo_rss </li></ul>Lists & Dropdown tags <ul><li>wp_list_authors </li></ul><ul><li>wp_list_categories </li></ul><ul><li>wp_list_pages </li></ul><ul><li>wp_list_bookmarks </li></ul><ul><li>wp_list_comments </li></ul><ul><li>wp_get_archives </li></ul><ul><li>wp_page_menu </li></ul><ul><li>wp_dropdown_pages </li></ul><ul><li>wp_dropdown_categories </li></ul><ul><li>wp_dropdown_users </li></ul>Login/Logout tags <ul><li>is_user_logged_in </li></ul><ul><li>wp_login_url </li></ul><ul><li>wp_logout_url </li></ul><ul><li>wp_lostpassword_url </li></ul><ul><li>wp_registration_url </li></ul><ul><li>wp_logout </li></ul><ul><li>wp_loginout </li></ul><ul><li>wp_register </li></ul>Post tags <ul><li>the_ID </li></ul><ul><li>the_title </li></ul><ul><li>the_title_rss </li></ul><ul><li>the_title_attribute </li></ul><ul><li>single_post_title </li></ul><ul><li>the_content </li></ul><ul><li>the_content_rss </li></ul><ul><li>the_excerpt </li></ul><ul><li>the_excerpt_rss </li></ul><ul><li>wp_link_pages </li></ul><ul><li>posts_nav_link </li></ul><ul><li>next_post_link </li></ul><ul><li>next_posts_link </li></ul><ul><li>previous_post_link </li></ul><ul><li>previous_posts_link </li></ul><ul><li>next_image_link </li></ul><ul><li>previous_image_link </li></ul><ul><li>sticky_class </li></ul><ul><li>the_category </li></ul><ul><li>the_category_rss </li></ul><ul><li>the_tags </li></ul><ul><li>the_meta </li></ul>Comment tags <ul><li>wp_list_comments </li></ul><ul><li>comments_number </li></ul><ul><li>comments_link </li></ul><ul><li>comments_rss_link </li></ul><ul><li>comments_popup_script </li></ul><ul><li>comments_popup_link </li></ul><ul><li>comment_ID </li></ul><ul><li>comment_id_fields </li></ul><ul><li>comment_author </li></ul><ul><li>comment_author_link </li></ul><ul><li>comment_author_email </li></ul><ul><li>comment_author_email_link </li></ul><ul><li>comment_author_url </li></ul><ul><li>comment_author_url_link </li></ul><ul><li>comment_author_IP </li></ul><ul><li>comment_type </li></ul><ul><li>comment_text </li></ul><ul><li>comment_excerpt </li></ul><ul><li>comment_date </li></ul><ul><li>comment_time </li></ul><ul><li>comment_form_title </li></ul><ul><li>comment_author_rss </li></ul><ul><li>comment_text_rss </li></ul><ul><li>get_avatar </li></ul><ul><li>permalink_comments_rss </li></ul><ul><li>comment_reply_link </li></ul><ul><li>cancel_comment_reply_link </li></ul><ul><li>previous_comments_link </li></ul><ul><li>next_comments_link </li></ul><ul><li>paginate_comments_links </li></ul>
  15. 15. Templating Template Tags Category tags <ul><li>the_category </li></ul><ul><li>the_category_rss </li></ul><ul><li>single_cat_title </li></ul><ul><li>category_description </li></ul><ul><li>wp_dropdown_categories </li></ul><ul><li>wp_list_categories </li></ul>Tag tags <ul><li>the_tags </li></ul><ul><li>tag_description </li></ul><ul><li>single_tag_title </li></ul><ul><li>wp_tag_cloud </li></ul><ul><li>wp_generate_tag_cloud </li></ul>Author tags <ul><li>the_author </li></ul><ul><li>the_author_link </li></ul><ul><li>the_author_posts </li></ul><ul><li>the_author_posts_link </li></ul><ul><li>the_author_meta </li></ul><ul><li>wp_list_authors </li></ul><ul><li>wp_dropdown_users </li></ul>Date and Time tags <ul><li>the_time </li></ul><ul><li>the_date </li></ul><ul><li>the_date_xml </li></ul><ul><li>the_modified_time </li></ul><ul><li>the_modified_date </li></ul><ul><li>the_modified_author </li></ul><ul><li>single_month_title </li></ul>Edit Link tags <ul><li>edit_post_link </li></ul><ul><li>edit_comment_link </li></ul><ul><li>edit_tag_link </li></ul><ul><li>edit_bookmark_link </li></ul>Permalink tags <ul><li>permalink_anchor </li></ul><ul><li>get_permalink </li></ul><ul><li>the_permalink </li></ul><ul><li>permalink_single_rss </li></ul>Links Manager tags <ul><li>wp_list_bookmarks </li></ul><ul><li>get_bookmarks </li></ul><ul><li>get_bookmark </li></ul><ul><li>get_bookmark_field </li></ul>Trackback tags <ul><li>trackback_url </li></ul><ul><li>trackback_rdf </li></ul>Title tags <ul><li>wp_title </li></ul><ul><li>single_post_title </li></ul><ul><li>single_cat_title </li></ul><ul><li>single_tag_title </li></ul><ul><li>single_month_title </li></ul><ul><li>the_search_query </li></ul>Query tags <ul><li>get_posts </li></ul><ul><li>query_posts </li></ul>
  16. 16. 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;.
  17. 17. 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() .
  18. 18. 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.
  19. 19. 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
  20. 20. 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
  21. 21. Theming <ul><li>Loop Resources </li></ul><ul><li>The Loop in Action </li></ul><ul><li>Template Tags </li></ul><ul><li>Using the Loop in Template Files </li></ul><ul><li>Matt Read Loop Article </li></ul><ul><li>MaxPower Dynamic Sticky Tutorial </li></ul><ul><li>IfElse Query_post Redux </li></ul><ul><li>1001 WordPression Loops </li></ul><ul><li>Global Variables and the WordPress Loop </li></ul><ul><li>WordPress Triple Loop Tutorial </li></ul><ul><li>Multiple Loops with Multiple Columns </li></ul><ul><li>WordPress - modified, dependent and extra Loops </li></ul><ul><li>Super Loop: Exclude Categories and Limit Number of Posts </li></ul><ul><li>Easily Adaptable WordPress Loop Templates: Basic Loops, Mullet Loops, and More </li></ul>* See my presentation on WordPress Theme Design
  22. 22. 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 <ul><li>Conventions </li></ul><ul><li>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 . </li></ul><ul><li>I usually start by converting a php function that I have built or found and convert it by adding the necessary WP code. </li></ul><ul><li>Main Elements </li></ul><ul><ul><li>Header Stuff (Name, version, etc…) </li></ul></ul><ul><ul><li>Add Menu Option </li></ul></ul><ul><ul><li>Set Up the Options Page </li></ul></ul><ul><ul><li>Register the Activation and Deactivation Hooks </li></ul></ul><ul><ul><li>The Main Function </li></ul></ul><ul><ul><li>*Always make sure to include a readme.txt with your plug-in package. </li></ul></ul>
  23. 23. 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); }
  24. 24. 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
  25. 25. Essential Plugins <ul><li>Ad Rotator - http://kpumuk.info/projects/wordpress-plugins/ad-rotator </li></ul><ul><li>Advanced Random Post - http://www.danielesalamina.it/advanced-random-post </li></ul><ul><li>AFD Admin Theme - http://aenonfiredesign.com/blog/afd-wordpress2-admin-theme </li></ul><ul><li>Akismet - http://akismet.com/ </li></ul><ul><li>All in One SEO Pack - http://semperfiwebdesign.com </li></ul><ul><li>Article Templates - http://www.bin-co.com/tools/wordpress/plugins/article_templates </li></ul><ul><li>Audio player - http://www.1pixelout.net/code/audio-player-wordpress-plugin </li></ul><ul><li>Blogroll Page - http://www.byte-me.org </li></ul><ul><li>Different Posts Per Page - http://www.maxblogpress.com/plugins/dppp </li></ul><ul><li>Disable WordPress Core Update - http://lud.icro.us/disable-wordpress-core-update </li></ul><ul><li>Executable PHP widget - http://wordpress.org/extend/plugins/php-code-widget </li></ul><ul><li>Kimili Flash Embed - http://www.kimili.com/plugins/kml_flashembed </li></ul><ul><li>Lightbox 2 - http://www.stimuli.ca/lightbox </li></ul><ul><li>Maintenance Mode - http://sw-guide.de/wordpress/plugins/maintenance-mode/ </li></ul><ul><li>myStatus - http://eightface.com/code/wp-mystatus </li></ul><ul><li>NextGEN Gallery - http://alexrabe.boelinger.com/?page_id=80 </li></ul>
  26. 26. Essential Plugins <ul><li>p2pConverter - http://www.briandgoad.com/blog/p2pConverter </li></ul><ul><li>Post2pdf - http://wordpress.org/extend/plugins/post2pdf </li></ul><ul><li>PXS Mail Form - http://www.phrixus.co.uk/pxsmail </li></ul><ul><li>QuickTime Embed - http://www.channel-ai.com/blog/plugins/quicktime-embed </li></ul><ul><li>Random Featured Post - http://www.mydollarplan.com/random-featured-post-plugin </li></ul><ul><li>Riffly Video/Audio Comments - http://riffly.com </li></ul><ul><li>Role Manager - http://www.im-web-gefunden.de/wordpress-plugins/role-manag er </li></ul><ul><li>Widget Logic - http://freakytrigger.co.uk/wordpress-setup </li></ul><ul><li>WordPress Database Backup - http://www.ilfilosofo.com/blog/wp-db-backup </li></ul><ul><li>Wordpress Download Monitor - http://wordpress.org/extend/plugins/download-monitor </li></ul><ul><li>WP Cache - http://mnm.uib.es/gallir/wp-cache-2 </li></ul><ul><li>WP e-commerce - http://www.instinct.co.nz/e-commerce </li></ul><ul><li>WP Polls - http://lesterchan.net/portfolio/programming/php </li></ul><ul><li>WP SpamFree - http://www.hybrid6.com/webgeek/plugins/wp-spamfree </li></ul><ul><li>WP-Sticky - http://lesterchan.net/portfolio/programming/php </li></ul><ul><li>WP Shopping Cart - http://www.instinct.co.nz </li></ul>
  27. 27. Resources <ul><li>Documentation </li></ul><ul><li>Codex - http://codex.wordpress.org/Main_Page </li></ul><ul><li>Site Architecture – http://codex.wordpress.org/Site_Architecture_1.5 </li></ul><ul><li>Template Hierarchy - http://codex.wordpress.org/Template_Hierarchy </li></ul><ul><li>WordPress Plugins - http://www.webdesignerwall.com/general/useful-wordpress-plugins/ </li></ul><ul><li>WordPress Theme Hacks - http://www.webdesignerwall.com/tutorials/wordpress-theme-hacks/ </li></ul><ul><li>Tutorials </li></ul><ul><li>Web Designer Wall - http://www.webdesignerwall.com </li></ul><ul><li>Six Revisions – http://www.sixrevisions.com </li></ul><ul><li>NetTuts - http://net.tutsplus.com/ </li></ul><ul><li>Tutorial 9 – http://www.tutorial9.net </li></ul><ul><li>WPTopics - http://www.wptopics.com/ </li></ul><ul><li>WordPress Tutorials - http://www.wp-tutorials.org/ </li></ul><ul><li>Themes </li></ul><ul><li>Function - http://wefunction.com </li></ul><ul><li>WPSnap - http://www.wpsnap.com/ </li></ul><ul><li>WooThemes – http://www.woothemes.com </li></ul><ul><li>StyleShout - http://www.styleshout.com </li></ul>
  28. 28. Resources <ul><li>Plugins </li></ul><ul><li>Simplified AJAX For WordPress Plugin Developers using Jquery </li></ul><ul><li>“Desenvolvendo Plugins para WordPress” by Rafael Dohms (in Brazilian Portuguese) </li></ul><ul><li>12 part “How to Write a Wordpress Plugin” at DevLounge.net by Ronald Huereca ( PDF ) </li></ul><ul><li>How to create WordPress Plugin from a scratch </li></ul><ul><li>Using AJAX with your WordPress Plugin , also at DevLounce.net </li></ul><ul><li>How to Write a Simple WordPress Plugin at ATD </li></ul><ul><li>Other </li></ul><ul><li>BuddyPress - http://buddypress.org/ </li></ul><ul><li>WordPress MU – http://mu.wordpress.org/ </li></ul><ul><li>WP e-Commerce – http://www.instinct.co.nz/e-commerce/ </li></ul><ul><li>Thematic – http://themeshaper.com/ </li></ul><ul><li>WpTouch – http://www.bravenewcode.com/wptouch/ </li></ul><ul><li>WordPress Mobile – http://en.blog.wordpress.com/2009/10/20/the-hero-is-in-your-pocket/ </li></ul>
  29. 29. <ul><li>Where to find me… </li></ul><ul><li>Thank You </li></ul><ul><li>http://www.brendanserashriar.com </li></ul><ul><li>http://www.dropthedigibomb.com </li></ul><ul><li>[email_address] </li></ul><ul><li>http://www.twitter.com/digibomb </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×