<!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>[12492] sites/trunk/wordpress.org/public_html/wp-content: Plugin Directory: Add ability to define a 'Plugin Author Notice' for plugins.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://meta.trac.wordpress.org/changeset/12492">12492</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/12492","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>2023-03-24 05:11:34 +0000 (Fri, 24 Mar 2023)</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 ability to define a 'Plugin Author Notice' for plugins.

This is a notice that plugin reviewers can set, that is then visible on the plugins page by plugin authors/committers.

The intent is that this can inform plugin authors why their plugin has been closed when they miss the email.

Fixse <a href="http://meta.trac.wordpress.org/ticket/6880">#6880</a>.
Closes https://github.com/WordPress/wordpress.org/pull/135.</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_htmlwpcontentthemespubwporgpluginsinctemplatetagsphp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/inc/template-tags.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpluginstemplatepartspluginsinglephp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/plugin-single.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminmetaboxclassauthornoticephp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-author-notice.php</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  2023-03-23 08:19:32 UTC (rev 12491)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-customizations.php    2023-03-24 05:11:34 UTC (rev 12492)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -63,6 +63,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                add_action( 'wp_ajax_plugin-svn-sync', array( __NAMESPACE__ . '\Metabox\Review_Tools', 'svn_sync' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                add_action( 'save_post', array( __NAMESPACE__ . '\Metabox\Release_Confirmation', 'save_post' ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                add_action( 'save_post', array( __NAMESPACE__ . '\Metabox\Author_Notice', 'save_post' ) );
</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">@@ -472,6 +473,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                array( __NAMESPACE__ . '\Metabox\Commits', 'display' ),
</span><span class="cx" style="display: block; padding: 0 10px">                                'plugin', 'normal', 'low'
</span><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-author-notice',
+                               __( 'Author Notice (Displayed on the plugins page to Plugin Authors)', 'wporg-plugins' ),
+                               array( __NAMESPACE__ . '\Metabox\Author_Notice', 'display' ),
+                               'plugin', 'normal', 'high'
+                       );
</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 unnecessary metaboxes.
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminmetaboxclassauthornoticephp"></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-author-notice.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-author-notice.php                           (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-author-notice.php     2023-03-24 05:11:34 UTC (rev 12492)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,146 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+namespace WordPressdotorg\Plugin_Directory\Admin\Metabox;
+use WordPressdotorg\Plugin_Directory\Tools;
+
+/**
+ * Manage the persistent author notice for the plugin.
+ *
+ * @package WordPressdotorg\Plugin_Directory\Admin\Metabox
+ */
+class Author_Notice {
+
+       const DEFAULT_TEXT  = '<p>This is a message that will be displayed on the top of the plugins page to plugin authors, even if the plugin is closed. To edit, simply click and type.</p>';
+       const POST_META_KEY = '_author_notice';
+
+       /**
+        * Displays the author notice controls.
+        */
+       public static function display() {
+               $post   = get_post();
+               $notice = get_post_meta( $post->ID, self::POST_META_KEY, true ) ?: [ 'type' => '', 'html' => '', 'when' => 0, 'who' => 0 ];
+
+               if ( ! $notice['html'] ) {
+                       $notice['html'] = self::DEFAULT_TEXT;
+               }
+
+               ?>
+               <select name="author_notice[type]" id="author-notice-select">
+                       <option value="" <?php selected( '', $notice['type'] ); ?>><?php esc_html_e( 'Do not show', 'wporg-plugins' ); ?></option>
+                       <optgroup label="<?php esc_attr_e( 'Notice types', 'wporg-plugins' ); ?>">
+                               <option value="info" <?php selected( 'info', $notice['type'] ); ?>><?php esc_html_e( 'Info / Notice', 'wporg-plugins' ); ?></option>
+                               <option value="warning" <?php selected( 'warning', $notice['type'] ); ?>><?php esc_html_e( 'Warning', 'wporg-plugins' ); ?></option>
+                               <option value="error" <?php selected( 'error', $notice['type'] ); ?>><?php esc_html_e( 'Error', 'wporg-plugins' ); ?></option>
+                       </optgroup>
+               </select>
+               <?php
+               if ( $notice['when'] ) {
+                       $who = get_user_by( 'id', $notice['who'] );
+                       printf(
+                               '<span>' . __( 'Last edited by %s <time title="%s">%s ago</a>', 'wporg-plugins' ) . '</span>',
+                               $who->display_name ?: $who->user_login,
+                               gmdate( 'Y-m-d H:i:s', $notice['when'] ),
+                               human_time_diff( $notice['when'] )
+                       );
+               }
+               ?>
+
+               <div id="author-notice-texteditable" class="inline notice notice-alt notice-<?php echo esc_attr( $notice['type'] ); ?>" contentEditable="true">
+                       <?php echo wp_kses_post( $notice['html'] ); ?>
+               </div>
+
+               <input type="hidden" name="author_notice[html]" id="author-notice" value="<?php echo esc_attr( $notice['html'] ); ?>" />
+
+               <script>
+                       jQuery( function( $ ) {
+                               $( '#author-notice-select' ).on( 'change', function() {
+                                       var $notice = $( '#author-notice-texteditable' );
+                                       $notice.removeClass( 'notice- notice-info notice-warning notice-error' );
+                                       $notice.addClass( 'notice-' + $( this ).val() );
+                               } );
+
+                               $( '#author-notice-texteditable' ).on( 'input change', function() {
+                                       // Don't allow deleting the <p> tag.
+                                       if ( ! $( this ).text() ) {
+                                               $( this ).html('<p></p>')
+                                       }
+
+                                       // Update the hidden input value with the HTML.
+                                       $( '#author-notice' ).val( $( this ).html() );
+                               } );
+                       } );
+               </script>
+               <style>
+                       #author-notice-texteditable.notice-:not(:focus) {
+                               opacity: 0.6;
+                       }
+               </style>
+               <?php
+       }
+
+       /**
+        * Saves the author notice.
+        *
+        * @param int|WP_Post $post Post ID or post object.
+        */
+       static function save_post( $post ) {
+               $post          = get_post( $post );
+               $post_meta     = get_post_meta( $post->ID, self::POST_META_KEY, true );
+               $author_notice = $post_meta ?: [ 'type' => '', 'html' => '' ];
+
+               if (
+                       $post &&
+                       isset( $_REQUEST['author_notice'] ) &&
+                       is_array( $_REQUEST['author_notice'] ) &&
+                       current_user_can( 'plugin_admin_edit', $post->ID )
+               ) {
+                       $new_author_notice         = wp_unslash( $_REQUEST['author_notice'] );
+                       $new_author_notice['type'] = sanitize_key( $new_author_notice['type'] );
+                       $new_author_notice['html'] = wp_kses_post( trim( $new_author_notice['html'] ) );
+
+                       // Check it's not empty with tags removed.
+                       if (
+                               $new_author_notice['html'] &&
+                               ! trim( wp_strip_all_tags( $new_author_notice['html'] ) )
+                       ) {
+                               $new_author_notice['html'] = '';
+                       }
+
+                       // Default or no text, remove the notice.
+                       if ( empty( $new_author_notice['html'] ) || self::DEFAULT_TEXT === $new_author_notice['html'] ) {
+                               $new_author_notice['type'] = '';
+                               $new_author_notice['html'] = '';
+                       }
+
+                       // Remove it.
+                       if ( $post_meta && ! $new_author_notice['type'] && ! $new_author_notice['html'] ) {
+                               delete_post_meta( $post->ID, self::POST_META_KEY );
+                               Tools::audit_log( 'Author notice removed.' );
+                               return;
+                       }
+
+                       // Value changed?
+                       if (
+                               $author_notice['html'] != $new_author_notice['html'] ||
+                               $author_notice['type'] != $new_author_notice['type']
+                       ) {
+                               $author_notice = [
+                                       'type' => $new_author_notice['type'],
+                                       'html' => $new_author_notice['html'],
+                                       'when' => time(),
+                                       'who'  => get_current_user_id(),
+                               ];
+
+                               update_post_meta( $post->ID, self::POST_META_KEY, $author_notice );
+
+                               $type_text = $author_notice['type'] ?: __( 'Do not show', 'wporg-plugins' );
+                               Tools::audit_log(
+                                       sprintf(
+                                               'Author notice set to: [%s] %s',
+                                               $type_text,
+                                               wp_strip_all_tags( $author_notice['html'] )
+                                       )
+                               );
+                       }
+               }
+       }
+}
</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-author-notice.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_htmlwpcontentthemespubwporgpluginsinctemplatetagsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/inc/template-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/themes/pub/wporg-plugins/inc/template-tags.php   2023-03-23 08:19:32 UTC (rev 12491)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/inc/template-tags.php     2023-03-24 05:11:34 UTC (rev 12492)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -128,7 +128,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function the_active_plugin_notice( $post = null ) {
</span><span class="cx" style="display: block; padding: 0 10px">        if ( ! in_array( get_post_status( $post ), [ 'rejected', 'closed' ], true ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                echo wp_kses_post( get_plugin_status_notice( $post ) );
</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"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -635,3 +635,25 @@
</span><span class="cx" style="display: block; padding: 0 10px">                echo '<p>' . sprintf( __( 'To disable release confirmations, please contact the plugins team by emailing %s.', 'wporg-plugins' ), 'plugins@wordpress.org' ) . '</p>';
</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">+
+/**
+ * Displays a persistent notice to the plugin author.
+ */
+function the_author_notice( $post = null ) {
+       $post = get_post( $post );
+
+       if ( ! current_user_can( 'plugin_admin_edit', $post->ID ) ) {
+               return;
+       }
+
+       $notice = get_post_meta( $post->ID, '_author_notice', true );
+
+       if ( $notice && $notice['type'] && $notice['html'] ) {
+               printf(
+                       '<div class="notice notice-alt notice-%s">%s</div>',
+                       esc_attr( $notice['type'] ),
+                       '<p><strong>' . __( 'A note from the Plugin Review team, visible only to the plugin author &amp; committers.', 'wporg-plugins' ) . '</strong></p>' .
+                       wp_kses_post( $notice['html'] ) // Should have wrapping <p> tags.
+               );
+       }
+}
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpluginstemplatepartspluginsinglephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/plugin-single.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/plugin-single.php        2023-03-23 08:19:32 UTC (rev 12491)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/plugin-single.php  2023-03-24 05:11:34 UTC (rev 12492)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -24,6 +24,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        <?php the_plugin_banner(); ?>
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        <header class="plugin-header">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                <?php the_author_notice(); ?>
</ins><span class="cx" style="display: block; padding: 0 10px">                 <?php the_active_plugin_notice(); ?>
</span><span class="cx" style="display: block; padding: 0 10px">                <?php the_unconfirmed_releases_notice(); ?>
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span></span></pre>
</div>
</div>

</body>
</html>