sint( $plan['scan_limit'] ) : 100, 'log_limit' => isset( $plan['log_limit'] ) ? absint( $plan['log_limit'] ) : 5000, 'log_limit' => isset( $plan['log_limit'] ) ? absint( $plan['log_limit'] ) : 5000, 'features' => array( 'multi_law' => isset( $features['multi_law'] ) && true === $features['multi_law'] ? true : false, 'custom_css' => isset( $features['custom_css'] ) && true === $features['custom_css'] ? true : false, 'custom_branding' => isset( $features['custom_branding'] ) && true === $features['custom_branding'] ? true : false, 'config_geo_rules' => isset( $features['config_geo_rules'] ) && true === $features['config_geo_rules'] ? true : false, 'max_free_websites' => isset( $plan['max_free_websites'] ) ? absint( $plan['max_free_websites'] ) : 1, 'remove_powered_by' => isset( $features['remove_powered_by'] ) && true === $features['remove_powered_by'] ? true : false, 'popup_layout' => isset( $features['popup_layout'] ) && true === $features['popup_layout'] ? true : false, ), ), 'banners' => array( 'status' => isset( $response['banner_status'] ) && 1 === $response['banner_status'] ? true : false, 'laws' => $applicable_laws, 'is_iab_enabled' => isset( $response['isIABEnabled'] ) && true === $response['isIABEnabled'], 'targetedLocation' => isset( $response['targetedLocation'] ) ? $response['targetedLocation'] : 'worldwide', ), 'consent_logs' => array( 'status' => isset( $response['visitor_log'] ) && true === $response['visitor_log'] ? true : false, ), 'scans' => array( 'date' => array( 'date' => $date, 'time' => $time, ), 'status' => isset( $response['last_scan_at'] ) && '' !== $response['last_scan_at'] ? true : false, ), 'success_scan' => array( 'date' => array( 'date' => $success_date, 'time' => $success_time, ), 'status' => isset( $response['last_successful_scan_at'] ) && '' !== $response['last_successful_scan_at'], ), 'languages' => array( 'selected' => isset( $response['language']['preferred'] ) ? cky_sanitize_text( $response['language']['preferred'] ) : array(), 'default' => isset( $response['settings_json']['defaultLanguage'] ) ? cky_sanitize_text( $response['settings_json']['defaultLanguage'] ) : 'en', ), 'tables_missing' => false, 'pageviews' => array( 'count' => isset( $response['pageviews']['views'] ) ? absint( $response['pageviews']['views'] ) : 0, 'limit' => isset( $response['pageviews']['views_limit'] ) ? absint( $response['pageviews']['views_limit'] ) : 25000, 'exceeded' => isset( $response['pageviews']['limit_exceeded'] ) && 1 === absint( $response['pageviews']['limit_exceeded'] ), 'ends_at' => $pageview_reset_date, ), 'website' => array( 'status' => isset( $response['website_status'] ) ? sanitize_text_field( $response['website_status'] ) : 'active', 'is_trial' => isset( $response['is_trial'] ) && true === $response['is_trial'], 'is_trial_with_card' => isset( $response['trial_with_card'] ) && true === $response['trial_with_card'], 'grace_period_ends_at' => $grace_period_ends, 'payment_status' => isset( $response['payment_status'] ) && true === $response['payment_status'], ), ); return $data; } return new WP_Error( 'cky_api_fetching_failed', __( 'Failed to fetch data from the API', 'cookie-law-info' ), array( 'status' => 400 ) ); } /** * Force update app settings if any changes from the plugin side. * * @param array $settings Settings array. * @return void */ public function maybe_update_app_settings( $settings = array() ) { if ( ! cky_is_cloud_request() || ! $this->get_website_id() ) { return; } $data = array( 'preferred_languages' => isset( $settings['languages']['selected'] ) ? $settings['languages']['selected'] : array(), 'default_language' => isset( $settings['languages']['default'] ) ? $settings['languages']['default'] : 'en', 'visitor_log' => isset( $settings['consent_logs']['status'] ) && true === $settings['consent_logs']['status'] ? 1 : 0, ); $response = $this->put( 'websites/' . $this->get_website_id(), wp_json_encode( $data ) ); $response_code = wp_remote_retrieve_response_code( $response ); if ( 200 !== $response_code ) { return new WP_Error( 'cky_api_settings_update_failed', __( 'Failed to the update the data to web app', 'cookie-law-info' ), array( 'status' => 200 ) ); } } /** * Delete the cache. * * @return void */ public function delete_cache() { wp_cache_flush(); } }