<!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>[4505] sites/trunk/wordpress.org/public_html/wp-content: Plugin Directory: Use `get_post()` for template functions.</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/4505">4505</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/4505","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>2016-12-08 13:58:37 +0000 (Thu, 08 Dec 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: Use `get_post()` for template functions.
Template functions should fall back to the global post object.
Also fixes a bug where assets weren't loaded correctly while in the loop.
Props joostdevalk for initial patch.
Fixes <a href="http://meta.trac.wordpress.org/ticket/2303">#2303</a>.</pre>
<h3>Modified 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>
<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_htmlwpcontentpluginsplugindirectorycliclassimportphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryshortcodesclassscreenshotsphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-screenshots.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpluginsfunctionsphp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/functions.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpluginstemplatepartspluginsinglephp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/plugin-single.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryapiroutesclasspluginphp"></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/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 2016-12-08 12:38:26 UTC (rev 4504)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin.php 2016-12-08 13:58:37 UTC (rev 4505)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -13,6 +13,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Plugin extends Base {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Plugin constructor.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> function __construct() {
</span><span class="cx" style="display: block; padding: 0 10px"> register_rest_route( 'plugins/v1', '/plugin/(?P<plugin_slug>[^/]+)/?', array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'methods' => WP_REST_Server::READABLE,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -123,7 +126,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $screen_shots as $image ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $result['screenshots'][ $image['resolution'] ] = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'src' => Template::get_asset_url( $post->post_name, $image ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'src' => Template::get_asset_url( $post, $image ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'caption' => array_key_exists( $image['resolution'], $descriptions ) ? $descriptions[ $image['resolution'] ] : ''
</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_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-12-08 12:38:26 UTC (rev 4504)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php 2016-12-08 13:58:37 UTC (rev 4505)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -116,8 +116,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public static function get_plugin_sections( $post = null ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $plugin = get_post( $post );
- $plugin_slug = $plugin->post_name;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $plugin = get_post( $post );
</ins><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="cx" style="display: block; padding: 0 10px"> 'description',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -173,12 +172,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> case 'support':
</span><span class="cx" style="display: block; padding: 0 10px"> $title = _x( 'Support', 'plugin tab title', 'wporg-plugins' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $url = 'https://wordpress.org/support/plugin/' . $plugin_slug;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $url = 'https://wordpress.org/support/plugin/' . $plugin->post_name;
</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"> case 'reviews':
</span><span class="cx" style="display: block; padding: 0 10px"> $title = _x( 'Reviews', 'plugin tab title', 'wporg-plugins' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $url = 'https://wordpress.org/support/plugin/' . $plugin_slug . '/reviews/';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $url = 'https://wordpress.org/support/plugin/' . $plugin->post_name . '/reviews/';
</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"> case 'developers':
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -210,33 +209,28 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @static
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param \WP_Post|string $plugin An instance of a Plugin post, or the plugin slug.
- * @param string $output Optional. Output type. 'html' or 'raw'. Default: 'raw'.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
+ * @param string $output Optional. Output type. 'html' or 'raw'. Default: 'raw'.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return mixed
</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 static function get_plugin_icon( $plugin, $output = 'raw' ) {
- $plugin = Plugin_Directory::instance()->get_plugin_post( $plugin );
- if ( ! $plugin ) {
- return false;
- }
- $plugin_slug = $plugin->post_name;
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function get_plugin_icon( $post = null, $output = 'raw' ) {
+ $plugin = get_post( $post );
</ins><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><span class="cx" style="display: block; padding: 0 10px"> $icon = $icon_2x = $svg = $generated = false;
</span><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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $icon_2x = self::get_asset_url( $plugin_slug, $info );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $icon_2x = self::get_asset_url( $plugin, $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"> case '128x128':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $icon = self::get_asset_url( $plugin_slug, $info );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $icon = self::get_asset_url( $plugin, $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"> /* false = the resolution of the icon, this is NOT disabled */
</span><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">- $svg = self::get_asset_url( $plugin_slug, $info );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $svg = self::get_asset_url( $plugin, $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="lines" style="display: block; padding: 0 10px; color: #888">@@ -269,7 +263,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> switch ( $output ) {
</span><span class="cx" style="display: block; padding: 0 10px"> case 'html':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id = "plugin-icon-{$plugin_slug}";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $id = "plugin-icon-{$plugin->post_name}";
</ins><span class="cx" style="display: block; padding: 0 10px"> $html = "<style type='text/css'>";
</span><span class="cx" style="display: block; padding: 0 10px"> $html .= "#{$id} { background-image: url('{$icon}'); } .plugin-icon { background-size: cover; height: 128px; width: 128px; }";
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $icon_2x ) && ! $generated ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -292,18 +286,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @static
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param \WP_Post|string $plugin An instance of a Plugin post, or the plugin slug.
- * @param string $output Optional. Output type. 'html' or 'raw'. Default: 'raw'.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
+ * @param string $output Optional. Output type. 'html' or 'raw'. Default: 'raw'.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return mixed
</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 static function get_plugin_banner( $plugin, $output = 'raw' ) {
- $plugin = Plugin_Directory::instance()->get_plugin_post( $plugin );
- if ( ! $plugin ) {
- return false;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function get_plugin_banner( $post = null, $output = 'raw' ) {
+ $plugin = get_post( $post );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $banner = $banner_2x = false;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $plugin_slug = $plugin->post_name;
</del><span class="cx" style="display: block; padding: 0 10px"> $raw_banners = get_post_meta( $plugin->ID, 'assets_banners', true );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Split in rtl and non-rtl banners.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -316,11 +306,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $raw_banners as $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 '1544x500':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $banner_2x = self::get_asset_url( $plugin_slug, $info );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $banner_2x = self::get_asset_url( $plugin, $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"> case '772x250':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $banner = self::get_asset_url( $plugin_slug, $info );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $banner = self::get_asset_url( $plugin, $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="lines" style="display: block; padding: 0 10px; color: #888">@@ -329,11 +319,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $rtl_banners as $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 '1544x500':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $banner_2x = self::get_asset_url( $plugin_slug, $info );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $banner_2x = self::get_asset_url( $plugin, $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"> case '772x250':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $banner = self::get_asset_url( $plugin_slug, $info );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $banner = self::get_asset_url( $plugin, $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="lines" style="display: block; padding: 0 10px; color: #888">@@ -345,7 +335,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> switch ( $output ) {
</span><span class="cx" style="display: block; padding: 0 10px"> case 'html':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id = "plugin-banner-{$plugin_slug}";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $id = "plugin-banner-{$plugin->post_name}";
</ins><span class="cx" style="display: block; padding: 0 10px"> $html = "<style type='text/css'>";
</span><span class="cx" style="display: block; padding: 0 10px"> $html .= "#{$id} { background-image: url('{$banner}'); }";
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $banner_2x ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -370,11 +360,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @static
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $plugin Plugin slug.
- * @param array $asset Assets folder information.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
+ * @param array $asset Assets folder information.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return string
</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 static function get_asset_url( $plugin, $asset ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function get_asset_url( $post, $asset ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $asset['location'] ) && 'plugin' == $asset['location'] ) {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Screenshots in the plugin folder - /plugins/plugin-name/screenshot-1.png.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -393,7 +383,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return esc_url( sprintf(
</span><span class="cx" style="display: block; padding: 0 10px"> $format,
</span><span class="cx" style="display: block; padding: 0 10px"> $asset['revision'],
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $plugin,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ get_post( $post )->post_name,
</ins><span class="cx" style="display: block; padding: 0 10px"> $asset['filename']
</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">@@ -450,8 +440,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Generate a download link for a given plugin & version.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param \WP_Post $post The Plugin Post.
- * @param string $version The version to link to. Optional. Default: latest.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
+ * @param string $version The version to link to. Optional. Default: latest.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return string The Download URL.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> static function download_link( $post = null, $version = 'latest' ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -485,24 +475,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Generates a link to toggle a plugin favorites state.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $plugin_slug The plugin slug.
- * @param mixed $user The user to alter the favorite status for.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
+ * @param mixed $user The user to alter the favorite status for.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return string URL to toggle status.
</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 static function get_favourite_link( $plugin_slug, $user = 0 ) {
- $post = Plugin_Directory::get_plugin_post( $plugin_slug );
- if ( ! $post ) {
- return false;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function get_favorite_link( $post = null, $user = 0 ) {
+ $post = get_post( $post );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $favorited = Tools::favorited_plugin( $post, $user );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return add_query_arg(
- array(
- '_wpnonce' => wp_create_nonce( 'wp_rest' ),
- ( $favorited ? 'unfavorite' : 'favorite' ) => '1'
- ),
- home_url( 'wp-json/plugins/v1/plugin/' . $post->post_name . '/favorite' )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return add_query_arg( array(
+ '_wpnonce' => wp_create_nonce( 'wp_rest' ),
+ ( $favorited ? 'unfavorite' : 'favorite' ) => '1'
+ ), home_url( 'wp-json/plugins/v1/plugin/' . $post->post_name . '/favorite' ) );
</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_htmlwpcontentpluginsplugindirectorycliclassimportphp"></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/cli/class-import.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/cli/class-import.php 2016-12-08 12:38:26 UTC (rev 4504)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php 2016-12-08 13:58:37 UTC (rev 4505)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -179,7 +179,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $banner_average_color = '';
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $first_banner = reset( $assets['banner'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // The Banners are not stored locally, which is why a URL is used here
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $banner_average_color = Tools::get_image_average_color( Template::get_asset_url( $plugin_slug, $first_banner ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $banner_average_color = Tools::get_image_average_color( Template::get_asset_url( $plugin, $first_banner ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> update_post_meta( $plugin->ID, 'assets_banners_color', wp_slash( $banner_average_color ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryshortcodesclassscreenshotsphp"></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/shortcodes/class-screenshots.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/shortcodes/class-screenshots.php 2016-12-08 12:38:26 UTC (rev 4504)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-screenshots.php 2016-12-08 13:58:37 UTC (rev 4505)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -30,7 +30,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $screen_shots as $image ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $screen_shot = sprintf( '<a href="%1$s" rel="nofollow"><img class="screenshot" src="%1$s" alt="" /></a>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- Template::get_asset_url( $plugin->post_name, $image )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ Template::get_asset_url( $plugin, $image )
</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 ( $descriptions && ! empty( $descriptions[ (int)$image['resolution'] ] ) ) {
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpluginsfunctionsphp"></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-plugins/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-plugins/functions.php 2016-12-08 12:38:26 UTC (rev 4504)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/functions.php 2016-12-08 13:58:37 UTC (rev 4505)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -163,27 +163,26 @@
</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">- $post_id = get_the_ID();
- $banner = Template::get_plugin_banner( $post_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $banner = Template::get_plugin_banner();
</ins><span class="cx" style="display: block; padding: 0 10px"> $banner['banner_2x'] = $banner['banner_2x'] ? $banner['banner'] : false;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $icon = Template::get_plugin_icon( $post_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $icon = Template::get_plugin_icon();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- printf( '<meta property="og:title" content="%s" />' . "\n", the_title_attribute( array( 'echo' => false, 'post' => $post_id ) ) );
- printf( '<meta property="og:description" content="%s" />' . "\n", esc_attr( strip_tags( get_the_excerpt( $post_id ) ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ printf( '<meta property="og:title" content="%s" />' . "\n", the_title_attribute( array( 'echo' => false ) ) );
+ printf( '<meta property="og:description" content="%s" />' . "\n", esc_attr( strip_tags( get_the_excerpt() ) ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> printf( '<meta property="og:site_name" content="WordPress.org" />' . "\n" );
</span><span class="cx" style="display: block; padding: 0 10px"> printf( '<meta property="og:type" content="website" />' . "\n" );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- printf( '<meta property="og:url" content="%s" />' . "\n", esc_url( get_permalink( $post_id ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ printf( '<meta property="og:url" content="%s" />' . "\n", esc_url( get_permalink() ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> printf( '<meta name="twitter:card" content="summary_large_image">' . "\n" );
</span><span class="cx" style="display: block; padding: 0 10px"> printf( '<meta name="twitter:site" content="@WordPress">' . "\n" );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $banner['banner_2x'] ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- printf( '<meta name="twitter:image" content="%s" />' . "\n", $banner['banner_2x'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ printf( '<meta name="twitter:image" content="%s" />' . "\n", esc_url( $banner['banner_2x'] ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $banner['banner'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- printf( '<meta property="og:image" content="%s" />' . "\n", $banner['banner'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ printf( '<meta property="og:image" content="%s" />' . "\n", esc_url( $banner['banner'] ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $icon['generated'] && ( $icon['icon_2x'] || $icon['icon'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- printf( '<meta name="thumbnail" content="%s" />', $icon['icon_2x'] ?: $icon['icon'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ printf( '<meta name="thumbnail" content="%s" />' . "\n", esc_url( $icon['icon_2x'] ?: $icon['icon'] ) );
</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"> add_action( 'wp_head', __NAMESPACE__ . '\social_meta_data' );
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpluginstemplatepartspluginsinglephp"></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-plugins/template-parts/plugin-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-plugins/template-parts/plugin-single.php 2016-12-08 12:38:26 UTC (rev 4504)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/plugin-single.php 2016-12-08 13:58:37 UTC (rev 4505)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -66,7 +66,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <div class="plugin-actions">
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_user_logged_in() ) :
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $url = Template::get_favourite_link( $post );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $url = Template::get_favorite_link();
</ins><span class="cx" style="display: block; padding: 0 10px"> $is_favorited = Tools::favorited_plugin( $post );
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <div class="plugin-favorite">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -140,7 +140,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( false !== stripos( $section_content, '<dl>' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $section_no_read_mores[] = 'faq';
</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">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $section_read_more = ! in_array( $section_slug, $section_no_read_mores );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> get_template_part( 'template-parts/section' );
</span></span></pre>
</div>
</div>
</body>
</html>