| @@ -1,6 +1,13 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | +use Kibo\PhastPlugins\PhastPress\CDN; | |
| 4 | +use Kibo\PhastPlugins\PhastPress\Compat; | |
| 5 | + | |
| 6 | +if (!defined('PHASTPRESS_VERSION')) { | |
| 7 | + exit; | |
| 8 | +} | |
| 9 | + | |
| 3 | 10 | require_once __DIR__ . '/autoload.php'; |
| 4 | 11 | |
| 5 | 12 | add_action('plugins_loaded', function () { |
| 6 | 13 | if (!get_option('phastpress_1.43')) { |
| @@ -35,10 +42,21 @@ | ||
| 35 | 42 | return $links; |
| 36 | 43 | }); |
| 37 | 44 | |
| 38 | 45 | add_action('plugins_loaded', function () { |
| 39 | - \Kibo\PhastPlugins\PhastPress\CDN::installHook(); | |
| 40 | - 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 | + } | |
| 41 | 59 | }); |
| 42 | 60 | |
| 43 | 61 | add_action('admin_print_scripts', function () { |
| 44 | 62 | echo phastpress_get_plugin_sdk()->getAutoConfiguration()->renderScript(); |
| @@ -55,19 +73,22 @@ | ||
| 55 | 73 | }); |
| 56 | 74 | |
| 57 | 75 | add_action('wp_head', function () { |
| 58 | 76 | $style = 'font-family:helvetica,sans-serif'; |
| 59 | - $args = [ | |
| 77 | + phastpress_console_log( | |
| 60 | 78 | "%cOptimized with %cPhastPress%c %s\nhttps://wordpress.org/plugins/phastpress/", |
| 61 | 79 | $style, |
| 62 | 80 | $style . ';font-weight:bold', |
| 63 | 81 | $style, |
| 64 | - PHASTPRESS_VERSION, | |
| 65 | - ]; | |
| 82 | + PHASTPRESS_VERSION | |
| 83 | + ); | |
| 84 | +}); | |
| 85 | + | |
| 86 | +function phastpress_console_log(...$args) { | |
| 66 | 87 | echo '<script data-phast-no-defer>console.log(' . |
| 67 | 88 | implode(',', array_map('json_encode', $args)) . |
| 68 | 89 | ')</script>'; |
| 69 | -}); | |
| 90 | +} | |
| 70 | 91 | |
| 71 | 92 | function phastpress_render_settings() { |
| 72 | 93 | echo sprintf( |
| 73 | 94 | '<div class="wrap"> |
| @@ -78,4 +99,14 @@ | ||
| 78 | 99 | __('PhastPress', 'phastpress'), |
| 79 | 100 | phastpress_get_plugin_sdk()->getAdminPanel()->render() |
| 80 | 101 | ); |
| 81 | 102 | } |
| 103 | + | |
| 104 | +add_action('ai1wm_exclude_content_from_export', function ($filters) { | |
| 105 | + if (!is_array($filters)) { | |
| 106 | + return $filters; | |
| 107 | + } | |
| 108 | + foreach (phastpress_get_plugin_sdk()->getCacheRootManager()->getAllCacheRoots() as $dir) { | |
| 109 | + $filters[] = $dir; | |
| 110 | + } | |
| 111 | + return $filters; | |
| 112 | +}); | |