| 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\Modules\MenuEditor\MenuEditor; |
| 9 |
use \WPAdminify\Inc\Modules\MenuDuplicator\MenuDuplicator; |
| 10 |
use \WPAdminify\Inc\Modules\PostDuplicator\PostDuplicator; |
| 11 |
use \WPAdminify\Inc\Modules\PostTypesOrder\PostTypesOrder; |
| 12 |
use \WPAdminify\Inc\Modules\Folders\Folders; |
| 13 |
use \WPAdminify\Inc\Modules\DisableComments\DisableComments; |
| 14 |
use \WPAdminify\Inc\Modules\ServerInformation\ServerInformation; |
| 15 |
use \WPAdminify\Inc\Modules\DismissNotices\Dismiss_Admin_Notices; |
| 16 |
use WPAdminify\Inc\Admin\Options\RollbackVersion; |
| 17 |
|
| 18 |
// no direct access allowed |
| 19 |
if (!defined('ABSPATH')) { |
| 20 |
exit; |
| 21 |
} |
| 22 |
/** |
| 23 |
* WP Adminify |
| 24 |
* |
| 25 |
* @package Modules |
| 26 |
* |
| 27 |
* @author Jewel Theme <support@jeweltheme.com> |
| 28 |
*/ |
| 29 |
|
| 30 |
class Modules extends AdminSettingsModel |
| 31 |
{ |
| 32 |
|
| 33 |
public function __construct() |
| 34 |
{ |
| 35 |
$this->modules_init(); |
| 36 |
add_action('admin_notices', [$this, 'module_conflict_notice'], -9999999); |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Include Moduels |
| 41 |
* |
| 42 |
* @return void |
| 43 |
*/ |
| 44 |
public function modules_init() |
| 45 |
{ |
| 46 |
$this->options = AdminSettings::get_instance()->get(); |
| 47 |
|
| 48 |
new Dismiss_Admin_Notices(); |
| 49 |
|
| 50 |
if (!empty($this->options['folders']['enable_folders'])) { |
| 51 |
new Folders(); |
| 52 |
} |
| 53 |
|
| 54 |
if (!empty($this->options['post_duplicator']['enable_post_duplicator'])) { |
| 55 |
new PostDuplicator(); |
| 56 |
} |
| 57 |
|
| 58 |
if (!empty($this->options['menu_duplicator'])) { |
| 59 |
new MenuDuplicator(); |
| 60 |
} |
| 61 |
|
| 62 |
if (!empty($this->options['post_types_order']['enable_pto'])) { |
| 63 |
new PostTypesOrder(); |
| 64 |
} |
| 65 |
|
| 66 |
if (!empty($this->options['disable_comments']['enable_disable_comments'] ) ) { |
| 67 |
new DisableComments(); |
| 68 |
} |
| 69 |
|
| 70 |
// new ServerInformation(); |
| 71 |
MenuEditor::get_instance(); |
| 72 |
|
| 73 |
// TO DO: Turned Off for future release, after making Network Options stable |
| 74 |
// if (Utils::check_modules($this->options['server_info'])) { |
| 75 |
// new RollbackVersion(); |
| 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); |
| 150 |
} |
| 151 |
} |
| 152 |
|