PluginProbe
WPIDE – File Manager & Code Editor / 3.4.1
WPIDE – File Manager & Code Editor v3.4.1
3.5.9 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 All 55 releases
← All changes | App/App.php +57 -160 3.5.93.4.1 View file →
@@ -1,11 +1,9 @@
1 1 <?php
2 2 namespace WPIDE\App;
3 3
4 -use WPIDE\App\Classes\Freemius;
5 4 use WPIDE\App\Classes\Migrations;
6 5 use WPIDE\App\Classes\RecommendedPlugins;
7 -use WPIDE\App\Classes\PromoNotice;
8 6 use WPIDE\App\Classes\ReviewNotice;
9 7 use WPIDE\App\Classes\Notices;
10 8 use WPIDE\App\Config\Config;
11 9 use WPIDE\App\Container\Container;
@@ -20,8 +18,9 @@
20 18 use const WPIDE\Constants\AUTHOR;
21 19 use const WPIDE\Constants\CONTENT_DIR;
22 20 use const WPIDE\Constants\DIR;
23 21 use const WPIDE\Constants\TMP_DIR;
22 +use const WPIDE\Constants\URL;
24 23 use const WPIDE\Constants\ASSETS_URL;
25 24 use const WPIDE\Constants\FATAL_ERROR_DROPIN;
26 25 use const WPIDE\Constants\FATAL_ERROR_DROPIN_VERSION;
27 26 use const WPIDE\Constants\FATAL_ERROR_DROPIN_VERSION_OPT;
@@ -35,9 +34,8 @@
35 34 public static $_instance;
36 35
37 36 private $container;
38 37 private $dependencyNotice;
39 - private $isNetworkActive;
40 38
41 39 protected $notices = [];
42 40 public $services = [];
43 41
@@ -78,17 +76,8 @@
78 76
79 77 return $this->resolve('WPIDE\App\Services\Cache\Cache');
80 78 }
81 79
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 -
91 80 public function call($callable, array $parameters)
92 81 {
93 82 return $this->container->call($callable, $parameters);
94 83 }
@@ -105,10 +94,10 @@
105 94
106 95 return $currentVersion === FATAL_ERROR_DROPIN_VERSION;
107 96 }
108 97
109 - public function dropInExists(): bool
110 - {
98 + public function dropInExists() {
99 +
111 100 $fs = LocalFileSystem::load(CONTENT_DIR);
112 101
113 102 return $fs->fileExists(FATAL_ERROR_DROPIN);
114 103 }
@@ -134,11 +123,8 @@
134 123 $fs->deleteFile(FATAL_ERROR_DROPIN);
135 124 }
136 125 }
137 126
138 - /**
139 - * @throws \Exception
140 - */
141 127 public function load()
142 128 {
143 129
144 130 if(!$this->dependencyCheck() || !is_admin()) {
@@ -152,12 +138,9 @@
152 138 $this->loadTextDomain();
153 139 $this->loadHooks();
154 140
155 141 Migrations::init();
156 - PromoNotice::init();
157 - if(!PromoNotice::enabled()) {
158 - ReviewNotice::init();
159 - }
142 + ReviewNotice::init();
160 143 RecommendedPlugins::init();
161 144 }
162 145
163 146 protected function loadTextDomain() {
@@ -191,13 +174,9 @@
191 174
192 175 protected function loadHooks()
193 176 {
194 177
195 - if($this->showAdminMenu()) {
196 - add_action('admin_menu', [$this, 'adminMenu' ]);
197 - add_action('network_admin_menu', [$this, 'adminMenu']);
198 - }
199 -
178 + add_action('admin_menu', [$this, 'adminMenu' ]);
200 179 add_action("wp_ajax_wpide_request", [$this, "ajaxRequest"]);
201 180 add_action("admin_init", [$this, "registerTasks"]);
202 181 add_action('admin_enqueue_scripts', [ $this, 'enqueueCommonAssets' ]);
203 182
@@ -202,25 +181,14 @@
202 181 add_action('admin_enqueue_scripts', [ $this, 'enqueueCommonAssets' ]);
203 182
204 183 if($this->isPluginScreen()) {
205 184
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 -
212 185 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 -
218 186 add_action('admin_head', [$this, 'addAdminFavicon']);
219 187 add_action("admin_menu", [$this, "setCurrentScreen"], -1);
220 188 add_action('admin_menu', [Notices::class, 'init']);
221 -
222 189 add_filter('screen_options_show_screen', '__return_false');
190 + add_filter('admin_body_class', [$this, 'bodyClasses'], 10, 1);
223 191 add_action('admin_enqueue_scripts', [ $this, 'deregisterWpStyles' ]);
224 192 }
225 193 }
226 194
@@ -238,63 +206,11 @@
238 206 {
239 207 return current_user_can('manage_options');
240 208 }
241 209
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 -
253 210 public function adminMenu()
254 211 {
255 212
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 -
297 213 add_menu_page(
298 214 NAME,
299 215 NAME,
300 216 'manage_options',
@@ -299,54 +215,43 @@
299 215 NAME,
300 216 'manage_options',
301 217 SLUG,
302 218 [$this, 'bootstrap'],
303 - 'dashicons-editor-code'
219 + 'dashicons-editor-code',
220 + 3
304 221 );
305 222
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 - );
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 + );
317 232
318 - if ($item['position'] > $highestPosition) {
319 - $highestPosition = $item['position'];
320 - }
321 - }
233 + add_submenu_page(
234 + SLUG,
235 + __( 'File Editor', 'wpide' ),
236 + __( 'File Editor', 'wpide' ),
237 + 'manage_options',
238 + SLUG.'#/file-editor',
239 + [$this, 'bootstrap'],
240 + 3
241 + );
322 242
323 243 add_submenu_page(
324 244 SLUG,
325 - '',
326 - '',
245 + __( 'DB Manager', 'wpide' ),
246 + __( 'DB Manager', 'wpide' ),
327 247 'manage_options',
328 - '#divider',
329 - '',
330 - $highestPosition + 10
248 + SLUG.'#/db-manager',
249 + [$this, 'bootstrap'],
250 + 3
331 251 );
332 252
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 - }
344 -
345 253 remove_submenu_page(SLUG, SLUG);
346 -
347 - do_action('wpide_admin_menu');
348 -
349 254 }
350 255
351 256 public function bootstrap() {
352 257
@@ -385,8 +290,18 @@
385 290 }
386 291 }
387 292 }
388 293
294 + public function bodyClasses($classes): string
295 + {
296 +
297 + if(!$this->isFreemiusScreen()) {
298 + $classes = $classes . " folded";
299 + }
300 +
301 + return $classes;
302 + }
303 +
389 304 public function deregisterWpStyles()
390 305 {
391 306
392 307 wp_deregister_style('color');
@@ -402,21 +317,21 @@
402 317 wp_deregister_style('widgets');
403 318 wp_deregister_style('l10n');
404 319 wp_deregister_style('site-icon');
405 320
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', '');
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);
419 334
420 335 }
421 336
422 337 public function enqueueCommonAssets()
@@ -421,9 +336,9 @@
421 336
422 337 public function enqueueCommonAssets()
423 338 {
424 339
425 - wp_enqueue_style(SLUG.'-fs-notices', ASSETS_URL.'global/css/global.css', [], VERSION);
340 + wp_enqueue_style(SLUG.'-fs-notices', ASSETS_URL.'global/css/fs-notices.css', [], VERSION);
426 341 }
427 342
428 343 public function ajaxRequest()
429 344 {
@@ -476,29 +391,11 @@
476 391
477 392 return false;
478 393 }
479 394
480 - public function isNetworkActive(): bool
481 - {
395 + public function getAdminUrl(): string {
482 396
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 );
397 + return admin_url( 'admin.php?page='.SLUG );
501 398 }
502 399
503 400 public function getAjaxUrl($req = ''): string
504 401 {