Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wordpres.../src/user-met.../user-int...
File: custom-meta-integration.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\User_Meta\User_Interface;
[2] Fix | Delete
[3] Fix | Delete
use Yoast\WP\SEO\Conditionals\Admin_Conditional;
[4] Fix | Delete
use Yoast\WP\SEO\Conditionals\User_Can_Edit_Users_Conditional;
[5] Fix | Delete
use Yoast\WP\SEO\Conditionals\User_Edit_Conditional;
[6] Fix | Delete
use Yoast\WP\SEO\Integrations\Integration_Interface;
[7] Fix | Delete
use Yoast\WP\SEO\User_Meta\Application\Custom_Meta_Collector;
[8] Fix | Delete
[9] Fix | Delete
/**
[10] Fix | Delete
* Handles custom meta for users.
[11] Fix | Delete
*/
[12] Fix | Delete
class Custom_Meta_Integration implements Integration_Interface {
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* The custom meta collector.
[16] Fix | Delete
*
[17] Fix | Delete
* @var Custom_Meta_Collector $custom_meta_collector The custom meta collector.
[18] Fix | Delete
*/
[19] Fix | Delete
private $custom_meta_collector;
[20] Fix | Delete
[21] Fix | Delete
/**
[22] Fix | Delete
* The constructor.
[23] Fix | Delete
*
[24] Fix | Delete
* @param Custom_Meta_Collector $custom_meta_collector The custom meta collector.
[25] Fix | Delete
*/
[26] Fix | Delete
public function __construct( Custom_Meta_Collector $custom_meta_collector ) {
[27] Fix | Delete
$this->custom_meta_collector = $custom_meta_collector;
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
/**
[31] Fix | Delete
* Retrieves the conditionals for the integration.
[32] Fix | Delete
*
[33] Fix | Delete
* @return array<Yoast\WP\SEO\Conditionals> The conditionals.
[34] Fix | Delete
*/
[35] Fix | Delete
public static function get_conditionals() {
[36] Fix | Delete
return [
[37] Fix | Delete
Admin_Conditional::class,
[38] Fix | Delete
User_Can_Edit_Users_Conditional::class,
[39] Fix | Delete
User_Edit_Conditional::class,
[40] Fix | Delete
];
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
/**
[44] Fix | Delete
* Registers action hook.
[45] Fix | Delete
*
[46] Fix | Delete
* @return void
[47] Fix | Delete
*/
[48] Fix | Delete
public function register_hooks(): void {
[49] Fix | Delete
\add_action( 'personal_options_update', [ $this, 'process_user_option_update' ] );
[50] Fix | Delete
\add_action( 'edit_user_profile_update', [ $this, 'process_user_option_update' ] );
[51] Fix | Delete
}
[52] Fix | Delete
[53] Fix | Delete
/**
[54] Fix | Delete
* Updates the user metas that (might) have been set on the user profile page.
[55] Fix | Delete
*
[56] Fix | Delete
* @param int $user_id User ID of the updated user.
[57] Fix | Delete
*
[58] Fix | Delete
* @return void
[59] Fix | Delete
*/
[60] Fix | Delete
public function process_user_option_update( $user_id ) {
[61] Fix | Delete
\update_user_meta( $user_id, '_yoast_wpseo_profile_updated', \time() );
[62] Fix | Delete
[63] Fix | Delete
if ( ! \check_admin_referer( 'wpseo_user_profile_update', 'wpseo_nonce' ) ) {
[64] Fix | Delete
return;
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
foreach ( $this->custom_meta_collector->get_custom_meta() as $meta ) {
[68] Fix | Delete
$meta_field_id = $meta->get_field_id();
[69] Fix | Delete
[70] Fix | Delete
$user_input_to_store = isset( $_POST[ $meta_field_id ] ) ? \sanitize_text_field( \wp_unslash( $_POST[ $meta_field_id ] ) ) : '';
[71] Fix | Delete
if ( $meta->is_empty_allowed() || $user_input_to_store !== '' ) {
[72] Fix | Delete
\update_user_meta( $user_id, $meta->get_key(), $user_input_to_store );
[73] Fix | Delete
continue;
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
\delete_user_meta( $user_id, $meta->get_key() );
[77] Fix | Delete
}
[78] Fix | Delete
}
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function