Edit File by line
/home/barbar84/www/wp-inclu...
File: user.php
'post_title' => $email_address,
[4000] Fix | Delete
'post_content' => wp_json_encode( $request_data ),
[4001] Fix | Delete
'post_status' => 'request-' . $status,
[4002] Fix | Delete
'post_type' => 'user_request',
[4003] Fix | Delete
'post_date' => current_time( 'mysql', false ),
[4004] Fix | Delete
'post_date_gmt' => current_time( 'mysql', true ),
[4005] Fix | Delete
),
[4006] Fix | Delete
true
[4007] Fix | Delete
);
[4008] Fix | Delete
[4009] Fix | Delete
return $request_id;
[4010] Fix | Delete
}
[4011] Fix | Delete
[4012] Fix | Delete
/**
[4013] Fix | Delete
* Get action description from the name and return a string.
[4014] Fix | Delete
*
[4015] Fix | Delete
* @since 4.9.6
[4016] Fix | Delete
*
[4017] Fix | Delete
* @param string $action_name Action name of the request.
[4018] Fix | Delete
* @return string Human readable action name.
[4019] Fix | Delete
*/
[4020] Fix | Delete
function wp_user_request_action_description( $action_name ) {
[4021] Fix | Delete
switch ( $action_name ) {
[4022] Fix | Delete
case 'export_personal_data':
[4023] Fix | Delete
$description = __( 'Export Personal Data' );
[4024] Fix | Delete
break;
[4025] Fix | Delete
case 'remove_personal_data':
[4026] Fix | Delete
$description = __( 'Erase Personal Data' );
[4027] Fix | Delete
break;
[4028] Fix | Delete
default:
[4029] Fix | Delete
/* translators: %s: Action name. */
[4030] Fix | Delete
$description = sprintf( __( 'Confirm the "%s" action' ), $action_name );
[4031] Fix | Delete
break;
[4032] Fix | Delete
}
[4033] Fix | Delete
[4034] Fix | Delete
/**
[4035] Fix | Delete
* Filters the user action description.
[4036] Fix | Delete
*
[4037] Fix | Delete
* @since 4.9.6
[4038] Fix | Delete
*
[4039] Fix | Delete
* @param string $description The default description.
[4040] Fix | Delete
* @param string $action_name The name of the request.
[4041] Fix | Delete
*/
[4042] Fix | Delete
return apply_filters( 'user_request_action_description', $description, $action_name );
[4043] Fix | Delete
}
[4044] Fix | Delete
[4045] Fix | Delete
/**
[4046] Fix | Delete
* Send a confirmation request email to confirm an action.
[4047] Fix | Delete
*
[4048] Fix | Delete
* If the request is not already pending, it will be updated.
[4049] Fix | Delete
*
[4050] Fix | Delete
* @since 4.9.6
[4051] Fix | Delete
*
[4052] Fix | Delete
* @param string $request_id ID of the request created via wp_create_user_request().
[4053] Fix | Delete
* @return true|WP_Error True on success, `WP_Error` on failure.
[4054] Fix | Delete
*/
[4055] Fix | Delete
function wp_send_user_request( $request_id ) {
[4056] Fix | Delete
$request_id = absint( $request_id );
[4057] Fix | Delete
$request = wp_get_user_request( $request_id );
[4058] Fix | Delete
[4059] Fix | Delete
if ( ! $request ) {
[4060] Fix | Delete
return new WP_Error( 'invalid_request', __( 'Invalid personal data request.' ) );
[4061] Fix | Delete
}
[4062] Fix | Delete
[4063] Fix | Delete
// Localize message content for user; fallback to site default for visitors.
[4064] Fix | Delete
if ( ! empty( $request->user_id ) ) {
[4065] Fix | Delete
$locale = get_user_locale( $request->user_id );
[4066] Fix | Delete
} else {
[4067] Fix | Delete
$locale = get_locale();
[4068] Fix | Delete
}
[4069] Fix | Delete
[4070] Fix | Delete
$switched_locale = switch_to_locale( $locale );
[4071] Fix | Delete
[4072] Fix | Delete
$email_data = array(
[4073] Fix | Delete
'request' => $request,
[4074] Fix | Delete
'email' => $request->email,
[4075] Fix | Delete
'description' => wp_user_request_action_description( $request->action_name ),
[4076] Fix | Delete
'confirm_url' => add_query_arg(
[4077] Fix | Delete
array(
[4078] Fix | Delete
'action' => 'confirmaction',
[4079] Fix | Delete
'request_id' => $request_id,
[4080] Fix | Delete
'confirm_key' => wp_generate_user_request_key( $request_id ),
[4081] Fix | Delete
),
[4082] Fix | Delete
wp_login_url()
[4083] Fix | Delete
),
[4084] Fix | Delete
'sitename' => wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ),
[4085] Fix | Delete
'siteurl' => home_url(),
[4086] Fix | Delete
);
[4087] Fix | Delete
[4088] Fix | Delete
/* translators: Do not translate DESCRIPTION, CONFIRM_URL, SITENAME, SITEURL: those are placeholders. */
[4089] Fix | Delete
$email_text = __(
[4090] Fix | Delete
'Howdy,
[4091] Fix | Delete
[4092] Fix | Delete
A request has been made to perform the following action on your account:
[4093] Fix | Delete
[4094] Fix | Delete
###DESCRIPTION###
[4095] Fix | Delete
[4096] Fix | Delete
To confirm this, please click on the following link:
[4097] Fix | Delete
###CONFIRM_URL###
[4098] Fix | Delete
[4099] Fix | Delete
You can safely ignore and delete this email if you do not want to
[4100] Fix | Delete
take this action.
[4101] Fix | Delete
[4102] Fix | Delete
Regards,
[4103] Fix | Delete
All at ###SITENAME###
[4104] Fix | Delete
###SITEURL###'
[4105] Fix | Delete
);
[4106] Fix | Delete
[4107] Fix | Delete
/**
[4108] Fix | Delete
* Filters the text of the email sent when an account action is attempted.
[4109] Fix | Delete
*
[4110] Fix | Delete
* The following strings have a special meaning and will get replaced dynamically:
[4111] Fix | Delete
*
[4112] Fix | Delete
* ###DESCRIPTION### Description of the action being performed so the user knows what the email is for.
[4113] Fix | Delete
* ###CONFIRM_URL### The link to click on to confirm the account action.
[4114] Fix | Delete
* ###SITENAME### The name of the site.
[4115] Fix | Delete
* ###SITEURL### The URL to the site.
[4116] Fix | Delete
*
[4117] Fix | Delete
* @since 4.9.6
[4118] Fix | Delete
*
[4119] Fix | Delete
* @param string $email_text Text in the email.
[4120] Fix | Delete
* @param array $email_data {
[4121] Fix | Delete
* Data relating to the account action email.
[4122] Fix | Delete
*
[4123] Fix | Delete
* @type WP_User_Request $request User request object.
[4124] Fix | Delete
* @type string $email The email address this is being sent to.
[4125] Fix | Delete
* @type string $description Description of the action being performed so the user knows what the email is for.
[4126] Fix | Delete
* @type string $confirm_url The link to click on to confirm the account action.
[4127] Fix | Delete
* @type string $sitename The site name sending the mail.
[4128] Fix | Delete
* @type string $siteurl The site URL sending the mail.
[4129] Fix | Delete
* }
[4130] Fix | Delete
*/
[4131] Fix | Delete
$content = apply_filters( 'user_request_action_email_content', $email_text, $email_data );
[4132] Fix | Delete
[4133] Fix | Delete
$content = str_replace( '###DESCRIPTION###', $email_data['description'], $content );
[4134] Fix | Delete
$content = str_replace( '###CONFIRM_URL###', esc_url_raw( $email_data['confirm_url'] ), $content );
[4135] Fix | Delete
$content = str_replace( '###EMAIL###', $email_data['email'], $content );
[4136] Fix | Delete
$content = str_replace( '###SITENAME###', $email_data['sitename'], $content );
[4137] Fix | Delete
$content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content );
[4138] Fix | Delete
[4139] Fix | Delete
/* translators: Confirm privacy data request notification email subject. 1: Site title, 2: Name of the action. */
[4140] Fix | Delete
$subject = sprintf( __( '[%1$s] Confirm Action: %2$s' ), $email_data['sitename'], $email_data['description'] );
[4141] Fix | Delete
[4142] Fix | Delete
/**
[4143] Fix | Delete
* Filters the subject of the email sent when an account action is attempted.
[4144] Fix | Delete
*
[4145] Fix | Delete
* @since 4.9.6
[4146] Fix | Delete
*
[4147] Fix | Delete
* @param string $subject The email subject.
[4148] Fix | Delete
* @param string $sitename The name of the site.
[4149] Fix | Delete
* @param array $email_data {
[4150] Fix | Delete
* Data relating to the account action email.
[4151] Fix | Delete
*
[4152] Fix | Delete
* @type WP_User_Request $request User request object.
[4153] Fix | Delete
* @type string $email The email address this is being sent to.
[4154] Fix | Delete
* @type string $description Description of the action being performed so the user knows what the email is for.
[4155] Fix | Delete
* @type string $confirm_url The link to click on to confirm the account action.
[4156] Fix | Delete
* @type string $sitename The site name sending the mail.
[4157] Fix | Delete
* @type string $siteurl The site URL sending the mail.
[4158] Fix | Delete
* }
[4159] Fix | Delete
*/
[4160] Fix | Delete
$subject = apply_filters( 'user_request_action_email_subject', $subject, $email_data['sitename'], $email_data );
[4161] Fix | Delete
[4162] Fix | Delete
$headers = '';
[4163] Fix | Delete
[4164] Fix | Delete
/**
[4165] Fix | Delete
* Filters the headers of the email sent when an account action is attempted.
[4166] Fix | Delete
*
[4167] Fix | Delete
* @since 5.4.0
[4168] Fix | Delete
*
[4169] Fix | Delete
* @param string|array $headers The email headers.
[4170] Fix | Delete
* @param string $subject The email subject.
[4171] Fix | Delete
* @param string $content The email content.
[4172] Fix | Delete
* @param int $request_id The request ID.
[4173] Fix | Delete
* @param array $email_data {
[4174] Fix | Delete
* Data relating to the account action email.
[4175] Fix | Delete
*
[4176] Fix | Delete
* @type WP_User_Request $request User request object.
[4177] Fix | Delete
* @type string $email The email address this is being sent to.
[4178] Fix | Delete
* @type string $description Description of the action being performed so the user knows what the email is for.
[4179] Fix | Delete
* @type string $confirm_url The link to click on to confirm the account action.
[4180] Fix | Delete
* @type string $sitename The site name sending the mail.
[4181] Fix | Delete
* @type string $siteurl The site URL sending the mail.
[4182] Fix | Delete
* }
[4183] Fix | Delete
*/
[4184] Fix | Delete
$headers = apply_filters( 'user_request_action_email_headers', $headers, $subject, $content, $request_id, $email_data );
[4185] Fix | Delete
[4186] Fix | Delete
$email_sent = wp_mail( $email_data['email'], $subject, $content, $headers );
[4187] Fix | Delete
[4188] Fix | Delete
if ( $switched_locale ) {
[4189] Fix | Delete
restore_previous_locale();
[4190] Fix | Delete
}
[4191] Fix | Delete
[4192] Fix | Delete
if ( ! $email_sent ) {
[4193] Fix | Delete
return new WP_Error( 'privacy_email_error', __( 'Unable to send personal data export confirmation email.' ) );
[4194] Fix | Delete
}
[4195] Fix | Delete
[4196] Fix | Delete
return true;
[4197] Fix | Delete
}
[4198] Fix | Delete
[4199] Fix | Delete
/**
[4200] Fix | Delete
* Returns a confirmation key for a user action and stores the hashed version for future comparison.
[4201] Fix | Delete
*
[4202] Fix | Delete
* @since 4.9.6
[4203] Fix | Delete
*
[4204] Fix | Delete
* @param int $request_id Request ID.
[4205] Fix | Delete
* @return string Confirmation key.
[4206] Fix | Delete
*/
[4207] Fix | Delete
function wp_generate_user_request_key( $request_id ) {
[4208] Fix | Delete
global $wp_hasher;
[4209] Fix | Delete
[4210] Fix | Delete
// Generate something random for a confirmation key.
[4211] Fix | Delete
$key = wp_generate_password( 20, false );
[4212] Fix | Delete
[4213] Fix | Delete
// Return the key, hashed.
[4214] Fix | Delete
if ( empty( $wp_hasher ) ) {
[4215] Fix | Delete
require_once ABSPATH . WPINC . '/class-phpass.php';
[4216] Fix | Delete
$wp_hasher = new PasswordHash( 8, true );
[4217] Fix | Delete
}
[4218] Fix | Delete
[4219] Fix | Delete
wp_update_post(
[4220] Fix | Delete
array(
[4221] Fix | Delete
'ID' => $request_id,
[4222] Fix | Delete
'post_status' => 'request-pending',
[4223] Fix | Delete
'post_password' => $wp_hasher->HashPassword( $key ),
[4224] Fix | Delete
)
[4225] Fix | Delete
);
[4226] Fix | Delete
[4227] Fix | Delete
return $key;
[4228] Fix | Delete
}
[4229] Fix | Delete
[4230] Fix | Delete
/**
[4231] Fix | Delete
* Validate a user request by comparing the key with the request's key.
[4232] Fix | Delete
*
[4233] Fix | Delete
* @since 4.9.6
[4234] Fix | Delete
*
[4235] Fix | Delete
* @param string $request_id ID of the request being confirmed.
[4236] Fix | Delete
* @param string $key Provided key to validate.
[4237] Fix | Delete
* @return true|WP_Error True on success, WP_Error on failure.
[4238] Fix | Delete
*/
[4239] Fix | Delete
function wp_validate_user_request_key( $request_id, $key ) {
[4240] Fix | Delete
global $wp_hasher;
[4241] Fix | Delete
[4242] Fix | Delete
$request_id = absint( $request_id );
[4243] Fix | Delete
$request = wp_get_user_request( $request_id );
[4244] Fix | Delete
$saved_key = $request->confirm_key;
[4245] Fix | Delete
$key_request_time = $request->modified_timestamp;
[4246] Fix | Delete
[4247] Fix | Delete
if ( ! $request || ! $saved_key || ! $key_request_time ) {
[4248] Fix | Delete
return new WP_Error( 'invalid_request', __( 'Invalid personal data request.' ) );
[4249] Fix | Delete
}
[4250] Fix | Delete
[4251] Fix | Delete
if ( ! in_array( $request->status, array( 'request-pending', 'request-failed' ), true ) ) {
[4252] Fix | Delete
return new WP_Error( 'expired_request', __( 'This personal data request has expired.' ) );
[4253] Fix | Delete
}
[4254] Fix | Delete
[4255] Fix | Delete
if ( empty( $key ) ) {
[4256] Fix | Delete
return new WP_Error( 'missing_key', __( 'The confirmation key is missing from this personal data request.' ) );
[4257] Fix | Delete
}
[4258] Fix | Delete
[4259] Fix | Delete
if ( empty( $wp_hasher ) ) {
[4260] Fix | Delete
require_once ABSPATH . WPINC . '/class-phpass.php';
[4261] Fix | Delete
$wp_hasher = new PasswordHash( 8, true );
[4262] Fix | Delete
}
[4263] Fix | Delete
[4264] Fix | Delete
/**
[4265] Fix | Delete
* Filters the expiration time of confirm keys.
[4266] Fix | Delete
*
[4267] Fix | Delete
* @since 4.9.6
[4268] Fix | Delete
*
[4269] Fix | Delete
* @param int $expiration The expiration time in seconds.
[4270] Fix | Delete
*/
[4271] Fix | Delete
$expiration_duration = (int) apply_filters( 'user_request_key_expiration', DAY_IN_SECONDS );
[4272] Fix | Delete
$expiration_time = $key_request_time + $expiration_duration;
[4273] Fix | Delete
[4274] Fix | Delete
if ( ! $wp_hasher->CheckPassword( $key, $saved_key ) ) {
[4275] Fix | Delete
return new WP_Error( 'invalid_key', __( 'The confirmation key is invalid for this personal data request.' ) );
[4276] Fix | Delete
}
[4277] Fix | Delete
[4278] Fix | Delete
if ( ! $expiration_time || time() > $expiration_time ) {
[4279] Fix | Delete
return new WP_Error( 'expired_key', __( 'The confirmation key has expired for this personal data request.' ) );
[4280] Fix | Delete
}
[4281] Fix | Delete
[4282] Fix | Delete
return true;
[4283] Fix | Delete
}
[4284] Fix | Delete
[4285] Fix | Delete
/**
[4286] Fix | Delete
* Return the user request object for the specified request ID.
[4287] Fix | Delete
*
[4288] Fix | Delete
* @since 4.9.6
[4289] Fix | Delete
*
[4290] Fix | Delete
* @param int $request_id The ID of the user request.
[4291] Fix | Delete
* @return WP_User_Request|false
[4292] Fix | Delete
*/
[4293] Fix | Delete
function wp_get_user_request( $request_id ) {
[4294] Fix | Delete
$request_id = absint( $request_id );
[4295] Fix | Delete
$post = get_post( $request_id );
[4296] Fix | Delete
[4297] Fix | Delete
if ( ! $post || 'user_request' !== $post->post_type ) {
[4298] Fix | Delete
return false;
[4299] Fix | Delete
}
[4300] Fix | Delete
[4301] Fix | Delete
return new WP_User_Request( $post );
[4302] Fix | Delete
}
[4303] Fix | Delete
[4304] Fix | Delete
/**
[4305] Fix | Delete
* Checks if Application Passwords is globally available.
[4306] Fix | Delete
*
[4307] Fix | Delete
* By default, Application Passwords is available to all sites using SSL or to local environments.
[4308] Fix | Delete
* Use {@see 'wp_is_application_passwords_available'} to adjust its availability.
[4309] Fix | Delete
*
[4310] Fix | Delete
* @since 5.6.0
[4311] Fix | Delete
*
[4312] Fix | Delete
* @return bool
[4313] Fix | Delete
*/
[4314] Fix | Delete
function wp_is_application_passwords_available() {
[4315] Fix | Delete
$available = is_ssl() || 'local' === wp_get_environment_type();
[4316] Fix | Delete
[4317] Fix | Delete
/**
[4318] Fix | Delete
* Filters whether Application Passwords is available.
[4319] Fix | Delete
*
[4320] Fix | Delete
* @since 5.6.0
[4321] Fix | Delete
*
[4322] Fix | Delete
* @param bool $available True if available, false otherwise.
[4323] Fix | Delete
*/
[4324] Fix | Delete
return apply_filters( 'wp_is_application_passwords_available', $available );
[4325] Fix | Delete
}
[4326] Fix | Delete
[4327] Fix | Delete
/**
[4328] Fix | Delete
* Checks if Application Passwords is available for a specific user.
[4329] Fix | Delete
*
[4330] Fix | Delete
* By default all users can use Application Passwords. Use {@see 'wp_is_application_passwords_available_for_user'}
[4331] Fix | Delete
* to restrict availability to certain users.
[4332] Fix | Delete
*
[4333] Fix | Delete
* @since 5.6.0
[4334] Fix | Delete
*
[4335] Fix | Delete
* @param int|WP_User $user The user to check.
[4336] Fix | Delete
* @return bool
[4337] Fix | Delete
*/
[4338] Fix | Delete
function wp_is_application_passwords_available_for_user( $user ) {
[4339] Fix | Delete
if ( ! wp_is_application_passwords_available() ) {
[4340] Fix | Delete
return false;
[4341] Fix | Delete
}
[4342] Fix | Delete
[4343] Fix | Delete
if ( ! is_object( $user ) ) {
[4344] Fix | Delete
$user = get_userdata( $user );
[4345] Fix | Delete
}
[4346] Fix | Delete
[4347] Fix | Delete
if ( ! $user || ! $user->exists() ) {
[4348] Fix | Delete
return false;
[4349] Fix | Delete
}
[4350] Fix | Delete
[4351] Fix | Delete
/**
[4352] Fix | Delete
* Filters whether Application Passwords is available for a specific user.
[4353] Fix | Delete
*
[4354] Fix | Delete
* @since 5.6.0
[4355] Fix | Delete
*
[4356] Fix | Delete
* @param bool $available True if available, false otherwise.
[4357] Fix | Delete
* @param WP_User $user The user to check.
[4358] Fix | Delete
*/
[4359] Fix | Delete
return apply_filters( 'wp_is_application_passwords_available_for_user', true, $user );
[4360] Fix | Delete
}
[4361] Fix | Delete
[4362] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function