| @@ -34,9 +34,9 @@ | ||
| 34 | 34 | if( is_array( $data ) && ! empty( $data ) ) { |
| 35 | 35 | return $data; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - $query = 'id, price, name, discounted_price, type, sites'; | |
| 38 | + $query = 'id, price, name, discounted_price, type, sites, coupon'; | |
| 39 | 39 | $response = $this->http()->query( |
| 40 | 40 | 'subscriptionPlans', |
| 41 | 41 | $query |
| 42 | 42 | )->post(); |
| @@ -60,8 +60,10 @@ | ||
| 60 | 60 | 'ip' => $_ip, |
| 61 | 61 | 'site_url' => $_site_url |
| 62 | 62 | ]; |
| 63 | 63 | |
| 64 | + $postArgs = []; | |
| 65 | + | |
| 64 | 66 | if ( $viaAPI ) { |
| 65 | 67 | $api_key = $this->get_param( 'api_key' ); |
| 66 | 68 | $funcArgs['api_key'] = $api_key; |
| 67 | 69 | |
| @@ -90,9 +92,9 @@ | ||
| 90 | 92 | $response = $this->http()->mutation( |
| 91 | 93 | $viaAPI ? 'connectWithApiKey' : 'connect', |
| 92 | 94 | $query, |
| 93 | 95 | $funcArgs |
| 94 | - )->post(); | |
| 96 | + )->post($postArgs); | |
| 95 | 97 | |
| 96 | 98 | if ( is_wp_error( $response ) ) { |
| 97 | 99 | return $response; |
| 98 | 100 | } |
| @@ -133,8 +135,10 @@ | ||
| 133 | 135 | unset( $response['user']['reviews'] ); |
| 134 | 136 | $meta['reviews'] = $_reviews; |
| 135 | 137 | } |
| 136 | 138 | |
| 139 | + // No longer need to manage is_live_api state - API selection is now handled by TEMPLATELY_DEV_API constant | |
| 140 | + | |
| 137 | 141 | $this->utils( 'options' )->set( 'user', $response['user'] ); |
| 138 | 142 | $response['user']['meta'] = $this->user_meta( $meta ); |
| 139 | 143 | |
| 140 | 144 | return $response; |
| @@ -180,11 +184,12 @@ | ||
| 180 | 184 | ->remove( 'reviews' ) |
| 181 | 185 | ->remove( 'cloud_activity' ) |
| 182 | 186 | ->remove( 'api_key' ) |
| 183 | 187 | ->remove( 'global_login' ) |
| 188 | + ->remove( 'total_download_counts' ) | |
| 184 | 189 | ->remove( 'templates_in_clouds' ); |
| 185 | 190 | |
| 186 | - if ( $this->utils( 'options' )->whoami() === 'global' ) { | |
| 191 | + if ( $this->utils( 'options' )->who_am_i() === 'global' ) { | |
| 187 | 192 | $this->utils( 'options' )->remove_global_login(); |
| 188 | 193 | } |
| 189 | 194 | |
| 190 | 195 | $global_user_id = $this->utils( 'options' )->is_global(); |
| @@ -200,9 +205,9 @@ | ||
| 200 | 205 | |
| 201 | 206 | return $global_user; |
| 202 | 207 | } |
| 203 | 208 | |
| 204 | - public static function is_signed() { | |
| 209 | + public static function is_signed(): array { | |
| 205 | 210 | $_response = [ |
| 206 | 211 | 'status' => 'success' |
| 207 | 212 | ]; |
| 208 | 213 | |
| @@ -220,9 +225,9 @@ | ||
| 220 | 225 | |
| 221 | 226 | return $_response; |
| 222 | 227 | } |
| 223 | 228 | |
| 224 | - public function user_meta( $meta = [] ) { | |
| 229 | + public function user_meta( $meta = [] ): array { | |
| 225 | 230 | $_meta = [ |
| 226 | 231 | 'link_account' => self::utils( 'options' )->link_account(), |
| 227 | 232 | 'unlink_account' => self::utils( 'options' )->unlink_account(), |
| 228 | 233 | 'is_globally_signed' => Login::is_globally_signed(), |
| @@ -235,12 +240,12 @@ | ||
| 235 | 240 | |
| 236 | 241 | return array_merge( $_meta, $meta ); |
| 237 | 242 | } |
| 238 | 243 | |
| 239 | - public static function is_globally_signed() { | |
| 244 | + public static function is_globally_signed(): bool { | |
| 240 | 245 | return rest_sanitize_boolean( ( new static )->utils( 'options' )->is_globally_signed() ); |
| 241 | 246 | } |
| 242 | 247 | |
| 243 | - public static function signed_as_global() { | |
| 248 | + public static function signed_as_global(): bool { | |
| 244 | 249 | return rest_sanitize_boolean( ( new static )->utils( 'options' )->signed_as_global() ); |
| 245 | 250 | } |
| 246 | 251 | } |