Skip to content

Commit

Permalink
Merge pull request #1425 from benlk/benlk-remove-get_user_attribute
Browse files Browse the repository at this point in the history
Remove get_user_attribute() helpers deprecated by WP VIP.
  • Loading branch information
kasparsd authored Sep 13, 2023
2 parents 1b56808 + 234d22e commit 4979211
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 20 deletions.
2 changes: 0 additions & 2 deletions alerts/class-alert-type-menu-alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
12 changes: 0 additions & 12 deletions classes/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1091,10 +1091,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 );
}

Expand All @@ -1109,10 +1105,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 @@ -1126,10 +1118,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 @@ -151,12 +151,12 @@ 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 ) {
$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 @@ -1139,7 +1139,7 @@ public function screen_controls( $status, $args ) {
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
6 changes: 3 additions & 3 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 Expand Up @@ -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(
Expand Down

0 comments on commit 4979211

Please sign in to comment.