diff --git a/src/wp-admin/css/edit.css b/src/wp-admin/css/edit.css index f237d02eb1..4587e31c65 100644 --- a/src/wp-admin/css/edit.css +++ b/src/wp-admin/css/edit.css @@ -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 ------------------------------------------------------------------------------*/ diff --git a/src/wp-admin/includes/misc.php b/src/wp-admin/includes/misc.php index 99967448ba..9732c43cee 100644 --- a/src/wp-admin/includes/misc.php +++ b/src/wp-admin/includes/misc.php @@ -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 .= '
'; - $content .= '

' . $section['plugin_name'] . '

'; - $content .= ''; + $plugin_name = esc_html( $section['plugin_name'] ); + + $content .= '
'; + $content .= '

' . $plugin_name . '

'; if ( ! empty( $meta ) ) { $content .= '' . $meta . ''; } - $content .= '
' . $section['policy_text'] . '
'; - $content .= "
\n"; + $content .= ''; + + $content .= '
'; + $content .= ''; + + $content .= ''; + + if ( empty( $section['removed'] ) ) { + $content .= ''; + } + + $content .= '
'; // End of .privacy-text-actions. + $content .= "
\n"; // End of .privacy-text-section. } ?> @@ -1589,7 +1609,7 @@ final class WP_Privacy_Policy_Content {
-

+

@@ -1606,7 +1626,7 @@ final class WP_Privacy_Policy_Content { /** * Return the default suggested privacy policy content. * - * @since 4.9.6 + * @since 4.9.6 * * @return string The defauld policy content. */ @@ -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 ); } } diff --git a/src/wp-admin/js/post.js b/src/wp-admin/js/post.js index 2f1f9509bb..fafcf66b1b 100644 --- a/src/wp-admin/js/post.js +++ b/src/wp-admin/js/post.js @@ -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 = document.createRange(); + 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 );