PluginProbe
PhastPress / 1.89
PhastPress v1.89
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.89, at bootstrap.php

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