<!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>[3892] sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc: Support Forums: Move logic into parent class, and display-specific functions into child compat classes.</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" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://meta.trac.wordpress.org/changeset/3892">3892</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/3892","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>jmdodd</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-08-31 16:58:29 +0000 (Wed, 31 Aug 2016)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Support Forums: Move logic into parent class, and display-specific functions into child compat classes.

Theme and plugin views share many behaviors; to avoid trying to keep both updated, this moves taxonomy registration, tests for loading actions and filters, view registration, rewrite rules, and general display logic into the general directory compat class.

Constants, helper functions, and unique display methods have been separated into their respective plugin or theme compat class.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginssupportforumsincclassdirectorycompatphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-directory-compat.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginssupportforumsincclassplugindirectorycompatphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-plugin-directory-compat.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginssupportforumsincclassthemedirectorycompatphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-theme-directory-compat.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginssupportforumsincclassdirectorycompatphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-directory-compat.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-directory-compat.php    2016-08-31 16:13:09 UTC (rev 3891)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-directory-compat.php      2016-08-31 16:58:29 UTC (rev 3892)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5,32 +5,95 @@
</span><span class="cx" style="display: block; padding: 0 10px"> abstract class Directory_Compat {
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        abstract protected function compat();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        abstract protected function compat_title();
</ins><span class="cx" style="display: block; padding: 0 10px">         abstract protected function slug();
</span><span class="cx" style="display: block; padding: 0 10px">        abstract protected function title();
</span><span class="cx" style="display: block; padding: 0 10px">        abstract protected function forum_id();
</span><span class="cx" style="display: block; padding: 0 10px">        abstract protected function query_var();
</span><span class="cx" style="display: block; padding: 0 10px">        abstract protected function taxonomy();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        abstract protected function parse_query();
+       abstract protected function do_view_sidebar();
+       abstract protected function do_topic_sidebar();
+       abstract protected function get_view_header();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        public function __construct() {}
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var $authors      = null;
+       var $contributors = null;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        public function init() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                if ( defined( 'WPORG_SUPPORT_FORUMS_BLOGID' ) && get_current_blog_id() == WPORG_SUPPORT_FORUMS_BLOGID ) {
+                       // Define the taxonomy and query vars for this view.
+                       add_action( 'plugins_loaded', array( $this, 'always_load' ) );
+
+                       // We have to add the custom view before bbPress runs its own action
+                       // on parse_query at priority 2.
+                       add_action( 'parse_query', array( $this, 'parse_query' ), 0 );
+
+                       // And this still needs to happen before priority 2.
+                       add_action( 'parse_query', array( $this, 'maybe_load' ), 1 );
+
+                       // Check to see if an individual topic is compat.
+                       add_action( 'template_redirect', array( $this, 'check_topic_for_compat' ) );
+               }
+       }
+
+       public function always_load() {
+               // Add filters necessary for determining which compat file to use.
</ins><span class="cx" style="display: block; padding: 0 10px">                 add_action( 'bbp_init',              array( $this, 'register_taxonomy' ) );
</span><span class="cx" style="display: block; padding: 0 10px">                add_filter( 'query_vars',            array( $this, 'add_query_var' ) );
</span><span class="cx" style="display: block; padding: 0 10px">                add_action( 'bbp_add_rewrite_rules', array( $this, 'add_rewrite_rules' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                add_filter( 'bbp_get_view_link',     array( $this, 'get_view_link' ), 10, 2 );
-               add_filter( 'bbp_breadcrumbs',       array( $this, 'breadcrumbs' ) );
</del><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        public function maybe_load() {
+               if ( false !== $this->slug() ) {
+                       // This must run before bbPress's parse_query at priority 2.
+                       $this->register_views();
+
+                       // Add theme-specific filters and actions.
+                       add_action( 'wporg_compat_view_sidebar', array( $this, 'do_view_sidebar' ) );
+
+                       // Add output filters and actions.
+                       add_filter( 'bbp_get_view_link',  array( $this, 'get_view_link' ), 10, 2 );
+                       add_filter( 'bbp_breadcrumbs',    array( $this, 'breadcrumbs' ) );
+                       add_filter( 'bbp_get_breadcrumb', array( $this, 'get_breadcrumb' ), 10, 3 );
+               }
+       }
+
+       public function check_topic_for_compat() {
+               if ( bbp_is_single_topic() ) {
+                       $slug = wp_get_object_terms( bbp_get_topic_id(), $this->taxonomy(), array( 'fields' => 'slugs' ) );
+
+                       // Match found for this compat.
+                       if ( ! empty( $slug ) ) {
+                               $slug = $slug[0];
+
+                               // Basic setup.
+                               $this->slug              = $slug;
+                               $this->{$this->compat()} = $this->get_object( $slug );
+                               $this->authors           = $this->get_authors( $slug );
+                               $this->contributors      = $this->get_contributors( $slug );
+
+                               // Add output filters and actions.
+                               if ( ! empty( $this->authors ) || ! empty( $this->contributors ) ) {
+                                       add_filter( 'bbp_get_topic_author_link', array( $this, 'author_link' ), 10, 2 );
+                                       add_filter( 'bbp_get_reply_author_link', array( $this, 'author_link' ), 10, 2 );
+                               }
+                               add_action( 'wporg_compat_single_topic_sidebar_pre', array( $this, 'do_topic_sidebar' ) );
+                       }
+               }
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         public function add_rewrite_rules() {
</span><span class="cx" style="display: block; padding: 0 10px">                $priority   = 'top';
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $root_id    = $this->compat();
</span><span class="cx" style="display: block; padding: 0 10px">                $root_var   = $this->query_var();
</span><span class="cx" style="display: block; padding: 0 10px">                $review_id  = 'reviews';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $active_id  = 'active';
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $support_rule = $this->compat() . '/([^/]+)/';
</span><span class="cx" style="display: block; padding: 0 10px">                $reviews_rule = $this->compat() . '/([^/]+)/' . $review_id . '/';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $active_rule  = $this->compat() . '/([^/]+)/' . $active_id . '/';
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $feed_id    = 'feed';
</span><span class="cx" style="display: block; padding: 0 10px">                $view_id    = bbp_get_view_rewrite_id();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -52,6 +115,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">                add_rewrite_rule( $support_rule . $base_rule,  'index.php?' . $view_id . '=' . $root_id . '&' . $root_var . '=$matches[1]',                               $priority );
</span><span class="cx" style="display: block; padding: 0 10px">                add_rewrite_rule( $support_rule . $paged_rule, 'index.php?' . $view_id . '=' . $root_id . '&' . $root_var . '=$matches[1]&' . $paged_id . '=$matches[2]', $priority );
</span><span class="cx" style="display: block; padding: 0 10px">                add_rewrite_rule( $support_rule . $feed_rule,  'index.php?' . $view_id . '=' . $root_id . '&' . $root_var . '=$matches[1]&' . $feed_id  . '=$matches[2]', $priority );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               // Add active view rewrite rules.
+               add_rewrite_rule( $active_rule . $base_rule,  'index.php?' . $view_id . '=' . $active_id . '&' . $root_var . '=$matches[1]',                               $priority );
+               add_rewrite_rule( $active_rule . $paged_rule, 'index.php?' . $view_id . '=' . $active_id . '&' . $root_var . '=$matches[1]&' . $paged_id . '=$matches[2]', $priority );
+               add_rewrite_rule( $active_rule . $feed_rule,  'index.php?' . $view_id . '=' . $active_id . '&' . $root_var . '=$matches[1]&' . $feed_id  . '=$matches[2]', $priority );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        public function add_query_var( $query_vars ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -65,6 +133,65 @@
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        public function register_views() {
+
+               // Add support view.
+               bbp_register_view(
+                       $this->compat(),
+                       $this->compat_title(),
+                       array(
+                               'post_parent'   => $this->forum_id(),
+                               'tax_query'     => array( array(
+                                       'taxonomy'  => $this->taxonomy(),
+                                       'field'     => 'slug',
+                                       'terms'     => $this->slug(),
+                               ) ),
+                               'show_stickies' => false,
+                               'orderby'       => 'ID',
+                       )
+               );
+
+               // Add reviews view.
+               bbp_register_view(
+                       'reviews',
+                       __( 'Reviews', 'wporg-forums' ),
+                       array(
+                               'post_parent'   => Plugin::REVIEWS_FORUM_ID,
+                               'meta_query'    => array( array(
+                                       'key'       => '_bbp_last_active_time',
+                                       'type'      => 'DATETIME',
+                               ) ),
+                               'tax_query'     => array( array(
+                                       'taxonomy'  => $this->taxonomy(),
+                                       'field'     => 'slug',
+                                       'terms'     => $this->slug(),
+                               ) ),
+                               'show_stickies' => false,
+                               'orderby'       => 'meta_value',
+                       )
+               );
+
+               // Add recent activity view.
+               bbp_register_view(
+                       'active',
+                       __( 'Recent Activity', 'wporg-forums' ),
+                       array(
+                               'post_parent'   => $this->forum_id(),
+                               'meta_query'    => array( array(
+                                       'key'       => '_bbp_last_active_time',
+                                       'type'      => 'DATETIME',
+                               ) ),
+                               'tax_query'     => array( array(
+                                       'taxonomy'  => $this->taxonomy(),
+                                       'field'     => 'slug',
+                                       'terms'     => $this->slug(),
+                               ) ),
+                               'show_stickies' => false,
+                               'orderby'       => 'meta_value',
+                       )
+               );
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Filter view links to provide prettier links for these subforum views.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -72,13 +199,21 @@
</span><span class="cx" style="display: block; padding: 0 10px">                global $wp_rewrite;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $view = bbp_get_view_id( $view );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( $view != $this->compat() ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( ! in_array( $view, array( 'active', 'reviews', $this->compat() ) ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         return $url;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Pretty permalinks.
</span><span class="cx" style="display: block; padding: 0 10px">                if ( $wp_rewrite->using_permalinks() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $url = $wp_rewrite->root . $this->compat() . '/' . $this->slug();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 switch ( $view ) {
+                               case 'active' :
+                               case 'reviews' :
+                                       $url = $wp_rewrite->root . $this->compat() . '/' . $this->slug() . '/' . $view;
+                                       break;
+
+                               default :
+                                       $url = $wp_rewrite->root . $this->compat() . '/' . $this->slug();
+                       }
</ins><span class="cx" style="display: block; padding: 0 10px">                         $url = home_url( user_trailingslashit( $url ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Unpretty permalinks.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -102,7 +237,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $view = bbp_get_view_id();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( ! in_array( $view, array( $this->compat(), 'reviews' ) ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( ! in_array( $view, array( $this->compat(), 'reviews', 'active' ) ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         return $r;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -114,4 +249,110 @@
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px">                return $r;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       /**
+        * Prefix a single view-specific header using the breadcrumb filter.
+        */
+       public function get_breadcrumb( $trail, $crumbs, $r ) {
+               if ( bbp_is_single_view() && in_array( bbp_get_view_id(), array( 'theme', 'plugin', 'reviews' ) ) ) {
+                       $view_header = $this->get_view_header();
+                       $trail = $view_header . $trail;
+               }
+               return $trail;
+       }
+
+       /**
+        * @todo Add the author or contributor badge.
+        */
+       public function author_link( $author_link, $args ) {
+               return $author_link;
+       }
+
+       /**
+        * Set up and cache the plugin or theme details.
+        *
+        * @param string $slug The object slug
+        */
+       public function get_object( $slug ) {
+               global $wpdb;
+
+               if ( 'theme' == $this->compat() ) {
+                       if ( ! is_null( $this->theme ) ) {
+                               return $this->theme;
+                       }
+               } else {
+                       if ( ! is_null( $this->plugin ) ) {
+                               return $this->plugin;
+                       }
+               }
+
+               // Check the cache.
+               $cache_key = "{$slug}";
+               $cache_group = $this->compat() . '-objects';
+               $compat_object = wp_cache_get( $cache_key, $cache_group );
+               if ( false === $compat_object ) {
+
+                       // Get the object information from the correct table.
+                       if ( $this->compat() == 'theme' ) {
+                               $compat_object = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}%d_posts WHERE post_name = %s AND post_type = 'repopackage' LIMIT 1", WPORG_THEME_DIRECTORY_BLOGID, $slug ) );
+                       } elseif ( $this->compat() == 'plugin' ) {
+                               $compat_object = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}%d_posts WHERE post_name = %s AND post_type = 'plugin' LIMIT 1", WPORG_PLUGIN_DIRECTORY_BLOGID, $slug ) );
+                       }
+
+                       wp_cache_set( $cache_key, $compat_object, $cache_group, 86400);
+               }
+               return $compat_object;
+       }
+
+       public function get_authors( $slug ) {
+               global $wpdb;
+
+               if ( null !== $this->authors ) {
+                       return $this->authors;
+               }
+
+               // Check the cache.
+               $cache_key = "{$slug}";
+               $cache_group = $this->compat() . '-authors';
+               $authors = wp_cache_get( $cache_key, $cache_group );
+               if ( false === $authors ) {
+
+                       if ( $this->compat() == 'theme' ) {
+                               $theme = $this->theme;
+                               $author = get_user_by( 'id', $this->theme->post_author );
+                               $authors = array( $author->user_login );
+                       } else {
+                               $authors = $wpdb->get_col( $wpdb->prepare( " SELECT user FROM plugin_2_svn_access WHERE `path` = %s", '/' . $slug ) );
+                       }
+
+                       wp_cache_set( $cache_key, $authors, $cache_group, 3600 );
+               }
+               return $authors;
+       }
+
+       public function get_contributors( $slug ) {
+               global $wpdb;
+
+               if ( null !== $this->contributors ) {
+                       return $this->contributors;
+               }
+
+               // Themes do not have contributors right now.
+               if ( $this->compat() == 'theme' ) {
+                       $contributors = array();
+                       return $contributors;
+               }
+
+               // Check the cache.
+               $cache_key = "{$slug}";
+               $cache_group = $this->compat() . '-contributors';
+               $contributors = wp_cache_get( $cache_key, $cache_group );
+               if ( false === $contributors ) {
+                       $contributors = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM {$wpdb->base_prefix}%d_postmeta WHERE post_id = %d AND meta_key = %s LIMIT 1", WPORG_PLUGIN_DIRECTORY_BLOGID, $this->plugin->ID, 'contributors' ) );
+                       $contributors = maybe_unserialize( $contributors );
+
+                       wp_cache_set( $cache_key, $contributors, $cache_group, 3600 );
+               }
+               return $contributors;
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginssupportforumsincclassplugindirectorycompatphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-plugin-directory-compat.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-plugin-directory-compat.php     2016-08-31 16:13:09 UTC (rev 3891)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-plugin-directory-compat.php       2016-08-31 16:58:29 UTC (rev 3892)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6,13 +6,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        const COMPAT = 'plugin';
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        var $slug = '';
-       var $plugin = '';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var $slug   = false;
+       var $plugin = null;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        function compat() {
</span><span class="cx" style="display: block; padding: 0 10px">                return self::COMPAT;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        function compat_title() {
+               return __( 'Plugin Support', 'wporg-forums' );
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         function slug() {
</span><span class="cx" style="display: block; padding: 0 10px">                return $this->slug;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -34,14 +38,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        public function __construct() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( defined( 'WPORG_SUPPORT_FORUMS_BLOGID' ) && get_current_blog_id() == WPORG_SUPPORT_FORUMS_BLOGID ) {
-                       // We have to add the custom view before bbPress runs its own action
-                       // on parse_query at priority 2.
-                       add_action( 'parse_query', array( $this, 'parse_query' ), 1 );
-
-                       // Add parent class hooks.
-                       add_action( 'plugins_loaded', array( $this, 'init' ) );
-               }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->init();
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -53,70 +50,88 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        return;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $plugin = $this->get_plugin_data( $slug );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $plugin = $this->get_object( $slug );
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( ! $plugin ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        return;
</span><span class="cx" style="display: block; padding: 0 10px">                } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $this->slug  = $slug;
-                       $this->plugin = $plugin;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $this->slug         = $slug;
+                       $this->plugin       = $plugin;
+                       $this->authors      = $this->get_authors( $slug );
+                       $this->contributors = $this->get_contributors( $slug );
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Add plugin support view.
-               bbp_register_view(
-                       self::COMPAT,
-                       __( 'Plugin Support', 'wporg-forums' ),
-                       array(
-                               'post_parent'   => Plugin::PLUGINS_FORUM_ID,
-                               'tax_query'     => array( array(
-                                       'taxonomy'  => $this->taxonomy(),
-                                       'field'     => 'slug',
-                                       'terms'     => $slug,
-                               ) ),
-                               'orderby'       => '',
-                               'show_stickies' => false,
-                       )
-               );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function do_view_sidebar() {
+               ?>
+               <div>
+                       <h3><?php _e( 'Browse Plugins', 'wporg-forums' ); ?></h3>
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Add plugin review view.
-               bbp_register_view(
-                       'reviews',
-                       __( 'Reviews', 'wporg-forums' ),
-                       array(
-                               'post_parent'   => Plugin::REVIEWS_FORUM_ID,
-                               'tax_query'     => array( array(
-                                       'taxonomy'  => $this->taxonomy(),
-                                       'field'     => 'slug',
-                                       'terms'     => $slug,
-                               ) ),
-                               'orderby'       => '',
-                               'show_stickies' => false,
-                       )
-               );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 <ul class="plugin-submenu">
+                               <li class="view"><a href='//wordpress.org/plugins/'><?php _e( 'Featured', 'wporg' ); ?></a></li>
+                               <li class="view"><a href='//wordpress.org/plugins/browse/popular/'><?php _e( 'Most Popular', 'wporg' ); ?></a></li>
+                               <li class="view"><a href='//wordpress.org/plugins/browse/favorites/'><?php _e( 'Favorites', 'wporg' ); ?></a></li>
+                               <li class="view"><a href='//wordpress.org/plugins/browse/beta/'><?php _e( 'Beta Testing', 'wporg' ); ?></a></li>
+                               <li class="view"><a href='/plugins/about/'><?php _e( 'Developers', 'wporg' ); ?></a></li>
+                       </ul>
+               </div>
+
+               <div>
+                       <h3><?php _e( 'Search Plugins', 'wporg-forums' ); ?></h3>
+
+                       <form id="side-search" method="get" action="//wordpress.org/plugins/search.php">
+                       <div>
+                               <input type="text" class="text" name="q" value="" />
+                               <input type="submit" class="button" value="<?php _e( 'Search', 'wporg-forums' ); ?>" />
+                       </div>
+                       </form>
+               </div>
+               <?php
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        public function get_plugin_data( $slug = '' ) {
-               global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function do_topic_sidebar() {
+               include_once WPORGPATH . 'extend/plugins-plugins/_plugin-icons.php';
+               $plugin  = sprintf( '<a href="//wordpress.org/plugins/%s/">%s</a>', esc_attr( $this->slug() ), esc_html( $this->plugin->post_title ) );
+               $faq     = sprintf( '<a href="//wordpress.org/plugins/%s/faq/">Frequently Asked Questions</a>', esc_attr( $this->slug() ) );
+               $support = sprintf( '<a href="//wordpress.org/support/plugin/%s/">Support Threads</a>', esc_attr( $this->slug() ) );
+               $reviews = sprintf( '<a href="//wordpress.org/support/plugin/%s/reviews/">Reviews</a>', esc_attr( $this->slug() ) );
+               ?>
+               <div>
+                       <h3>About this Plugin</h3>
+                       <ul>
+                               <li><?php echo wporg_get_plugin_icon( $this->slug, 128 ); ?></li>
+                               <li style="clear:both;"><?php echo $plugin; ?></li>
+                               <?php if ( ! empty( $this->plugin->post_content ) && false !== strpos( $this->plugin->post_content, '<!--section=faq-->' ) ) : ?>
+                               <li><?php echo $faq; ?></li>
+                               <?php endif; ?>
+                               <li><?php echo $support; ?></li>
+                               <li><?php echo $reviews; ?></li>
+                       </ul>
+               </div>
+               <?php
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( ! empty( $this->plugin ) ) {
-                       return $this->plugin;
-               }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+        * Return a custom view header string so that get_breadcrumbs will display it.
+        */
+       public function get_view_header() {
+               $slug        = esc_attr( $this->slug );
+               $description = esc_html__( 'Description', 'wporg-forums' );
+               $support     = esc_html__( 'Support', 'wporg-forums' );
+               $reviews     = esc_html__( 'Reviews', 'wporg-forums' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $sql = $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}%d_posts WHERE post_name = %s AND post_type = 'plugin' LIMIT 1", WPORG_PLUGIN_DIRECTORY_BLOGID, $slug );
-               $row = $wpdb->get_row( $sql );
-               if ( ! $row ) {
-                       return false;
-               } else {
-                       $plugin = $row;
-                       $sql = $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}%d_postmeta WHERE post_id = %d AND meta_key NOT LIKE %s", WPORG_PLUGIN_DIRECTORY_BLOGID, $row->ID, '_trac_ticket_%' );
-                       $results = $wpdb->get_results( $sql );
-                       if( $results ) {
-                               foreach ( $results as $row ) {
-                                       if ( ! isset( $plugin->{$row->meta_key} ) ) {
-                                               $plugin->{$row->meta_key} = maybe_unserialize( $row->meta_value );
-                                       }
-                               }
-                       }
-               }
-               return $plugin;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $header = <<<EOT
+               <ul id="sections">
+                       <li class="section-description">
+                               <a href="//wordpress.org/plugins/{$slug}/">{$description}</a>
+                       </li>
+                       <li class="section-support">
+                               <a href="//wordpress.org/support/plugin/{$slug}/">{$support}</a>
+                       <li>
+                       <li class="section-reviews">
+                               <a href="//wordpress.org/support/plugin/{$slug}/reviews/">{$reviews}</a>
+                       </li>
+                       </ul>
+EOT;
+               return $header;
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginssupportforumsincclassthemedirectorycompatphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-theme-directory-compat.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-theme-directory-compat.php      2016-08-31 16:13:09 UTC (rev 3891)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-theme-directory-compat.php        2016-08-31 16:58:29 UTC (rev 3892)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6,13 +6,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        const COMPAT = 'theme';
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        var $slug = '';
-       var $theme = '';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var $slug  = false;
+       var $theme = null;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        function compat() {
</span><span class="cx" style="display: block; padding: 0 10px">                return self::COMPAT;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        function compat_title() {
+               return __( 'Theme Support', 'wporg-forums' );
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         function slug() {
</span><span class="cx" style="display: block; padding: 0 10px">                return $this->slug;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -34,14 +38,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        public function __construct() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( defined( 'WPORG_SUPPORT_FORUMS_BLOGID' ) && get_current_blog_id() == WPORG_SUPPORT_FORUMS_BLOGID ) {
-                       // We have to add the custom view before bbPress runs its own action
-                       // on parse_query at priority 2.
-                       add_action( 'parse_query', array( $this, 'parse_query' ), 1 );
-
-                       // Add parent class hooks.
-                       add_action( 'plugins_loaded', array( $this, 'init' ) );
-               }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->init();
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -53,70 +50,83 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        return;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $theme = $this->get_theme_data( $slug );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $theme = $this->get_object( $slug );
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( ! $theme ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        return;
</span><span class="cx" style="display: block; padding: 0 10px">                } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $this->slug  = $slug;
-                       $this->theme = $theme;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $this->slug         = $slug;
+                       $this->theme        = $theme;
+                       $this->authors      = $this->get_authors( $slug );
+                       $this->contributors = $this->get_contributors( $slug );
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Add theme support view.
-               bbp_register_view(
-                       self::COMPAT,
-                       __( 'Theme Support', 'wporg-forums' ),
-                       array(
-                               'post_parent'   => Plugin::THEMES_FORUM_ID,
-                               'tax_query'     => array( array(
-                                       'taxonomy'  => $this->taxonomy(),
-                                       'field'     => 'slug',
-                                       'terms'     => $slug,
-                               ) ),
-                               'orderby'       => '',
-                               'show_stickies' => false,
-                       )
-               );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function do_view_sidebar() {
+               ?>
+               <div>
+                       <h3><?php _e( 'Browse Themes', 'wporg-forums' ); ?></h3>
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Add theme review view.
-               bbp_register_view(
-                       'reviews',
-                       __( 'Reviews', 'wporg-forums' ),
-                       array(
-                               'post_parent'   => Plugin::REVIEWS_FORUM_ID,
-                               'tax_query'     => array( array(
-                                       'taxonomy'  => $this->taxonomy(),
-                                       'field'     => 'slug',
-                                       'terms'     => $slug,
-                               ) ),
-                               'orderby'       => '',
-                               'show_stickies' => false,
-                       )
-               );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 <ul class="theme-submenu">
+                               <li class="view"><a href="//wordpress.org/themes/"><?php _e( 'Featured', 'wporg-forums' ); ?></a></li>
+                               <li class="view"><a href="//wordpress.org/themes/browse/popular/"><?php _e( 'Most Popular', 'wporg-forums' ); ?></a></li>
+                               <li class="view"><a href="//wordpress.org/themes/browse/new/"><?php _e( 'Latest', 'wporg-forums' ); ?></a></li>
+                               <li class="view"><a href="/themes/getting-started/"><?php _e( 'Theme Authors', 'wporg-forums' ); ?></a></li>
+                               <li class="view"><a href="/themes/commercial/"><?php _e( 'Commercial', 'wporg-forums' ); ?></a></li>
+                       </ul>
+               </div>
+
+               <div>
+                       <h3><?php _e( 'Search Themes', 'wporg-forums' ); ?></h3>
+
+                       <form id="side-search" method="get" action="//wordpress.org/themes/search.php">
+                       <div>
+                               <input type="text" class="text" name="q" value="" />
+                               <input type="submit" class="button" value="<?php _e( 'Search', 'wporg-forums' ); ?>" />
+                       </div>
+                       </form>
+               </div>
+               <?php
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        public function get_theme_data( $slug = '' ) {
-               global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function do_topic_sidebar() {
+               $theme   = sprintf( '<a href="//wordpress.org/plugins/%s/">%s</a>', esc_attr( $this->slug() ), esc_html( $this->theme->post_title ) );
+               $support = sprintf( '<a href="//wordpress.org/support/plugin/%s/">Support Threads</a>', esc_attr( $this->slug() ) );
+               $reviews = sprintf( '<a href="//wordpress.org/support/plugin/%s/reviews/">Reviews</a>', esc_attr( $this->slug() ) );
+               ?>
+               <div>
+                       <h3>About this Theme</h3>
+                       <ul>
+                               <li><?php echo $theme; ?></li>
+                               <li><?php echo $support; ?></li>
+                               <li><?php echo $reviews; ?></li>
+                       </ul>
+               </div>
+               <?php
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( ! empty( $this->theme ) ) {
-                       return $this->theme;
-               }
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $sql = $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}%d_posts WHERE post_name = %s AND post_type = 'repopackage' LIMIT 1", WPORG_THEME_DIRECTORY_BLOGID, $slug );
-               $row = $wpdb->get_row( $sql );
-               if ( ! $row ) {
-                       return false;
-               } else {
-                       $theme = $row;
-                       $sql = $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}%d_postmeta WHERE post_id = %d AND meta_key NOT LIKE %s", WPORG_THEME_DIRECTORY_BLOGID, $row->ID, '_trac_ticket_%' );
-                       $results = $wpdb->get_results( $sql );
-                       if( $results ) {
-                               foreach ( $results as $row ) {
-                                       if ( ! isset( $theme->{$row->meta_key} ) ) {
-                                               $theme->{$row->meta_key} = maybe_unserialize( $row->meta_value );
-                                       }
-                               }
-                       }
-               }
-               return $theme;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+        * Return a custom view header string so that get_breadcrumbs will display it.
+        */
+       public function get_view_header() {
+               $slug        = esc_attr( $this->slug );
+               $description = esc_html__( 'Description', 'wporg-forums' );
+               $support     = esc_html__( 'Support', 'wporg-forums' );
+               $reviews     = esc_html__( 'Reviews', 'wporg-forums' );
+
+               $header = <<<EOT
+               <ul id="sections">
+                       <li class="section-description">
+                               <a href="//wordpress.org/themes/{$slug}/">{$description}</a>
+                       </li>
+                       <li class="section-support">
+                               <a href="//wordpress.org/support/theme/{$slug}/">{$support}</a>
+                       <li>
+                       <li class="section-reviews">
+                               <a href="//wordpress.org/support/theme/{$slug}/reviews/">{$reviews}</a>
+                       </li>
+                       </ul>
+EOT;
+               return $header;
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>

</body>
</html>