Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 62 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
| WP_Privacy_Participating_Plugins | |
0.00% |
0 / 60 |
|
0.00% |
0 / 7 |
342 | |
0.00% |
0 / 1 |
| getInstance | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| __clone | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| __wakeup | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| __construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| maybe_add_erasers_info | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
20 | |||
| maybe_add_exporters_info | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
20 | |||
| maybe_add_privacy_info | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
30 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Privacy Participating Plugins file. |
| 4 | * |
| 5 | * @package privacy |
| 6 | */ |
| 7 | |
| 8 | if ( ! class_exists( 'WP_Privacy_Participating_Plugins' ) ) { |
| 9 | /** |
| 10 | * WP Privacy Participating Plugins |
| 11 | * |
| 12 | * Adds additional information to the export and erasure pages to clarify |
| 13 | * scope of the exporters, erasers and privacy policy guide. |
| 14 | */ |
| 15 | class WP_Privacy_Participating_Plugins { |
| 16 | /** |
| 17 | * WP_Privacy_Participating_Plugins instance. |
| 18 | * |
| 19 | * @var WP_Privacy_Participating_Plugins |
| 20 | */ |
| 21 | private static $instance; |
| 22 | |
| 23 | /** |
| 24 | * Returns a class instance. |
| 25 | * |
| 26 | * @return WP_Privacy_Participating_Plugins |
| 27 | */ |
| 28 | public static function getInstance() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid |
| 29 | if ( null === self::$instance ) { |
| 30 | self::$instance = new self(); |
| 31 | } |
| 32 | return self::$instance; |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Prevent cloning. |
| 37 | */ |
| 38 | private function __clone() { |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Prevent unserialization. |
| 43 | */ |
| 44 | public function __wakeup() { |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Constructor. |
| 49 | */ |
| 50 | protected function __construct() { |
| 51 | add_action( 'admin_footer', array( $this, 'maybe_add_erasers_info' ) ); |
| 52 | add_action( 'admin_footer', array( $this, 'maybe_add_exporters_info' ) ); |
| 53 | add_action( 'admin_footer', array( $this, 'maybe_add_privacy_info' ) ); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Determines if erasers info should be displayed and does so. Or not. |
| 58 | */ |
| 59 | public function maybe_add_erasers_info() { |
| 60 | if ( ! function_exists( 'get_current_screen' ) ) { |
| 61 | return; |
| 62 | } |
| 63 | |
| 64 | $screen = get_current_screen(); |
| 65 | if ( $screen === null ) { |
| 66 | return; |
| 67 | } |
| 68 | |
| 69 | if ( 'tools_page_remove_personal_data' !== $screen->id ) { |
| 70 | return; |
| 71 | } |
| 72 | |
| 73 | $prompt = __( |
| 74 | 'Please note - this tool only erases the personal data stored by WordPress and |
| 75 | participating plugins. It does not delete registered users, nor does it erase |
| 76 | personal data stored by non-participating plugins. It is your responsibility |
| 77 | to delete registered users as well as personal data stored by non-participating |
| 78 | plugins. The personal data erased includes only the following items at this |
| 79 | time:', |
| 80 | 'wpcomsh' |
| 81 | ); |
| 82 | |
| 83 | $erasers = apply_filters( 'wp_privacy_personal_data_erasers', array() ); |
| 84 | ?> |
| 85 | <script type="text/javascript"> |
| 86 | jQuery( document ).ready( function( $ ) { |
| 87 | var prompt = <?php echo wp_json_encode( $prompt, JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP ); ?>; |
| 88 | var erasers = <?php echo wp_json_encode( $erasers, JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP ); ?>; |
| 89 | var isRemovePage = $( 'body' ).hasClass( 'tools_page_remove_personal_data' ); |
| 90 | |
| 91 | if ( isRemovePage ) { |
| 92 | $( '.wp-header-end' ).after( |
| 93 | "<div class='notice notice-info wp-privacy-eraser-notice'></div>" |
| 94 | ); |
| 95 | $( '.wp-privacy-eraser-notice' ).html( '<p>' + prompt + '</p>' ); |
| 96 | if ( erasers ) { |
| 97 | $( '.wp-privacy-eraser-notice' ).append( '<ul></ul>' ); |
| 98 | $.map( erasers, function( val ) { |
| 99 | $( '.wp-privacy-eraser-notice ul' ).append( '<li>' + val.eraser_friendly_name + '</li>' ); |
| 100 | } ); |
| 101 | } |
| 102 | } |
| 103 | } ); |
| 104 | </script> |
| 105 | <?php |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * Determines if exporters info should be displayed and does so. Or not. |
| 110 | */ |
| 111 | public function maybe_add_exporters_info() { |
| 112 | if ( ! function_exists( 'get_current_screen' ) ) { |
| 113 | return; |
| 114 | } |
| 115 | |
| 116 | $screen = get_current_screen(); |
| 117 | if ( $screen === null ) { |
| 118 | return; |
| 119 | } |
| 120 | |
| 121 | if ( 'tools_page_export_personal_data' !== $screen->id ) { |
| 122 | return; |
| 123 | } |
| 124 | |
| 125 | $prompt = __( |
| 126 | 'Please note - this tool only exports the personal data stored by WordPress and |
| 127 | participating plugins. It does not export personal data stored by |
| 128 | non-participating plugins. It is your responsibility to export personal data |
| 129 | stored by non-participating plugins separately. The personal data exported |
| 130 | includes only the following items at this time:', |
| 131 | 'wpcomsh' |
| 132 | ); |
| 133 | |
| 134 | $exporters = apply_filters( 'wp_privacy_personal_data_exporters', array() ); |
| 135 | ?> |
| 136 | <script type="text/javascript"> |
| 137 | jQuery( document ).ready( function( $ ) { |
| 138 | var prompt = <?php echo wp_json_encode( $prompt, JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP ); ?>; |
| 139 | var exporters = <?php echo wp_json_encode( $exporters, JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP ); ?>; |
| 140 | var isExportPage = $( 'body' ).hasClass( 'tools_page_export_personal_data' ); |
| 141 | |
| 142 | if ( isExportPage ) { |
| 143 | $( '.wp-header-end' ).after( |
| 144 | "<div class='notice notice-info wp-privacy-exporter-notice'></div>" |
| 145 | ); |
| 146 | $( '.wp-privacy-exporter-notice' ).html( '<p>' + prompt + '</p>' ); |
| 147 | if ( exporters ) { |
| 148 | $( '.wp-privacy-exporter-notice' ).append( '<ul></ul>' ); |
| 149 | $.map( exporters, function( val ) { |
| 150 | $( '.wp-privacy-exporter-notice ul' ).append( '<li>' + val.exporter_friendly_name + '</li>' ); |
| 151 | } ); |
| 152 | } |
| 153 | } |
| 154 | } ); |
| 155 | </script> |
| 156 | <?php |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * Determines if privacy info should be displayed and does so. Or not. |
| 161 | */ |
| 162 | public function maybe_add_privacy_info() { |
| 163 | if ( ! function_exists( 'get_current_screen' ) ) { |
| 164 | return; |
| 165 | } |
| 166 | |
| 167 | $screen = get_current_screen(); |
| 168 | if ( $screen === null ) { |
| 169 | return; |
| 170 | } |
| 171 | |
| 172 | if ( 'tools' !== $screen->id ) { |
| 173 | return; |
| 174 | } |
| 175 | |
| 176 | if ( ! isset( $_GET['wp-privacy-policy-guide'] ) ) { // phpcs:ignore WordPress.Security |
| 177 | return; |
| 178 | } |
| 179 | |
| 180 | $prompt = __( |
| 181 | 'Please note - this tool only displays privacy policy information provided by |
| 182 | WordPress and participating plugins. It does not include privacy policy |
| 183 | information for non-participating plugins. It is your responsibility to |
| 184 | obtain privacy policy information for non-participating plugins separately.', |
| 185 | 'wpcomsh' |
| 186 | ); |
| 187 | ?> |
| 188 | <script type="text/javascript"> |
| 189 | jQuery( document ).ready( function( $ ) { |
| 190 | var hasPrivacyDiv = 0 < $( 'div.wp-privacy-policy-guide' ).length; |
| 191 | var prompt = <?php echo wp_json_encode( $prompt, JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP ); ?>; |
| 192 | if ( hasPrivacyDiv ) { |
| 193 | $( 'h1' ).after( |
| 194 | "<div class='notice notice-info wp-privacy-policy-notice'></div>" |
| 195 | ); |
| 196 | $( '.wp-privacy-policy-notice' ).html( '<p>' + prompt + '</p>' ); |
| 197 | } |
| 198 | } ); |
| 199 | </script> |
| 200 | <?php |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | WP_Privacy_Participating_Plugins::getInstance(); |
| 205 | } |