Ticket #43620: 43620.4.diff
File 43620.4.diff, 10.3 KB (added by , 6 years ago) |
---|
-
src/wp-admin/css/edit.css
685 685 686 686 .privacy-text-section .privacy-text-copy-button { 687 687 float: right; 688 margin-top: -1.8em;689 688 } 690 689 691 690 .privacy-text-section { … … 692 691 padding: 1px 14px 1px 12px; 693 692 border-top: 1px solid #e3e3e3; 694 693 border-left: 4px solid transparent; 694 position: relative; 695 695 } 696 696 697 .privacy-text-box-body .privacy-text-section:nth-child(odd):not(.text-removed):not(.text-updated) { 698 background-color: #f9f9f9; 699 } 700 697 701 .privacy-text-section.text-updated { 698 702 border-left-color: #46b450; 699 703 background-color: #ecf7ed; … … 704 708 background-color: #fbeaea; 705 709 } 706 710 711 .policy-text, 712 .policy-actions, 707 713 .closed .privacy-text-box-body { 708 714 display: none; 709 715 } 716 .policy-actions.show, 717 .policy-text.show { 718 display: block; 719 } 710 720 721 .privacy-text-meta { 722 font-size: 11px; 723 color: #555D66; 724 font-weight: 600; 725 } 726 727 .policy-text-less { 728 float: left; 729 margin-top: 10px; 730 } 731 732 .policy-text { 733 margin-bottom: 50px; 734 } 735 736 .policy-actions { 737 height: 30px; 738 margin-bottom: 10px; 739 position: absolute; 740 bottom: 0; 741 width: calc( 100% - 30px ); 742 } 743 711 744 /*------------------------------------------------------------------------------ 712 745 11.1 - Custom Fields 713 746 ------------------------------------------------------------------------------*/ -
src/wp-admin/includes/admin-filters.php
137 137 add_action( 'admin_init', array( 'WP_Privacy_Policy_Content', 'text_change_check' ), 20 ); 138 138 139 139 // Show a "postbox" with the text suggestions for a privacy policy. 140 add_action( 'edit_form_after_ title', array( 'WP_Privacy_Policy_Content', 'privacy_policy_postbox' ) );140 add_action( 'edit_form_after_editor', array( 'WP_Privacy_Policy_Content', 'privacy_policy_postbox' ) ); 141 141 142 142 // Add the suggested policy text from WordPress. 143 143 add_action( 'admin_init', array( 'WP_Privacy_Policy_Content', 'add_suggested_content' ), 15 ); -
src/wp-admin/includes/misc.php
1362 1362 1363 1363 ?> 1364 1364 <div class="policy-text-updated notice notice-warning is-dismissible"> 1365 <p><?php 1366 1367 _e( 'The suggested privacy policy text has changed.' ); 1368 1369 if ( empty( $post ) || $post->ID != $policy_page_id ) { 1370 ?> 1371 <a href="<?php echo get_edit_post_link( $policy_page_id ); ?>"><?php _e( 'Edit the privacy policy.' ); ?></a> 1372 <?php 1373 } 1374 1375 ?></p> 1365 <p> 1366 <?php 1367 _e( 'The suggested privacy policy text has changed.' ); 1368 if ( empty( $post ) || $post->ID != $policy_page_id ) { 1369 ?> 1370 <a href="<?php echo get_edit_post_link( $policy_page_id ); ?>"><?php _e( 'Edit the privacy policy.' ); ?></a> 1371 <?php 1372 } 1373 ?> 1374 </p> 1376 1375 </div> 1377 1376 <?php 1378 1377 } … … 1395 1394 update_option( '_wp_privacy_text_change_check', 'no-check' ); 1396 1395 1397 1396 // Remove updated|removed status. 1398 $old = (array) get_post_meta( $policy_page_id, '_wp_suggested_privacy_policy_content' );1399 $done = array();1397 $old = (array) get_post_meta( $policy_page_id, '_wp_suggested_privacy_policy_content' ); 1398 $done = array(); 1400 1399 $update_cache = false; 1401 1400 1402 1401 foreach ( $old as $old_key => $old_data ) { … … 1439 1438 */ 1440 1439 public static function get_suggested_policy_text() { 1441 1440 $policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' ); 1442 $new = self::$policy_content;1443 $old = (array) get_post_meta( $policy_page_id, '_wp_suggested_privacy_policy_content' );1444 $checked = array();1445 $time = time();1446 $update_cache = false;1441 $new = self::$policy_content; 1442 $old = (array) get_post_meta( $policy_page_id, '_wp_suggested_privacy_policy_content' ); 1443 $checked = array(); 1444 $time = time(); 1445 $update_cache = false; 1447 1446 1448 1447 // Check for no-changes and updates. 1449 1448 foreach ( $new as $new_key => $new_data ) { … … 1546 1545 1547 1546 $content_array = self::get_suggested_policy_text(); 1548 1547 1549 $content = '';1548 $content = ''; 1550 1549 $date_format = get_option( 'date_format' ); 1551 $copy = __( 'Copy' );1550 $copy = __( 'Copy' ); 1552 1551 1553 1552 foreach ( $content_array as $section ) { 1554 1553 $class = $meta = ''; … … 1555 1554 1556 1555 if ( ! empty( $section['removed'] ) ) { 1557 1556 $class = ' text-removed'; 1558 $date = date_i18n( $date_format, $section['removed'] ); 1559 $meta = sprintf( __( 'Policy text removed %s.' ), $date ); 1557 $date = date_i18n( $date_format, $section['removed'] ); 1558 // translators: %s date. 1559 $meta = sprintf( __( 'Policy text removed %s.' ), $date ); 1560 1560 } elseif ( ! empty( $section['updated'] ) ) { 1561 1561 $class = ' text-updated'; 1562 $date = date_i18n( $date_format, $section['updated'] ); 1563 $meta = sprintf( __( 'Policy text last updated %s.' ), $date ); 1562 $date = date_i18n( $date_format, $section['updated'] ); 1563 // translators: %s date. 1564 $meta = sprintf( __( 'Policy text last updated %s.' ), $date ); 1564 1565 } elseif ( ! empty( $section['added'] ) ) { 1565 1566 $class = ' text-added'; 1566 $date = date_i18n( $date_format, $section['added'] ); 1567 $meta = sprintf( __( 'Policy text added %s.' ), $date ); 1567 $date = date_i18n( $date_format, $section['added'] ); 1568 // translators: %s date. 1569 $meta = sprintf( __( 'Policy text added %s.' ), $date ); 1568 1570 } 1569 1571 1570 1572 $content .= '<div class="privacy-text-section' . $class . '">'; 1571 1573 $content .= '<h3>' . $section['plugin_name'] . '</h3>'; 1572 $content .= '<button type="button" class="privacy-text-copy-button button">';1573 $content .= $copy;1574 $content .= '<span class="screen-reader-text">' . sprintf( __( 'Copy suggested policy text from %s.' ), $section['plugin_name'] ) . '</span>';1575 $content .= '</button>';1576 1574 1577 1575 if ( ! empty( $meta ) ) { 1578 1576 $content .= '<span class="privacy-text-meta">' . $meta . '</span>'; 1579 1577 } 1580 1578 1581 $content .= '<div class="policy-text">' . $section['policy_text'] . '</div>'; 1579 if ( strlen( $section['policy_text'] ) >= 400 ) { 1580 $content .= '<div class="policy-actions">'; 1581 $content .= '<a href="#" class="policy-text-less">' . __( 'Read Less' ) . '</a>'; 1582 $content .= '<button type="button" class="privacy-text-copy-button button">'; 1583 $content .= $copy; 1584 // translators: %s plugin name. 1585 $content .= '<span class="screen-reader-text">' . sprintf( __( 'Copy suggested policy text from %s.' ), $section['plugin_name'] ) . '</span>'; 1586 $content .= '</button>'; 1587 $content .= '</div>'; 1588 $content .= '<div class="policy-text">' . $section['policy_text'] . '</div>'; 1589 $content .= '<div class="policy-text-excerpt">' . substr( $section['policy_text'], 0, 400 ) . '…</div><p><a href="#" class="policy-text-more">' . __( 'Read More' ) . '</a></p>'; 1590 } else { 1591 $content .= '<div class="policy-actions show">'; 1592 $content .= '<button type="button" class="privacy-text-copy-button button">'; 1593 $content .= $copy; 1594 // translators: %s plugin name. 1595 $content .= '<span class="screen-reader-text">' . sprintf( __( 'Copy suggested policy text from %s.' ), $section['plugin_name'] ) . '</span>'; 1596 $content .= '</button>'; 1597 $content .= '</div>'; 1598 $content .= '<div class="policy-text show">' . $section['policy_text'] . '</div>'; 1599 } 1600 1582 1601 $content .= "</div>\n"; 1583 1602 } 1584 1603 … … 1589 1608 <span class="toggle-indicator" aria-hidden="true"></span> 1590 1609 </button> 1591 1610 <div class="privacy-text-box-head hndle"> 1592 <h2><?php _e( 'This suggested privacy policy text comes from plugins you have installed.' ); ?></h2>1611 <h2><?php _e( 'This suggested privacy policy text comes from plugins & themes you have installed.' ); ?></h2> 1593 1612 <p> 1594 1613 <?php _e( 'We suggest reviewing this text then copying and pasting it into your privacy policy page.' ); ?> 1595 1614 <?php _e( 'Please remember you are responsible for the policies you choose to adopt, so review the content and make any necessary edits.' ); ?> … … 1606 1625 /** 1607 1626 * Return the default suggested privacy policy content. 1608 1627 * 1609 * @since 4.9.6 1628 * @since 4.9.6 1610 1629 * 1611 1630 * @return string The defauld policy content. 1612 1631 */ … … 1633 1652 */ 1634 1653 public static function add_suggested_content() { 1635 1654 $content = self::get_default_content(); 1636 wp_add_privacy_policy_content( 1655 wp_add_privacy_policy_content( 'WordPress', $content ); 1637 1656 } 1638 1657 } -
src/wp-admin/js/post.js
1268 1268 update(); 1269 1269 } ); 1270 1270 1271 // Privacy policy postbox, copy button. 1271 } )( jQuery, new wp.utils.WordCounter() ); 1272 1273 1274 // Privacy policy postbox, copy button, policy text read more, policy text read less. 1275 ( function( $ ) { 1276 1272 1277 $( document ).on( 'click', function( event ) { 1273 1278 var $target = $( event.target ); 1274 1279 var node, range; 1275 1280 1276 1281 if ( $target.is( 'button.privacy-text-copy-button' ) ) { 1277 node = $target.parent(). find( 'div.policy-text' )[0];1282 node = $target.parent().parent().find( 'div.policy-text' )[0]; 1278 1283 1279 1284 if ( node ) { 1280 1285 try { 1281 1286 window.getSelection().removeAllRanges(); 1282 range = document.createRange(); 1283 range.selectNode( node ); 1287 range = document.createRange(); 1288 range.selectNode( node ); 1284 1289 window.getSelection().addRange( range ); 1285 1290 1286 1291 document.execCommand( 'copy' ); … … 1288 1293 } catch ( er ) {} 1289 1294 } 1290 1295 } 1296 1297 if ( $target.is( 'a.policy-text-more' ) ) { 1298 event.preventDefault(); 1299 $target.toggle(); 1300 $target.parent().siblings('div.policy-text').toggle(); 1301 $target.parent().siblings('div.policy-text-excerpt').toggle(); 1302 $target.parent().parent().find('div.policy-actions').toggle(); 1303 } 1304 1305 if ( $target.is( 'a.policy-text-less' ) ) { 1306 event.preventDefault(); 1307 $target.parent().toggle(); 1308 $target.parent().siblings( 'div.policy-text' ).toggle(); 1309 $target.parent().siblings('div.policy-text-excerpt').toggle(); 1310 $target.parent().parent().find('a.policy-text-more').toggle(); 1311 $target.parent().find('div.policy-actions').toggle(); 1312 } 1291 1313 }); 1292 1314 1293 } )( jQuery , new wp.utils.WordCounter());1315 } )( jQuery );