| @@ -1,6 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | +use Kibo\PhastPlugins\PhastPress\CDN; | |
| 4 | +use Kibo\PhastPlugins\PhastPress\Compat; | |
| 5 | + | |
| 3 | 6 | if (!defined('PHASTPRESS_VERSION')) { |
| 4 | 7 | exit; |
| 5 | 8 | } |
| 6 | 9 | |
| @@ -39,10 +42,21 @@ | ||
| 39 | 42 | return $links; |
| 40 | 43 | }); |
| 41 | 44 | |
| 42 | 45 | add_action('plugins_loaded', function () { |
| 43 | - \Kibo\PhastPlugins\PhastPress\CDN::installHook(); | |
| 44 | - phastpress_deploy(); | |
| 46 | + CDN::installHook(); | |
| 47 | + Compat\Log::setup(); | |
| 48 | + | |
| 49 | + if (($priority = has_filter('init', 'wp_cache_late_loader')) !== false) { | |
| 50 | + add_action('init', 'phastpress_deploy', $priority + 1); | |
| 51 | + Compat\Log::add( | |
| 52 | + 'wp-super-cache', | |
| 53 | + 'deploying PhastPress via init hook to support WP Super Cache late init' | |
| 54 | + ); | |
| 55 | + (new Compat\NextGenGallery())->setup($priority + 1); | |
| 56 | + } else { | |
| 57 | + phastpress_deploy(); | |
| 58 | + } | |
| 45 | 59 | }); |
| 46 | 60 | |
| 47 | 61 | add_action('admin_print_scripts', function () { |
| 48 | 62 | echo phastpress_get_plugin_sdk()->getAutoConfiguration()->renderScript(); |
| @@ -59,19 +73,22 @@ | ||
| 59 | 73 | }); |
| 60 | 74 | |
| 61 | 75 | add_action('wp_head', function () { |
| 62 | 76 | $style = 'font-family:helvetica,sans-serif'; |
| 63 | - $args = [ | |
| 77 | + phastpress_console_log( | |
| 64 | 78 | "%cOptimized with %cPhastPress%c %s\nhttps://wordpress.org/plugins/phastpress/", |
| 65 | 79 | $style, |
| 66 | 80 | $style . ';font-weight:bold', |
| 67 | 81 | $style, |
| 68 | - PHASTPRESS_VERSION, | |
| 69 | - ]; | |
| 82 | + PHASTPRESS_VERSION | |
| 83 | + ); | |
| 84 | +}); | |
| 85 | + | |
| 86 | +function phastpress_console_log(...$args) { | |
| 70 | 87 | echo '<script data-phast-no-defer>console.log(' . |
| 71 | 88 | implode(',', array_map('json_encode', $args)) . |
| 72 | 89 | ')</script>'; |
| 73 | -}); | |
| 90 | +} | |
| 74 | 91 | |
| 75 | 92 | function phastpress_render_settings() { |
| 76 | 93 | echo sprintf( |
| 77 | 94 | '<div class="wrap"> |