Automattic\WooCommerce\Admin\API
MobileAppQRLogin::shuffled_candidate_numbers
Build the shuffled candidate triple returned by /qr-login-status while in the scanned state. The order is fixed at scan time (in scan_token) and stored in challenge.shuffled so every poll returns the same array — re-shuffling per-poll caused visible tile flicker on wc-admin. Falls back to building + shuffling on the fly for any token record that predates the persisted-shuffle change.
Method of the class: MobileAppQRLogin{}
No Hooks.
Returns
array<int, string>.
Usage
// private - for code of main (parent) class only $result = $this->shuffled_candidate_numbers( $challenge ): array;
- $challenge(array<string, mixed>) (required)
- The challenge payload from the token record.
MobileAppQRLogin::shuffled_candidate_numbers() MobileAppQRLogin::shuffled candidate numbers code WC 11.0.1
private function shuffled_candidate_numbers( array $challenge ): array {
if ( isset( $challenge['shuffled'] ) && is_array( $challenge['shuffled'] ) ) {
return array_map( 'strval', $challenge['shuffled'] );
}
$real = isset( $challenge['real'] ) ? (string) $challenge['real'] : '';
$distractors = isset( $challenge['distractors'] ) && is_array( $challenge['distractors'] )
? array_map( 'strval', $challenge['distractors'] )
: array();
$candidates = array_merge( array( $real ), $distractors );
shuffle( $candidates );
return $candidates;
}