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

113 lines 3.1 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 } else {
57 phastpress_deploy();
58 }
59 });
60
61 add_action('admin_print_scripts', function () {
62 echo phastpress_get_plugin_sdk()->getAutoConfiguration()->renderScript();
63 });
64
65 add_action('admin_menu', function () {
66 add_options_page(
67 __('PhastPress', 'phastpress'),
68 __('PhastPress', 'phastpress'),
69 'manage_options',
70 'phast-press',
71 'phastpress_render_settings'
72 );
73 });
74
75 add_action('wp_head', function () {
76 $style = 'font-family:helvetica,sans-serif';
77 phastpress_console_log(
78 "%cOptimized with %cPhastPress%c %s\nhttps://wordpress.org/plugins/phastpress/",
79 $style,
80 $style . ';font-weight:bold',
81 $style,
82 PHASTPRESS_VERSION
83 );
84 });
85
86 function phastpress_console_log(...$args) {
87 echo '<script data-phast-no-defer>console.log(' .
88 implode(',', array_map('json_encode', $args)) .
89 ')</script>';
90 }
91
92 function phastpress_render_settings() {
93 echo sprintf(
94 '<div class="wrap">
95 <h1 class="wp-heading-inline">%s</h1>
96 %s
97 </div>
98 ',
99 __('PhastPress', 'phastpress'),
100 phastpress_get_plugin_sdk()->getAdminPanel()->render()
101 );
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 });
113