← All changes
|
modules/content-generation/class-cartflows-ai-utils.php
+7
-2
3.2.0
→
3.3.0
View file →
| @@ -24,8 +24,10 @@ | ||
| 24 | 24 | private static $instance; |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * Initiator |
| 28 | + * | |
| 29 | + * @return self | |
| 28 | 30 | */ |
| 29 | 31 | public static function get_instance() { |
| 30 | 32 | if ( ! isset( self::$instance ) ) { |
| 31 | 33 | self::$instance = new self(); |
| @@ -161,14 +163,17 @@ | ||
| 161 | 163 | */ |
| 162 | 164 | protected function get_auth_data( $key = '' ) { |
| 163 | 165 | $auth_data = get_option( 'cartflows_auth', false ); |
| 164 | 166 | |
| 165 | - if ( empty( $auth_data ) ) { | |
| 167 | + if ( empty( $auth_data ) || ! is_array( $auth_data ) ) { | |
| 166 | 168 | return new WP_Error( 'no_auth_data', __( 'No authentication data found.', 'cartflows' ) ); |
| 167 | 169 | } |
| 168 | 170 | |
| 169 | 171 | if ( ! empty( $key ) && is_string( $key ) ) { |
| 170 | - return $auth_data[ $key ] ?? new WP_Error( 'no_key_found', __( 'No data found for the provided key.', 'cartflows' ) ); | |
| 172 | + $value = $auth_data[ $key ] ?? null; | |
| 173 | + return is_string( $value ) | |
| 174 | + ? $value | |
| 175 | + : new WP_Error( 'no_key_found', __( 'No data found for the provided key.', 'cartflows' ) ); | |
| 171 | 176 | } |
| 172 | 177 | |
| 173 | 178 | return $auth_data; |
| 174 | 179 | } |