Wordpress & HTML5 by Rob Larsen


Published on

Rob Larsen presentation at WordCamp

Published in: Education, Technology, Design
1 Like
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Note I didn’t use a <section> for the div id=content. It’s really just a generic container. If that was a section- the outline (which I’ll show you) would show “untitled section” because it’s not coupled with a header. The time element has a machine readable datetime attribute.
  • Note I didn’t use a <section> for the div id=content. It’s really just a generic container. If that was a section- the outline (which I’ll show you) would show “untitled section” because it’s not coupled with a header. The time element has a machine readable datetime attribute.
  • Wordpress & HTML5 by Rob Larsen

    1. 1. HTML5 + WordPress Rob Larsen 1.23.2010 htmlcssjavascript.com | drunkenfist.com @robreact htmlcssjavascript.com /downloads/wordpress.ppt
    2. 2. Who is this Guy Anyway? <ul><li>12+ years HTML/CSS/JavaScript. My job since 1999. </li></ul><ul><li>WordPress since 2005. Launched a ton of sites. Currently manage 6. </li></ul><ul><li>For the next 5 days: Principal Presentation Engineer at Cramer </li></ul><ul><li>Next Week: Molecular </li></ul><ul><li>PAST: AdvisorTech, Compete, Demandware, The Weekly Dig, Gillette, Museum of Science, Boston, PC Connection, State Street, Webex </li></ul>
    3. 3. Introduction to HTML5 <ul><ul><li>HTML5 is a lot of things- </li></ul></ul><ul><ul><li>Ongoing. This is a moving target. The spec can change underneath you. This can be fun, I swear. It also means there’s not always an answer. That, too, can be fun. </li></ul></ul><ul><ul><li>Occasionally controversial. </li></ul></ul><ul><ul><li>Full of cool stuff that’s got both browser and web developers excited </li></ul></ul><ul><ul><li>Something to pay attention to/ experiment with/ discuss and give feedback on (which is why we’re here today) </li></ul></ul>
    4. 4. What Are We Going To Talk About <ul><ul><li>Marking up a standard WordPress blog using some of the new, semantic elements/attributes. This is a subset of the spec that’s relatively stable and is usable right now. We’ll use a small bit of JavaScript or the Modernizr library to make styling these elements work in Internet Explorer. </li></ul></ul><ul><ul><li>Sweet. </li></ul></ul>
    5. 5. Meet the New Semantic Elements <ul><li><section> The section element represents a generic document or application section. A section, in this context, is a thematic grouping of content, typically with a heading. Examples of sections would be chapters, the various tabbed pages in a tabbed dialog box, or the numbered sections of a thesis. A Web site's home page could be split into sections for an introduction, news items, contact information. </li></ul>
    6. 6. Meet the New Semantic Elements <ul><li><nav> The nav element represents a section of a page that links to other pages or to parts within the page: a section with navigation links. Not all groups of links on a page need to be in a nav element — only sections that consist of major navigation blocks are appropriate for the nav element. In particular, it is common for footers to have a short list of links to various pages of a site, such as the terms of service, the home page, and a copyright page. The footer element alone is sufficient for such cases, without a nav element </li></ul>
    7. 7. Meet the New Semantic Elements <ul><li><article> The article element represents a component of a page that consists of a self-contained composition in a document, page, application, or site and that is intended to be independently distributable or reusable, e.g. in syndication. This could be a forum post, a magazine or newspaper article, a Web log entry, a user-submitted comment, an interactive widget or gadget, or any other independent item of content. </li></ul>
    8. 8. Meet the New Semantic Elements <ul><li><aside> The aside element represents a section of a page that consists of content that is tangentially related to the content around the aside element, and which could be considered separate from that content. Such sections are often represented as sidebars in printed typography. The element can be used for typographical effects like pull quotes or sidebars, for advertising, for groups of nav elements, and for other content that is considered separate from the main content of the page. </li></ul>
    9. 9. Meet the New Semantic Elements <ul><li><hgroup> The hgroup element represents the heading of a section. The element is used to group a set of h1–h6 elements when the heading has multiple levels, such as subheadings, alternative titles, or taglines. </li></ul><ul><li>“ Just another wordpress weblog” </li></ul>
    10. 10. Meet the New Semantic Elements <ul><li><header> The header element represents a group of introductory or navigational aids. A header element is intended to usually contain the section’s heading (an h1–h6 element or an hgroup element), but this is not required. The header element can also be used to wrap a section’s table of contents, a search form, or any relevant logos. </li></ul>
    11. 11. Meet the New Semantic Elements <ul><li><footer> The footer element represents a footer for its nearest ancestor sectioning content or sectioning root element. A footer typically contains information about its section such as who wrote it, links to related documents, copyright data, and the like. Footers don’t necessarily have to appear at the end of a section, though they usually do. When the footer element contains entire sections, they represent appendices, indexes, long colophons, verbose license agreements, and other such content. </li></ul>
    12. 12. Meet the New Semantic Elements <ul><li><time> The time element represents either a time on a 24 hour clock, or a precise date in the proleptic Gregorian calendar, optionally with a time and a time-zone offset. </li></ul>
    13. 13. Meet the New Semantic Elements <ul><li><form> <input> attributes </li></ul><ul><li>Placeholder Text/Search Boxes </li></ul><ul><li><input type=&quot;search&quot; placeholder=“Search Example.com&quot; name=&quot;s&quot; id=&quot;s&quot; /> </li></ul><ul><li>Email Addresses </li></ul><ul><li><input type=&quot;email&quot; class=&quot;text-input&quot; name=&quot;email&quot; id=&quot;email&quot; value=&quot;&quot; size=&quot;22&quot; tabindex=&quot;2&quot; aria-required='true' /> </li></ul><ul><li>Web Addresses </li></ul><ul><li><input type=&quot;url&quot; class=&quot;text-input&quot; name=&quot;url&quot; id=&quot;url&quot; value=&quot;&quot; size=&quot;22“ tabindex=&quot;3&quot; /> </li></ul>
    14. 14. Isn’t All That New Stuff Just About Perfect for Marking up a Blog? <ul><li>Heck yes. </li></ul>
    15. 15. Let’s Look at Some Code
    16. 16. header.php <ul><li><?php </li></ul><ul><li>/** </li></ul><ul><li>* @package WordPress </li></ul><ul><li>* @subpackage Kubrick_x_HTML5 </li></ul><ul><li>*/ </li></ul><ul><li>?> </li></ul><ul><li><!DOCTYPE html> </li></ul><ul><li><!--simplified!--> </li></ul><ul><li><html <?php language_attributes(); ?>> </li></ul><ul><li><!--simplified!--> </li></ul><ul><li><head profile=&quot;http://gmpg.org/xfn/11&quot;> </li></ul><ul><li><!--simplified!--> </li></ul><ul><li><meta charset=&quot;<?php bloginfo('charset'); ?>&quot; /> </li></ul><ul><li><title><?php wp_title('&laquo;', true, 'right'); ?> <?php bloginfo('name'); ?></title> </li></ul><ul><li><script type=&quot;text/javascript&quot;> </li></ul><ul><li>var elem; </li></ul><ul><li>var elems = 'abbr article aside audio canvas datalist details eventsource figure footer header hgroup mark menu meter nav output progress section time video'.split(' '); </li></ul><ul><li>var i = elems.length+1; </li></ul><ul><li>while ( --i ) { </li></ul><ul><li>elem = document.createElement( elems[i] ); </li></ul><ul><li>} </li></ul><ul><li>elem = null; </li></ul><ul><li></script> </li></ul><ul><li><link rel=&quot;stylesheet&quot; href=&quot;<?php bloginfo('stylesheet_url'); ?>&quot; media=&quot;screen&quot; /> </li></ul><ul><li><link rel=&quot;pingback&quot; href=&quot;<?php bloginfo('pingback_url'); ?>&quot; /> </li></ul>Default/Kubrick (part 1)
    17. 17. header.php <ul><li><style media=&quot;screen&quot;> </li></ul><ul><li><?php </li></ul><ul><li>// Checks to see whether it needs a sidebar or not </li></ul><ul><li>if ( empty($withcomments) && !is_single() ) { </li></ul><ul><li>?> </li></ul><ul><li>#page { background: url(&quot;<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbg-<?php bloginfo('text_direction'); ?>.jpg&quot;) repeat-y top; border: none; } </li></ul><ul><li><?php } else { // No sidebar ?> </li></ul><ul><li>#page { background: url(&quot;<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbgwide.jpg&quot;) repeat-y top; border: none; } </li></ul><ul><li><?php } ?> </li></ul><ul><li></style> </li></ul><ul><li><?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?> </li></ul><ul><li><?php wp_head(); ?> </li></ul><ul><li></head> </li></ul><ul><li><body <?php body_class(); ?>> </li></ul><ul><li><div id=&quot;page&quot;> </li></ul><ul><li><!--header--> </li></ul><ul><li><header id=&quot;header&quot; > </li></ul><ul><li><hgroup id=&quot;headerimg&quot;> </li></ul><ul><li><h1><a href=&quot;<?php echo get_option('home'); ?>/&quot;><?php bloginfo('name'); ?></a></h1> </li></ul><ul><li><h2 class=&quot;description&quot;><?php bloginfo('description'); ?></h2> </li></ul><ul><li></hgroup> </li></ul><ul><li></header> </li></ul><ul><li><hr /> </li></ul>Default/Kubrick (part 2)
    18. 18. header.php <ul><li><!DOCTYPE html> </li></ul><ul><li><html <?php language_attributes(); ?> class=“no-js”> </li></ul><ul><li><head profile=&quot;http://gmpg.org/xfn/11&quot;> </li></ul><ul><li><title> </li></ul><ul><li><?php if ( is_front_page() ) {bloginfo('name');?> | Fresh Ideas Caught and Served <?php } else {;?> </li></ul><ul><li><?php bloginfo('name');?> | </li></ul><ul><li><?php if($post->post_parent) { </li></ul><ul><li>$parent_title = get_the_title($post->post_parent); </li></ul><ul><li>echo $parent_title;?> </li></ul><ul><li>&ndash; </li></ul><ul><li><?php }?> </li></ul><ul><li><?php wp_title(''); ?> </li></ul><ul><li><?php } ?> </li></ul><ul><li></title> </li></ul><ul><li><meta charset=&quot;<?php bloginfo('charset'); ?>&quot; /> </li></ul><ul><li><meta name=&quot;description&quot; content=&quot;<?php echo get_post_meta($post->ID, &quot;meta-description&quot;, &quot;true&quot;); ?>&quot; /> </li></ul><ul><li><link rel=&quot;shortcut icon&quot; href=&quot;http://static.crameronline.com/_assets/images/favicon.ico&quot;/> </li></ul><ul><li><script type=&quot;text/javascript&quot;> </li></ul><ul><li>var ___baseURL =&quot;<?php bloginfo('template_directory'); ?>&quot;; </li></ul><ul><li></script> </li></ul><ul><li><!—one file, which contains Modernizr  </li></ul><ul><li><script type=&quot;text/javascript&quot; src=&quot;<?php bloginfo('template_directory'); ?>/_assets/scripts/b.c.js&quot;></script> </li></ul>AwiderNet.com
    19. 19. View Source <ul><li><html lang=&quot;en-US&quot; dir=&quot;ltr&quot; class=&quot;js canvas canvastext geolocation rgba hsla no-multiplebgs borderimage borderradius boxshadow opacity no-cssanimations csscolumns no-cssgradients no-cssreflections csstransforms no-csstransforms3d no-csstransitions video audio fontface&quot;> </li></ul><ul><li><!– such is the power of modernizr  </li></ul><ul><li><head profile=&quot;http://gmpg.org/xfn/11&quot;> </li></ul><ul><li><title>A Wider Net | Fresh Ideas Caught and Served </title> </li></ul><ul><li><meta charset=&quot;UTF-8&quot;> </li></ul>AwiderNet.com
    20. 20. index.php <?php /** * @package WordPress * @subpackage Kubrick_x_HTML5 */ get_header(); ?> <div id=&quot;content&quot; class=&quot;narrowcolumn&quot; > <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <article <?php post_class() ?> id=&quot;post-<?php the_ID(); ?>&quot;> <h1> <a href=&quot;<?php the_permalink() ?>&quot; rel=&quot;bookmark&quot; title=&quot;Permanent Link to <?php the_title_attribute(); ?>&quot;><?php the_title(); ?></a> </h1> <time datetime=&quot;<?php the_time('c') ?>&quot; pubdate=&quot;pubdate&quot;><?php the_time('F jS, Y') ?></time> <div class=&quot;entry&quot;> <?php the_content('Read the rest of this entry &raquo;'); ?> </div> <p class=&quot;postmetadata&quot;><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p> </article> <?php endwhile; ?> <nav class=&quot;navigation&quot;> <div class=&quot;alignleft&quot;><?php next_posts_link('&laquo; Older Entries') ?></div> <div class=&quot;alignright&quot;><?php previous_posts_link('Newer Entries &raquo;') ?></div> </nav> <?php else : ?> <h1 class=&quot;center&quot;>Not Found</h1> <p class=&quot;center&quot;>Sorry, but you are looking for something that isn't here.</p> <?php get_search_form(); ?> <?php endif; ?> </div> <?php get_sidebar(); ?> <?php get_footer(); ?> Default/Kubrick
    21. 21. View Source s<article id=&quot;post-3&quot; class=&quot;post-3 post hentry category-uncategorized&quot;> <h1><a title=&quot;Permanent Link to This Is an HTML5ized Version of the Default Wordpress Theme&quot; rel=&quot;bookmark&quot; href=&quot;http://htmlcssjavascript.com/dev/?p=3&quot;>This Is an HTML5ized Version of the Default Wordpress Theme</a></h1> <time pubdate=&quot;pubdate&quot; datetime=&quot;2010-01-17T21:52:52+00:00&quot;>January 17th, 2010</time> <div class=&quot;entry&quot;> <p>Source Code and discussion.</p> </div> <p class=&quot;postmetadata&quot;> Posted in <a rel=&quot;category&quot; title=&quot;View all posts in Uncategorized&quot; href=&quot;http://htmlcssjavascript.com/dev/?cat=1&quot;>Uncategorized</a> | <a title=&quot;Edit post&quot; href=&quot;http://htmlcssjavascript.com/dev/wp-admin/post.php?action=edit&amp;post=3&quot; class=&quot;post-edit-link&quot;>Edit</a> | <a title=&quot;Comment on This Is an HTML5ized Version of the Default Wordpress Theme&quot; href=&quot;http://htmlcssjavascript.com/dev/?p=3#respond&quot;>No Comments »</a></p> </article> Default/Kubrick
    22. 22. sidebar.php <?php /** * @package WordPress * @subpackage Kubrick_x_HTML5 */ ?> <aside id=&quot;sidebar&quot; > <ul> <?php /* Widgetized sidebar, if you have the plugin installed. */ if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?> <!-- SNIP --> </li> <?php }?> </ul> <nav> <ul> <?php wp_list_pages('title_li=<h2>Pages</h2>' ); ?> <li><h2>Archives</h2> <ul> <?php wp_get_archives('type=monthly'); ?> </ul> </li> <?php wp_list_categories('show_count=1&title_li=<h2>Categories</h2>'); ?> </ul> </nav> <ul> <?php /* If this is the frontpage */ if ( is_home() || is_page() ) { ?> <?php wp_list_bookmarks(); ?> <li><h2>Meta</h2> <!-- SNIP --> </li> <?php } ?> <?php endif; ?> </ul> </aside> Default/Kubrick
    23. 23. searchform.php <?php /** * @package WordPress * @subpackage Kubrick_x_HTML5 */ ?> <form method=&quot;get&quot; id=&quot;searchform&quot; action=&quot;<?php bloginfo('url'); ?>&quot; > <div> <label class=&quot;screen-reader-text&quot; for=&quot;s&quot;>Search for:</label> <input type=&quot;search&quot; placeholder=&quot;Search <?php bloginfo('blogtitle'); ?>&quot; name=&quot;s&quot; id=&quot;s&quot; /> <input type=&quot;submit&quot; id=&quot;searchsubmit&quot; value=&quot;Search&quot; /> </div> </form> Default/Kubrick
    24. 24. comments.php <?php // snip! ?> <?php if ( comments_open() ) : ?> <div id=&quot;comment-form&quot;> <h2><?php comment_form_title( 'Leave a comment', 'Leave a Reply to %s' ); ?></h2> <div class=&quot;cancel-comment-reply&quot;> <small><?php cancel_comment_reply_link(); ?></small> </div> <?php if ( get_option('comment_registration') && !is_user_logged_in() ) : ?> <p>You must be <a href=&quot;<?php echo wp_login_url( get_permalink() ); ?>&quot;>logged in</a> to post a comment.</p> <?php else : ?> <form action=&quot;<?php echo get_option('siteurl'); ?>/wp-comments-post.php&quot; method=&quot;post&quot; id=&quot;commentform&quot;> <?php if ( is_user_logged_in() ) : ?> <p>Logged in as <a href=&quot;<?php echo get_option('siteurl'); ?>/wp-admin/profile.php&quot;><?php echo $user_identity; ?></a>. <a href=&quot;<?php echo wp_logout_url(get_permalink()); ?>&quot; title=&quot;Log out of this account&quot;>Log out &raquo;</a></p> <?php else : ?> <p><label for=&quot;author&quot;><small>Name <?php if ($req) echo &quot;(required)&quot;; ?></small></label><input type=&quot;text&quot; class=&quot;text-input&quot; name=&quot;author&quot; id=&quot;author&quot; value=&quot;<?php echo esc_attr($comment_author); ?>&quot; size=&quot;22&quot; tabindex=&quot;1&quot; <?php if ($req) echo &quot;aria-required='true'&quot;; ?> /> </p> <p><label for=&quot;email&quot;><small>Mail (will not be published) <?php if ($req) echo &quot;(required)&quot;; ?></small></label> <input type=&quot;email&quot; class=&quot;text-input&quot; name=&quot;email&quot; id=&quot;email&quot; value=&quot;<?php echo esc_attr($comment_author_email); ?>&quot; size=&quot;22&quot; tabindex=&quot;2&quot; <?php if ($req) echo &quot;aria-required='true'&quot;; ?> /></p> <p><label for=&quot;url&quot;><small>Website</small></label>< input type=&quot;url&quot; class=&quot;text-input&quot; name=&quot;url&quot; id=&quot;url&quot; value=&quot;<?php echo esc_attr($comment_author_url); ?>&quot; size=&quot;22&quot; tabindex=&quot;3&quot; /> </p> <?php endif; ?> <p><label for=&quot;comment&quot;><small>Comments</small></label> <textarea name=&quot;comment&quot; cols=&quot;100%&quot; rows=&quot;10&quot; tabindex=&quot;4&quot;></textarea> </p> <div class=&quot;button&quot;><input name=&quot;submit&quot; type=&quot;submit&quot; id=&quot;submit&quot; tabindex=&quot;5&quot; value=&quot;Submit&quot; /></div> <?php comment_id_fields(); ?> <?php do_action('comment_form', $post->ID); ?> </form> <!—SNIP-  AWiderNet
    25. 25. footer.php <?php /** * @package WordPress * @subpackage Kubrick_x_HTML5 */ ?> <hr /> <footer id=&quot;footer&quot; > <!-- If you'd like to support WordPress, having the &quot;powered by&quot; link somewhere on your blog is the best way; it's our only promotion or advertising. --> <p> <?php bloginfo('name'); ?> is proudly powered by <a href=&quot;http://wordpress.org/&quot;>WordPress</a> <br /><a href=&quot;<?php bloginfo('rss2_url'); ?>&quot;>Entries (RSS)</a> and <a href=&quot;<?php bloginfo('comments_rss2_url'); ?>&quot;>Comments (RSS)</a>. <!-- <?php echo get_num_queries(); ?> queries. <?php timer_stop(1); ?> seconds. --> </p> </footer> </div> <!-- Gorgeous design by Michael Heilemann - http://binarybonsai.com/kubrick/ --> <?php /* &quot;Just what do you think you're doing Dave?&quot; */ ?> <?php wp_footer(); ?> </body> </html> Default/Kubrick
    26. 26. What’s the Diff? footer.php
    27. 27. archives.php <?php /** * @package WordPress * @subpackage Kubrick_x_HTML5 */ /* Template Name: Archives */ ?> <?php get_header(); ?> <div id=&quot;content&quot; class=&quot;widecolumn&quot;> <?php get_search_form(); ?> <section> <h2>Archives by Month:</h2> <ul> <?php wp_get_archives('type=monthly'); ?> </ul> </section> <section> <h2>Archives by Subject:</h2> <ul> <?php wp_list_categories(); ?> </ul> </section> </div> <?php get_footer(); ?> Kubrick/default
    28. 28. style.css /*SNIP!*/ /* Begin Structure */ body { margin: 0 0 20px 0; padding: 0; } /*HTML5*/ footer, section, article, aside, header, time { display:block; } #page { background-color: white; margin: 20px auto; padding: 0; width: 760px; border: 1px solid #959596; } #header /*SNIP!*/ Kubrick/default
    29. 29. What’s the Diff? style.css
    30. 30. style.css .borderradius.boxshadow.rgba #container #main article, .borderradius.boxshadow.rgba #container #main #posts > .meta-data, .borderradius.boxshadow.rgba #container #main #posts #no-results, .borderradius.boxshadow.rgba #container #main #posts .author { border-radius:10px; -moz-border-radius:10px; -webkit-border-radius:10px; -moz-box-shadow: 0px 0px 5px rgba(0, 0, 0, .15); box-shadow: 0px 0px 5px rgba(0, 0, 0, .15); -webkit-box-shadow: 0px 0px 5px rgba(0, 0, 0, .15); background:#fff; overflow: hidden; } AWiderNet
    31. 31. PSST! CSS3
    32. 32. Things I Learned <ul><li>The new outline algorithm is a fickle master </li></ul><ul><li>Otherwise- not so bad. </li></ul><ul><li>Kubrick worked with almost no browser specific intervention in modern browsers </li></ul>
    33. 33. Any Questions?
    34. 34. More Info <ul><li>http://www.whatwg.org/ </li></ul><ul><li>http://diveintohtml5.org/ </li></ul><ul><li>http://www.modernizr.com/ </li></ul><ul><li>http://gsnedders.html5.org/outliner/ </li></ul><ul><li>http://htmlcssjavascript.com/html/im-messing-around-with-an-html5-version-of-the-default-wordpress-theme/ </li></ul>