| @@ -1,14 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | -namespace PXLBSAdminify\Inc\Classes\Notifications; | |
| 2 | +namespace WPAdminify\Inc\Classes\Notifications; | |
| 3 | 3 | |
| 4 | -use PXLBSAdminify\Inc\Classes\Notifications\Model\Notice; | |
| 4 | +use WPAdminify\Inc\Classes\Notifications\Base\User_Data; | |
| 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 | * |
| @@ -20,12 +16,12 @@ | ||
| 20 | 16 | |
| 21 | 17 | public function __construct() { |
| 22 | 18 | add_action('admin_notices', [$this, 'maybe_show_folder_module_notice'], -9999999); |
| 23 | 19 | add_action('admin_footer', array($this, 'enqueue_conflict_plugin_admin_scripts'), 99999); |
| 24 | - add_action('wp_ajax_pxlbsadminify_module_conflicts', [$this, 'pxlbsadminify_module_conflicts']); | |
| 20 | + add_action('wp_ajax_jltwp_adminify_module_conflicts', [$this, 'jltwp_adminify_module_conflicts']); | |
| 25 | 21 | } |
| 26 | 22 | |
| 27 | - public function check_folder_module_conflict(){ | |
| 23 | + public function jltwp_adminify_check_folder_module_conflict(){ | |
| 28 | 24 | $plugins = [ |
| 29 | 25 | 'folders/folders.php', |
| 30 | 26 | 'filebird/filebird.php', |
| 31 | 27 | 'real-media-library-lite/index.php', |
| @@ -50,9 +46,9 @@ | ||
| 50 | 46 | * Handle AJAX request to dismiss the admin notice. |
| 51 | 47 | * |
| 52 | 48 | * @since 1.0.0 |
| 53 | 49 | */ |
| 54 | - public function pxlbsadminify_module_conflicts() { | |
| 50 | + public function jltwp_adminify_module_conflicts() { | |
| 55 | 51 | |
| 56 | 52 | if (!current_user_can('install_plugins')) { |
| 57 | 53 | return; |
| 58 | 54 | } |
| @@ -57,21 +53,18 @@ | ||
| 57 | 53 | return; |
| 58 | 54 | } |
| 59 | 55 | |
| 60 | 56 | // Verify nonce for security. |
| 61 | - check_ajax_referer( 'pxlbsadminify_dismiss_notice_nonce', 'nonce' ); | |
| 62 | - $plugin_name = isset($_POST['plugin_name']) ? sanitize_text_field(wp_unslash($_POST['plugin_name'])) : ''; | |
| 63 | - if ('' === $plugin_name) { | |
| 64 | - wp_send_json_error( array( 'message' => __( 'Missing plugin name.', 'adminify' ) ), 400 ); | |
| 65 | - } | |
| 66 | - $plugin_exists = get_option('pxlbsadminify_plugin_conflict'); | |
| 57 | + check_ajax_referer( 'dismiss_notice_nonce', 'nonce' ); | |
| 58 | + $conflicted_plugins = []; | |
| 59 | + $plugin_exists = get_option('_wpadminify_plugin_conflict'); | |
| 67 | 60 | $plugin_exists = is_array($plugin_exists) ? $plugin_exists : []; |
| 68 | - $conflicted_plugins = array_merge( $plugin_exists, [ $plugin_name ] ); | |
| 61 | + $conflicted_plugins = array_merge( $plugin_exists, [$_POST['plugin_name']] ); | |
| 69 | 62 | |
| 70 | 63 | // Update user meta to store dismissal state. |
| 71 | - update_option('pxlbsadminify_plugin_conflict', $conflicted_plugins ); | |
| 64 | + update_option('_wpadminify_plugin_conflict', $conflicted_plugins ); | |
| 72 | 65 | |
| 73 | - $this->force_disable_module('folders'); | |
| 66 | + $this->jltwp_force_disable_module('folders'); | |
| 74 | 67 | wp_send_json_success( array( 'message' => 'Notice dismissed.' ) ); |
| 75 | 68 | } |
| 76 | 69 | |
| 77 | 70 | /** |
| @@ -78,15 +71,15 @@ | ||
| 78 | 71 | * Disable WP Adminify Module. |
| 79 | 72 | * |
| 80 | 73 | * @param string $module_name Module name to disable. |
| 81 | 74 | */ |
| 82 | - public function force_disable_module( $module_name) { | |
| 75 | + public function jltwp_force_disable_module( $module_name) { | |
| 83 | 76 | // Disable WP Adminify Folder Module |
| 84 | - $adminSettings = \PXLBSAdminify\Inc\Admin\AdminSettings::get_instance(); | |
| 77 | + $adminSettings = \WPAdminify\Inc\Admin\AdminSettings::get_instance(); | |
| 85 | 78 | $options = get_option($adminSettings->get_prefix()); |
| 86 | 79 | |
| 87 | 80 | $options[$module_name] = false; // force disable |
| 88 | - update_option('pxlbsadminify_settings', $options); | |
| 81 | + update_option('_wpadminify', $options); | |
| 89 | 82 | } |
| 90 | 83 | |
| 91 | 84 | |
| 92 | 85 | /** |
| @@ -140,18 +133,18 @@ | ||
| 140 | 133 | * @since 1.0.0 |
| 141 | 134 | */ |
| 142 | 135 | public function maybe_show_folder_module_notice() |
| 143 | 136 | { |
| 144 | - $result = $this->check_folder_module_conflict(); | |
| 137 | + $result = $this->jltwp_adminify_check_folder_module_conflict(); | |
| 145 | 138 | if(! $result){ |
| 146 | 139 | return; |
| 147 | 140 | } |
| 148 | - $this->force_disable_module('folders'); | |
| 141 | + $this->jltwp_force_disable_module('folders'); | |
| 149 | 142 | // Check if the notice has already been dismissed. |
| 150 | - $plugin_exists = get_option('pxlbsadminify_plugin_conflict'); | |
| 143 | + $plugin_exists = get_option('_wpadminify_plugin_conflict'); | |
| 151 | 144 | if(!empty($plugin_exists)){ |
| 152 | 145 | if(in_array( $result['Name'], $plugin_exists)){ |
| 153 | - // $this->force_disable_module('folders'); | |
| 146 | + // $this->jltwp_force_disable_module('folders'); | |
| 154 | 147 | return; |
| 155 | 148 | } |
| 156 | 149 | } |
| 157 | 150 | |
| @@ -164,9 +157,9 @@ | ||
| 164 | 157 | |
| 165 | 158 | |
| 166 | 159 | // if (is_admin()) { |
| 167 | 160 | // add_action('admin_footer', array($this, 'enqueue_conflict_plugin_admin_scripts'), 99999); |
| 168 | - // add_action('wp_ajax_pxlbsadminify_module_conflicts', array($this, 'pxlbsadminify_module_conflicts')); | |
| 161 | + // add_action('wp_ajax_jltwp_adminify_module_conflicts', array($this, 'jltwp_adminify_module_conflicts')); | |
| 169 | 162 | // } |
| 170 | 163 | } |
| 171 | 164 | |
| 172 | 165 | /** |
| @@ -174,20 +167,20 @@ | ||
| 174 | 167 | * |
| 175 | 168 | * Enqueue JavaScript that handles the conflict notice dismissal. |
| 176 | 169 | */ |
| 177 | 170 | public function enqueue_conflict_plugin_admin_scripts() { |
| 178 | - if( ! $this->check_folder_module_conflict()) return; | |
| 171 | + if( ! $this->jltwp_adminify_check_folder_module_conflict()) return; | |
| 179 | 172 | |
| 180 | 173 | ?> |
| 181 | 174 | <script> |
| 182 | 175 | |
| 183 | - function pxlbsadminify_notice_action(evt, $this, action_type) { | |
| 176 | + function jltwp_adminify_notice_action(evt, $this, action_type) { | |
| 184 | 177 | if (evt) evt.preventDefault(); |
| 185 | 178 | $this.closest('.conflict-notice-wp-adminify').slideUp(200); |
| 186 | 179 | |
| 187 | 180 | jQuery.post('<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>', { |
| 188 | - action: 'pxlbsadminify_module_conflicts', | |
| 189 | - _wpnonce: '<?php echo esc_js( wp_create_nonce( 'pxlbsadminify_dismiss_notice_nonce' ) ); ?>', | |
| 181 | + action: 'jltwp_adminify_module_conflicts', | |
| 182 | + _wpnonce: '<?php echo esc_js( wp_create_nonce( 'dismiss_notice_nonce' ) ); ?>', | |
| 190 | 183 | action_type: action_type, |
| 191 | 184 | plugin_name: $this.data('pluginName') |
| 192 | 185 | }); |
| 193 | 186 | } |
| @@ -193,9 +186,9 @@ | ||
| 193 | 186 | } |
| 194 | 187 | |
| 195 | 188 | // Notice Dismiss |
| 196 | 189 | jQuery('body').on('click', '.conflict-notice-wp-adminify .wp-adminify-notice-dismiss', function(evt) { |
| 197 | - pxlbsadminify_notice_action(evt, jQuery(this), 'dismiss'); | |
| 190 | + jltwp_adminify_notice_action(evt, jQuery(this), 'dismiss'); | |
| 198 | 191 | }); |
| 199 | 192 | </script> |
| 200 | 193 | |
| 201 | 194 | <?php |