Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Code Deodorant 2014

Tom J Nowell
September 28, 2014

Code Deodorant 2014

Given at WordCamp Europe Sophia 2014

Tom J Nowell

September 28, 2014
Tweet

More Decks by Tom J Nowell

Other Decks in Technology

Transcript

  1. Indenting <?php if (is_lt_IE9()) : ?> <?php if (function_exists('dynamic_sidebar') &&

    dynamic_sidebar ('countdown-ie')) : else : ?> <div class="pre-widget"> <p><strong>Widgetized area 1</strong></p> <p>This panel is active and ready for you to add some widgets via the WP Admin</p> </div> <?php endif; ?> <?php else : ?> <?php if (function_exists('dynamic_sidebar') && dynamic_sidebar ('countdown')) : else : ? > <div class="pre-widget"> <p><strong>Widgetized area 2</strong></p> <p>This panel is active and ready for you to add some widgets via the WP Admin</p> </div> <?php endif; ?> <?php endif; ?>
  2. Warnings and @ PHP Warning: strip_tags() expects parameter 1 to

    be string, array given in … $str = @strip_tags(‘<b>example</b>’);
  3. Anonymous Objects class Davina_Plugin { function __construct() { add_filter( 'the_content',

    array( $this, 'swear' ), -1 ); } function swear( $content ) { return "Hello big brother house, you are live on channel 4, do not say sh*t f*ck or b*gger"; } } new Davina_Plugin();
  4. pre_get_posts function exclude_cat( $query ) { if ( $query->is_home() &&

    $query->is_main_query() ) { $query->set( 'cat', '-1,-1347' ); } } add_action( 'pre_get_posts', 'exclude_cat' );
  5. Calculations 1 unit test = 1.5kb 1 Samsung 1TB drive

    = 0.4kg 80 Undecillion kg or 8x1037kg or~4 solar masses
  6. 162,789,208,987 Solar Masses 1x10^9 - Sombrero Galaxy 1x10^10 - Large

    Megallenic Cloud dwarf galaxy 1.6x10^11 - WP_Query::get_posts unit test ( 2TB Samsung HD's ) 1.5×10^12 - Milky Way