Automattic\WooCommerce\StoreApi\Routes\V1\Ucp
CatalogSearch::decode_cursor
Decode a cursor string back into a numeric offset.
Method of the class: CatalogSearch{}
No Hooks.
Returns
int.
Usage
// private - for code of main (parent) class only $result = $this->decode_cursor( $cursor ): int;
- $cursor(string) (required)
- Opaque cursor string.
CatalogSearch::decode_cursor() CatalogSearch::decode cursor code WC 11.3.0
private function decode_cursor( string $cursor ): int {
if ( '' === $cursor ) {
return 0;
}
$decoded = base64_decode( $cursor, true ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode
if ( false === $decoded || 0 !== strpos( $decoded, 'offset:' ) ) {
return 0;
}
return max( 0, (int) substr( $decoded, 7 ) );
}