Skip to content

Commit

Permalink
Remove update_user_meta and delete_user_meta updates
Browse files Browse the repository at this point in the history
  • Loading branch information
benlk committed Apr 15, 2023
1 parent 26e1543 commit 234d22e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
8 changes: 0 additions & 8 deletions classes/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

Expand All @@ -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 );
}
}
6 changes: 3 additions & 3 deletions classes/class-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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' );
Expand Down
4 changes: 2 additions & 2 deletions classes/class-live-update.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down

0 comments on commit 234d22e

Please sign in to comment.