<!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>[3846] sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums: Support: Support Forums initial commit.</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/3846">3846</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/3846","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-23 20:13:40 +0000 (Tue, 23 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: Support Forums initial commit.

See <a href="http://meta.trac.wordpress.org/ticket/1544">#1544</a>.</pre>

<h3>Added Paths</h3>
<ul>
<li>sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/</li>
<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_htmlwpcontentpluginssupportforumsincclassperformanceoptimizationsphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-performance-optimizations.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_htmlwpcontentpluginssupportforumsincclasspluginphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-plugin.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>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginssupportforumssupportforumsphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/support-forums.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginssupportforumsincclassdirectorycompatphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: 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                            (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-directory-compat.php      2016-08-23 20:13:40 UTC (rev 3846)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,117 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+namespace WordPressdotorg\Forums;
+
+abstract class Directory_Compat {
+
+       abstract protected function compat();
+       abstract protected function slug();
+       abstract protected function title();
+       abstract protected function forum_id();
+       abstract protected function query_var();
+       abstract protected function taxonomy();
+
+       public function __construct() {}
+
+       public function init() {
+               add_action( 'bbp_init',              array( $this, 'register_taxonomy' ) );
+               add_filter( 'query_vars',            array( $this, 'add_query_var' ) );
+               add_action( 'bbp_add_rewrite_rules', array( $this, 'add_rewrite_rules' ) );
+
+               add_filter( 'bbp_get_view_link',     array( $this, 'get_view_link' ), 10, 2 );
+               add_filter( 'bbp_breadcrumbs',       array( $this, 'breadcrumbs' ) );
+       }
+
+       public function add_rewrite_rules() {
+               $priority   = 'top';
+
+               $root_id    = $this->compat();
+               $root_var   = $this->query_var();
+               $review_id  = 'reviews';
+
+               $support_rule = $this->compat() . '/([^/]+)/';
+               $reviews_rule = $this->compat() . '/([^/]+)/' . $review_id . '/';
+
+               $feed_id    = 'feed';
+               $view_id    = bbp_get_view_rewrite_id();
+               $paged_id   = bbp_get_paged_rewrite_id();
+
+               $feed_slug  = 'feed';
+               $paged_slug = bbp_get_paged_slug();
+
+               $base_rule  = '?$';
+               $feed_rule  = $feed_slug  . '/?$';
+               $paged_rule = $paged_slug . '/?([0-9]{1,})/?$';
+
+               // Add reviews view rewrite rules.
+               add_rewrite_rule( $reviews_rule . $base_rule,  'index.php?' . $view_id . '=' . $review_id . '&' . $root_var . '=$matches[1]',                               $priority );
+               add_rewrite_rule( $reviews_rule . $paged_rule, 'index.php?' . $view_id . '=' . $review_id . '&' . $root_var . '=$matches[1]&' . $paged_id . '=$matches[2]', $priority );
+               add_rewrite_rule( $reviews_rule . $feed_rule,  'index.php?' . $view_id . '=' . $review_id . '&' . $root_var . '=$matches[1]&' . $feed_id  . '=$matches[2]', $priority );
+
+               // Add support view rewrite rules.
+               add_rewrite_rule( $support_rule . $base_rule,  'index.php?' . $view_id . '=' . $root_id . '&' . $root_var . '=$matches[1]',                               $priority );
+               add_rewrite_rule( $support_rule . $paged_rule, 'index.php?' . $view_id . '=' . $root_id . '&' . $root_var . '=$matches[1]&' . $paged_id . '=$matches[2]', $priority );
+               add_rewrite_rule( $support_rule . $feed_rule,  'index.php?' . $view_id . '=' . $root_id . '&' . $root_var . '=$matches[1]&' . $feed_id  . '=$matches[2]', $priority );
+       }
+
+       public function add_query_var( $query_vars ) {
+               $query_vars[] = $this->query_var();
+               return $query_vars;
+       }
+
+       public function register_taxonomy() {
+               if ( post_type_exists( 'topic' ) ) {
+                       register_taxonomy( $this->taxonomy(), 'topic', array( 'public' => false ) );
+               }
+       }
+
+       /**
+        * Filter view links to provide prettier links for these subforum views.
+        */
+       public function get_view_link( $url, $view ) {
+               global $wp_rewrite;
+
+               $view = bbp_get_view_id( $view );
+               if ( $view != $this->compat() ) {
+                       return $url;
+               }
+
+               // Pretty permalinks.
+               if ( $wp_rewrite->using_permalinks() ) {
+                       $url = $wp_rewrite->root . $this->compat() . '/' . $this->slug();
+                       $url = home_url( user_trailingslashit( $url ) );
+
+               // Unpretty permalinks.
+               } else {
+                       $url = add_query_arg( array(
+                               bbp_get_view_rewrite_id() => $view,
+                               $this->query_var()        => $this->slug(),
+                       ) );
+               }
+
+               return $url;
+       }
+
+       /**
+        * Filter the breadcrumbs for directory views so we can specify the plugin
+        * or theme in the breadcrumbs.
+        */
+       public function breadcrumbs( $r ) {
+               if ( ! bbp_is_single_view() ) {
+                       return $r;
+               }
+
+               $view = bbp_get_view_id();
+               if ( ! in_array( $view, array( $this->compat(), 'reviews' ) ) ) {
+                       return $r;
+               }
+
+               $r[1] = '<a href="' . esc_url( bbp_get_forum_permalink( $this->forum_id() ) ) . '" class="bbp-breadcrumb-forum">' . esc_html( bbp_get_forum_title( $this->forum_id() ) ) . '</a>';
+               $r[2] = esc_html( $this->title() );
+               if ( 'reviews' == $view ) {
+                       $r[2] = '<a href="' . esc_url( bbp_get_view_url( $this->compat() ) ) . '" class="bbp-breadcrumb-forum">' . esc_html( $this->title() ) . '</a>';
+                       $r[3] = __( 'Reviews', 'wporg-forums' );
+               }
+               return $r;
+       }
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-directory-compat.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginssupportforumsincclassperformanceoptimizationsphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-performance-optimizations.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-performance-optimizations.php                           (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-performance-optimizations.php     2016-08-23 20:13:40 UTC (rev 3846)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,73 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+namespace WordPressdotorg\Forums;
+
+class Performance_Optimizations {
+
+       function __construct() {
+               add_filter( 'bbp_after_has_topics_parse_args', array( __CLASS__, 'has_topics' ) );
+       }
+
+       /**
+        * Optimize queries for has_topics as much as possible to avoid breaking things.
+        */
+       public static function has_topics( $r ) {
+               /**
+                * Filter view queries so they only look at the last N days of topics.
+                */
+               if ( bbp_is_single_view() ) {
+                       $view = bbp_get_view_id();
+                       // Exclude plugin and theme views from this restriction.
+                       // @todo Update date to a reasonable range once we're done importing.
+                       if ( ! in_array( $view, array( 'plugin', 'theme', 'review' ) ) ) {
+                               $r['date_query'] = array( 'after' => '19 months ago' );
+                       }
+
+               /**
+                * Filter forum queries so they are not sorted by the post meta value of
+                * `_bbp_last_active_time`. This query needs additional optimization
+                * to run over large sets of posts.
+                * See also:
+                * - https://bbpress.trac.wordpress.org/ticket/1925
+                */
+               } elseif ( bbp_is_single_forum() ) {
+                       unset( $r['meta_key'] );
+                       unset( $r['meta_type'] );
+
+                       $r['orderby'] = 'post_date';
+                       add_action( 'pre_get_posts', array( __CLASS__, 'pre_get_posts' ) );
+               }
+               return $r;
+       }
+
+       /**
+        * If this is a single forum query, don't use SQL_CALC_FOUND_ROWS to find the
+        * total available topics.
+        */
+       public static function pre_get_posts( $q ) {
+               if (
+                       isset( $q->query['post_type'] ) && $q->query['post_type'] === bbp_get_topic_post_type()
+               ) {
+                       $q->set( 'no_found_rows', true );
+                       add_filter( 'posts_groupby', '__return_empty_string' );
+                       add_filter( 'bbp_topic_pagination', array( __CLASS__, 'topic_pagination' ) );
+               }
+       }
+
+       /**
+        * Instead, use a COUNT(*) query to find total topics in a forum.
+        */
+       public static function topic_pagination( $r ) {
+               global $wpdb;
+
+               if ( bbp_is_single_forum() ) {
+                       $per_page = bbp_get_topics_per_page();
+                       $forum_id = bbp_get_forum_id();
+                       $total = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->posts WHERE 1=1 AND post_type = 'topic' AND post_parent = %d AND post_status IN ( 'closed', 'publish' )", $forum_id ) );
+
+                       $r['total'] = ceil( (int) $total / (int) $per_page );
+                       remove_filter( 'bbp_topic_pagination', array( __CLASS__, 'topic_pagination' ) );
+               }
+               return $r;
+       }
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-performance-optimizations.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginssupportforumsincclassplugindirectorycompatphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: 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                             (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-plugin-directory-compat.php       2016-08-23 20:13:40 UTC (rev 3846)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,122 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+namespace WordPressdotorg\Forums;
+
+class Plugin_Directory_Compat extends Directory_Compat {
+
+       const COMPAT = 'plugin';
+
+       var $slug = '';
+       var $plugin = '';
+
+       function compat() {
+               return self::COMPAT;
+       }
+
+       function slug() {
+               return $this->slug;
+       }
+
+       function title() {
+               return $this->plugin->post_title;
+       }
+
+       function forum_id() {
+               return Plugin::PLUGINS_FORUM_ID;
+       }
+
+       function query_var() {
+               return 'wporg_' . self::COMPAT;
+       }
+
+       function taxonomy() {
+               return 'topic-' . self::COMPAT;
+       }
+
+       public function __construct() {
+               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' ) );
+               }
+       }
+
+       /**
+        * Add views if the plugin query_var is present.
+        */
+       public function parse_query() {
+               $slug = get_query_var( 'wporg_plugin' );
+               if ( ! $slug ) {
+                       return;
+               }
+
+               $plugin = $this->get_plugin_data( $slug );
+               if ( ! $plugin ) {
+                       return;
+               } else {
+                       $this->slug  = $slug;
+                       $this->plugin = $plugin;
+               }
+
+               // 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,
+                       )
+               );
+
+               // 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,
+                       )
+               );
+       }
+
+       public function get_plugin_data( $slug = '' ) {
+               global $wpdb;
+
+               if ( ! empty( $this->plugin ) ) {
+                       return $this->plugin;
+               }
+
+               $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;
+       }
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-plugin-directory-compat.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginssupportforumsincclasspluginphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-plugin.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.php                              (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-plugin.php        2016-08-23 20:13:40 UTC (rev 3846)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,44 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+namespace WordPressdotorg\Forums;
+
+class Plugin {
+
+       /**
+        * Set constants for existing forums.
+        */
+       const THEMES_FORUM_ID   = 21261;
+       const PLUGINS_FORUM_ID  = 21262;
+       const REVIEWS_FORUM_ID  = 21272;
+
+       /**
+        * @var Plugin The singleton instance.
+        */
+       private static $instance;
+
+       /**
+        * Always return the same instance of this plugin.
+        *
+        * @return Plugin
+        */
+       public static function get_instance() {
+               if ( ! ( self::$instance instanceof Plugin ) ) {
+                       self::$instance = new Plugin();
+               }
+               return self::$instance;
+       }
+
+       /**
+        * Instantiate a new Plugin object.
+        */
+       private function __construct() {
+               $this->performance = new Performance_Optimizations;
+
+               // These modifications are specific to https://wordpress.org/support/
+               $blog_id = get_current_blog_id();
+               if ( $blog_id && defined( 'WPORG_SUPPORT_FORUMS_BLOGID' ) && WPORG_SUPPORT_FORUMS_BLOGID == $blog_id ) {
+                       $this->themes  = new Theme_Directory_Compat;
+                       $this->plugins = new Plugin_Directory_Compat;
+               }
+       }
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-plugin.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginssupportforumsincclassthemedirectorycompatphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: 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                              (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-theme-directory-compat.php        2016-08-23 20:13:40 UTC (rev 3846)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,122 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+namespace WordPressdotorg\Forums;
+
+class Theme_Directory_Compat extends Directory_Compat {
+
+       const COMPAT = 'theme';
+
+       var $slug = '';
+       var $theme = '';
+
+       function compat() {
+               return self::COMPAT;
+       }
+
+       function slug() {
+               return $this->slug;
+       }
+
+       function title() {
+               return ! empty( $this->theme ) ? $this->theme->post_title : '';
+       }
+
+       function forum_id() {
+               return Plugin::THEMES_FORUM_ID;
+       }
+
+       function query_var() {
+               return 'wporg_' . self::COMPAT;
+       }
+
+       function taxonomy() {
+               return 'topic-' . self::COMPAT;
+       }
+
+       public function __construct() {
+               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' ) );
+               }
+       }
+
+       /**
+        * Add views if the theme query_var is present.
+        */
+       public function parse_query() {
+               $slug = get_query_var( 'wporg_theme' );
+               if ( ! $slug ) {
+                       return;
+               }
+
+               $theme = $this->get_theme_data( $slug );
+               if ( ! $theme ) {
+                       return;
+               } else {
+                       $this->slug  = $slug;
+                       $this->theme = $theme;
+               }
+
+               // 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,
+                       )
+               );
+
+               // 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,
+                       )
+               );
+       }
+
+       public function get_theme_data( $slug = '' ) {
+               global $wpdb;
+
+               if ( ! empty( $this->theme ) ) {
+                       return $this->theme;
+               }
+
+               $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;
+       }
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-theme-directory-compat.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginssupportforumssupportforumsphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/support-forums.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/support-forums.php                                (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/support-forums.php  2016-08-23 20:13:40 UTC (rev 3846)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,24 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Plugin Name: Support Forums
+ * Plugin URI: https://wordpress.org/support/
+ * Description: Transform a WordPress site into the support forums.
+ * Version: 1.0
+ * Author: WordPress.org
+ * Author URI: https://wordpress.org/
+ * Text Domain: wporg-forums
+ * License: GPLv2
+ * License URI: http://opensource.org/licenses/gpl-2.0.php
+ */
+
+namespace WordPressdotorg\Forums;
+
+// Includes
+include( dirname( __FILE__ ) . '/inc/class-plugin.php' );
+include( dirname( __FILE__ ) . '/inc/class-directory-compat.php' );
+include( dirname( __FILE__ ) . '/inc/class-theme-directory-compat.php' );
+include( dirname( __FILE__ ) . '/inc/class-plugin-directory-compat.php' );
+include( dirname( __FILE__ ) . '/inc/class-performance-optimizations.php' );
+
+// Instantiate the plugin on load.
+Plugin::get_instance();
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/support-forums.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span></div>

</body>
</html>