WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/26/2019 08:49:04 PM (7 months ago)
Author:
azaozz
Message:

Privacy tools: Organize privacy functions into logical files and classes.

Props xkon, birgire, desrosj, garrett-eclipse, azaozz.
See #43895.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/misc.php

    r45204 r45448  
    13201320
    13211321/**
    1322  * WP_Privacy_Policy_Content class.
    1323  * TODO: move this to a new file.
    1324  *
    1325  * @since 4.9.6
    1326  */
    1327 final class WP_Privacy_Policy_Content {
    1328 
    1329     private static $policy_content = array();
    1330 
    1331     /**
    1332      * Constructor
    1333      *
    1334      * @since 4.9.6
    1335      */
    1336     private function __construct() {}
    1337 
    1338     /**
    1339      * Add content to the postbox shown when editing the privacy policy.
    1340      *
    1341      * Plugins and themes should suggest text for inclusion in the site's privacy policy.
    1342      * The suggested text should contain information about any functionality that affects user privacy,
    1343      * and will be shown in the Suggested Privacy Policy Content postbox.
    1344      *
    1345      * Intended for use from `wp_add_privacy_policy_content()`.
    1346      *
    1347      * @since 4.9.6
    1348      *
    1349      * @param string $plugin_name The name of the plugin or theme that is suggesting content for the site's privacy policy.
    1350      * @param string $policy_text The suggested content for inclusion in the policy.
    1351      */
    1352     public static function add( $plugin_name, $policy_text ) {
    1353         if ( empty( $plugin_name ) || empty( $policy_text ) ) {
    1354             return;
    1355         }
    1356 
    1357         $data = array(
    1358             'plugin_name' => $plugin_name,
    1359             'policy_text' => $policy_text,
    1360         );
    1361 
    1362         if ( ! in_array( $data, self::$policy_content, true ) ) {
    1363             self::$policy_content[] = $data;
    1364         }
    1365     }
    1366 
    1367     /**
    1368      * Quick check if any privacy info has changed.
    1369      *
    1370      * @since 4.9.6
    1371      */
    1372     public static function text_change_check() {
    1373 
    1374         $policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' );
    1375 
    1376         // The site doesn't have a privacy policy.
    1377         if ( empty( $policy_page_id ) ) {
    1378             return false;
    1379         }
    1380 
    1381         if ( ! current_user_can( 'edit_post', $policy_page_id ) ) {
    1382             return false;
    1383         }
    1384 
    1385         $old = (array) get_post_meta( $policy_page_id, '_wp_suggested_privacy_policy_content' );
    1386 
    1387         // Updates are not relevant if the user has not reviewed any suggestions yet.
    1388         if ( empty( $old ) ) {
    1389             return false;
    1390         }
    1391 
    1392         $cached = get_option( '_wp_suggested_policy_text_has_changed' );
    1393 
    1394         /*
    1395          * When this function is called before `admin_init`, `self::$policy_content`
    1396          * has not been populated yet, so use the cached result from the last
    1397          * execution instead.
    1398          */
    1399         if ( ! did_action( 'admin_init' ) ) {
    1400             return 'changed' === $cached;
    1401         }
    1402 
    1403         $new = self::$policy_content;
    1404 
    1405         // Remove the extra values added to the meta.
    1406         foreach ( $old as $key => $data ) {
    1407             if ( ! empty( $data['removed'] ) ) {
    1408                 unset( $old[ $key ] );
    1409                 continue;
    1410             }
    1411 
    1412             $old[ $key ] = array(
    1413                 'plugin_name' => $data['plugin_name'],
    1414                 'policy_text' => $data['policy_text'],
    1415             );
    1416         }
    1417 
    1418         // Normalize the order of texts, to facilitate comparison.
    1419         sort( $old );
    1420         sort( $new );
    1421 
    1422         // The == operator (equal, not identical) was used intentionally.
    1423         // See http://php.net/manual/en/language.operators.array.php
    1424         if ( $new != $old ) {
    1425             // A plugin was activated or deactivated, or some policy text has changed.
    1426             // Show a notice on the relevant screens to inform the admin.
    1427             add_action( 'admin_notices', array( 'WP_Privacy_Policy_Content', 'policy_text_changed_notice' ) );
    1428             $state = 'changed';
    1429         } else {
    1430             $state = 'not-changed';
    1431         }
    1432 
    1433         // Cache the result for use before `admin_init` (see above).
    1434         if ( $cached !== $state ) {
    1435             update_option( '_wp_suggested_policy_text_has_changed', $state );
    1436         }
    1437 
    1438         return 'changed' === $state;
    1439     }
    1440 
    1441     /**
    1442      * Output a warning when some privacy info has changed.
    1443      *
    1444      * @since 4.9.6
    1445      */
    1446     public static function policy_text_changed_notice() {
    1447         global $post;
    1448 
    1449         $screen = get_current_screen()->id;
    1450 
    1451         if ( 'privacy' !== $screen ) {
    1452             return;
    1453         }
    1454 
    1455         ?>
    1456         <div class="policy-text-updated notice notice-warning is-dismissible">
    1457             <p>
    1458             <?php
    1459                 printf(
    1460                     /* translators: %s: Privacy Policy Guide URL */
    1461                     __( 'The suggested privacy policy text has changed. Please <a href="%s">review the guide</a> and update your privacy policy.' ),
    1462                     esc_url( admin_url( 'tools.php?wp-privacy-policy-guide=1' ) )
    1463                 );
    1464             ?>
    1465             </p>
    1466         </div>
    1467         <?php
    1468     }
    1469 
    1470     /**
    1471      * Update the cached policy info when the policy page is updated.
    1472      *
    1473      * @since 4.9.6
    1474      * @access private
    1475      */
    1476     public static function _policy_page_updated( $post_id ) {
    1477         $policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' );
    1478 
    1479         if ( ! $policy_page_id || $policy_page_id !== (int) $post_id ) {
    1480             return;
    1481         }
    1482 
    1483         // Remove updated|removed status.
    1484         $old          = (array) get_post_meta( $policy_page_id, '_wp_suggested_privacy_policy_content' );
    1485         $done         = array();
    1486         $update_cache = false;
    1487 
    1488         foreach ( $old as $old_key => $old_data ) {
    1489             if ( ! empty( $old_data['removed'] ) ) {
    1490                 // Remove the old policy text.
    1491                 $update_cache = true;
    1492                 continue;
    1493             }
    1494 
    1495             if ( ! empty( $old_data['updated'] ) ) {
    1496                 // 'updated' is now 'added'.
    1497                 $done[]       = array(
    1498                     'plugin_name' => $old_data['plugin_name'],
    1499                     'policy_text' => $old_data['policy_text'],
    1500                     'added'       => $old_data['updated'],
    1501                 );
    1502                 $update_cache = true;
    1503             } else {
    1504                 $done[] = $old_data;
    1505             }
    1506         }
    1507 
    1508         if ( $update_cache ) {
    1509             delete_post_meta( $policy_page_id, '_wp_suggested_privacy_policy_content' );
    1510             // Update the cache.
    1511             foreach ( $done as $data ) {
    1512                 add_post_meta( $policy_page_id, '_wp_suggested_privacy_policy_content', $data );
    1513             }
    1514         }
    1515     }
    1516 
    1517     /**
    1518      * Check for updated, added or removed privacy policy information from plugins.
    1519      *
    1520      * Caches the current info in post_meta of the policy page.
    1521      *
    1522      * @since 4.9.6
    1523      *
    1524      * @return array The privacy policy text/informtion added by core and plugins.
    1525      */
    1526     public static function get_suggested_policy_text() {
    1527         $policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' );
    1528         $checked        = array();
    1529         $time           = time();
    1530         $update_cache   = false;
    1531         $new            = self::$policy_content;
    1532         $old            = array();
    1533 
    1534         if ( $policy_page_id ) {
    1535             $old = (array) get_post_meta( $policy_page_id, '_wp_suggested_privacy_policy_content' );
    1536         }
    1537 
    1538         // Check for no-changes and updates.
    1539         foreach ( $new as $new_key => $new_data ) {
    1540             foreach ( $old as $old_key => $old_data ) {
    1541                 $found = false;
    1542 
    1543                 if ( $new_data['policy_text'] === $old_data['policy_text'] ) {
    1544                     // Use the new plugin name in case it was changed, translated, etc.
    1545                     if ( $old_data['plugin_name'] !== $new_data['plugin_name'] ) {
    1546                         $old_data['plugin_name'] = $new_data['plugin_name'];
    1547                         $update_cache            = true;
    1548                     }
    1549 
    1550                     // A plugin was re-activated.
    1551                     if ( ! empty( $old_data['removed'] ) ) {
    1552                         unset( $old_data['removed'] );
    1553                         $old_data['added'] = $time;
    1554                         $update_cache      = true;
    1555                     }
    1556 
    1557                     $checked[] = $old_data;
    1558                     $found     = true;
    1559                 } elseif ( $new_data['plugin_name'] === $old_data['plugin_name'] ) {
    1560                     // The info for the policy was updated.
    1561                     $checked[] = array(
    1562                         'plugin_name' => $new_data['plugin_name'],
    1563                         'policy_text' => $new_data['policy_text'],
    1564                         'updated'     => $time,
    1565                     );
    1566                     $found     = $update_cache = true;
    1567                 }
    1568 
    1569                 if ( $found ) {
    1570                     unset( $new[ $new_key ], $old[ $old_key ] );
    1571                     continue 2;
    1572                 }
    1573             }
    1574         }
    1575 
    1576         if ( ! empty( $new ) ) {
    1577             // A plugin was activated.
    1578             foreach ( $new as $new_data ) {
    1579                 if ( ! empty( $new_data['plugin_name'] ) && ! empty( $new_data['policy_text'] ) ) {
    1580                     $new_data['added'] = $time;
    1581                     $checked[]         = $new_data;
    1582                 }
    1583             }
    1584             $update_cache = true;
    1585         }
    1586 
    1587         if ( ! empty( $old ) ) {
    1588             // A plugin was deactivated.
    1589             foreach ( $old as $old_data ) {
    1590                 if ( ! empty( $old_data['plugin_name'] ) && ! empty( $old_data['policy_text'] ) ) {
    1591                     $data = array(
    1592                         'plugin_name' => $old_data['plugin_name'],
    1593                         'policy_text' => $old_data['policy_text'],
    1594                         'removed'     => $time,
    1595                     );
    1596 
    1597                     $checked[] = $data;
    1598                 }
    1599             }
    1600             $update_cache = true;
    1601         }
    1602 
    1603         if ( $update_cache && $policy_page_id ) {
    1604             delete_post_meta( $policy_page_id, '_wp_suggested_privacy_policy_content' );
    1605             // Update the cache.
    1606             foreach ( $checked as $data ) {
    1607                 add_post_meta( $policy_page_id, '_wp_suggested_privacy_policy_content', $data );
    1608             }
    1609         }
    1610 
    1611         return $checked;
    1612     }
    1613 
    1614     /**
    1615      * Add a notice with a link to the guide when editing the privacy policy page.
    1616      *
    1617      * @since 4.9.6
    1618      * @since 5.0.0 The $post parameter is now optional.
    1619      *
    1620      * @param WP_Post|null $post The currently edited post. Default null.
    1621      */
    1622     public static function notice( $post = null ) {
    1623         if ( is_null( $post ) ) {
    1624             global $post;
    1625         } else {
    1626             $post = get_post( $post );
    1627         }
    1628 
    1629         if ( ! ( $post instanceof WP_Post ) ) {
    1630             return;
    1631         }
    1632 
    1633         if ( ! current_user_can( 'manage_privacy_options' ) ) {
    1634             return;
    1635         }
    1636 
    1637         $policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' );
    1638 
    1639         if ( ! $policy_page_id || $policy_page_id !== $post->ID ) {
    1640             return;
    1641         }
    1642 
    1643         $message = __( 'Need help putting together your new Privacy Policy page? Check out our guide for recommendations on what content to include, along with policies suggested by your plugins and theme.' );
    1644         $url     = esc_url( admin_url( 'tools.php?wp-privacy-policy-guide=1' ) );
    1645         $label   = __( 'View Privacy Policy Guide.' );
    1646 
    1647         if ( get_current_screen()->is_block_editor() ) {
    1648             wp_enqueue_script( 'wp-notices' );
    1649             $action = array(
    1650                 'url'   => $url,
    1651                 'label' => $label,
    1652             );
    1653             wp_add_inline_script(
    1654                 'wp-notices',
    1655                 sprintf(
    1656                     'wp.data.dispatch( "core/notices" ).createWarningNotice( "%s", { actions: [ %s ], isDismissible: false } )',
    1657                     $message,
    1658                     wp_json_encode( $action )
    1659                 ),
    1660                 'after'
    1661             );
    1662         } else {
    1663             ?>
    1664             <div class="notice notice-warning inline wp-pp-notice">
    1665                 <p>
    1666                 <?php
    1667                 echo $message;
    1668                 printf(
    1669                     ' <a href="%s" target="_blank">%s <span class="screen-reader-text">%s</span></a>',
    1670                     $url,
    1671                     $label,
    1672                     /* translators: accessibility text */
    1673                     __( '(opens in a new tab)' )
    1674                 );
    1675                 ?>
    1676                 </p>
    1677             </div>
    1678             <?php
    1679         }
    1680     }
    1681 
    1682     /**
    1683      * Output the privacy policy guide together with content from the theme and plugins.
    1684      *
    1685      * @since 4.9.6
    1686      */
    1687     public static function privacy_policy_guide() {
    1688 
    1689         $content_array = self::get_suggested_policy_text();
    1690 
    1691         $content       = '';
    1692         $toc           = array( '<li><a href="#wp-privacy-policy-guide-introduction">' . __( 'Introduction' ) . '</a></li>' );
    1693         $date_format   = __( 'F j, Y' );
    1694         $copy          = __( 'Copy this section to clipboard' );
    1695         $return_to_top = '<a href="#" class="return-to-top">' . __( '&uarr; Return to Top' ) . '</a>';
    1696 
    1697         foreach ( $content_array as $section ) {
    1698             $class = $meta = $removed = '';
    1699 
    1700             if ( ! empty( $section['removed'] ) ) {
    1701                 $class = ' text-removed';
    1702                 $date  = date_i18n( $date_format, $section['removed'] );
    1703                 $meta  = sprintf( __( 'Removed %s.' ), $date );
    1704 
    1705                 $removed = __( 'You deactivated this plugin on %s and may no longer need this policy.' );
    1706                 $removed = '<div class="error inline"><p>' . sprintf( $removed, $date ) . '</p></div>';
    1707             } elseif ( ! empty( $section['updated'] ) ) {
    1708                 $class = ' text-updated';
    1709                 $date  = date_i18n( $date_format, $section['updated'] );
    1710                 $meta  = sprintf( __( 'Updated %s.' ), $date );
    1711             }
    1712 
    1713             if ( $meta ) {
    1714                 $meta = '<br><span class="privacy-text-meta">' . $meta . '</span>';
    1715             }
    1716 
    1717             $plugin_name = esc_html( $section['plugin_name'] );
    1718             $toc_id      = 'wp-privacy-policy-guide-' . sanitize_title( $plugin_name );
    1719             $toc[]       = sprintf( '<li><a href="#%1$s">%2$s</a>' . $meta . '</li>', $toc_id, $plugin_name );
    1720 
    1721             $content .= '<div class="privacy-text-section' . $class . '">';
    1722             $content .= '<a id="' . $toc_id . '">&nbsp;</a>';
    1723             /* translators: %s: plugin name */
    1724             $content .= '<h2>' . sprintf( __( 'Source: %s' ), $plugin_name ) . '</h2>';
    1725             $content .= $removed;
    1726 
    1727             $content .= '<div class="policy-text">' . $section['policy_text'] . '</div>';
    1728             $content .= $return_to_top;
    1729 
    1730             if ( empty( $section['removed'] ) ) {
    1731                 $content         .= '<div class="privacy-text-actions">';
    1732                     $content     .= '<button type="button" class="privacy-text-copy button">';
    1733                         $content .= $copy;
    1734                         $content .= '<span class="screen-reader-text">' . sprintf( __( 'Copy suggested policy text from %s.' ), $plugin_name ) . '</span>';
    1735                     $content     .= '</button>';
    1736                 $content         .= '</div>';
    1737             }
    1738 
    1739             $content .= "</div>\n"; // End of .privacy-text-section.
    1740         }
    1741 
    1742         if ( count( $toc ) > 2 ) {
    1743             ?>
    1744             <div  class="privacy-text-box-toc">
    1745                 <p><?php _e( 'Table of Contents' ); ?></p>
    1746                 <ol>
    1747                     <?php echo implode( "\n", $toc ); ?>
    1748                 </ol>
    1749             </div>
    1750             <?php
    1751         }
    1752 
    1753         ?>
    1754         <div class="privacy-text-box">
    1755             <div class="privacy-text-box-head">
    1756                 <a id="wp-privacy-policy-guide-introduction">&nbsp;</a>
    1757                 <h2><?php _e( 'Introduction' ); ?></h2>
    1758                 <p><?php _e( 'Hello,' ); ?></p>
    1759                 <p><?php _e( 'This text template will help you to create your web site&#8217;s privacy policy.' ); ?></p>
    1760                 <p><?php _e( 'We have suggested the sections you will need. Under each section heading you will find a short summary of what information you should provide, which will help you to get started. Some sections include suggested policy content, others will have to be completed with information from your theme and plugins.' ); ?></p>
    1761                 <p><?php _e( 'Please edit your privacy policy content, making sure to delete the summaries, and adding any information from your theme and plugins. Once you publish your policy page, remember to add it to your navigation menu.' ); ?></p>
    1762                 <p><?php _e( 'It is your responsibility to write a comprehensive privacy policy, to make sure it reflects all national and international legal requirements on privacy, and to keep your policy current and accurate.' ); ?></p>
    1763             </div>
    1764 
    1765             <div class="privacy-text-box-body">
    1766                 <?php echo $content; ?>
    1767             </div>
    1768         </div>
    1769         <?php
    1770     }
    1771 
    1772     /**
    1773      * Return the default suggested privacy policy content.
    1774      *
    1775      * @since 4.9.6
    1776      * @since 5.0.0 Added the `$blocks` parameter.
    1777      *
    1778      * @param bool $description Whether to include the descriptions under the section headings. Default false.
    1779      * @param bool $blocks      Whether to format the content for the block editor. Default true.
    1780      * @return string The default policy content.
    1781      */
    1782     public static function get_default_content( $description = false, $blocks = true ) {
    1783         $suggested_text = $description ? '<strong class="privacy-policy-tutorial">' . __( 'Suggested text:' ) . ' </strong>' : '';
    1784         $content        = '';
    1785         $strings        = array();
    1786 
    1787         // Start of the suggested privacy policy text.
    1788         if ( $description ) {
    1789             $strings[] = '<div class="wp-suggested-text">';
    1790         }
    1791 
    1792         /* translators: default privacy policy heading. */
    1793         $strings[] = '<h2>' . __( 'Who we are' ) . '</h2>';
    1794 
    1795         if ( $description ) {
    1796             /* translators: privacy policy tutorial. */
    1797             $strings[] = '<p class="privacy-policy-tutorial">' . __( 'In this section you should note your site URL, as well as the name of the company, organization, or individual behind it, and some accurate contact information.' ) . '</p>';
    1798             /* translators: privacy policy tutorial. */
    1799             $strings[] = '<p class="privacy-policy-tutorial">' . __( 'The amount of information you may be required to show will vary depending on your local or national business regulations. You may, for example, be required to display a physical address, a registered address, or your company registration number.' ) . '</p>';
    1800         }
    1801 
    1802         /* translators: default privacy policy text, %s Site URL. */
    1803         $strings[] = '<p>' . $suggested_text . sprintf( __( 'Our website address is: %s.' ), get_bloginfo( 'url', 'display' ) ) . '</p>';
    1804 
    1805         /* translators: default privacy policy heading. */
    1806         $strings[] = '<h2>' . __( 'What personal data we collect and why we collect it' ) . '</h2>';
    1807 
    1808         if ( $description ) {
    1809             /* translators: privacy policy tutorial. */
    1810             $strings[] = '<p class="privacy-policy-tutorial">' . __( 'In this section you should note what personal data you collect from users and site visitors. This may include personal data, such as name, email address, personal account preferences; transactional data, such as purchase information; and technical data, such as information about cookies.' ) . '</p>';
    1811             /* translators: privacy policy tutorial. */
    1812             $strings[] = '<p class="privacy-policy-tutorial">' . __( 'You should also note any collection and retention of sensitive personal data, such as data concerning health.' ) . '</p>';
    1813             /* translators: privacy policy tutorial. */
    1814             $strings[] = '<p class="privacy-policy-tutorial">' . __( 'In addition to listing what personal data you collect, you need to note why you collect it. These explanations must note either the legal basis for your data collection and retention or the active consent the user has given.' ) . '</p>';
    1815             /* translators: privacy policy tutorial. */
    1816             $strings[] = '<p class="privacy-policy-tutorial">' . __( 'Personal data is not just created by a user&#8217;s interactions with your site. Personal data is also generated from technical processes such as contact forms, comments, cookies, analytics, and third party embeds.' ) . '</p>';
    1817             /* translators: privacy policy tutorial. */
    1818             $strings[] = '<p class="privacy-policy-tutorial">' . __( 'By default WordPress does not collect any personal data about visitors, and only collects the data shown on the User Profile screen from registered users. However some of your plugins may collect personal data. You should add the relevant information below.' ) . '</p>';
    1819         }
    1820 
    1821         /* translators: default privacy policy heading. */
    1822         $strings[] = '<h3>' . __( 'Comments' ) . '</h3>';
    1823 
    1824         if ( $description ) {
    1825             /* translators: privacy policy tutorial. */
    1826             $strings[] = '<p class="privacy-policy-tutorial">' . __( 'In this subsection you should note what information is captured through comments. We have noted the data which WordPress collects by default.' ) . '</p>';
    1827         }
    1828 
    1829         /* translators: default privacy policy text. */
    1830         $strings[] = '<p>' . $suggested_text . __( 'When visitors leave comments on the site we collect the data shown in the comments form, and also the visitor&#8217;s IP address and browser user agent string to help spam detection.' ) . '</p>';
    1831         /* translators: default privacy policy text. */
    1832         $strings[] = '<p>' . __( 'An anonymized string created from your email address (also called a hash) may be provided to the Gravatar service to see if you are using it. The Gravatar service privacy policy is available here: https://automattic.com/privacy/. After approval of your comment, your profile picture is visible to the public in the context of your comment.' ) . '</p>';
    1833 
    1834         /* translators: default privacy policy heading. */
    1835         $strings[] = '<h3>' . __( 'Media' ) . '</h3>';
    1836 
    1837         if ( $description ) {
    1838             /* translators: privacy policy tutorial. */
    1839             $strings[] = '<p class="privacy-policy-tutorial">' . __( 'In this subsection you should note what information may be disclosed by users who can upload media files. All uploaded files are usually publicly accessible.' ) . '</p>';
    1840         }
    1841 
    1842         /* translators: default privacy policy text. */
    1843         $strings[] = '<p>' . $suggested_text . __( 'If you upload images to the website, you should avoid uploading images with embedded location data (EXIF GPS) included. Visitors to the website can download and extract any location data from images on the website.' ) . '</p>';
    1844 
    1845         /* translators: default privacy policy heading. */
    1846         $strings[] = '<h3>' . __( 'Contact forms' ) . '</h3>';
    1847 
    1848         if ( $description ) {
    1849             /* translators: privacy policy tutorial. */
    1850             $strings[] = '<p class="privacy-policy-tutorial">' . __( 'By default, WordPress does not include a contact form. If you use a contact form plugin, use this subsection to note what personal data is captured when someone submits a contact form, and how long you keep it. For example, you may note that you keep contact form submissions for a certain period for customer service purposes, but you do not use the information submitted through them for marketing purposes.' ) . '</p>';
    1851         }
    1852 
    1853         /* translators: default privacy policy heading. */
    1854         $strings[] = '<h3>' . __( 'Cookies' ) . '</h3>';
    1855 
    1856         if ( $description ) {
    1857             /* translators: privacy policy tutorial. */
    1858             $strings[] = '<p class="privacy-policy-tutorial">' . __( 'In this subsection you should list the cookies your web site uses, including those set by your plugins, social media, and analytics. We have provided the cookies which WordPress installs by default.' ) . '</p>';
    1859         }
    1860 
    1861         /* translators: default privacy policy text. */
    1862         $strings[] = '<p>' . $suggested_text . __( 'If you leave a comment on our site you may opt-in to saving your name, email address and website in cookies. These are for your convenience so that you do not have to fill in your details again when you leave another comment. These cookies will last for one year.' ) . '</p>';
    1863         /* translators: default privacy policy text. */
    1864         $strings[] = '<p>' . __( 'If you visit our login page, we will set a temporary cookie to determine if your browser accepts cookies. This cookie contains no personal data and is discarded when you close your browser.' ) . '</p>';
    1865         /* translators: default privacy policy text. */
    1866         $strings[] = '<p>' . __( 'When you log in, we will also set up several cookies to save your login information and your screen display choices. Login cookies last for two days, and screen options cookies last for a year. If you select &quot;Remember Me&quot;, your login will persist for two weeks. If you log out of your account, the login cookies will be removed.' ) . '</p>';
    1867         /* translators: default privacy policy text. */
    1868         $strings[] = '<p>' . __( 'If you edit or publish an article, an additional cookie will be saved in your browser. This cookie includes no personal data and simply indicates the post ID of the article you just edited. It expires after 1 day.' ) . '</p>';
    1869 
    1870         /* translators: default privacy policy heading. */
    1871         $strings[] = '<h3>' . __( 'Embedded content from other websites' ) . '</h3>';
    1872         /* translators: default privacy policy text. */
    1873         $strings[] = '<p>' . $suggested_text . __( 'Articles on this site may include embedded content (e.g. videos, images, articles, etc.). Embedded content from other websites behaves in the exact same way as if the visitor has visited the other website.' ) . '</p>';
    1874         /* translators: default privacy policy text. */
    1875         $strings[] = '<p>' . __( 'These websites may collect data about you, use cookies, embed additional third-party tracking, and monitor your interaction with that embedded content, including tracking your interaction with the embedded content if you have an account and are logged in to that website.' ) . '</p>';
    1876 
    1877         /* translators: default privacy policy heading. */
    1878         $strings[] = '<h3>' . __( 'Analytics' ) . '</h3>';
    1879 
    1880         if ( $description ) {
    1881             /* translators: privacy policy tutorial. */
    1882             $strings[] = '<p class="privacy-policy-tutorial">' . __( 'In this subsection you should note what analytics package you use, how users can opt out of analytics tracking, and a link to your analytics provider&#8217;s privacy policy, if any.' ) . '</p>';
    1883             /* translators: privacy policy tutorial. */
    1884             $strings[] = '<p class="privacy-policy-tutorial">' . __( 'By default WordPress does not collect any analytics data. However, many web hosting accounts collect some anonymous analytics data. You may also have installed a WordPress plugin that provides analytics services. In that case, add information from that plugin here.' ) . '</p>';
    1885         }
    1886 
    1887         /* translators: default privacy policy heading. */
    1888         $strings[] = '<h2>' . __( 'Who we share your data with' ) . '</h2>';
    1889 
    1890         if ( $description ) {
    1891             /* translators: privacy policy tutorial. */
    1892             $strings[] = '<p class="privacy-policy-tutorial">' . __( 'In this section you should name and list all third party providers with whom you share site data, including partners, cloud-based services, payment processors, and third party service providers, and note what data you share with them and why. Link to their own privacy policies if possible.' ) . '</p>';
    1893             /* translators: privacy policy tutorial. */
    1894             $strings[] = '<p class="privacy-policy-tutorial">' . __( 'By default WordPress does not share any personal data with anyone.' ) . '</p>';
    1895         }
    1896 
    1897         /* translators: default privacy policy heading. */
    1898         $strings[] = '<h2>' . __( 'How long we retain your data' ) . '</h2>';
    1899 
    1900         if ( $description ) {
    1901             /* translators: privacy policy tutorial. */
    1902             $strings[] = '<p class="privacy-policy-tutorial">' . __( 'In this section you should explain how long you retain personal data collected or processed by the web site. While it is your responsibility to come up with the schedule of how long you keep each dataset for and why you keep it, that information does need to be listed here. For example, you may want to say that you keep contact form entries for six months, analytics records for a year, and customer purchase records for ten years.' ) . '</p>';
    1903         }
    1904 
    1905         /* translators: default privacy policy text. */
    1906         $strings[] = '<p>' . $suggested_text . __( 'If you leave a comment, the comment and its metadata are retained indefinitely. This is so we can recognize and approve any follow-up comments automatically instead of holding them in a moderation queue.' ) . '</p>';
    1907         /* translators: default privacy policy text. */
    1908         $strings[] = '<p>' . __( 'For users that register on our website (if any), we also store the personal information they provide in their user profile. All users can see, edit, or delete their personal information at any time (except they cannot change their username). Website administrators can also see and edit that information.' ) . '</p>';
    1909 
    1910         /* translators: default privacy policy heading. */
    1911         $strings[] = '<h2>' . __( 'What rights you have over your data' ) . '</h2>';
    1912 
    1913         if ( $description ) {
    1914             /* translators: privacy policy tutorial. */
    1915             $strings[] = '<p class="privacy-policy-tutorial">' . __( 'In this section you should explain what rights your users have over their data and how they can invoke those rights.' ) . '</p>';
    1916         }
    1917 
    1918         /* translators: default privacy policy text. */
    1919         $strings[] = '<p>' . $suggested_text . __( 'If you have an account on this site, or have left comments, you can request to receive an exported file of the personal data we hold about you, including any data you have provided to us. You can also request that we erase any personal data we hold about you. This does not include any data we are obliged to keep for administrative, legal, or security purposes.' ) . '</p>';
    1920 
    1921         /* translators: default privacy policy heading. */
    1922         $strings[] = '<h2>' . __( 'Where we send your data' ) . '</h2>';
    1923 
    1924         if ( $description ) {
    1925             /* translators: privacy policy tutorial. */
    1926             $strings[] = '<p class="privacy-policy-tutorial">' . __( 'In this section you should list all transfers of your site data outside the European Union and describe the means by which that data is safeguarded to European data protection standards. This could include your web hosting, cloud storage, or other third party services.' ) . '</p>';
    1927             /* translators: privacy policy tutorial. */
    1928             $strings[] = '<p class="privacy-policy-tutorial">' . __( 'European data protection law requires data about European residents which is transferred outside the European Union to be safeguarded to the same standards as if the data was in Europe. So in addition to listing where data goes, you should describe how you ensure that these standards are met either by yourself or by your third party providers, whether that is through an agreement such as Privacy Shield, model clauses in your contracts, or binding corporate rules.' ) . '</p>';
    1929         }
    1930 
    1931         /* translators: default privacy policy text. */
    1932         $strings[] = '<p>' . $suggested_text . __( 'Visitor comments may be checked through an automated spam detection service.' ) . '</p>';
    1933 
    1934         /* translators: default privacy policy heading. */
    1935         $strings[] = '<h2>' . __( 'Your contact information' ) . '</h2>';
    1936 
    1937         if ( $description ) {
    1938             /* translators: privacy policy tutorial. */
    1939             $strings[] = '<p class="privacy-policy-tutorial">' . __( 'In this section you should provide a contact method for privacy-specific concerns. If you are required to have a Data Protection Officer, list their name and full contact details here as well.' ) . '</p>';
    1940         }
    1941 
    1942         /* translators: default privacy policy heading. */
    1943         $strings[] = '<h2>' . __( 'Additional information' ) . '</h2>';
    1944 
    1945         if ( $description ) {
    1946             /* translators: privacy policy tutorial. */
    1947             $strings[] = '<p class="privacy-policy-tutorial">' . __( 'If you use your site for commercial purposes and you engage in more complex collection or processing of personal data, you should note the following information in your privacy policy in addition to the information we have already discussed.' ) . '</p>';
    1948         }
    1949 
    1950         /* translators: default privacy policy heading. */
    1951         $strings[] = '<h3>' . __( 'How we protect your data' ) . '</h3>';
    1952 
    1953         if ( $description ) {
    1954             /* translators: privacy policy tutorial. */
    1955             $strings[] = '<p class="privacy-policy-tutorial">' . __( 'In this section you should explain what measures you have taken to protect your users&#8217; data. This could include technical measures such as encryption; security measures such as two factor authentication; and measures such as staff training in data protection. If you have carried out a Privacy Impact Assessment, you can mention it here too.' ) . '</p>';
    1956         }
    1957 
    1958         /* translators: default privacy policy heading. */
    1959         $strings[] = '<h3>' . __( 'What data breach procedures we have in place' ) . '</h3>';
    1960 
    1961         if ( $description ) {
    1962             /* translators: privacy policy tutorial. */
    1963             $strings[] = '<p class="privacy-policy-tutorial">' . __( 'In this section you should explain what procedures you have in place to deal with data breaches, either potential or real, such as internal reporting systems, contact mechanisms, or bug bounties.' ) . '</p>';
    1964         }
    1965 
    1966         /* translators: default privacy policy heading. */
    1967         $strings[] = '<h3>' . __( 'What third parties we receive data from' ) . '</h3>';
    1968 
    1969         if ( $description ) {
    1970             /* translators: privacy policy tutorial. */
    1971             $strings[] = '<p class="privacy-policy-tutorial">' . __( 'If your web site receives data about users from third parties, including advertisers, this information must be included within the section of your privacy policy dealing with third party data.' ) . '</p>';
    1972         }
    1973 
    1974         /* translators: default privacy policy heading. */
    1975         $strings[] = '<h3>' . __( 'What automated decision making and/or profiling we do with user data' ) . '</h3>';
    1976 
    1977         if ( $description ) {
    1978             /* translators: privacy policy tutorial. */
    1979             $strings[] = '<p class="privacy-policy-tutorial">' . __( 'If your web site provides a service which includes automated decision making - for example, allowing customers to apply for credit, or aggregating their data into an advertising profile - you must note that this is taking place, and include information about how that information is used, what decisions are made with that aggregated data, and what rights users have over decisions made without human intervention.' ) . '</p>';
    1980         }
    1981 
    1982         /* translators: default privacy policy heading. */
    1983         $strings[] = '<h3>' . __( 'Industry regulatory disclosure requirements' ) . '</h3>';
    1984 
    1985         if ( $description ) {
    1986             /* translators: privacy policy tutorial. */
    1987             $strings[] = '<p class="privacy-policy-tutorial">' . __( 'If you are a member of a regulated industry, or if you are subject to additional privacy laws, you may be required to disclose that information here.' ) . '</p>';
    1988             $strings[] = '</div>';
    1989         }
    1990 
    1991         if ( $blocks ) {
    1992             foreach ( $strings as $key => $string ) {
    1993                 if ( 0 === strpos( $string, '<p>' ) ) {
    1994                     $strings[ $key ] = '<!-- wp:paragraph -->' . $string . '<!-- /wp:paragraph -->';
    1995                 }
    1996 
    1997                 if ( 0 === strpos( $string, '<h2>' ) ) {
    1998                     $strings[ $key ] = '<!-- wp:heading -->' . $string . '<!-- /wp:heading -->';
    1999                 }
    2000 
    2001                 if ( 0 === strpos( $string, '<h3>' ) ) {
    2002                     $strings[ $key ] = '<!-- wp:heading {"level":3} -->' . $string . '<!-- /wp:heading -->';
    2003                 }
    2004             }
    2005         }
    2006 
    2007         $content = implode( '', $strings );
    2008         // End of the suggested privacy policy text.
    2009 
    2010         /**
    2011          * Filters the default content suggested for inclusion in a privacy policy.
    2012          *
    2013          * @since 4.9.6
    2014          * @since 5.0.0 Added the `$strings`, `$description`, and `$blocks` parameters.
    2015          *
    2016          * @param string $content     The default policy content.
    2017          * @param array  $strings     An array of privacy policy content strings.
    2018          * @param bool   $description Whether policy descriptions should be included.
    2019          * @param bool   $blocks      Whether the content should be formatted for the block editor.
    2020          */
    2021         return apply_filters( 'wp_get_default_privacy_policy_content', $content, $strings, $description, $blocks );
    2022     }
    2023 
    2024     /**
    2025      * Add the suggested privacy policy text to the policy postbox.
    2026      *
    2027      * @since 4.9.6
    2028      */
    2029     public static function add_suggested_content() {
    2030         $content = self::get_default_content( true, false );
    2031         wp_add_privacy_policy_content( __( 'WordPress' ), $content );
    2032     }
    2033 }
    2034 
    2035 /**
    20361322 * Checks if the user needs to update PHP.
    20371323 *
Note: See TracChangeset for help on using the changeset viewer.