Add Privacy Tools admin page under the Tools menu.

Props allendav, xkon, azaozz.
See #43435.
Built from https://develop.svn.wordpress.org/trunk@42814


git-svn-id: http://core.svn.wordpress.org/trunk@42644 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2018-03-09 15:04:33 +00:00
parent 051dd178b3
commit b93dfd3571
6 changed files with 200 additions and 25 deletions

View File

@ -27,7 +27,7 @@ include( ABSPATH . 'wp-admin/admin-header.php' );
<a href="about.php" class="nav-tab nav-tab-active"><?php _e( 'What&#8217;s New' ); ?></a>
<a href="credits.php" class="nav-tab"><?php _e( 'Credits' ); ?></a>
<a href="freedoms.php" class="nav-tab"><?php _e( 'Freedoms' ); ?></a>
<a href="privacy.php" class="nav-tab"><?php _e( 'Privacy' ); ?></a>
<a href="freedoms.php?privacy-notice" class="nav-tab"><?php _e( 'Privacy' ); ?></a>
</h2>
<div class="feature-section one-col">

View File

@ -28,7 +28,7 @@ include( ABSPATH . 'wp-admin/admin-header.php' );
<a href="about.php" class="nav-tab"><?php _e( 'What&#8217;s New' ); ?></a>
<a href="credits.php" class="nav-tab nav-tab-active"><?php _e( 'Credits' ); ?></a>
<a href="freedoms.php" class="nav-tab"><?php _e( 'Freedoms' ); ?></a>
<a href="privacy.php" class="nav-tab"><?php _e( 'Privacy' ); ?></a>
<a href="freedoms.php?privacy-notice" class="nav-tab"><?php _e( 'Privacy' ); ?></a>
</h2>
<div class="about-wrap-content">

View File

@ -14,6 +14,9 @@ $title = __( 'Freedoms' );
list( $display_version ) = explode( '-', get_bloginfo( 'version' ) );
include( ABSPATH . 'wp-admin/admin-header.php' );
$is_privacy_notice = isset( $_GET['privacy-notice'] );
?>
<div class="wrap about-wrap full-width-layout">
@ -26,10 +29,21 @@ include( ABSPATH . 'wp-admin/admin-header.php' );
<h2 class="nav-tab-wrapper wp-clearfix">
<a href="about.php" class="nav-tab"><?php _e( 'What&#8217;s New' ); ?></a>
<a href="credits.php" class="nav-tab"><?php _e( 'Credits' ); ?></a>
<a href="freedoms.php" class="nav-tab nav-tab-active"><?php _e( 'Freedoms' ); ?></a>
<a href="privacy.php" class="nav-tab"><?php _e( 'Privacy' ); ?></a>
<a href="freedoms.php" class="nav-tab<?php if ( ! $is_privacy_notice ) { echo ' nav-tab-active'; } ?>"><?php _e( 'Freedoms' ); ?></a>
<a href="freedoms.php?privacy-notice" class="nav-tab<?php if ( $is_privacy_notice ) { echo ' nav-tab-active'; } ?>"><?php _e( 'Privacy' ); ?></a>
</h2>
<?php if ( $is_privacy_notice ) : ?>
<div class="about-wrap-content">
<p class="about-description"><?php _e( 'From time to time, your WordPress site may send data to WordPress.org &#8212; including, but not limited to &#8212; the version of WordPress you are using, and a list of installed plugins and themes.' ); ?></p>
<p><?php printf( __( 'This data is used to provide general enhancements to WordPress, which includes helping to protect your site by finding and automatically installing new updates. It is also used to calculate statistics, such as those shown on the <a href="%s">WordPress.org stats page</a>.' ), 'https://wordpress.org/about/stats/' ); ?></p>
<p><?php printf( __( 'We take privacy and transparency very seriously. To learn more about what data we collect, and how we use it, please visit <a href="%s">WordPress.org/about/privacy</a>.' ), 'https://wordpress.org/about/privacy/' ); ?></p>
</div>
<?php else : ?>
<div class="about-wrap-content">
<p class="about-description"><?php printf( __( 'WordPress is Free and open source software, built by a distributed community of mostly volunteer developers from around the world. WordPress comes with some awesome, worldview-changing rights courtesy of its <a href="%s">license</a>, the GPL.' ), 'https://wordpress.org/about/license/' ); ?></p>
@ -55,5 +69,6 @@ include( ABSPATH . 'wp-admin/admin-header.php' );
<p><?php _e( 'Don&#8217;t you wish all software came with these freedoms? So do we! For more information, check out the <a href="https://www.fsf.org/">Free Software Foundation</a>.' ); ?></p>
</div>
<?php endif; ?>
</div>
<?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?>

View File

@ -256,6 +256,7 @@ $menu[75] = array( __( 'Tools' ), 'edit_posts', 'tools.php',
$submenu['tools.php'][5] = array( __( 'Available Tools' ), 'edit_posts', 'tools.php' );
$submenu['tools.php'][10] = array( __( 'Import' ), 'import', 'import.php' );
$submenu['tools.php'][15] = array( __( 'Export' ), 'export', 'export.php' );
$submenu['tools.php'][20] = array( __( 'Privacy' ), 'manage_options', 'privacy.php' );
if ( is_multisite() && ! is_main_site() ) {
$submenu['tools.php'][25] = array( __( 'Delete Site' ), 'delete_site', 'ms-delete-site.php' );
}

View File

@ -1,6 +1,6 @@
<?php
/**
* Privacy administration panel.
* Privacy Tools Screen.
*
* @package WordPress
* @subpackage Administration
@ -9,34 +9,193 @@
/** WordPress Administration Bootstrap */
require_once( dirname( __FILE__ ) . '/admin.php' );
$title = __( 'Privacy' );
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( __( 'Sorry, you are not allowed to manage privacy on this site.' ) );
}
list( $display_version ) = explode( '-', get_bloginfo( 'version' ) );
// "Borrow" xfn.js for now so we don't have to create new files.
// wp_enqueue_script( 'xfn' );
$action = isset( $_POST['action'] ) ? $_POST['action'] : '';
if ( ! empty( $action ) ) {
check_admin_referer( $action );
if ( 'set-privacy-page' === $action ) {
$privacy_policy_page_id = isset( $_POST['page_for_privacy_policy'] ) ? (int) $_POST['page_for_privacy_policy'] : 0;
update_option( 'wp_page_for_privacy_policy', $privacy_policy_page_id );
add_settings_error(
'page_for_privacy_policy',
'page_for_privacy_policy',
__( 'Privacy policy page updated successfully.' ),
'updated'
);
} elseif ( 'create-privacy-page' === $action ) {
$privacy_policy_page_id = wp_insert_post(
array(
'post_title' => __( 'Privacy Policy' ),
'post_status' => 'draft',
'post_type' => 'page',
),
true
);
if ( is_wp_error( $privacy_policy_page_id ) ) {
add_settings_error(
'page_for_privacy_policy',
'page_for_privacy_policy',
__( 'Unable to create privacy policy page.' ),
'error'
);
} else {
update_option( 'wp_page_for_privacy_policy', $privacy_policy_page_id );
add_settings_error(
'page_for_privacy_policy',
'page_for_privacy_policy',
__( 'Privacy policy page created successfully.' ),
'updated'
);
}
}
}
// If a privacy policy page ID is available, make sure the page actually exists. If not, display a warning
$privacy_policy_page_exists = false;
$privacy_policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' );
if ( ! empty( $privacy_policy_page_id ) ) {
$privacy_policy_page = get_post( $privacy_policy_page_id );
if ( ! $privacy_policy_page instanceof WP_Post ) {
add_settings_error(
'page_for_privacy_policy',
'page_for_privacy_policy',
__( 'The currently selected privacy policy page does not exist. Please create or select new page.' ),
'warning'
);
} else {
if ( 'trash' === $privacy_policy_page->post_status ) {
add_settings_error(
'page_for_privacy_policy',
'page_for_privacy_policy',
sprintf(
__( 'The currently selected privacy policy page is in the trash. Please create or select new privacy policy page or <a href="%s">restore the current page</a>.' ),
'edit.php?post_status=trash&post_type=page'
),
'error'
);
} else {
$privacy_policy_page_exists = true;
}
}
}
$title = __( 'Privacy Tools' );
get_current_screen()->add_help_tab( array(
'id' => 'privacy',
'title' => __( 'Privacy' ),
'content' => '<p>' . __( 'This page provides tools with which you can manage your user\'s personal data and site\'s privacy policy.' ) . '</p>',
) );
get_current_screen()->set_help_sidebar(
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
'<p>' . __( '<a href="#">Documentation on privacy</a>' ) . '</p>'
);
require_once( ABSPATH . 'wp-admin/admin-header.php' );
include( ABSPATH . 'wp-admin/admin-header.php' );
?>
<div class="wrap about-wrap full-width-layout">
<div class="wrap">
<h1><?php echo esc_html( $title ); ?></h1>
<?php settings_errors(); ?>
<h1><?php printf( __( 'Welcome to WordPress %s' ), $display_version ); ?></h1>
<h2 class="title"><?php _e( 'Privacy policy page' ); ?></h2>
<table class="form-table">
<?php
<p class="about-text"><?php printf( __( 'Thank you for updating to the latest version! WordPress %s will smooth your design workflow and keep you safe from coding errors.' ), $display_version ); ?></p>
if ( $privacy_policy_page_exists ) {
$edit_href = add_query_arg(
array(
'post' => $privacy_policy_page_id,
'action' => 'edit',
),
admin_url( 'post.php' )
);
$view_href = get_permalink( $privacy_policy_page_id );
<div class="wp-badge"><?php printf( __( 'Version %s' ), $display_version ); ?></div>
?>
<tr>
<th colspan="2">
<?php
printf(
__( '<a href="%1$s">Edit</a> or <a href="%2$s">view</a> your privacy policy.' ),
$edit_href,
$view_href
);
?>
</th>
</tr>
<?php
}
<h2 class="nav-tab-wrapper wp-clearfix">
<a href="about.php" class="nav-tab"><?php _e( 'What&#8217;s New' ); ?></a>
<a href="credits.php" class="nav-tab"><?php _e( 'Credits' ); ?></a>
<a href="freedoms.php" class="nav-tab"><?php _e( 'Freedoms' ); ?></a>
<a href="privacy.php" class="nav-tab nav-tab-active"><?php _e( 'Privacy' ); ?></a>
</h2>
?>
<tr>
<th scope="row">
<?php
<div class="about-wrap-content">
<p class="about-description"><?php _e( 'From time to time, your WordPress site may send data to WordPress.org &#8212; including, but not limited to &#8212; the version of WordPress you are using, and a list of installed plugins and themes.' ); ?></p>
if ( $privacy_policy_page_exists ) {
_e( 'Select another page for your privacy policy' );
} else {
_e( 'Select an existing privacy policy page' );
}
<p><?php printf( __( 'This data is used to provide general enhancements to WordPress, which includes helping to protect your site by finding and automatically installing new updates. It is also used to calculate statistics, such as those shown on the <a href="%s">WordPress.org stats page</a>.' ), 'https://wordpress.org/about/stats/' ); ?></p>
?>
</th>
<td id="front-static-pages">
<form method="post" action="">
<?php wp_nonce_field( 'set-privacy-page' ); ?>
<input type="hidden" name="action" value="set-privacy-page" />
<fieldset>
<legend class="screen-reader-text"><span><?php _e( 'Select your privacy policy page.' ); ?></span></legend>
<label for="page_for_privacy_policy">
<?php wp_dropdown_pages(
array(
'name' => 'page_for_privacy_policy',
'show_option_none' => __( '&mdash; Select &mdash;' ),
'option_none_value' => '0',
'selected' => $privacy_policy_page_id,
'post_status' => array( 'draft', 'publish' ),
)
);
?>
</label>
</fieldset>
<?php submit_button( __( 'Set Page' ) ); ?>
</form>
</td>
</tr>
<?php
<p><?php printf( __( 'We take privacy and transparency very seriously. To learn more about what data we collect, and how we use it, please visit <a href="%s">WordPress.org/about/privacy</a>.' ), 'https://wordpress.org/about/privacy/' ); ?></p>
if ( ! $privacy_policy_page_exists ) {
?>
<tr>
<th scope="row"><?php _e( 'Create new page for your privacy policy' ); ?></th>
<td>
<form method="post" action="">
<input type="hidden" name="action" value="create-privacy-page" />
<?php wp_nonce_field( 'create-privacy-page' ); ?>
<?php submit_button( __( 'Create Page' ) ); ?>
</form>
</td>
</tr>
<?php
}
?>
</table>
</div>
</div>
<?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?>
<?php
include( ABSPATH . 'wp-admin/admin-footer.php' );

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.0-alpha-42812';
$wp_version = '5.0-alpha-42814';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.