<!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>[2655] sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory: Plugin Directory: Add several metaboxes for the Plugin Review/Admin.</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/2655">2655</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/2655","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>dd32</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-03-01 07:51:16 +0000 (Tue, 01 Mar 2016)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Plugin Directory: Add several metaboxes for the Plugin Review/Admin.
This change includes switching to custom taxonomies, a custom publish metabox, a custom tags metabox, and the start of a plugin-reviewer metabox.
See <a href="http://meta.trac.wordpress.org/ticket/1570">#1570</a>, <a href="http://meta.trac.wordpress.org/ticket/1584">#1584</a> </pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminclasscustomizationsphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-customizations.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminmetaboxclasscommittersphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-committers.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_htmlwpcontentpluginsplugindirectorycliclassimportphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryplugindirectoryphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/plugin-directory.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminmetaboxclasscontrolsphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-controls.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminmetaboxclasscustomfieldsphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-custom-fields.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminmetaboxclassplugintagsphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-plugin-tags.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminmetaboxclassreviewtoolsphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-review-tools.php</a></li>
<li>sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/css/</li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectorycsseditformcss">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/css/edit-form.css</a></li>
<li>sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/js/</li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryjseditformjs">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/js/edit-form.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminclasscustomizationsphp"></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/admin/class-customizations.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/admin/class-customizations.php 2016-03-01 03:32:49 UTC (rev 2654)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-customizations.php 2016-03-01 07:51:16 UTC (rev 2655)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,5 +1,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> namespace WordPressdotorg\Plugin_Directory\Admin;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+use \WordPressdotorg\Plugin_Directory;
</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"> * All functionality related to the Administration interface.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -9,7 +10,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> class Customizations {
</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">- * Fetch the instance of the Plugin_Directory class.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Fetch the instance of the Admin Customizations class.
</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">@@ -17,44 +18,103 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return ! is_null( $instance ) ? $instance : $instance = new Customizations();
</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">+ private function __construct() {
+ // Admin Metaboxes
+ add_action( 'add_meta_boxes', array( $this, 'register_admin_metaboxes' ), 10, 1 );
+ add_action( 'do_meta_boxes', array( $this, 'replace_title_global' ) );
+
+ add_action( 'save_post_plugin', array( $this, 'save_plugin_post' ), 10, 2 );
+
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Adds the plugin name into the post editing title.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @global $title The wp-admin title variable.
+ *
+ * @param string $post_type The post type of the current page
+ * @return void.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- private function __construct() {
- add_action( 'add_meta_boxes', array( $this, 'register_admin_metaboxes' ) );
- add_action( 'edit_form_after_title', array( $this, 'edit_form_after_title' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function replace_title_global( $post_type ) {
+ global $title;
+ if ( 'plugin' === $post_type ) {
+ $title = sprintf( $title, get_the_title() ); // esc_html() on output
+ }
</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><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Enqueue JS and CSS assets needed for any wp-admin screens.
+ *
+ * @param string $hook_suffix The hook suffix of the current screen.
+ * @return void.
+ */
+ public function enqueue_assets( $hook_suffix ) {
+ global $post_type;
+
+ if ( 'post.php' == $hook_suffix && 'plugin' == $post_type ) {
+ wp_enqueue_style( 'plugin-admin-edit-css', plugins_url( 'css/edit-form.css', Plugin_Directory\PLUGIN_FILE ), array( 'edit' ), 1 );
+ wp_enqueue_script( 'plugin-admin-edit-js', plugins_url( 'js/edit-form.js', Plugin_Directory\PLUGIN_FILE ), array(), 1 );
+ }
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Register the Admin metaboxes for the plugin management screens.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
+ * @param string $post_type The post type of the current screen.
+ * @return void.
</ins><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 register_admin_metaboxes() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function register_admin_metaboxes( $post_type ) {
+ if ( 'plugin' != $post_type ) {
+ return;
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> add_meta_box(
</span><span class="cx" style="display: block; padding: 0 10px"> 'plugin-committers',
</span><span class="cx" style="display: block; padding: 0 10px"> __( 'Plugin Committers', 'wporg-plugins' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array( __NAMESPACE__ . '\\Metabox\\Committers', 'display' ),
- 'plugin'
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ array( __NAMESPACE__ . '\Metabox\Committers', 'display' ),
+ 'plugin', 'side'
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ add_meta_box(
+ 'plugin-review',
+ __( 'Plugin Review Tools', 'wporg-plugins' ),
+ array( __NAMESPACE__ . '\Metabox\Review_Tools', 'display' ),
+ 'plugin', 'normal', 'high'
+ );
+
+ add_meta_box(
+ 'plugin-fields',
+ __( 'Plugin Meta', 'wporg-plugins' ),
+ array( __NAMESPACE__ . '\Metabox\Custom_Fields', 'display' ),
+ 'plugin', 'normal', 'low'
+ );
+
+ // Replace the publish box
+ add_meta_box(
+ 'submitdiv',
+ __( 'Plugin Controls', 'wporg-plugins' ),
+ array( __NAMESPACE__ . '\Metabox\Controls', 'display' ),
+ 'plugin', 'side', 'high'
+ );
+
+ // Remove the Slug metabox
+ add_meta_box( 'slugdiv', false, false, false );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Displays a link to the plugins zip file.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Hook into the save process for the plugin post_type to save extra metadata.
</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 \WP_Post $post
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Currently saves the tested_with value.
+ *
+ * @param int $post_id The post_id being updated.
+ * @param \WP_Post $post The WP_Post object being updated.
</ins><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 edit_form_after_title( $post ) {
- $zip_files = get_attached_media( 'application/zip', $post );
- $zip_file = current( $zip_files );
- $zip_url = wp_get_attachment_url( $zip_file->ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function save_plugin_post( $post_id, $post ) {
+ // Save meta information
+ if ( isset( $_POST['tested_with'] ) && isset( $_POST['hidden_tested_with'] ) && $_POST['tested_with'] != $_POST['hidden_tested_with'] ) {
+ update_post_meta( $post_id, 'tested', wp_slash( wp_unslash( $_POST['tested_with'] ) ) );
+ }
+ }
</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 ( $zip_url ) :
- ?>
-
- <p style="padding: 0 10px;">
- <?php printf( __( '<strong>Zip file:</strong> %s' ), sprintf( '<a href="%s">%s</a>', esc_url( $zip_url ), esc_html( $zip_url ) ) ); ?>
- </p>
-
- <?php
- endif;
- }
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminmetaboxclasscommittersphp"></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/admin/metabox/class-committers.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/admin/metabox/class-committers.php 2016-03-01 03:32:49 UTC (rev 2654)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-committers.php 2016-03-01 07:51:16 UTC (rev 2655)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,6 +1,5 @@
</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\Admin\Metabox;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> use WordPressdotorg\Plugin_Directory\Tools;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -9,10 +8,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @package WordPressdotorg\Plugin_Directory\Admin\Metabox
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Committers {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- /**
- *
- */
</del><span class="cx" style="display: block; padding: 0 10px"> static function display() {
</span><span class="cx" style="display: block; padding: 0 10px"> $plugin_slug = get_post()->post_name;
</span><span class="cx" style="display: block; padding: 0 10px"> $existing_committers = Tools::get_plugin_committers( $plugin_slug );
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminmetaboxclasscontrolsphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-controls.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/admin/metabox/class-controls.php (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-controls.php 2016-03-01 07:51:16 UTC (rev 2655)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,147 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+namespace WordPressdotorg\Plugin_Directory\Admin\Metabox;
+
+/**
+ * The Plugin Controls / Publish metabox.
+ *
+ * @package WordPressdotorg\Plugin_Directory\Admin\Metabox
+ */
+class Controls {
+
+ /**
+ * Displays the Publish metabox for plugins.
+ * The HTML here matches what Core uses.
+ */
+ static function display() {
+ echo '<div class="submitbox" id="submitpost">';
+ echo '<div id="misc-publishing-actions">';
+ self::display_post_status();
+
+ if ( 'publish' == get_post_status() ) {
+ self::display_tested_up_to();
+ }
+ echo '</div>';
+
+ echo '<div id="major-publishing-actions"><div id="publishing-action">';
+ echo '<span class="spinner"></span>';
+ printf( '<input type="submit" name="save_changes" id="publish" class="button button-primary button-large" value="%s">', __( 'Save Changes', 'wporg-plugins' ) );
+ echo '</div><div class="clear"></div></div>';
+ echo '</div>';
+ }
+
+ /**
+ * Displays the Plugin Status control in the Publish metabox.
+ */
+ protected static function display_post_status() {
+ $post = get_post();
+
+ $statuses = array( 'publish', 'pending', 'disabled', 'closed', 'rejected' );
+ // TODO Add capability check here
+ ?>
+ <div class="misc-pub-section misc-pub-plugin-status">
+ <label for="post_status"><?php _e( 'Status:', 'wporg-plugins' ); ?></label>
+ <span id="plugin-status-display"><?php echo esc_html( get_post_status_object( $post->post_status )->label ); ?></span>
+ <a href="#plugin_status" class="edit-plugin-status hide-if-no-js"><span aria-hidden="true">Edit</span> <span class="screen-reader-text">Edit status</span></a>
+
+ <div id="plugin-status-select" class="hide-if-js">
+ <input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr( $post->post_status ); ?>">
+ <select name="post_status" id="plugin_status">
+ <?php
+ foreach ( $statuses as $statii ) {
+ $status_object = get_post_status_object( $statii );
+ $selected = selected( $post->post_status, $statii, false );
+ printf(
+ '<option value="%s" %s>%s</option>',
+ esc_attr( $statii ),
+ $selected,
+ esc_html( $status_object->label )
+ );
+ }
+ ?>
+ </select>
+ <a href="#plugin_status" class="save-plugin-status hide-if-no-js button">OK</a>
+ <a href="#plugin_status" class="cancel-plugin-status hide-if-no-js button-cancel">Cancel</a>
+ </div>
+
+ </div><!-- .misc-pub-section --><?php
+ }
+
+ /**
+ * Displays the Tested Up To control in the Publish metabox.
+ */
+ protected static function display_tested_up_to() {
+ $post = get_post();
+ $tested_up_to = (string) get_post_meta( $post->ID, 'tested', true );
+ $versions = self::get_tested_up_to_versions( $tested_up_to );
+ $tested_up_to = $versions['tested_up_to'];
+ $unknown_string = _x( 'Unknown', 'unknown version', 'wporg-plugins' );
+ ?>
+ <div class="misc-pub-section misc-pub-tested">
+ <label for="tested_with"><?php _e( 'Tested With:', 'wporg-plugins' ); ?></label>
+ <span id="tested-with-display"><?php echo ( $tested_up_to ? sprintf( 'WordPress %s', $tested_up_to ) : $unknown_string ); ?></span>
+ <a href="#tested_with" class="edit-tested-with hide-if-no-js"><span aria-hidden="true">Edit</span> <span class="screen-reader-text">Edit status</span></a>
+
+ <div id="tested-with-select" class="hide-if-js">
+ <input type="hidden" name="hidden_tested_with" id="hidden_tested_with" value="<?php echo esc_attr( $tested_up_to ); ?>">
+ <select name="tested_with" id="tested_with">
+ <?php
+ foreach ( $versions['versions'] as $ver ) {
+ printf(
+ '<option value="%s" %s>%s</option>',
+ esc_attr( $ver ),
+ selected( $tested_up_to, $ver, true ),
+ esc_html( $ver ? sprintf( 'WordPress %s', $ver ) : $unknown_string )
+ );
+ }
+ ?>
+ </select>
+ <a href="#tested_with" class="save-tested-with hide-if-no-js button">OK</a>
+ <a href="#tested_with" class="cancel-tested-with hide-if-no-js button-cancel">Cancel</a>
+ </div>
+
+ </div><!-- .misc-pub-section --><?php
+ }
+
+ /**
+ * Fetch all versions which an author can set their plugin as tested with.
+ *
+ * This returns the latest release in the previous 4 branches, trunk, and
+ * the current version the plugin is marked as tested with.
+ *
+ * @param string $tested_up_to The version which the plugin is currently specified as compatible to.
+ *
+ * @return array An array containing 'versions' an array of versions for display, and 'tested_up_to'
+ * the sanitized/most recent version of the $tested_up_to parameter.
+ */
+ protected static function get_tested_up_to_versions( $tested_up_to ) {
+ global $wp_version;
+ // Fetch all "compatible" versions, this array is in the form of [ '4.4.2' => [ '4.4.1', '4.4' ], ...]
+ if ( function_exists( 'wporg_get_version_equivalents' ) ) {
+ // This function is a global WordPress.org function.
+ $all_versions = wporg_get_version_equivalents();
+ } else {
+ $all_version = array( (string)(float)$wp_version => array( $wp_version ) );
+ }
+
+ $versions = array_slice( array_keys( $all_versions ), 0, 4 );
+ // WordPress.org runs trunk, this keeps the highest version selectable as trunk
+ $versions[5] = preg_replace( '!-\d{4,}$!', '', $wp_version );
+
+ $found = false;
+ foreach( $versions as $version ) {
+ if ( isset( $all_versions[ $version ] ) && in_array( $tested_up_to, $all_versions[ $version ] ) ) {
+ $tested_up_to = $version;
+ $found = true;
+ break;
+ }
+ }
+ // If the version specified isn't going to display, insert it into the list.
+ if ( ! $found ) {
+ $versions[4] = $tested_up_to;
+ ksort( $versions );
+ }
+
+ return compact( 'versions', 'tested_up_to' );
+ }
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-controls.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminmetaboxclasscustomfieldsphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-custom-fields.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/admin/metabox/class-custom-fields.php (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-custom-fields.php 2016-03-01 07:51:16 UTC (rev 2655)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,36 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+namespace WordPressdotorg\Plugin_Directory\Admin\Metabox;
+
+/**
+ * Displays the Custom Metadata we've stored for the plugin.
+ *
+ * @package WordPressdotorg\Plugin_Directory\Admin\Metabox
+ */
+class Custom_Fields {
+ static function display() {
+ $post = get_post();
+ $fields = array(
+ 'version' => 'Latest Plugin Version',
+ 'stable_tag' => 'Stable Tag',
+ 'tested' => 'Tested With',
+ 'requires' => 'Requires',
+ 'donate_link' => 'Donate URL',
+ 'header_plugin_uri' => 'Plugin URI',
+ 'header_author' => 'Plugin Author',
+ 'header_author_uri' => 'Plugin Author URI',
+ 'header_textdomain' => 'Plugin TextDomain',
+ 'header_description' => 'Plugin Description',
+ );
+ echo '<dl>';
+ foreach ( $fields as $field => $text ) {
+ if ( ! ($value = get_post_meta( $post->ID, $field, true ) ) ) {
+ continue;
+ }
+ printf( '<dt>%s</dt><dd>%s</dd>', esc_html( $text ), make_clickable( esc_html( $value ) ) );
+ }
+ // Description is stored in the post_excerpt rather than meta
+ printf( '<dt>%s</dt><dd>%s</dd>', esc_html( $fields['header_description'] ), get_the_excerpt() );
+ echo '</dl>';
+ }
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-custom-fields.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminmetaboxclassplugintagsphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-plugin-tags.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/admin/metabox/class-plugin-tags.php (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-plugin-tags.php 2016-03-01 07:51:16 UTC (rev 2655)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,31 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+namespace WordPressdotorg\Plugin_Directory\Admin\Metabox;
+
+/**
+ * The Plugin Tags metabox
+ *
+ * @package WordPressdotorg\Plugin_Directory\Admin\Metabox
+ */
+class Plugin_Tags {
+
+ /**
+ * Displays the Publish metabox for plugins.
+ * The HTML here matches what Core uses.
+ */
+ static function display( $post, $box ) {
+ $taxonomy = get_taxonomy( 'plugin_tag' );
+ ?>
+ <div id="taxonomy-plugin_tag" class="categorydiv">
+ <div id="plugin_tag-all" class="tabs-panel">
+ <?php
+ echo "<input type='hidden' name='tax_input[plugin_tag][]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.
+ ?>
+ <ul id="plugin_tagchecklist" data-wp-lists="list:plugin_tag" class="categorychecklist form-no-clear">
+ <?php wp_terms_checklist( $post->ID, array( 'taxonomy' => 'plugin_tag' ) ); ?>
+ </ul>
+ </div>
+ </div>
+ <?php
+ }
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-plugin-tags.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminmetaboxclassreviewtoolsphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-review-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/admin/metabox/class-review-tools.php (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-review-tools.php 2016-03-01 07:51:16 UTC (rev 2655)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,36 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+namespace WordPressdotorg\Plugin_Directory\Admin\Metabox;
+
+/**
+ * The Plugin Review metabox.
+ *
+ * @package WordPressdotorg\Plugin_Directory\Admin\Metabox
+ */
+class Review_Tools {
+ static function display() {
+ $post = get_post();
+ $plugin_slug = $post->post_name;
+
+ $zip_files = get_attached_media( 'application/zip', $post );
+ if ( $zip_files && 'pending' == $post->post_status ) {
+ $zip_file = current( $zip_files );
+ $zip_url = wp_get_attachment_url( $zip_file->ID );
+ printf(
+ '<p>' . __( '<strong>Zip file:</strong> %s', 'wporg-plugins' ) . '</p>',
+ sprintf(
+ '<a href="%s">%s</a>',
+ esc_url( $zip_url ),
+ esc_html( $zip_url )
+ )
+ );
+ }
+
+ echo "<ul>
+ <li><a href='https://plugins.trac.wordpress.org/log/{$plugin_slug}/'>" . __( 'Development Log', 'wporg-plugins' ) . "</a></li>
+ <li><a href='https://plugins.svn.wordpress.org/{$plugin_slug}/'>" . __( 'Subversion Repository', 'wporg-plugins' ) . "</a></li>
+ <li><a href='https://plugins.trac.wordpress.org/browser/{$plugin_slug}/'>" . __( 'Browse in Trac', 'wporg-plugins' ) . '</a></li>
+ </ul>';
+
+ }
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-review-tools.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryclassplugindirectoryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php 2016-03-01 03:32:49 UTC (rev 2654)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php 2016-03-01 07:51:16 UTC (rev 2655)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11,16 +11,13 @@
</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><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function instance( $plugin_file = null ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function instance() {
</ins><span class="cx" style="display: block; padding: 0 10px"> static $instance = 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">- return ! is_null( $instance ) ? $instance : $instance = new Plugin_Directory( $plugin_file );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return ! is_null( $instance ) ? $instance : $instance = new Plugin_Directory();
</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">- /**
- * @param string $plugin_file
- */
- private function __construct( $plugin_file ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ private function __construct() {
</ins><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="cx" style="display: block; padding: 0 10px"> add_filter( 'post_type_link', array( $this, 'package_link' ), 10, 2 );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -29,10 +26,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'the_content', array( $this, 'filter_post_content_to_correct_page' ), 1 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Load all Admin-specific items.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( 'admin_init', array( __NAMESPACE__ . '\\Admin\\Customizations', 'instance' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( 'admin_init', array( __NAMESPACE__ . '\Admin\Customizations', 'instance' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- register_activation_hook( $plugin_file, array( $this, 'activate' ) );
- register_deactivation_hook( $plugin_file, array( $this, 'deactivate' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ register_activation_hook( PLUGIN_FILE, array( $this, 'activate' ) );
+ register_deactivation_hook( PLUGIN_FILE, array( $this, 'deactivate' ) );
</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">@@ -42,29 +39,71 @@
</span><span class="cx" style="display: block; padding: 0 10px"> load_plugin_textdomain( '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(
- 'name' => __( 'Plugins', 'wporg-plugins' ),
- 'singular_name' => __( 'Plugin', 'wporg-plugins' ),
- 'menu_name' => __( 'My Plugins', 'wporg-plugins' ),
- 'add_new' => __( 'Add New', 'wporg-plugins' ),
- 'add_new_item' => __( 'Add New Plugin', 'wporg-plugins' ),
- 'edit_item' => __( 'Edit Plugin', 'wporg-plugins' ),
- 'new_item' => __( 'New Plugin', 'wporg-plugins' ),
- 'view_item' => __( 'View Plugin', 'wporg-plugins' ),
- 'search_items' => __( 'Search Plugins', 'wporg-plugins' ),
- 'not_found' => __( 'No plugins found', 'wporg-plugins' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'labels' => array(
+ 'name' => __( 'Plugins', 'wporg-plugins' ),
+ 'singular_name' => __( 'Plugin', 'wporg-plugins' ),
+ 'menu_name' => __( 'My Plugins', 'wporg-plugins' ),
+ 'add_new' => __( 'Add New', 'wporg-plugins' ),
+ 'add_new_item' => __( 'Add New Plugin', 'wporg-plugins' ),
+ 'edit_item' => __( 'Editing Plugin: %s', 'wporg-plugins' ),
+ 'new_item' => __( 'New Plugin', 'wporg-plugins' ),
+ 'view_item' => __( 'View Plugin', 'wporg-plugins' ),
+ 'search_items' => __( 'Search Plugins', 'wporg-plugins' ),
+ 'not_found' => __( 'No plugins found', 'wporg-plugins' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'not_found_in_trash' => __( 'No plugins found in Trash', '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">- 'description' => __( 'A Repo Plugin', 'wporg-plugins' ),
- 'supports' => array( 'title', 'editor', 'excerpt', 'custom-fields' ),
- 'taxonomies' => array( 'post_tag', 'category' ),
- 'public' => true,
- 'show_ui' => true,
- 'has_archive' => true,
- 'rewrite' => false,
- 'menu_icon' => 'dashicons-admin-plugins',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'description' => __( 'A Repo Plugin', 'wporg-plugins' ),
+ 'supports' => false,
+ 'public' => true,
+ 'show_ui' => true,
+ 'has_archive' => true,
+ 'rewrite' => false,
+ 'menu_icon' => 'dashicons-admin-plugins',
+ 'capability_type' => array( 'post', 'posts' ), // TODO roles & capabilities
+ 'map_meta_cap' => true,
+ 'capabilities' => array(
+ 'create_posts' => 'do_not_allow'
+ )
</ins><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_taxonomy( 'plugin_category', 'plugin', array(
+ 'hierarchical' => true,
+ 'query_var' => 'plugin_category',
+ 'rewrite' => false,
+ 'public' => true,
+ 'show_ui' => true,
+ 'show_admin_column' => true,
+ 'meta_box_cb' => 'post_categories_meta_box',
+ 'capabilities' => array(
+ 'assign_terms' => 'manage_categories',
+ )
+ ) );
+
+ register_taxonomy( 'plugin_tag', 'plugin', array(
+ 'hierarchical' => true, /* for tax_input[] handling on post saves. */
+ 'query_var' => 'plugin_tag',
+ 'rewrite' => array(
+ 'hierarchical' => false,
+ 'slug' => 'tags',
+ 'with_front' => false,
+ 'ep_mask' => EP_TAGS,
+ ),
+ 'labels' => array(
+ 'name' => __( 'Plugin Tags', 'wporg-plugins' ),
+ 'singular_name' => __( 'Plugin Tag', 'wporg-plugins' ),
+ 'edit_item' => __( 'Edit Tag', 'wporg-plugins' ),
+ 'update_item' => __( 'Update Tag', 'wporg-plugins' ),
+ 'add_new_item' => __( 'Add New Tag', 'wporg-plugins' ),
+ 'new_item_name' => __( 'New Tag Name', 'wporg-plugins' ),
+ 'search_items' => __( 'Search Tags', 'wporg-plugins' ),
+ ),
+ 'public' => true,
+ 'show_ui' => true,
+ 'show_admin_column' => true,
+ 'meta_box_cb' => array( __NAMESPACE__ . '\Admin\Metabox\Plugin_Tags', 'display' ),
+ 'capabilities' => array()
+ ) );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> register_post_status( 'pending', array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'label' => _x( 'Pending', 'plugin status', 'wporg-plugins' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'public' => false,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -83,6 +122,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'show_in_admin_status_list' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> 'label_count' => _n_noop( 'Closed <span class="count">(%s)</span>', 'Closed <span class="count">(%s)</span>', 'wporg-plugins' ),
</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_post_status( 'rejected', array(
+ 'label' => _x( 'Rejected', 'plugin status', 'wporg-plugins' ),
+ 'public' => false,
+ 'show_in_admin_status_list' => true,
+ 'label_count' => _n_noop( 'Rejected <span class="count">(%s)</span>', 'Rejected <span class="count">(%s)</span>', 'wporg-plugins' ),
+ ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Add the browse/* views.
</span><span class="cx" style="display: block; padding: 0 10px"> add_rewrite_tag( '%browse%', '(featured|popular|beta|new|favorites)' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -107,13 +152,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Register the Shortcodes used within the content.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function register_shortcodes() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_shortcode( 'wporg-plugin-upload', array( __NAMESPACE__ . '\\Shortcodes\\Upload', 'display' ) );
- add_shortcode( 'wporg-plugins-screenshots', array( __NAMESPACE__ . '\\Shortcodes\\Screenshots', 'display' ) );
- // add_shortcode( 'wporg-plugins-stats', array( __NAMESPACE__ . '\\Shortcodes\\Stats', 'display' ) );
- // add_shortcode( 'wporg-plugins-developer', array( __NAMESPACE__ . '\\Shortcodes\\Developer', 'display' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_shortcode( 'wporg-plugin-upload', array( __NAMESPACE__ . '\Shortcodes\Upload', 'display' ) );
+ add_shortcode( 'wporg-plugins-screenshots', array( __NAMESPACE__ . '\Shortcodes\Screenshots', 'display' ) );
+ // add_shortcode( 'wporg-plugins-stats', array( __NAMESPACE__ . '\Shortcodes\Stats', 'display' ) );
+ // add_shortcode( 'wporg-plugins-developer', array( __NAMESPACE__ . '\Shortcodes\Developer', 'display' ) );
</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><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Upon plugin activation, set up the current site for acting
+ * as the plugin directory.
+ *
+ * Setting up the site requires setting up the theme and proper
+ * rewrite permastructs.
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @global \WP_Rewrite $wp_rewrite WordPress rewrite component.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function activate() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -147,7 +198,7 @@
</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">- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Clean up options & rewrite rules after plugin deactivation.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function deactivate() {
</span><span class="cx" style="display: block; padding: 0 10px"> flush_rewrite_rules();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -240,11 +291,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> switch ( get_query_var( 'browse' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> case 'beta':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $wp_query->query_vars['category_name'] = 'beta';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $wp_query->query_vars['plugin_category'] = 'beta';
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> case 'featured':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $wp_query->query_vars['category_name'] = 'featured';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $wp_query->query_vars['plugin_category'] = 'featured';
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> case 'favorites':
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -325,12 +376,17 @@
</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><span class="cx" style="display: block; padding: 0 10px"> * @param $plugin_slug string|\WP_Post The slug of the plugin to retrieve.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return \WP_Post|\WP_Error
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return \WP_Post|bool
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> static public function get_plugin_post( $plugin_slug ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $post;
</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">+ // Use the global $post object when it matches to avoid hitting the database.
+ if ( !empty( $post ) && 'plugin' == $post->post_type && $plugin_slug == $post->post_name ) {
+ return $post;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><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></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectorycliclassimportphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php 2016-03-01 03:32:49 UTC (rev 2654)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php 2016-03-01 07:51:16 UTC (rev 2655)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2,6 +2,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> namespace WordPressdotorg\Plugin_Directory\CLI;
</span><span class="cx" style="display: block; padding: 0 10px"> use WordPressdotorg\Plugin_Directory\Plugin_Directory;
</span><span class="cx" style="display: block; padding: 0 10px"> use WordPressdotorg\Plugin_Directory\Readme_Parser;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+use WordPressdotorg\Plugin_Directory\Template;
</ins><span class="cx" style="display: block; padding: 0 10px"> use WordPressdotorg\Plugin_Directory\Tools;
</span><span class="cx" style="display: block; padding: 0 10px"> use WordPressdotorg\Plugin_Directory\Tools\Filesystem;
</span><span class="cx" style="display: block; padding: 0 10px"> use WordPressdotorg\Plugin_Directory\Tools\SVN;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -87,10 +88,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_update_post( $plugin );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $this->readme_fields as $readme_field ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_post_meta( $plugin->ID, $readme_field, $readme->$readme_field );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Don't change the tested version if a newer version was specified through wp-admin
+ if ( 'tested' == $readme_field && version_compare( get_post_meta( $plugin->ID, 'tested', true ), $readme->$readme_field, '>' ) ) {
+ continue;
+ }
+ update_post_meta( $plugin->ID, $readme_field, wp_slash( $readme->$readme_field ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $this->plugin_headers as $plugin_header => $meta_field ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_post_meta( $plugin->ID, $meta_field, $headers->$plugin_header );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_post_meta( $plugin->ID, $meta_field, wp_slash( $headers->$plugin_header ) );
</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"> update_post_meta( $plugin->ID, 'sections', array_keys( $readme->sections ) );
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectorycsseditformcss"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/css/edit-form.css</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/css/edit-form.css (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/css/edit-form.css 2016-03-01 07:51:16 UTC (rev 2655)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,44 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/*
+ * CSS Rules for the Plugin Admin screen
+ */
+#misc-publishing-actions label::before {
+ font: normal 20px/1 dashicons;
+ speak: none;
+ display: inline-block;
+ padding: 0 2px 0 0;
+ top: 0;
+ left: -1px;
+ position: relative;
+ vertical-align: top;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+ text-decoration: none !important;
+ color: #82878c;
+}
+
+#misc-publishing-actions label[for="post_status"]::before {
+ content: "\f173";
+}
+#misc-publishing-actions label[for="tested_with"]::before {
+ content: "\f177";
+}
+
+#misc-publishing-actions span#plugin-status-display,
+#misc-publishing-actions span#tested-with-display {
+ font-weight: bold;
+}
+
+.inside-submitbox #plugin-status,
+.inside-submitbox #tested-with {
+ margin: 2px 0 2px -2px;
+}
+
+#plugin-status-select,
+#tested-with-select {
+ margin-top: 3px;
+}
+
+/* We don't output the Title or Editor instance, so this div is indentionally empty, hide it to remove the margin. */
+.wp-admin.post-type-plugin #post-body-content {
+ display: none;
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/css/edit-form.css
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryjseditformjs"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/js/edit-form.js</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/js/edit-form.js (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/js/edit-form.js 2016-03-01 07:51:16 UTC (rev 2655)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,69 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/*
+ * JS for the Plugin Admin screens.
+ */
+
+jQuery(document).ready( function($) {
+
+ var updateText,
+ $testedWithSelect = $('#tested-with-select'),
+ $pluginStatusSelect = $('#plugin-status-select');
+
+ // submitdiv
+ if ( $('#submitdiv').length ) {
+
+ updateText = function() {
+ $('#plugin-status-display').html( $('option:selected', $pluginStatusSelect).text() );
+ $('#tested-with-display').html( $('option:selected', $testedWithSelect).text() );
+ return true;
+ };
+
+ // Plugin Status / post_status
+ $pluginStatusSelect.siblings('a.edit-plugin-status').click( function( event ) {
+ if ( $pluginStatusSelect.is( ':hidden' ) ) {
+ $pluginStatusSelect.slideDown( 'fast', function() {
+ $pluginStatusSelect.find('select').focus();
+ } );
+ $(this).hide();
+ }
+ event.preventDefault();
+ });
+
+ $pluginStatusSelect.find('.save-plugin-status').click( function( event ) {
+ $pluginStatusSelect.slideUp( 'fast' ).siblings( 'a.edit-plugin-status' ).show().focus();
+ updateText();
+ event.preventDefault();
+ });
+
+ $pluginStatusSelect.find('.cancel-plugin-status').click( function( event ) {
+ $pluginStatusSelect.slideUp( 'fast' ).siblings( 'a.edit-plugin-status' ).show().focus();
+ $('#post_status').val( $('#hidden_post_status').val() );
+ updateText();
+ event.preventDefault();
+ });
+
+ // Tested With
+ $testedWithSelect.siblings('a.edit-tested-with').click( function( event ) {
+ if ( $testedWithSelect.is( ':hidden' ) ) {
+ $testedWithSelect.slideDown( 'fast', function() {
+ $testedWithSelect.find('select').focus();
+ } );
+ $(this).hide();
+ }
+ event.preventDefault();
+ });
+
+ $testedWithSelect.find('.save-tested-with').click( function( event ) {
+ $testedWithSelect.slideUp( 'fast' ).siblings( 'a.edit-tested-with' ).show().focus();
+ updateText();
+ event.preventDefault();
+ });
+
+ $testedWithSelect.find('.cancel-tested-with').click( function( event ) {
+ $testedWithSelect.slideUp( 'fast' ).siblings( 'a.edit-tested-with' ).show().focus();
+ $('#tested_with').val( $('#hidden_tested_with').val() );
+ updateText();
+ event.preventDefault();
+ });
+ } // end submitdiv
+
+} );
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryplugindirectoryphp"></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/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/plugin-directory.php 2016-03-01 03:32:49 UTC (rev 2654)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/plugin-directory.php 2016-03-01 07:51:16 UTC (rev 2655)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -15,10 +15,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> namespace WordPressdotorg\Plugin_Directory;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Store the root plugin file for usage with functions which use the plugin basename.
+ */
+define( __NAMESPACE__ . '\PLUGIN_FILE', __FILE__ );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Register an Autoloader for all files
</span><span class="cx" style="display: block; padding: 0 10px"> include __DIR__ . '/class-autoloader.php';
</span><span class="cx" style="display: block; padding: 0 10px"> Autoloader\register_class_path( __NAMESPACE__, __DIR__ );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-// Create the instance of the plugin, passing __FILE__ for actions that need it.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+// Instantiate the Plugin Directory
</ins><span class="cx" style="display: block; padding: 0 10px"> include __DIR__ . '/class-plugin-directory.php';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-Plugin_Directory::instance( __FILE__ );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+Plugin_Directory::instance();
</ins></span></pre>
</div>
</div>
</body>
</html>