<!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>[3511] sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory: Plugin Directory: Documentation and formatting updates.</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/3511">3511</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/3511","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-06-20 17:34:18 +0000 (Mon, 20 Jun 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: Documentation and formatting updates.
See <a href="http://meta.trac.wordpress.org/ticket/1584">#1584</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryclasscapabilitiesphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-capabilities.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryclassi18nphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-i18n.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryclassmarkdownphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-markdown.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_htmlwpcontentpluginsplugindirectoryclassplugini18nphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-i18n.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_htmlwpcontentpluginsplugindirectoryclasstoolsphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-tools.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryclasscapabilitiesphp"></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-capabilities.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-capabilities.php 2016-06-20 16:37:50 UTC (rev 3510)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-capabilities.php 2016-06-20 17:34:18 UTC (rev 3511)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,6 +1,7 @@
</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;
</span><span class="cx" style="display: block; padding: 0 10px"> use WordPressdotorg\Plugin_Directory\Tools;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Manages the capabilities for the WordPress.org plugins directory.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11,6 +12,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Filters a user's capabilities depending on specific context and/or privilege.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @static
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param array $required_caps Returns the user's actual capabilities.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $cap Capability name.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param int $user_id The user ID.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -71,40 +74,45 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return $required_caps;
</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">+ /**
+ * Sets up custom roles and makes them available.
+ *
+ * @static
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> public static function add_roles() {
</span><span class="cx" style="display: block; padding: 0 10px"> $committer = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'read' => true,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'read' => true,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'plugin_dashboard_access' => true,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'plugin_edit_own' => true,
- 'plugin_set_category' => true,
- 'plugin_add_committer' => true,
- 'plugin_edit_others' => true,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'plugin_edit_own' => true,
+ 'plugin_set_category' => true,
+ 'plugin_add_committer' => true,
+ 'plugin_edit_others' => true,
</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"> $reviewer = array_merge( $committer, array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'moderate_comments' => true,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'moderate_comments' => true,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'plugin_edit_pending' => true,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'plugin_review' => true,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'plugin_review' => true,
</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"> $admin = array_merge( $reviewer, array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'plugin_approve' => true,
- 'plugin_reject' => true,
- 'plugin_disable' => true,
- 'plugin_close' => true,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'plugin_approve' => true,
+ 'plugin_reject' => true,
+ 'plugin_disable' => true,
+ 'plugin_close' => true,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'plugin_set_section' => true, // Special categories.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'manage_categories' => true, // Let them assign these special categories.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'manage_categories' => true, // Let them assign these special categories.
</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"> // Remove the roles first, incase we've changed the permission set.
</span><span class="cx" style="display: block; padding: 0 10px"> remove_role( 'plugin_committer' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_role( 'plugin_reviewer' );
- remove_role( 'plugin_admin' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_role( 'plugin_reviewer' );
+ remove_role( 'plugin_admin' );
</ins><span class="cx" style="display: block; padding: 0 10px"> add_role( 'plugin_committer', 'Plugin Committer', $committer );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_role( 'plugin_reviewer', 'Plugin Reviewer', $reviewer );
- add_role( 'plugin_admin', 'Plugin Admin', $admin );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_role( 'plugin_reviewer', 'Plugin Reviewer', $reviewer );
+ add_role( 'plugin_admin', 'Plugin Admin', $admin );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach( array( 'contributor', 'author', 'editor', 'administrator' ) as $role ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( array( 'contributor', 'author', 'editor', 'administrator' ) as $role ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $wp_role = get_role( $role );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $wp_role ) {
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryclassi18nphp"></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-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-i18n.php 2016-06-20 16:37:50 UTC (rev 3510)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-i18n.php 2016-06-20 17:34:18 UTC (rev 3511)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6,7 +6,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @package WordPressdotorg\Plugin_Directory
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-class i18n {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+class I18n {
</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"> * Translate a Term Name.
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryclassmarkdownphp"></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-markdown.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-markdown.php 2016-06-20 16:37:50 UTC (rev 3510)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-markdown.php 2016-06-20 17:34:18 UTC (rev 3511)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -14,9 +14,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Markdown extends \Michelf\MarkdownExtra {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @param string $text
+ * @return string
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> public function transform( $text ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $text = $this->code_trick( trim( $text ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Convert any `= Section =` headers into a real header
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Convert any `= Section =` headers into a real header.
</ins><span class="cx" style="display: block; padding: 0 10px"> $text = preg_replace( '/^[\s]*=[\s]+(.+?)[\s]+=/m', "\n" . '<h4>$1</h4>' . "\n", $text );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $text = parent::transform( trim( $text ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -24,18 +29,33 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return trim( $text );
</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">+ /**
+ * @access protected
+ *
+ * @param string $text
+ * @return string
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> protected function code_trick( $text ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // when doing markdown, first take any user formatted code blocks and turn them into backticks so that
- // markdown will preserve things like underscores in code blocks
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /*
+ * When doing markdown, first take any user formatted code blocks and turn them into backticks so that
+ * markdown will preserve things like underscores in code blocks.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> $text = preg_replace_callback( "!(<pre><code>|<code>)(.*?)(</code></pre>|</code>)!s", array( $this, 'code_trick_decodeit_cb' ), $text );
</span><span class="cx" style="display: block; padding: 0 10px"> $text = str_replace( array( "\r\n", "\r" ), "\n", $text );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Markdown can do inline code, we convert bbPress style block level code to Markdown style
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Markdown can do inline code, we convert bbPress style block level code to Markdown style.
</ins><span class="cx" style="display: block; padding: 0 10px"> $text = preg_replace_callback( "!(^|\n)([ \t]*?)`(.*?)`!s", array( $this, 'code_trick_indent_cb' ), $text );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return $text;
</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">+ /**
+ * @access protected
+ *
+ * @param array $matches
+ * @return string
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> protected function code_trick_indent_cb( $matches ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $text = $matches[3];
</span><span class="cx" style="display: block; padding: 0 10px"> $text = preg_replace( '|^|m', $matches[2] . ' ', $text );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -43,14 +63,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return $matches[1] . $text;
</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">+ /**
+ * @access protected
+ *
+ * @param array $matches
+ * @return string
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> protected function code_trick_decodeit_cb( $matches ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $text = $matches[2];
</del><span class="cx" style="display: block; padding: 0 10px"> $trans_table = array_flip( get_html_translation_table( HTML_ENTITIES ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $text = strtr( $text, $trans_table );
- $text = str_replace( '<br />', '', $text );
- $text = str_replace( '&', '&', $text );
- $text = str_replace( ''', "'", $text );
</del><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $text = $matches[2];
+ $text = strtr( $text, $trans_table );
+ $text = str_replace( '<br />', '', $text );
+ $text = str_replace( '&', '&', $text );
+ $text = str_replace( ''', "'", $text );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( '<pre><code>' == $matches[1] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $text = "\n$text\n";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<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-06-20 16:37:50 UTC (rev 3510)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php 2016-06-20 17:34:18 UTC (rev 3511)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11,12 +11,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> class Plugin_Directory {
</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">- * Local cache for translated content injected into meta
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Local cache for translated content injected into meta.
+ *
+ * @access private
+ *
+ * @var array
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> private $i18n_meta = array();
</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"> * Fetch the instance of the Plugin_Directory class.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
+ * @static
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public static function instance() {
</span><span class="cx" style="display: block; padding: 0 10px"> static $instance = null;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -24,6 +30,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return ! is_null( $instance ) ? $instance : $instance = new Plugin_Directory();
</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">+ /**
+ * Plugin_Directory constructor.
+ *
+ * @access private
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> private function __construct() {
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'init', array( $this, 'init' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'init', array( $this, 'register_shortcodes' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -43,20 +54,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'embed_oembed_discover', '__return_false' );
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'oembed_providers', array( $this, 'oembed_whitelist' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Shim in postmeta support for data which doesn't yet live in postmeta
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Shim in postmeta support for data which doesn't yet live in postmeta.
</ins><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'get_post_metadata', array( $this, 'filter_shim_postmeta' ), 10, 3 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'map_meta_cap', array( __NAMESPACE__ . '\Capabilities', 'map_meta_cap' ), 10, 4 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Load the API routes
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Load the API routes.
</ins><span class="cx" style="display: block; padding: 0 10px"> add_action( 'rest_api_init', array( __NAMESPACE__ . '\API\Base', 'load_routes' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Load all Admin-specific items.
- // Cannot be included on `admin_init` to allow access to menu hooks
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /*
+ * Load all Admin-specific items.
+ * Cannot be included on `admin_init` to allow access to menu hooks.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( defined( 'WP_ADMIN' ) && WP_ADMIN ) {
</span><span class="cx" style="display: block; padding: 0 10px"> Customizations::instance();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( 'wp_insert_post_data', array( __NAMESPACE__ . '\Admin\Status_Transitions', 'can_change_post_status' ), 10, 2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( 'wp_insert_post_data', array( __NAMESPACE__ . '\Admin\Status_Transitions', 'can_change_post_status' ), 10, 2 );
</ins><span class="cx" style="display: block; padding: 0 10px"> add_action( 'transition_post_status', array( __NAMESPACE__ . '\Admin\Status_Transitions', 'instance' ) );
</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">@@ -73,7 +86,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_cache_add_global_groups( 'wporg-plugins' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> register_post_type( 'plugin', array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'labels' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'labels' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'name' => __( 'Plugins', 'wporg-plugins' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'singular_name' => __( 'Plugin', 'wporg-plugins' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'menu_name' => __( 'My Plugins', 'wporg-plugins' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -104,7 +117,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'read_private_posts' => 'do_not_allow',
</span><span class="cx" style="display: block; padding: 0 10px"> 'delete_posts' => 'do_not_allow',
</span><span class="cx" style="display: block; padding: 0 10px"> 'create_posts' => 'do_not_allow',
</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"> ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'plugin_section', 'plugin', array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -147,7 +160,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'meta_box_cb' => array( __NAMESPACE__ . '\Admin\Metabox\Plugin_Categories', 'display' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'capabilities' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'assign_terms' => 'plugin_set_category',
</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"> ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'plugin_built_for', 'plugin', array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -155,7 +168,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'query_var' => 'plugin_built_for',
</span><span class="cx" style="display: block; padding: 0 10px"> 'rewrite' => false,
</span><span class="cx" style="display: block; padding: 0 10px"> 'labels' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'name' => __( 'Built For', 'wporg-plugins' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'name' => __( 'Built For', 'wporg-plugins' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'public' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> 'show_ui' => true,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -163,7 +176,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'meta_box_cb' => false, // array( __NAMESPACE__ . '\Admin\Metabox\Plugin_Categories', 'display' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'capabilities' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'assign_terms' => 'plugin_set_category',
</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"> ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'plugin_business_model', 'plugin', array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -171,7 +184,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'query_var' => 'plugin_business_model',
</span><span class="cx" style="display: block; padding: 0 10px"> 'rewrite' => false,
</span><span class="cx" style="display: block; padding: 0 10px"> 'labels' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'name' => __( 'Business Model', 'wporg-plugins' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'name' => __( 'Business Model', 'wporg-plugins' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'public' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> 'show_ui' => true,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -179,7 +192,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'meta_box_cb' => false, // array( __NAMESPACE__ . '\Admin\Metabox\Plugin_Categories', 'display' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'capabilities' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'assign_terms' => 'plugin_set_category',
</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"> ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> register_post_status( 'pending', array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -219,23 +232,24 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // /browse/ should be the popular archive view.
</span><span class="cx" style="display: block; padding: 0 10px"> add_rewrite_rule( '^browse$', 'index.php?browse=popular', 'top' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Create an archive for a users favorites too.
</span><span class="cx" style="display: block; padding: 0 10px"> add_rewrite_rule( '^browse/favorites/([^/]+)$', 'index.php?browse=favorites&favorites_user=$matches[1]', 'top' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Handle the old plugin tabs URLs
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Handle the old plugin tabs URLs.
</ins><span class="cx" style="display: block; padding: 0 10px"> add_rewrite_rule( '^([^/]+)/(installation|faq|screenshots|changelog|stats|developers|other_notes)$', 'index.php?redirect_plugin_tab=$matches[1]/#$matches[2]', 'top' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // If changing capabilities around, uncomment this.
</span><span class="cx" style="display: block; padding: 0 10px"> //Capabilities::add_roles();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // When this plugin is used in the context of a Rosetta site, handle it gracefully
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // When this plugin is used in the context of a Rosetta site, handle it gracefully.
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( 'wordpress.org' != $_SERVER['HTTP_HOST'] && defined( 'WPORG_PLUGIN_DIRECTORY_BLOGID' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'option_home', array( $this, 'rosetta_network_localize_url' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'option_siteurl', array( $this, 'rosetta_network_localize_url' ) );
</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"> if ( 'en_US' != get_locale() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'get_term', array( __NAMESPACE__ . '\i18n', 'translate_term' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'get_term', array( __NAMESPACE__ . '\I18n', 'translate_term' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'the_content', array( $this, 'translate_post_content' ), 1, 2 );
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'the_title', array( $this, 'translate_post_title' ), 1, 2 );
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'get_the_excerpt', array( $this, 'translate_post_excerpt' ), 1, 2 );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -249,7 +263,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // When Jetpack syncs, we want to add filters to inject additional metadata for Jetpack, so it syncs for ElasticSearch indexing.
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'shutdown', array( $this, 'append_meta_for_jetpack' ), 8 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><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">@@ -262,9 +275,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> add_shortcode( 'wporg-plugins-reviews', array( __NAMESPACE__ . '\Shortcodes\Reviews', 'display' ) );
</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">+ /**
+ * Register the Widgets used plugin detail pages.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> public function register_widgets() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- register_widget( __NAMESPACE__ . '\Widgets\Donate' );
- register_widget( __NAMESPACE__ . '\Widgets\Meta' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ register_widget( __NAMESPACE__ . '\Widgets\Donate' );
+ register_widget( __NAMESPACE__ . '\Widgets\Meta' );
</ins><span class="cx" style="display: block; padding: 0 10px"> register_widget( __NAMESPACE__ . '\Widgets\Ratings' );
</span><span class="cx" style="display: block; padding: 0 10px"> register_widget( __NAMESPACE__ . '\Widgets\Support' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -390,6 +406,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'plugin_built_for' == $term->taxonomy ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Term slug = Post Slug = /%postname%/
</span><span class="cx" style="display: block; padding: 0 10px"> return trailingslashit( home_url( $term->slug ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -428,12 +445,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_query->query_vars['browse'] = 'featured';
</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">- switch ( $wp_query->query_vars['browse'] ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ switch ( $wp_query->get( 'browse' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> case 'favorites':
</span><span class="cx" style="display: block; padding: 0 10px"> $favorites_user = wp_get_current_user();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( !empty( $wp_query->query_vars['favorites_user'] ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! empty( $wp_query->query_vars['favorites_user'] ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $favorites_user = $wp_query->query_vars['favorites_user'];
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } elseif ( !empty( $_GET['favorites_user'] ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } elseif ( ! empty( $_GET['favorites_user'] ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $favorites_user = $_GET['favorites_user'];
</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">@@ -449,28 +466,26 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $favorites_user || ! $wp_query->query_vars['post_name__in'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_query->query_vars['p'] = -1;
</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><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 'new':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $wp_query->query_vars['orderby'] = 'post_modified';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $wp_query->query_vars['orderby'] = 'post_modified';
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( isset( $wp_query->query['browse'] ) ) {
- if ( 'beta' != $wp_query->query['browse'] && 'featured' != $wp_query->query['browse'] ) {
- unset( $wp_query->query_vars['browse'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( isset( $wp_query->query['browse'] ) && 'beta' != $wp_query->query['browse'] && 'featured' != $wp_query->query['browse'] ) {
+ unset( $wp_query->query_vars['browse'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'the_posts', function( $posts, $wp_query ) {
- // Fix the queried object for the archive view
- if ( ! $wp_query->queried_object && isset( $wp_query->query['browse'] ) ) {
- $wp_query->query_vars['browse'] = $wp_query->query['browse'];
- $wp_query->queried_object = get_term_by( 'slug', $wp_query->query['browse'], 'plugin_section' );
- }
- return $posts;
- }, 10, 2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'the_posts', function( $posts, $wp_query ) {
</ins><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">+ // Fix the queried object for the archive view.
+ if ( ! $wp_query->queried_object && isset( $wp_query->query['browse'] ) ) {
+ $wp_query->query_vars['browse'] = $wp_query->query['browse'];
+ $wp_query->queried_object = get_term_by( 'slug', $wp_query->query['browse'], 'plugin_section' );
+ }
+
+ return $posts;
+ }, 10, 2 );
</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 ( $wp_query->is_archive() && empty( $wp_query->query_vars['orderby'] ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -484,9 +499,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $content Post content.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $section Optional. Which readme section to translate.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int $post_id Optional. Post ID. Default: 0.
</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 function translate_post_content( $content, $section = null, $post_id = null ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function translate_post_content( $content, $section = null, $post_id = 0 ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( is_null( $section ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return $content;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -513,8 +529,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Returns the requested page's excerpt, translated.
</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 $excerpt
- * @param \WP_Post $post
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $excerpt
+ * @param int|\WP_Post $post
</ins><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 translate_post_excerpt( $excerpt, $post ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -522,58 +538,69 @@
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Shutdown action that will add a filter to inject additional postmeta containing translated content if Jetpack is syncing.
- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Shutdown action that will add a filter to inject additional postmeta containing translated content if Jetpack
+ * is syncing.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function append_meta_for_jetpack() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Guess if a Jetpack sync is scheduled to run. It runs during shutdown at a lower priority than this action, so we can get in first.
- // Fetching the extra meta to inject is expensive, so we only want to do this if a sync is likely.
- if ( class_exists( 'Jetpack' ) && !empty(\Jetpack::$instance->sync->sync) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /*
+ * Guess if a Jetpack sync is scheduled to run. It runs during shutdown at a lower priority than this action,
+ * so we can get in first.Fetching the extra meta to inject is expensive, so we only want to do this if a sync
+ * is likely.
+ */
+ if ( class_exists( 'Jetpack' ) && ! empty( \Jetpack::$instance->sync->sync ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'wporg_plugins_custom_meta_fields', array( $this, 'filter_post_meta_i18n' ), 10, 2 );
</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><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="cx" style="display: block; padding: 0 10px"> * Filter for wporg_plugins_custom_meta_fields to inject translated content for ES.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @global string $locale Current locale.
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param array $meta
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param int $post_id
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int $post_id
</ins><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 filter_post_meta_i18n( $meta, $post_id ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Prevent recursion and repeat runs
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Prevent recursion and repeat runs.
</ins><span class="cx" style="display: block; padding: 0 10px"> remove_filter( 'wporg_plugins_custom_meta_fields', array( $this, 'filter_post_meta_i18n' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $post_id <= 200 ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $locales_to_sync = array( 'fr_FR', 'es_ES' ); // This should probably be a list of available translations for the plugin readme.
</del><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // This should probably be a list of available translations for the plugin readme.
+ $locales_to_sync = array(
+ 'fr_FR',
+ 'es_ES',
+ );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> global $locale;
</span><span class="cx" style="display: block; padding: 0 10px"> $_locale = $locale;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $locales_to_sync as $locale ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->i18n_meta[$post_id]['title_'.$locale] = $this->translate_post_title( get_the_title( $post_id ), $post_id );
- $this->i18n_meta[$post_id]['excerpt_'.$locale] = $this->translate_post_excerpt( get_the_excerpt( $post_id ), $post_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->i18n_meta[ $post_id ][ 'title_' . $locale ] = $this->translate_post_title( get_the_title( $post_id ), $post_id );
+ $this->i18n_meta[ $post_id ][ 'excerpt_' . $locale ] = $this->translate_post_excerpt( get_the_excerpt( $post_id ), $post_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Split up the content to translate it in sections
- $content = '';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Split up the content to translate it in sections.
+ $content = '';
</ins><span class="cx" style="display: block; padding: 0 10px"> $sections = $this->split_post_content_into_pages( get_the_content( $post_id ) );
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $sections as $section => $section_content ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $content .= $this->translate_post_content( $section_content, $section, $post_id );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->i18n_meta[$post_id]['content_'.$locale] = $content;
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->i18n_meta[ $post_id ][ 'content_' . $locale ] = $content;
</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"> $locale = $_locale;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $meta = array_merge( $meta, array_keys( $this->i18n_meta[$post_id] ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $meta = array_merge( $meta, array_keys( $this->i18n_meta[ $post_id ] ) );
</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">- add_filter( 'wporg_plugins_custom_meta_fields', array( $this, 'filter_post_meta_i18n'), 10, 2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'wporg_plugins_custom_meta_fields', array( $this, 'filter_post_meta_i18n' ), 10, 2 );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> return $meta;
</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">-
</del><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Filter for rest_api_allowed_post_types to enable JP syncing of the CPT
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -582,15 +609,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function filter_allowed_post_types( $allowed_post_types ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $allowed_post_types[] = 'plugin';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return $allowed_post_types;
</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><span class="cx" style="display: block; padding: 0 10px"> * Filters the available public query vars to add our custom parameters.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
+ * @param array $vars Public query vars.
+ * @return array
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function filter_query_vars( $vars ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $vars[] = 'favorites_user';
</span><span class="cx" style="display: block; padding: 0 10px"> $vars[] = 'redirect_plugin_tab';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return $vars;
</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">@@ -601,8 +633,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return mixed
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function filter_jetpack_options( $new_value ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( is_array( $new_value ) && array_key_exists( 'public', $new_value ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( is_array( $new_value ) && array_key_exists( 'public', $new_value ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $new_value['public'] = 1;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return $new_value;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -620,7 +653,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Handles a redirect for the old /$plugin/$tab_name/ URLs and search.php
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function redirect_old_plugin_urls() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Handle a redirect for /$plugin/$tab_name/ to /$plugin/#$tab_name
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Handle a redirect for /$plugin/$tab_name/ to /$plugin/#$tab_name.
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( get_query_var( 'redirect_plugin_tab' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_safe_redirect( site_url( get_query_var( 'redirect_plugin_tab' ) ) );
</span><span class="cx" style="display: block; padding: 0 10px"> die();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -629,7 +663,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // We've disabled WordPress's default 404 redirects, so we'll handle them ourselves.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_404() ) {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // [1] => plugins [2] => example-plugin-name [2..] => random()
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // [1] => plugins [2] => example-plugin-name [2..] => random().
</ins><span class="cx" style="display: block; padding: 0 10px"> $path = explode( '/', $_SERVER['REQUEST_URI'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'tags' === $path[2] ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -645,18 +679,21 @@
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // The about page is now over at /developers/
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // The about page is now over at /developers/.
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( 'about' === $path[2] ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_safe_redirect( home_url('/developers/' . ( ( isset( $path[3] ) && 'add' == $path[3] ) ? 'add/' : '' ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_safe_redirect( home_url( '/developers/' . ( ( isset( $path[3] ) && 'add' == $path[3] ) ? 'add/' : '' ) ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> die();
</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">- // Otherwise, handle a plugin redirect
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Otherwise, handle a plugin redirect.
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $plugin = self::get_plugin_post( $path[2] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $is_disabled = in_array( $plugin->post_status, array( 'disabled', 'closed' ), true );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $is_disabled && current_user_can( 'edit_post', $plugin ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_safe_redirect( add_query_arg( array( 'post' => $plugin->ID, 'action' => 'edit' ), admin_url( 'post.php' ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_safe_redirect( add_query_arg( array(
+ 'post' => $plugin->ID,
+ 'action' => 'edit',
+ ), admin_url( 'post.php' ) ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> die();
</span><span class="cx" style="display: block; padding: 0 10px"> } else if ( ! $is_disabled ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_safe_redirect( get_permalink( $plugin->ID ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -671,7 +708,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> die();
</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">- // new-style Search links
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // new-style Search links.
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( get_query_var( 's' ) && isset( $_GET['s'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_safe_redirect( site_url( '/search/' . urlencode( get_query_var( 's' ) ) . '/' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> die();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -705,6 +742,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return false;
</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">@@ -721,31 +759,34 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function filter_shim_postmeta( $value, $object_id, $meta_key ) {
</span><span class="cx" style="display: block; padding: 0 10px"> switch ( $meta_key ) {
</span><span class="cx" style="display: block; padding: 0 10px"> case 'downloads':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = get_post( $object_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = get_post( $object_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $count = Template::get_downloads_count( $post );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $value = array( $count );
+ break;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return array( $count );
- break;
</del><span class="cx" style="display: block; padding: 0 10px"> case 'rating':
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $object_id );
</span><span class="cx" style="display: block; padding: 0 10px"> // The WordPress.org global ratings functions
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! function_exists( 'wporg_get_rating_avg' ) ) {
</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">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $rating = wporg_get_rating_avg( 'plugin', $post->post_name );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $value = array( $rating );
+ break;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return array( $rating );
- break;
</del><span class="cx" style="display: block; padding: 0 10px"> case 'ratings':
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $object_id );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! function_exists( 'wporg_get_rating_counts' ) ) {
</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">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $ratings = wporg_get_rating_counts( 'plugin', $post->post_name );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $value = array( $ratings );
+ break;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return array( $ratings );
- break;
</del><span class="cx" style="display: block; padding: 0 10px"> case false:
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> // In the event $meta_key is false, the caller wants all meta fields, so we'll append our custom ones here too.
</span><span class="cx" style="display: block; padding: 0 10px"> remove_filter( 'get_post_metadata', array( $this, 'filter_shim_postmeta' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -759,20 +800,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $custom_meta_fields = apply_filters( 'wporg_plugins_custom_meta_fields', $custom_meta_fields, $object_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $custom_meta_fields as $key ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // When WordPress calls `get_post_meta( $post_id, false )` it expects an array of maybe_serialize()'d data
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // When WordPress calls `get_post_meta( $post_id, false )` it expects an array of maybe_serialize()'d data.
</ins><span class="cx" style="display: block; padding: 0 10px"> $shimed_data = $this->filter_shim_postmeta( false, $object_id, $key );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $shimed_data ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $value[ $key ][0] = (string) maybe_serialize( $shimed_data[0] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ break;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- break;
</del><span class="cx" style="display: block; padding: 0 10px"> default:
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $this->i18n_meta[ $object_id ][ $meta_key ] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return array( $this->i18n_meta[ $object_id ][ $meta_key ] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</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">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return $value;
</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">@@ -822,16 +865,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Retrieve the WP_Post object representing a given plugin.
</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 $plugin_slug string|\WP_Post The slug of the plugin to retrieve.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @static
+ * @global \WP_Post $post WordPress post object.
+ *
+ * @param string|\WP_Post $plugin_slug The slug of the plugin to retrieve.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return \WP_Post|bool
</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 public function get_plugin_post( $plugin_slug ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function get_plugin_post( $plugin_slug ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> global $post;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $plugin_slug instanceof \WP_Post ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return $plugin_slug;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Use the global $post object when it matches to avoid hitting the database.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( !empty( $post ) && 'plugin' == $post->post_type && $plugin_slug == $post->post_name ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! empty( $post ) && 'plugin' == $post->post_type && $plugin_slug == $post->post_name ) {
</ins><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><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -840,12 +888,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( false !== ( $post_id = wp_cache_get( $plugin_slug, 'plugin-slugs' ) ) && ( $post = get_post( $post_id ) ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // We have a $post.
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</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 class="cx" style="display: block; padding: 0 10px"> 'name' => $plugin_slug,
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => array( 'publish', 'pending', 'disabled', 'closed', 'draft', 'approved' ),
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $posts ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $post = false;
</span><span class="cx" style="display: block; padding: 0 10px"> wp_cache_add( 0, $plugin_slug, 'plugin-slugs' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -860,6 +910,8 @@
</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"> * Create a new post entry for a given plugin slug.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
+ * @static
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $args {
</span><span class="cx" style="display: block; padding: 0 10px"> * An array of elements that make up a post to insert.
</span></span></pre></div>
<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 2016-06-20 16:37:50 UTC (rev 3510)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-i18n.php 2016-06-20 17:34:18 UTC (rev 3511)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -13,28 +13,55 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $i18n_cache_group = 'plugins-i18n';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @var string
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> public $master_project;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @static
+ *
+ * @var bool
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> public static $use_cache = true;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /**
+ * @static
+ *
+ * @var bool
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> public static $set_cache = true;
</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">+ * @access protected
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @var \wpdb WordPress database abstraction object.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected $db;
</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"> * Fetch the instance of the Plugin_I18n class.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
+ * @static
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public static function instance() {
</span><span class="cx" style="display: block; padding: 0 10px"> static $instance = null;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> global $wpdb;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return ! is_null( $instance ) ? $instance : $instance = new Plugin_I18n( $wpdb );
</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">- function __construct( $db, $tracker = null ) {
- if ( !empty( $db ) && is_object( $db ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Plugin_I18n constructor.
+ *
+ * @access private
+ *
+ * @param \wpdb $db WordPress database abstraction object.
+ * @param null $tracker
+ */
+ private function __construct( $db, $tracker = null ) {
+ if ( ! empty( $db ) && is_object( $db ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->db = $db;
</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">@@ -42,41 +69,44 @@
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Generates and returns a standard cache key format, for consistency
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Generates and returns a standard cache key format, for consistency.
</ins><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 $slug Plugin slug
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $slug Plugin slug
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $branch dev|stable
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $suffix Arbitrary cache key suffix, if needed for uniqueness
- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $suffix Optional. Arbitrary cache key suffix, if needed for uniqueness.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return string Cache key
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function cache_key( $slug, $branch, $suffix = null ) {
- // EG keys
- // plugin:press-this:stable-readme:originals
- // plugin:press-this:stable-readme:original:title
- // plugin:press-this:stable-readme:fr:title
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function cache_key( $slug, $branch, $suffix = '' ) {
+
+ /*
+ * EG keys
+ * plugin:press-this:stable-readme:originals
+ * plugin:press-this:stable-readme:original:title
+ * plugin:press-this:stable-readme:fr:title
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> $key = "{$this->master_project}:{$slug}:{$branch}";
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( !empty( $suffix ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! empty( $suffix ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $key .= ":{$suffix}";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return $key;
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Cache getting, with proper global cache group
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Cache getting, with proper global cache group.
</ins><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 $slug Plugin slug
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $slug Plugin slug
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $branch dev|stable
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $suffix Arbitrary cache key suffix, if needed for uniqueness
- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $suffix Optional. Arbitrary cache key suffix, if needed for uniqueness.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return bool|mixed As returned by wp_cache_set()
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function cache_get( $slug, $branch, $suffix = null ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function cache_get( $slug, $branch, $suffix = '' ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! self::$use_cache ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</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"> $key = $this->cache_key( $slug, $branch, $suffix );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return wp_cache_get( $key, $this->i18n_cache_group );
</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">@@ -87,27 +117,27 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $branch dev|stable
</span><span class="cx" style="display: block; padding: 0 10px"> * @param mixed $content Content to be cached.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $suffix Optional. Arbitrary cache key suffix, if needed for uniqueness.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @return bool As returned by wp_cache_set()
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function cache_set( $slug, $branch, $content, $suffix = null ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function cache_set( $slug, $branch, $content, $suffix = '' ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! self::$set_cache ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</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"> $key = $this->cache_key( $slug, $branch, $suffix );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return wp_cache_set( $key, $content, $this->i18n_cache_group );
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Gets a GlotPress branch ID
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets a GlotPress branch ID.
</ins><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 $slug Plugin slug
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $slug Plugin slug
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $branch dev|stable
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return bool|int|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">- function get_gp_branch_id( $slug, $branch ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function get_gp_branch_id( $slug, $branch ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $cache_suffix = "branch_id";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( false !== ( $branch_id = $this->cache_get( $slug, $branch, $cache_suffix ) ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -129,23 +159,24 @@
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Gets GlotPress "originals" based on passed parameters
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets GlotPress "originals" based on passed parameters.
</ins><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 $slug Plugin slug
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $slug Plugin slug
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $branch dev|stable
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $key Unique key
- * @param string $str String to match in GP
- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $key Unique key
+ * @param string $str String to match in GP
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return array|bool|mixed|null
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function get_gp_originals( $slug, $branch, $key, $str ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function get_gp_originals( $slug, $branch, $key, $str ) {
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Try to get a single original with the whole content first (title, etc), if passed, or get them all otherwise.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( !empty( $key ) && !empty( $str ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! empty( $key ) && ! empty( $str ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $originals = $this->search_gp_original( $slug, $branch, $key, $str );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( !empty( $originals ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Do not cache this as originals, search_gp_original() does its own caching.
+ if ( ! empty( $originals ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array( $originals );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Do not cache this as originals, search_gp_original() does its own caching
</del><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"> $cache_suffix = 'originals';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -166,7 +197,9 @@
</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"> if ( empty( $originals ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $originals = array(); // still cache if empty, but as array, never false
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Still cache if empty, but as array, never false.
+ $originals = array();
</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"> $this->cache_set( $slug, $branch, $originals, $cache_suffix );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -175,15 +208,14 @@
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Get GlotPress translation set ID based on passed params
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Get GlotPress translation set ID based on passed params.
</ins><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 $slug Plugin slug
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $slug Plugin slug
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $branch dev|stable
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $locale EG: fr
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @return bool|int|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">- function get_gp_translation_set_id( $slug, $branch, $locale ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function get_gp_translation_set_id( $slug, $branch, $locale ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $cache_suffix = "{$locale}:translation_set_id";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( false !== ( $translation_set_id = $this->cache_get( $slug, $branch, $cache_suffix ) ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -201,10 +233,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $branch_id, $locale ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $translation_set_id ) ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Don't give up yet. Might be given fr_FR, which actually exists as locale=fr in GP.
</span><span class="cx" style="display: block; padding: 0 10px"> $translation_set_id = $this->db->get_var( $this->db->prepare(
</span><span class="cx" style="display: block; padding: 0 10px"> 'SELECT id FROM ' . GLOTPRESS_TABLE_PREFIX . 'translation_sets WHERE project_id = %d AND locale = %s',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $branch_id, preg_replace( '/^([^-]+)(-.+)?$/', '\1', $locale ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $branch_id, preg_replace( '/^([^-]+)(-.+)?$/', '\1', $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"> if ( empty( $translation_set_id ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -217,16 +251,15 @@
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Searches GlotPress "originals" for the passed string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Searches GlotPress "originals" for the passed string.
</ins><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 $slug Plugin slug
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $slug Plugin slug
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $branch dev|stable
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $key Unique key
- * @param string $str String to be searched for
- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $key Unique key
+ * @param string $str String to be searched for
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return bool|mixed|null
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function search_gp_original( $slug, $branch, $key, $str ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function search_gp_original( $slug, $branch, $key, $str ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $cache_suffix = "original:{$key}";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( false !== ( $original = $this->cache_get( $slug, $branch, $cache_suffix ) ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -254,15 +287,15 @@
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Somewhat emulated equivalent of __() for content translation drawn directly from the GlotPress DB
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Somewhat emulated equivalent of __() for content translation drawn directly from the GlotPress DB.
</ins><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 $key Unique key, used for caching
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $key Unique key, used for caching
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $content Content to be translated
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param array $args Misc arguments, such as BBPress topic id (otherwise acquired from global $topic_id)
- *
- * @return mixed
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param array $args Optional. Misc arguments, such as BBPress topic id
+ * (otherwise acquired from global $topic_id).
+ * @return string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function translate( $key, $content, $args = array() ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function translate( $key, $content, $args = array() ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $key ) || empty( $content ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return $content;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -284,9 +317,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_locale = get_locale();
</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">- $server_name = strtolower( $_SERVER['SERVER_NAME'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $server_name = strtolower( $_SERVER['SERVER_NAME'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( 'api.wordpress.org' == $server_name ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Support formats like fr, haz, and en_GB
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Support formats like fr, haz, and en_GB.
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $_REQUEST['locale'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_locale = preg_replace( '/[^a-zA-Z_]/', '', $_REQUEST['locale'] );
</span><span class="cx" style="display: block; padding: 0 10px"> } else if ( ! empty( $_REQUEST['request'] ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -308,8 +342,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return $content;
</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">- $locale = $gp_locale->slug; // The slug is the locale of a translation set.
- $slug = $post->post_name;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // The slug is the locale of a translation set.
+ $locale = $gp_locale->slug;
+ $slug = $post->post_name;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post->stable_tag = get_post_meta( $post->ID, 'stable_tag', true );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -325,7 +360,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $cache_suffix = "{$locale}:{$key}";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Try the cache
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Try the cache.
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( false !== ( $cache = $this->cache_get( $slug, $branch, $cache_suffix ) ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // DEBUG
</span><span class="cx" style="display: block; padding: 0 10px"> // var_dump( array( $slug, $branch, $cache_suffix, $cache ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -367,20 +402,19 @@
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Takes content, searches for $original, and replaces it by $translation
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Takes content, searches for $original, and replaces it by $translation.
</ins><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 $original English string
- * @param string $translation Translation
- * @param string $content Content to be searched
- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $original English string.
+ * @param string $translation Translation.
+ * @param string $content Content to be searched.
</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">- function translate_gp_original( $original, $translation, $content ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function translate_gp_original( $original, $translation, $content ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( false === strpos( $content, '<' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $content = str_replace( $original, $translation, $content );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $original = preg_quote( $original, '/' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $content = preg_replace( "/(<([a-z0-9]*)\b[^>]*>){$original}(<\/\\2>)/m", "\\1{$translation}\\3", $content );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $content = preg_replace( "/(<([a-z0-9]*)\b[^>]*>){$original}(<\/\\2>)/m", "\\1{$translation}\\3", $content );
</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"> return $content;
</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-06-20 16:37:50 UTC (rev 3510)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php 2016-06-20 17:34:18 UTC (rev 3511)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11,13 +11,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Returns a string representing the number of active installs for an item.
</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 bool $full Whether to include "active installs" suffix. Default: true.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @static
+ *
+ * @param bool $full Optional. Whether to include "active installs" suffix. Default: true.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string "1+ million" or "1+ million active installs" depending on $full.
</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 active_installs( $full = true, $post = null ) {
- $post = get_post( $post );
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function active_installs( $full = true, $post = null ) {
+ $post = get_post( $post );
</ins><span class="cx" style="display: block; padding: 0 10px"> $count = get_post_meta( $post->ID, 'active_installs', true );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $count <= 10 ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -27,15 +28,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $text = number_format_i18n( $count ) . '+';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return $full ? sprintf( __( '%s active installs', 'wporg-plugins' ), $text ) : $text;
</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">-
</del><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|int $post Optional.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Returns the number of downloads for a plugin.
+ *
+ * @static
+ * @global \wpdb $wpdb WordPress database abstraction object.
+ *
+ * @param int|\WP_Post|null $post Optional.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return int
</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_downloads_count( $post = null ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function get_downloads_count( $post = null ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( false === ( $count = wp_cache_get( $post->ID, 'plugin_download_count' ) ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -51,9 +57,14 @@
</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">+ * Returns the cumulative number of downloads of all plugins.
+ *
+ * @static
+ * @global \wpdb $wpdb WordPress database abstraction object.
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return int
</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_total_downloads() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function get_total_downloads() {
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( false === ( $count = wp_cache_get( 'plugin_download_count', 'plugin_download_count' ) ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> global $wpdb;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -67,6 +78,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Displays a plugin's rating with the amount of ratings it has received.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @static
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
</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="lines" style="display: block; padding: 0 10px; color: #888">@@ -86,10 +99,14 @@
</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">+ * Returns the available sections for a plugin.
+ *
+ * @static
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
</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( $post = null ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function get_plugin_sections( $post = null ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $plugin = get_post( $post );
</span><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="lines" style="display: block; padding: 0 10px; color: #888">@@ -108,9 +125,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $raw_sections = get_post_meta( $plugin->ID, 'sections', true );
</span><span class="cx" style="display: block; padding: 0 10px"> $raw_sections = array_unique( array_merge( $raw_sections, $default_sections ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $sections = array();
- $title = $url = '';
- $permalink = get_permalink();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $sections = array();
+ $title = $url = '';
+ $permalink = get_permalink();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $raw_sections as $section_slug ) {
</span><span class="cx" style="display: block; padding: 0 10px"> switch ( $section_slug ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -182,11 +199,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Retrieve the Plugin Icon details for a plugin.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @static
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param \WP_Post|string $plugin An instance of a Plugin post, or the plugin slug.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $output Output type. 'html' or 'raw'. Default: 'raw'.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @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">- static function get_plugin_icon( $plugin, $output = 'raw' ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function get_plugin_icon( $plugin, $output = 'raw' ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $plugin = Plugin_Directory::instance()->get_plugin_post( $plugin );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $plugin ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -208,7 +227,7 @@
</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_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="lines" style="display: block; padding: 0 10px; color: #888">@@ -225,7 +244,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Use the average color of the first known banner as the icon background color
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $color = get_post_meta( $plugin->ID, 'assets_banners_color', true ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( strlen( $color ) == 6 && strspn( $color, 'abcdef0123456789' ) == 6 ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( strlen( $color ) === 6 && strspn( $color, 'abcdef0123456789' ) === 6 ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $icon->setColor( '#' . $color );
</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">@@ -235,8 +254,8 @@
</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}";
- $html = "<style type='text/css'>";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $id = "plugin-icon-{$plugin_slug}";
+ $html = "<style type='text/css'>";
</ins><span class="cx" style="display: block; padding: 0 10px"> $html .= "#{$id} { background-image: url('{$icon}'); } .plugin-icon { background-size: 128px 128px; height: 128px; width: 128px; }";
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $icon_2x ) && ! $generated ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $html .= "@media only screen and (-webkit-min-device-pixel-ratio: 1.5) { #{$id} { background-image: url('{$icon_2x}'); } }";
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -256,22 +275,24 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Retrieve the Plugin Icon details for a plugin.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @static
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param \WP_Post|string $plugin An instance of a Plugin post, or the plugin slug.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $output Output type. 'html' or 'raw'. Default: 'raw'.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @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">- static function get_plugin_banner( $plugin, $output = 'raw' ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function get_plugin_banner( $plugin, $output = 'raw' ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $plugin = Plugin_Directory::instance()->get_plugin_post( $plugin );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $plugin ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</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">- $banner = $banner_2x = false;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $banner = $banner_2x = false;
</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"> $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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $rtl_banners = array_filter( $raw_banners, function( $info ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $rtl_banners = array_filter( $raw_banners, function ( $info ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return (bool) stristr( $info['filename'], '-rtl' );
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px"> $raw_banners = array_diff_key( $raw_banners, $rtl_banners );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -309,8 +330,8 @@
</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}";
- $html = "<style type='text/css'>";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $id = "plugin-banner-{$plugin_slug}";
+ $html = "<style type='text/css'>";
</ins><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="cx" style="display: block; padding: 0 10px"> $html .= "@media only screen and (-webkit-min-device-pixel-ratio: 1.5) { #{$id} { background-image: url('{$banner_2x}'); } }";
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -328,16 +349,24 @@
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param $plugin
- * @param $asset
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Generates and returns the URL to a passed asset.
+ *
+ * Assets can be screenshots, icons, banners, etc.
+ *
+ * @static
+ *
+ * @param string $plugin Plugin slug.
+ * @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">- 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( $plugin, $asset ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $asset['location'] ) && 'plugin' == $asset['location'] ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Screenshots in the plugin folder - /plugins/plugin-name/screenshot-1.png
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Screenshots in the plugin folder - /plugins/plugin-name/screenshot-1.png.
</ins><span class="cx" style="display: block; padding: 0 10px"> $format = 'https://s.w.org/plugins/%s/%s?rev=%s';
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Images in the assets folder - /plugin-name/assets/screenshot-1.png
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Images in the assets folder - /plugin-name/assets/screenshot-1.png.
</ins><span class="cx" style="display: block; padding: 0 10px"> $format = 'https://ps.w.org/%s/assets/%s?rev=%s';
</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">@@ -352,7 +381,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * A helper method to create dashicon stars.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type int|array {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @static
+ *
+ * @param int|array $args {
</ins><span class="cx" style="display: block; padding: 0 10px"> * If numeric arg passed, assumed to be 'rating'.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @type int $rating The rating to display.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -361,41 +392,43 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * }
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string The Rating HTML.
</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 dashicons_stars( $args = array() ) {
- $defaults = array(
- 'rating' => 0,
- 'template' => '<span class="%1$s"></span>'
- );
- $r = wp_parse_args( ( is_numeric( $args ) ? array( 'rating' => $args ) : $args ), $defaults );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function dashicons_stars( $args = array() ) {
+ $args = wp_parse_args( ( is_numeric( $args ) ? array( 'rating' => $args ) : $args ), array(
+ 'rating' => 0,
+ 'template' => '<span class="%1$s"></span>',
+ ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $rating = round( $r['rating'] / 0.5 ) * 0.5;
- $template = $r['template'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $rating = round( $args['rating'] / 0.5 ) * 0.5;
+ $template = $args['template'];
</ins><span class="cx" style="display: block; padding: 0 10px"> $title_template = __( '%s out of 5 stars', 'wporg-plugins' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $title = sprintf( $title_template, $rating );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $title = sprintf( $title_template, $rating );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $output = '<div class="wporg-ratings" title="' . esc_attr( $title ) . '" data-title-template="' . esc_attr( $title_template ) . '" data-rating="' . esc_attr( $rating ) . '" style="color:#ffb900;">';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $output = '<div class="wporg-ratings" title="' . esc_attr( $title ) . '" data-title-template="' . esc_attr( $title_template ) . '" data-rating="' . esc_attr( $rating ) . '" style="color:#ffb900;">';
</ins><span class="cx" style="display: block; padding: 0 10px"> $counter = round( $rating * 2 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- for ( $i = 1; $i <= 5; $i++ ) {
- switch ($counter) {
- case 0:
- $output .= sprintf( $template, 'dashicons dashicons-star-empty', $i );
- break;
- case 1:
- $output .= sprintf( $template, 'dashicons dashicons-star-half', $i );
- $counter--;
- break;
- default:
- $output .= sprintf( $template, 'dashicons dashicons-star-filled', $i );
- $counter -= 2;
- break;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ for ( $i = 1; $i <= 5; $i++ ) {
+ switch ( $counter ) {
+ case 0:
+ $output .= sprintf( $template, 'dashicons dashicons-star-empty', $i );
+ break;
+
+ case 1:
+ $output .= sprintf( $template, 'dashicons dashicons-star-half', $i );
+ $counter--;
+ break;
+
+ default:
+ $output .= sprintf( $template, 'dashicons dashicons-star-filled', $i );
+ $counter -= 2;
+ break;
</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 .= '</div>';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return $output;
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Generate a Download link for a given plugin & version.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Generate a download link for a given plugin & version.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param \WP_Post $post The Plugin Post.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $version The version to link to. Optional. Default: latest.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -418,6 +451,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Properly encodes a string to UTF-8.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @static
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $string
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryclasstoolsphp"></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-tools.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-tools.php 2016-06-20 16:37:50 UTC (rev 3510)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-tools.php 2016-06-20 17:34:18 UTC (rev 3511)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11,15 +11,19 @@
</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"> * Retrieve the average color of a specified image.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * This currently relies upon the Jetpack libraries.
</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 $file_location string URL or filepath of image
- * @return string|bool Average color as a hex value, False on failure
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @static
+ *
+ * @param $file_location string URL or filepath of image.
+ * @return string|bool Average color as a hex value, False on failure.
</ins><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_image_average_color( $file_location ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function get_image_average_color( $file_location ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! class_exists( 'Tonesque' ) && function_exists( 'jetpack_require_lib' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> jetpack_require_lib( 'tonesque' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! class_exists( 'Tonesque' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -32,6 +36,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Returns the two latest reviews of a specific plugin.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @static
</ins><span class="cx" style="display: block; padding: 0 10px"> * @global \wpdb $wpdb WordPress database abstraction object.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @todo Populate with review title/content.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -53,6 +58,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ratings.object_slug = %s AND
</span><span class="cx" style="display: block; padding: 0 10px"> posts.post_position = 1
</span><span class="cx" style="display: block; padding: 0 10px"> ORDER BY ratings.review_id DESC LIMIT 2", $plugin_slug ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_cache_set( "{$plugin_slug}_reviews", $reviews, 'wporg-plugins', HOUR_IN_SECONDS );
</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">@@ -62,13 +68,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Retrieve a list of users who have commit to a specific plugin.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @static
+ * @global \wpdb $wpdb WordPress database abstraction object.
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $plugin_slug The plugin slug.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array The list of user_login's which have commit.
</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_committers( $plugin_slug ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( false === ( $committers = wp_cache_get( "{$plugin_slug}_committer", 'wporg-plugins' ) ) ) {
+ global $wpdb;
</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 ( false === ( $committers = wp_cache_get( "{$plugin_slug}_committer", 'wporg-plugins' ) ) ) {
</del><span class="cx" style="display: block; padding: 0 10px"> $committers = $wpdb->get_col( $wpdb->prepare( 'SELECT user FROM `' . PLUGINS_TABLE_PREFIX . 'svn_access' . '` WHERE path = %s', "/{$plugin_slug}" ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_cache_set( "{$plugin_slug}_committer", $committers, 'wporg-plugins' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -80,32 +89,41 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Retrieve a list of plugins a specific user has commit to.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @static
+ * @global \wpdb $wpdb WordPress database abstraction object.
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param int|\WP_User $user The user.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array The list of plugins the user has commit to.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public static function get_users_write_access_plugins( $user ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
</del><span class="cx" style="display: block; padding: 0 10px"> if ( ! $user instanceof \WP_User ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $user = new \WP_User( $user );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $user->exists() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</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"> if ( false === ( $plugins = wp_cache_get( "{$user->user_login}_committer", 'wporg-plugins' ) ) ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $wpdb;
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $plugins = $wpdb->get_col( $wpdb->prepare( 'SELECT path FROM `' . PLUGINS_TABLE_PREFIX . 'svn_access' . '` WHERE user = %s', $user->user_login ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $plugins = array_map( function( $plugin ) { return trim( $plugin, '/' ); }, $plugins );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $plugins = array_map( function ( $plugin ) {
+ return trim( $plugin, '/' );
+ }, $plugins );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_cache_set( "{$user->user_login}_committer", $plugins, 'wporg-plugins' );
</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"> return $plugins;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><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="cx" style="display: block; padding: 0 10px"> * Grant a user RW access to a plugin.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @static
+ * @global \wpdb $wpdb WordPress database abstraction object.
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $plugin_slug The plugin slug.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string|\WP_User $user The user to grant access to.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return bool
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -123,6 +141,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $existing_committers = self::get_plugin_committers( $plugin_slug );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( in_array( $user->user_login, $existing_committers, true ) ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> // User already has write access.
</span><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -130,19 +149,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_cache_delete( "{$plugin_slug}_committer", 'wporg-plugins' );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_cache_delete( "{$user->user_login}_committer", 'wporg-plugins' );
</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 (bool) $wpdb->insert(
- PLUGINS_TABLE_PREFIX . 'svn_access',
- array(
- 'path' => "/{$plugin_slug}",
- 'user' => $user->user_login,
- 'access' => 'rw',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return (bool) $wpdb->insert( PLUGINS_TABLE_PREFIX . 'svn_access', array(
+ 'path' => "/{$plugin_slug}",
+ 'user' => $user->user_login,
+ 'access' => 'rw',
+ ) );
</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="cx" style="display: block; padding: 0 10px"> * Revoke a users RW access to a plugin.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @static
+ * @global \wpdb $wpdb WordPress database abstraction object.
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $plugin_slug The plugin slug.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string|\WP_User $user The user to revoke access of.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return bool
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -161,13 +180,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_cache_delete( "{$plugin_slug}_committer", 'wporg-plugins' );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_cache_delete( "{$user->user_login}_committer", 'wporg-plugins' );
</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 $wpdb->delete(
- PLUGINS_TABLE_PREFIX . 'svn_access',
- array(
- 'path' => "/{$plugin_slug}",
- 'user' => $user->user_login,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $wpdb->delete( PLUGINS_TABLE_PREFIX . 'svn_access', array(
+ 'path' => "/{$plugin_slug}",
+ 'user' => $user->user_login,
+ ) );
</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">@@ -176,10 +192,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Plugin Committers are automatically subscribed to plugin commit
</span><span class="cx" style="display: block; padding: 0 10px"> * emails and cannot unsubscribe.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @static
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $plugin_slug The plugin to subscribe to.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param int|WP_User $user The user to subscribe. Default current user.
- * @param bool $subscribe Whether to subscribe (true) or unsubscribe (false).
- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int|WP_User $user Optional. The user to subscribe. Default current user.
+ * @param bool $subscribe Optional. Whether to subscribe (true) or unsubscribe (false).
+ * Default: true.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return bool Whether the user is subscribed.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public static function subscribe_to_plugin_commits( $plugin_slug, $user = 0, $subscribe = true ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -215,9 +233,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Plugin Committers are automatically subscribed to commits, and this
</span><span class="cx" style="display: block; padding: 0 10px"> * function does not respect that status.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @static
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $plugin_slug The plugin to subscribe to.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param int|WP_User $user The user to check. Default current user.
- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int|WP_User $user Optional. The user to check. Default current user.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return bool Whether the specified user is subscribed to commits.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public static function subscribed_to_plugin_commits( $plugin_slug, $user = 0 ) {
</span></span></pre>
</div>
</div>
</body>
</html>