PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.2.4
Adminify – White Label, Admin Menu Editor, Login Customizer v4.2.4
4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 4.1.17 All 164 releases
adminify / Inc / Classes / ThirdPartyCompatibility.php

ThirdPartyCompatibility.php in Adminify – White Label, Admin Menu Editor, Login Customizer 4.2.4, at Inc/Classes/ThirdPartyCompatibility.php

773 lines 30.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace PXLBSAdminify\Inc\Classes;
4
5 use PXLBSAdminify\Inc\Utils;
6 use PXLBSAdminify\Inc\Admin\AdminSettings;
7 use PXLBSAdminify\Inc\Modules\MenuEditor\MenuEditorOptions;
8 // no direct access allowed
9 if ( !defined( 'ABSPATH' ) ) {
10 exit;
11 }
12 /**
13 * PXLBSAdminify
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, 'reset_theme_conflicts'], 999999 );
27 // 28-6-24
28 add_action( 'admin_head', [$this, 'plugin_conflicts'], 999999 );
29 if ( Utils::is_plugin_active( 'gravityforms/gravityforms.php' ) ) {
30 add_filter(
31 'update_footer',
32 [$this, 'change_admin_footer'],
33 9999,
34 3
35 );
36 }
37 // All Fluent Plugin Assets Supports
38 $this->whitelist_assets_in_fluent_plugins();
39 }
40
41 /**
42 * Whitelist Adminify assets in Fluent ecosystem no-conflict mode.
43 *
44 * Fluent Boards, Fluent Booking, Fluent CRM, Fluent Community, Fluent Forms,
45 * and Fluent Snippets (easy-code-manager) iterate $wp_scripts->queue on their
46 * admin pages and dequeue every plugin script whose src isn't in their approved
47 * slug list. Without this whitelist, Adminify's frame-adminify--admin script is
48 * stripped, leaving an empty React mount (white screen).
49 */
50 public function whitelist_assets_in_fluent_plugins() {
51 $add_regex = function ( $slugs ) {
52 $slugs[] = '\\/adminify\\/';
53 return $slugs;
54 };
55 if ( Utils::is_plugin_active( 'fluent-boards/fluent-boards.php' ) ) {
56 add_filter( 'fluent_boards/asset_listed_slugs', $add_regex );
57 }
58 if ( Utils::is_plugin_active( 'fluent-booking/fluent-booking.php' ) ) {
59 add_filter( 'fluent_booking/asset_listed_slugs', $add_regex );
60 }
61 if ( Utils::is_plugin_active( 'fluent-crm/fluent-crm.php' ) ) {
62 add_filter( 'fluent_crm_asset_listed_slugs', $add_regex );
63 }
64 if ( Utils::is_plugin_active( 'fluent-community/fluent-community.php' ) ) {
65 add_filter( 'fluent_community/asset_listed_slugs', $add_regex );
66 add_filter( 'fluent_com_editor/asset_listed_slugs', $add_regex );
67 }
68 if ( Utils::is_plugin_active( 'easy-code-manager/easy-code-manager.php' ) ) {
69 add_filter( 'fluent_snippets_asset_listed_slugs', $add_regex );
70 }
71 if ( Utils::is_plugin_active( 'fluentform/fluentform.php' ) ) {
72 add_filter( 'fluentform/exclude_js_slugs_from_dequeue', function ( $slugs ) {
73 $slugs[] = 'adminify';
74 return $slugs;
75 } );
76 }
77 }
78
79 /**
80 * Gravity Form Custom Footer missing div closing support
81 */
82 public function change_admin_footer( $footer_text ) {
83 $current_screen = get_current_screen();
84 if ( !empty( $current_screen ) && ($current_screen->id === 'toplevel_page_gf_edit_forms' || $current_screen->id === 'forms_page_gf_new_form') ) {
85 return $footer_text . '</div>';
86 }
87 return $footer_text;
88 }
89
90 public function plugin_conflicts() {
91 $adminify_ui = AdminSettings::get_instance()->get( 'admin_ui' );
92 if ( !empty( $adminify_ui ) ) {
93 // Motopress Hotel Booking Lite
94 if ( Utils::is_plugin_active( 'motopress-hotel-booking-lite/motopress-hotel-booking.php' ) ) {
95 echo '<style>
96 .wp-adminify.bookings_page_mphb_calendar .widefat thead th,
97 .wp-adminify.bookings_page_mphb_calendar .widefat tfoot th,
98 .wp-adminify.bookings_page_mphb_calendar .widefat tbody td {
99 padding: 0 !important;
100 }
101 .adminify-ui .widefat tbody tr td:first-child {
102 border-left-color: inherit !important;
103 }
104 </style>';
105 }
106 // Fluent Support
107 if ( Utils::is_plugin_active( 'fluent-support/fluent-support.php' ) ) {
108 echo '<style>
109 body.adminify-ui .fs_main_navbar{width:100%;top:0;left:0;}
110 </style>';
111 }
112 // Fluent Affiliate
113 if ( Utils::is_plugin_active( 'fluent-affiliate/fluent-affiliate.php' ) ) {
114 echo '<style>
115 body.adminify-ui #fluent-affiliate-app #fa_aff_menu {top:0;}
116 </style>';
117 }
118 // Fluent Cart
119 if ( Utils::is_plugin_active( 'fluent-cart/fluent-cart.php' ) ) {
120 echo '<style>
121 body.adminify-ui #wpbody-content #fct_admin_menu_holder .fct_admin_menu_wrap {width:100%;top:0;left:0;}
122 </style>';
123 }
124 }
125 if ( Utils::is_plugin_active( 'squirrly-seo/squirrly.php' ) ) {
126 echo '<style>
127 .wp-adminify.adminify-ui.block-editor-page .interface-interface-skeleton {
128 top: 0 !important;
129 }
130 </style>';
131 }
132 if ( Utils::is_plugin_active( 'surecart/surecart.php' ) || Utils::is_plugin_active( 'suremember/suremember.php' ) ) {
133 if ( !empty( $adminify_ui ) ) {
134 echo '<style>
135 .css-wa3qun,.backdrop-blur-sm {
136 top: 0 !important;
137 }
138 #suremembers-settings-content::before, #sc-settings-content::before{
139 width: 250px !important;
140 }
141 </style>';
142 }
143 }
144 if ( Utils::is_plugin_active( 'advanced-database-cleaner-pro/advanced-db-cleaner.php' ) ) {
145 echo '<style>
146 .wp-adminify.toplevel_page_advanced_db_cleaner #wpbody-content .wp-list-table.widefat td{
147 padding: 10px 10px;
148 }
149 .wp-adminify.toplevel_page_advanced_db_cleaner #wpbody-content input#aDBc_keep_button_revision {
150 padding: 0px 3px !important;
151 line-height: inherit !important;
152 }
153 </style>';
154 }
155 if ( Utils::is_plugin_active( 'insert-headers-and-footers/ihaf.php' ) ) {
156 echo '<style>
157 .wp-adminify .wpcode-code-type-picker, .wp-adminify .wpcode-code-type-picker-backdrop {
158 left: 0;
159 }
160 </style>';
161 }
162 if ( Utils::is_plugin_active( 'advanced-access-manager/aam.php' ) ) {
163 add_filter(
164 'pxlbsadminify_menu_option_compatibility_filter',
165 array($this, 'apply_menu_restrictions_via_filter'),
166 10,
167 2
168 );
169 }
170 if ( Utils::is_plugin_active( 'meta-box/meta-box.php' ) ) {
171 echo '<style>
172 .adminify-ui .og.mb {
173 left: 0;
174 }
175 </style>';
176 }
177 if ( Utils::is_plugin_active( 'wp-security-audit-log/wp-security-audit-log.php' ) ) {
178 echo '<script>
179 jQuery(document).ready(function($) {
180 $("body.wp-adminify.adminify-ui ul.frame-adminify-admin-menu li a .frame-adminify-menu-item-name").find("style").remove();
181
182 setInterval(function() {
183 $("body.wp-adminify.adminify-ui ul.frame-adminify-admin-menu li a .frame-adminify-menu-item-name").find("style").remove();
184 }, 1000);
185 });
186 </script>';
187 }
188 if ( Utils::is_plugin_active( 'shopengine/shopengine.php' ) ) {
189 global $pagenow;
190 // e.g. "edit.php"
191 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only check, no state change.
192 $post_type = ( isset( $_GET['post_type'] ) ? sanitize_key( wp_unslash( $_GET['post_type'] ) ) : '' );
193 // Build the slug
194 $slug = ( $post_type ? "{$pagenow}?post_type={$post_type}" : $pagenow );
195 // Example usage:
196 if ( $slug === 'edit.php?post_type=shopengine-template' ) {
197 echo '<style>
198 #wpfooter {
199 position: inherit !important;
200 display: flex;
201 flex-direction: column-reverse;
202 }
203 </style>';
204 }
205 }
206 if ( Utils::is_plugin_active( 'breeze/breeze.php' ) ) {
207 echo '<script>
208 jQuery(document).ready(function($) {
209
210 const iframe = document.getElementById("frame-adminify-app--iframe");
211
212 const fileBtn = document.getElementById("adminify-top-menu-breeze-purge-file-group");
213 const objectCacheBtn = document.getElementById("adminify-top-menu-breeze-purge-object-cache-group");
214
215 if( fileBtn ) {
216 fileBtn.addEventListener("click", function (e) {
217 handleClickBreezeBtn("#wp-admin-bar-breeze-purge-file-group");
218 });
219 }
220
221 if( objectCacheBtn ) {
222 objectCacheBtn.addEventListener("click", function (e) {
223 handleClickBreezeBtn("#wp-admin-bar-breeze-purge-object-cache-group");
224 });
225 }
226
227 function handleClickBreezeBtn(selector) {
228 try {
229 const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
230
231 // Find and click the button
232 const button = iframeDoc.querySelector(selector);
233 if (button) {
234 button.click();
235 }
236 } catch (error) {
237 console.error("Cannot access iframe content:", error);
238 }
239 }
240 });
241 </script>';
242 }
243 // Redis Object Cache plugin compatibility
244 if ( Utils::is_plugin_active( 'redis-cache/redis-cache.php' ) ) {
245 $nonce = wp_create_nonce();
246 $ajaxurl = esc_url( admin_url( 'admin-ajax.php' ) );
247 $flushingText = __( 'Flushing cache...', 'adminify' );
248 echo '<script>
249 jQuery(document).ready(function($) {
250 const flushBtn = document.getElementById("adminify-top-menu-redis-cache-flush");
251 const parentMenu = document.getElementById("adminify-top-menu-redis-cache");
252
253 if (flushBtn) {
254 const flushLink = flushBtn.querySelector("a");
255
256 flushBtn.addEventListener("click", async function(e) {
257 e.preventDefault();
258 e.stopPropagation();
259
260 if (!flushLink) return;
261
262 // Store original text
263 const originalText = flushLink.textContent || flushLink.innerText;
264
265 // Close dropdown and show flushing text on parent menu
266 const parentLink = parentMenu ? parentMenu.querySelector("a") : null;
267 const parentOriginalHTML = parentLink ? parentLink.innerHTML : null;
268
269 if (parentLink) {
270 parentLink.innerHTML = "' . esc_js( $flushingText ) . '";
271 }
272
273 // Close dropdown
274 const dropdown = flushBtn.closest(".adminify-dropdown");
275 if (dropdown) {
276 dropdown.classList.remove("show");
277 }
278
279 try {
280 const data = new FormData();
281 data.append("action", "roc_flush_cache");
282 data.append("nonce", "' . esc_js( $nonce ) . '");
283
284 const response = await fetch("' . esc_url( $ajaxurl ) . '", {
285 method: "POST",
286 body: data,
287 });
288
289 const resultText = await response.text();
290
291 // Show result text
292 if (parentLink) {
293 parentLink.innerHTML = resultText;
294 }
295
296 // Reset to original after 3 seconds
297 setTimeout(function() {
298 if (parentLink && parentOriginalHTML) {
299 parentLink.innerHTML = parentOriginalHTML;
300 }
301 }, 3000);
302
303 } catch (error) {
304 console.error("Object cache could not be flushed:", error);
305 // Reset on error
306 if (parentLink && parentOriginalHTML) {
307 parentLink.innerHTML = parentOriginalHTML;
308 }
309 }
310 });
311 }
312 });
313 </script>';
314 }
315 }
316
317 public function apply_menu_restrictions_via_filter( $menu_options, $menu ) {
318 $aam_options = get_option( 'aam_access_settings', [] );
319 if ( is_array( $aam_options ) ) {
320 $simplified_aam_option = $this->simplify_aam_menu_restriction( $aam_options );
321 $menu_options = $this->update_aam_menu_option( $menu_options, $simplified_aam_option );
322 }
323 return $menu_options;
324 }
325
326 public function simplify_aam_menu_restriction( $aam_option ) {
327 $simplified_aam_option = [];
328 foreach ( $aam_option['role'] as $role => $aam_role ) {
329 if ( !empty( $aam_role['menu'] ) ) {
330 foreach ( $aam_role['menu'] as $menu_item => $value ) {
331 if ( !$value ) {
332 continue;
333 }
334 $menu_item = str_replace( 'menu-', '', $menu_item );
335 if ( !isset( $simplified_aam_option[$menu_item] ) ) {
336 $simplified_aam_option[$menu_item] = [];
337 }
338 $simplified_aam_option[$menu_item][] = $role;
339 }
340 }
341 }
342 return $simplified_aam_option;
343 }
344
345 public function update_aam_menu_option( $menu_options, $simplified_aam_option ) {
346 foreach ( $menu_options as $key => $item ) {
347 // If this menu item is in restricted list, update hidden_for
348 if ( isset( $simplified_aam_option[$key] ) ) {
349 if ( !isset( $item['hidden_for'] ) ) {
350 $item['hidden_for'] = [];
351 }
352 $item['hidden_for'] = array_merge( $item['hidden_for'], $simplified_aam_option[$key] );
353 $item['hidden_for'] = array_unique( $item['hidden_for'] );
354 }
355 // If submenu exists, apply the function recursively
356 // if (isset($item['submenu']) && is_array($item['submenu'])) {
357 // $item['submenu'] = update_aam_menu_option($item['submenu'], $simplified_aam_option);
358 // }
359 $menu_options[$key] = $item;
360 }
361 return $menu_options;
362 }
363
364 public function reset_theme_conflicts() {
365 global $pagenow;
366 if ( $pagenow == 'wp-login.php' || $pagenow == 'wp-register.php' || $pagenow == 'customize.php' ) {
367 return;
368 }
369 $screen = get_current_screen();
370 $theme = wp_get_theme();
371 // Neve WordPress Theme
372 if ( 'Neve' == $theme->name || 'Neve' == $theme->parent_theme ) {
373 wp_enqueue_style(
374 'wp-adminify_neve-theme',
375 PXLBSADMINIFY_ASSETS . 'css/themes/neve.min.css',
376 false,
377 PXLBSADMINIFY_VER
378 );
379 }
380 // Phlox WordPress Theme
381 if ( 'Phlox' == $theme->name || 'Phlox' == $theme->parent_theme ) {
382 echo '<style>
383 .wp-adminify.adminify-ui #wpcontent .wp-adminify.adminify-top_bar {
384 opacity: 1 !important;
385 }
386 </style>';
387 }
388 // Enfold WordPress Theme
389 if ( 'Enfold' == $theme->name || 'Enfold' == $theme->parent_theme ) {
390 echo '<style>
391 .wp-adminify.avia-advanced-editor-enabled #wpadminbar{
392 display: none !important;
393 }
394 </style>';
395 }
396 // BrightHub theme compatibility fix
397 if ( 'BrightHub' == $theme->name || 'BrightHub' == $theme->parent_theme ) {
398 echo '<style>
399 body.wp-adminify.adminify-ui.wp-theme-brighthub #wpadminbar,
400 body.wp-adminify.adminify-ui.wp-theme-brighthub #adminmenumain{
401 display: none !important;
402 }
403 .adminify-toolbar-wrapper .adminify-toolbar ul.adminify-top-menu li.adminify-top-menu-item{
404 display: flex;
405 width: auto;
406 justify-content: center;
407 align-items: center;
408 }
409 </style>';
410 echo '<script>
411 document.addEventListener("DOMContentLoaded", function() {
412 document.documentElement.setAttribute("frame-adminify-app", "true");
413
414 var iframe = document.querySelector(".adminify-frame-wrapper iframe");
415 if (iframe) {
416 iframe.addEventListener("load", function() {
417 try {
418 iframe.contentDocument.documentElement.setAttribute("frame-adminify-iframe", "true");
419 } catch(e) {
420 console.log("Could not access iframe content");
421 }
422 });
423
424 try {
425 if (iframe.contentDocument && iframe.contentDocument.documentElement) {
426 iframe.contentDocument.documentElement.setAttribute("frame-adminify-iframe", "true");
427 }
428 } catch(e) {
429 // Cross-origin restrictions might prevent access
430 }
431 }
432 });
433 document.addEventListener("DOMContentLoaded", function() {
434 var menuItems = document.querySelectorAll(".wp-adminify.adminify-ui .adminify-toolbar-wrapper .adminify-toolbar .adminify-top-menu li");
435 menuItems.forEach(function(item) {
436 var link = item.querySelector("a");
437 var divInLink = item.querySelector("a > div");
438 if (link && divInLink) {
439 link.textContent = divInLink.textContent;
440 }
441 });
442 });
443 </script>';
444 }
445 // Third Party Plugin CSS Conflict
446 // $pxlbsadminify_plugin_conflict_css = '';
447 // if (Utils::is_plugin_active('quillforms/quillforms.php')) {
448 // $pxlbsadminify_plugin_conflict_css = '//css code here';
449 // $pxlbsadminify_plugin_conflict_css = preg_replace('#/\*.*?\*/#s', '', $pxlbsadminify_plugin_conflict_css);
450 // $pxlbsadminify_plugin_conflict_css = preg_replace('/\s*([{}|:;,])\s+/', '$1', $pxlbsadminify_plugin_conflict_css);
451 // $pxlbsadminify_plugin_conflict_css = preg_replace('/\s\s+(.*)/', '$1', $pxlbsadminify_plugin_conflict_css);
452 // }
453 // $adminify_ui = AdminSettings::get_instance()->get('admin_ui');
454 // if (!empty($adminify_ui)) {
455 // wp_add_inline_style('wp-adminify-admin', wp_strip_all_tags($pxlbsadminify_plugin_conflict_css));
456 // } else {
457 // wp_add_inline_style('wp-adminify-default-ui', wp_strip_all_tags($pxlbsadminify_plugin_conflict_css));
458 // }
459 if ( Utils::is_plugin_active( 'stackable-ultimate-gutenberg-blocks-premium/plugin.php' ) ) {
460 echo '<style>
461 .wp-adminify.adminify-ui #wpcontent .wp-adminify.adminify-top_bar {
462 opacity: 1 !important;
463 }
464 </style>';
465 }
466 if ( Utils::is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
467 echo '<style>
468 .adminify-ui #woocommerce-embedded-root .woocommerce-layout__header, .adminify-ui .woocommerce-layout .woocommerce-layout__header {
469 width: 100%;
470 top: 0;
471 }
472 .adminify-ui #woocommerce-embedded-root .woocommerce-layout__header .woocommerce-layout__header-wrapper, .adminify-ui .woocommerce-layout .woocommerce-layout__header .woocommerce-layout__header-wrapper {
473 margin-right: 1rem;
474 }
475 body.woocommerce-page #wpwrap #wpcontent,
476 body.woocommerce-page.woocommerce_page_wc-admin #wpwrap #wpbody-content {
477 overflow-x: unset !important;
478 position: unset !important;
479 }
480 </style>';
481 }
482 if ( Utils::is_plugin_active( 'tinymce-templates/tinymce-templates.php' ) ) {
483 echo '<style>#tinymce-templates-wrap #tinymce-templates-preview { height: 500px !important; }</style>';
484 }
485 if ( Utils::is_plugin_active( 'elementor/elementor.php' ) ) {
486 echo '<style>
487 body.wp-adminify-admin-bar.admin-bar .dialog-lightbox-widget {
488 height: calc(100vh - 0px) !important;
489 }
490 body.wp-adminify-admin-bar.admin-bar #e-admin-top-bar-root{
491 padding-top: 70px !important;
492 width: calc(100% + 20px) !important;
493 margin-left: -20px;
494 }
495 body.wp-adminify-admin-bar.admin-bar #e-admin-top-bar-root .e-admin-top-bar{
496 padding-left: 20px;
497 }
498
499 body.adminify-ui.e-has-sidebar-navigation #wpwrap #wpcontent #editor-one-top-bar > header {
500 top: 0!important;
501 }
502 </style>';
503 }
504 if ( Utils::is_plugin_active( 'one-click-demo-import/one-click-demo-import.php' ) ) {
505 echo '<style>
506 .wp-adminify.appearance_page_one-click-demo-import .button-hero {
507 min-height: auto !important;
508 }
509 </style>';
510 }
511 if ( Utils::is_plugin_active( 'wpforms-lite/wpforms.php' ) ) {
512 if ( Utils::currentpage_id( 'dashboard' ) ) {
513 wp_enqueue_style(
514 'wpforms-full',
515 WPFORMS_PLUGIN_URL . 'assets/css/frontend/classic/wpforms-full.css',
516 [],
517 WPFORMS_VERSION
518 );
519 }
520 }
521 if ( Utils::is_plugin_active( 'classic-editor/classic-editor.php' ) ) {
522 echo '<style>
523 #ed_toolbar{
524 width: 100% !important;
525 }
526 #ed_toolbar #qt_content_dfw{
527 line-height: inherit;
528 padding: 0;
529 }
530 </style>';
531 }
532 if ( Utils::is_plugin_active( 'updraftplus/updraftplus.php' ) ) {
533 echo '<style>
534 .wp-adminify.settings_page_updraftplus input{
535 border-radius: 4px !important;
536 border: 1px solid #CCC !important;
537 }
538 .wp-adminify.adminify-dark-mode .updraft_feat_table,
539 .wp-adminify.adminify-dark-mode .updraft_feat_table td,
540 .wp-adminify.adminify-dark-mode .updraft_next_scheduled_backups_wrapper > div,
541 .wp-adminify.adminify-dark-mode .updraft_migrate_widget_module_content{
542 background: inherit;
543 }
544 .wp-adminify.adminify-dark-mode .updraft_premium_cta,
545 .wp-adminify.adminify-dark-mode .updraft_premium_cta__bottom,
546 .wp-adminify.adminify-dark-mode .udp-box,
547 .wp-adminify.adminify-dark-mode .updraftcentral_cloud_connect,
548 .wp-adminify.adminify-dark-mode .updraft_advert_bottom,
549 .wp-adminify.adminify-dark-mode #remote-storage-container label{
550 background: #020407;
551 }
552 .wp-adminify.adminify-dark-mode .expertmode .advanced_settings_container .advanced_settings_menu .advanced_tools_button{
553 color: inherit;
554 }
555 </style>';
556 }
557 if ( Utils::is_plugin_active( 'tinymce-advanced/tinymce-advanced.php' ) ) {
558 echo '<style>
559 .wp-editor-container .mce-container-body .mce-menubar.mce-toolbar{
560 position: initial !important;
561 }
562 .wp-editor-container .mce-container-body .mce-toolbar-grp .mce-container-body{
563 position: relative !important;
564 }
565 .wp-editor-container .mce-container-body .mce-toolbar-grp .mce-toolbar.mce-first {
566 padding-right: 0 !important;
567 }
568 #ed_toolbar{
569 width: 100% !important;
570 }
571 #ed_toolbar #qt_content_dfw{
572 line-height: inherit;
573 padding: 0;
574 }
575 </style>';
576 }
577 if ( Utils::is_plugin_active( 'email-template-customizer-for-woo/email-template-customizer-for-woo.php' ) ) {
578 if ( $screen->id === 'edit-viwec_template' ) {
579 echo '<style>
580 #wpfooter{
581 position: relative !important;
582 display: flex;
583 flex-direction: column-reverse;
584 }
585 </style>';
586 }
587 }
588 if ( Utils::is_plugin_active( 'woocommerce-orders-tracking/woocommerce-orders-tracking.php' ) ) {
589 if ( $screen->id === 'woocommerce_page_wc-orders' ) {
590 echo '<style>
591 #wpfooter{
592 position: relative !important;
593 display: block !important;
594 flex-direction: column-reverse;
595 }
596 </style>';
597 }
598 }
599 // Divi Theme - "Edit With Divi" link should reload parent page instead of iframe
600 if ( 'Divi' == $theme->name || 'Divi' == $theme->parent_theme ) {
601 echo '<script>
602 document.addEventListener("DOMContentLoaded", function() {
603 var iframe = document.getElementById("frame-adminify-app--iframe");
604 if (!iframe) return;
605
606 function handleDiviLinks(iframeDoc) {
607 var diviLinks = iframeDoc.querySelectorAll("a[href*=\\"et_fb=1\\"], a.et_pb_toggle_builder_wrapper, a[href*=\\"page=et_divi_options\\"]");
608 diviLinks.forEach(function(link) {
609 link.addEventListener("click", function(e) {
610 e.preventDefault();
611 e.stopPropagation();
612 window.top.location.href = link.href;
613 });
614 });
615 }
616
617 iframe.addEventListener("load", function() {
618 try {
619 var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
620 handleDiviLinks(iframeDoc);
621
622 var observer = new MutationObserver(function() {
623 handleDiviLinks(iframeDoc);
624 });
625 observer.observe(iframeDoc.body, { childList: true, subtree: true });
626 } catch(e) {
627 console.log("Divi compatibility: Cannot access iframe content");
628 }
629 });
630 });
631 </script>';
632 echo '<style>
633 #adminify-top-menu-et-builder-shortcode-framework,
634 #adminify-top-menu-et-builder-shortcode-framework-loaded,
635 #adminify-top-menu-et-builder-shortcode-framework-option,
636 #adminify-top-menu-et-builder-shortcode-framework-constant,
637 #adminify-top-menu-et-builder-shortcode-framework-hook,
638 #adminify-top-menu-et-builder-shortcode-framework-constant-value {
639 display: none;
640 }
641 </style>';
642 }
643 if ( Utils::is_plugin_active( 'js_composer/js_composer.php' ) ) {
644 echo '<style>
645 .adminify-ui .vc_dropdown-list-item p{
646 color: #fff;
647 }
648 </style>';
649 }
650 // Third Party localize script
651 wp_localize_script( 'adminify-admin', 'PXLBSADMINIFY_THIRDPARTY', $this->thirdparty_create_js_object() );
652 }
653
654 public function thirdparty_create_js_object() {
655 // betterlinks menu settings
656 $betterlinks = [
657 'active' => false,
658 ];
659 if ( Utils::is_plugin_active( 'betterlinks/betterlinks.php' ) ) {
660 if ( is_array( $this->menu_settings ) && array_key_exists( 'betterlinks', $this->menu_settings ) ) {
661 $menu_name = ( !empty( $this->menu_settings['betterlinks']['name'] ) ? esc_html( $this->menu_settings['betterlinks']['name'] ) : '' );
662 $submenu_manage = ( !empty( $this->menu_settings['betterlinks']['submenu']['betterlinks']['name'] ) ? esc_html( $this->menu_settings['betterlinks']['submenu']['betterlinks']['name'] ) : '' );
663 $submenu_name = ( !empty( $this->menu_settings['betterlinks']['submenu']['betterlinks-analytics']['name'] ) ? esc_html( $this->menu_settings['betterlinks']['submenu']['betterlinks-analytics']['name'] ) : '' );
664 $submenu_settings = ( !empty( $this->menu_settings['betterlinks']['submenu']['betterlinks-settings']['name'] ) ? esc_html( $this->menu_settings['betterlinks']['submenu']['betterlinks-settings']['name'] ) : '' );
665 $betterlinks = [
666 'active' => true,
667 'menu_name' => esc_html( $menu_name ),
668 'submenu_manage' => esc_html( $submenu_manage ),
669 'submenu_name' => esc_html( $submenu_name ),
670 'submenu_settings' => esc_html( $submenu_settings ),
671 ];
672 }
673 }
674 return [
675 'ajax_url' => admin_url( 'admin-ajax.php' ),
676 'better_links' => wp_kses_post_deep( $betterlinks ),
677 ];
678 }
679
680 public function register_actions_on_init() {
681 // Brizy Builder
682 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only check, no state change.
683 if ( isset( $_REQUEST['brizy-edit-iframe'] ) ) {
684 add_filter( 'pxlbsadminify_defer_skip', '__return_true' );
685 add_filter( 'pxlbsadminify_skip_removing_dashicons', '__return_true' );
686 }
687 }
688
689 public function register_actions_on_admin_init() {
690 $adminify_ui = AdminSettings::get_instance()->get( 'admin_ui' );
691 if ( !empty( $adminify_ui ) ) {
692 // Commented On: 24-3-24
693 add_action( 'admin_enqueue_scripts', [$this, 'enqueue_scripts'], 999 );
694 }
695 // Commented On: 10-6-24
696 // add_filter('pxlbsadminify_third_party_styles', [$this, 'register_compatability_styles']);
697 // Fluent CRM
698 add_action( 'fluentcrm_skip_no_conflict', '__return_true' );
699 // Fluent FORM
700 add_action( 'fluentform_skip_no_conflict', '__return_true' );
701 }
702
703 /**
704 * Register Third Party Styles
705 *
706 * @since 1.0.0
707 */
708 public function register_compatability_styles( $plugin_supports ) {
709 if ( !is_array( $plugin_supports ) ) {
710 $plugin_supports = [];
711 }
712 $plugin_dir = PXLBSADMINIFY_ASSETS . 'css/plugins/';
713 $plugin_files = list_files( PXLBSADMINIFY_PATH . 'assets/css/plugins/', 1 );
714 if ( !empty( $plugin_files ) ) {
715 foreach ( $plugin_files as $file ) {
716 $plugin_supports[wp_basename( $file, '.min.css' )] = $plugin_dir . wp_basename( $file );
717 }
718 }
719 return $plugin_supports;
720 }
721
722 /**
723 * Admin Enqueue Third Party Scripts/Styles
724 *
725 * @return void
726 */
727 public function enqueue_scripts() {
728 $plugin_supports = [];
729 $plugin_supports = apply_filters( 'pxlbsadminify_third_party_styles', $plugin_supports );
730 // Check Plugin Activated for Site Wide
731 if ( is_multisite() ) {
732 $active_plugins = get_site_option( 'active_sitewide_plugins' );
733 foreach ( $active_plugins as $active_path => $active_plugin ) {
734 if ( is_plugin_active_for_network( $active_path ) ) {
735 $string = explode( '/', $active_path );
736 $pluginname = $string[0];
737 if ( isset( $plugin_supports[$pluginname] ) ) {
738 if ( $plugin_supports[$pluginname] != '' ) {
739 wp_register_style(
740 'adminify_site-wide_' . $pluginname . '_css',
741 $plugin_supports[$pluginname],
742 [],
743 PXLBSADMINIFY_VER
744 );
745 wp_enqueue_style( 'adminify_site-wide_' . $pluginname . '_css' );
746 }
747 }
748 }
749 }
750 }
751 // Check Plugin Activated for Individual Sites
752 $activeplugins = get_option( 'active_plugins' );
753 foreach ( $activeplugins as $plugin ) {
754 if ( Utils::is_plugin_active( $plugin ) ) {
755 $string = explode( '/', $plugin );
756 $pluginname = $string[0];
757 if ( isset( $plugin_supports[$pluginname] ) ) {
758 if ( $plugin_supports[$pluginname] != '' ) {
759 wp_register_style(
760 'adminify_' . $pluginname . '_css',
761 $plugin_supports[$pluginname],
762 [],
763 PXLBSADMINIFY_VER
764 );
765 wp_enqueue_style( 'adminify_' . $pluginname . '_css' );
766 }
767 }
768 }
769 }
770 }
771
772 }
773