Make WordPress Core


Ignore:
Timestamp:
05/02/2018 03:53:15 AM (8 years ago)
Author:
SergeyBiryukov
Message:

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.
Merges [42992] to the 4.9 branch.
See #43620.

Location:
branches/4.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9

  • branches/4.9/src/wp-admin/includes/misc.php

    r43112 r43113  
    15011501                $date_format = get_option( 'date_format' );
    15021502                $copy = __( 'Copy' );
     1503                $more = __( 'Read More' );
     1504                $less = __( 'Read Less' );
    15031505
    15041506                foreach ( $content_array as $section ) {
    … …  
    15191521                        }
    15201522
    1521                         $content .= '<div class="privacy-text-section' . $class . '">';
    1522                         $content .= '<h3>' . $section['plugin_name'] . '</h3>';
    1523                         $content .= '<button type="button" class="privacy-text-copy-button button">';
    1524                         $content .= $copy;
    1525                         $content .= '<span class="screen-reader-text">' . sprintf( __( 'Copy suggested policy text from %s.' ), $section['plugin_name'] ) . '</span>';
    1526                         $content .= '</button>';
     1523                        $plugin_name = esc_html( $section['plugin_name'] );
     1524
     1525                        $content .= '<div class="privacy-text-section folded' . $class . '">';
     1526                        $content .= '<h3>' . $plugin_name . '</h3>';
    15271527
    15281528                        if ( ! empty( $meta ) ) {
    … …  
    15301530                        }
    15311531
    1532                         $content .= '<div class="policy-text">' . $section['policy_text'] . '</div>';
    1533                         $content .= "</div>\n";
     1532                        $content .= '<div class="policy-text" aria-expanded="false">' . $section['policy_text'] . '</div>';
     1533
     1534                        $content .= '<div class="privacy-text-actions">';
     1535                                $content .= '<button type="button" class="button-link policy-text-more">';
     1536                                        $content .= $more;
     1537                                        $content .= '<span class="screen-reader-text">' . sprintf( __( 'Expand suggested policy text section from %s.' ), $plugin_name ) . '</span>';
     1538                                $content .= '</button>';
     1539
     1540                                $content .= '<button type="button" class="button-link policy-text-less">';
     1541                                        $content .= $less;
     1542                                        $content .= '<span class="screen-reader-text">' . sprintf( __( 'Collapse suggested policy text section from %s.' ), $plugin_name ) . '</span>';
     1543                                $content .= '</button>';
     1544
     1545                                if ( empty( $section['removed'] ) ) {
     1546                                        $content .= '<button type="button" class="privacy-text-copy button">';
     1547                                                $content .= $copy;
     1548                                                $content .= '<span class="screen-reader-text">' . sprintf( __( 'Copy suggested policy text from %s.' ), $plugin_name ) . '</span>';
     1549                                        $content .= '</button>';
     1550                                }
     1551
     1552                        $content .= '</div>'; // End of .privacy-text-actions.
     1553                        $content .= "</div>\n"; // End of .privacy-text-section.
    15341554                }
    15351555
    … …  
    15411561                        </button>
    15421562                        <div class="privacy-text-box-head hndle">
    1543                                 <h2><?php _e( 'This suggested privacy policy text comes from plugins you have installed.' ); ?></h2>
     1563                                <h2><?php _e( 'This suggested privacy policy text comes from plugins and themes you have installed.' ); ?></h2>
    15441564                                <p>
    15451565                                        <?php _e( 'We suggest reviewing this text then copying and pasting it into your privacy policy page.' ); ?>
    … …  
    15581578         * Return the default suggested privacy policy content.
    15591579         *
    1560          * @since 4.9.6         
     1580         * @since 4.9.6
    15611581         *
    15621582         * @return string The defauld policy content.
    … …  
    15851605        public static function add_suggested_content() {
    15861606                $content = self::get_default_content();
    1587                 wp_add_privacy_policy_content(  'WordPress', $content );
    1588         }
    1589 }
     1607                wp_add_privacy_policy_content( 'WordPress', $content );
     1608        }
     1609}
Note: See TracChangeset for help on using the changeset viewer.