-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdismiss-privacy-tools.php
166 lines (157 loc) · 6.21 KB
/
dismiss-privacy-tools.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php
/*
Plugin Name: Dismiss Privacy Tools
Plugin URI: https://github.com/luciano-croce/dismiss-privacy-tools/
Description: Dismiss <strong>Privacy Tools</strong> added in WordPress 4.9.6, completely, when it is activated, or if it is in mu-plugins directory.
Version: 0.0.1
Requires at least: 4.9.6-alpha
Tested up to: 5.0-alpha
Requires PHP: 5.2.4
Author: Luciano Croce
Author URI: https://github.com/luciano-croce/
License: GPLv2 or later (license.txt)
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: dismiss-privacy-tools
Domain Path: /languages
Network: true
GitHub Plugin URI: https://github.com/luciano-croce/dismiss-privacy-tools/
GitHub Branch: master
Requires WP: 4.9.6-alpha
*
* Features:
*
* Disable Privacy Toool /wp-admin/privacy.php
* Disable Erase Personal Data /wp-admin/tools.php?page=erase_personal_data
* Disable Export Personal Data /wp-admin/tools.php?page=export_personal_data
* Dismiss pointer for the new privacy tools.
* Remove scheduled event used to delete old export files.
* Remove scheduled hook used to delete old export files.
* Short circuits the option for the privacy policy page to always return 0 to avoid unnedded database query.
* Delete uneeded database options and reset options to default.
*/
/**
* Dismiss Privacy Tools
*
* Dismiss Privacy Tools added in WordPress 4.9.6 (completely) included Erase and Export Personal Data.
*
* PHPDocumentor
*
* @package WordPress\Plugin
* @subpackage Dashboard\Dismiss_Privacy_tools
* @link https://github.com/luciano-croce/dismiss-privacy-tools/
* @version 0.0.1 (Build 2018-05-10) Stable Release
* @since 4.9.6-alpha
* @author Luciano Croce <luciano.croce@gmail.com>
* @copyright 2018 - Luciano Croce
* @license https://www.gnu.org/licenses/gpl-2.0.html - GPLv2 or later (license.txt)
* @todo Investigating possible pointer_wp496_privacy bug (future release)
*/
/**
* Completely disable the Privacy Tools added in WordPress 4.9.6 or later and greater.
*
* @param array $required_capabilities - The primitive capabilities that are required to perform the requested meta capability.
* @param string $requested_capability - The requested meta capability.
* @param int $user_id - The user ID.
* @param array $args - The object ID. (typically adds the context to the cap)
*
* @return array - The primitive capabilities that are required to perform the requested meta capability.
*
* @since 2018-06-22
* @version 2018-06-22
* @author Luciano Croce @ profiles.wordpress.org/luciano.croce
*/
function disable_496_privacy_tools( $required_capabilities, $requested_capability, $user_id, $args ) {
$privacy_capabilities = array( 'manage_privacy_options', 'erase_others_personal_data', 'export_others_personal_data' );
if ( in_array( $requested_capability, $privacy_capabilities ) ) {
$required_capabilities[] = 'do_not_allow';
}
return $required_capabilities;
}
add_filter( 'map_meta_cap', 'disable_496_privacy_tools', 10, 4 );
/**
* Short circuits the option for the privacy policy page to always return 0.
*
* The option is used by get_privacy_policy_url() among others.
*
* @since 2018-06-22
* @version 2018-06-22
* @author Luciano Croce @ profiles.wordpress.org/luciano.croce
*/
add_filter( 'pre_option_wp_page_for_privacy_policy', '__return_zero' );
/**
* Removes the default scheduled event used to delete old export files.
*
* @since 2018-06-22
* @version 2018-06-22
* @author Luciano Croce @ profiles.wordpress.org/luciano.croce
*/
remove_action( 'init', 'wp_schedule_delete_old_privacy_export_files' );
/**
* Disable the checkbox comments – privacy - approved?
*
* @since 2018-06-22
* @version 2018-06-22
* @author Luciano Croce @ profiles.wordpress.org/luciano.croce
*/
function comment_form_hide_cookies_consent( $fields ) {
unset( $fields['cookies'] );
return $fields;
}
add_filter( 'comment_form_default_fields', 'comment_form_hide_cookies_consent' );
/*
* Delete uneeded database options - reset to default - dismiss yellow warning on edit and other pages.
*
* @since 2018-06-22
* @version 2018-06-22
* @author Luciano Croce @ profiles.wordpress.org/luciano.croce
*/
delete_option( 'wp_page_for_privacy_policy' );
delete_option( '_wp_privacy_text_change_check' );
delete_site_option( 'wp_page_for_privacy_policy' );
delete_site_option( '_wp_privacy_text_change_check' );
/**
* Disable and Remove Background Hook Cron.
*
* Scheduled Auto Old Privacy Files Export Delete.
*
* @since 2018-06-22
* @version 2018-06-22
* @author Luciano Croce @ profiles.wordpress.org/luciano.croce
*/
function privacy_tools_scheduled_cron() {
wp_clear_scheduled_hook( 'wp_privacy_delete_old_export_files' );
}
add_action( 'admin_init', 'privacy_tools_scheduled_cron' );
/**
* Dismiss all the new feature pointers.
*
* @since 3.3.0
*
* All pointers can be disabled using the following:
* remove_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts' ) );
*
* @param string $hook_suffix The current admin page.
*
* Dismiss a pointer for the new privacy tools.
*
* @since 4.9.6
*
* Privacy pointer can be disabled using the following:
* remove_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_wp496_privacy' ) );
*
* @param string $hook_suffix The current admin page.
*
* @since 2018-06-22
* @version 2018-06-22
* @author Luciano Croce @ profiles.wordpress.org/luciano.croce
*/
class dismiss_pointer_wp496_privacy{
public function __construct(){
add_action( 'admin_init', array( $this, 'remove_action' ) );
}
function remove_action(){
// remove_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_wp496_privacy' ) ); # This for now not work: due a bug? Investigating... wp496_privacy ???
remove_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts' ) );
}
}
$dismiss_pointer_wp496_privacy = new dismiss_pointer_wp496_privacy;