From b79f938e6d8d601520f59d0297083377e41ad809 Mon Sep 17 00:00:00 2001 From: Ben Keith Date: Fri, 14 Apr 2023 20:41:35 -0400 Subject: [PATCH 1/3] Remove get_user_attribute --- classes/class-admin.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/classes/class-admin.php b/classes/class-admin.php index 947c47af..ce4f0631 100644 --- a/classes/class-admin.php +++ b/classes/class-admin.php @@ -1086,10 +1086,6 @@ public function get_users_record_meta( $authors ) { * @return mixed */ public function get_user_meta( $user_id, $meta_key, $single = true ) { - if ( wp_stream_is_vip() && function_exists( 'get_user_attribute' ) ) { - return get_user_attribute( $user_id, $meta_key ); - } - return get_user_meta( $user_id, $meta_key, $single ); } From 26e1543156f67d90a072919e66a3fc25405d0626 Mon Sep 17 00:00:00 2001 From: Ben Keith Date: Fri, 14 Apr 2023 20:43:18 -0400 Subject: [PATCH 2/3] Remove references to this self-defined get_user_meta function --- alerts/class-alert-type-menu-alert.php | 2 -- classes/class-list-table.php | 4 ++-- classes/class-live-update.php | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/alerts/class-alert-type-menu-alert.php b/alerts/class-alert-type-menu-alert.php index b3950d93..99032b65 100644 --- a/alerts/class-alert-type-menu-alert.php +++ b/alerts/class-alert-type-menu-alert.php @@ -141,8 +141,6 @@ public function menu_alert( $wp_admin_bar ) { /** * Get a list of all current alert messages for current user. * - * @todo update this for VIP. (get_user_meta) - * * @return array List of alert messages */ public function get_messages() { diff --git a/classes/class-list-table.php b/classes/class-list-table.php index 6a5d3231..0443c919 100644 --- a/classes/class-list-table.php +++ b/classes/class-list-table.php @@ -151,7 +151,7 @@ public function get_hidden_columns() { } // Directly checking the user meta; to check whether user has changed screen option or not. - $hidden = $this->plugin->admin->get_user_meta( $user->ID, 'manage' . $this->screen->id . 'columnshidden', true ); + $hidden = get_user_meta( $user->ID, 'manage' . $this->screen->id . 'columnshidden', true ); // If user meta is not found; add the default hidden column 'id'. if ( ! $hidden ) { @@ -1133,7 +1133,7 @@ public function screen_controls( $status, $args ) { unset( $args ); $user_id = get_current_user_id(); - $option = $this->plugin->admin->get_user_meta( $user_id, $this->plugin->admin->live_update->user_meta_key, true ); + $option = get_user_meta( $user_id, $this->plugin->admin->live_update->user_meta_key, true ); $heartbeat = wp_script_is( 'heartbeat', 'done' ) ? 'true' : 'false'; if ( 'on' === $option && 'false' === $heartbeat ) { diff --git a/classes/class-live-update.php b/classes/class-live-update.php index 220288bc..eff2f100 100644 --- a/classes/class-live-update.php +++ b/classes/class-live-update.php @@ -183,7 +183,7 @@ public function heartbeat_received( $response, $data ) { return $response; } - $enable_stream_update = ( 'off' !== $this->plugin->admin->get_user_meta( get_current_user_id(), $this->user_meta_key ) ); + $enable_stream_update = ( 'off' !== get_user_meta( get_current_user_id(), $this->user_meta_key ) ); // Register list table. $this->list_table = new List_Table( From 234d22e887fc8af68114102bc81f173bd4abce9e Mon Sep 17 00:00:00 2001 From: Ben Keith Date: Fri, 14 Apr 2023 20:57:22 -0400 Subject: [PATCH 3/3] Remove update_user_meta and delete_user_meta updates --- classes/class-admin.php | 8 -------- classes/class-list-table.php | 6 +++--- classes/class-live-update.php | 4 ++-- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/classes/class-admin.php b/classes/class-admin.php index ce4f0631..8f1c548f 100644 --- a/classes/class-admin.php +++ b/classes/class-admin.php @@ -1100,10 +1100,6 @@ public function get_user_meta( $user_id, $meta_key, $single = true ) { * @return int|bool */ public function update_user_meta( $user_id, $meta_key, $meta_value, $prev_value = '' ) { - if ( wp_stream_is_vip() && function_exists( 'update_user_attribute' ) ) { - return update_user_attribute( $user_id, $meta_key, $meta_value ); - } - return update_user_meta( $user_id, $meta_key, $meta_value, $prev_value ); } @@ -1117,10 +1113,6 @@ public function update_user_meta( $user_id, $meta_key, $meta_value, $prev_value * @return bool */ public function delete_user_meta( $user_id, $meta_key, $meta_value = '' ) { - if ( wp_stream_is_vip() && function_exists( 'delete_user_attribute' ) ) { - return delete_user_attribute( $user_id, $meta_key, $meta_value ); - } - return delete_user_meta( $user_id, $meta_key, $meta_value ); } } diff --git a/classes/class-list-table.php b/classes/class-list-table.php index 0443c919..23c8a4f3 100644 --- a/classes/class-list-table.php +++ b/classes/class-list-table.php @@ -156,7 +156,7 @@ public function get_hidden_columns() { // If user meta is not found; add the default hidden column 'id'. if ( ! $hidden ) { $hidden = array( 'id' ); - $this->plugin->admin->update_user_meta( $user->ID, 'manage' . $this->screen->id . 'columnshidden', $hidden ); + update_user_meta( $user->ID, 'manage' . $this->screen->id . 'columnshidden', $hidden ); } return $hidden; @@ -1133,13 +1133,13 @@ public function screen_controls( $status, $args ) { unset( $args ); $user_id = get_current_user_id(); - $option = get_user_meta( $user_id, $this->plugin->admin->live_update->user_meta_key, true ); + $option = $this->plugin->admin->get_user_meta( $user_id, $this->plugin->admin->live_update->user_meta_key, true ); $heartbeat = wp_script_is( 'heartbeat', 'done' ) ? 'true' : 'false'; if ( 'on' === $option && 'false' === $heartbeat ) { $option = 'off'; - $this->plugin->admin->update_user_meta( $user_id, $this->plugin->admin->live_update->user_meta_key, 'off' ); + update_user_meta( $user_id, $this->plugin->admin->live_update->user_meta_key, 'off' ); } $nonce = wp_create_nonce( $this->plugin->admin->live_update->user_meta_key . '_nonce' ); diff --git a/classes/class-live-update.php b/classes/class-live-update.php index eff2f100..f20d0baa 100644 --- a/classes/class-live-update.php +++ b/classes/class-live-update.php @@ -72,14 +72,14 @@ public function enable_live_update() { $user = (int) $input['user']; if ( 'false' === $input['heartbeat'] ) { - $this->plugin->admin->update_user_meta( $user, $this->user_meta_key, 'off' ); + update_user_meta( $user, $this->user_meta_key, 'off' ); wp_send_json_error( esc_html__( "Live updates could not be enabled because Heartbeat is not loaded.\n\nYour hosting provider or another plugin may have disabled it for performance reasons.", 'stream' ) ); return; } - $success = $this->plugin->admin->update_user_meta( $user, $this->user_meta_key, $checked ); + $success = update_user_meta( $user, $this->user_meta_key, $checked ); if ( $success ) { wp_send_json_success( ( 'on' === $checked ) ? 'Live Updates enabled' : 'Live Updates disabled' );