<!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>[42992] trunk/src/wp-admin: Privacy: make the sections in the suggested privacy policy text postbox foldable.</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="https://core.trac.wordpress.org/changeset/42992">42992</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/42992","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>azaozz</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2018-04-19 12:38:44 +0000 (Thu, 19 Apr 2018)</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'>Privacy: make the sections in the suggested privacy policy text postbox foldable. Add Read More/Read Less buttons. Fix copying of the suggested text by pressing the button.
Props melchoyce, xkon, azaozz.
See <a href="https://core.trac.wordpress.org/ticket/43620">#43620</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadmincsseditcss">trunk/src/wp-admin/css/edit.css</a></li>
<li><a href="#trunksrcwpadminincludesmiscphp">trunk/src/wp-admin/includes/misc.php</a></li>
<li><a href="#trunksrcwpadminjspostjs">trunk/src/wp-admin/js/post.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadmincsseditcss"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/css/edit.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/css/edit.css 2018-04-19 00:25:52 UTC (rev 42991)
+++ trunk/src/wp-admin/css/edit.css 2018-04-19 12:38:44 UTC (rev 42992)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -649,7 +649,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /* Sugested text for privacy policy postbox */
</span><span class="cx" style="display: block; padding: 0 10px"> .privacy-text-box {
</span><span class="cx" style="display: block; padding: 0 10px"> margin: 10px 0 0;
</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"> .privacy-text-box-head {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -656,7 +655,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> border-left: 4px solid #ffb900;
</span><span class="cx" style="display: block; padding: 0 10px"> border-bottom: 1px solid #e5e5e5;
</span><span class="cx" style="display: block; padding: 0 10px"> box-shadow: 0 1px 1px rgba(0,0,0,0.04);
</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"> .privacy-text-box .privacy-text-box-head.hndle {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -671,7 +669,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> .privacy-text-box-body {
</span><span class="cx" style="display: block; padding: 0 10px"> height: 320px;
</span><span class="cx" style="display: block; padding: 0 10px"> overflow: auto;
</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"> #privacy-text-box .inside {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -680,15 +677,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> .privacy-text-box h3 {
</span><span class="cx" style="display: block; padding: 0 10px"> font-size: 1em;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- margin: 1em 0;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ margin: 1em 0 0.5em;
</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">-.privacy-text-section .privacy-text-copy-button {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.privacy-text-section .privacy-text-copy {
</ins><span class="cx" style="display: block; padding: 0 10px"> float: right;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- margin-top: -1.8em;
</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"> .privacy-text-section {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ position: relative;
</ins><span class="cx" style="display: block; padding: 0 10px"> padding: 1px 14px 1px 12px;
</span><span class="cx" style="display: block; padding: 0 10px"> border-top: 1px solid #e3e3e3;
</span><span class="cx" style="display: block; padding: 0 10px"> border-left: 4px solid transparent;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -704,10 +701,55 @@
</span><span class="cx" style="display: block; padding: 0 10px"> background-color: #fbeaea;
</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">+.privacy-text-meta {
+ font-size: 11px;
+ color: #555D66;
+ font-weight: 600;
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> .closed .privacy-text-box-body {
</span><span class="cx" style="display: block; padding: 0 10px"> display: none;
</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">+.privacy-text-section.folded {
+ height: 150px;
+ overflow: hidden;
+}
+
+.privacy-text-actions {
+ line-height: 32px;
+ padding-bottom: 6px;
+}
+
+.folded .privacy-text-actions {
+ position: absolute;
+ bottom: 0;
+ background-color: white;
+ width: calc(100% - 24px);
+ box-shadow: 0px -5px 10px 5px rgba(255, 255, 255, .8);
+}
+
+.text-removed .privacy-text-actions {
+ background-color: #fbeaea;
+ box-shadow: 0px -5px 10px 5px rgba(251, 234, 234, .8);
+}
+
+.text-updated .privacy-text-actions {
+ background-color: #ecf7ed;
+ box-shadow: 0px -5px 10px 5px rgba(236, 247, 237, .8);
+}
+
+.policy-text-more,
+.folded .privacy-text-copy,
+.folded .policy-text-less {
+ display: none;
+}
+
+.folded .policy-text-more {
+ display: inline;
+}
+
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /*------------------------------------------------------------------------------
</span><span class="cx" style="display: block; padding: 0 10px"> 11.1 - Custom Fields
</span><span class="cx" style="display: block; padding: 0 10px"> ------------------------------------------------------------------------------*/
</span></span></pre></div>
<a id="trunksrcwpadminincludesmiscphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/misc.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/misc.php 2018-04-19 00:25:52 UTC (rev 42991)
+++ trunk/src/wp-admin/includes/misc.php 2018-04-19 12:38:44 UTC (rev 42992)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1549,6 +1549,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $content = '';
</span><span class="cx" style="display: block; padding: 0 10px"> $date_format = get_option( 'date_format' );
</span><span class="cx" style="display: block; padding: 0 10px"> $copy = __( 'Copy' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $more = __( 'Read More' );
+ $less = __( 'Read Less' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $content_array as $section ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $class = $meta = '';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1567,19 +1569,37 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $meta = sprintf( __( 'Policy text added %s.' ), $date );
</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">- $content .= '<div class="privacy-text-section' . $class . '">';
- $content .= '<h3>' . $section['plugin_name'] . '</h3>';
- $content .= '<button type="button" class="privacy-text-copy-button button">';
- $content .= $copy;
- $content .= '<span class="screen-reader-text">' . sprintf( __( 'Copy suggested policy text from %s.' ), $section['plugin_name'] ) . '</span>';
- $content .= '</button>';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $plugin_name = esc_html( $section['plugin_name'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $content .= '<div class="privacy-text-section folded' . $class . '">';
+ $content .= '<h3>' . $plugin_name . '</h3>';
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $meta ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $content .= '<span class="privacy-text-meta">' . $meta . '</span>';
</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">- $content .= '<div class="policy-text">' . $section['policy_text'] . '</div>';
- $content .= "</div>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $content .= '<div class="policy-text" aria-expanded="false">' . $section['policy_text'] . '</div>';
+
+ $content .= '<div class="privacy-text-actions">';
+ $content .= '<button type="button" class="button-link policy-text-more">';
+ $content .= $more;
+ $content .= '<span class="screen-reader-text">' . sprintf( __( 'Expand suggested policy text section from %s.' ), $plugin_name ) . '</span>';
+ $content .= '</button>';
+
+ $content .= '<button type="button" class="button-link policy-text-less">';
+ $content .= $less;
+ $content .= '<span class="screen-reader-text">' . sprintf( __( 'Collapse suggested policy text section from %s.' ), $plugin_name ) . '</span>';
+ $content .= '</button>';
+
+ if ( empty( $section['removed'] ) ) {
+ $content .= '<button type="button" class="privacy-text-copy button">';
+ $content .= $copy;
+ $content .= '<span class="screen-reader-text">' . sprintf( __( 'Copy suggested policy text from %s.' ), $plugin_name ) . '</span>';
+ $content .= '</button>';
+ }
+
+ $content .= '</div>'; // End of .privacy-text-actions.
+ $content .= "</div>\n"; // End of .privacy-text-section.
</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">@@ -1589,7 +1609,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <span class="toggle-indicator" aria-hidden="true"></span>
</span><span class="cx" style="display: block; padding: 0 10px"> </button>
</span><span class="cx" style="display: block; padding: 0 10px"> <div class="privacy-text-box-head hndle">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <h2><?php _e( 'This suggested privacy policy text comes from plugins you have installed.' ); ?></h2>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <h2><?php _e( 'This suggested privacy policy text comes from plugins and themes you have installed.' ); ?></h2>
</ins><span class="cx" style="display: block; padding: 0 10px"> <p>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php _e( 'We suggest reviewing this text then copying and pasting it into your privacy policy page.' ); ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php _e( 'Please remember you are responsible for the policies you choose to adopt, so review the content and make any necessary edits.' ); ?>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1606,7 +1626,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Return the default suggested privacy policy content.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 4.9.6
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string The defauld policy content.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1633,6 +1653,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public static function add_suggested_content() {
</span><span class="cx" style="display: block; padding: 0 10px"> $content = self::get_default_content();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_add_privacy_policy_content( 'WordPress', $content );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_add_privacy_policy_content( 'WordPress', $content );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpadminjspostjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/js/post.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/js/post.js 2018-04-19 00:25:52 UTC (rev 42991)
+++ trunk/src/wp-admin/js/post.js 2018-04-19 12:38:44 UTC (rev 42992)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1268,19 +1268,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> update();
</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">+} )( jQuery, new wp.utils.WordCounter() );
+
+( function( $ ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> // Privacy policy postbox, copy button.
</span><span class="cx" style="display: block; padding: 0 10px"> $( document ).on( 'click', function( event ) {
</span><span class="cx" style="display: block; padding: 0 10px"> var $target = $( event.target );
</span><span class="cx" style="display: block; padding: 0 10px"> var node, range;
</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 ( $target.is( 'button.privacy-text-copy-button' ) ) {
- node = $target.parent().find( 'div.policy-text' )[0];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $target.is( 'button.privacy-text-copy' ) ) {
+ node = $target.parent().parent().find( 'div.policy-text' )[0];
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( node ) {
</span><span class="cx" style="display: block; padding: 0 10px"> try {
</span><span class="cx" style="display: block; padding: 0 10px"> window.getSelection().removeAllRanges();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- range = document.createRange();
- range.selectNode( node );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ range = document.createRange();
+ range.selectNodeContents( node );
</ins><span class="cx" style="display: block; padding: 0 10px"> window.getSelection().addRange( range );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> document.execCommand( 'copy' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1287,7 +1290,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> window.getSelection().removeAllRanges();
</span><span class="cx" style="display: block; padding: 0 10px"> } catch ( er ) {}
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } else if ( $target.is( 'button.policy-text-more' ) ) {
+ $target.parents( '.privacy-text-section' ).removeClass( 'folded' )
+ .find( '.policy-text' ).attr( 'aria-expanded', 'true' );
+ } else if ( $target.is( 'button.policy-text-less' ) ) {
+ $target.parents( '.privacy-text-section' ).addClass( 'folded' )
+ .find( '.policy-text' ).attr( 'aria-expanded', '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">-} )( jQuery, new wp.utils.WordCounter() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+} )( jQuery );
</ins></span></pre>
</div>
</div>
</body>
</html>