llms_rest_get_all_error_statuses( WP_Error $wp_error )
Returns all the error statuses of a WP_Error
Parameters Parameters
- $wp_error
-
(WP_Error) (Required) The WP_Error object.
Return Return
(int[])
Source Source
File: libraries/lifterlms-rest/includes/server/llms-rest-server-functions.php
function llms_rest_get_all_error_statuses( $wp_error ) { $statuses = array(); if ( is_wp_error( $wp_error ) && ! empty( $wp_error->has_errors() ) ) { /** * The method `get_all_error_data()` has been introduced in wp 5.6.0. * TODO: remove bw compatibility when min wp version will be raised above 5.6.0. */ global $wp_version; $func = ( version_compare( $wp_version, 5.6, '>=' ) ) ? 'get_all_error_data' : 'get_error_data'; foreach ( $wp_error->get_error_codes() as $code ) { $status = $wp_error->{$func}( $code ); $status = 'get_error_data' === $func ? array( $status ) : $status; /** * Use native `array_column()` in place of `wp_list_pluck()` as: * 1) `$status` is fors ure an array (and not possibly an object); * 2) `wp_list_pluck()` raises an error if the key ('status' in this case) is not found. */ $statuses = array_merge( $statuses, array_column( $status, 'status' ) ); } $statuses = array_filter( array_unique( $statuses ) ); } return $statuses; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
1.0.0-beta.18 | Introduced. |