wpsmith / genesis-sandbox-featured-content-widget

Genesis Sandbox Featured Content Widget. Based on Nick Croft's Genesis Featured Widget Amplified for additional functionality which allows support for custom post types, taxonomies, and extends the flexibility of the widget via action hooks to allow the elements to be re-positioned or other elements to be added.
39 stars 21 forks source link

HTML5 Header/Footer sections #36

Open jalberts opened 10 years ago

jalberts commented 10 years ago

I noticed that the featured posts' title is not being wrapped in a <header> block. The StudioPress themes using HTML5 output their featured posts (standard Genesis Featured Posts widget) with the following structure:

<header class="entry-header">
    <h2 class="entry-title">
        <a href="http://example.com/example-post/">Example Post</a>
    </h2>
    <p class="byline post-info entry-meta">
        <time class="entry-time" itemprop="datePublished" datetime="2014-07-23T14:37:26+00:00">July 23, 2014</time> By <span class="entry-author" itemprop="author" itemscope="itemscope" itemtype="http://schema.org/Person"><a href="http://example.com/author/personx/" class="entry-author-link" itemprop="url" rel="author"><span class="entry-author-name" itemprop="name">Person X</span></a></span>
    </p>
</header>

The default CSS styling for, say the by line, relies on this structure and these classes. Specifically, they target .content .entry-header .entry-meta. So the header with its class, and the entry-meta class on the post-info <p> (which is not included in the output from this plugin).

It's easy enough to add the class in, but I thought I'd take a look at wrapping the title/byline and adding in a wrap for the post-meta with footer, if genesis_html5() returned true as a PR.

The problem is, the plugin creates and prints both parts separately. I see at least two options, but I thought I'd see which you'd prefer for a PR (or if you have a different idea):

  1. Merge the current do_byline() and do_post_title() functions into one function, generate the entire <header> section, and print it.
  2. Output the <header> wrap between both functions:
    • If byline position set to after title, output opening <header> in do_post_title().
    • If byline position set to before title, output closing </header> in do_post_title().
    • If byline position is set to after title, output closing </header> in do_byline().
    • If byline position is set to before title, output opening <header> in do_byline().

The latter is a bit more confusing, but I wanted your preference on which way to go with that.

I think for <footer> I can put that into the post-meta output.

On a related note, the latest HTML5 themes are also now correctly using <h1> instead of <h2> for the article title. I can submit a PR to conditionally handle that, too, if you'd like.