| @@ -1,84 +1,176 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -namespace PXLBSAdminify\Inc\Admin; | |
| 3 | +namespace WPAdminify\Inc\Admin; | |
| 4 | 4 | |
| 5 | -use PXLBSAdminify\Inc\Utils; | |
| 6 | -use \PXLBSAdminify\Inc\Admin\AdminSettings; | |
| 7 | -use \PXLBSAdminify\Inc\Admin\AdminSettingsModel; | |
| 8 | -use \PXLBSAdminify\Inc\Modules\MenuEditor\MenuEditor; | |
| 9 | -use \PXLBSAdminify\Inc\Modules\MenuDuplicator\MenuDuplicator; | |
| 10 | -use \PXLBSAdminify\Inc\Modules\PostDuplicator\PostDuplicator; | |
| 11 | -use \PXLBSAdminify\Inc\Modules\PostTypesOrder\PostTypesOrder; | |
| 12 | -use \PXLBSAdminify\Inc\Modules\Folders\Folders; | |
| 13 | -use \PXLBSAdminify\Inc\Modules\DisableComments\DisableComments; | |
| 14 | -use \PXLBSAdminify\Inc\Modules\ServerInformation\ServerInformation; | |
| 15 | -use \PXLBSAdminify\Inc\Modules\DismissNotices\Dismiss_Admin_Notices; | |
| 16 | -use \PXLBSAdminify\Inc\Modules\DashboardWidget\DashboardWidget; | |
| 17 | -use PXLBSAdminify\Inc\Admin\Options\RollbackVersion; | |
| 18 | - | |
| 5 | +use WPAdminify\Inc\Utils ; | |
| 6 | +use WPAdminify\Inc\Admin\AdminSettings ; | |
| 7 | +use WPAdminify\Inc\Admin\AdminSettingsModel ; | |
| 8 | +use WPAdminify\Inc\Classes\QuickCircleMenu ; | |
| 9 | +use WPAdminify\Inc\Modules\MenuEditor\MenuEditor ; | |
| 10 | +use WPAdminify\Inc\Modules\AdminColumns\AdminColumns ; | |
| 11 | +use WPAdminify\Inc\Modules\Folders\Folders ; | |
| 12 | +use WPAdminify\Inc\Modules\GooglePageSpeed\GooglePageSpeed ; | |
| 13 | +use WPAdminify\Inc\Modules\LoginCustomizer\LoginCustomizer ; | |
| 14 | +use WPAdminify\Inc\Modules\NotificationBar\NotificationBar ; | |
| 15 | +use WPAdminify\Inc\Modules\SidebarGenerator\Sidebar_Generator ; | |
| 16 | +use WPAdminify\Inc\Modules\DismissNotices\Dismiss_Admin_Notices ; | |
| 17 | +use WPAdminify\Inc\Modules\ActivityLogs\ActivityLogs ; | |
| 18 | +use WPAdminify\Inc\Modules\AdminPages\AdminPages ; | |
| 19 | +use WPAdminify\Inc\Modules\CustomHeaderFooter\CustomHeaderFooter ; | |
| 20 | +use WPAdminify\Inc\Modules\DashboardWidget\DashboardWidget ; | |
| 21 | +use WPAdminify\Inc\Modules\PostDuplicator\PostDuplicator ; | |
| 22 | +use WPAdminify\Inc\Modules\MenuDuplicator\MenuDuplicator ; | |
| 23 | +use WPAdminify\Inc\Modules\PostTypesOrder\PostTypesOrder ; | |
| 24 | +use WPAdminify\Inc\Modules\DisableComments\DisableComments ; | |
| 25 | +use WPAdminify\Inc\Modules\ServerInformation\ServerInformation ; | |
| 26 | +use WPAdminify\Inc\Admin\Options\RollbackVersion ; | |
| 19 | 27 | // no direct access allowed |
| 20 | -if (!defined('ABSPATH')) { | |
| 21 | - exit; | |
| 28 | +if ( !defined( 'ABSPATH' ) ) { | |
| 29 | + exit; | |
| 22 | 30 | } |
| 23 | 31 | /** |
| 24 | 32 | * WP Adminify |
| 25 | - * | |
| 26 | 33 | * @package Modules |
| 27 | 34 | * |
| 28 | 35 | * @author Jewel Theme <support@jeweltheme.com> |
| 29 | 36 | */ |
| 30 | - | |
| 31 | 37 | class Modules extends AdminSettingsModel |
| 32 | 38 | { |
| 39 | + public function __construct() | |
| 40 | + { | |
| 41 | + $this->modules_init(); | |
| 42 | + add_action( 'admin_notices', [ $this, 'module_conflict_notice' ], -9999999 ); | |
| 43 | + } | |
| 44 | + | |
| 45 | + /** | |
| 46 | + * Include Moduels | |
| 47 | + * | |
| 48 | + * @return void | |
| 49 | + */ | |
| 50 | + public function modules_init() | |
| 51 | + { | |
| 52 | + $this->options = AdminSettings::get_instance()->get(); | |
| 53 | + if ( Utils::check_modules( $this->options['folders'] ) ) { | |
| 54 | + new Folders(); | |
| 55 | + } | |
| 56 | + if ( Utils::check_modules( $this->options['quick_menu'] ) ) { | |
| 57 | + new QuickCircleMenu(); | |
| 58 | + } | |
| 59 | + if ( Utils::check_modules( $this->options['login_customizer'] ) ) { | |
| 60 | + new LoginCustomizer(); | |
| 61 | + } | |
| 62 | + if ( Utils::check_modules( $this->options['admin_notices'] ) ) { | |
| 63 | + new Dismiss_Admin_Notices(); | |
| 64 | + } | |
| 65 | + if ( Utils::check_modules( $this->options['admin_columns'] ) ) { | |
| 66 | + new AdminColumns(); | |
| 67 | + } | |
| 68 | + if ( Utils::check_modules( $this->options['menu_editor'] ) ) { | |
| 69 | + new MenuEditor(); | |
| 70 | + } | |
| 71 | + if ( Utils::check_modules( $this->options['dashboard_widgets'] ) ) { | |
| 72 | + new DashboardWidget(); | |
| 73 | + } | |
| 74 | + if ( Utils::check_modules( $this->options['pagespeed_insights'] ) ) { | |
| 75 | + new GooglePageSpeed(); | |
| 76 | + } | |
| 77 | + if ( Utils::check_modules( $this->options['custom_css_js'] ) ) { | |
| 78 | + new CustomHeaderFooter(); | |
| 79 | + } | |
| 80 | + if ( Utils::check_modules( $this->options['menu_duplicator'] ) ) { | |
| 81 | + new MenuDuplicator(); | |
| 82 | + } | |
| 83 | + if ( Utils::check_modules( $this->options['activity_logs'] ) ) { | |
| 84 | + ActivityLogs::get_instance(); | |
| 85 | + } | |
| 86 | + if ( Utils::check_modules( $this->options['notification_bar'] ) ) { | |
| 87 | + new NotificationBar(); | |
| 88 | + } | |
| 89 | + if ( Utils::check_modules( $this->options['post_duplicator'] ) ) { | |
| 90 | + new PostDuplicator(); | |
| 91 | + } | |
| 92 | + if ( Utils::check_modules( $this->options['post_types_order'] ) ) { | |
| 93 | + new PostTypesOrder(); | |
| 94 | + } | |
| 95 | + if ( Utils::check_modules( $this->options['disable_comments'] ) ) { | |
| 96 | + new DisableComments(); | |
| 97 | + } | |
| 98 | + if ( Utils::check_modules( $this->options['sidebar_generator'] ) ) { | |
| 99 | + new Sidebar_Generator(); | |
| 100 | + } | |
| 101 | + if ( Utils::check_modules( $this->options['server_info'] ) ) { | |
| 102 | + new ServerInformation(); | |
| 103 | + } | |
| 104 | + // TO DO: Turned Off for future release, after making Network Options stable | |
| 105 | + // if (Utils::check_modules($this->options['server_info'])) { | |
| 106 | + // new RollbackVersion(); | |
| 107 | + // } | |
| 108 | + } | |
| 109 | + | |
| 110 | + public function maybe_conflicted_plugins_active( $plugins, $module_name ) | |
| 111 | + { | |
| 112 | + $options = (array) AdminSettings::get_instance()->get(); | |
| 113 | + if ( !Utils::check_modules( $options[$module_name] ) ) { | |
| 114 | + return false; | |
| 115 | + } | |
| 116 | + $active_plugins = get_option( 'active_plugins', [] ); | |
| 117 | + $is_found = false; | |
| 118 | + $_plugin = null; | |
| 119 | + foreach ( $active_plugins as $plugin ) { | |
| 120 | + | |
| 121 | + if ( in_array( $plugin, $plugins ) ) { | |
| 122 | + $is_found = true; | |
| 123 | + $_plugin = $plugin; | |
| 124 | + } | |
| 125 | + | |
| 126 | + } | |
| 127 | + if ( !$is_found ) { | |
| 128 | + return false; | |
| 129 | + } | |
| 130 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; | |
| 131 | + $all_plugins = get_plugins(); | |
| 132 | + return $all_plugins[$_plugin]; | |
| 133 | + } | |
| 134 | + | |
| 135 | + public function module_conflict_notice() | |
| 136 | + { | |
| 137 | + $this->maybe_show_folder_module_notice(); | |
| 138 | + } | |
| 139 | + | |
| 140 | + public function maybe_show_folder_module_notice() | |
| 141 | + { | |
| 142 | + $plugins = [ | |
| 143 | + 'folders/folders.php', | |
| 144 | + 'filebird/filebird.php', | |
| 145 | + 'real-media-library-lite/index.php', | |
| 146 | + 'wicked-folders/wicked-folders.php', | |
| 147 | + 'real-category-library-lite/index.php', | |
| 148 | + 'wp-media-folders/wp-media-folders.php', | |
| 149 | + 'media-library-plus/maxgalleria-media-library.php' | |
| 150 | + ]; | |
| 151 | + $result = $this->maybe_conflicted_plugins_active( $plugins, 'folders' ); | |
| 152 | + if ( !$result ) { | |
| 153 | + return; | |
| 154 | + } | |
| 155 | + ?> | |
| 33 | 156 | |
| 34 | - public function __construct() | |
| 35 | - { | |
| 36 | - $this->modules_init(); | |
| 37 | - } | |
| 157 | + <div class="notice notice-warning is-dismissible"> | |
| 158 | + <p class="notice-brand-identifier"><img width="100" src="<?php | |
| 159 | + echo WP_ADMINIFY_ASSETS_IMAGE . 'logos/logo-text-light.svg' ; | |
| 160 | + ?>" alt=""></p> | |
| 161 | + <br /> | |
| 162 | + <p>You are using <strong><?php | |
| 163 | + echo $result['Name'] ; | |
| 164 | + ?></strong> plugin, which serve the same purpose as our folder module.</p> | |
| 165 | + <p>We have Disabled our <strong>Folder</strong> module, to avoid conflicts.</p> | |
| 166 | + </div> | |
| 38 | 167 | |
| 168 | +<?php | |
| 169 | + $adminSettings = AdminSettings::get_instance(); | |
| 170 | + $options = get_option( $adminSettings->prefix ); | |
| 171 | + $options['folders'] = false; | |
| 172 | + // force disable | |
| 173 | + update_option( $adminSettings->prefix, $options ); | |
| 174 | + } | |
| 39 | 175 | |
| 40 | - /** | |
| 41 | - * Include Moduels | |
| 42 | - * | |
| 43 | - * @return void | |
| 44 | - */ | |
| 45 | - public function modules_init() | |
| 46 | - { | |
| 47 | - $this->options = AdminSettings::get_instance()->get(); | |
| 48 | - | |
| 49 | - new Dismiss_Admin_Notices(); | |
| 50 | - | |
| 51 | - if (!empty($this->options['folders']['enable_folders'])) { | |
| 52 | - new Folders(); | |
| 53 | - } | |
| 54 | - | |
| 55 | - if (!empty($this->options['post_duplicator']['enable_post_duplicator'])) { | |
| 56 | - new PostDuplicator(); | |
| 57 | - } | |
| 58 | - | |
| 59 | - if (!empty($this->options['menu_duplicator'])) { | |
| 60 | - new MenuDuplicator(); | |
| 61 | - } | |
| 62 | - | |
| 63 | - if (!empty($this->options['post_types_order']['enable_pto'])) { | |
| 64 | - new PostTypesOrder(); | |
| 65 | - } | |
| 66 | - | |
| 67 | - if (!empty($this->options['disable_comments']['enable_disable_comments'] ) ) { | |
| 68 | - new DisableComments(); | |
| 69 | - } | |
| 70 | - | |
| 71 | - if (!empty($this->options['dashboard_widgets'])) { | |
| 72 | - new DashboardWidget(); | |
| 73 | - } | |
| 74 | - | |
| 75 | - // new ServerInformation(); | |
| 76 | - | |
| 77 | - MenuEditor::get_instance(); | |
| 78 | - | |
| 79 | - // TO DO: Turned Off for future release, after making Network Options stable | |
| 80 | - // if (Utils::check_modules($this->options['server_info'])) { | |
| 81 | - // new RollbackVersion(); | |
| 82 | - // } | |
| 83 | - } | |
| 84 | -} | |
| 176 | +} | |