Make WordPress Core


Ignore:
Timestamp:
05/01/2018 11:41:37 PM (8 years ago)
Author:
SergeyBiryukov
Message:

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

Props melchoyce, mikejolley, allendav, xkon.
Merges [42967] to the 4.9 branch.
See #43481.

Location:
branches/4.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9

  • branches/4.9/src/wp-includes/user.php

    r43070 r43071  
    27342734
    27352735/**
     2736 * Get all user privacy request types.
     2737 *
     2738 * @since 5.0.0
     2739 * @access private
     2740 *
     2741 * @return array
     2742 */
     2743function _wp_privacy_action_request_types() {
     2744        return array(
     2745                'user_export_request',
     2746                'user_remove_request',
     2747        );
     2748}
     2749
     2750/**
     2751 * Update log when privacy request is confirmed.
     2752 *
     2753 * @since 5.0.0
     2754 * @access private
     2755 *
     2756 * @param array $result Result of the request from the user.
     2757 */
     2758function _wp_privacy_account_request_confirmed( $result ) {
     2759        if ( isset( $result['action'], $result['request_data'], $result['request_data']['privacy_request_id'] ) && in_array( $result['action'], _wp_privacy_action_request_types(), true ) ) {
     2760                $privacy_request_id = absint( $result['request_data']['privacy_request_id'] );
     2761                $privacy_request    = get_post( $privacy_request_id );
     2762
     2763                if ( ! $privacy_request || ! in_array( $privacy_request->post_type, _wp_privacy_action_request_types(), true ) ) {
     2764                        return;
     2765                }
     2766
     2767                update_post_meta( $privacy_request_id, '_confirmed_timestamp', time() );
     2768                wp_update_post( array(
     2769                        'ID'          => $privacy_request_id,
     2770                        'post_status' => 'request-confirmed',
     2771                ) );
     2772        }
     2773}
     2774add_action( 'account_action_confirmed', '_wp_privacy_account_request_confirmed' );
     2775
     2776/**
     2777 * Update log when privacy request fails.
     2778 *
     2779 * @since 5.0.0
     2780 * @access private
     2781 *
     2782 * @param array $result Result of the request from the user.
     2783 */
     2784function _wp_privacy_account_request_failed( $result ) {
     2785        if ( isset( $result['action'], $result['request_data'], $result['request_data']['privacy_request_id'] ) &&
     2786                in_array( $result['action'], _wp_privacy_action_request_types(), true ) ) {
     2787
     2788                $privacy_request_id = absint( $result['request_data']['privacy_request_id'] );
     2789                $privacy_request    = get_post( $privacy_request_id );
     2790
     2791                if ( ! $privacy_request || ! in_array( $privacy_request->post_type, _wp_privacy_action_request_types(), true ) ) {
     2792                        return;
     2793                }
     2794
     2795                wp_update_post( array(
     2796                        'ID'          => $privacy_request_id,
     2797                        'post_status' => 'request-failed',
     2798                ) );
     2799        }
     2800}
     2801
     2802/**
    27362803 * Send a confirmation request email to confirm an action.
    27372804 *
    27382805 * @since 5.0.0
    27392806 *
    2740  * @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. 
     2807 * @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.
    27412808 * @param string $action_name        Name of the action that is being confirmed. Defaults to 'confirm_email'.
    27422809 * @param string $action_description User facing description of the action they will be confirming. Defaults to "confirm your email address".
     
    28402907         *
    28412908         * @since 5.0.0
    2842          * 
     2909         *
    28432910         * @param string $email_text     Text in the email.
    28442911         * @param array  $email_data {
     
    29623029                $email    = $user->user_email;
    29633030
    2964                 if ( false !== strpos( $confirm_action_data, ':' ) ) {
    2965                         list( $key_request_time, $saved_key ) = explode( ':', $confirm_action_data, 2 );
     3031                if ( false !== strpos( $raw_data, ':' ) ) {
     3032                        list( $key_request_time, $saved_key ) = explode( ':', $raw_data, 2 );
    29663033                }
    29673034        } else {
    29683035                $raw_data = get_site_option( '_verify_action_' . $action_name . '_' . $uid, '' );
    29693036
    2970                 if ( false !== strpos( $confirm_action_data, ':' ) ) {
    2971                         list( $key_request_time, $saved_key, $email ) = explode( ':', $confirm_action_data, 3 );
     3037                if ( false !== strpos( $raw_data, ':' ) ) {
     3038                        list( $key_request_time, $saved_key, $email ) = explode( ':', $raw_data, 3 );
    29723039                }
    29733040        }
     
    29913058         *
    29923059         * @since 5.0.0
    2993          * 
     3060         *
    29943061         * @param int $expiration The expiration time in seconds.
    29953062         */
Note: See TracChangeset for help on using the changeset viewer.