SlideShare ist ein Scribd-Unternehmen logo
1 von 26
Downloaden Sie, um offline zu lesen
YOU’RE DOING IT WRONG




Chris Scott - @chrisscott - slideshare.net/iamzed
             photo by mimk http://www.flickr.com/photos/mimk/222612527/
Thanks
• Dion Hulse’s (DD32) two part series on doing it
    wrong:
    • http://dd32.id.au/2009/11/01/youre-doing-it-
      wrong-1/
    • http://dd32.id.au/2009/11/01/youre-doing-it-
      wrong-2/
    • http://dd32.id.au/2009/11/24/how-to-do-it-right-
      part-0/
•   Michael Pretty for ideas and telling me what I’m doing
    wrong
•   Sean O’Shaughnessy for ideas and graphics
New Features in a Year:
         2.7 - 2.8.6
• Sticky posts
• Comment threading and paging
• Widgets API
• Load scripts minified by default
• Load scripts in the footer
• esc_* functions
• security fixes
• and much more...
Wrong and Right
Not Upgrading




 WRONG
Upgrading




RIGHT
Calling Functions That
           Don’t Exist
<div id="sidebar" role="complementary">
  <ul>
     <li><?php wp_ozh_wsa('mybanner') ?></li>

    ... rest of sidebar ...

  </ul>
</div>




               WRONG
Check for Functions Before
          Calling
<div id="sidebar" role="complementary">
  <ul>
     <?php if (function_exists('wp_ozh_wsa')) : ?>
       <li><?php wp_ozh_wsa('mybanner') ?></li>
     <?php endif; ?>

    ... rest of sidebar ...

  </ul>
</div>



                 RIGHT
Hard-Coding WordPress
           Paths
$cb_path = get_bloginfo('wpurl')."/wp-content/
plugins/wp-codebox"; //URL to the plugin directory




               WRONG
Use Constants or Helper
        Functions
$cb_path = plugins_url('', __FILE__);   //URL to the
plugin directory




                RIGHT
Echoing Scripts/CSS in
        Header/Footer
function codebox_header() {
  $hHead .= "<script language="javascript" type=
"text/javascript" src="".get_bloginfo('wpurl')."/
wp-includes/js/jquery/jquery.js"></script>n";
  $hHead .= "<script language="javascript" type=
"text/javascript" src="{$cb_path}/js/codebox.js"
></script>n";
  print($hHead);
}
add_action('wp_head', 'codebox_header');



               WRONG
Enqueue Scripts and Styles

function codebox_header() {
  wp_enqueue_script(
     'codebox',
     plugins_url('js/ codebox.js', __FILE__),
     array('jquery')
  );
}
add_action('template_redirect', 'codebox_header');




                RIGHT
Not Checking Indices or
     Object Properties
if ($_GET['wp125action'] == "deactivate") {
  ...
}




               WRONG
Checking Indices/Properties

if (isset($_GET['wp125action']) &&
  $_GET['wp125action'] == "deactivate") {
  ...
}




                RIGHT
Not Using WP_DEBUG




    WRONG
Define WP_DEBUG in
       wp-config.php
define('WP_DEBUG', true);




                RIGHT
Using Globals Instead of
  Helper Functions/Classes
global $post;

$linkname = get_the_title($post->ID);




                WRONG
Use Helper Functions/
           Classes
$linkname = get_the_title();




                RIGHT
Writing SQL

global $wpdb;

$wpdb->query("update ".$articles." set review = ".
  $rating." where post_id = ".$post_id);




                WRONG
Use $wpdb Methods

global $wpdb;

$wpdb->update(
   $articles,
   array('review' => $rating),
   compact('post_id')
);




                 RIGHT
Not Validating/Escaping
         User Input
<label for="title"><?php echo
get_option('my_plugin_option_title'); ?></label>

<input type="text" id="value" name="value" value="<?
php echo get_option('my_plugin_option_value')); ?>">




               WRONG
Validate and Escape User
            Input
<label for="title"><?php echo
esc_html(get_option('my_plugin_option_title')); ?></
label>

<input type="text" id="value" name="value" value="<?
php echo
esc_attr(get_option('my_plugin_option_value')); ?>">




                RIGHT
Not Using Caching

$response = wp_remote_get($url);
if (!is_wp_error($response)
     && $response['response']['code'] == '200')
{
  $data = $response['body'];
}
... do something with data ...




               WRONG
Use Caching

if (!$data = wp_cache_get('my_external_data')) {
  $response = wp_remote_get($url);
  if (!is_wp_error($response) &&
       $response['response']['code'] == '200')
  {
     $data = $response['body'];
     wp_cache_set('my_external_data', $data);
  }
}
... do something with data ...



                RIGHT
Not Contributing




photo by TaranRampersad http://www.flickr.com/photos/knowprose/2294744043/




           WRONG
Contributing
http://codex.wordpress.org/
Contributing_to_WordPress

• Edit the Codex
• Answer Forum Support Questions
• Participate in Development
  • Planning, Testing, Bug Reporting and Fixing
• Say “Thanks”


                  RIGHT

Weitere ähnliche Inhalte

Was ist angesagt?

WordPress Theme Design and Development Workshop - Day 3
WordPress Theme Design and Development Workshop - Day 3WordPress Theme Design and Development Workshop - Day 3
WordPress Theme Design and Development Workshop - Day 3Mizanur Rahaman Mizan
 
Introduction to jQuery - Barcamp London 9
Introduction to jQuery - Barcamp London 9Introduction to jQuery - Barcamp London 9
Introduction to jQuery - Barcamp London 9Jack Franklin
 
Short intro to JQuery and Modernizr
Short intro to JQuery and ModernizrShort intro to JQuery and Modernizr
Short intro to JQuery and ModernizrJussi Pohjolainen
 
jQtouch, Building Awesome Webapps
jQtouch, Building Awesome WebappsjQtouch, Building Awesome Webapps
jQtouch, Building Awesome WebappsHome
 
JavaScript & AJAX in WordPress
JavaScript & AJAX in WordPressJavaScript & AJAX in WordPress
JavaScript & AJAX in WordPressIgor Benić
 
Angular JS blog tutorial
Angular JS blog tutorialAngular JS blog tutorial
Angular JS blog tutorialClaude Tech
 
iPhone Appleless Apps
iPhone Appleless AppsiPhone Appleless Apps
iPhone Appleless AppsRemy Sharp
 
Webapps without the web
Webapps without the webWebapps without the web
Webapps without the webRemy Sharp
 
Jqeury ajax plugins
Jqeury ajax pluginsJqeury ajax plugins
Jqeury ajax pluginsInbal Geffen
 
Clearance: Simple, complete Ruby web app authentication.
Clearance: Simple, complete Ruby web app authentication.Clearance: Simple, complete Ruby web app authentication.
Clearance: Simple, complete Ruby web app authentication.Jason Morrison
 
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress WordCamp Kyiv
 
2012.sandiego.wordcamp
2012.sandiego.wordcamp2012.sandiego.wordcamp
2012.sandiego.wordcampBrandon Dove
 
Practical PHP by example Jan Leth-Kjaer
Practical PHP by example   Jan Leth-KjaerPractical PHP by example   Jan Leth-Kjaer
Practical PHP by example Jan Leth-KjaerCOMMON Europe
 
Auto tools
Auto toolsAuto tools
Auto tools祺 周
 

Was ist angesagt? (20)

Codegnitorppt
CodegnitorpptCodegnitorppt
Codegnitorppt
 
WordPress Theme Design and Development Workshop - Day 3
WordPress Theme Design and Development Workshop - Day 3WordPress Theme Design and Development Workshop - Day 3
WordPress Theme Design and Development Workshop - Day 3
 
Introduction to jQuery - Barcamp London 9
Introduction to jQuery - Barcamp London 9Introduction to jQuery - Barcamp London 9
Introduction to jQuery - Barcamp London 9
 
JQuery
JQueryJQuery
JQuery
 
Short intro to JQuery and Modernizr
Short intro to JQuery and ModernizrShort intro to JQuery and Modernizr
Short intro to JQuery and Modernizr
 
18.register login
18.register login18.register login
18.register login
 
jQtouch, Building Awesome Webapps
jQtouch, Building Awesome WebappsjQtouch, Building Awesome Webapps
jQtouch, Building Awesome Webapps
 
20110820 header new style
20110820 header new style20110820 header new style
20110820 header new style
 
JavaScript & AJAX in WordPress
JavaScript & AJAX in WordPressJavaScript & AJAX in WordPress
JavaScript & AJAX in WordPress
 
Owasp & php
Owasp & phpOwasp & php
Owasp & php
 
Angular JS blog tutorial
Angular JS blog tutorialAngular JS blog tutorial
Angular JS blog tutorial
 
iPhone Appleless Apps
iPhone Appleless AppsiPhone Appleless Apps
iPhone Appleless Apps
 
Webapps without the web
Webapps without the webWebapps without the web
Webapps without the web
 
Jqeury ajax plugins
Jqeury ajax pluginsJqeury ajax plugins
Jqeury ajax plugins
 
Clearance: Simple, complete Ruby web app authentication.
Clearance: Simple, complete Ruby web app authentication.Clearance: Simple, complete Ruby web app authentication.
Clearance: Simple, complete Ruby web app authentication.
 
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress
 
2012.sandiego.wordcamp
2012.sandiego.wordcamp2012.sandiego.wordcamp
2012.sandiego.wordcamp
 
Practical PHP by example Jan Leth-Kjaer
Practical PHP by example   Jan Leth-KjaerPractical PHP by example   Jan Leth-Kjaer
Practical PHP by example Jan Leth-Kjaer
 
Auto tools
Auto toolsAuto tools
Auto tools
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 

Ähnlich wie You're Doing it Wrong - WordCamp Orlando

Becoming a better WordPress Developer
Becoming a better WordPress DeveloperBecoming a better WordPress Developer
Becoming a better WordPress DeveloperJoey Kudish
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkDirk Haun
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)arcware
 
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)Mike Schinkel
 
[Bristol WordPress] Supercharging WordPress Development
[Bristol WordPress] Supercharging WordPress Development[Bristol WordPress] Supercharging WordPress Development
[Bristol WordPress] Supercharging WordPress DevelopmentAdam Tomat
 
Using shortcode in plugin development
Using shortcode in plugin developmentUsing shortcode in plugin development
Using shortcode in plugin developmentgskhanal
 
Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8Michelangelo van Dam
 
Virtual Madness @ Etsy
Virtual Madness @ EtsyVirtual Madness @ Etsy
Virtual Madness @ EtsyNishan Subedi
 
HirshHorn theme: how I created it
HirshHorn theme: how I created itHirshHorn theme: how I created it
HirshHorn theme: how I created itPaul Bearne
 
Drupal Development
Drupal DevelopmentDrupal Development
Drupal DevelopmentJeff Eaton
 
What mom never told you about bundle configurations - Symfony Live Paris 2012
What mom never told you about bundle configurations - Symfony Live Paris 2012What mom never told you about bundle configurations - Symfony Live Paris 2012
What mom never told you about bundle configurations - Symfony Live Paris 2012D
 
Building iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" DominoBuilding iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" DominoRob Bontekoe
 
AppForum 2014 Boost Hybrid App Performance
AppForum 2014 Boost Hybrid App PerformanceAppForum 2014 Boost Hybrid App Performance
AppForum 2014 Boost Hybrid App Performancerobgalvinjr
 

Ähnlich wie You're Doing it Wrong - WordCamp Orlando (20)

Becoming a better WordPress Developer
Becoming a better WordPress DeveloperBecoming a better WordPress Developer
Becoming a better WordPress Developer
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application Framework
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
 
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
 
[Bristol WordPress] Supercharging WordPress Development
[Bristol WordPress] Supercharging WordPress Development[Bristol WordPress] Supercharging WordPress Development
[Bristol WordPress] Supercharging WordPress Development
 
Add loop shortcode
Add loop shortcodeAdd loop shortcode
Add loop shortcode
 
QA for PHP projects
QA for PHP projectsQA for PHP projects
QA for PHP projects
 
Using shortcode in plugin development
Using shortcode in plugin developmentUsing shortcode in plugin development
Using shortcode in plugin development
 
Blog Hacks 2011
Blog Hacks 2011Blog Hacks 2011
Blog Hacks 2011
 
Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8
 
Virtual Madness @ Etsy
Virtual Madness @ EtsyVirtual Madness @ Etsy
Virtual Madness @ Etsy
 
Get AngularJS Started!
Get AngularJS Started!Get AngularJS Started!
Get AngularJS Started!
 
HirshHorn theme: how I created it
HirshHorn theme: how I created itHirshHorn theme: how I created it
HirshHorn theme: how I created it
 
WCLA12 JavaScript
WCLA12 JavaScriptWCLA12 JavaScript
WCLA12 JavaScript
 
Seven deadly theming sins
Seven deadly theming sinsSeven deadly theming sins
Seven deadly theming sins
 
Drupal Development
Drupal DevelopmentDrupal Development
Drupal Development
 
What mom never told you about bundle configurations - Symfony Live Paris 2012
What mom never told you about bundle configurations - Symfony Live Paris 2012What mom never told you about bundle configurations - Symfony Live Paris 2012
What mom never told you about bundle configurations - Symfony Live Paris 2012
 
Building iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" DominoBuilding iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" Domino
 
Yii Introduction
Yii IntroductionYii Introduction
Yii Introduction
 
AppForum 2014 Boost Hybrid App Performance
AppForum 2014 Boost Hybrid App PerformanceAppForum 2014 Boost Hybrid App Performance
AppForum 2014 Boost Hybrid App Performance
 

Kürzlich hochgeladen

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 

Kürzlich hochgeladen (20)

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 

You're Doing it Wrong - WordCamp Orlando

  • 1. YOU’RE DOING IT WRONG Chris Scott - @chrisscott - slideshare.net/iamzed photo by mimk http://www.flickr.com/photos/mimk/222612527/
  • 2. Thanks • Dion Hulse’s (DD32) two part series on doing it wrong: • http://dd32.id.au/2009/11/01/youre-doing-it- wrong-1/ • http://dd32.id.au/2009/11/01/youre-doing-it- wrong-2/ • http://dd32.id.au/2009/11/24/how-to-do-it-right- part-0/ • Michael Pretty for ideas and telling me what I’m doing wrong • Sean O’Shaughnessy for ideas and graphics
  • 3. New Features in a Year: 2.7 - 2.8.6 • Sticky posts • Comment threading and paging • Widgets API • Load scripts minified by default • Load scripts in the footer • esc_* functions • security fixes • and much more...
  • 7. Calling Functions That Don’t Exist <div id="sidebar" role="complementary"> <ul> <li><?php wp_ozh_wsa('mybanner') ?></li> ... rest of sidebar ... </ul> </div> WRONG
  • 8. Check for Functions Before Calling <div id="sidebar" role="complementary"> <ul> <?php if (function_exists('wp_ozh_wsa')) : ?> <li><?php wp_ozh_wsa('mybanner') ?></li> <?php endif; ?> ... rest of sidebar ... </ul> </div> RIGHT
  • 9. Hard-Coding WordPress Paths $cb_path = get_bloginfo('wpurl')."/wp-content/ plugins/wp-codebox"; //URL to the plugin directory WRONG
  • 10. Use Constants or Helper Functions $cb_path = plugins_url('', __FILE__); //URL to the plugin directory RIGHT
  • 11. Echoing Scripts/CSS in Header/Footer function codebox_header() { $hHead .= "<script language="javascript" type= "text/javascript" src="".get_bloginfo('wpurl')."/ wp-includes/js/jquery/jquery.js"></script>n"; $hHead .= "<script language="javascript" type= "text/javascript" src="{$cb_path}/js/codebox.js" ></script>n"; print($hHead); } add_action('wp_head', 'codebox_header'); WRONG
  • 12. Enqueue Scripts and Styles function codebox_header() { wp_enqueue_script( 'codebox', plugins_url('js/ codebox.js', __FILE__), array('jquery') ); } add_action('template_redirect', 'codebox_header'); RIGHT
  • 13. Not Checking Indices or Object Properties if ($_GET['wp125action'] == "deactivate") { ... } WRONG
  • 14. Checking Indices/Properties if (isset($_GET['wp125action']) && $_GET['wp125action'] == "deactivate") { ... } RIGHT
  • 16. Define WP_DEBUG in wp-config.php define('WP_DEBUG', true); RIGHT
  • 17. Using Globals Instead of Helper Functions/Classes global $post; $linkname = get_the_title($post->ID); WRONG
  • 18. Use Helper Functions/ Classes $linkname = get_the_title(); RIGHT
  • 19. Writing SQL global $wpdb; $wpdb->query("update ".$articles." set review = ". $rating." where post_id = ".$post_id); WRONG
  • 20. Use $wpdb Methods global $wpdb; $wpdb->update( $articles, array('review' => $rating), compact('post_id') ); RIGHT
  • 21. Not Validating/Escaping User Input <label for="title"><?php echo get_option('my_plugin_option_title'); ?></label> <input type="text" id="value" name="value" value="<? php echo get_option('my_plugin_option_value')); ?>"> WRONG
  • 22. Validate and Escape User Input <label for="title"><?php echo esc_html(get_option('my_plugin_option_title')); ?></ label> <input type="text" id="value" name="value" value="<? php echo esc_attr(get_option('my_plugin_option_value')); ?>"> RIGHT
  • 23. Not Using Caching $response = wp_remote_get($url); if (!is_wp_error($response) && $response['response']['code'] == '200') { $data = $response['body']; } ... do something with data ... WRONG
  • 24. Use Caching if (!$data = wp_cache_get('my_external_data')) { $response = wp_remote_get($url); if (!is_wp_error($response) && $response['response']['code'] == '200') { $data = $response['body']; wp_cache_set('my_external_data', $data); } } ... do something with data ... RIGHT
  • 25. Not Contributing photo by TaranRampersad http://www.flickr.com/photos/knowprose/2294744043/ WRONG
  • 26. Contributing http://codex.wordpress.org/ Contributing_to_WordPress • Edit the Codex • Answer Forum Support Questions • Participate in Development • Planning, Testing, Bug Reporting and Fixing • Say “Thanks” RIGHT