| @@ -213,23 +213,36 @@ | ||
| 213 | 213 | $profile_data = is_array( $hub_profile_ui ) ? $hub_profile_ui : array(); |
| 214 | 214 | $wpmudev = wd_di()->get( \WP_Defender\Behavior\WPMUDEV::class ); |
| 215 | 215 | $scan_api = wd_di()->get( \WP_Defender\Controller\Scan::class )->dump_routes_and_nonces(); |
| 216 | 216 | |
| 217 | - return array( | |
| 217 | + // wp_timezone_string() returns a raw offset like "+05:30" for sites that use | |
| 218 | + // a numeric GMT offset instead of a named timezone. Intl.DateTimeFormat does | |
| 219 | + // not accept "+05:30", but it does accept the "UTC+05:30" form in all modern | |
| 220 | + // browsers (Chrome 24+, Firefox 23+, Safari 10+). Prefix the offset so the | |
| 221 | + // JS Intl APIs work correctly without falling back to the browser timezone. | |
| 222 | + $tz_string = wp_timezone_string(); | |
| 223 | + if ( preg_match( '/^[+-]/', $tz_string ) ) { | |
| 224 | + $tz_string = 'UTC' . $tz_string; | |
| 225 | + } | |
| 226 | + | |
| 227 | + $data = array( | |
| 218 | 228 | 'defenderUrl' => network_admin_url( 'admin.php?page=wp-defender' ), |
| 219 | 229 | 'pluginUrl' => WP_DEFENDER_BASE_URL, |
| 220 | 230 | 'adminUrl' => network_admin_url(), |
| 221 | 231 | 'siteUrl' => network_site_url(), |
| 232 | + 'timeZone' => $tz_string, | |
| 233 | + 'timeZoneOffset' => (int) round( wp_timezone()->getOffset( new \DateTime( 'now' ) ) / 60 ), | |
| 234 | + 'startOfWeek' => (int) get_option( 'start_of_week', 1 ), | |
| 222 | 235 | 'profileData' => $profile_data, |
| 223 | 236 | 'hubConnector' => wd_di()->get( \WP_Defender\Controller\Hub_Connector::class )->data_frontend(), |
| 224 | - 'isPro' => $wpmudev->is_pro(), | |
| 225 | - 'isWpOrg' => defender_is_wp_org_version(), | |
| 226 | 237 | 'pluginUpdate' => $this->get_plugin_update_notice_data(), |
| 227 | 238 | 'whiteLabel' => defender_whitelabel_data(), |
| 228 | 239 | 'activityLog' => wd_di()->get( \WP_Defender\Controller\Activity_Log::class )->data_frontend(), |
| 229 | 240 | 'hubApiKey' => array( |
| 230 | - 'available' => false !== $wpmudev->get_apikey(), | |
| 241 | + 'available' => $wpmudev->is_apikey_available(), | |
| 231 | 242 | ), |
| 243 | + 'isWpOrg' => defender_is_wp_org_version(), | |
| 244 | + 'isPro' => $wpmudev->is_pro(), | |
| 232 | 245 | 'hosted' => $wpmudev->is_wpmu_hosting(), |
| 233 | 246 | 'highContrastMode' => defender_high_contrast(), |
| 234 | 247 | 'isUnlimitedHosting' => defender_is_unlimited_hosting(), |
| 235 | 248 | 'scanApi' => array( |
| @@ -236,8 +249,10 @@ | ||
| 236 | 249 | 'routes' => $scan_api['routes'] ?? array(), |
| 237 | 250 | 'nonces' => $scan_api['nonces'] ?? array(), |
| 238 | 251 | ), |
| 239 | 252 | ); |
| 253 | + | |
| 254 | + return $data; | |
| 240 | 255 | } |
| 241 | 256 | |
| 242 | 257 | /** |
| 243 | 258 | * Page-specific data for a concrete controller. |