Changeset 43084 for branches/4.9/src/wp-includes/user.php
- Timestamp:
- 05/02/2018 01:03:53 AM (7 years ago)
- Location:
- branches/4.9
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.9
- Property svn:mergeinfo changed
/trunk merged: 43011,43014
- Property svn:mergeinfo changed
-
branches/4.9/src/wp-includes/user.php
r43083 r43084 2763 2763 } 2764 2764 2765 if ( ! in_array( $request_data ['status'], array( 'request-pending', 'request-failed' ), true ) ) {2765 if ( ! in_array( $request_data->status, array( 'request-pending', 'request-failed' ), true ) ) { 2766 2766 return; 2767 2767 } … … 2769 2769 update_post_meta( $request_id, '_wp_user_request_confirmed_timestamp', time() ); 2770 2770 wp_update_post( array( 2771 'ID' => $request_ data['request_id'],2771 'ID' => $request_id, 2772 2772 'post_status' => 'request-confirmed', 2773 2773 ) ); … … 2785 2785 $request = wp_get_user_request_data( $request_id ); 2786 2786 2787 if ( $request && in_array( $request ['action'], _wp_privacy_action_request_types(), true ) ) {2787 if ( $request && in_array( $request->action_name, _wp_privacy_action_request_types(), true ) ) { 2788 2788 $message = '<p class="message">' . __( 'Action has been confirmed.' ) . '</p>'; 2789 2789 $message .= __( 'The site administrator has been notified and will fulfill your request as soon as possible.' ); … … 2823 2823 // Check for duplicates. 2824 2824 $requests_query = new WP_Query( array( 2825 'post_type' => 'user_request', 2826 'title' => $action_name, 2827 'post_status' => 'any', 2828 'fields' => 'ids', 2829 'meta_query' => array( 2830 array( 2831 'key' => '_wp_user_request_user_email', 2832 'value' => $email_address, 2833 ), 2834 ), 2825 'post_type' => 'user_request', 2826 'post_name__in' => array( $action_name ), // Action name stored in post_name column. 2827 'title' => $email_address, // Email address stored in post_title column. 2828 'post_status' => 'any', 2829 'fields' => 'ids', 2835 2830 ) ); 2836 2831 … … 2841 2836 $request_id = wp_insert_post( array( 2842 2837 'post_author' => $user_id, 2843 'post_title' => $action_name, 2838 'post_name' => $action_name, 2839 'post_title' => $email_address, 2844 2840 'post_content' => wp_json_encode( $request_data ), 2845 2841 'post_status' => 'request-pending', … … 2848 2844 'post_date_gmt' => current_time( 'mysql', true ), 2849 2845 ), true ); 2850 2851 if ( is_wp_error( $request_id ) ) {2852 return $request_id;2853 }2854 2855 update_post_meta( $request_id, '_wp_user_request_user_email', $email_address );2856 update_post_meta( $request_id, '_wp_user_request_confirmed_timestamp', false );2857 2846 2858 2847 return $request_id; … … 2884 2873 * Filters the user action description. 2885 2874 * 2875 * @since 4.9.6 2876 * 2886 2877 * @param string $description The default description. 2887 2878 * @param string $action_name The name of the request. 2888 */ 2879 */ 2889 2880 return apply_filters( 'user_request_action_description', $description, $action_name ); 2890 2881 } … … 2902 2893 function wp_send_user_request( $request_id ) { 2903 2894 $request_id = absint( $request_id ); 2904 $request = get_post( $request_id );2905 2906 if ( ! $request || 'user_request' !== $request->post_type) {2895 $request = wp_get_user_request_data( $request_id ); 2896 2897 if ( ! $request ) { 2907 2898 return new WP_Error( 'user_request_error', __( 'Invalid request.' ) ); 2908 2899 } 2909 2900 2910 if ( 'request-pending' !== $request->post_status ) {2911 wp_update_post( array(2912 'ID' => $request_id,2913 'post_status' => 'request-pending',2914 'post_date' => current_time( 'mysql', false ),2915 'post_date_gmt' => current_time( 'mysql', true ),2916 ) );2917 }2918 2919 2901 $email_data = array( 2920 'action_name' => $request->post_title, 2921 'email' => get_post_meta( $request->ID, '_wp_user_request_user_email', true ), 2922 'description' => wp_user_request_action_description( $request->post_title ), 2902 'email' => $request->email, 2903 'description' => wp_user_request_action_description( $request->action_name ), 2923 2904 'confirm_url' => add_query_arg( array( 2924 2905 'action' => 'confirmaction', … … 2968 2949 * Data relating to the account action email. 2969 2950 * 2970 * @type string $action_name Name of the action being performed.2971 * @type string $email The email address this is being sent to.2972 * @type string $description Description of the action being performed so the user knows what the email is for.2973 * @type string $confirm_url The link to click on to confirm the account action.2974 * @type string $sitename The site name sending the mail.2975 * @type string $siteurl The site URL sending the mail.2951 * @type WP_User_Request $request User request object. 2952 * @type string $email The email address this is being sent to. 2953 * @type string $description Description of the action being performed so the user knows what the email is for. 2954 * @type string $confirm_url The link to click on to confirm the account action. 2955 * @type string $sitename The site name sending the mail. 2956 * @type string $siteurl The site URL sending the mail. 2976 2957 * } 2977 2958 */ … … 2989 2970 2990 2971 /** 2991 * Returns a confirmation key for a user action and stores the hashed version .2972 * Returns a confirmation key for a user action and stores the hashed version for future comparison. 2992 2973 * 2993 2974 * @since 4.9.6 … … 3008 2989 } 3009 2990 3010 update_post_meta( $request_id, '_wp_user_request_confirm_key', $wp_hasher->HashPassword( $key ) ); 3011 update_post_meta( $request_id, '_wp_user_request_confirm_key_timestamp', time() ); 2991 wp_update_post( array( 2992 'ID' => $request_id, 2993 'post_status' => 'request-pending', 2994 'post_password' => $wp_hasher->HashPassword( $key ), 2995 'post_modified' => current_time( 'mysql', false ), 2996 'post_modified_gmt' => current_time( 'mysql', true ), 2997 ) ); 3012 2998 3013 2999 return $key; … … 3033 3019 } 3034 3020 3035 if ( ! in_array( $request ['status'], array( 'request-pending', 'request-failed' ), true ) ) {3021 if ( ! in_array( $request->status, array( 'request-pending', 'request-failed' ), true ) ) { 3036 3022 return __( 'This link has expired.' ); 3037 3023 } … … 3046 3032 } 3047 3033 3048 $key_request_time = $request ['confirm_key_timestamp'];3049 $saved_key = $request ['confirm_key'];3034 $key_request_time = $request->modified_timestamp; 3035 $saved_key = $request->confirm_key; 3050 3036 3051 3037 if ( ! $saved_key ) { … … 3088 3074 function wp_get_user_request_data( $request_id ) { 3089 3075 $request_id = absint( $request_id ); 3090 $ request= get_post( $request_id );3091 3092 if ( ! $ request || 'user_request' !== $request->post_type ) {3076 $post = get_post( $request_id ); 3077 3078 if ( ! $post || 'user_request' !== $post->post_type ) { 3093 3079 return false; 3094 3080 } 3095 3081 3096 return array( 3097 'request_id' => $request->ID, 3098 'user_id' => $request->post_author, 3099 'email' => get_post_meta( $request->ID, '_wp_user_request_user_email', true ), 3100 'action' => $request->post_title, 3101 'requested_timestamp' => strtotime( $request->post_date_gmt ), 3102 'confirmed_timestamp' => get_post_meta( $request->ID, '_wp_user_request_confirmed_timestamp', true ), 3103 'completed_timestamp' => get_post_meta( $request->ID, '_wp_user_request_completed_timestamp', true ), 3104 'request_data' => json_decode( $request->post_content, true ), 3105 'status' => $request->post_status, 3106 'confirm_key' => get_post_meta( $request_id, '_wp_user_request_confirm_key', true ), 3107 'confirm_key_timestamp' => get_post_meta( $request_id, '_wp_user_request_confirm_key_timestamp', true ), 3108 ); 3109 } 3082 return new WP_User_Request( $post ); 3083 } 3084 3085 /** 3086 * WP_User_Request class. 3087 * 3088 * Represents user request data loaded from a WP_Post object. 3089 * 3090 * @since 4.9.6 3091 */ 3092 final class WP_User_Request { 3093 /** 3094 * Request ID. 3095 * 3096 * @var int 3097 */ 3098 public $ID = 0; 3099 3100 /** 3101 * User ID. 3102 * 3103 * @var int 3104 */ 3105 3106 public $user_id = 0; 3107 3108 /** 3109 * User email. 3110 * 3111 * @var int 3112 */ 3113 public $email = ''; 3114 3115 /** 3116 * Action name. 3117 * 3118 * @var string 3119 */ 3120 public $action_name = ''; 3121 3122 /** 3123 * Current status. 3124 * 3125 * @var string 3126 */ 3127 public $status = ''; 3128 3129 /** 3130 * Timestamp this request was created. 3131 * 3132 * @var int|null 3133 */ 3134 public $created_timestamp = null; 3135 3136 /** 3137 * Timestamp this request was last modified. 3138 * 3139 * @var int|null 3140 */ 3141 public $modified_timestamp = null; 3142 3143 /** 3144 * Timestamp this request was confirmed. 3145 * 3146 * @var int 3147 */ 3148 public $confirmed_timestamp = null; 3149 3150 /** 3151 * Timestamp this request was completed. 3152 * 3153 * @var int 3154 */ 3155 public $completed_timestamp = null; 3156 3157 /** 3158 * Misc data assigned to this request. 3159 * 3160 * @var array 3161 */ 3162 public $request_data = array(); 3163 3164 /** 3165 * Key used to confirm this request. 3166 * 3167 * @var string 3168 */ 3169 public $confirm_key = ''; 3170 3171 /** 3172 * Constructor. 3173 * 3174 * @since 4.9.6 3175 * 3176 * @param WP_Post|object $post Post object. 3177 */ 3178 public function __construct( $post ) { 3179 $this->ID = $post->ID; 3180 $this->user_id = $post->post_author; 3181 $this->email = $post->post_title; 3182 $this->action_name = $post->post_name; 3183 $this->status = $post->post_status; 3184 $this->created_timestamp = strtotime( $post->post_date_gmt ); 3185 $this->modified_timestamp = strtotime( $post->post_modified_gmt ); 3186 $this->confirmed_timestamp = (int) get_post_meta( $post->ID, '_wp_user_request_confirmed_timestamp', true ); 3187 $this->completed_timestamp = (int) get_post_meta( $post->ID, '_wp_user_request_completed_timestamp', true ); 3188 $this->request_data = json_decode( $post->post_content, true ); 3189 $this->confirm_key = $post->post_password; 3190 } 3191 }
Note: See TracChangeset
for help on using the changeset viewer.