| @@ -35,8 +35,14 @@ | ||
| 35 | 35 | || ( |
| 36 | 36 | defined('WPACU_LOAD_ASSETS_REQ_KEY') |
| 37 | 37 | && !empty($_REQUEST[WPACU_LOAD_ASSETS_REQ_KEY]) |
| 38 | 38 | ) |
| 39 | + // WPBakery | |
| 40 | + || ( | |
| 41 | + defined('WPB_VC_VERSION') | |
| 42 | + && isset($_GET['vc_editable']) | |
| 43 | + && $_GET['vc_editable'] === 'true' | |
| 44 | + ) | |
| 39 | 45 | ) { |
| 40 | 46 | return; |
| 41 | 47 | } |
| 42 | 48 | |
| @@ -48,8 +54,19 @@ | ||
| 48 | 54 | |
| 49 | 55 | return preg_replace('~<script\b~i', '$0 data-phast-no-defer', $tag); |
| 50 | 56 | }, 10, 2); |
| 51 | 57 | |
| 58 | + add_filter('wp_print_scripts', function () { | |
| 59 | + foreach (wp_scripts()->registered as $handle => $item) { | |
| 60 | + if (empty($item->extra['phast_no_defer']) | |
| 61 | + || empty($item->extra['data']) | |
| 62 | + ) { | |
| 63 | + continue; | |
| 64 | + } | |
| 65 | + $item->extra['data'] = "'phast-no-defer';\n" . $item->extra['data']; | |
| 66 | + } | |
| 67 | + }); | |
| 68 | + | |
| 52 | 69 | foreach ([ |
| 53 | 70 | Compat\MonsterInsights::class, |
| 54 | 71 | Compat\Slimstat::class, |
| 55 | 72 | Compat\GoogleSiteKit::class, |
| @@ -62,9 +79,9 @@ | ||
| 62 | 79 | $sdk = phastpress_get_plugin_sdk(); |
| 63 | 80 | $handler = $sdk->getPhastAPI()->deployOutputBufferForDocument(); |
| 64 | 81 | |
| 65 | 82 | // Allow disabling PhastPress with hook. |
| 66 | - add_filter('template_redirect', function () use ($handler) { | |
| 83 | + add_action('template_redirect', function () use ($handler) { | |
| 67 | 84 | if (apply_filters('phastpress_disable', false)) { |
| 68 | 85 | $handler->cancel(); |
| 69 | 86 | } |
| 70 | 87 | }, 100); |