PluginProbe
WPIDE – File Manager & Code Editor / 3.5.5
WPIDE – File Manager & Code Editor v3.5.5
3.5.8 3.5.7 2.0.14 2.0.15 2.0.16 2.0.2 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1 2.2 2.3 2.3.1 2.3.2 2.4.0 2.5 2.6 3.0 3.1 3.2 3.3 3.4 All 54 releases
← All changes | App/App.php +160 -57 3.43.5.5 View file →
@@ -1,9 +1,11 @@
1 1 <?php
2 2 namespace WPIDE\App;
3 3
4 +use WPIDE\App\Classes\Freemius;
4 5 use WPIDE\App\Classes\Migrations;
5 6 use WPIDE\App\Classes\RecommendedPlugins;
7 +use WPIDE\App\Classes\PromoNotice;
6 8 use WPIDE\App\Classes\ReviewNotice;
7 9 use WPIDE\App\Classes\Notices;
8 10 use WPIDE\App\Config\Config;
9 11 use WPIDE\App\Container\Container;
@@ -18,9 +20,8 @@
18 20 use const WPIDE\Constants\AUTHOR;
19 21 use const WPIDE\Constants\CONTENT_DIR;
20 22 use const WPIDE\Constants\DIR;
21 23 use const WPIDE\Constants\TMP_DIR;
22 -use const WPIDE\Constants\URL;
23 24 use const WPIDE\Constants\ASSETS_URL;
24 25 use const WPIDE\Constants\FATAL_ERROR_DROPIN;
25 26 use const WPIDE\Constants\FATAL_ERROR_DROPIN_VERSION;
26 27 use const WPIDE\Constants\FATAL_ERROR_DROPIN_VERSION_OPT;
@@ -34,8 +35,9 @@
34 35 public static $_instance;
35 36
36 37 private $container;
37 38 private $dependencyNotice;
39 + private $isNetworkActive;
38 40
39 41 protected $notices = [];
40 42 public $services = [];
41 43
@@ -76,8 +78,17 @@
76 78
77 79 return $this->resolve('WPIDE\App\Services\Cache\Cache');
78 80 }
79 81
82 + /**
83 + * @throws \DI\DependencyException
84 + * @throws \DI\NotFoundException
85 + */
86 + public function transient() {
87 +
88 + return $this->resolve('WPIDE\App\Services\Transient\Transient');
89 + }
90 +
80 91 public function call($callable, array $parameters)
81 92 {
82 93 return $this->container->call($callable, $parameters);
83 94 }
@@ -94,10 +105,10 @@
94 105
95 106 return $currentVersion === FATAL_ERROR_DROPIN_VERSION;
96 107 }
97 108
98 - public function dropInExists() {
99 -
109 + public function dropInExists(): bool
110 + {
100 111 $fs = LocalFileSystem::load(CONTENT_DIR);
101 112
102 113 return $fs->fileExists(FATAL_ERROR_DROPIN);
103 114 }
@@ -123,8 +134,11 @@
123 134 $fs->deleteFile(FATAL_ERROR_DROPIN);
124 135 }
125 136 }
126 137
138 + /**
139 + * @throws \Exception
140 + */
127 141 public function load()
128 142 {
129 143
130 144 if(!$this->dependencyCheck() || !is_admin()) {
@@ -138,9 +152,12 @@
138 152 $this->loadTextDomain();
139 153 $this->loadHooks();
140 154
141 155 Migrations::init();
142 - ReviewNotice::init();
156 + PromoNotice::init();
157 + if(!PromoNotice::enabled()) {
158 + ReviewNotice::init();
159 + }
143 160 RecommendedPlugins::init();
144 161 }
145 162
146 163 protected function loadTextDomain() {
@@ -174,9 +191,13 @@
174 191
175 192 protected function loadHooks()
176 193 {
177 194
178 - add_action('admin_menu', [$this, 'adminMenu' ]);
195 + if($this->showAdminMenu()) {
196 + add_action('admin_menu', [$this, 'adminMenu' ]);
197 + add_action('network_admin_menu', [$this, 'adminMenu']);
198 + }
199 +
179 200 add_action("wp_ajax_wpide_request", [$this, "ajaxRequest"]);
180 201 add_action("admin_init", [$this, "registerTasks"]);
181 202 add_action('admin_enqueue_scripts', [ $this, 'enqueueCommonAssets' ]);
182 203
@@ -181,14 +202,25 @@
181 202 add_action('admin_enqueue_scripts', [ $this, 'enqueueCommonAssets' ]);
182 203
183 204 if($this->isPluginScreen()) {
184 205
206 + // When network active, If trying to load plugin admin url, redirect back to network root
207 + if(!$this->showAdminMenu() && !$this->isFreemiusScreen() && !Freemius::sdk()->is_activation_mode() && !Freemius::showSubmenus()) {
208 + wp_redirect(network_admin_url());
209 + die();
210 + }
211 +
185 212 add_filter('admin_title', [$this, 'setAdminTitle']);
213 +
214 + add_action('network_admin_menu', [$this, 'addAdminFavicon']);
215 + add_action("network_admin_menu", [$this, "setCurrentScreen"], -1);
216 + add_action('network_admin_menu', [Notices::class, 'init']);
217 +
186 218 add_action('admin_head', [$this, 'addAdminFavicon']);
187 219 add_action("admin_menu", [$this, "setCurrentScreen"], -1);
188 220 add_action('admin_menu', [Notices::class, 'init']);
221 +
189 222 add_filter('screen_options_show_screen', '__return_false');
190 - add_filter('admin_body_class', [$this, 'bodyClasses'], 10, 1);
191 223 add_action('admin_enqueue_scripts', [ $this, 'deregisterWpStyles' ]);
192 224 }
193 225 }
194 226
@@ -206,11 +238,63 @@
206 238 {
207 239 return current_user_can('manage_options');
208 240 }
209 241
242 + public function showAdminMenu(): bool
243 + {
244 +
245 + if(fs_is_network_admin()) {
246 +
247 + return $this->isNetworkActive() && (WP_FS__SHOW_NETWORK_EVEN_WHEN_DELEGATED || !Freemius::sdk()->is_network_delegated_connection());
248 + }
249 +
250 + return true;
251 + }
252 +
210 253 public function adminMenu()
211 254 {
212 255
256 + $menuTopItems = apply_filters('wpide_admin_menu_top_items', [
257 + [
258 + 'title' => __( 'File Manager', 'wpide' ),
259 + 'slug' => SLUG.'#/file-manager',
260 + 'callback' => [$this, 'bootstrap'],
261 + 'position' => 10
262 + ],
263 + [
264 + 'title' => __( 'File Editor', 'wpide' ),
265 + 'slug' => SLUG.'#/file-editor',
266 + 'callback' => [$this, 'bootstrap'],
267 + 'position' => 20
268 + ],
269 + [
270 + 'title' => __( 'Image Editor', 'wpide' ),
271 + 'slug' => SLUG.'#/image-editor',
272 + 'callback' => [$this, 'bootstrap'],
273 + 'position' => 20
274 + ],
275 + [
276 + 'title' => __( 'DB Manager', 'wpide' ),
277 + 'slug' => SLUG.'#/db-manager',
278 + 'callback' => [$this, 'bootstrap'],
279 + 'position' => 30
280 + ],
281 + [
282 + 'title' => __( 'Config Manager', 'wpide' ),
283 + 'slug' => SLUG.'#/config-manager',
284 + 'callback' => [$this, 'bootstrap'],
285 + 'position' => 30
286 + ],
287 + [
288 + 'title' => __( 'Settings', 'wpide' ),
289 + 'slug' => SLUG.'#/settings',
290 + 'callback' => [$this, 'bootstrap'],
291 + 'position' => 40
292 + ]
293 + ]);
294 +
295 + $menuBottomItems = apply_filters('wpide_admin_menu_bottom_items', []);
296 +
213 297 add_menu_page(
214 298 NAME,
215 299 NAME,
216 300 'manage_options',
@@ -215,43 +299,54 @@
215 299 NAME,
216 300 'manage_options',
217 301 SLUG,
218 302 [$this, 'bootstrap'],
219 - 'dashicons-editor-code',
220 - 3
303 + 'dashicons-editor-code'
221 304 );
222 305
223 - add_submenu_page(
224 - SLUG,
225 - __( 'File Manager', 'wpide' ),
226 - __( 'File Manager', 'wpide' ),
227 - 'manage_options',
228 - SLUG.'#/file-manager',
229 - [$this, 'bootstrap'],
230 - 3
231 - );
306 + $highestPosition = 0;
307 + foreach ($menuTopItems as $item) {
308 + add_submenu_page(
309 + SLUG,
310 + $item['title'],
311 + $item['title'],
312 + 'manage_options',
313 + $item['slug'],
314 + $item['callback'],
315 + $item['position']
316 + );
232 317
318 + if ($item['position'] > $highestPosition) {
319 + $highestPosition = $item['position'];
320 + }
321 + }
322 +
233 323 add_submenu_page(
234 324 SLUG,
235 - __( 'File Editor', 'wpide' ),
236 - __( 'File Editor', 'wpide' ),
325 + '',
326 + '',
237 327 'manage_options',
238 - SLUG.'#/file-editor',
239 - [$this, 'bootstrap'],
240 - 3
328 + '#divider',
329 + '',
330 + $highestPosition + 10
241 331 );
242 332
243 - add_submenu_page(
244 - SLUG,
245 - __( 'DB Manager', 'wpide' ),
246 - __( 'DB Manager', 'wpide' ),
247 - 'manage_options',
248 - SLUG.'#/db-manager',
249 - [$this, 'bootstrap'],
250 - 3
251 - );
333 + foreach ($menuBottomItems as $item) {
334 + add_submenu_page(
335 + SLUG,
336 + $item['title'],
337 + $item['title'],
338 + 'manage_options',
339 + $item['slug'],
340 + $item['callback'],
341 + $item['position']
342 + );
343 + }
252 344
253 345 remove_submenu_page(SLUG, SLUG);
346 +
347 + do_action('wpide_admin_menu');
348 +
254 349 }
255 350
256 351 public function bootstrap() {
257 352
@@ -290,18 +385,8 @@
290 385 }
291 386 }
292 387 }
293 388
294 - public function bodyClasses($classes): string
295 - {
296 -
297 - if(!$this->isFreemiusScreen()) {
298 - $classes = $classes . " folded";
299 - }
300 -
301 - return $classes;
302 - }
303 -
304 389 public function deregisterWpStyles()
305 390 {
306 391
307 392 wp_deregister_style('color');
@@ -317,21 +402,21 @@
317 402 wp_deregister_style('widgets');
318 403 wp_deregister_style('l10n');
319 404 wp_deregister_style('site-icon');
320 405
321 - wp_register_style('color', null);
322 - wp_register_style('forms', null);
323 - wp_register_style('dashboard', null);
324 - wp_register_style('list-tables', null);
325 - wp_register_style('edit', null);
326 - wp_register_style('revisions', null);
327 - wp_register_style('media', null);
328 - wp_register_style('themes', null);
329 - wp_register_style('about', null);
330 - wp_register_style('nav-menus', null);
331 - wp_register_style('widgets', null);
332 - wp_register_style('l10n', null);
333 - wp_register_style('site-icon', null);
406 + wp_register_style('color', '');
407 + wp_register_style('forms', '');
408 + wp_register_style('dashboard', '');
409 + wp_register_style('list-tables', '');
410 + wp_register_style('edit', '');
411 + wp_register_style('revisions', '');
412 + wp_register_style('media', '');
413 + wp_register_style('themes', '');
414 + wp_register_style('about', '');
415 + wp_register_style('nav-menus', '');
416 + wp_register_style('widgets', '');
417 + wp_register_style('l10n', '');
418 + wp_register_style('site-icon', '');
334 419
335 420 }
336 421
337 422 public function enqueueCommonAssets()
@@ -336,9 +421,9 @@
336 421
337 422 public function enqueueCommonAssets()
338 423 {
339 424
340 - wp_enqueue_style(SLUG.'-fs-notices', ASSETS_URL.'global/css/fs-notices.css', [], VERSION);
425 + wp_enqueue_style(SLUG.'-fs-notices', ASSETS_URL.'global/css/global.css', [], VERSION);
341 426 }
342 427
343 428 public function ajaxRequest()
344 429 {
@@ -391,11 +476,29 @@
391 476
392 477 return false;
393 478 }
394 479
395 - public function getAdminUrl(): string {
480 + public function isNetworkActive(): bool
481 + {
396 482
397 - return admin_url( 'admin.php?page='.SLUG );
483 + if(!isset($this->isNetworkActive)) {
484 +
485 + $plugin = basename(WPIDE_DIR) . '/' . basename(WPIDE_FILE);
486 + $this->isNetworkActive = is_plugin_active_for_network($plugin);
487 + }
488 +
489 + return $this->isNetworkActive;
490 + }
491 +
492 + public function getAdminUrl($section = null, $network = false): string {
493 +
494 + $admin_url_function = $network ? 'network_admin_url' : 'admin_url';
495 +
496 + $url = 'admin.php?page='.SLUG;
497 + if(!empty($section)) {
498 + $url .= '#/'.$section;
499 + }
500 + return $admin_url_function( $url );
398 501 }
399 502
400 503 public function getAjaxUrl($req = ''): string
401 504 {