<!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>[5218] sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory: Plugin Directory: Update developers section.</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/5218">5218</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/5218","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>2017-03-30 21:44:49 +0000 (Thu, 30 Mar 2017)</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: Update developers section.
Replaces lists with full sentences and adds locale details.
See <a href="http://meta.trac.wordpress.org/ticket/1824">#1824</a>.
Fixes <a href="http://meta.trac.wordpress.org/ticket/2629">#2629</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryclassplugini18nphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-i18n.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryshortcodesclassdevelopersphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-developers.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryclassplugini18nphp"></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-i18n.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-i18n.php 2017-03-30 21:42:37 UTC (rev 5217)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-i18n.php 2017-03-30 21:44:49 UTC (rev 5218)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -430,26 +430,40 @@
</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 find_all_translations_for_plugin( $slug, $branch, $min_percent = 0 ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = Plugin_Directory::get_plugin_post( $slug );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return wp_filter_object_list( $this->get_locales( $post, $branch, $min_percent ), null, null, 'wp_locale' );
+ }
+
+ /**
+ * Returns a list of locale objects for a given plugin slug and branch.
+ *
+ * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
+ * @param string $branch Optional. Branch - 'stable-readme' for example. Default: 'stable'.
+ * @param int $min_percent Optional. Only return locales where percent_translated is >= this value.
+ * Default: 95.
+ * @return array
+ */
+ public function get_locales( $post = null, $branch = 'stable', $min_percent = 95 ) {
+ $post = get_post( $post );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // This naively hits the API. It could probably be re-written to query the DB instead.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $api_url = esc_url_raw( 'https://translate.wordpress.org/api/projects/wp-plugins/' . $slug . '/' . $branch, array( 'https' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $api_url = esc_url_raw( 'https://translate.wordpress.org/api/projects/wp-plugins/' . $post->post_name . '/' . $branch, array( 'https' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $out = array();
- $http = new \WP_Http();
- $result = $http->request( $api_url );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $locales = array();
+ $http = new \WP_Http();
+ $result = $http->request( $api_url );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! is_wp_error( $result ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $data = json_decode( $result['body'] );
</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 ( $data && isset( $data->translation_sets ) ) {
- foreach ( $data->translation_sets as $translation ) {
- if ( $translation->percent_translated >= $min_percent ) {
- $out[] = $translation->wp_locale;
- }
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! empty( $data->translation_sets ) ) {
+ $locales = array_filter( $data->translation_sets, function( $locale ) use ( $min_percent ) {
+ return $locale->percent_translated >= $min_percent;
+ } );
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $out;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $locales;
</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_htmlwpcontentpluginsplugindirectoryshortcodesclassdevelopersphp"></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-developers.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-developers.php 2017-03-30 21:42:37 UTC (rev 5217)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-developers.php 2017-03-30 21:44:49 UTC (rev 5218)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,6 +1,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> namespace WordPressdotorg\Plugin_Directory\Shortcodes;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-use WordPressdotorg\Plugin_Directory\Template;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+use WordPressdotorg\Plugin_Directory\Plugin_I18n;
</ins><span class="cx" style="display: block; padding: 0 10px"> use WordPressdotorg\Plugin_Directory\Tools;
</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">@@ -15,7 +15,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> static function display() {
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $output = '<p>' . sprintf( __( '%s is open source software. The following people have contributed to this plugin.', 'wporg-plugins' ), get_the_title( $post ) ) . '</p>';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $slug = $post->post_name;
+ $title = get_the_title( $post );
+ $output = '<p>' . sprintf( __( '%s is open source software. The following people have contributed to this plugin.', 'wporg-plugins' ), $title ) . '</p>';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> ob_start();
</span><span class="cx" style="display: block; padding: 0 10px"> the_widget( 'WordPressdotorg\Plugin_Directory\Widgets\Contributors', array(), array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -27,30 +29,50 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $output .= ob_get_clean();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $locales = Plugin_I18n::instance()->get_locales();
+ $output .= '<p>';
+
+ if ( ! empty( $locales ) ) {
+ $locales_list = implode( ', ', array_map( function( $locale ) use ( $slug ) {
+ return sprintf( '<a href="%1$s">%2$s</a>', esc_url( "{$locale->locale}.wordpress.org/plugins/{$slug}/" ), $locale->name );
+ }, $locales ) );
+ /* Translators: 1: Plugin name; 2: Number of locales; 3: List of locales; */
+ $output .= sprintf( '%1$s has been translated into these %2$d locales: %3$s.', $title, count( $locales ), $locales_list ) . ' ';
+ $output .= sprintf(
+ /* Translators: URL to translator view; */
+ __( 'Thank you to <a href="%s">the translators</a> for their contributions.', 'wporg-plugins' ),
+ esc_url( "https://translate.wordpress.org/projects/wp-plugins/{$slug}/contributors" )
+ );
+ $output .= '<br />';
+ }
+
+ /* Translators: 1: GlotPress URL; 2: Plugin name; */
+ $output .= sprintf( __( '<a href="%1$s">Translate %2$s into your language.</a>', 'wporg-plugins' ), esc_url( 'https://translate.wordpress.org/projects/wp-plugins/' . $slug ), $title );
+ $output .= '</p>';
+
+ $output .= '<h3>' . __( 'Interested in development?', 'wporg-plugins' ) . '</h3>';
+ /* Translators: 1: Trac URL; 2: Development log URL; 3: RSS URL; */
+ $format = __( '<a href="%1$s">Browse the code</a> or subscribe to the <a href="%2$s">development log</a> by <a href="%3$s">RSS</a>.' );
+ $email_url = '';
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( is_user_logged_in() ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /* Translators: 1: Trac URL; 2: Development log URL; 3: RSS URL; 4: Email subscription URL; */
+ $format = __( '<a href="%1$s">Browse the code</a> or subscribe to the <a href="%2$s">development log</a> by <a href="%4$s">email</a> or <a href="%3$s">RSS</a>.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $subscribed = Tools::subscribed_to_plugin_commits( $post, get_current_user_id() );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- $subscribe_change_url = esc_url( add_query_arg( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $email_url = esc_url( add_query_arg( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> '_wpnonce' => wp_create_nonce( 'wp_rest' ),
</span><span class="cx" style="display: block; padding: 0 10px"> ( $subscribed ? 'unsubscribe' : 'subscribe' ) => '1',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ), home_url( 'wp-json/plugins/v1/plugin/' . $post->post_name . '/commit-subscription' ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ), home_url( "wp-json/plugins/v1/plugin/{$slug}/commit-subscription" ) ) );
</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">- return $output .
- '<h3>' . __( 'Browse the code', 'wporg-plugins' ) . '</h3>' .
- '<ul>' .
- '<li>' .
- '<a href="' . esc_url( "https://plugins.trac.wordpress.org/log/{$post->post_name}/" ) . '" rel="nofollow">' . __( 'Development Log', 'wporg-plugins' ) . '</a>' . "\n" .
- '<a href="' . esc_url( "https://plugins.trac.wordpress.org/log/{$post->post_name}/?limit=100&mode=stop_on_copy&format=rss" ) . '" rel="nofollow"><img src="https://s.w.org/style/images/feedicon.png" /></a>' .
- '</li>' .
- '<li><a href="' . esc_url( "https://plugins.svn.wordpress.org/{$post->post_name}/" ) . '" rel="nofollow">' . __( 'Subversion Repository', 'wporg-plugins' ) . '</a></li>' .
- '<li><a href="' . esc_url( "https://plugins.trac.wordpress.org/browser/{$post->post_name}/" ) . '" rel="nofollow">' . __( 'Browse in Trac', 'wporg-plugins' ) . '</a></li>' .
- '<li><a href="' . esc_url( "https://translate.wordpress.org/projects/wp-plugins/{$post->post_name}/" ) . '" rel="nofollow">' . __( 'Translation Contributors', 'wporg-plugins' ) . '</a></li>' .
- ( !is_user_logged_in() ? '' : (
- $subscribed ?
- "<li><a href='$subscribe_change_url'>" . __( 'Unsubscribe from plugin commits', 'wporg-plugins' ) . '</a></li>' :
- "<li><a href='$subscribe_change_url'>" . __( 'Subscribe to plugin commits via email', 'wporg-plugins' ) . '</a></li>'
- ) ) .
- '</ul>';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $output .= '<p>' . sprintf(
+ $format,
+ esc_url( "https://plugins.trac.wordpress.org/browser/{$slug}/" ),
+ esc_url( "https://plugins.trac.wordpress.org/log/{$slug}/" ),
+ esc_url( "https://plugins.trac.wordpress.org/log/{$slug}/?limit=100&mode=stop_on_copy&format=rss" ),
+ $email_url
+ ) . '</p>';
+
+ return $output;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>
</body>
</html>