PluginProbe
PhastPress / 1.96
PhastPress v1.96
3.12 3.11 1.75 1.76 1.77 1.78 1.79 1.80 1.81 1.82 1.83 1.84 1.85 1.86 1.87 1.88 1.89 1.90 1.91 1.92 1.93 1.94 1.95 1.96 1.97 All 119 releases
phastpress / bootstrap.php

bootstrap.php in PhastPress 1.96, at bootstrap.php

121 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use Kibo\PhastPlugins\PhastPress\CDN;
4 use Kibo\PhastPlugins\PhastPress\Compat;
5
6 if (!defined('PHASTPRESS_VERSION')) {
7 exit;
8 }
9
10 require_once __DIR__ . '/autoload.php';
11
12 add_action('plugins_loaded', function () {
13 if (!get_option('phastpress_1.43')) {
14 phastpress_get_plugin_sdk()
15 ->getPluginConfiguration()
16 ->update([
17 'img-optimization-tags' => false,
18 'img-optimization-css' => false,
19 ]);
20 update_option('phastpress_1.43', gmdate('Y-m-d\TH:i:s\Z'));
21 }
22 });
23
24 register_activation_hook(PHASTPRESS_PLUGIN_FILE, function () {
25 update_option('phastpress_1.43', gmdate('Y-m-d\TH:i:s\Z'));
26 });
27
28 add_action('wp_ajax_phastpress_ajax_dispatch', function () {
29 wp_send_json(
30 phastpress_get_plugin_sdk()->getAJAXRequestsDispatcher()->dispatch($_POST)
31 );
32 });
33
34 add_action('admin_notices', function () {
35 echo phastpress_get_plugin_sdk()->getInstallNotice()->render();
36 });
37
38 add_filter('plugin_action_links_' . plugin_basename(PHASTPRESS_PLUGIN_FILE), function ($links) {
39 $link = '<a href="' . admin_url('options-general.php?page=phast-press') . '">'
40 . __('Settings', 'phastpress') . '</a>';
41 array_unshift($links, $link);
42 return $links;
43 });
44
45 add_action('plugins_loaded', function () {
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 } elseif (class_exists(\LiteSpeed\Core::class)
57 && ($priority = (new Compat\LiteSpeedCache())->getHookPriority()) !== null
58 ) {
59 add_action('after_setup_theme', 'phastpress_deploy', $priority + 1);
60 Compat\Log::add(
61 'litespeed-cache',
62 'deploying PhastPress via after_setup_theme hook to support LiteSpeed Cache'
63 );
64 } else {
65 phastpress_deploy();
66 }
67 });
68
69 add_action('admin_print_scripts', function () {
70 echo phastpress_get_plugin_sdk()->getAutoConfiguration()->renderScript();
71 });
72
73 add_action('admin_menu', function () {
74 add_options_page(
75 __('PhastPress', 'phastpress'),
76 __('PhastPress', 'phastpress'),
77 'manage_options',
78 'phast-press',
79 'phastpress_render_settings'
80 );
81 });
82
83 add_action('wp_head', function () {
84 $style = 'font-family:helvetica,sans-serif';
85 phastpress_console_log(
86 "%cOptimized with %cPhastPress%c %s\nhttps://wordpress.org/plugins/phastpress/",
87 $style,
88 $style . ';font-weight:bold',
89 $style,
90 PHASTPRESS_VERSION
91 );
92 });
93
94 function phastpress_console_log(...$args) {
95 echo '<script data-phast-no-defer>console.log(' .
96 implode(',', array_map('json_encode', $args)) .
97 ')</script>';
98 }
99
100 function phastpress_render_settings() {
101 echo sprintf(
102 '<div class="wrap">
103 <h1 class="wp-heading-inline">%s</h1>
104 %s
105 </div>
106 ',
107 __('PhastPress', 'phastpress'),
108 phastpress_get_plugin_sdk()->getAdminPanel()->render()
109 );
110 }
111
112 add_action('ai1wm_exclude_content_from_export', function ($filters) {
113 if (!is_array($filters)) {
114 return $filters;
115 }
116 foreach (phastpress_get_plugin_sdk()->getCacheRootManager()->getAllCacheRoots() as $dir) {
117 $filters[] = $dir;
118 }
119 return $filters;
120 });
121