'.__("Manage personal data", 'complianz-gdpr').''; } return $value; } public function datarequest_data($requests){ foreach ($requests as $key => $request ){ $email = $request['email']; $requests[$key]['has_data'] = $this->has_personal_data_in_wpcore($email); } return $requests; } public function report_customer_columns($columns){ $columns['has_data'] = __( 'Reported data', 'complianz-gdpr' ); return $columns; } /** * Extend options with generic options * * @param array $options * * @return array */ public function datarequest_options( $options = [] ){ $options += [ "request_for_access" => [ 'short' => __( 'Request for access', 'complianz-gdpr' ), 'long' => __( 'Submit a request for access to the data we process about you.', 'complianz-gdpr' ), 'slug' => 'definition/what-is-the-right-to-access/', ], "right_to_be_forgotten" => [ 'short' => __( 'Right to be Forgotten', 'complianz-gdpr' ), 'long' => __( 'Submit a request for deletion of the data if it is no longer relevant.', 'complianz-gdpr' ), 'slug' => 'definition/right-to-be-forgotten/', ], "right_to_data_portability" => [ 'short' => __( 'Right to Data Portability', 'complianz-gdpr' ), 'long' => __( 'Submit a request to receive an export file of the data we process about you.', 'complianz-gdpr' ), 'slug' => 'definition/right-to-data-portability/', ], ]; return $options; } /** * Check if this user has any personal data * @param $email_address * * @return bool */ public function has_personal_data_in_wpcore($email_address){ if (!is_email($email_address)) { return false; } $exporters = apply_filters( 'wp_privacy_personal_data_exporters', array() ); if ( ! is_array( $exporters ) ) { wp_send_json_error( __( 'An exporter has improperly used the registration filter.' ) ); } // Do we have any registered exporters? if ( 0 < count( $exporters ) ) { foreach ($exporters as $exporter ) { $exporter_friendly_name = $exporter['exporter_friendly_name']; if ( ! array_key_exists( 'callback', $exporter ) ) { wp_send_json_error( /* translators: %s: Exporter friendly name. */ sprintf( __( 'Exporter does not include a callback: %s.' ), esc_html( $exporter_friendly_name ) ) ); } if ( ! is_callable( $exporter['callback'] ) ) { wp_send_json_error( /* translators: %s: Exporter friendly name. */ sprintf( __( 'Exporter callback is not a valid callback: %s.' ), esc_html( $exporter_friendly_name ) ) ); } $callback = $exporter['callback']; $response = call_user_func( $callback, $email_address, 1 );//we only need to know if there is more than one, so page '1' is sufficient for our purpose /** * If we encounter errors, we assume there is personal data */ if ( is_wp_error( $response ) ) { return true; } if ( ! is_array( $response ) ) { return true; } if ( ! array_key_exists( 'data', $response ) ) { return true; } if ( ! is_array( $response['data'] ) ) { return true; } if ( ! array_key_exists( 'done', $response ) ) { return true; } } } else { //no exporters return false; } if ( is_wp_error( $response ) ) { return true; } $data = $response['data']; return count($data)>0; } /** * Render the form in the shortcode * * @return string */ public function datarequest_form($atts = [], $content = null, $tag = '') { $atts = array_change_key_case( (array) $atts, CASE_LOWER ); $atts = shortcode_atts( array( 'region' => 'us' ), $atts, $tag ); $region = sanitize_title($atts['region']); ob_start(); ?>
×
datarequest_options(); foreach ( $options as $id => $label ) { ?>
get_charset_collate(); $table_name = $wpdb->prefix . 'cmplz_dnsmpd'; $sql = "CREATE TABLE $table_name ( `ID` int(11) NOT NULL AUTO_INCREMENT, `request_for_access` int(11) NOT NULL, `right_to_be_forgotten` int(11) NOT NULL, `right_to_data_portability` int(11) NOT NULL, PRIMARY KEY (ID) ) $charset_collate;"; dbDelta( $sql ); update_option( 'cmplz_datarequests_db_version', CMPLZ_VERSION, false ); } } } //class closure } $data_request = new cmplz_datarequest();