<!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>[3020] sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory: Plugin Directory: Add a REST API endpoint which represents the full plugin data currently exposed through `api.wordpress.org`.</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/3020">3020</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/3020","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>dd32</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-04-27 08:08:11 +0000 (Wed, 27 Apr 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'>Plugin Directory: Add a REST API endpoint which represents the full plugin data currently exposed through `api.wordpress.org`.
Although it's unlikely api.wordpress.org will run the API directly, this is a test to verify that all data we have on file is available.
See <a href="http://meta.trac.wordpress.org/ticket/1576">#1576</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryapiclassbasephp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/class-base.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryclassplugindirectoryphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryclasstemplatephp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectorywidgetsclassratingsphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-ratings.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryapiroutesclasspluginphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryapiclassbasephp"></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/plugin-directory/api/class-base.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/plugin-directory/api/class-base.php 2016-04-27 07:51:54 UTC (rev 3019)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/class-base.php 2016-04-27 08:08:11 UTC (rev 3020)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -12,6 +12,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> static function load_routes() {
</span><span class="cx" style="display: block; padding: 0 10px"> new Routes\Internal_Stats();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ new Routes\Plugin();
</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></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryapiroutesclasspluginphp"></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/plugin-directory/api/routes/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/plugin-directory/api/routes/class-plugin.php (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin.php 2016-04-27 08:08:11 UTC (rev 3020)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,294 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+namespace WordPressdotorg\Plugin_Directory\API\Routes;
+use WordPressdotorg\Plugin_Directory\Plugin_Directory;
+use WordPressdotorg\Plugin_Directory\Template;
+use WordPressdotorg\Plugin_Directory\API\Base;
+
+/**
+ * An API Endpoint to expose a single Plugin data via api.wordpress.org/plugins/info/1.x
+ *
+ * @package WordPressdotorg_Plugin_Directory
+ */
+class Plugin extends Base {
+
+ function __construct() {
+ register_rest_route( 'plugins/v1', '/plugin/(?P<plugin_slug>[^/]+)/?', array(
+ 'methods' => \WP_REST_Server::READABLE,
+ 'callback' => array( $this, 'plugin_info' ),
+ 'args' => array(
+ 'plugin_slug' => array(
+ 'validate_callback' => array( $this, 'validate_plugin_slug_callback' ),
+ )
+ )
+ ) );
+ }
+
+ /**
+ * Endpoint to retrieve a full plugin representation.
+ *
+ * @param \WP_REST_Request $request The Rest API Request.
+ * @return array A formatted array of all the data for the plugin.
+ */
+ function plugin_info( $request ) {
+ /*
+ * NOTE: Don't try to implement things such as the `fields` support in this endpoint.
+ * It's highly unlikely we'll expose the REST API via api.wordpress.org as it is,
+ * it'll probably have something in front of it.
+ *
+ * NOTE: Don't use any data from the client, such as the user_agent, just stick to what is presented in the GET payload.
+ * It can't be cached if it's using data from other sources.
+ */
+ $plugin_slug = $request['plugin_slug'];
+
+ global $post;
+ $post = Plugin_Directory::get_plugin_post( $plugin_slug );
+
+ if ( 'publish' != $post->post_status ) {
+ // Copy what the REST API does if the param is incorrect
+ return new \WP_Error(
+ 'rest_invalid_param',
+ 'Invalid parameter(s): plugin_slug',
+ array(
+ 'status' => \WP_HTTP::BAD_REQUEST,
+ 'params' => array(
+ 'plugin_slug' => 'Invalid parameter.'
+ )
+ )
+ );
+ }
+
+ $post_id = $post->ID;
+
+ $result = array();
+ $result['name'] = $post->post_title;
+ $result['slug'] = $post->post_name;
+ $result['version'] = get_post_meta( $post_id, 'version', true );
+
+ if ( get_post_meta( $post_id, 'header_author_uri', true ) ) {
+ $result['author'] = sprintf( '<a href="%s">%s</a>', get_post_meta( $post_id, 'header_author_uri', true ), get_post_meta( $post_id, 'header_author', true ) );
+ } elseif ( get_post_meta( $post_id, 'header_aufthor', true ) ) {
+ $result['author'] = get_post_meta( $post_id, 'header_aufthor', true );
+ } else {
+ $result['author'] = get_user_by( 'id', $post->post_author )->display_name;
+ }
+
+ $result['author_profile'] = $this->get_user_profile_link( $post->post_author );
+ $result['contributors'] = array();
+
+ foreach ( (array)get_post_meta( $post_id, 'contributors', true ) as $contributor ) {
+ $user = get_user_by( 'slug', $contributor );
+ if ( ! $user ) {
+ continue;
+ }
+
+ $result['contributors'][ $contributor ] = array(
+ 'profile' => $this->get_user_profile_link( $user ),
+ 'avatar' => get_avatar_url( $user, array( 'default' => 'monsterid', 'rating' => 'g' ) ),
+ 'display_name' => $user->display_name
+ );
+ }
+
+ $result['requires'] = get_post_meta( $post_id, 'requires', true );
+ $result['tested'] = get_post_meta( $post_id, 'tested', true );
+ $result['compatibility'] = array();
+ $result['rating'] = get_post_meta( $post_id, 'rating', true ) * 20; // Stored as 0.0 ~ 5.0, API outputs as 0..100
+ $result['ratings'] = array_map( 'intval', (array) get_post_meta( $post_id, 'ratings', true ) );
+ $result['num_ratings'] = array_sum( $result['ratings'] );
+ $result['active_installs'] = (int)get_post_meta( $post_id, 'active_installs', true );
+ $result['downloaded'] = get_post_meta( $post_id, 'downloads', true );
+ $result['last_updated'] = gmdate( 'Y-m-d', strtotime( $post->post_modified_gmt ) );
+ $result['added'] = gmdate( 'Y-m-d', strtotime( $post->post_date_gmt ) );
+ $result['homepage'] = get_post_meta( $post_id, 'header_plugin_uri', true );
+ $result['sections'] = array();
+
+ $_pages = preg_split( "#<!--section=(.+?)-->#", $post->post_content, - 1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
+ for ( $i = 0; $i < count( $_pages ); $i += 2 ) {
+ $result['sections'][ $_pages[ $i ] ] = apply_filters( 'the_content', $_pages[ $i + 1 ] );
+ }
+ $result['sections']['reviews'] = $this->get_plugin_reviews_markup( $post->post_name );
+ $result['description'] = $result['sections']['description'];
+
+ $result['description'] = $post->post_excerpt;
+ $result['download_link'] = Template::download_link( $post );
+
+ $result['tags'] = array();
+ if ( $terms = get_the_terms( $post->ID, 'plugin_tag' ) ) {
+ foreach ( $terms as $term ) {
+ $result['tags'][ $term->slug ] = $term->name;
+ }
+ }
+
+ $result['stable_tag'] = get_post_meta( $post_id, 'stable_tag', true );
+
+ $result['versions'] = array();
+ if ( $versions = get_post_meta( $post_id, 'tagged_versions', true ) ) {
+ foreach ( $versions as $version ) {
+ $result['versions'][ $version ] = Template::download_link( $post, $version );
+ }
+ }
+
+ $result['donate_link'] = get_post_meta( $post_id, 'donate_link', true );
+
+ $result['banners'] = array();
+ if ( $banners = Template::get_plugin_banner( $post ) ) {
+ if ( isset( $banners['baner'] ) ) {
+ $result['banners']['low'] = $banners['banner'];
+ }
+ if ( isset( $banners['banner_2x'] ) ) {
+ $result['banners']['high'] = $banners['banner_2x'];
+ }
+ }
+
+ $result['icons'] = array();
+ if ( $icons = Template::get_plugin_icon( $post ) ) {
+ if ( !empty( $icons['icon'] ) && empty( $icons['generated'] ) ) {
+ $result['icons']['1x'] = $icons['icon'];
+ } elseif ( !empty( $icons['icon'] ) && ! empty( $icons['generated'] ) ) {
+ $result['icons']['default'] = $icons['icon'];
+ }
+ if ( !empty( $icons['icon_2x'] ) ) {
+ $result['icons']['2x'] = $icons['icon_2x'];
+ }
+ if ( !empty( $icons['svg'] ) ) {
+ $result['icons']['svg'] = $icons['svg'];
+ }
+ }
+
+ // That's all folks!
+
+ return $result;
+ }
+
+ /**
+ * Generate a link for a user to profiles.wordpress.org.
+ *
+ * @param int|\WP_User|string A WP_User instance, or ID/slug of a user.
+ * @return string The profiles.wordpress.org link.
+ */
+ protected function get_user_profile_link( $user ) {
+ $u = false;
+ if ( $user instanceOf \WP_User ) {
+ $u = $user;
+ } else {
+ if ( is_numeric( $user ) ) {
+ $u = get_user_by( 'id', $user );
+ }
+ if ( ! $u ) {
+ $u = get_user_by( 'slug', $user );
+ }
+ }
+
+ return 'https://profiles.wordpress.org/' . $u->user_nicename;
+ }
+
+ /**
+ * Returns a HTML formatted representation of the latest 10 reviews for a plugin.
+ *
+ * @param string $plugin_slug The plugin slug.
+ * @return string HTML blob of data.
+ */
+ protected function get_plugin_reviews_markup( $plugin_slug ) {
+ $output = '';
+ foreach ( $this->get_plugin_reviews_data( $plugin_slug ) as $review ) {
+ $output .= $this->get_plugin_reviews_markup_singular( $review );
+ }
+ return $output;
+ }
+
+ /**
+ * Generates a HTML blob for a single review.
+ *
+ * @param object $review Single row of data from `self::get_plugin_reviews_data()`
+ * @return string Blob of HTML representing the review.
+ */
+ protected function get_plugin_reviews_markup_singular( $review ) {
+ $reviewer = get_user_by( 'id', $review->topic_poster );
+ ob_start();
+
+ // Copied from bb-theme/wporg/_reviews.php, with quite a few things stripped out.
+?>
+<div class="review">
+ <div class="review-head">
+ <div class="reviewer-info">
+ <div class="review-title-section">
+ <h4 class="review-title"><?php echo $review->topic_title; ?></h4>
+ <div class="star-rating"><?php
+ /* Core has .star-rating .star colour styling, which is why we use a custom wrapper and template */
+ echo Template::dashicons_stars( array(
+ 'rating' => wporg_get_rating( $review->topic_id ),
+ 'template' => '<span class="star %1$s"></span>',
+ ) );
+ ?></div>
+ </div>
+ <p class="reviewer">
+ By <a href="https://profiles.wordpress.org/<?php echo $reviewer->user_nicename; ?>"><?php echo get_avatar( $review->topic_poster, 16, 'monsterid' ); ?></a>
+ <a href="https://profiles.wordpress.org/<?php echo $reviewer->user_nicename; ?>" class="reviewer-name"><?php
+ echo $reviewer->display_name;
+
+ if ( $reviewer->display_name != $reviewer->user_login ) {
+ echo " <small>({$reviewer->user_login})</small>";
+ }
+ ?></a><?php
+ /* // Display author badge next to the person's name if they're reviewing their own thing
+ if ( class_exists( '\WPORG_Extend_Author_Badge' ) ) {
+ echo \WPORG_Extend_Author_Badge::get_instance()->show_author_badge( '', $post->post_id );
+ } */
+ ?>,
+ <span class="review-date"><?php echo gmdate( 'F j, Y', strtotime( $review->topic_start_time ) ); ?></span>
+ <?php if ( $review->wp_version ) : ?>
+ <span class="review-wp-version">for WordPress <?php echo $review->wp_version; ?></span>
+ <?php endif; ?>
+ </p>
+ </div>
+ </div>
+ <div class="review-body"><?php echo $review->post_text; ?></div>
+</div>
+<?php
+ return ob_get_clean();
+
+ }
+
+ /**
+ * Fetch the latest 10 reviews for a given plugin from the database.
+ *
+ * This uses raw SQL to query the bbPress tables to fetch reviews.
+ *
+ * @param string $plugin_slug The slug of the plugin.
+ * @return array An array of review details.
+ */
+ protected function get_plugin_reviews_data( $plugin_slug ) {
+ global $wpdb;
+ if ( ! defined( 'WPORGPATH' ) || ! defined( 'CUSTOM_USER_TABLE' ) ) {
+ // Reviews are stored in the main supoport forum, which isn't open source yet.
+ return array();
+ }
+
+ if ( $reviews = wp_cache_get( $plugin_slug, 'reviews' ) ) {
+ return $reviews;
+ }
+
+ // The forums are the source for users, and also where reviews live.
+ $table_prefix = str_replace( 'users', '', CUSTOM_USER_TABLE );
+ $forum_id = 18; // The Review Forums ID
+
+ $reviews = $wpdb->get_results( $wpdb->prepare( "
+ SELECT
+ t.topic_id, t.topic_title, t.topic_poster, t.topic_start_time,
+ p.post_text,
+ tm_wp.meta_value as wp_version
+ FROM {$table_prefix}topics AS t
+ JOIN {$table_prefix}meta AS tm ON ( tm.object_type = 'bb_topic' AND t.topic_id = tm.object_id AND tm.meta_key = 'is_plugin' )
+ JOIN {$table_prefix}posts as p ON ( t.topic_id = p.topic_id AND post_status = 0 AND post_position = 1 )
+ LEFT JOIN {$table_prefix}meta AS tm_wp ON ( tm_wp.object_type = 'bb_topic' AND t.topic_id = tm_wp.object_id AND tm_wp.meta_key = 'wp_version' )
+ WHERE t.forum_id = %d AND t.topic_status = 0 AND t.topic_sticky = 0 AND tm.meta_value = %s
+ ORDER BY t.topic_start_time DESC
+ LIMIT 10",
+ $forum_id,
+ $plugin_slug
+ ) );
+
+ wp_cache_set( $plugin_slug, $reviews, 'reviews' );
+ return $reviews;
+ }
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/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_htmlwpcontentpluginsplugindirectoryclassplugindirectoryphp"></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/plugin-directory/class-plugin-directory.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/plugin-directory/class-plugin-directory.php 2016-04-27 07:51:54 UTC (rev 3019)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php 2016-04-27 08:08:11 UTC (rev 3020)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -385,6 +385,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function filter_post_content_to_correct_page( $content ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
+ return $content;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( 'plugin' === get_post()->post_type ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $page = get_query_var( 'content_page' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -504,6 +507,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return $post;
</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">+ // TODO: Add caching here.
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // get_post_by_slug();
</span><span class="cx" style="display: block; padding: 0 10px"> $posts = get_posts( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_type' => 'plugin',
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryclasstemplatephp"></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/plugin-directory/class-template.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/plugin-directory/class-template.php 2016-04-27 07:51:54 UTC (rev 3019)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php 2016-04-27 08:08:11 UTC (rev 3020)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -66,8 +66,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- static function get_plugin_sections() {
- $plugin = get_post();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ static function get_plugin_sections( $post = null ) {
+ $plugin = get_post( $post );
</ins><span class="cx" style="display: block; padding: 0 10px"> $plugin_slug = $plugin->post_name;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $default_sections = array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -172,7 +172,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $raw_icons = get_post_meta( $plugin->ID, 'assets_icons', true );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $icon = $icon_2x = $vector = $generated = false;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $icon = $icon_2x = $svg = $generated = false;
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $raw_icons as $file => $info ) {
</span><span class="cx" style="display: block; padding: 0 10px"> switch ( $info['resolution'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> case '256x256':
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -183,13 +183,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $icon = self::get_asset_url( $plugin_slug, $info );
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /* false = the resolution of the icon, this is NOT disabled */
</ins><span class="cx" style="display: block; padding: 0 10px"> case false && 'icon.svg' == $file:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $icon = self::get_asset_url( $plugin_slug, $info );
- $vector = true;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $svg = self::get_asset_url( $plugin_slug, $info );
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</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">+ if ( ! $icon && $svg ) {
+ $icon = $svg;
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $icon ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $generated = true;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -222,7 +226,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> case 'raw':
</span><span class="cx" style="display: block; padding: 0 10px"> default:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return compact( 'icon', 'icon_2x', 'vector', 'generated' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return compact( 'svg', 'icon', 'icon_2x', 'generated' );
</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">@@ -332,5 +336,25 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $output .= '</div>';
</span><span class="cx" style="display: block; padding: 0 10px"> return $output;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /**
+ * Generate a Download link for a given plugin & version.
+ *
+ * @param \WP_Post $post The Plugin Post.
+ * @param string $version The version to link to. Optional. Default: latest.
+ * @return string The Download URL.
+ */
+ static function download_link( $post = null, $version = 'latest' ) {
+ $post = get_post( $post );
+
+ if ( 'latest' == $version || 'latest-stable' == $version ) {
+ $version = get_post_meta( $post->ID, 'stable_tag', true );
+ }
+
+ if ( 'trunk' != $version ) {
+ return sprintf( "https://downloads.wordpress.org/plugin/%s.%s.zip", $post->post_name, $version );
+ } else {
+ return sprintf( "https://downloads.wordpress.org/plugin/%s.zip", $post->post_name );
+ }
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectorywidgetsclassratingsphp"></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/plugin-directory/widgets/class-ratings.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/plugin-directory/widgets/class-ratings.php 2016-04-27 07:51:54 UTC (rev 3019)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-ratings.php 2016-04-27 08:08:11 UTC (rev 3020)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -88,7 +88,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> jQuery(document).ready( function($) {
</span><span class="cx" style="display: block; padding: 0 10px"> var $rating = $( '.user-rating div' ),
</span><span class="cx" style="display: block; padding: 0 10px"> $stars = $rating.find( '.dashicons' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- current_rating = $rating.data('rating'),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ current_rating = $rating.data( 'rating' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> rating_clear_timer = 0;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $stars.mouseover( function() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -98,7 +98,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> rating = $prev_items.length + 1;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( rating_clear_timer ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- rating_clear_timer = clearTimeout( rating_clear_timer );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ clearTimeout( rating_clear_timer );
+ rating_clear_timer = 0;
</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"> if ( rating == current_rating ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -114,7 +115,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px"> $rating.mouseout( function() {
</span><span class="cx" style="display: block; padding: 0 10px"> var clear_callback = function() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var rating = $rating.data('rating');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var rating = $rating.data( 'rating' );
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( rating == current_rating ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>
</body>
</html>