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 #43620. Built from https://develop.svn.wordpress.org/trunk@42992 git-svn-id: http://core.svn.wordpress.org/trunk@42821 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0b0c754563
commit
891deab7c5
|
@ -649,14 +649,12 @@ span.wp-media-buttons-icon:before {
|
|||
/* Sugested text for privacy policy postbox */
|
||||
.privacy-text-box {
|
||||
margin: 10px 0 0;
|
||||
|
||||
}
|
||||
|
||||
.privacy-text-box-head {
|
||||
border-right: 4px solid #ffb900;
|
||||
border-bottom: 1px solid #e5e5e5;
|
||||
box-shadow: 0 1px 1px rgba(0,0,0,0.04);
|
||||
|
||||
}
|
||||
|
||||
.privacy-text-box .privacy-text-box-head.hndle {
|
||||
|
@ -671,7 +669,6 @@ span.wp-media-buttons-icon:before {
|
|||
.privacy-text-box-body {
|
||||
height: 320px;
|
||||
overflow: auto;
|
||||
|
||||
}
|
||||
|
||||
#privacy-text-box .inside {
|
||||
|
@ -680,15 +677,15 @@ span.wp-media-buttons-icon:before {
|
|||
|
||||
.privacy-text-box h3 {
|
||||
font-size: 1em;
|
||||
margin: 1em 0;
|
||||
margin: 1em 0 0.5em;
|
||||
}
|
||||
|
||||
.privacy-text-section .privacy-text-copy-button {
|
||||
.privacy-text-section .privacy-text-copy {
|
||||
float: left;
|
||||
margin-top: -1.8em;
|
||||
}
|
||||
|
||||
.privacy-text-section {
|
||||
position: relative;
|
||||
padding: 1px 12px 1px 14px;
|
||||
border-top: 1px solid #e3e3e3;
|
||||
border-right: 4px solid transparent;
|
||||
|
@ -704,10 +701,55 @@ span.wp-media-buttons-icon:before {
|
|||
background-color: #fbeaea;
|
||||
}
|
||||
|
||||
.privacy-text-meta {
|
||||
font-size: 11px;
|
||||
color: #555D66;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.closed .privacy-text-box-body {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
11.1 - Custom Fields
|
||||
------------------------------------------------------------------------------*/
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -649,14 +649,12 @@ span.wp-media-buttons-icon:before {
|
|||
/* Sugested text for privacy policy postbox */
|
||||
.privacy-text-box {
|
||||
margin: 10px 0 0;
|
||||
|
||||
}
|
||||
|
||||
.privacy-text-box-head {
|
||||
border-left: 4px solid #ffb900;
|
||||
border-bottom: 1px solid #e5e5e5;
|
||||
box-shadow: 0 1px 1px rgba(0,0,0,0.04);
|
||||
|
||||
}
|
||||
|
||||
.privacy-text-box .privacy-text-box-head.hndle {
|
||||
|
@ -671,7 +669,6 @@ span.wp-media-buttons-icon:before {
|
|||
.privacy-text-box-body {
|
||||
height: 320px;
|
||||
overflow: auto;
|
||||
|
||||
}
|
||||
|
||||
#privacy-text-box .inside {
|
||||
|
@ -680,15 +677,15 @@ span.wp-media-buttons-icon:before {
|
|||
|
||||
.privacy-text-box h3 {
|
||||
font-size: 1em;
|
||||
margin: 1em 0;
|
||||
margin: 1em 0 0.5em;
|
||||
}
|
||||
|
||||
.privacy-text-section .privacy-text-copy-button {
|
||||
.privacy-text-section .privacy-text-copy {
|
||||
float: right;
|
||||
margin-top: -1.8em;
|
||||
}
|
||||
|
||||
.privacy-text-section {
|
||||
position: relative;
|
||||
padding: 1px 14px 1px 12px;
|
||||
border-top: 1px solid #e3e3e3;
|
||||
border-left: 4px solid transparent;
|
||||
|
@ -704,10 +701,55 @@ span.wp-media-buttons-icon:before {
|
|||
background-color: #fbeaea;
|
||||
}
|
||||
|
||||
.privacy-text-meta {
|
||||
font-size: 11px;
|
||||
color: #555D66;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.closed .privacy-text-box-body {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
11.1 - Custom Fields
|
||||
------------------------------------------------------------------------------*/
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1549,6 +1549,8 @@ final class WP_Privacy_Policy_Content {
|
|||
$content = '';
|
||||
$date_format = get_option( 'date_format' );
|
||||
$copy = __( 'Copy' );
|
||||
$more = __( 'Read More' );
|
||||
$less = __( 'Read Less' );
|
||||
|
||||
foreach ( $content_array as $section ) {
|
||||
$class = $meta = '';
|
||||
|
@ -1567,19 +1569,37 @@ final class WP_Privacy_Policy_Content {
|
|||
$meta = sprintf( __( 'Policy text added %s.' ), $date );
|
||||
}
|
||||
|
||||
$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>';
|
||||
$plugin_name = esc_html( $section['plugin_name'] );
|
||||
|
||||
$content .= '<div class="privacy-text-section folded' . $class . '">';
|
||||
$content .= '<h3>' . $plugin_name . '</h3>';
|
||||
|
||||
if ( ! empty( $meta ) ) {
|
||||
$content .= '<span class="privacy-text-meta">' . $meta . '</span>';
|
||||
}
|
||||
|
||||
$content .= '<div class="policy-text">' . $section['policy_text'] . '</div>';
|
||||
$content .= "</div>\n";
|
||||
$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.
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -1589,7 +1609,7 @@ final class WP_Privacy_Policy_Content {
|
|||
<span class="toggle-indicator" aria-hidden="true"></span>
|
||||
</button>
|
||||
<div class="privacy-text-box-head hndle">
|
||||
<h2><?php _e( 'This suggested privacy policy text comes from plugins you have installed.' ); ?></h2>
|
||||
<h2><?php _e( 'This suggested privacy policy text comes from plugins and themes you have installed.' ); ?></h2>
|
||||
<p>
|
||||
<?php _e( 'We suggest reviewing this text then copying and pasting it into your privacy policy page.' ); ?>
|
||||
<?php _e( 'Please remember you are responsible for the policies you choose to adopt, so review the content and make any necessary edits.' ); ?>
|
||||
|
@ -1633,6 +1653,6 @@ final class WP_Privacy_Policy_Content {
|
|||
*/
|
||||
public static function add_suggested_content() {
|
||||
$content = self::get_default_content();
|
||||
wp_add_privacy_policy_content( 'WordPress', $content );
|
||||
wp_add_privacy_policy_content( 'WordPress', $content );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1268,26 +1268,35 @@ jQuery(document).ready( function($) {
|
|||
update();
|
||||
} );
|
||||
|
||||
} )( jQuery, new wp.utils.WordCounter() );
|
||||
|
||||
( function( $ ) {
|
||||
// Privacy policy postbox, copy button.
|
||||
$( document ).on( 'click', function( event ) {
|
||||
var $target = $( event.target );
|
||||
var node, range;
|
||||
|
||||
if ( $target.is( 'button.privacy-text-copy-button' ) ) {
|
||||
node = $target.parent().find( 'div.policy-text' )[0];
|
||||
if ( $target.is( 'button.privacy-text-copy' ) ) {
|
||||
node = $target.parent().parent().find( 'div.policy-text' )[0];
|
||||
|
||||
if ( node ) {
|
||||
try {
|
||||
window.getSelection().removeAllRanges();
|
||||
range = document.createRange();
|
||||
range.selectNode( node );
|
||||
range.selectNodeContents( node );
|
||||
window.getSelection().addRange( range );
|
||||
|
||||
document.execCommand( 'copy' );
|
||||
window.getSelection().removeAllRanges();
|
||||
} catch ( er ) {}
|
||||
}
|
||||
} 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' );
|
||||
}
|
||||
});
|
||||
|
||||
} )( jQuery, new wp.utils.WordCounter() );
|
||||
} )( jQuery );
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.0-alpha-42991';
|
||||
$wp_version = '5.0-alpha-42992';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue