Make WordPress Core


Ignore:
Timestamp:
04/12/2020 02:24:38 PM (6 years ago)
Author:
SergeyBiryukov
Message:

Privacy: Add an indication when the Copy action in Privacy Policy Guide is complete.

This adds a "Copied!" text near the "Copy this section to clipboard" button to provide direct feedback that the action was completed.

Props garrett-eclipse, nickylimjj, xkon, desrosj, birgire.
Fixes #44588.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-privacy-policy-content.php

    r47284 r47572  
    373373
    374374                $content_array = self::get_suggested_policy_text();
    375 
    376375                $content       = '';
    377376                $toc           = array( '<li><a href="#wp-privacy-policy-guide-introduction">' . __( 'Introduction' ) . '</a></li>' );
    378377                $date_format   = __( 'F j, Y' );
    379                 $copy          = __( 'Copy this section to clipboard' );
    380                 $return_to_top = '<a href="#" class="return-to-top">' . __( '&uarr; Return to Top' ) . '</a>';
    381378
    382379                foreach ( $content_array as $section ) {
     
    386383
    387384                        if ( ! empty( $section['removed'] ) ) {
    388                                 $class = ' text-removed';
     385                                $class = 'text-removed';
    389386                                $date  = date_i18n( $date_format, $section['removed'] );
    390387                                /* translators: %s: Date of plugin deactivation. */
     
    395392                                $removed = '<div class="error inline"><p>' . sprintf( $removed, $date ) . '</p></div>';
    396393                        } elseif ( ! empty( $section['updated'] ) ) {
    397                                 $class = ' text-updated';
     394                                $class = 'text-updated';
    398395                                $date  = date_i18n( $date_format, $section['updated'] );
    399396                                /* translators: %s: Date of privacy policy text update. */
     
    409406                        $toc[]       = sprintf( '<li><a href="#%1$s">%2$s</a>' . $meta . '</li>', $toc_id, $plugin_name );
    410407
    411                         $content .= '<div class="privacy-text-section' . $class . '">';
     408                        $content .= '<div class="privacy-text-section ' . $class . '">';
    412409                        $content .= '<a id="' . $toc_id . '">&nbsp;</a>';
    413410                        /* translators: %s: Plugin name. */
     
    416413
    417414                        $content .= '<div class="policy-text">' . $section['policy_text'] . '</div>';
    418                         $content .= $return_to_top;
     415                        $content .= '<a href="#" class="return-to-top">' . __( '&uarr; Return to Top' ) . '</a>';
    419416
    420417                        if ( empty( $section['removed'] ) ) {
    421                                 $content         .= '<div class="privacy-text-actions">';
    422                                         $content     .= '<button type="button" class="privacy-text-copy button">';
    423                                                 $content .= $copy;
    424                                                 $content .= '<span class="screen-reader-text">';
    425                                                 /* translators: %s: Plugin name. */
    426                                                 $content .= sprintf( __( 'Copy suggested policy text from %s.' ), $plugin_name );
    427                                                 $content .= '</span>';
    428                                         $content     .= '</button>';
    429                                 $content         .= '</div>';
    430                         }
    431 
    432                         $content .= "</div>\n"; // End of .privacy-text-section.
     418                                $content .= '<div class="privacy-text-actions">';
     419                                $content .= '<button type="button" class="privacy-text-copy button">';
     420                                $content .= __( 'Copy this section to clipboard' );
     421                                $content .= '<span class="screen-reader-text">';
     422                                /* translators: %s: Plugin name. */
     423                                $content .= sprintf( __( 'Copy suggested policy text from %s.' ), $plugin_name );
     424                                $content .= '</span>';
     425                                $content .= '</button>';
     426                                $content .= '<span class="success" aria-hidden="true">' . __( 'Copied!' ) . '</span>';
     427                                $content .= '</div>';
     428                        }
     429
     430                        $content .= '</div>'; // End of .privacy-text-section.
    433431                }
    434432
    435433                if ( count( $toc ) > 2 ) {
    436434                        ?>
    437                         <div  class="privacy-text-box-toc">
     435                        <div class="privacy-text-box-toc">
    438436                                <p><?php _e( 'Table of Contents' ); ?></p>
    439437                                <ol>
    440                                         <?php echo implode( "\n", $toc ); ?>
     438                                        <?php echo implode( $toc ); ?>
    441439                                </ol>
    442440                        </div>
Note: See TracChangeset for help on using the changeset viewer.