| @@ -1,37 +1,6 @@ | ||
| 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 | - | |
| 10 | -try { | |
| 11 | - new PDO('sqlite::memory:'); | |
| 12 | -} catch (\Throwable $e) { | |
| 13 | - add_action('admin_notices', function () use ($e) { | |
| 14 | - ?> | |
| 15 | - <div class="error notice"> | |
| 16 | - <p><b>Sorry, PhastPress requires a PHP extension that is not installed.</b></p> | |
| 17 | - <p> | |
| 18 | - The PDO extension needs to be installed with the SQLite3 database driver available.<br> | |
| 19 | - Currently we're getting this error: <em><?= esc_html($e->getMessage()); ?></em> | |
| 20 | - </p> | |
| 21 | - <p> | |
| 22 | - Ask your hosting provider to install the <a href="https://www.php.net/manual/en/ref.pdo-sqlite.php" target="_blank" rel="noopener">PDO_SQLITE extension</a>, or downgrade to <a href="https://downloads.wordpress.org/plugin/phastpress.2.1.zip" target="_blank" rel="noopener">PhastPress 2.1</a>. | |
| 23 | - </p> | |
| 24 | - </div> | |
| 25 | - <?php | |
| 26 | - }); | |
| 27 | - return; | |
| 28 | -} | |
| 29 | - | |
| 30 | -if (!defined('REQUESTS_SILENCE_PSR0_DEPRECATIONS')) { | |
| 31 | - define('REQUESTS_SILENCE_PSR0_DEPRECATIONS', true); | |
| 32 | -} | |
| 33 | - | |
| 34 | 3 | require_once __DIR__ . '/autoload.php'; |
| 35 | 4 | |
| 36 | 5 | add_action('plugins_loaded', function () { |
| 37 | 6 | if (!get_option('phastpress_1.43')) { |
| @@ -54,9 +23,9 @@ | ||
| 54 | 23 | phastpress_get_plugin_sdk()->getAJAXRequestsDispatcher()->dispatch($_POST) |
| 55 | 24 | ); |
| 56 | 25 | }); |
| 57 | 26 | |
| 58 | -add_action('admin_footer', function () { | |
| 27 | +add_action('admin_notices', function () { | |
| 59 | 28 | echo phastpress_get_plugin_sdk()->getInstallNotice()->render(); |
| 60 | 29 | }); |
| 61 | 30 | |
| 62 | 31 | add_filter('plugin_action_links_' . plugin_basename(PHASTPRESS_PLUGIN_FILE), function ($links) { |
| @@ -66,33 +35,10 @@ | ||
| 66 | 35 | return $links; |
| 67 | 36 | }); |
| 68 | 37 | |
| 69 | 38 | add_action('plugins_loaded', function () { |
| 70 | - CDN::installHook(); | |
| 71 | - Compat\Log::setup(); | |
| 72 | - | |
| 73 | - if ((new Compat\Ajax())->setup()) { | |
| 74 | - return; | |
| 75 | - } | |
| 76 | - | |
| 77 | - if (($priority = has_filter('init', 'wp_cache_late_loader')) !== false) { | |
| 78 | - add_action('init', 'phastpress_deploy', $priority + 1); | |
| 79 | - Compat\Log::add( | |
| 80 | - 'wp-super-cache', | |
| 81 | - 'deploying PhastPress via init hook to support WP Super Cache late init' | |
| 82 | - ); | |
| 83 | - (new Compat\NextGenGallery())->setup($priority + 1); | |
| 84 | - } elseif (class_exists(\LiteSpeed\Core::class) | |
| 85 | - && ($priority = (new Compat\LiteSpeedCache())->getHookPriority()) !== null | |
| 86 | - ) { | |
| 87 | - add_action('after_setup_theme', 'phastpress_deploy', $priority + 1); | |
| 88 | - Compat\Log::add( | |
| 89 | - 'litespeed-cache', | |
| 90 | - 'deploying PhastPress via after_setup_theme hook to support LiteSpeed Cache' | |
| 91 | - ); | |
| 92 | - } else { | |
| 93 | - phastpress_deploy(); | |
| 94 | - } | |
| 39 | + \Kibo\PhastPlugins\PhastPress\CDN::installHook(); | |
| 40 | + phastpress_deploy(); | |
| 95 | 41 | }); |
| 96 | 42 | |
| 97 | 43 | add_action('admin_print_scripts', function () { |
| 98 | 44 | echo phastpress_get_plugin_sdk()->getAutoConfiguration()->renderScript(); |
| @@ -109,23 +55,19 @@ | ||
| 109 | 55 | }); |
| 110 | 56 | |
| 111 | 57 | add_action('wp_head', function () { |
| 112 | 58 | $style = 'font-family:helvetica,sans-serif'; |
| 113 | - phastpress_console_log( | |
| 59 | + $args = [ | |
| 114 | 60 | "%cOptimized with %cPhastPress%c %s\nhttps://wordpress.org/plugins/phastpress/", |
| 115 | 61 | $style, |
| 116 | 62 | $style . ';font-weight:bold', |
| 117 | 63 | $style, |
| 118 | - PHASTPRESS_VERSION | |
| 119 | - ); | |
| 64 | + PHASTPRESS_VERSION, | |
| 65 | + ]; | |
| 66 | + echo '<script data-phast-no-defer>console.log(' . | |
| 67 | + implode(',', array_map('json_encode', $args)) . | |
| 68 | + ')</script>'; | |
| 120 | 69 | }); |
| 121 | - | |
| 122 | -function phastpress_console_log(...$args) { | |
| 123 | - echo phastpress_script( | |
| 124 | - sprintf('console.log(%s)', implode(',', array_map('json_encode', $args))), | |
| 125 | - ['data-phast-no-defer' => ''] | |
| 126 | - ); | |
| 127 | -} | |
| 128 | 70 | |
| 129 | 71 | function phastpress_render_settings() { |
| 130 | 72 | echo sprintf( |
| 131 | 73 | '<div class="wrap"> |