|
2 | 2 |
|
3 | 3 | defined('ABSPATH') or die('This page may not be accessed directly.'); |
4 | 4 |
|
5 | | -function add_async_for_script($url) |
6 | | -{ |
7 | | - if (strpos($url, '#asyncload') === false) |
8 | | - return $url; |
9 | | - else if (is_admin()) |
10 | | - return str_replace('#asyncload', '', $url); |
11 | | - else |
12 | | - return str_replace('#asyncload', '', $url)."' async='async"; |
13 | | -} |
14 | | - |
15 | 5 | class OneSignal_Public |
16 | 6 | { |
17 | 7 | public function __construct() |
@@ -77,13 +67,11 @@ public static function onesignal_header() |
77 | 67 | OneSignal_Public::insert_onesignal_stamp(); |
78 | 68 | } ?> |
79 | 69 | <?php |
80 | | - add_filter('clean_url', 'add_async_for_script', 11, 1); |
81 | | - |
82 | 70 | if (defined('ONESIGNAL_DEBUG') && defined('ONESIGNAL_LOCAL')) { |
83 | | - wp_register_script('local_sdk', 'https://localhost:3001/sdks/OneSignalSDK.js#asyncload', array(), false, true); |
| 71 | + wp_register_script('local_sdk', 'https://localhost:3001/sdks/OneSignalSDK.js', array(), '1.0.0', array('strategy' => 'async')); |
84 | 72 | wp_enqueue_script('local_sdk'); |
85 | 73 | } else { |
86 | | - wp_register_script('remote_sdk', 'https://cdn.onesignal.com/sdks/OneSignalSDK.js#asyncload', array(), false, true); |
| 74 | + wp_register_script('remote_sdk', 'https://cdn.onesignal.com/sdks/OneSignalSDK.js', array(), '1.0.0', array('strategy' => 'async')); |
87 | 75 | wp_enqueue_script('remote_sdk'); |
88 | 76 | } ?> |
89 | 77 | <script> |
|
0 commit comments