PluginProbe
FlyWP Helper – Page Cache, Page Optimization, Emails for FlyWP Server Control Panel / trunk
FlyWP Helper – Page Cache, Page Optimization, Emails for FlyWP Server Control Panel vtrunk
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 1.5.1 All 26 releases
← All changes | flywp.php +43 -20 1.2trunk 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.2
6 + * Version: 1.7.1
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.2';
44 + public $version = '1.7.1';
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.
@@ -84,13 +89,29 @@
84 89 flush_rewrite_rules( false );
85 90 }
86 91
87 92 /**
93 + * Plugin deactivation hook.
94 + *
95 + * @return void
96 + */
97 + public function deactivate() {
98 + $timestamp = wp_next_scheduled( FlyWP\Api\UpdatesData::CRON_HOOK );
99 + if ( $timestamp ) {
100 + wp_unschedule_event( $timestamp, FlyWP\Api\UpdatesData::CRON_HOOK );
101 + }
102 + }
103 +
104 + /**
88 105 * Initialize plugin.
89 106 *
90 107 * @return void
91 108 */
92 109 public function init_plugin() {
110 + // Loaded ahead of the API-key gate below, as it does not use the API key. It answers
111 + // one POST path and does nothing on any other request.
112 + new FlyWP\Frontend\MagicLogin();
113 +
93 114 if ( ! $this->has_key() ) {
94 115 $this->add_action( 'admin_notices', 'admin_notice' );
95 116
96 117 return;
@@ -101,15 +122,17 @@
101 122 } else {
102 123 $this->frontend = new FlyWP\Frontend();
103 124 }
104 125
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();
111 - $this->optimize = new FlyWP\Optimizations();
126 + $this->router = new FlyWP\Router();
127 + $this->rest = new FlyWP\Api();
128 + $this->fastcgi = new FlyWP\Fastcgi_Cache();
129 + $this->opcache = new FlyWP\Opcache();
130 + $this->flyapi = new FlyWP\FlyApi();
131 + $this->email = new FlyWP\Email();
132 + $this->optimize = new FlyWP\Optimizations();
133 + $this->litespeed = new FlyWP\Litespeed();
134 + $this->updates_data = new FlyWP\Api\UpdatesData();
112 135 }
113 136
114 137 /**
115 138 * Show admin notice if API key is not set.
@@ -140,23 +163,23 @@
140 163 return FLYWP_API_KEY;
141 164 }
142 165
143 166 /**
144 - * Debugging helper.
167 + * Public key used to verify magic-login tokens.
145 168 *
146 - * @param mixed $value
147 - * @param bool $die
169 + * Set as a constant on classic WordPress. On Bedrock it may only be present in the
170 + * environment, so fall back to `getenv()`.
148 171 *
149 - * @return void
172 + * @return string
150 173 */
151 - public function debug( $value, $die = false ) {
152 - echo '<pre>';
153 - print_r( $value );
154 - echo '</pre>';
174 + public function get_login_public_key() {
175 + if ( FLYWP_LOGIN_PUBLIC_KEY !== '' ) {
176 + return FLYWP_LOGIN_PUBLIC_KEY;
177 + }
155 178
156 - if ( $die ) {
157 - die();
158 - }
179 + $from_env = getenv( 'FLYWP_LOGIN_PUBLIC_KEY' );
180 +
181 + return $from_env === false ? '' : $from_env;
159 182 }
160 183 }
161 184
162 185 /**