Your SlideShare is downloading. ×
0
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
WordPress Development at PHP Quebec - Nov 2009
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

WordPress Development at PHP Quebec - Nov 2009

4,160

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.

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,160
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
55
Comments
0
Likes
3
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Development PHP Quebec – November 09 Gathering
  • 2. full-time now!
  • 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. Getting started
  • 5. What you need PHP version 4.3 or greater MySQL version 4.0 or greater Creativity and Passion
  • 6. Theming <ul><li>Create or download a Photoshop design. Create a static HTML+CSS template of each page . </li></ul>
  • 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 &amp; 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. Yes, I know, this is PHP Quebec… Ok, back to the code.
  • 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 &lt;&lt; header.php , sidebar.php , and footer.php ).
  • 10. Templating The front page
  • 11. Templating Splitting the file
  • 12. Templating Let’s start with the Template System Template Tags Conditional Tags PHP Function Calls
  • 13. Templating &lt;?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; ?&gt; &lt;?php if ( is_home() ): ?&gt; &lt;h3&gt;Main Page&lt;/h3&gt; &lt;?php elseif( is_archive() ): ?&gt; &lt;h3&gt;Archives Page&lt;/h3&gt; &lt;?php else: ?&gt; &lt;h3&gt;Welcome to my blog!!&lt;/h3&gt; &lt;?php endif; ?&gt; Standard PHP WordPress
  • 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 &amp; 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. 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. 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 &amp;quot;Not Found&amp;quot;.
  • 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. Templating Playing with the code &lt;?php wp_list_categories(&apos;show_count=1&amp;title_li=&lt;h2&gt;Categories&lt;/h2&gt;&apos;); ?&gt; Most blogs display categories somewhere, usually the side bar. The easiest way to do this is with the wp_list_categories() Template Tag.
  • 19. Templating Playing with the code &lt;ul&gt; &lt;li id=&amp;quot;categories&amp;quot;&gt; &lt;?php wp_dropdown_categories(&apos;title_li=&amp;hierarchical=0&amp;show_count=1&amp;child_of=9&apos;); ?&gt; &lt;script type=&amp;quot;text/javascript&amp;quot;&gt; &lt;!-- var dropdown = document.getElementById(&amp;quot;cat&amp;quot;); function onCatChange() { if ( dropdown.options[dropdown.selectedIndex].value &gt; 0 ) { location.href = &amp;quot;&lt;?php echo get_option(&apos;home&apos;); ?&gt;/?cat=&amp;quot;+dropdown.options[dropdown.selectedIndex].value; } } dropdown.onchange = onCatChange; --&gt; &lt;/script&gt; &lt;/li&gt; &lt;/ul&gt; What if I wanted to display specific categories and have them in a dropdown box? * See the full tutorial at dropthedigibomb.com
  • 20. Templating Playing with the code &lt;?php if(is_page(&amp;quot;landing&amp;quot;)) : ?&gt; &lt;h5 class=&amp;quot;tagline&amp;quot;&gt; Hello! I&apos;m Brendan Sera-Shriar A.K.A. &lt;span class=&amp;quot;blue&amp;quot;&gt;digibomb&lt;/span&gt;, a freelance web designer from Montreal, Canada. &lt;/h5&gt; &lt;?php elseif(is_page(&amp;quot;work&amp;quot;) || is_page(&amp;quot;branding&amp;quot;) || is_page(&amp;quot;other-projects&amp;quot;) || is_page(&amp;quot;client-list&amp;quot;)) : ?&gt; &lt;h5 class=&amp;quot;tagline&amp;quot;&gt; I don&apos;t just build &lt;span class=&amp;quot;blue&amp;quot;&gt;websites&lt;/span&gt; I build &lt;span class=&amp;quot;blue&amp;quot;&gt;communities&lt;/span&gt;! &lt;/h5&gt; &lt;?php endif; ?&gt; What if I wanted to display different taglines on each page? * See it in action at digibombinc.com
  • 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. 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. Writing Plugins The PHP Function function randomflashloader(){ srand(microtime() *1000000); $num= rand (0,3); $project = array(); $project[0] = &amp;quot;http://pv3world.com/labs/PV3interactive/pv3world_cube.swf&amp;quot;; $project[1] = &amp;quot;http://pv3world.com/labs/rays/rays.swf&amp;quot;; $project[2] = &amp;quot;http://pv3world.com/labs/PV3Galaxy/galaxy_cubes_interactive.swf&amp;quot;; $project[3] = &amp;quot;http://pv3world.com/labs/graffitiplane/graffiti_plane2.swf&amp;quot;; $frame.= &amp;quot;&lt;center&gt;&amp;quot;; $frame.= &amp;quot;&lt;embed src=&amp;quot;$project[$num]&amp;quot; &amp;quot;; $frame.= &amp;quot;width =&amp;quot;300&amp;quot; height=&amp;quot;250&amp;quot; bgcolor=&amp;quot;#000000&amp;quot; border=&amp;quot;0&amp;quot;/&gt;&amp;quot;; $frame.= &amp;quot;&lt;/a&gt;&amp;quot;; echo($frame); }
  • 24. Writing Plugins The WordPress Plugin Hooks //Check install directory $rfl_directory = &apos;wp-content/plugins/randomflashloader/&apos;; if ((!strstr(dirname(__FILE__).&apos;/&apos;, $rfl_directory)) &amp;&amp; (!strstr(dirname(__FILE__).&apos;apos;, str_replace(&apos;/&apos;, &apos;apos;, $rfl_directory)))) { trigger_error(sprintf(__(&apos;&lt;b&gt;Random Flash Loader is not installed in the proper directory!&lt;/b&gt;&lt;br /&gt;It won&apos;t work until installed in &lt;b&gt;%s&lt;/b&gt;&lt;br /&gt;&apos;, &apos;randomflashloader&apos;), $rfl_directory), E_USER_ERROR); return; } // Add the Options Menu add_action(&apos;admin_menu&apos;, &apos;random_flash_loader_options_setup&apos;); // Setup the Options Page function random_flash_loader_options_setup() { global $random_flash_loader_data; add_options_page($random_flash_loader_data[&apos;Name&apos;], &apos;RandomFlashLoader&apos;, 8, basename(__FILE__), &apos;random_flash_loader_page&apos;); } // Activation and Deactivation Hooks register_deactivation_hook(__FILE__, &apos;random_flash_loader_deactivate&apos;); register_activation_hook(__FILE__, &apos;random_flash_loader_activate&apos;); * Download plugin here http://www.dropthedigibomb.com/randomflashloader.rar
  • 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. 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. 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. 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. <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>

×