Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit a389601

Browse files
nerradsenadir
authored andcommitted
fix invalid filter usage and include WP_Error check
1 parent e35f89a commit a389601

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Diff for: src/RestApi.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class RestApi {
1919
*/
2020
public static function init() {
2121
add_action( 'rest_api_init', array( __CLASS__, 'register_rest_routes' ), 10 );
22-
add_filter( 'rest_authentication_errors', array( __CLASS__, 'maybe_init_cart_session' ), 1, 2 );
22+
add_filter( 'rest_authentication_errors', array( __CLASS__, 'maybe_init_cart_session' ), 1 );
2323
}
2424

2525
/**
@@ -61,12 +61,13 @@ public static function get_routes_from_namespace( $namespace ) {
6161
*
6262
* @todo check compat < WC 3.6. Make specific to cart endpoint.
6363
* @param mixed $return Value being filtered.
64-
* @param array $request Request data.
6564
* @return mixed
6665
*/
67-
public static function maybe_init_cart_session( $return, $request = false ) {
66+
public static function maybe_init_cart_session( $return ) {
6867
$wc_instance = wc();
69-
if ( ! $wc_instance instanceof \WooCommerce ) {
68+
// if WooCommerce instance isn't available or already have an
69+
// authentication error, just return.
70+
if ( ! $wc_instance instanceof \WooCommerce || \is_wp_error( $return ) ) {
7071
return $return;
7172
}
7273
$wc_instance->frontend_includes();

0 commit comments

Comments
 (0)