Permalink
Browse files

initial add

  • Loading branch information...
1 parent 7caa513 commit 3a5570211f4d5723055cfbc09a868a47650b88aa @alexkingorg committed Aug 25, 2012
Showing with 4,189 additions and 0 deletions.
  1. +17 −0 config.php
  2. +3 −0 content/delete-post/00-title.php
  3. +52 −0 content/delete-post/01-code.php
  4. +16 −0 content/intro/intro.php
  5. +3 −0 content/menus/00-title.php
  6. +5 −0 content/menus/01-example.php
  7. +12 −0 content/menus/02-db-tables.php
  8. +10 −0 content/menus/03-wp-options.php
  9. +10 −0 content/menus/04-wp-posts.php
  10. +14 −0 content/menus/05-wp-terms.php
  11. +3 −0 content/queries/00-title.php
  12. +9 −0 content/queries/01-why.php
  13. +111 −0 content/queries/02-wp-query-simple.php
  14. +163 −0 content/queries/03-wp-query-complex.php
  15. +18 −0 content/queries/04-wp-query-modifiers.php
  16. +23 −0 content/queries/05-get_post.php
  17. +5 −0 content/queries/06-performance.php
  18. +23 −0 content/queries/07-is-main-query.php
  19. +30 −0 content/queries/08-tools.php
  20. +6 −0 content/queries/css/queries.html
  21. BIN content/queries/img/debug-bar.png
  22. +16 −0 content/queries/js/queries.html
  23. +15 −0 content/return-values/00-title.php
  24. +3 −0 content/script-debug/00-title.php
  25. +8 −0 content/script-debug/01-constant.php
  26. +3 −0 content/security/00-title.php
  27. +5 −0 content/security/01-overview.php
  28. +21 −0 content/slashes/00-title.php
  29. +7 −0 content/slashes/01-preferred-model.php
  30. +15 −0 content/slashes/02-wp-model.php
  31. +68 −0 content/slashes/03-update-post-meta.php
  32. +47 −0 content/slashes/04-wp-insert-post.php
  33. +19 −0 content/slashes/05-wp-insert-user.php
  34. +6 −0 content/slashes/06-future.php
  35. +11 −0 content/slashes/js/slashes.html
  36. +3 −0 content/tax-vs-meta/00-title.php
  37. +9 −0 content/tax-vs-meta/01-overview.php
  38. +8 −0 content/tax-vs-meta/02-rules.php
  39. +4 −0 content/the-content/00-title.php
  40. +7 −0 content/the-content/01-data-sources.php
  41. +10 −0 content/the-content/02-example-id.php
  42. +11 −0 content/the-content/03-example-title.php
  43. +11 −0 content/the-content/04-content-source.php
  44. +6 −0 content/the-content/05-consistency.php
  45. +7 −0 content/the-content/06-revelation.php
  46. +9 −0 content/the-content/07-source.php
  47. +104 −0 content/the-content/08-path.php
  48. +144 −0 content/the-content/09-global-pages.php
  49. +11 −0 content/the-content/10-summary.php
  50. +3 −0 content/the-content/11-why.php
  51. +8 −0 content/the-content/12-lessons.php
  52. +3 −0 content/the-content/13-examples-title.php
  53. +75 −0 content/the-content/14-examples.php
  54. +38 −0 content/the-content/css/the-content.html
  55. BIN content/the-content/img/new-yorker-page-1-2.png
  56. +35 −0 content/the-content/js/the-content.html
  57. +3 −0 content/the-excerpt/00-title.php
  58. +9 −0 content/the-excerpt/01-overview.php
  59. +24 −0 content/the-excerpt/02-wp-trim-excerpt.php
  60. +68 −0 content/the-excerpt/03-edge-case.php
  61. +16 −0 content/the-excerpt/04-filter.php
  62. +16 −0 content/the-excerpt/js/the-excerpt.html
  63. +17 −0 content/wrap-up/00-credits.php
  64. +278 −0 css/global.css
  65. BIN fonts/inconsolata/v5/BjAYBlHtW3CJxDcjzrnZCLrIa-7acMAeDBVuclsi6Gc.woff
  66. BIN fonts/source-sans-pro/v2/toadOcfmlt9b38dHJxOBGNp0ELeHKGXh4I1VjlO9Cxo.woff
  67. BIN img/arrow.png
  68. BIN img/bg.png
  69. BIN img/counter.png
  70. +84 −0 index.php
  71. +48 −0 js/step-stages.js
  72. +2 −0 lib/google-code-prettify/lang-apollo.js
  73. +18 −0 lib/google-code-prettify/lang-clj.js
  74. +2 −0 lib/google-code-prettify/lang-css.js
  75. +1 −0 lib/google-code-prettify/lang-go.js
  76. +2 −0 lib/google-code-prettify/lang-hs.js
  77. +3 −0 lib/google-code-prettify/lang-lisp.js
  78. +2 −0 lib/google-code-prettify/lang-lua.js
  79. +2 −0 lib/google-code-prettify/lang-ml.js
  80. +4 −0 lib/google-code-prettify/lang-n.js
  81. +1 −0 lib/google-code-prettify/lang-proto.js
  82. +2 −0 lib/google-code-prettify/lang-scala.js
  83. +2 −0 lib/google-code-prettify/lang-sql.js
  84. +1 −0 lib/google-code-prettify/lang-tex.js
  85. +2 −0 lib/google-code-prettify/lang-vb.js
  86. +3 −0 lib/google-code-prettify/lang-vhdl.js
  87. +2 −0 lib/google-code-prettify/lang-wiki.js
  88. +3 −0 lib/google-code-prettify/lang-xq.js
  89. +2 −0 lib/google-code-prettify/lang-yaml.js
  90. +1 −0 lib/google-code-prettify/prettify.css
  91. +28 −0 lib/google-code-prettify/prettify.js
  92. +295 −0 lib/impress.js/README.md
  93. BIN lib/impress.js/apple-touch-icon.png
  94. +703 −0 lib/impress.js/css/impress-demo.css
  95. BIN lib/impress.js/favicon.png
  96. +438 −0 lib/impress.js/index.html
  97. +800 −0 lib/impress.js/js/impress.js
  98. +4 −0 lib/jquery/jquery-1.7.2.min.js
  99. +9 −0 lib/jquery/jquery.localscroll-1.2.7-min.js
  100. +11 −0 lib/jquery/jquery.scrollTo-1.4.2-min.js
View
@@ -0,0 +1,17 @@
+<?php
+
+$sections = array(
+ 'intro',
+ 'the-content',
+ 'the-excerpt',
+ 'slashes',
+ 'script-debug',
+ 'queries',
+ 'tax-vs-meta',
+ 'menus',
+// 'return-values',
+// include a plugin in a theme
+ 'delete-post',
+ 'security',
+ 'wrap-up',
+);
@@ -0,0 +1,3 @@
+ <section id="delete-post" class="step slide-title" data-x="<?php echo $data_x; ?>" data-y="<?php echo $data_y; ?>">
+ <h1>Delete Post</h1>
+ </section>
@@ -0,0 +1,52 @@
+ <section id="<?php echo section_id(); ?>" class="step slide" data-x="<?php echo $data_x; ?>" data-y="<?php echo $data_y; ?>">
+<!-- counter -->
+ <div class="counter">
+ <p>1 <span>of</span> 1</p>
+ </div>
+ <div class="scrollable">
+ <article class="stage">
+ <div class="inner-wrap">
+ <h2><code>wp_delete_post()</code></h2>
+ <p class="typ-sm">wp-includes/post.php, line 2022</p>
+ </div>
+ <div class="code-block">
+<pre class="code prettyprint linenums">function wp_delete_post( $postid = 0, $force_delete = false ) {
+
+// [...]
+
+ do_action('before_delete_post', $postid);
+
+// [...]
+
+ wp_delete_object_term_relationships($postid, get_object_taxonomies($post->post_type));
+
+// [...]
+
+ $comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $postid ));
+ foreach ( $comment_ids as $comment_id )
+ wp_delete_comment( $comment_id, true );
+
+ $post_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $postid ));
+ foreach ( $post_meta_ids as $mid )
+ delete_metadata_by_mid( 'post', $mid );
+
+ do_action( 'delete_post', $postid );</pre>
+ </div>
+ </article>
+ <article class="stage pad-top-1x">
+ <div class="code-block">
+<pre class="code prettyprint linenums"> do_action( 'delete_post', $postid );
+ $wpdb->delete( $wpdb->posts, array( 'ID' => $postid ) );
+ do_action( 'deleted_post', $postid );
+
+// [...]
+
+ do_action('after_delete_post', $postid);
+
+ return $post;
+}
+</pre>
+ </div>
+ </article>
+ </div>
+ </section>
View
@@ -0,0 +1,16 @@
+ <section id="intro" class="step slide-title" data-x="0" data-y="<?php echo $data_y; ?>">
+ <h1>Core Competency</h1>
+ <p>Alex King &middot; alexking.org</p>
+ </section>
+
+ <section id="bio" class="step slide" data-x="1024" data-y="<?php echo $data_y; ?>">
+ <div class="inner-wrap">
+ <ul class="typ-intro">
+ <li>Original contributor to WordPress core</li>
+ <li>Hosted first theme competitions for WordPress (2004, 2005)</li>
+ <li>Released dozens of plugins/themes</li>
+ <li>Architect of Carrington Core, <br>Carrington Build &amp; RAMP</li>
+ <li>Founder of Crowd Favorite</li>
+ </ul>
+ </div>
+ </section>
@@ -0,0 +1,3 @@
+ <section id="menus" class="step slide-title" data-x="<?php echo $data_x; ?>" data-y="<?php echo $data_y; ?>">
+ <h1>Menus</h1>
+ </section>
@@ -0,0 +1,5 @@
+ <section id="<?php echo section_id(); ?>" class="step slide pad-top-2x" data-x="<?php echo $data_x; ?>" data-y="<?php echo $data_y; ?>">
+ <div class="code-block">
+<pre class="code prettyprint linenums">&lt;php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?></pre>
+ </div>
+ </section>
@@ -0,0 +1,12 @@
+ <section id="<?php echo section_id(); ?>" class="step slide pad-top-1x" data-x="<?php echo $data_x; ?>" data-y="<?php echo $data_y; ?>">
+ <div class="inner-wrap">
+ <ul class="typ-intro">
+ <li>wp_options<br>&nbsp;</li>
+ <li>wp_posts</li>
+ <li>wp_postmeta<br>&nbsp;</li>
+ <li>wp_terms</li>
+ <li>wp_term_relationships</li>
+ <li>wp_term_taxonomy</li>
+ </ul>
+ </div>
+ </section>
@@ -0,0 +1,10 @@
+ <section id="<?php echo section_id(); ?>" class="step slide pad-top-1x" data-x="<?php echo $data_x; ?>" data-y="<?php echo $data_y; ?>">
+ <div class="inner-wrap">
+ <h2><code>wp_options</code></h2>
+ <ul class="typ-intro mar-top-2x">
+ <li>Maps menus to theme locations</li>
+ <li>Mapping is stored on a per-theme basis</li>
+ <li><code>theme_mods_(theme slug)</code></li>
+ </ul>
+ </div>
+ </section>
@@ -0,0 +1,10 @@
+ <section id="<?php echo section_id(); ?>" class="step slide" data-x="<?php echo $data_x; ?>" data-y="<?php echo $data_y; ?>">
+ <div class="inner-wrap">
+ <h2><code class="inline pad-left-none">wp_posts</code> &amp; <code class="inline">wp_postmeta</code></h2>
+ <ul class="typ-intro mar-top-2x">
+ <li>Menu items</li>
+ <li>Type of item, details about it</li>
+ <li><code>_menu_item_type, _menu_item_menu_item_parent, _menu_item_object_id, _menu_item_object, _menu_item_target, _menu_item_classes, _menu_item_xfn, <br>_menu_item_url</code></li>
+ </ul>
+ </div>
+ </section>
@@ -0,0 +1,14 @@
+ <section id="<?php echo section_id(); ?>" class="step slide pad-top-1x" data-x="<?php echo $data_x; ?>" data-y="<?php echo $data_y; ?>">
+ <div class="inner-wrap">
+ <h2>
+ <code class="inline pad-left-none">wp_terms</code>, <br>
+ <code class="inline pad-left-none">wp_term_taxonomy</code> &amp; <br>
+ <code class="inline pad-left-none">wp_term_relationships</code>
+ </h2>
+ <ul class="typ-intro mar-top-2x">
+ <li>wp_terms holds the menu name</li>
+ <li>wp_term_taxonomy stores the registration of the nav_menu taxonomy</li>
+ <li>wp_term_relationships attaches the menu items to the menu term</li>
+ </ul>
+ </div>
+ </section>
@@ -0,0 +1,3 @@
+ <section id="<?php echo section_id(); ?>" class="step slide-title" data-x="<?php echo $data_x; ?>" data-y="<?php echo $data_y; ?>">
+ <h1>Database Queries</h1>
+ </section>
@@ -0,0 +1,9 @@
+ <section id="<?php echo section_id(); ?>" class="step slide pad-top-1-5x" data-x="<?php echo $data_x; ?>" data-y="<?php echo $data_y; ?>">
+ <div class="inner-wrap">
+ <ul class="typ-intro">
+ <li>Most common performance bottleneck</li>
+ <li>Easiest way to improve page <br>generation time</li>
+ <li>Every database query should be intentional</li>
+ </ul>
+ </div>
+ </section>
@@ -0,0 +1,111 @@
+ <section id="<?php echo section_id(); ?>" class="step slide" data-x="<?php echo $data_x; ?>" data-y="<?php echo $data_y; ?>">
+
+<!-- counter -->
+ <div class="counter">
+ <p>1 <span>of</span> 1</p>
+ </div>
+
+ <div class="scrollable">
+
+
+<!-- 1 -->
+ <article class="stage">
+ <div class="inner-wrap">
+ <p>Get the two most recent posts.</p>
+ </div>
+ <div class="code-block">
+<pre class="code prettyprint linenums">$example = new WP_Query(array(
+ 'posts_per_page' => 2,
+ 'orderby' => 'date',
+ 'order' => 'DESC',
+));</pre>
+ </div>
+ </article>
+
+
+<!-- 2 -->
+ <article class="stage whoa">
+ <div class="inner-wrap">
+ <p>This actually generates <em>five</em> database queries.</p>
+ </div>
+ </article>
+
+
+<!-- 3 -->
+ <article class="stage">
+ <div class="inner-wrap">
+ <p>Query #1: find IDs of posts matching query args</p>
+ </div>
+ <div class="code-block">
+<pre class="code prettyprint linenums lang-sql">SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts
+WHERE 1=1
+AND wp_posts.post_type = 'post'
+AND (
+ wp_posts.post_status = 'publish'
+ OR wp_posts.post_status = 'future'
+ OR wp_posts.post_status = 'draft'
+ OR wp_posts.post_status = 'pending'
+ OR wp_posts.post_status = 'private'
+)
+ORDER BY wp_posts.post_date DESC
+LIMIT 0, 2</pre>
+ </div>
+ </article>
+
+
+<!-- 4 -->
+ <article class="stage">
+ <div class="inner-wrap">
+ <p>Query #2: check total number of results</p>
+ </div>
+ <div class="code-block">
+<pre class="code prettyprint linenums lang-sql">SELECT FOUND_ROWS()</pre>
+ </div>
+ </article>
+
+
+<!-- 5 -->
+ <article class="stage">
+ <div class="inner-wrap">
+ <p>Query #3: get full post data</p>
+ </div>
+ <div class="code-block">
+<pre class="code prettyprint linenums lang-sql">SELECT wp_posts.*
+FROM wp_posts
+WHERE ID IN (10134,10263)</pre>
+ </div>
+ </article>
+
+
+<!-- 6 -->
+ <article class="stage">
+ <div class="inner-wrap">
+ <p>Query #4: find taxonomy terms for selected posts</p>
+ </div>
+ <div class="code-block">
+<pre class="code prettyprint linenums lang-sql">SELECT t.*, tt.*, tr.object_id
+FROM wp_terms AS t
+INNER JOIN wp_term_taxonomy AS tt
+ ON tt.term_id = t.term_id
+INNER JOIN wp_term_relationships AS tr
+ ON tr.term_taxonomy_id = tt.term_taxonomy_id
+WHERE tt.taxonomy IN ('category', 'post_tag', 'post_format')
+AND tr.object_id IN (10134, 10263)
+ORDER BY t.name ASC</pre>
+ </div>
+ </article>
+
+
+<!-- 7 -->
+ <article class="stage">
+ <div class="inner-wrap">
+ <p>Query #5: find postmeta for selected posts</p>
+ </div>
+ <div class="code-block">
+<pre class="code prettyprint linenums lang-sql">SELECT post_id, meta_key, meta_value
+FROM wp_postmeta
+WHERE post_id IN (10134,10263)</pre>
+ </div>
+ </article>
+ </div>
+ </section>
Oops, something went wrong.

0 comments on commit 3a55702

Please sign in to comment.