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