Presentation covering what PHP is, the benefits, and some basic best practices relating to WordPress Development. Presented to the Birmingham, Alabama WordPress Meetup May 23rd, 2011 at Pale Eddies Pour House Check out http://wpbham.com for more information about past and future presentations/meetups
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
<?php + WordPress
1. <?php + WordPress
Christopher Reding
http://christopherreding.com
twitter: @creding
2. What is PHP
• PHP ( Hypertext Pre-processor ) is a
server side scripting language. Server side
means it runs on the server prior to
sending data to the browser. Due to this
fact you can not run PHP on the page itself.
3. What PHP can help you
with.
• conditional statements ( if this do that )
• create html for the browser
• retrieve data from a database
• simple and complex math
• date manipulation
• image creation, ( think captcha )
• image manipulation ( think the thumbnails wp creates )
• handling file uploads
• managing files and directories on the server
• read and write cookies
• read and write session data ( server cookies sorta )
• remote file requests ( like grabbing an rss feed )
• parsing xml ( outputting the rss feed )
• string manipulation ( capitalize first letter, replace a word, etc.)
• create arrays ( like a mini database )
• and on and on and on
4. Common uses of PHP
in WordPress
• conditional statements - <?php if ( have_posts() ):
• loops - <?php while ( have_posts() ): the_post();
• WP Classes - <?php $query = new WP_Query($args);
• WP Functions - <? the_content(); ?>
• WP filters and actions to alter the default WordPress behavior or add to it.
• creating your own functions and classes for themes and plugins
• date creation and manipulation
• adding, removing, or replacing text in a string ( hyperlinks from email addresses )
• string shortening ( the excerpt )
5. Where to learn more
about PHP?
• http://www.php.net
• http://codex.WordPress.org/Function_Reference
• http://www.w3schools.com/php/
• http://net.tutsplus.com/category/tutorials/php/
• http://www.sitepoint.com/forums/php-34/
• http://www.lynda.com/PHP-training-tutorials/282-0.html
6. Solving Problems
• http://wordpress.org/support/
• http://stackoverflow.com/questions/tagged/php
• http://google.com
• http://wordpress.stackexchange.com
The best source for finding the answer to a problem is always to find a
person who had a similar problem. Word your google searches with this in
mind and learn what sites provide the best user generated information
( and ranking of answers ) this is one reason I love stackoverflow, the
answers are voted on with the higher number generally being the best
overall ( not always though )Exploring the WordPress source code
If you need to accomplish something in WordPress and you don’t have a
clue how to do it, you may want to dig into the source to see if the WP
devs have already built your solution.
7. Tools for the source
• http://core.trac.WordPress.org/browser
• http://wpseek.com
Example: Say you are looking for a method to open and
read a remote file.You search the source ( using
wpseek.com ) for “open remote file” this will output a
list of functions and actions/hooks that match your
search. If nothing is returned don’t give up, rather change
the query including any other words that describe the
functionality you are looking for.
8. Why is this Good
For one you are writing less code which is (less
work) awesome, two you are using code that the
dev team has already vetted which saves you
from trying to make your square peg fit in a WP
shaped hole.
9. Learn WordPress Coding
Standards
• http://codex.WordPress.org/
WordPress_Coding_Standards
• This will make it much easier to read.
• Compliments the source rather than
appearing alien or different
10. Use inline-documentation
• awesome for the next guy, or you in a year
after you last looked at the code.
• http://codex.WordPress.org/
Inline_Documentation
12. <?php echo “The End”; ?>
Christopher Reding
http://christopherreding.com
twitter: @creding
Presented at the Birmingham, Alabama
WordPress Meetup http://wpbham.com