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

WordPress WTF

Fc7368fd45560e1e7401bc80684f5867?s=47 Adam Onishi
February 24, 2014

WordPress WTF

After you’ve spent many years working with something, you start to get to that point where you feel competent, that you can do anything and every problem has a solution. However, with this understanding you also get to a point where as well as seeing how something works, you can also see how badly it does it. This is the point Adam has come to with WordPress.

In this talk, you’ll take a look over some weaknesses with WordPress, exploring downsides of the architecture, the theming and some more general problems around the platform. But also you’ll see how to avoid these problems and write better themes, plugins, and websites with WordPress.

Video here: http://www.supermondays.org/2014/02/25/content-management-systems-videos/

Fc7368fd45560e1e7401bc80684f5867?s=128

Adam Onishi

February 24, 2014
Tweet

Transcript

  1. @onishiweb What The F...!

  2. @onishiweb

  3. @onishiweb Photo by Dan Goven: http://flic.kr/p/js7sdf

  4. @onishiweb

  5. @onishiweb Shameless Plug

  6. @onishiweb

  7. @onishiweb

  8. @onishiweb WTF WordPress?

  9. @onishiweb Templates...

  10. @onishiweb Templates are built procedurally <?php get_header(); ?> <!-- Stuff

    --> <?php get_sidebar(); ?> <?php get_footer(); ?>
  11. @onishiweb No separation of logic from the view

  12. @onishiweb

  13. @onishiweb Template Tags...

  14. @onishiweb Content Tags are alright <!-- Output the title -->

    <h1><?php the_title(); ?></h1> <!-- Return the title --> <h1><?php echo get_the_title(); ?></h1>
  15. @onishiweb If sometimes a little confusing <!-- Output the content

    formatted --> <?php the_content(); ?> <!-- Return the content, NO formatting --> <?php echo get_the_content(); ?>
  16. @onishiweb A bit more confusing... <!-- Setup the current post...

    --> <?php the_post(); ?>
  17. @onishiweb A bit more confusing... <?php // The Loop if(

    have_posts() ): while( have_posts() ): the_post(); /* Do stuff */ endwhile; endif; ?>
  18. @onishiweb And even more confusing! <!-- Output the search form

    --> <?php get_search_form(); ?>
  19. @onishiweb Template Tags But...

  20. @onishiweb IDs..!

  21. @onishiweb IDs EVERYWHERE! <!-- Output of <?php body_class(); ?> -->

    <body class="home page page-id-7 page- template-default page"> <!-- Nav menu output --> <li id="menu-item-36" class="menu-item-pink menu-item menu-item-type-custom menu-item- object-custom menu-item-36">
  22. @onishiweb IDs EVERYWHERE! <!-- Output of <?php body_class(); ?> -->

    <body class="home page page-id-7 page- template-default page"> <!-- Nav menu output --> <li id="menu-item-36" class="menu-item-pink menu-item menu-item-type-custom menu-item- object-custom menu-item-36">
  23. @onishiweb IDs EVERYWHERE! <!-- Output of <?php body_class(); ?> -->

    <body class="home page page-id-7 page- template-default page"> <!-- Nav menu output --> <li id="menu-item-36" class="menu-item-pink menu-item menu-item-type-custom menu-item- object-custom menu-item-36">
  24. @onishiweb WordPress Hooks to the rescue add_filter('body_class', ... ); add_filter('post_class',

    ... );
  25. @onishiweb Add better classes function dig_add_useful_classes($classes) { global $post; if(

    ! is_tag() ) { $classes[] = dig_get_post_type_class(); } if( is_page() ) { global $post; $classes[] = 'page-' . $post->post_name; } return $classes; } https://gist.github.com/onishiweb/9151982
  26. @onishiweb Add better classes function dig_get_post_type_class( $type = false )

    { if( ! $type ) { $type = dig_current_post_type(); } $class = str_replace('dig_', '', $type); $class = str_replace('_', '-', $class); return $class; } https://gist.github.com/onishiweb/9151992
  27. @onishiweb Add better classes function dig_current_post_type() { global $post; if(

    ! is_tag() ) { $type_name = get_post_type(); if( ! $type_name ) { $taxonomy = get_query_var( 'taxonomy' ); $type_name = substr_replace($taxonomy, '', -9); } return $type_name; } } https://gist.github.com/onishiweb/9152009
  28. @onishiweb Better classes = Happy Adam! <!-- Post type archive

    page --> <body class="archive post-type-archive post-type-archive-dig_product product"> <!-- Taxonomy archive --> <body class="archive tax- dig_product_filter_2 term-detergent term-114 product">
  29. @onishiweb WP-Admin...

  30. @onishiweb

  31. @onishiweb

  32. @onishiweb

  33. @onishiweb

  34. @onishiweb

  35. @onishiweb WP-Admin But...

  36. @onishiweb

  37. @onishiweb @MKJONES @MWTSN http://wpclarity.com/

  38. @onishiweb Plugins...

  39. @onishiweb Plugins...

  40. @onishiweb Biggest lesson learnt from this current project: WordPress plugins

    are largely evil, and should not be relied on for core functionality - Alex Jegtnes (@jegtnes)
  41. @onishiweb Have you tried deactivating your plugins?

  42. @onishiweb Plugins But...

  43. @onishiweb

  44. @onishiweb It’s not all bad...

  45. @onishiweb Open Source

  46. @onishiweb The Codex

  47. @onishiweb The Community!

  48. @onishiweb Photo by Jonny Allbut: http://flic.kr/p/hQbbEq

  49. @onishiweb Thank You