<!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>[8729] sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory: Plugin Directory: Introduce localised screenshots, allowing plugins to have translated screenshots on the website and within the wp-admin plugin installer.</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 { white-space: pre-line; 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/8729">8729</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/8729","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>2019-05-03 07:03:20 +0000 (Fri, 03 May 2019)</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: Introduce localised screenshots, allowing plugins to have translated screenshots on the website and within the wp-admin plugin installer.
This works by allowing screenshots located in the `/assets/` folder to define the locale of the image, eg. `screenshot-1-de_DE.png` or `screenshot-1-ary.png`.
Props ck3lee, dd32.
See <a href="http://meta.trac.wordpress.org/ticket/3935">#3935</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryapifieldspluginclassscreenshotsphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/fields/plugin/class-screenshots.php</a></li>
<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>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryapifieldspluginclassscreenshotsphp"></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/fields/plugin/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/api/fields/plugin/class-screenshots.php 2019-05-03 04:40:12 UTC (rev 8728)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/fields/plugin/class-screenshots.php 2019-05-03 07:03:20 UTC (rev 8729)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -8,7 +8,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> class Screenshots {
</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">- * Banners constructor.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Screenshots constructor.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function __construct() {
</span><span class="cx" style="display: block; padding: 0 10px"> register_rest_field( 'plugin', 'screenshots', [
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -27,23 +27,15 @@
</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 function get_screenshots( $object ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $descriptions = get_post_meta( $object['id'], 'screenshots', true ) ?: [];
- $screen_shots = get_post_meta( $object['id'], 'assets_screenshots', true ) ?: [];
- $response = [];
-
- foreach ( $screen_shots as $image ) {
- $screen_shot = [
- 'src' => esc_url( Template::get_asset_url( $object['id'], $image ) ),
- ];
-
- if ( $descriptions && ! empty( $descriptions[ (int) $image['resolution'] ] ) ) {
- $caption = $descriptions[ (int) $image['resolution'] ];
- $screen_shot['caption'] = Plugin_I18n::instance()->translate( 'screenshot-' . $image['resolution'], $caption, [ 'post_id' => $object['id'] ] );
- }
-
- $response[] = $screen_shot;
- }
-
- return $response;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Reduce the Screenshots to the required fields.
+ return array_values( array_map(
+ function( $image ) {
+ return [
+ 'src' => $image['src'],
+ 'caption' => $image['caption'],
+ ];
+ },
+ Template::get_screenshots( $object['id'] )
+ ) );
</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_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 2019-05-03 04:40:12 UTC (rev 8728)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin.php 2019-05-03 07:03:20 UTC (rev 8729)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -154,25 +154,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $result['short_description'] = get_the_excerpt();
</span><span class="cx" style="display: block; padding: 0 10px"> $result['download_link'] = Template::download_link( $post );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result['screenshots'] = array();
- $descriptions = get_post_meta( $post->ID, 'screenshots', true ) ?: array();
- $screen_shots = get_post_meta( $post->ID, 'assets_screenshots', true ) ?: array();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Reduce images to caption + src
+ $result['screenshots'] = array_map(
+ function( $image ) {
+ return [
+ 'src' => $image['src'],
+ 'caption' => $image['caption'],
+ ];
+ },
+ Template::get_screenshots( $post )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /*
- * Find the image that corresponds with the text.
- * The image numbers are stored within the 'resolution' key.
- */
- foreach ( $screen_shots as $image ) {
- $src = Template::get_asset_url( $post, $image );
- $caption = '';
- if ( $descriptions && ! empty( $descriptions[ (int) $image['resolution'] ] ) ) {
- $caption = $descriptions[ (int) $image['resolution'] ];
- $caption = Plugin_I18n::instance()->translate( 'screenshot-' . $image['resolution'], $caption, [ 'post_id' => $post->ID ] );
- }
-
- $result['screenshots'][ $image['resolution'] ] = compact( 'src', 'caption' );
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( $result['screenshots'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $result['sections']['screenshots'] = $this->get_screenshot_markup( $result['screenshots'] );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</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 2019-05-03 04:40:12 UTC (rev 8728)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php 2019-05-03 07:03:20 UTC (rev 8729)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -364,7 +364,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'reviews',
</span><span class="cx" style="display: block; padding: 0 10px"> 'developers',
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! get_post_meta( $plugin->ID, 'screenshots', true ) && ! get_post_meta( $plugin->ID, 'assets_screenshots', true ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! get_post_meta( $plugin->ID, 'assets_screenshots', true ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> unset( $default_sections[ array_search( 'screenshots', $default_sections ) ] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! get_post_meta( $plugin->ID, 'all_blocks' ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -979,4 +979,86 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return $link;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /**
+ * Fetch plugin Screenshots, accounting for localised screenshots.
+ *
+ * @static
+ *
+ * @param object|int $plugin The plugin to fetch screenshots for. Optional.
+ * @param string $locale The locale requested. Optional.
+ * @return array Screenshots for the plugin, localised if possible.
+ */
+ public static function get_screenshots( $plugin = null, $locale = null ) {
+ $plugin = get_post( $plugin );
+
+ if ( ! $locale ) {
+ $locale = get_locale();
+ }
+
+ // All indexed from 1. The Image 'number' is stored in the 'resolution' key
+ $screen_shots = get_post_meta( $plugin->ID, 'assets_screenshots', true ) ?: array();
+ $descriptions = get_post_meta( $plugin->ID, 'screenshots', true ) ?: array();
+
+ if ( empty( $screen_shots ) ) {
+ return array();
+ }
+
+ $sorted = array();
+ foreach ( $screen_shots as $image ) {
+ if ( ! isset( $sorted[ $image['resolution'] ] ) ) {
+ $sorted[ $image['resolution'] ] = array();
+ }
+
+ if ( empty( $image['locale'] ) ) {
+ // if the image has no locale, always insert to the last element (lowerst priority).
+ $sorted[ $image['resolution'] ][] = $image;
+ } elseif ( $locale === $image['locale'] ) {
+ // if the locale is a full match, always insert to the first element (highest priority).
+ array_unshift( $sorted[ $image['resolution'] ], $image );
+ } else {
+ // TODO: de_DE_informal should probably fall back to de_DE before de_CH. Maybe this can wait until Core properly supports locale hierarchy.
+
+ $image_locale_parts = explode( '_', $image['locale'] );
+ $locale_parts = explode( '_', $locale );
+ // if only the language matches.
+ if ( $image_locale_parts[0] === $locale_parts[0] ) {
+ // image with locale has a higher priority than image without locale.
+ $last_image = end( $sorted[ $image['resolution'] ] );
+ if ( empty( $last_image['locale'] ) ) {
+ array_splice( $sorted[ $image['resolution'] ], count( $sorted[ $image['resolution'] ] ), 0, array( $image ) );
+ } else {
+ $sorted[ $image['resolution'] ][] = $image;
+ }
+ }
+ }
+ }
+
+ // Sort
+ ksort( $sorted, SORT_NATURAL );
+
+ // Reduce images to singulars and attach metadata
+ foreach ( $sorted as $index => $items ) {
+ // The highest priority image is the first.
+ $image = $items[0];
+
+ // Attach caption data
+ $image['caption'] = false;
+ if ( isset( $descriptions[ (int) $index ] ) ) {
+ $image['caption'] = $descriptions[ (int) $index ];
+ $image['caption'] = Plugin_I18n::instance()->translate(
+ 'screenshot-' . $image['resolution'],
+ $image['caption'],
+ [ 'post_id' => $plugin->ID ]
+ );
+ }
+
+ // Attach URL information for the asset
+ $image['src'] = Template::get_asset_url( $plugin, $image );
+
+ $sorted[ $index ] = $image;
+ }
+
+ return $sorted;
+ }
</ins><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 2019-05-03 04:40:12 UTC (rev 8728)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php 2019-05-03 07:03:20 UTC (rev 8729)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -364,8 +364,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $svn_assets_folder = SVN::ls( self::PLUGIN_SVN_BASE . "/{$plugin_slug}/assets/", true /* verbose */ );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $svn_assets_folder ) { // /assets/ may not exist.
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $svn_assets_folder as $asset ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // screenshot-0(-rtl).(png|jpg|jpeg|gif) || icon.svg
- if ( ! preg_match( '!^(?P<type>screenshot|banner|icon)(-(?P<resolution>[\dx]+)(-rtl)?\.(png|jpg|jpeg|gif)|\.svg)$!i', $asset['filename'], $m ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // screenshot-0(-rtl)(-de_DE).(png|jpg|jpeg|gif) || icon.svg
+ if ( ! preg_match( '!^(?P<type>screenshot|banner|icon)(?:-(?P<resolution>[\dx]+)(-rtl)?(?:-(?P<locale>[a-z]{2,3}(?:_[A-Z]{2})?(?:_[a-z0-9]+)?))?\.(png|jpg|jpeg|gif)|\.svg)$!i', $asset['filename'], $m ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> continue;
</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">@@ -374,8 +374,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $revision = $asset['revision'];
</span><span class="cx" style="display: block; padding: 0 10px"> $location = 'assets';
</span><span class="cx" style="display: block; padding: 0 10px"> $resolution = isset( $m['resolution'] ) ? $m['resolution'] : false;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $locale = isset( $m['locale'] ) ? $m['locale'] : false;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $assets[ $type ][ $asset['filename'] ] = compact( 'filename', 'revision', 'resolution', 'location' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $assets[ $type ][ $asset['filename'] ] = compact( 'filename', 'revision', 'resolution', 'location', 'locale' );
</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_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 2019-05-03 04:40:12 UTC (rev 8728)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-screenshots.php 2019-05-03 07:03:20 UTC (rev 8729)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -15,34 +15,22 @@
</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"> static function display() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $plugin = get_post();
</del><span class="cx" style="display: block; padding: 0 10px"> $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">- // All indexed from 1.
- $descriptions = get_post_meta( $plugin->ID, 'screenshots', true ) ?: array();
- $screen_shots = get_post_meta( $plugin->ID, 'assets_screenshots', true ) ?: array();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $screenshots = Template::get_screenshots();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( empty( $screen_shots ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! $screenshots ) {
</ins><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">- ksort( $screen_shots, SORT_NATURAL );
-
- /*
- * Find the image that corresponds with the text.
- * The image numbers are stored within the 'resolution' key.
- */
- foreach ( $screen_shots as $image ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $screenshots as $image ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $screen_shot = sprintf(
</span><span class="cx" style="display: block; padding: 0 10px"> '<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">- esc_url( Template::get_asset_url( $plugin, $image ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ esc_url( $image['src'] )
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $descriptions && ! empty( $descriptions[ (int) $image['resolution'] ] ) ) {
- $caption = $descriptions[ (int) $image['resolution'] ];
- $caption = Plugin_I18n::instance()->translate( 'screenshot-' . $image['resolution'], $caption, [ 'post_id' => $plugin->ID ] );
-
- $screen_shot .= '<figcaption>' . $caption . '</figcaption>';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $image['caption'] ) {
+ $screen_shot .= '<figcaption>' . $image['caption'] . '</figcaption>';
</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"> $output .= '<li><figure>' . $screen_shot . '</figure></li>';
</span></span></pre>
</div>
</div>
</body>
</html>