| @@ -1,14 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace WPAdminify\Inc\Classes\Notifications; |
| 3 | 3 | |
| 4 | +use WPAdminify\Inc\Classes\Notifications\Base\User_Data; | |
| 4 | 5 | use WPAdminify\Inc\Classes\Notifications\Model\Notice; |
| 5 | 6 | |
| 6 | -// no direct access allowed | |
| 7 | -if (!defined('ABSPATH')) { | |
| 8 | - exit; | |
| 9 | -} | |
| 10 | - | |
| 11 | 7 | if ( ! class_exists( 'Module_Conflicts' ) ) { |
| 12 | 8 | /** |
| 13 | 9 | * Module_Conflicts Class |
| 14 | 10 | * |
| @@ -17,32 +13,21 @@ | ||
| 17 | 13 | class Module_Conflicts extends Notice { |
| 18 | 14 | |
| 19 | 15 | public $color = 'warning'; |
| 20 | 16 | |
| 21 | - public function __construct() { | |
| 17 | + public function __construct() | |
| 18 | + { | |
| 19 | + parent::__construct(); | |
| 22 | 20 | add_action('admin_notices', [$this, 'maybe_show_folder_module_notice'], -9999999); |
| 23 | - add_action('admin_footer', array($this, 'enqueue_conflict_plugin_admin_scripts'), 99999); | |
| 24 | - add_action('wp_ajax_jltwp_adminify_module_conflicts', [$this, 'jltwp_adminify_module_conflicts']); | |
| 25 | - } | |
| 26 | 21 | |
| 27 | - public function jltwp_adminify_check_folder_module_conflict(){ | |
| 28 | - $plugins = [ | |
| 29 | - 'folders/folders.php', | |
| 30 | - 'filebird/filebird.php', | |
| 31 | - 'real-media-library-lite/index.php', | |
| 32 | - 'wicked-folders/wicked-folders.php', | |
| 33 | - 'real-category-library-lite/index.php', | |
| 34 | - 'wp-media-folders/wp-media-folders.php', | |
| 35 | - 'media-library-plus/maxgalleria-media-library.php', | |
| 36 | - ]; | |
| 37 | - $result = $this->maybe_conflicted_plugins_active( $plugins ); | |
| 38 | - | |
| 39 | - if (!$result) { | |
| 40 | - return false; | |
| 22 | + if(is_admin()){ | |
| 23 | + add_action( 'admin_footer', array( $this, 'enqueue_conflict_plugin_admin_scripts' ),99999 ); | |
| 24 | + add_action( 'wp_ajax_jltwp_adminify_module_conflicts', array( $this, 'jltwp_adminify_module_conflicts' ) ); | |
| 41 | 25 | } |
| 42 | - return $result; | |
| 43 | 26 | } |
| 44 | 27 | |
| 28 | + | |
| 29 | + | |
| 45 | 30 | /** |
| 46 | 31 | * Dismiss module conflict notice via AJAX. |
| 47 | 32 | * |
| 48 | 33 | * Stores the conflict notice dismissal state in the options table. |
| @@ -137,12 +122,24 @@ | ||
| 137 | 122 | * @since 1.0.0 |
| 138 | 123 | */ |
| 139 | 124 | public function maybe_show_folder_module_notice() |
| 140 | 125 | { |
| 141 | - $result = $this->jltwp_adminify_check_folder_module_conflict(); | |
| 142 | - if(! $result){ | |
| 126 | + $plugins = [ | |
| 127 | + 'folders/folders.php', | |
| 128 | + 'filebird/filebird.php', | |
| 129 | + 'real-media-library-lite/index.php', | |
| 130 | + 'wicked-folders/wicked-folders.php', | |
| 131 | + 'real-category-library-lite/index.php', | |
| 132 | + 'wp-media-folders/wp-media-folders.php', | |
| 133 | + 'media-library-plus/maxgalleria-media-library.php', | |
| 134 | + ]; | |
| 135 | + | |
| 136 | + $result = $this->maybe_conflicted_plugins_active( $plugins ); | |
| 137 | + | |
| 138 | + if (!$result) { | |
| 143 | 139 | return; |
| 144 | 140 | } |
| 141 | + | |
| 145 | 142 | $this->jltwp_force_disable_module('folders'); |
| 146 | 143 | // Check if the notice has already been dismissed. |
| 147 | 144 | $plugin_exists = get_option('_wpadminify_plugin_conflict'); |
| 148 | 145 | if(!empty($plugin_exists)){ |
| @@ -157,14 +154,8 @@ | ||
| 157 | 154 | <button type="button" class="notice-dismiss wp-adminify-notice-dismiss" data-plugin-name="<?php echo esc_html($result['Name']);?>"></button> |
| 158 | 155 | <?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'])); ?> |
| 159 | 156 | </div> |
| 160 | 157 | <?php |
| 161 | - | |
| 162 | - | |
| 163 | - // if (is_admin()) { | |
| 164 | - // add_action('admin_footer', array($this, 'enqueue_conflict_plugin_admin_scripts'), 99999); | |
| 165 | - // add_action('wp_ajax_jltwp_adminify_module_conflicts', array($this, 'jltwp_adminify_module_conflicts')); | |
| 166 | - // } | |
| 167 | 158 | } |
| 168 | 159 | |
| 169 | 160 | /** |
| 170 | 161 | * Enqueue JavaScript for conflict plugins notice. |
| @@ -170,12 +161,10 @@ | ||
| 170 | 161 | * Enqueue JavaScript for conflict plugins notice. |
| 171 | 162 | * |
| 172 | 163 | * Enqueue JavaScript that handles the conflict notice dismissal. |
| 173 | 164 | */ |
| 174 | - public function enqueue_conflict_plugin_admin_scripts() { | |
| 175 | - if( ! $this->jltwp_adminify_check_folder_module_conflict()) return; | |
| 176 | - | |
| 177 | - ?> | |
| 165 | + public function enqueue_conflict_plugin_admin_scripts() { ?> | |
| 166 | + | |
| 178 | 167 | <script> |
| 179 | 168 | |
| 180 | 169 | function jltwp_adminify_notice_action(evt, $this, action_type) { |
| 181 | 170 | if (evt) evt.preventDefault(); |
| @@ -212,5 +201,5 @@ | ||
| 212 | 201 | return array(0); |
| 213 | 202 | } |
| 214 | 203 | |
| 215 | 204 | } |
| 216 | -} | |
| 205 | +} | |