<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[781] sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer: Code Reference: streamline UI for archive/search listings</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://meta.trac.wordpress.org/changeset/781">781</a></dd>
<dt>Author</dt> <dd>coffee2code</dd>
<dt>Date</dt> <dd>2014-08-12 06:26:08 +0000 (Tue, 12 Aug 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Code Reference: streamline UI for archive/search listings

* Add content-reference-archive.php template and use it for archive and search listings
* Add wporg_filter_archive_excerpt() and use it to prefix post type label to excerpts in archive listings
* Add wporg_filter_archive_title() and use it to append '()' to titles for function-like post types in archive listings
* Add get_line_number() to get either start or end line number
* Display simplified archive listing (no full method signature, no parts highlighting)
* Add post type label, source file relative path, and start line number to archive listed items

fixes <a href="http://meta.trac.wordpress.org/ticket/450">#450</a>
props nicolealleyinteractivecom</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperarchivephp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/archive.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperheaderphp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/header.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperincextrasphp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/extras.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperinctemplatetagsphp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperscssmainscss">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/scss/main.scss</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdevelopersearchphp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/search.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperstylesheetsmaincss">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/stylesheets/main.css</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdevelopercontentreferencearchivephp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/content-reference-archive.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperarchivephp"></a>
<div class="modfile"><h4>Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/archive.php (780 => 781)</h4>
<pre class="diff"><span>
<span class="info">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/archive.php  2014-08-12 06:20:51 UTC (rev 780)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/archive.php     2014-08-12 06:26:08 UTC (rev 781)
</span><span class="lines">@@ -22,13 +22,7 @@
</span><span class="cx">                          <?php /* Start the Loop */ ?>
</span><span class="cx">                          <?php while ( have_posts() ) : the_post(); ?>
</span><span class="cx"> 
</span><del>-                                       <?php
-                                               /* Include the Post-Format-specific template for the content.
-                                                * If you want to override this in a child theme, then include a file
-                                                * called content-___.php (where ___ is the Post Format name) and that will be used instead.
-                                                */
-                                               get_template_part( 'content', 'reference' );
-                                       ?>
</del><ins>+                                        <?php get_template_part( 'content', 'reference-archive' ); ?>
</ins><span class="cx"> 
</span><span class="cx">                          <?php endwhile; ?>
</span><span class="cx"> 
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdevelopercontentreferencearchivephp"></a>
<div class="addfile"><h4>Added: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/content-reference-archive.php (0 => 781)</h4>
<pre class="diff"><span>
<span class="info">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/content-reference-archive.php                                (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/content-reference-archive.php   2014-08-12 06:26:08 UTC (rev 781)
</span><span class="lines">@@ -0,0 +1,20 @@
</span><ins>+<?php namespace DevHub;
+/**
+ * The template used for displaying reference content in archive.php & search.php
+ *
+ * @package wporg-developer
+ */
+?>
+
+<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
+
+       <h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
+
+       <div class="description">
+               <?php the_excerpt(); ?>
+       </div>
+       <div class="sourcefile">
+               <p>Source: <?php echo get_source_file(); ?>:<?php echo get_line_number(); ?></p>
+       </div>
+
+</article>
</ins><span class="cx">\ No newline at end of file
</span><span class="cx">Property changes on: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/content-reference-archive.php
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<ins>+native
</ins><span class="cx">\ No newline at end of property
</span><a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperheaderphp"></a>
<div class="modfile"><h4>Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/header.php (780 => 781)</h4>
<pre class="diff"><span>
<span class="info">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/header.php   2014-08-12 06:20:51 UTC (rev 780)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/header.php      2014-08-12 06:26:08 UTC (rev 781)
</span><span class="lines">@@ -9,7 +9,7 @@
</span><span class="cx"> require WPORGPATH . 'header.php';
</span><span class="cx"> ?>
</span><span class="cx"> 
</span><del>-<div id="page" class="hfeed site devhub-wrap">
</del><ins>+<div id="page" <?php body_class( 'hfeed site devhub-wrap' ); ?>>
</ins><span class="cx">   <?php do_action( 'before' ); ?>
</span><span class="cx">  <header id="masthead" class="site-header" role="banner">
</span><span class="cx">          <div class="inner-wrap">
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperincextrasphp"></a>
<div class="modfile"><h4>Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/extras.php (780 => 781)</h4>
<pre class="diff"><span>
<span class="info">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/extras.php       2014-08-12 06:20:51 UTC (rev 780)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/extras.php  2014-08-12 06:26:08 UTC (rev 781)
</span><span class="lines">@@ -66,3 +66,33 @@
</span><span class="cx">  return $title;
</span><span class="cx"> }
</span><span class="cx"> add_filter( 'wp_title', 'wporg_developer_wp_title', 10, 2 );
</span><ins>+
+/**
+ * Prefixes excerpts for archive view with content type label.
+ *
+ * @param  string $excerpt The excerpt.
+ * @return string
+ */
+function wporg_filter_archive_excerpt( $excerpt ) {
+       if ( ! is_single() ) {
+               $excerpt = '<b>' . get_post_type_labels( get_post_type_object( get_post_type( get_the_ID() ) ) )->singular_name . ': </b>' . $excerpt;
+       }
+
+       return $excerpt;
+}
+add_filter( 'get_the_excerpt', 'wporg_filter_archive_excerpt' );
+
+/**
+ * Appends parentheses to titles in archive view for functions and methods.
+ *
+ * @param  string $title The title.
+ * @return string
+ */
+function wporg_filter_archive_title( $title ) {
+       if ( ! is_single() && in_array( get_post_type(), array( 'wp-parser-function', 'wp-parser-method' ) ) ) {
+               $title .= '()';
+       }
+
+       return $title;
+}
+add_filter( 'the_title', 'wporg_filter_archive_title' );
</ins></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperinctemplatetagsphp"></a>
<div class="modfile"><h4>Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php (780 => 781)</h4>
<pre class="diff"><span>
<span class="info">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php        2014-08-12 06:20:51 UTC (rev 780)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php   2014-08-12 06:26:08 UTC (rev 781)
</span><span class="lines">@@ -622,6 +622,22 @@
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  /**
</span><ins>+        * Retrieve either the starting or ending line number.
+        *
+        * @param  int    $post_id Optional. The post ID.
+        * @param  string $type    Optional. Either 'start' for starting line number, or 'end' for ending line number.
+        *
+        * @return int
+        */
+       function get_line_number( $post_id = null, $type = 'start' ) {
+
+               $post_id  = empty( $post_id ) ? get_the_ID() : $post_id;
+               $meta_key = ( 'end' == $type ) ? '_wp-parser_end_line_num' : '_wp-parser_line_num';
+
+               return (int) get_post_meta( $post_id, $meta_key, true );
+       }
+
+       /**
</ins><span class="cx">    * Retrieve the URL to the actual source file and line.
</span><span class="cx">   *
</span><span class="cx">   * @param null $post_id     Post ID.
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperscssmainscss"></a>
<div class="modfile"><h4>Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/scss/main.scss (780 => 781)</h4>
<pre class="diff"><span>
<span class="info">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/scss/main.scss       2014-08-12 06:20:51 UTC (rev 780)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/scss/main.scss  2014-08-12 06:26:08 UTC (rev 781)
</span><span class="lines">@@ -882,6 +882,24 @@
</span><span class="cx">          }
</span><span class="cx">  }
</span><span class="cx"> 
</span><ins>+       &.archive, &.search {
+               .wp-parser-class, .wp-parser-function, .wp-parser-hook, .wp-parser-method {
+                       h1 {
+                               a {
+                                       font-family: $body-font;
+                                       color: #21759b;
+                                       font-weight: normal;
+                               }
+                       }
+                       div {
+                               &.sourcefile {
+                                       color: #999999;
+                                       font-style: italic;
+                               }
+                       }
+               }
+       }
+
</ins><span class="cx">   .single {
</span><span class="cx">          .wp-parser-class, .wp-parser-function, .wp-parser-hook, .wp-parser-method {
</span><span class="cx">                  border-bottom-style: none;
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdevelopersearchphp"></a>
<div class="modfile"><h4>Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/search.php (780 => 781)</h4>
<pre class="diff"><span>
<span class="info">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/search.php   2014-08-12 06:20:51 UTC (rev 780)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/search.php      2014-08-12 06:26:08 UTC (rev 781)
</span><span class="lines">@@ -23,7 +23,7 @@
</span><span class="cx">                  <?php /* Start the Loop */ ?>
</span><span class="cx">                  <?php while ( have_posts() ) : the_post(); ?>
</span><span class="cx"> 
</span><del>-                               <?php get_template_part( 'content', 'reference' ); ?>
</del><ins>+                                <?php get_template_part( 'content', 'reference-archive' ); ?>
</ins><span class="cx"> 
</span><span class="cx">                  <?php endwhile; ?>
</span><span class="cx"> 
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperstylesheetsmaincss"></a>
<div class="modfile"><h4>Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/stylesheets/main.css (780 => 781)</h4>
<pre class="diff"><span>
<span class="info">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/stylesheets/main.css 2014-08-12 06:20:51 UTC (rev 780)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/stylesheets/main.css    2014-08-12 06:26:08 UTC (rev 781)
</span><span class="lines">@@ -1093,6 +1093,15 @@
</span><span class="cx">   border-radius: 5px;
</span><span class="cx">   padding: 20px;
</span><span class="cx"> }
</span><ins>+.devhub-wrap.archive .wp-parser-class h1 a, .devhub-wrap.archive .wp-parser-function h1 a, .devhub-wrap.archive .wp-parser-hook h1 a, .devhub-wrap.archive .wp-parser-method h1 a, .devhub-wrap.search .wp-parser-class h1 a, .devhub-wrap.search .wp-parser-function h1 a, .devhub-wrap.search .wp-parser-hook h1 a, .devhub-wrap.search .wp-parser-method h1 a {
+  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
+  color: #21759b;
+  font-weight: normal;
+}
+.devhub-wrap.archive .wp-parser-class div.sourcefile, .devhub-wrap.archive .wp-parser-function div.sourcefile, .devhub-wrap.archive .wp-parser-hook div.sourcefile, .devhub-wrap.archive .wp-parser-method div.sourcefile, .devhub-wrap.search .wp-parser-class div.sourcefile, .devhub-wrap.search .wp-parser-function div.sourcefile, .devhub-wrap.search .wp-parser-hook div.sourcefile, .devhub-wrap.search .wp-parser-method div.sourcefile {
+  color: #999999;
+  font-style: italic;
+}
</ins><span class="cx"> .devhub-wrap .single .wp-parser-class, .devhub-wrap .single .wp-parser-function, .devhub-wrap .single .wp-parser-hook, .devhub-wrap .single .wp-parser-method {
</span><span class="cx">   border-bottom-style: none;
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>