<!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>[1322] sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes: WP.org Themes: Stay local for better performance.</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/1322">1322</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/1322","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>obenland</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2015-02-25 15:56:45 +0000 (Wed, 25 Feb 2015)</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'>WP.org Themes: Stay local for better performance.

Refrains from doing extra API requests but rather includes the API class
directly.

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

<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgthemesfunctionsphp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/functions.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgthemesviewtemplatesthemesinglephp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/view-templates/theme-single.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgthemesfunctionsphp"></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/themes/pub/wporg-themes/functions.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/themes/pub/wporg-themes/functions.php    2015-02-25 15:23:28 UTC (rev 1321)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/functions.php      2015-02-25 15:56:45 UTC (rev 1322)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -28,28 +28,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">        add_theme_support( 'html5', array(
</span><span class="cx" style="display: block; padding: 0 10px">                'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
</span><span class="cx" style="display: block; padding: 0 10px">        ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-       $themes_allowedtags = array(
-               'a'       => array( 'href' => array(), 'title' => array(), 'target' => array() ),
-               'abbr'    => array( 'title' => array() ),
-               'acronym' => array( 'title' => array() ),
-               'code'    => array(),
-               'pre'     => array(),
-               'em'      => array(),
-               'strong'  => array(),
-               'div'     => array(),
-               'p'       => array(),
-               'ul'      => array(),
-               'ol'      => array(),
-               'li'      => array(),
-               'h1'      => array(),
-               'h2'      => array(),
-               'h3'      => array(),
-               'h4'      => array(),
-               'h5'      => array(),
-               'h6'      => array(),
-               'img'     => array( 'src' => array(), 'class' => array(), 'alt' => array() ),
-       );
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'after_setup_theme', 'wporg_themes_setup' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -163,39 +141,23 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * A recreation of Core's implementation without capability check, since there is nothing to install.
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function wporg_themes_query_themes() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        global $themes_allowedtags, $theme_field_defaults;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $theme_field_defaults, $themes_allowedtags;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $args = wp_parse_args( wp_unslash( $_REQUEST['request'] ), array(
</span><span class="cx" style="display: block; padding: 0 10px">                'per_page' => 20,
</span><span class="cx" style="display: block; padding: 0 10px">                'fields'   => $theme_field_defaults,
</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">-        $old_filter = isset( $args['browse'] ) ? $args['browse'] : 'search';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ include_once '/home/api/public_html/themes/info/1.0/class-themes-api.php';
+       $api = new Themes_API( 'query_themes', $args );
+       $api = $api->response;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        /** This filter is documented in wp-admin/includes/class-wp-theme-install-list-table.php */
-       $args = apply_filters( 'install_themes_table_api_args_' . $old_filter, $args );
-
-       $api = themes_api( 'query_themes', $args );
-
</del><span class="cx" style="display: block; padding: 0 10px">         if ( is_wp_error( $api ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                wp_send_json_error();
</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">-        foreach ( $api->themes as &$theme ) {
-               $theme->name           = wp_kses( $theme->name,        $themes_allowedtags );
-
-               // add in the nicename for the url, and the displayname for the display
-               $user = get_user_by('login', $theme->author);
-               $theme->authorurl       = $user->user_nicename;
-               $theme->authordispname = wp_kses( $user->display_name, $themes_allowedtags );
-
-               $theme->author         = wp_kses( $theme->author,      $themes_allowedtags );
-               $theme->version        = wp_kses( $theme->version,     $themes_allowedtags );
-               $theme->description    = wp_kses( $theme->description, $themes_allowedtags );
-               $theme->downloaded     = number_format_i18n( $theme->downloaded );
-               $theme->num_ratings    = number_format_i18n( $theme->num_ratings );
-               $theme->preview_url    = set_url_scheme( $theme->preview_url );
-               wporg_themes_photon_screen_shot( $theme );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $api->themes as $key => $theme ) {
+               $api->themes[ $key ] = wporg_themes_ajax_prepare_theme( $theme );
</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">        wp_send_json_success( $api );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -204,36 +166,63 @@
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'wp_ajax_nopriv_query-themes', 'wporg_themes_query_themes' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> function wporg_themes_theme_info() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        global $themes_allowedtags;
-
</del><span class="cx" style="display: block; padding: 0 10px">         $args  = wp_unslash( $_REQUEST );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $theme = themes_api( 'theme_information', array( 'slug' => $args['slug'] ) );
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( is_wp_error( $theme ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ include_once '/home/api/public_html/themes/info/1.0/class-themes-api.php';
+       $api = new Themes_API( 'query_themes', array( 'slug' => $args['slug'] ) );
+       $api = $api->response;
+
+       if ( is_wp_error( $api ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 wp_send_json_error();
</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->name           = wp_kses( $theme->name,        $themes_allowedtags );
-       $theme->author         = wp_kses( $theme->author,      $themes_allowedtags );
-       $theme->version        = wp_kses( $theme->version,     $themes_allowedtags );
-       $theme->description    = wp_kses( $theme->description, $themes_allowedtags );
-       $theme->downloaded     = number_format_i18n( $theme->downloaded );
-       $theme->num_ratings    = number_format_i18n( $theme->num_ratings );
-       $theme->preview_url    = set_url_scheme( $theme->preview_url );
-       wporg_themes_photon_screen_shot( $theme );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $api = wporg_themes_ajax_prepare_theme( $api );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        wp_send_json_success( $theme );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_send_json_success( $api );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'wp_ajax_theme-info',        'wporg_themes_theme_info' );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'wp_ajax_nopriv_theme-info', 'wporg_themes_theme_info' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/**
- * Photon-ifies the screen shot URL.
- *
- * @param object $theme
- * @return object
- */
-function wporg_themes_photon_screen_shot( $theme ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function wporg_themes_ajax_prepare_theme( $theme ) {
+       global $themes_allowedtags;
+
+       if ( empty( $themes_allowedtags ) ) {
+               $themes_allowedtags = array(
+                       'a'       => array( 'href' => array(), 'title' => array(), 'target' => array() ),
+                       'abbr'    => array( 'title' => array() ),
+                       'acronym' => array( 'title' => array() ),
+                       'code'    => array(),
+                       'pre'     => array(),
+                       'em'      => array(),
+                       'strong'  => array(),
+                       'div'     => array(),
+                       'p'       => array(),
+                       'ul'      => array(),
+                       'ol'      => array(),
+                       'li'      => array(),
+                       'h1'      => array(),
+                       'h2'      => array(),
+                       'h3'      => array(),
+                       'h4'      => array(),
+                       'h5'      => array(),
+                       'h6'      => array(),
+                       'img'     => array( 'src' => array(), 'class' => array(), 'alt' => array() ),
+               );
+       }
+
+       $author        = get_user_by( 'login', $theme->author );
+       $theme->author = new StdClass;
+       foreach ( array( 'user_nicename', 'display_name' ) as $property ) {
+               $theme->author->$property = $author->$property;
+       }
+
+       $theme->name        = wp_kses( $theme->name, $themes_allowedtags );
+       $theme->version     = wp_kses( $theme->version, $themes_allowedtags );
+       $theme->description = wp_kses( $theme->description, $themes_allowedtags );
+       $theme->downloaded  = number_format_i18n( $theme->downloaded );
+       $theme->num_ratings = number_format_i18n( $theme->num_ratings );
+       $theme->preview_url = set_url_scheme( $theme->preview_url );
+
</ins><span class="cx" style="display: block; padding: 0 10px">         if ( preg_match( '/screenshot.(jpg|jpeg|png|gif)/', $theme->screenshot_url, $match ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                $theme->screenshot_url = sprintf( 'https://i0.wp.com/themes.svn.wordpress.org/%1$s/%2$s/%3$s',
</span><span class="cx" style="display: block; padding: 0 10px">                        $theme->slug,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -241,6 +230,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        $match[0]
</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">+
</ins><span class="cx" style="display: block; padding: 0 10px">         return $theme;
</span><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_htmlwpcontentthemespubwporgthemesviewtemplatesthemesinglephp"></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/themes/pub/wporg-themes/view-templates/theme-single.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/themes/pub/wporg-themes/view-templates/theme-single.php  2015-02-25 15:23:28 UTC (rev 1321)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/view-templates/theme-single.php    2015-02-25 15:56:45 UTC (rev 1322)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -16,7 +16,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        <div class="theme-head">
</span><span class="cx" style="display: block; padding: 0 10px">                                <h3 class="theme-name entry-title">{{{ data.name }}}</h3>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                <h4 class="theme-author"><?php printf( __( 'By %s' ), '<a href="https://profiles.wordpress.org/{{ data.authorurl }}"><span class="author">{{{ data.authordispname }}}</span></a>' ); ?></h4>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         <h4 class="theme-author"><?php printf( __( 'By %s' ), '<a href="https://profiles.wordpress.org/{{ data.author.user_nicename }}"><span class="author">{{{ data.author.display_name }}}</span></a>' ); ?></h4>
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                <div class="theme-actions">
</span><span class="cx" style="display: block; padding: 0 10px">                                        <a href="{{{ data.preview_url }}}" class="button button-secondary"><?php _e( 'Preview' ); ?></a>
</span></span></pre>
</div>
</div>

</body>
</html>