Make WordPress Core


Ignore:
Timestamp:
04/10/2018 06:01:20 PM (8 years ago)
Author:
azaozz
Message:

Privacy: add new wp-admin screens for exporting and removing of personal data.

Props @melchoyce, @mikejolley, @allendav, @xkon.
See #43481.

File:
1 edited

Legend:

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

    r42964 r42967  
    28122812
    28132813/**
     2814 * Get all user privacy request types.
     2815 *
     2816 * @since 5.0.0
     2817 * @access private
     2818 *
     2819 * @return array
     2820 */
     2821function _wp_privacy_action_request_types() {
     2822        return array(
     2823                'user_export_request',
     2824                'user_remove_request',
     2825        );
     2826}
     2827
     2828/**
     2829 * Update log when privacy request is confirmed.
     2830 *
     2831 * @since 5.0.0
     2832 * @access private
     2833 *
     2834 * @param array $result Result of the request from the user.
     2835 */
     2836function _wp_privacy_account_request_confirmed( $result ) {
     2837        if ( isset( $result['action'], $result['request_data'], $result['request_data']['privacy_request_id'] ) && in_array( $result['action'], _wp_privacy_action_request_types(), true ) ) {
     2838                $privacy_request_id = absint( $result['request_data']['privacy_request_id'] );
     2839                $privacy_request    = get_post( $privacy_request_id );
     2840
     2841                if ( ! $privacy_request || ! in_array( $privacy_request->post_type, _wp_privacy_action_request_types(), true ) ) {
     2842                        return;
     2843                }
     2844
     2845                update_post_meta( $privacy_request_id, '_confirmed_timestamp', time() );
     2846                wp_update_post( array(
     2847                        'ID'          => $privacy_request_id,
     2848                        'post_status' => 'request-confirmed',
     2849                ) );
     2850        }
     2851}
     2852add_action( 'account_action_confirmed', '_wp_privacy_account_request_confirmed' );
     2853
     2854/**
     2855 * Update log when privacy request fails.
     2856 *
     2857 * @since 5.0.0
     2858 * @access private
     2859 *
     2860 * @param array $result Result of the request from the user.
     2861 */
     2862function _wp_privacy_account_request_failed( $result ) {
     2863        if ( isset( $result['action'], $result['request_data'], $result['request_data']['privacy_request_id'] ) &&
     2864                in_array( $result['action'], _wp_privacy_action_request_types(), true ) ) {
     2865
     2866                $privacy_request_id = absint( $result['request_data']['privacy_request_id'] );
     2867                $privacy_request    = get_post( $privacy_request_id );
     2868
     2869                if ( ! $privacy_request || ! in_array( $privacy_request->post_type, _wp_privacy_action_request_types(), true ) ) {
     2870                        return;
     2871                }
     2872
     2873                wp_update_post( array(
     2874                        'ID'          => $privacy_request_id,
     2875                        'post_status' => 'request-failed',
     2876                ) );
     2877        }
     2878}
     2879
     2880/**
    28142881 * Send a confirmation request email to confirm an action.
    28152882 *
    28162883 * @since 5.0.0
    28172884 *
    2818  * @param string $email              User email address. This can be the address of a registered or non-registered user. Defaults to logged in user email address. 
     2885 * @param string $email              User email address. This can be the address of a registered or non-registered user. Defaults to logged in user email address.
    28192886 * @param string $action_name        Name of the action that is being confirmed. Defaults to 'confirm_email'.
    28202887 * @param string $action_description User facing description of the action they will be confirming. Defaults to "confirm your email address".
     
    29182985         *
    29192986         * @since 5.0.0
    2920          * 
     2987         *
    29212988         * @param string $email_text     Text in the email.
    29222989         * @param array  $email_data {
     
    30403107                $email    = $user->user_email;
    30413108
    3042                 if ( false !== strpos( $confirm_action_data, ':' ) ) {
    3043                         list( $key_request_time, $saved_key ) = explode( ':', $confirm_action_data, 2 );
     3109                if ( false !== strpos( $raw_data, ':' ) ) {
     3110                        list( $key_request_time, $saved_key ) = explode( ':', $raw_data, 2 );
    30443111                }
    30453112        } else {
    30463113                $raw_data = get_site_option( '_verify_action_' . $action_name . '_' . $uid, '' );
    30473114
    3048                 if ( false !== strpos( $confirm_action_data, ':' ) ) {
    3049                         list( $key_request_time, $saved_key, $email ) = explode( ':', $confirm_action_data, 3 );
     3115                if ( false !== strpos( $raw_data, ':' ) ) {
     3116                        list( $key_request_time, $saved_key, $email ) = explode( ':', $raw_data, 3 );
    30503117                }
    30513118        }
     
    30693136         *
    30703137         * @since 5.0.0
    3071          * 
     3138         *
    30723139         * @param int $expiration The expiration time in seconds.
    30733140         */
Note: See TracChangeset for help on using the changeset viewer.