| @@ -50,11 +50,12 @@ | ||
| 50 | 50 | |
| 51 | 51 | $cfg = array( |
| 52 | 52 | 'endpoint' => esc_url_raw( rest_url( 'easyfonts/v1/async-fonts' ) ), |
| 53 | 53 | 'nonce' => wp_create_nonce( 'wp_rest' ), |
| 54 | + 'token' => Settings::beacon_token(), | |
| 54 | 55 | ); |
| 55 | 56 | |
| 56 | - $src = EASYFONTS_DIR . 'assets/frontend/async-blocker.js'; | |
| 57 | + $src = EASYFONTS_DIR . 'assets/frontend/async-blocker.min.js'; | |
| 57 | 58 | |
| 58 | 59 | if ( ! is_readable( $src ) ) { |
| 59 | 60 | return; |
| 60 | 61 | } |
| @@ -80,8 +81,14 @@ | ||
| 80 | 81 | if ( is_admin() ) { |
| 81 | 82 | return; |
| 82 | 83 | } |
| 83 | 84 | |
| 85 | + // Master kill switch: when Easy Fonts is disabled, add nothing to the | |
| 86 | + // front end — no beacon, no X-ray, no inline config. | |
| 87 | + if ( ! Settings::get( 'enabled', 1 ) ) { | |
| 88 | + return; | |
| 89 | + } | |
| 90 | + | |
| 84 | 91 | $route = (string) wp_parse_url( home_url( add_query_arg( array() ) ), PHP_URL_PATH ); |
| 85 | 92 | $device = wp_is_mobile() ? 'mobile' : 'desktop'; |
| 86 | 93 | |
| 87 | 94 | if ( Settings::get( 'beacon', 1 ) ) { |
| @@ -86,9 +93,9 @@ | ||
| 86 | 93 | |
| 87 | 94 | if ( Settings::get( 'beacon', 1 ) ) { |
| 88 | 95 | wp_enqueue_script( |
| 89 | 96 | 'easyfonts-beacon', |
| 90 | - EASYFONTS_URL . 'assets/frontend/beacon.js', | |
| 97 | + EASYFONTS_URL . 'assets/frontend/beacon.min.js', | |
| 91 | 98 | array(), |
| 92 | 99 | EASYFONTS_VERSION, |
| 93 | 100 | array( |
| 94 | 101 | 'strategy' => 'defer', |
| @@ -101,8 +108,9 @@ | ||
| 101 | 108 | 'EasyFontsBeacon', |
| 102 | 109 | array( |
| 103 | 110 | 'endpoint' => esc_url_raw( rest_url( 'easyfonts/v1/beacon' ) ), |
| 104 | 111 | 'nonce' => wp_create_nonce( 'wp_rest' ), |
| 112 | + 'token' => Settings::beacon_token(), | |
| 105 | 113 | 'route' => '' === $route ? '/' : $route, |
| 106 | 114 | 'device' => $device, |
| 107 | 115 | ) |
| 108 | 116 | ); |
| @@ -111,9 +119,9 @@ | ||
| 111 | 119 | // X-ray overlay: admins only, on demand. |
| 112 | 120 | if ( current_user_can( 'manage_options' ) && isset( $_GET['easyfonts_xray'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
| 113 | 121 | wp_enqueue_script( |
| 114 | 122 | 'easyfonts-xray', |
| 115 | - EASYFONTS_URL . 'assets/frontend/xray.js', | |
| 123 | + EASYFONTS_URL . 'assets/frontend/xray.min.js', | |
| 116 | 124 | array(), |
| 117 | 125 | EASYFONTS_VERSION, |
| 118 | 126 | array( 'in_footer' => true ) |
| 119 | 127 | ); |