self::mask($options['adscout_api_token']), 'partner_domain_hex' => self::mask($options['adscout_partner_domain_hex']), ); (new AdScout_Frontend())::include_partial('integration-settings', 'admin', $data); return; } public static function api_base_url_settings(): void { $response = wp_remote_get(ADSCOUT_LOCATIONS_URL); if ($response && wp_remote_retrieve_response_code($response) === 200) { $location_data = json_decode(wp_remote_retrieve_body($response), true); } $location_data = is_array($location_data) ? $location_data : [ ['name' => 'AdScout', 'url' => 'https://scoutefy.com/'], ]; $filtered_location_data = array_filter($location_data, function($item) { return is_array($item) && isset($item['name']) && isset($item['url']); }); $adjusted_location_data = array_map(function($item) { return ['name' => $item['name'], 'url' => $item['url']]; }, $filtered_location_data); $options = (new AdScout_Options()); $base_url = 'https://scoutefy.com/'; if($options::get_option('adscout_api_endpoint') and $options::get_option('adscout_api_endpoint') !== '') { $base_url = $options::get_option('adscout_api_endpoint'); } $locations_data = [ 'endpoints' => array_map(function ($item) { return [$item['name'] => $item['url']]; }, $adjusted_location_data), 'selected' => $base_url, ]; (new AdScout_Frontend())::include_partial('api-base-url', 'admin', $locations_data); } public static function feed_settings(): void { $options = (new AdScout_Options())::all_options(); $feed_data = array( 'as_feed_last_updated' => $options['as_feed_last_updated'] ?? false, 'as_feed_url' => $options['as_feed_url'] ?? false, ); (new AdScout_Frontend())::include_partial('feed-generator', 'admin', $feed_data); } public static function sync_user_data(): void { $options = (new AdScout_Options())::all_options(); (new AdScout_Frontend())::include_partial('share-order-personal-data', 'admin', [ 'applied' => (new AdScout_Options())::get_option('sync_user_data'), ]); } public static function coupon_settings(): void { (new AdScout_Frontend())::include_partial('coupon-settings', 'admin', [ 'url' => esc_url( get_rest_url() ) . ADSCOUT_API_ENDPOINT_PREFIX . ADSCOUT_API_ENDPOINT_NAME, ]); } public static function order_status_settings(): void { $options = (new AdScout_Options())::all_options(); if (!is_array($options['adscout_order_statuses_to_sync'])) { $statuses = explode(',', $options['adscout_order_statuses_to_sync']); } else { $statuses = $options['adscout_order_statuses_to_sync']; } $data = array( 'adscout_order_statuses_to_sync' => $statuses, ); (new AdScout_Frontend())::include_partial('order-sync-status-settings', 'admin', $data); } /** * Returns a masked token to show in frontend * @param $token * @return string */ public static function mask($token): string { if ($token and strlen($token) > 10) { return str_repeat('•', strlen(substr($token, -20)) - 10) . substr(substr($token, -20), -10); } return '••••••'; } }