ID ) ? absint( $user->ID ) : 0; if ( $userId <= 0 ) { return; } $storedHandle = get_user_meta( $userId, self::META_KEY, true ); $handle = MetaPayload::sanitizeTwitterHandle( $storedHandle ); ?>

403 ] ); } check_admin_referer( 'update-user_' . $userId ); // The value is only read when it is a string, so an array shaped field // can never reach the sanitiser with the wrong type. // phpcs:ignore WordPress.Security.NonceVerification.Missing -- nonce verified above. $rawHandle = isset( $_POST[ self::META_KEY ] ) && is_string( $_POST[ self::META_KEY ] ) ? sanitize_text_field( wp_unslash( $_POST[ self::META_KEY ] ) ) : null; if ( ! is_string( $rawHandle ) ) { return; } $storedHandle = get_user_meta( $userId, self::META_KEY, true ); $currentHandle = MetaPayload::sanitizeTwitterHandle( is_string( $storedHandle ) ? $storedHandle : '' ); $newHandle = MetaPayload::sanitizeTwitterHandle( $rawHandle ); if ( $currentHandle === $newHandle ) { return; } $saved = update_user_meta( $userId, self::META_KEY, $newHandle ); // A strict false means the write failed, so the editor sees an error // instead of core's success notice while the handle was lost. if ( false === $saved ) { wp_die( esc_html__( 'The X handle could not be saved. Please try again.', 'rankkernel' ), '', [ 'response' => 500 ] ); } } }