| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPAdminify\Inc\Classes; |
| 4 |
|
| 5 |
use WPAdminify\Inc\Utils; |
| 6 |
use WPAdminify\Inc\Admin\AdminSettings; |
| 7 |
use WPAdminify\Inc\Modules\MenuEditor\MenuEditorOptions; |
| 8 |
// no direct access allowed |
| 9 |
if ( !defined( 'ABSPATH' ) ) { |
| 10 |
exit; |
| 11 |
} |
| 12 |
/** |
| 13 |
* WPAdminify |
| 14 |
* Third Party Plugins Compatibility |
| 15 |
* |
| 16 |
* @author Jewel Theme <support@jeweltheme.com> |
| 17 |
*/ |
| 18 |
class ThirdPartyCompatibility { |
| 19 |
public $menu_settings; |
| 20 |
|
| 21 |
public function __construct() { |
| 22 |
$this->menu_settings = ( new MenuEditorOptions() )->get(); |
| 23 |
add_action( 'init', [$this, 'register_actions_on_init'], 0 ); |
| 24 |
add_action( 'admin_init', [$this, 'register_actions_on_admin_init'], 0 ); |
| 25 |
// 24-3-24 |
| 26 |
add_action( 'admin_enqueue_scripts', [$this, 'jltwp_adminify_reset_theme_conflicts'], 999999 ); |
| 27 |
add_action( 'admin_head', [$this, 'jltwp_adminify_plugin_conflicts'], 999999 ); |
| 28 |
} |
| 29 |
|
| 30 |
public function jltwp_adminify_plugin_conflicts() { |
| 31 |
if ( Utils::is_plugin_active( 'squirrly-seo/squirrly.php' ) ) { |
| 32 |
echo '<style> |
| 33 |
.wp-adminify.adminify-ui.block-editor-page .interface-interface-skeleton { |
| 34 |
top: 0 !important; |
| 35 |
} |
| 36 |
</style>'; |
| 37 |
} |
| 38 |
if ( Utils::is_plugin_active( 'advanced-database-cleaner-pro/advanced-db-cleaner.php' ) ) { |
| 39 |
echo '<style> |
| 40 |
.wp-adminify.toplevel_page_advanced_db_cleaner #wpbody-content .wp-list-table.widefat td{ |
| 41 |
padding: 10px 10px; |
| 42 |
} |
| 43 |
.wp-adminify.toplevel_page_advanced_db_cleaner #wpbody-content input#aDBc_keep_button_revision { |
| 44 |
padding: 0px 3px !important; |
| 45 |
line-height: inherit !important; |
| 46 |
} |
| 47 |
</style>'; |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
public function jltwp_adminify_reset_theme_conflicts() { |
| 52 |
global $pagenow; |
| 53 |
if ( $pagenow == 'wp-login.php' || $pagenow == 'wp-register.php' || $pagenow == 'customize.php' ) { |
| 54 |
return; |
| 55 |
} |
| 56 |
$theme = wp_get_theme(); |
| 57 |
// Neve WordPress Theme |
| 58 |
if ( 'Neve' == $theme->name || 'Neve' == $theme->parent_theme ) { |
| 59 |
wp_enqueue_style( |
| 60 |
'wp-adminify_neve-theme', |
| 61 |
WP_ADMINIFY_ASSETS . 'css/themes/neve.min.css', |
| 62 |
false, |
| 63 |
WP_ADMINIFY_VER |
| 64 |
); |
| 65 |
} |
| 66 |
// Phlox WordPress Theme |
| 67 |
if ( 'Phlox' == $theme->name || 'Phlox' == $theme->parent_theme ) { |
| 68 |
echo '<style> |
| 69 |
.wp-adminify.adminify-ui #wpcontent .wp-adminify.adminify-top_bar { |
| 70 |
opacity: 1 !important; |
| 71 |
} |
| 72 |
</style>'; |
| 73 |
} |
| 74 |
// Enfold WordPress Theme |
| 75 |
if ( 'Enfold' == $theme->name || 'Enfold' == $theme->parent_theme ) { |
| 76 |
echo '<style> |
| 77 |
.wp-adminify.avia-advanced-editor-enabled #wpadminbar{ |
| 78 |
display: none !important; |
| 79 |
} |
| 80 |
</style>'; |
| 81 |
} |
| 82 |
// Third Party Plugin CSS Conflict |
| 83 |
// $jltwp_adminify_plugin_conflict_css = ''; |
| 84 |
// if (Utils::is_plugin_active('quillforms/quillforms.php')) { |
| 85 |
// $jltwp_adminify_plugin_conflict_css = '//css code here'; |
| 86 |
// $jltwp_adminify_plugin_conflict_css = preg_replace('#/\*.*?\*/#s', '', $jltwp_adminify_plugin_conflict_css); |
| 87 |
// $jltwp_adminify_plugin_conflict_css = preg_replace('/\s*([{}|:;,])\s+/', '$1', $jltwp_adminify_plugin_conflict_css); |
| 88 |
// $jltwp_adminify_plugin_conflict_css = preg_replace('/\s\s+(.*)/', '$1', $jltwp_adminify_plugin_conflict_css); |
| 89 |
// } |
| 90 |
// $adminify_ui = AdminSettings::get_instance()->get('admin_ui'); |
| 91 |
// if (!empty($adminify_ui)) { |
| 92 |
// wp_add_inline_style('wp-adminify-admin', wp_strip_all_tags($jltwp_adminify_plugin_conflict_css)); |
| 93 |
// } else { |
| 94 |
// wp_add_inline_style('wp-adminify-default-ui', wp_strip_all_tags($jltwp_adminify_plugin_conflict_css)); |
| 95 |
// } |
| 96 |
if ( Utils::is_plugin_active( 'stackable-ultimate-gutenberg-blocks-premium/plugin.php' ) ) { |
| 97 |
echo '<style> |
| 98 |
.wp-adminify.adminify-ui #wpcontent .wp-adminify.adminify-top_bar { |
| 99 |
opacity: 1 !important; |
| 100 |
} |
| 101 |
</style>'; |
| 102 |
} |
| 103 |
if ( Utils::is_plugin_active( 'woocommerce/woocommerce.php' ) ) { |
| 104 |
echo '<style> |
| 105 |
body.woocommerce-page #wpwrap #wpcontent, |
| 106 |
body.woocommerce-page.woocommerce_page_wc-admin #wpwrap #wpbody-content { |
| 107 |
overflow-x: unset !important; |
| 108 |
position: unset !important; |
| 109 |
} |
| 110 |
</style>'; |
| 111 |
} |
| 112 |
if ( Utils::is_plugin_active( 'tinymce-templates/tinymce-templates.php' ) ) { |
| 113 |
echo '<style>#tinymce-templates-wrap #tinymce-templates-preview { height: 500px !important; }</style>'; |
| 114 |
} |
| 115 |
if ( Utils::is_plugin_active( 'elementor/elementor.php' ) ) { |
| 116 |
echo '<style> |
| 117 |
body.wp-adminify-admin-bar.admin-bar .dialog-lightbox-widget { |
| 118 |
height: calc(100vh - 0px) !important; |
| 119 |
} |
| 120 |
body.wp-adminify-admin-bar.admin-bar #e-admin-top-bar-root{ |
| 121 |
padding-top: 70px !important; |
| 122 |
width: calc(100% + 20px) !important; |
| 123 |
margin-left: -20px; |
| 124 |
} |
| 125 |
body.wp-adminify-admin-bar.admin-bar #e-admin-top-bar-root .e-admin-top-bar{ |
| 126 |
padding-left: 20px; |
| 127 |
} |
| 128 |
</style>'; |
| 129 |
} |
| 130 |
if ( Utils::is_plugin_active( 'one-click-demo-import/one-click-demo-import.php' ) ) { |
| 131 |
echo '<style> |
| 132 |
.wp-adminify.appearance_page_one-click-demo-import .button-hero { |
| 133 |
min-height: auto !important; |
| 134 |
} |
| 135 |
</style>'; |
| 136 |
} |
| 137 |
if ( Utils::is_plugin_active( 'wpforms-lite/wpforms.php' ) ) { |
| 138 |
if ( Utils::jltwp_adminify_currentpage_id( 'dashboard' ) ) { |
| 139 |
wp_enqueue_style( |
| 140 |
'wpforms-full', |
| 141 |
WPFORMS_PLUGIN_URL . 'assets/css/frontend/classic/wpforms-full.css', |
| 142 |
[], |
| 143 |
WPFORMS_VERSION |
| 144 |
); |
| 145 |
} |
| 146 |
} |
| 147 |
if ( Utils::is_plugin_active( 'classic-editor/classic-editor.php' ) ) { |
| 148 |
echo '<style> |
| 149 |
#ed_toolbar{ |
| 150 |
width: 100% !important; |
| 151 |
} |
| 152 |
#ed_toolbar #qt_content_dfw{ |
| 153 |
line-height: inherit; |
| 154 |
padding: 0; |
| 155 |
} |
| 156 |
</style>'; |
| 157 |
} |
| 158 |
if ( Utils::is_plugin_active( 'updraftplus/updraftplus.php' ) ) { |
| 159 |
echo '<style> |
| 160 |
.wp-adminify.settings_page_updraftplus input{ |
| 161 |
border-radius: 4px !important; |
| 162 |
border: 1px solid #CCC !important; |
| 163 |
} |
| 164 |
.wp-adminify.adminify-dark-mode .updraft_feat_table, |
| 165 |
.wp-adminify.adminify-dark-mode .updraft_feat_table td, |
| 166 |
.wp-adminify.adminify-dark-mode .updraft_next_scheduled_backups_wrapper > div, |
| 167 |
.wp-adminify.adminify-dark-mode .updraft_migrate_widget_module_content{ |
| 168 |
background: inherit; |
| 169 |
} |
| 170 |
.wp-adminify.adminify-dark-mode .updraft_premium_cta, |
| 171 |
.wp-adminify.adminify-dark-mode .updraft_premium_cta__bottom, |
| 172 |
.wp-adminify.adminify-dark-mode .udp-box, |
| 173 |
.wp-adminify.adminify-dark-mode .updraftcentral_cloud_connect, |
| 174 |
.wp-adminify.adminify-dark-mode .updraft_advert_bottom, |
| 175 |
.wp-adminify.adminify-dark-mode #remote-storage-container label{ |
| 176 |
background: #020407; |
| 177 |
} |
| 178 |
.wp-adminify.adminify-dark-mode .expertmode .advanced_settings_container .advanced_settings_menu .advanced_tools_button{ |
| 179 |
color: inherit; |
| 180 |
} |
| 181 |
</style>'; |
| 182 |
} |
| 183 |
if ( Utils::is_plugin_active( 'tinymce-advanced/tinymce-advanced.php' ) ) { |
| 184 |
echo '<style> |
| 185 |
.wp-editor-container .mce-container-body .mce-menubar.mce-toolbar{ |
| 186 |
position: initial !important; |
| 187 |
} |
| 188 |
.wp-editor-container .mce-container-body .mce-toolbar-grp .mce-container-body{ |
| 189 |
position: relative !important; |
| 190 |
} |
| 191 |
.wp-editor-container .mce-container-body .mce-toolbar-grp .mce-toolbar.mce-first { |
| 192 |
padding-right: 0 !important; |
| 193 |
} |
| 194 |
#ed_toolbar{ |
| 195 |
width: 100% !important; |
| 196 |
} |
| 197 |
#ed_toolbar #qt_content_dfw{ |
| 198 |
line-height: inherit; |
| 199 |
padding: 0; |
| 200 |
} |
| 201 |
</style>'; |
| 202 |
} |
| 203 |
// Third Party localize script |
| 204 |
wp_localize_script( 'wp-adminify-admin', 'WPAdminify_ThirdParty', $this->thirdparty_create_js_object() ); |
| 205 |
} |
| 206 |
|
| 207 |
public function thirdparty_create_js_object() { |
| 208 |
// betterlinks menu settings |
| 209 |
$betterlinks = [ |
| 210 |
'active' => false, |
| 211 |
]; |
| 212 |
if ( Utils::is_plugin_active( 'betterlinks/betterlinks.php' ) ) { |
| 213 |
if ( is_array( $this->menu_settings ) && array_key_exists( 'betterlinks', $this->menu_settings ) ) { |
| 214 |
$menu_name = ( !empty( $this->menu_settings['betterlinks']['name'] ) ? esc_html( $this->menu_settings['betterlinks']['name'] ) : '' ); |
| 215 |
$submenu_manage = ( !empty( $this->menu_settings['betterlinks']['submenu']['betterlinks']['name'] ) ? esc_html( $this->menu_settings['betterlinks']['submenu']['betterlinks']['name'] ) : '' ); |
| 216 |
$submenu_name = ( !empty( $this->menu_settings['betterlinks']['submenu']['betterlinks-analytics']['name'] ) ? esc_html( $this->menu_settings['betterlinks']['submenu']['betterlinks-analytics']['name'] ) : '' ); |
| 217 |
$submenu_settings = ( !empty( $this->menu_settings['betterlinks']['submenu']['betterlinks-settings']['name'] ) ? esc_html( $this->menu_settings['betterlinks']['submenu']['betterlinks-settings']['name'] ) : '' ); |
| 218 |
$betterlinks = [ |
| 219 |
'active' => true, |
| 220 |
'menu_name' => esc_html( $menu_name ), |
| 221 |
'submenu_manage' => esc_html( $submenu_manage ), |
| 222 |
'submenu_name' => esc_html( $submenu_name ), |
| 223 |
'submenu_settings' => esc_html( $submenu_settings ), |
| 224 |
]; |
| 225 |
} |
| 226 |
} |
| 227 |
return [ |
| 228 |
'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 229 |
'better_links' => wp_kses_post_deep( $betterlinks ), |
| 230 |
]; |
| 231 |
} |
| 232 |
|
| 233 |
public function register_actions_on_init() { |
| 234 |
// Brizy Builder |
| 235 |
if ( isset( $_REQUEST['brizy-edit-iframe'] ) ) { |
| 236 |
add_filter( 'wp_adminify_defer_skip', '__return_true' ); |
| 237 |
add_filter( 'wp_adminify_skip_removing_dashicons', '__return_true' ); |
| 238 |
} |
| 239 |
} |
| 240 |
|
| 241 |
public function register_actions_on_admin_init() { |
| 242 |
$adminify_ui = AdminSettings::get_instance()->get( 'admin_ui' ); |
| 243 |
if ( !empty( $adminify_ui ) ) { |
| 244 |
add_action( 'admin_enqueue_scripts', [$this, 'enqueue_scripts'], 999 ); |
| 245 |
// 24-3-24 |
| 246 |
} |
| 247 |
add_filter( 'adminify_third_party_styles', [$this, 'register_compatability_styles'] ); |
| 248 |
// Fluent CRM |
| 249 |
add_action( 'fluentcrm_skip_no_conflict', '__return_true' ); |
| 250 |
// Fluent FORM |
| 251 |
add_action( 'fluentform_skip_no_conflict', '__return_true' ); |
| 252 |
} |
| 253 |
|
| 254 |
/** |
| 255 |
* Register Third Party Styles |
| 256 |
* |
| 257 |
* @since 1.0.0 |
| 258 |
*/ |
| 259 |
public function register_compatability_styles( $plugin_supports ) { |
| 260 |
if ( !is_array( $plugin_supports ) ) { |
| 261 |
$plugin_supports = []; |
| 262 |
} |
| 263 |
$plugin_dir = WP_ADMINIFY_ASSETS . 'css/plugins/'; |
| 264 |
$plugin_files = list_files( WP_ADMINIFY_PATH . 'assets/css/plugins/', 1 ); |
| 265 |
if ( !empty( $plugin_files ) ) { |
| 266 |
foreach ( $plugin_files as $file ) { |
| 267 |
$plugin_supports[wp_basename( $file, '.min.css' )] = $plugin_dir . wp_basename( $file ); |
| 268 |
} |
| 269 |
} |
| 270 |
return $plugin_supports; |
| 271 |
} |
| 272 |
|
| 273 |
/** |
| 274 |
* Admin Enqueue Third Party Scripts/Styles |
| 275 |
* |
| 276 |
* @return void |
| 277 |
*/ |
| 278 |
public function enqueue_scripts() { |
| 279 |
$plugin_supports = []; |
| 280 |
$plugin_supports = apply_filters( 'adminify_third_party_styles', $plugin_supports ); |
| 281 |
// Check Plugin Activated for Site Wide |
| 282 |
if ( is_multisite() ) { |
| 283 |
$active_plugins = get_site_option( 'active_sitewide_plugins' ); |
| 284 |
foreach ( $active_plugins as $active_path => $active_plugin ) { |
| 285 |
if ( is_plugin_active_for_network( $active_path ) ) { |
| 286 |
$string = explode( '/', $active_path ); |
| 287 |
$pluginname = $string[0]; |
| 288 |
if ( isset( $plugin_supports[$pluginname] ) ) { |
| 289 |
if ( $plugin_supports[$pluginname] != '' ) { |
| 290 |
wp_register_style( |
| 291 |
'wp-adminify_site-wide_' . $pluginname . '_css', |
| 292 |
$plugin_supports[$pluginname], |
| 293 |
[], |
| 294 |
WP_ADMINIFY_VER |
| 295 |
); |
| 296 |
wp_enqueue_style( 'wp-adminify_site-wide_' . $pluginname . '_css' ); |
| 297 |
} |
| 298 |
} |
| 299 |
} |
| 300 |
} |
| 301 |
} |
| 302 |
// Check Plugin Activated for Individual Sites |
| 303 |
$activeplugins = get_option( 'active_plugins' ); |
| 304 |
foreach ( $activeplugins as $plugin ) { |
| 305 |
if ( Utils::is_plugin_active( $plugin ) ) { |
| 306 |
$string = explode( '/', $plugin ); |
| 307 |
$pluginname = $string[0]; |
| 308 |
if ( isset( $plugin_supports[$pluginname] ) ) { |
| 309 |
if ( $plugin_supports[$pluginname] != '' ) { |
| 310 |
wp_register_style( |
| 311 |
'wp-adminify_' . $pluginname . '_css', |
| 312 |
$plugin_supports[$pluginname], |
| 313 |
[], |
| 314 |
WP_ADMINIFY_VER |
| 315 |
); |
| 316 |
wp_enqueue_style( 'wp-adminify_' . $pluginname . '_css' ); |
| 317 |
} |
| 318 |
} |
| 319 |
} |
| 320 |
} |
| 321 |
} |
| 322 |
|
| 323 |
} |
| 324 |
|