| @@ -12,9 +12,8 @@ | ||
| 12 | 12 | use \WPAdminify\Inc\Modules\Folders\Folders; |
| 13 | 13 | use \WPAdminify\Inc\Modules\DisableComments\DisableComments; |
| 14 | 14 | use \WPAdminify\Inc\Modules\ServerInformation\ServerInformation; |
| 15 | 15 | use \WPAdminify\Inc\Modules\DismissNotices\Dismiss_Admin_Notices; |
| 16 | -use \WPAdminify\Inc\Modules\DashboardWidget\DashboardWidget; | |
| 17 | 16 | use WPAdminify\Inc\Admin\Options\RollbackVersion; |
| 18 | 17 | |
| 19 | 18 | // no direct access allowed |
| 20 | 19 | if (!defined('ABSPATH')) { |
| @@ -33,11 +32,11 @@ | ||
| 33 | 32 | |
| 34 | 33 | public function __construct() |
| 35 | 34 | { |
| 36 | 35 | $this->modules_init(); |
| 36 | + add_action('admin_notices', [$this, 'module_conflict_notice'], -9999999); | |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - | |
| 40 | 39 | /** |
| 41 | 40 | * Include Moduels |
| 42 | 41 | * |
| 43 | 42 | * @return void |
| @@ -67,14 +66,9 @@ | ||
| 67 | 66 | if (!empty($this->options['disable_comments']['enable_disable_comments'] ) ) { |
| 68 | 67 | new DisableComments(); |
| 69 | 68 | } |
| 70 | 69 | |
| 71 | - if (!empty($this->options['dashboard_widgets'])) { | |
| 72 | - new DashboardWidget(); | |
| 73 | - } | |
| 74 | - | |
| 75 | 70 | // new ServerInformation(); |
| 76 | - | |
| 77 | 71 | MenuEditor::get_instance(); |
| 78 | 72 | |
| 79 | 73 | // TO DO: Turned Off for future release, after making Network Options stable |
| 80 | 74 | // if (Utils::check_modules($this->options['server_info'])) { |
| @@ -79,6 +73,79 @@ | ||
| 79 | 73 | // TO DO: Turned Off for future release, after making Network Options stable |
| 80 | 74 | // if (Utils::check_modules($this->options['server_info'])) { |
| 81 | 75 | // new RollbackVersion(); |
| 82 | 76 | // } |
| 77 | + } | |
| 78 | + | |
| 79 | + public function maybe_conflicted_plugins_active( $plugins ) | |
| 80 | + { | |
| 81 | + // $options = (array) AdminSettings::get_instance()->get(); | |
| 82 | + // if (!Utils::check_modules($options[$module_name])) { | |
| 83 | + // return false; | |
| 84 | + // } | |
| 85 | + | |
| 86 | + $active_plugins = get_option('active_plugins', []); | |
| 87 | + | |
| 88 | + $is_found = false; | |
| 89 | + | |
| 90 | + $_plugin = null; | |
| 91 | + | |
| 92 | + foreach ($active_plugins as $plugin) { | |
| 93 | + if (in_array($plugin, $plugins)) { | |
| 94 | + $is_found = true; | |
| 95 | + $_plugin = $plugin; | |
| 96 | + } | |
| 97 | + } | |
| 98 | + | |
| 99 | + if (!$is_found) { | |
| 100 | + return false; | |
| 101 | + } | |
| 102 | + | |
| 103 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; | |
| 104 | + | |
| 105 | + $all_plugins = get_plugins(); | |
| 106 | + | |
| 107 | + return $all_plugins[$_plugin]; | |
| 108 | + } | |
| 109 | + | |
| 110 | + public function module_conflict_notice() | |
| 111 | + { | |
| 112 | + $this->maybe_show_folder_module_notice(); | |
| 113 | + } | |
| 114 | + | |
| 115 | + public function maybe_show_folder_module_notice() | |
| 116 | + { | |
| 117 | + $plugins = [ | |
| 118 | + 'folders/folders.php', | |
| 119 | + 'filebird/filebird.php', | |
| 120 | + 'real-media-library-lite/index.php', | |
| 121 | + 'wicked-folders/wicked-folders.php', | |
| 122 | + 'real-category-library-lite/index.php', | |
| 123 | + 'wp-media-folders/wp-media-folders.php', | |
| 124 | + 'media-library-plus/maxgalleria-media-library.php', | |
| 125 | + ]; | |
| 126 | + | |
| 127 | + $result = $this->maybe_conflicted_plugins_active( $plugins ); | |
| 128 | + | |
| 129 | + if (!$result) { | |
| 130 | + return; | |
| 131 | + } | |
| 132 | + | |
| 133 | +?> | |
| 134 | + | |
| 135 | + <div class="notice notice-warning is-dismissible"> | |
| 136 | + <p class="notice-brand-identifier"><img width="100" src="<?php echo esc_url(WP_ADMINIFY_ASSETS_IMAGE) . 'logos/logo-text-light.svg'; ?>" alt=""></p> | |
| 137 | + <br /> | |
| 138 | + <?php echo sprintf(wp_kses_post('<p>You are using <strong>%s</strong> plugin, which serve the same purpose as our folder module.</p><p>We have Disabled our <strong>Folder</strong> module, to avoid conflicts.</p>'), esc_html($result['Name'])); ?> | |
| 139 | + | |
| 140 | + </div> | |
| 141 | + | |
| 142 | +<?php | |
| 143 | + | |
| 144 | + $adminSettings = AdminSettings::get_instance(); | |
| 145 | + | |
| 146 | + $options = get_option($adminSettings->prefix); | |
| 147 | + $options['folders'] = false; // force disable | |
| 148 | + | |
| 149 | + update_option($adminSettings->prefix, $options); | |
| 83 | 150 | } |
| 84 | 151 | } |