PluginProbe
FlyWP Helper – Page Cache, Page Optimization, Emails for FlyWP Server Control Panel / 1.8.0
FlyWP Helper – Page Cache, Page Optimization, Emails for FlyWP Server Control Panel v1.8.0
1.8.0 1.7.1 1.7.0 1.6.0 1.5.2 trunk 0.1 0.2.0 0.2.1 0.3 0.3.1 0.3.2 0.3.3 0.3.4 0.4 0.4.1 0.4.2 0.4.3 1.0 1.1 1.2 1.3.1 1.4.0 1.4.1 1.5.0 All 27 releases
← All changes | flywp.php +49 -19 1.1 → 1.8.0 View file →
@@ -2,9 +2,9 @@
2 2 /**
3 3 * Plugin Name: FlyWP
4 4 * Plugin URI: https://flywp.com
5 5 * Description: Helper plugin for FlyWP
6 - * Version: 1.1
6 + * Version: 1.8.0
7 7 * Author: FlyWP
8 8 * Author URI: https://flywp.com/?utm_source=wporg&utm_medium=banner&utm_campaign=author-uri
9 9 * License: GPL2
10 10 */
@@ -40,9 +40,9 @@
40 40 * Plugin version.
41 41 *
42 42 * @var string
43 43 */
44 - public $version = '1.1';
44 + public $version = '1.8.0';
45 45
46 46 /**
47 47 * Plugin Constructor.
48 48 *
@@ -52,8 +52,9 @@
52 52 $this->define_constants();
53 53
54 54 $this->add_action( 'plugins_loaded', 'init_plugin' );
55 55 register_activation_hook( __FILE__, [ $this, 'activate' ] );
56 + register_deactivation_hook( __FILE__, [ $this, 'deactivate' ] );
56 57 }
57 58
58 59 /**
59 60 * Define plugin constants.
@@ -69,8 +70,12 @@
69 70
70 71 if ( ! defined( 'FLYWP_API_KEY' ) ) {
71 72 define( 'FLYWP_API_KEY', '' );
72 73 }
74 +
75 + if ( ! defined( 'FLYWP_LOGIN_PUBLIC_KEY' ) ) {
76 + define( 'FLYWP_LOGIN_PUBLIC_KEY', '' );
77 + }
73 78 }
74 79
75 80 /**
76 81 * Plugin activation hook.
@@ -81,16 +86,37 @@
81 86 $router = new FlyWP\Router();
82 87 $router->register_routes();
83 88
84 89 flush_rewrite_rules( false );
90 +
91 + FlyWP\StaticSite\Bootstrap::install();
85 92 }
86 93
87 94 /**
95 + * Plugin deactivation hook.
96 + *
97 + * @return void
98 + */
99 + public function deactivate() {
100 + $timestamp = wp_next_scheduled( FlyWP\Api\UpdatesData::CRON_HOOK );
101 + if ( $timestamp ) {
102 + wp_unschedule_event( $timestamp, FlyWP\Api\UpdatesData::CRON_HOOK );
103 + }
104 + }
105 +
106 + /**
88 107 * Initialize plugin.
89 108 *
90 109 * @return void
91 110 */
92 111 public function init_plugin() {
112 + // Loaded ahead of the API-key gate below, as it does not use the API key. It answers
113 + // one POST path and does nothing on any other request.
114 + new FlyWP\Frontend\MagicLogin();
115 +
116 + // The static site CLI commands do not use the API key.
117 + FlyWP\StaticSite\Bootstrap::register_cli();
118 +
93 119 if ( ! $this->has_key() ) {
94 120 $this->add_action( 'admin_notices', 'admin_notice' );
95 121
96 122 return;
@@ -101,14 +127,18 @@
101 127 } else {
102 128 $this->frontend = new FlyWP\Frontend();
103 129 }
104 130
105 - $this->router = new FlyWP\Router();
106 - $this->rest = new FlyWP\Api();
107 - $this->fastcgi = new FlyWP\Fastcgi_Cache();
108 - $this->opcache = new FlyWP\Opcache();
109 - $this->flyapi = new FlyWP\FlyApi();
110 - $this->email = new FlyWP\Email();
131 + $this->router = new FlyWP\Router();
132 + $this->rest = new FlyWP\Api();
133 + $this->fastcgi = new FlyWP\Fastcgi_Cache();
134 + $this->opcache = new FlyWP\Opcache();
135 + $this->flyapi = new FlyWP\FlyApi();
136 + $this->email = new FlyWP\Email();
137 + $this->optimize = new FlyWP\Optimizations();
138 + $this->litespeed = new FlyWP\Litespeed();
139 + $this->updates_data = new FlyWP\Api\UpdatesData();
140 + $this->static_site = new FlyWP\StaticSite\Bootstrap();
111 141 }
112 142
113 143 /**
114 144 * Show admin notice if API key is not set.
@@ -139,23 +169,23 @@
139 169 return FLYWP_API_KEY;
140 170 }
141 171
142 172 /**
143 - * Debugging helper.
173 + * Public key used to verify magic-login tokens.
144 174 *
145 - * @param mixed $value
146 - * @param bool $die
175 + * Set as a constant on classic WordPress. On Bedrock it may only be present in the
176 + * environment, so fall back to `getenv()`.
147 177 *
148 - * @return void
178 + * @return string
149 179 */
150 - public function debug( $value, $die = false ) {
151 - echo '<pre>';
152 - print_r( $value );
153 - echo '</pre>';
180 + public function get_login_public_key() {
181 + if ( FLYWP_LOGIN_PUBLIC_KEY !== '' ) {
182 + return FLYWP_LOGIN_PUBLIC_KEY;
183 + }
154 184
155 - if ( $die ) {
156 - die();
157 - }
185 + $from_env = getenv( 'FLYWP_LOGIN_PUBLIC_KEY' );
186 +
187 + return $from_env === false ? '' : $from_env;
158 188 }
159 189 }
160 190
161 191 /**