| @@ -1,849 +1,172 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -namespace PXLBSAdminify\Inc\Classes; | |
| 3 | +namespace WPAdminify\Inc\Classes; | |
| 4 | 4 | |
| 5 | -use PXLBSAdminify\Inc\Utils; | |
| 6 | -use PXLBSAdminify\Inc\Admin\AdminSettings; | |
| 7 | -use PXLBSAdminify\Inc\Modules\MenuEditor\MenuEditorOptions; | |
| 5 | +use WPAdminify\Inc\Utils; | |
| 6 | + | |
| 8 | 7 | // no direct access allowed |
| 9 | -if ( !defined( 'ABSPATH' ) ) { | |
| 10 | - exit; | |
| 11 | -} | |
| 8 | +if (!defined('ABSPATH')) exit; | |
| 12 | 9 | /** |
| 13 | - * PXLBSAdminify | |
| 10 | + * WPAdminify | |
| 14 | 11 | * Third Party Plugins Compatibility |
| 15 | 12 | * |
| 16 | 13 | * @author Jewel Theme <support@jeweltheme.com> |
| 17 | 14 | */ |
| 18 | -class ThirdPartyCompatibility { | |
| 19 | - public $menu_settings; | |
| 20 | 15 | |
| 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 | - // Inject layout-tightening CSS INTO the block editor iframe (parent CSS | |
| 30 | - // cannot reach inside). Closes the huge top gap between the editor toolbar | |
| 31 | - // and the post title that's amplified inside the Adminify iframe wrapper. | |
| 32 | - // add_filter('block_editor_settings_all', [$this, 'block_editor_iframe_layout_tweaks']); // TODO: comment because not product this issue. if we product this issue then think about why create this this and solve it all type of users | |
| 33 | - if ( Utils::is_plugin_active( 'gravityforms/gravityforms.php' ) ) { | |
| 34 | - add_filter( | |
| 35 | - 'update_footer', | |
| 36 | - [$this, 'change_admin_footer'], | |
| 37 | - 9999, | |
| 38 | - 3 | |
| 39 | - ); | |
| 40 | - } | |
| 41 | - // All Fluent Plugin Assets Supports | |
| 42 | - $this->whitelist_assets_in_fluent_plugins(); | |
| 16 | +class ThirdPartyCompatibility | |
| 17 | +{ | |
| 18 | + public function __construct() | |
| 19 | + { | |
| 20 | + add_action('admin_init', [$this, 'register_actions'], 0); | |
| 21 | + $this->enqueue_scripts(); | |
| 43 | 22 | } |
| 44 | 23 | |
| 45 | - /** | |
| 46 | - * Whitelist Adminify assets in Fluent ecosystem no-conflict mode. | |
| 47 | - * | |
| 48 | - * Fluent Boards, Fluent Booking, Fluent CRM, Fluent Community, Fluent Forms, | |
| 49 | - * and Fluent Snippets (easy-code-manager) iterate $wp_scripts->queue on their | |
| 50 | - * admin pages and dequeue every plugin script whose src isn't in their approved | |
| 51 | - * slug list. Without this whitelist, Adminify's frame-adminify--admin script is | |
| 52 | - * stripped, leaving an empty React mount (white screen). | |
| 53 | - */ | |
| 54 | - public function whitelist_assets_in_fluent_plugins() { | |
| 55 | - $add_regex = function ( $slugs ) { | |
| 56 | - $slugs[] = '\\/adminify\\/'; | |
| 57 | - return $slugs; | |
| 58 | - }; | |
| 59 | - if ( Utils::is_plugin_active( 'fluent-boards/fluent-boards.php' ) ) { | |
| 60 | - add_filter( 'fluent_boards/asset_listed_slugs', $add_regex ); | |
| 61 | - } | |
| 62 | - if ( Utils::is_plugin_active( 'fluent-booking/fluent-booking.php' ) ) { | |
| 63 | - add_filter( 'fluent_booking/asset_listed_slugs', $add_regex ); | |
| 64 | - } | |
| 65 | - if ( Utils::is_plugin_active( 'fluent-crm/fluent-crm.php' ) ) { | |
| 66 | - add_filter( 'fluent_crm_asset_listed_slugs', $add_regex ); | |
| 67 | - } | |
| 68 | - if ( Utils::is_plugin_active( 'fluent-community/fluent-community.php' ) ) { | |
| 69 | - add_filter( 'fluent_community/asset_listed_slugs', $add_regex ); | |
| 70 | - add_filter( 'fluent_com_editor/asset_listed_slugs', $add_regex ); | |
| 71 | - } | |
| 72 | - if ( Utils::is_plugin_active( 'easy-code-manager/easy-code-manager.php' ) ) { | |
| 73 | - add_filter( 'fluent_snippets_asset_listed_slugs', $add_regex ); | |
| 74 | - } | |
| 75 | - if ( Utils::is_plugin_active( 'fluentform/fluentform.php' ) ) { | |
| 76 | - add_filter( 'fluentform/exclude_js_slugs_from_dequeue', function ( $slugs ) { | |
| 77 | - $slugs[] = 'adminify'; | |
| 78 | - return $slugs; | |
| 79 | - } ); | |
| 80 | - } | |
| 24 | + public function register_actions() | |
| 25 | + { | |
| 26 | + add_action('admin_enqueue_scripts', [$this, 'enqueue_scripts'], 999); | |
| 27 | + add_filter('adminify_third_party_styles', [$this, 'register_compatability_styles']); | |
| 81 | 28 | } |
| 82 | 29 | |
| 30 | + | |
| 83 | 31 | /** |
| 84 | - * Gravity Form Custom Footer missing div closing support | |
| 32 | + * Register Third Party Styles | |
| 33 | + * @since 1.0.0 | |
| 85 | 34 | */ |
| 86 | - public function change_admin_footer( $footer_text ) { | |
| 87 | - $current_screen = get_current_screen(); | |
| 88 | - if ( !empty( $current_screen ) && ($current_screen->id === 'toplevel_page_gf_edit_forms' || $current_screen->id === 'forms_page_gf_new_form') ) { | |
| 89 | - return $footer_text . '</div>'; | |
| 90 | - } | |
| 91 | - return $footer_text; | |
| 92 | - } | |
| 93 | 35 | |
| 94 | - public function plugin_conflicts() { | |
| 95 | - $adminify_ui = AdminSettings::get_instance()->get( 'admin_ui' ); | |
| 96 | - if ( !empty( $adminify_ui ) ) { | |
| 97 | - // Motopress Hotel Booking Lite | |
| 98 | - if ( Utils::is_plugin_active( 'motopress-hotel-booking-lite/motopress-hotel-booking.php' ) ) { | |
| 99 | - echo '<style> | |
| 100 | - .wp-adminify.bookings_page_mphb_calendar .widefat thead th, | |
| 101 | - .wp-adminify.bookings_page_mphb_calendar .widefat tfoot th, | |
| 102 | - .wp-adminify.bookings_page_mphb_calendar .widefat tbody td { | |
| 103 | - padding: 0 !important; | |
| 104 | - } | |
| 105 | - .adminify-ui .widefat tbody tr td:first-child { | |
| 106 | - border-left-color: inherit !important; | |
| 107 | - } | |
| 108 | - </style>'; | |
| 109 | - } | |
| 110 | - // Fluent Support | |
| 111 | - if ( Utils::is_plugin_active( 'fluent-support/fluent-support.php' ) ) { | |
| 112 | - echo '<style> | |
| 113 | - body.adminify-ui .fs_main_navbar{width:100%;top:0;left:0;} | |
| 114 | - </style>'; | |
| 115 | - } | |
| 116 | - // Fluent Affiliate | |
| 117 | - if ( Utils::is_plugin_active( 'fluent-affiliate/fluent-affiliate.php' ) ) { | |
| 118 | - echo '<style> | |
| 119 | - body.adminify-ui #fluent-affiliate-app #fa_aff_menu {top:0;} | |
| 120 | - </style>'; | |
| 121 | - } | |
| 122 | - // Fluent Cart | |
| 123 | - if ( Utils::is_plugin_active( 'fluent-cart/fluent-cart.php' ) ) { | |
| 124 | - echo '<style> | |
| 125 | - body.adminify-ui #wpbody-content #fct_admin_menu_holder .fct_admin_menu_wrap {width:100%;top:0;left:0;} | |
| 126 | - </style>'; | |
| 127 | - } | |
| 128 | - // Fluent CRM | |
| 129 | - if ( Utils::is_plugin_active( 'fluent-crm/fluent-crm.php' ) ) { | |
| 130 | - echo '<style> | |
| 131 | - .wp-adminify.adminify-ui .fcrm_topbar {top:0;} | |
| 132 | - </style>'; | |
| 133 | - } | |
| 134 | - // WP 7.0+ Command Palette: kill the focus border on the cmdk input | |
| 135 | - // (Adminify UI input styles bleed in) and wire the Adminify topbar | |
| 136 | - // item (#adminify-top-menu-command-palette) to open the palette. | |
| 137 | - echo '<style> | |
| 138 | - .wp-adminify .commands-command-menu__container input[cmdk-input], | |
| 139 | - .wp-adminify .commands-command-menu__container input[cmdk-input]:focus, | |
| 140 | - .wp-adminify .commands-command-menu__container input[cmdk-input]:focus-visible { | |
| 141 | - border: 0 !important; | |
| 142 | - outline: 0 !important; | |
| 143 | - box-shadow: none !important; | |
| 144 | - } | |
| 145 | - </style>'; | |
| 146 | - $pxlbsadminify_cmdk_js = "(function(){function openCmd(){try{if(window.wp&&wp.data&&wp.data.dispatch('core/commands')){wp.data.dispatch('core/commands').open();return;}}catch(e){}var isMac=/Mac|iPod|iPhone|iPad/.test(navigator.platform);document.dispatchEvent(new KeyboardEvent('keydown',{key:'k',code:'KeyK',keyCode:75,which:75,ctrlKey:!isMac,metaKey:isMac,bubbles:true,cancelable:true}));}document.addEventListener('click',function(e){var t=e.target&&e.target.closest&&e.target.closest('#adminify-top-menu-command-palette a, .adminify-top-menu-command-palette a');if(!t)return;e.preventDefault();openCmd();});}());"; | |
| 147 | - if ( function_exists( 'wp_print_inline_script_tag' ) ) { | |
| 148 | - wp_print_inline_script_tag( $pxlbsadminify_cmdk_js ); | |
| 149 | - } else { | |
| 150 | - echo '<script>' . $pxlbsadminify_cmdk_js . '</script>'; | |
| 151 | - // phpcs:ignore WordPress.WP.EnqueuedResources | |
| 152 | - } | |
| 153 | - // WP 7.0 block editor interface skeleton: pin to 0/0 inside Adminify UI. | |
| 154 | - // WP's default left/top offsets are for the WP admin bar + sidebar which | |
| 155 | - // Adminify hides — without this, the editor shifts off-origin. | |
| 156 | - echo '<style> | |
| 157 | - body.wp-adminify.adminify-ui .editor-editor-interface.edit-post-layout.interface-interface-skeleton, | |
| 158 | - body.wp-adminify.adminify-ui .interface-interface-skeleton { | |
| 159 | - left: 0 !important; | |
| 160 | - top: 0 !important; | |
| 161 | - } | |
| 162 | - </style>'; | |
| 163 | - // WPML (sitepress-multilingual-cms) admin language switcher | |
| 164 | - // (#WPML_ALS) is mirrored into the Adminify topbar. Its language | |
| 165 | - // links otherwise switch inside the iframe, so the parent admin | |
| 166 | - // chrome keeps the old language. Force a full top-window reload to | |
| 167 | - // the chosen language URL so the whole admin re-renders. | |
| 168 | - if ( Utils::is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) ) { | |
| 169 | - $pxlbsadminify_wpml_js = "(function(){document.addEventListener('click',function(e){var li=e.target&&e.target.closest&&e.target.closest('[id^=\"adminify-top-menu-WPML_ALS_\"]');if(!li)return;var a=li.querySelector('a')||(e.target.closest('a'));if(!a)return;var href=a.getAttribute('href')||a.href;if(!href||href==='#')return;e.preventDefault();e.stopPropagation();window.top.location.href=href;},true);}());"; | |
| 170 | - if ( function_exists( 'wp_print_inline_script_tag' ) ) { | |
| 171 | - wp_print_inline_script_tag( $pxlbsadminify_wpml_js ); | |
| 172 | - } else { | |
| 173 | - echo '<script>' . $pxlbsadminify_wpml_js . '</script>'; | |
| 174 | - // phpcs:ignore WordPress.WP.EnqueuedResources | |
| 175 | - } | |
| 176 | - } | |
| 36 | + public function register_compatability_styles($plugin_supports) | |
| 37 | + { | |
| 38 | + | |
| 39 | + if (!is_array($plugin_supports)) { | |
| 40 | + $plugin_supports = array(); | |
| 177 | 41 | } |
| 178 | - if ( Utils::is_plugin_active( 'squirrly-seo/squirrly.php' ) ) { | |
| 179 | - // kept as-is for squirrly compat; the generic adminify-ui rule below covers all editor pages | |
| 180 | - } | |
| 181 | - if ( Utils::is_plugin_active( 'surecart/surecart.php' ) || Utils::is_plugin_active( 'suremember/suremember.php' ) ) { | |
| 182 | - if ( !empty( $adminify_ui ) ) { | |
| 183 | - echo '<style> | |
| 184 | - .css-wa3qun,.backdrop-blur-sm { | |
| 185 | - top: 0 !important; | |
| 186 | - } | |
| 187 | - #suremembers-settings-content::before, #sc-settings-content::before{ | |
| 188 | - width: 250px !important; | |
| 189 | - } | |
| 190 | - </style>'; | |
| 191 | - } | |
| 192 | - } | |
| 193 | - if ( Utils::is_plugin_active( 'advanced-database-cleaner-pro/advanced-db-cleaner.php' ) ) { | |
| 194 | - echo '<style> | |
| 195 | - .wp-adminify.toplevel_page_advanced_db_cleaner #wpbody-content .wp-list-table.widefat td{ | |
| 196 | - padding: 10px 10px; | |
| 197 | - } | |
| 198 | - .wp-adminify.toplevel_page_advanced_db_cleaner #wpbody-content input#aDBc_keep_button_revision { | |
| 199 | - padding: 0px 3px !important; | |
| 200 | - line-height: inherit !important; | |
| 201 | - } | |
| 202 | - </style>'; | |
| 203 | - } | |
| 204 | - if ( Utils::is_plugin_active( 'insert-headers-and-footers/ihaf.php' ) ) { | |
| 205 | - echo '<style> | |
| 206 | - .wp-adminify .wpcode-code-type-picker, .wp-adminify .wpcode-code-type-picker-backdrop { | |
| 207 | - left: 0; | |
| 208 | - } | |
| 209 | - </style>'; | |
| 210 | - } | |
| 211 | - if ( Utils::is_plugin_active( 'advanced-access-manager/aam.php' ) ) { | |
| 212 | - add_filter( | |
| 213 | - 'pxlbsadminify_menu_option_compatibility_filter', | |
| 214 | - array($this, 'apply_menu_restrictions_via_filter'), | |
| 215 | - 10, | |
| 216 | - 2 | |
| 217 | - ); | |
| 218 | - } | |
| 219 | - if ( Utils::is_plugin_active( 'meta-box/meta-box.php' ) ) { | |
| 220 | - echo '<style> | |
| 221 | - .adminify-ui .og.mb { | |
| 222 | - left: 0; | |
| 223 | - } | |
| 224 | - </style>'; | |
| 225 | - } | |
| 226 | - if ( Utils::is_plugin_active( 'wp-security-audit-log/wp-security-audit-log.php' ) ) { | |
| 227 | - echo '<script> | |
| 228 | - jQuery(document).ready(function($) { | |
| 229 | - $("body.wp-adminify.adminify-ui ul.frame-adminify-admin-menu li a .frame-adminify-menu-item-name").find("style").remove(); | |
| 230 | 42 | |
| 231 | - setInterval(function() { | |
| 232 | - $("body.wp-adminify.adminify-ui ul.frame-adminify-admin-menu li a .frame-adminify-menu-item-name").find("style").remove(); | |
| 233 | - }, 1000); | |
| 234 | - }); | |
| 235 | - </script>'; | |
| 236 | - } | |
| 237 | - if ( Utils::is_plugin_active( 'shopengine/shopengine.php' ) ) { | |
| 238 | - global $pagenow; | |
| 239 | - // e.g. "edit.php" | |
| 240 | - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only check, no state change. | |
| 241 | - $post_type = ( isset( $_GET['post_type'] ) ? sanitize_key( wp_unslash( $_GET['post_type'] ) ) : '' ); | |
| 242 | - // Build the slug | |
| 243 | - $slug = ( $post_type ? "{$pagenow}?post_type={$post_type}" : $pagenow ); | |
| 244 | - // Example usage: | |
| 245 | - if ( $slug === 'edit.php?post_type=shopengine-template' ) { | |
| 246 | - echo '<style> | |
| 247 | - #wpfooter { | |
| 248 | - position: inherit !important; | |
| 249 | - display: flex; | |
| 250 | - flex-direction: column-reverse; | |
| 251 | - } | |
| 252 | - </style>'; | |
| 253 | - } | |
| 254 | - } | |
| 255 | - if ( Utils::is_plugin_active( 'breeze/breeze.php' ) ) { | |
| 256 | - echo '<script> | |
| 257 | - jQuery(document).ready(function($) { | |
| 258 | - | |
| 259 | - const iframe = document.getElementById("frame-adminify-app--iframe"); | |
| 43 | + $plugin_supports['jetpack'] = WP_ADMINIFY_ASSETS . 'css/plugins/jetpack.css'; | |
| 44 | + $plugin_supports['akismet'] = WP_ADMINIFY_ASSETS . 'css/plugins/akismet.css'; | |
| 260 | 45 | |
| 261 | - const fileBtn = document.getElementById("adminify-top-menu-breeze-purge-file-group"); | |
| 262 | - const objectCacheBtn = document.getElementById("adminify-top-menu-breeze-purge-object-cache-group"); | |
| 46 | + // Page Builders & Metabox | |
| 47 | + $plugin_supports['gutenberg'] = WP_ADMINIFY_ASSETS . 'css/plugins/gutenberg.css'; | |
| 48 | + $plugin_supports['elementor'] = WP_ADMINIFY_ASSETS . 'css/plugins/elementor.css'; | |
| 49 | + $plugin_supports['siteorigin-page-builder'] = WP_ADMINIFY_ASSETS . 'css/plugins/siteorigin-page-builder.css'; | |
| 50 | + $plugin_supports['google-site-kit'] = WP_ADMINIFY_ASSETS . 'css/plugins/google-site-kit.css'; | |
| 51 | + $plugin_supports['meta-box'] = WP_ADMINIFY_ASSETS . 'css/plugins/meta-box.css'; | |
| 52 | + $plugin_supports['breeze'] = WP_ADMINIFY_ASSETS . 'css/plugins/breeze.css'; | |
| 53 | + $plugin_supports['codepress-admin-columns'] = WP_ADMINIFY_ASSETS . 'css/plugins/codepress-admin-columns.css'; | |
| 54 | + $plugin_supports['admin-menu-editor'] = WP_ADMINIFY_ASSETS . 'css/plugins/admin-menu-editor.css'; | |
| 55 | + // $plugin_supports['admin-menu-editor-pro'] = WP_ADMINIFY_ASSETS . 'css/plugins/admin-menu-editor-pro.css'; | |
| 56 | + $plugin_supports['master-addons'] = WP_ADMINIFY_ASSETS . 'css/plugins/master-addons.css'; | |
| 57 | + $plugin_supports['advanced-custom-fields'] = WP_ADMINIFY_ASSETS . 'css/plugins/advanced-custom-fields.css'; | |
| 58 | + // $plugin_supports['advanced-custom-fields-pro'] = WP_ADMINIFY_ASSETS . 'css/plugins/advanced-custom-fields-pro.css'; | |
| 263 | 59 | |
| 264 | - if( fileBtn ) { | |
| 265 | - fileBtn.addEventListener("click", function (e) { | |
| 266 | - handleClickBreezeBtn("#wp-admin-bar-breeze-purge-file-group"); | |
| 267 | - }); | |
| 268 | - } | |
| 60 | + //Customizer | |
| 61 | + $plugin_supports['loginpress'] = WP_ADMINIFY_ASSETS . 'css/plugins/loginpress.css'; | |
| 269 | 62 | |
| 270 | - if( objectCacheBtn ) { | |
| 271 | - objectCacheBtn.addEventListener("click", function (e) { | |
| 272 | - handleClickBreezeBtn("#wp-admin-bar-breeze-purge-object-cache-group"); | |
| 273 | - }); | |
| 274 | - } | |
| 275 | 63 | |
| 276 | - function handleClickBreezeBtn(selector) { | |
| 277 | - try { | |
| 278 | - const iframeDoc = iframe.contentDocument || iframe.contentWindow.document; | |
| 279 | - | |
| 280 | - // Find and click the button | |
| 281 | - const button = iframeDoc.querySelector(selector); | |
| 282 | - if (button) { | |
| 283 | - button.click(); | |
| 284 | - } | |
| 285 | - } catch (error) { | |
| 286 | - console.error("Cannot access iframe content:", error); | |
| 287 | - } | |
| 288 | - } | |
| 289 | - }); | |
| 290 | - </script>'; | |
| 64 | + // E-Commerce | |
| 65 | + if (jltwp_adminify()->can_use_premium_code__premium_only()) { | |
| 66 | + $plugin_supports['woocommerce'] = WP_ADMINIFY_URL . 'Pro/assets/css/plugins/woocommerce.css'; | |
| 291 | 67 | } |
| 292 | - // Redis Object Cache plugin compatibility | |
| 293 | - if ( Utils::is_plugin_active( 'redis-cache/redis-cache.php' ) ) { | |
| 294 | - $nonce = wp_create_nonce(); | |
| 295 | - $ajaxurl = esc_url( admin_url( 'admin-ajax.php' ) ); | |
| 296 | - $flushingText = __( 'Flushing cache...', 'adminify' ); | |
| 297 | - echo '<script> | |
| 298 | - jQuery(document).ready(function($) { | |
| 299 | - const flushBtn = document.getElementById("adminify-top-menu-redis-cache-flush"); | |
| 300 | - const parentMenu = document.getElementById("adminify-top-menu-redis-cache"); | |
| 68 | + // $plugin_supports['easy-digital-downloads'] = WP_ADMINIFY_ASSETS . 'css/plugins/easy-digital-downloads.css'; | |
| 301 | 69 | |
| 302 | - if (flushBtn) { | |
| 303 | - const flushLink = flushBtn.querySelector("a"); | |
| 70 | + // Security & Performance Plugins | |
| 71 | + $plugin_supports['wordfence'] = WP_ADMINIFY_ASSETS . 'css/plugins/wordfence.css'; | |
| 72 | + $plugin_supports['litespeed-cache'] = WP_ADMINIFY_ASSETS . 'css/plugins/litespeed-cache.css'; | |
| 73 | + $plugin_supports['w3-total-cache'] = WP_ADMINIFY_ASSETS . 'css/plugins/w3-total-cache.css'; | |
| 74 | + $plugin_supports['wp-super-cache'] = WP_ADMINIFY_ASSETS . 'css/plugins/wp-super-cache.css'; | |
| 75 | + $plugin_supports['limit-login-attempts'] = WP_ADMINIFY_ASSETS . 'css/plugins/limit-login-attempts.css'; | |
| 76 | + $plugin_supports['autoptimize'] = WP_ADMINIFY_ASSETS . 'css/plugins/autoptimize.css'; | |
| 77 | + $plugin_supports['disable-comments'] = WP_ADMINIFY_ASSETS . 'css/plugins/disable-comments.css'; | |
| 78 | + $plugin_supports['better-search-replace'] = WP_ADMINIFY_ASSETS . 'css/plugins/better-search-replace.css'; | |
| 79 | + $plugin_supports['better-wp-security'] = WP_ADMINIFY_ASSETS . 'css/plugins/better-wp-security.css'; | |
| 80 | + $plugin_supports['wp-rocket'] = WP_ADMINIFY_ASSETS . 'css/plugins/wp-rocket.css'; | |
| 304 | 81 | |
| 305 | - flushBtn.addEventListener("click", async function(e) { | |
| 306 | - e.preventDefault(); | |
| 307 | - e.stopPropagation(); | |
| 308 | 82 | |
| 309 | - if (!flushLink) return; | |
| 83 | + // Forum & Social Plugins | |
| 84 | + $plugin_supports['bbpress'] = WP_ADMINIFY_ASSETS . 'css/plugins/bbpress.css'; | |
| 85 | + $plugin_supports['buddy-press'] = WP_ADMINIFY_ASSETS . 'css/plugins/buddy-press.css'; | |
| 86 | + $plugin_supports['instagram-feed'] = WP_ADMINIFY_ASSETS . 'css/plugins/instagram-feed.css'; | |
| 310 | 87 | |
| 311 | - // Store original text | |
| 312 | - const originalText = flushLink.textContent || flushLink.innerText; | |
| 313 | 88 | |
| 314 | - // Close dropdown and show flushing text on parent menu | |
| 315 | - const parentLink = parentMenu ? parentMenu.querySelector("a") : null; | |
| 316 | - const parentOriginalHTML = parentLink ? parentLink.innerHTML : null; | |
| 89 | + // Forms Plugins | |
| 90 | + $plugin_supports['contact-form-7'] = WP_ADMINIFY_ASSETS . 'css/plugins/contact-form-7.css'; | |
| 91 | + $plugin_supports['forminator-contact-form'] = WP_ADMINIFY_ASSETS . 'css/plugins/forminator-contact-form.css'; | |
| 92 | + $plugin_supports['wpforms-lite'] = WP_ADMINIFY_ASSETS . 'css/plugins/wpforms.css'; | |
| 93 | + $plugin_supports['wpforms'] = WP_ADMINIFY_ASSETS . 'css/plugins/wpforms.css'; | |
| 94 | + $plugin_supports['weforms'] = WP_ADMINIFY_ASSETS . 'css/plugins/weforms.css'; | |
| 95 | + $plugin_supports['gravityforms'] = WP_ADMINIFY_ASSETS . 'css/plugins/gravityforms.css'; | |
| 96 | + $plugin_supports['aio-contact-lite'] = WP_ADMINIFY_ASSETS . 'css/plugins/aio-contact-lite.css'; | |
| 317 | 97 | |
| 318 | - if (parentLink) { | |
| 319 | - parentLink.innerHTML = "' . esc_js( $flushingText ) . '"; | |
| 320 | - } | |
| 98 | + // Themes | |
| 321 | 99 | |
| 322 | - // Close dropdown | |
| 323 | - const dropdown = flushBtn.closest(".adminify-dropdown"); | |
| 324 | - if (dropdown) { | |
| 325 | - dropdown.classList.remove("show"); | |
| 326 | - } | |
| 327 | 100 | |
| 328 | - try { | |
| 329 | - const data = new FormData(); | |
| 330 | - data.append("action", "roc_flush_cache"); | |
| 331 | - data.append("nonce", "' . esc_js( $nonce ) . '"); | |
| 101 | + // SEO Plugins | |
| 102 | + $plugin_supports['seo-by-rank-math'] = WP_ADMINIFY_ASSETS . 'css/plugins/seo-by-rank-math.css'; | |
| 103 | + $plugin_supports['yoast-seo'] = WP_ADMINIFY_ASSETS . 'css/plugins/wordpress-seo.css'; | |
| 104 | + $plugin_supports['yoast-duplicate'] = WP_ADMINIFY_ASSETS . 'css/plugins/yoast-duplicate.css'; | |
| 105 | + $plugin_supports['redirection'] = WP_ADMINIFY_ASSETS . 'css/plugins/redirection.css'; | |
| 106 | + $plugin_supports['wordpress-seo'] = WP_ADMINIFY_ASSETS . 'css/plugins/wordpress-seo.css'; | |
| 107 | + $plugin_supports['wp-seopress'] = WP_ADMINIFY_ASSETS . 'css/plugins/wp-seopress.css'; | |
| 108 | + $plugin_supports['all-in-one-seo-pack'] = WP_ADMINIFY_ASSETS . 'css/plugins/all-in-one-seo-pack.css'; | |
| 109 | + $plugin_supports['xml-sitemap'] = WP_ADMINIFY_ASSETS . 'css/plugins/xml-sitemap.css'; | |
| 110 | + $plugin_supports['duplicate-page'] = WP_ADMINIFY_ASSETS . 'css/plugins/duplicate-page.css'; | |
| 111 | + $plugin_supports['google-analytics-for-wordpress'] = WP_ADMINIFY_ASSETS . 'css/plugins/monster-insights-for-google-analytics.css'; | |
| 332 | 112 | |
| 333 | - const response = await fetch("' . esc_url( $ajaxurl ) . '", { | |
| 334 | - method: "POST", | |
| 335 | - body: data, | |
| 336 | - }); | |
| 337 | 113 | |
| 338 | - const resultText = await response.text(); | |
| 114 | + // Backup Pluins | |
| 115 | + $plugin_supports['updrafts-backup'] = WP_ADMINIFY_ASSETS . 'css/plugins/updrafts-backup.css'; | |
| 116 | + $plugin_supports['updraftplus'] = WP_ADMINIFY_ASSETS . 'css/plugins/updraftplus.css'; | |
| 117 | + $plugin_supports['all-in-one-wp-migration'] = WP_ADMINIFY_ASSETS . 'css/plugins/all-in-one-wp-migration.css'; | |
| 118 | + $plugin_supports['wp-rocket'] = WP_ADMINIFY_ASSETS . 'css/plugins/wp-rocket.css'; | |
| 119 | + $plugin_supports['duplicate-wp-migration'] = WP_ADMINIFY_ASSETS . 'css/plugins/duplicate-wp-migration.css'; | |
| 120 | + $plugin_supports['backup'] = WP_ADMINIFY_ASSETS . 'css/plugins/backup.css'; | |
| 339 | 121 | |
| 340 | - // Show result text | |
| 341 | - if (parentLink) { | |
| 342 | - parentLink.innerHTML = resultText; | |
| 343 | - } | |
| 122 | + // Mailing Service | |
| 123 | + $plugin_supports['mailpoet'] = WP_ADMINIFY_ASSETS . 'css/plugins/mailpoet.css'; | |
| 124 | + $plugin_supports['mc4wp-mailchimp'] = WP_ADMINIFY_ASSETS . 'css/plugins/mc4wp-mailchimp.css'; | |
| 344 | 125 | |
| 345 | - // Reset to original after 3 seconds | |
| 346 | - setTimeout(function() { | |
| 347 | - if (parentLink && parentOriginalHTML) { | |
| 348 | - parentLink.innerHTML = parentOriginalHTML; | |
| 349 | - } | |
| 350 | - }, 3000); | |
| 126 | + // Icons | |
| 127 | + $plugin_supports['font-awesome'] = WP_ADMINIFY_ASSETS . 'css/plugins/font-awesome.css'; | |
| 351 | 128 | |
| 352 | - } catch (error) { | |
| 353 | - console.error("Object cache could not be flushed:", error); | |
| 354 | - // Reset on error | |
| 355 | - if (parentLink && parentOriginalHTML) { | |
| 356 | - parentLink.innerHTML = parentOriginalHTML; | |
| 357 | - } | |
| 358 | - } | |
| 359 | - }); | |
| 360 | - } | |
| 361 | - }); | |
| 362 | - </script>'; | |
| 363 | - } | |
| 364 | - } | |
| 129 | + // Blog / Post Related | |
| 130 | + $plugin_supports['fakerpress'] = WP_ADMINIFY_ASSETS . 'css/plugins/fakerpress.css'; | |
| 131 | + $plugin_supports['post-types-order'] = WP_ADMINIFY_ASSETS . 'css/plugins/post-types-order.css'; | |
| 365 | 132 | |
| 366 | - public function apply_menu_restrictions_via_filter( $menu_options, $menu ) { | |
| 367 | - $aam_options = get_option( 'aam_access_settings', [] ); | |
| 368 | - if ( is_array( $aam_options ) ) { | |
| 369 | - $simplified_aam_option = $this->simplify_aam_menu_restriction( $aam_options ); | |
| 370 | - $menu_options = $this->update_aam_menu_option( $menu_options, $simplified_aam_option ); | |
| 371 | - } | |
| 372 | - return $menu_options; | |
| 373 | - } | |
| 133 | + // Others | |
| 134 | + $plugin_supports['modern-events-calendar-lite'] = WP_ADMINIFY_ASSETS . 'css/plugins/modern-events-calendar-lite.css'; | |
| 135 | + $plugin_supports['sfwd-lms'] = WP_ADMINIFY_ASSETS . 'css/plugins/sfwd-lms.css'; | |
| 136 | + // $plugin_supports['visualizer'] = WP_ADMINIFY_ASSETS . 'css/plugins/visualizer.css'; | |
| 137 | + // $plugin_supports['wpdatatables'] = WP_ADMINIFY_ASSETS . 'css/plugins/wpdatatables.css'; | |
| 138 | + $plugin_supports['cookie-notice'] = WP_ADMINIFY_ASSETS . 'css/plugins/cookie-notice.css'; | |
| 139 | + $plugin_supports['loco-translate'] = WP_ADMINIFY_ASSETS . 'css/plugins/loco-translate.css'; | |
| 140 | + $plugin_supports['insert-header-footer'] = WP_ADMINIFY_ASSETS . 'css/plugins/insert-header-footer.css'; | |
| 141 | + $plugin_supports['custom-post-type-ui'] = WP_ADMINIFY_ASSETS . 'css/plugins/custom-post-type-ui.css'; | |
| 142 | + $plugin_supports['notificationx'] = WP_ADMINIFY_ASSETS . 'css/plugins/notificationx.css'; | |
| 143 | + $plugin_supports['antispam-bee'] = WP_ADMINIFY_ASSETS . 'css/plugins/antispam-bee.css'; | |
| 374 | 144 | |
| 375 | - public function simplify_aam_menu_restriction( $aam_option ) { | |
| 376 | - $simplified_aam_option = []; | |
| 377 | - foreach ( $aam_option['role'] as $role => $aam_role ) { | |
| 378 | - if ( !empty( $aam_role['menu'] ) ) { | |
| 379 | - foreach ( $aam_role['menu'] as $menu_item => $value ) { | |
| 380 | - if ( !$value ) { | |
| 381 | - continue; | |
| 382 | - } | |
| 383 | - $menu_item = str_replace( 'menu-', '', $menu_item ); | |
| 384 | - if ( !isset( $simplified_aam_option[$menu_item] ) ) { | |
| 385 | - $simplified_aam_option[$menu_item] = []; | |
| 386 | - } | |
| 387 | - $simplified_aam_option[$menu_item][] = $role; | |
| 388 | - } | |
| 389 | - } | |
| 390 | - } | |
| 391 | - return $simplified_aam_option; | |
| 145 | + return $plugin_supports; | |
| 392 | 146 | } |
| 393 | 147 | |
| 394 | - public function update_aam_menu_option( $menu_options, $simplified_aam_option ) { | |
| 395 | - foreach ( $menu_options as $key => $item ) { | |
| 396 | - // If this menu item is in restricted list, update hidden_for | |
| 397 | - if ( isset( $simplified_aam_option[$key] ) ) { | |
| 398 | - if ( !isset( $item['hidden_for'] ) ) { | |
| 399 | - $item['hidden_for'] = []; | |
| 400 | - } | |
| 401 | - $item['hidden_for'] = array_merge( $item['hidden_for'], $simplified_aam_option[$key] ); | |
| 402 | - $item['hidden_for'] = array_unique( $item['hidden_for'] ); | |
| 403 | - } | |
| 404 | - // If submenu exists, apply the function recursively | |
| 405 | - // if (isset($item['submenu']) && is_array($item['submenu'])) { | |
| 406 | - // $item['submenu'] = update_aam_menu_option($item['submenu'], $simplified_aam_option); | |
| 407 | - // } | |
| 408 | - $menu_options[$key] = $item; | |
| 409 | - } | |
| 410 | - return $menu_options; | |
| 411 | - } | |
| 412 | 148 | |
| 413 | - public function reset_theme_conflicts() { | |
| 414 | - global $pagenow; | |
| 415 | - if ( $pagenow == 'wp-login.php' || $pagenow == 'wp-register.php' || $pagenow == 'customize.php' ) { | |
| 416 | - return; | |
| 417 | - } | |
| 418 | - $screen = get_current_screen(); | |
| 419 | - $theme = wp_get_theme(); | |
| 420 | - // Neve WordPress Theme | |
| 421 | - if ( 'Neve' == $theme->name || 'Neve' == $theme->parent_theme ) { | |
| 422 | - wp_enqueue_style( | |
| 423 | - 'wp-adminify_neve-theme', | |
| 424 | - PXLBSADMINIFY_ASSETS . 'css/themes/neve.min.css', | |
| 425 | - false, | |
| 426 | - PXLBSADMINIFY_VER | |
| 427 | - ); | |
| 428 | - } | |
| 429 | - // Phlox WordPress Theme | |
| 430 | - if ( 'Phlox' == $theme->name || 'Phlox' == $theme->parent_theme ) { | |
| 431 | - echo '<style> | |
| 432 | - .wp-adminify.adminify-ui #wpcontent .wp-adminify.adminify-top_bar { | |
| 433 | - opacity: 1 !important; | |
| 434 | - } | |
| 435 | - </style>'; | |
| 436 | - } | |
| 437 | - // Enfold WordPress Theme | |
| 438 | - if ( 'Enfold' == $theme->name || 'Enfold' == $theme->parent_theme ) { | |
| 439 | - echo '<style> | |
| 440 | - .wp-adminify.avia-advanced-editor-enabled #wpadminbar{ | |
| 441 | - display: none !important; | |
| 442 | - } | |
| 443 | - </style>'; | |
| 444 | - } | |
| 445 | - // BrightHub theme compatibility fix | |
| 446 | - if ( 'BrightHub' == $theme->name || 'BrightHub' == $theme->parent_theme ) { | |
| 447 | - echo '<style> | |
| 448 | - body.wp-adminify.adminify-ui.wp-theme-brighthub #wpadminbar, | |
| 449 | - body.wp-adminify.adminify-ui.wp-theme-brighthub #adminmenumain{ | |
| 450 | - display: none !important; | |
| 451 | - } | |
| 452 | - .adminify-toolbar-wrapper .adminify-toolbar ul.adminify-top-menu li.adminify-top-menu-item{ | |
| 453 | - display: flex; | |
| 454 | - width: auto; | |
| 455 | - justify-content: center; | |
| 456 | - align-items: center; | |
| 457 | - } | |
| 458 | - </style>'; | |
| 459 | - echo '<script> | |
| 460 | - document.addEventListener("DOMContentLoaded", function() { | |
| 461 | - document.documentElement.setAttribute("frame-adminify-app", "true"); | |
| 462 | - | |
| 463 | - var iframe = document.querySelector(".adminify-frame-wrapper iframe"); | |
| 464 | - if (iframe) { | |
| 465 | - iframe.addEventListener("load", function() { | |
| 466 | - try { | |
| 467 | - iframe.contentDocument.documentElement.setAttribute("frame-adminify-iframe", "true"); | |
| 468 | - } catch(e) { | |
| 469 | - console.log("Could not access iframe content"); | |
| 470 | - } | |
| 471 | - }); | |
| 472 | - | |
| 473 | - try { | |
| 474 | - if (iframe.contentDocument && iframe.contentDocument.documentElement) { | |
| 475 | - iframe.contentDocument.documentElement.setAttribute("frame-adminify-iframe", "true"); | |
| 476 | - } | |
| 477 | - } catch(e) { | |
| 478 | - // Cross-origin restrictions might prevent access | |
| 479 | - } | |
| 480 | - } | |
| 481 | - }); | |
| 482 | - document.addEventListener("DOMContentLoaded", function() { | |
| 483 | - var menuItems = document.querySelectorAll(".wp-adminify.adminify-ui .adminify-toolbar-wrapper .adminify-toolbar .adminify-top-menu li"); | |
| 484 | - menuItems.forEach(function(item) { | |
| 485 | - var link = item.querySelector("a"); | |
| 486 | - var divInLink = item.querySelector("a > div"); | |
| 487 | - if (link && divInLink) { | |
| 488 | - link.textContent = divInLink.textContent; | |
| 489 | - } | |
| 490 | - }); | |
| 491 | - }); | |
| 492 | - </script>'; | |
| 493 | - } | |
| 494 | - // Third Party Plugin CSS Conflict | |
| 495 | - // $pxlbsadminify_plugin_conflict_css = ''; | |
| 496 | - // if (Utils::is_plugin_active('quillforms/quillforms.php')) { | |
| 497 | - // $pxlbsadminify_plugin_conflict_css = '//css code here'; | |
| 498 | - // $pxlbsadminify_plugin_conflict_css = preg_replace('#/\*.*?\*/#s', '', $pxlbsadminify_plugin_conflict_css); | |
| 499 | - // $pxlbsadminify_plugin_conflict_css = preg_replace('/\s*([{}|:;,])\s+/', '$1', $pxlbsadminify_plugin_conflict_css); | |
| 500 | - // $pxlbsadminify_plugin_conflict_css = preg_replace('/\s\s+(.*)/', '$1', $pxlbsadminify_plugin_conflict_css); | |
| 501 | - // } | |
| 502 | - // $adminify_ui = AdminSettings::get_instance()->get('admin_ui'); | |
| 503 | - // if (!empty($adminify_ui)) { | |
| 504 | - // wp_add_inline_style('wp-adminify-admin', wp_strip_all_tags($pxlbsadminify_plugin_conflict_css)); | |
| 505 | - // } else { | |
| 506 | - // wp_add_inline_style('wp-adminify-default-ui', wp_strip_all_tags($pxlbsadminify_plugin_conflict_css)); | |
| 507 | - // } | |
| 508 | - if ( Utils::is_plugin_active( 'stackable-ultimate-gutenberg-blocks-premium/plugin.php' ) ) { | |
| 509 | - echo '<style> | |
| 510 | - .wp-adminify.adminify-ui #wpcontent .wp-adminify.adminify-top_bar { | |
| 511 | - opacity: 1 !important; | |
| 512 | - } | |
| 513 | - </style>'; | |
| 514 | - } | |
| 515 | - if ( Utils::is_plugin_active( 'woocommerce/woocommerce.php' ) ) { | |
| 516 | - echo '<style> | |
| 517 | - .adminify-ui #woocommerce-embedded-root .woocommerce-layout__header, .adminify-ui .woocommerce-layout .woocommerce-layout__header { | |
| 518 | - width: 100%; | |
| 519 | - top: 0; | |
| 520 | - } | |
| 521 | - .adminify-ui #woocommerce-embedded-root .woocommerce-layout__header .woocommerce-layout__header-wrapper, .adminify-ui .woocommerce-layout .woocommerce-layout__header .woocommerce-layout__header-wrapper { | |
| 522 | - margin-right: 1rem; | |
| 523 | - } | |
| 524 | - body.woocommerce-page #wpwrap #wpcontent, | |
| 525 | - body.woocommerce-page.woocommerce_page_wc-admin #wpwrap #wpbody-content { | |
| 526 | - overflow-x: unset !important; | |
| 527 | - position: unset !important; | |
| 528 | - } | |
| 529 | - </style>'; | |
| 530 | - } | |
| 531 | - if ( Utils::is_plugin_active( 'tinymce-templates/tinymce-templates.php' ) ) { | |
| 532 | - echo '<style>#tinymce-templates-wrap #tinymce-templates-preview { height: 500px !important; }</style>'; | |
| 533 | - } | |
| 534 | - if ( Utils::is_plugin_active( 'elementor/elementor.php' ) ) { | |
| 535 | - echo '<style> | |
| 536 | - body.wp-adminify-admin-bar.admin-bar .dialog-lightbox-widget { | |
| 537 | - height: calc(100vh - 0px) !important; | |
| 538 | - } | |
| 539 | - body.wp-adminify-admin-bar.admin-bar #e-admin-top-bar-root{ | |
| 540 | - padding-top: 70px !important; | |
| 541 | - width: calc(100% + 20px) !important; | |
| 542 | - margin-left: -20px; | |
| 543 | - } | |
| 544 | - body.wp-adminify-admin-bar.admin-bar #e-admin-top-bar-root .e-admin-top-bar{ | |
| 545 | - padding-left: 20px; | |
| 546 | - } | |
| 547 | - | |
| 548 | - body.adminify-ui.e-has-sidebar-navigation #wpwrap #wpcontent #editor-one-top-bar > header { | |
| 549 | - top: 0!important; | |
| 550 | - } | |
| 551 | - </style>'; | |
| 552 | - } | |
| 553 | - if ( Utils::is_plugin_active( 'one-click-demo-import/one-click-demo-import.php' ) ) { | |
| 554 | - echo '<style> | |
| 555 | - .wp-adminify.appearance_page_one-click-demo-import .button-hero { | |
| 556 | - min-height: auto !important; | |
| 557 | - } | |
| 558 | - </style>'; | |
| 559 | - } | |
| 560 | - if ( Utils::is_plugin_active( 'wpforms-lite/wpforms.php' ) ) { | |
| 561 | - if ( Utils::currentpage_id( 'dashboard' ) ) { | |
| 562 | - wp_enqueue_style( | |
| 563 | - 'wpforms-full', | |
| 564 | - WPFORMS_PLUGIN_URL . 'assets/css/frontend/classic/wpforms-full.css', | |
| 565 | - [], | |
| 566 | - WPFORMS_VERSION | |
| 567 | - ); | |
| 568 | - } | |
| 569 | - } | |
| 570 | - if ( Utils::is_plugin_active( 'classic-editor/classic-editor.php' ) ) { | |
| 571 | - echo '<style> | |
| 572 | - #ed_toolbar{ | |
| 573 | - width: 100% !important; | |
| 574 | - } | |
| 575 | - #ed_toolbar #qt_content_dfw{ | |
| 576 | - line-height: inherit; | |
| 577 | - padding: 0; | |
| 578 | - } | |
| 579 | - </style>'; | |
| 580 | - } | |
| 581 | - if ( Utils::is_plugin_active( 'updraftplus/updraftplus.php' ) ) { | |
| 582 | - echo '<style> | |
| 583 | - .wp-adminify.settings_page_updraftplus input{ | |
| 584 | - border-radius: 4px !important; | |
| 585 | - border: 1px solid #CCC !important; | |
| 586 | - } | |
| 587 | - .wp-adminify.adminify-dark-mode .updraft_feat_table, | |
| 588 | - .wp-adminify.adminify-dark-mode .updraft_feat_table td, | |
| 589 | - .wp-adminify.adminify-dark-mode .updraft_next_scheduled_backups_wrapper > div, | |
| 590 | - .wp-adminify.adminify-dark-mode .updraft_migrate_widget_module_content{ | |
| 591 | - background: inherit; | |
| 592 | - } | |
| 593 | - .wp-adminify.adminify-dark-mode .updraft_premium_cta, | |
| 594 | - .wp-adminify.adminify-dark-mode .updraft_premium_cta__bottom, | |
| 595 | - .wp-adminify.adminify-dark-mode .udp-box, | |
| 596 | - .wp-adminify.adminify-dark-mode .updraftcentral_cloud_connect, | |
| 597 | - .wp-adminify.adminify-dark-mode .updraft_advert_bottom, | |
| 598 | - .wp-adminify.adminify-dark-mode #remote-storage-container label{ | |
| 599 | - background: #020407; | |
| 600 | - } | |
| 601 | - .wp-adminify.adminify-dark-mode .expertmode .advanced_settings_container .advanced_settings_menu .advanced_tools_button{ | |
| 602 | - color: inherit; | |
| 603 | - } | |
| 604 | - </style>'; | |
| 605 | - } | |
| 606 | - if ( Utils::is_plugin_active( 'tinymce-advanced/tinymce-advanced.php' ) ) { | |
| 607 | - echo '<style> | |
| 608 | - .wp-editor-container .mce-container-body .mce-menubar.mce-toolbar{ | |
| 609 | - position: initial !important; | |
| 610 | - } | |
| 611 | - .wp-editor-container .mce-container-body .mce-toolbar-grp .mce-container-body{ | |
| 612 | - position: relative !important; | |
| 613 | - } | |
| 614 | - .wp-editor-container .mce-container-body .mce-toolbar-grp .mce-toolbar.mce-first { | |
| 615 | - padding-right: 0 !important; | |
| 616 | - } | |
| 617 | - #ed_toolbar{ | |
| 618 | - width: 100% !important; | |
| 619 | - } | |
| 620 | - #ed_toolbar #qt_content_dfw{ | |
| 621 | - line-height: inherit; | |
| 622 | - padding: 0; | |
| 623 | - } | |
| 624 | - </style>'; | |
| 625 | - } | |
| 626 | - if ( Utils::is_plugin_active( 'email-template-customizer-for-woo/email-template-customizer-for-woo.php' ) ) { | |
| 627 | - if ( $screen->id === 'edit-viwec_template' ) { | |
| 628 | - echo '<style> | |
| 629 | - #wpfooter{ | |
| 630 | - position: relative !important; | |
| 631 | - display: flex; | |
| 632 | - flex-direction: column-reverse; | |
| 633 | - } | |
| 634 | - </style>'; | |
| 635 | - } | |
| 636 | - } | |
| 637 | - if ( Utils::is_plugin_active( 'woocommerce-orders-tracking/woocommerce-orders-tracking.php' ) ) { | |
| 638 | - if ( $screen->id === 'woocommerce_page_wc-orders' ) { | |
| 639 | - echo '<style> | |
| 640 | - #wpfooter{ | |
| 641 | - position: relative !important; | |
| 642 | - display: block !important; | |
| 643 | - flex-direction: column-reverse; | |
| 644 | - } | |
| 645 | - </style>'; | |
| 646 | - } | |
| 647 | - } | |
| 648 | - // Divi Theme - "Edit With Divi" link should reload parent page instead of iframe | |
| 649 | - if ( 'Divi' == $theme->name || 'Divi' == $theme->parent_theme ) { | |
| 650 | - echo '<script> | |
| 651 | - document.addEventListener("DOMContentLoaded", function() { | |
| 652 | - var iframe = document.getElementById("frame-adminify-app--iframe"); | |
| 653 | - if (!iframe) return; | |
| 654 | - | |
| 655 | - function handleDiviLinks(iframeDoc) { | |
| 656 | - var diviLinks = iframeDoc.querySelectorAll("a[href*=\\"et_fb=1\\"], a.et_pb_toggle_builder_wrapper, a[href*=\\"page=et_divi_options\\"]"); | |
| 657 | - diviLinks.forEach(function(link) { | |
| 658 | - link.addEventListener("click", function(e) { | |
| 659 | - e.preventDefault(); | |
| 660 | - e.stopPropagation(); | |
| 661 | - window.top.location.href = link.href; | |
| 662 | - }); | |
| 663 | - }); | |
| 664 | - } | |
| 665 | - | |
| 666 | - iframe.addEventListener("load", function() { | |
| 667 | - try { | |
| 668 | - var iframeDoc = iframe.contentDocument || iframe.contentWindow.document; | |
| 669 | - handleDiviLinks(iframeDoc); | |
| 670 | - | |
| 671 | - var observer = new MutationObserver(function() { | |
| 672 | - handleDiviLinks(iframeDoc); | |
| 673 | - }); | |
| 674 | - observer.observe(iframeDoc.body, { childList: true, subtree: true }); | |
| 675 | - } catch(e) { | |
| 676 | - console.log("Divi compatibility: Cannot access iframe content"); | |
| 677 | - } | |
| 678 | - }); | |
| 679 | - }); | |
| 680 | - </script>'; | |
| 681 | - echo '<style> | |
| 682 | - #adminify-top-menu-et-builder-shortcode-framework, | |
| 683 | - #adminify-top-menu-et-builder-shortcode-framework-loaded, | |
| 684 | - #adminify-top-menu-et-builder-shortcode-framework-option, | |
| 685 | - #adminify-top-menu-et-builder-shortcode-framework-constant, | |
| 686 | - #adminify-top-menu-et-builder-shortcode-framework-hook, | |
| 687 | - #adminify-top-menu-et-builder-shortcode-framework-constant-value { | |
| 688 | - display: none; | |
| 689 | - } | |
| 690 | - </style>'; | |
| 691 | - } | |
| 692 | - if ( Utils::is_plugin_active( 'js_composer/js_composer.php' ) ) { | |
| 693 | - echo '<style> | |
| 694 | - .adminify-ui .vc_dropdown-list-item p{ | |
| 695 | - color: #fff; | |
| 696 | - } | |
| 697 | - </style>'; | |
| 698 | - } | |
| 699 | - // Third Party localize script | |
| 700 | - wp_localize_script( 'adminify-admin', 'PXLBSADMINIFY_THIRDPARTY', $this->thirdparty_create_js_object() ); | |
| 701 | - } | |
| 702 | - | |
| 703 | - public function thirdparty_create_js_object() { | |
| 704 | - // betterlinks menu settings | |
| 705 | - $betterlinks = [ | |
| 706 | - 'active' => false, | |
| 707 | - ]; | |
| 708 | - if ( Utils::is_plugin_active( 'betterlinks/betterlinks.php' ) ) { | |
| 709 | - if ( is_array( $this->menu_settings ) && array_key_exists( 'betterlinks', $this->menu_settings ) ) { | |
| 710 | - $menu_name = ( !empty( $this->menu_settings['betterlinks']['name'] ) ? esc_html( $this->menu_settings['betterlinks']['name'] ) : '' ); | |
| 711 | - $submenu_manage = ( !empty( $this->menu_settings['betterlinks']['submenu']['betterlinks']['name'] ) ? esc_html( $this->menu_settings['betterlinks']['submenu']['betterlinks']['name'] ) : '' ); | |
| 712 | - $submenu_name = ( !empty( $this->menu_settings['betterlinks']['submenu']['betterlinks-analytics']['name'] ) ? esc_html( $this->menu_settings['betterlinks']['submenu']['betterlinks-analytics']['name'] ) : '' ); | |
| 713 | - $submenu_settings = ( !empty( $this->menu_settings['betterlinks']['submenu']['betterlinks-settings']['name'] ) ? esc_html( $this->menu_settings['betterlinks']['submenu']['betterlinks-settings']['name'] ) : '' ); | |
| 714 | - $betterlinks = [ | |
| 715 | - 'active' => true, | |
| 716 | - 'menu_name' => esc_html( $menu_name ), | |
| 717 | - 'submenu_manage' => esc_html( $submenu_manage ), | |
| 718 | - 'submenu_name' => esc_html( $submenu_name ), | |
| 719 | - 'submenu_settings' => esc_html( $submenu_settings ), | |
| 720 | - ]; | |
| 721 | - } | |
| 722 | - } | |
| 723 | - return [ | |
| 724 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), | |
| 725 | - 'better_links' => wp_kses_post_deep( $betterlinks ), | |
| 726 | - ]; | |
| 727 | - } | |
| 728 | - | |
| 729 | - public function register_actions_on_init() { | |
| 730 | - // Brizy Builder | |
| 731 | - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only check, no state change. | |
| 732 | - if ( isset( $_REQUEST['brizy-edit-iframe'] ) ) { | |
| 733 | - add_filter( 'pxlbsadminify_defer_skip', '__return_true' ); | |
| 734 | - add_filter( 'pxlbsadminify_skip_removing_dashicons', '__return_true' ); | |
| 735 | - } | |
| 736 | - } | |
| 737 | - | |
| 738 | - public function register_actions_on_admin_init() { | |
| 739 | - $adminify_ui = AdminSettings::get_instance()->get( 'admin_ui' ); | |
| 740 | - if ( !empty( $adminify_ui ) ) { | |
| 741 | - // Commented On: 24-3-24 | |
| 742 | - add_action( 'admin_enqueue_scripts', [$this, 'enqueue_scripts'], 999 ); | |
| 743 | - } | |
| 744 | - // Commented On: 10-6-24 | |
| 745 | - // add_filter('pxlbsadminify_third_party_styles', [$this, 'register_compatability_styles']); | |
| 746 | - // Fluent CRM | |
| 747 | - add_action( 'fluentcrm_skip_no_conflict', '__return_true' ); | |
| 748 | - // Fluent FORM | |
| 749 | - add_action( 'fluentform_skip_no_conflict', '__return_true' ); | |
| 750 | - } | |
| 751 | - | |
| 752 | 149 | /** |
| 753 | - * Register Third Party Styles | |
| 754 | - * | |
| 755 | - * @since 1.0.0 | |
| 756 | - */ | |
| 757 | - public function register_compatability_styles( $plugin_supports ) { | |
| 758 | - if ( !is_array( $plugin_supports ) ) { | |
| 759 | - $plugin_supports = []; | |
| 760 | - } | |
| 761 | - $plugin_dir = PXLBSADMINIFY_ASSETS . 'css/plugins/'; | |
| 762 | - $plugin_files = list_files( PXLBSADMINIFY_PATH . 'assets/css/plugins/', 1 ); | |
| 763 | - if ( !empty( $plugin_files ) ) { | |
| 764 | - foreach ( $plugin_files as $file ) { | |
| 765 | - $plugin_supports[wp_basename( $file, '.min.css' )] = $plugin_dir . wp_basename( $file ); | |
| 766 | - } | |
| 767 | - } | |
| 768 | - return $plugin_supports; | |
| 769 | - } | |
| 770 | - | |
| 771 | - /** | |
| 772 | 150 | * Admin Enqueue Third Party Scripts/Styles |
| 773 | 151 | * |
| 774 | 152 | * @return void |
| 775 | 153 | */ |
| 776 | - public function enqueue_scripts() { | |
| 777 | - $plugin_supports = []; | |
| 778 | - $plugin_supports = apply_filters( 'pxlbsadminify_third_party_styles', $plugin_supports ); | |
| 779 | - // Check Plugin Activated for Site Wide | |
| 780 | - if ( is_multisite() ) { | |
| 781 | - $active_plugins = get_site_option( 'active_sitewide_plugins' ); | |
| 782 | - foreach ( $active_plugins as $active_path => $active_plugin ) { | |
| 783 | - if ( is_plugin_active_for_network( $active_path ) ) { | |
| 784 | - $string = explode( '/', $active_path ); | |
| 785 | - $pluginname = $string[0]; | |
| 786 | - if ( isset( $plugin_supports[$pluginname] ) ) { | |
| 787 | - if ( $plugin_supports[$pluginname] != '' ) { | |
| 788 | - wp_register_style( | |
| 789 | - 'adminify_site-wide_' . $pluginname . '_css', | |
| 790 | - $plugin_supports[$pluginname], | |
| 791 | - [], | |
| 792 | - PXLBSADMINIFY_VER | |
| 793 | - ); | |
| 794 | - wp_enqueue_style( 'adminify_site-wide_' . $pluginname . '_css' ); | |
| 795 | - } | |
| 796 | - } | |
| 154 | + public function enqueue_scripts() | |
| 155 | + { | |
| 156 | + $plugin_supports = array(); | |
| 157 | + $plugin_supports = apply_filters('adminify_third_party_styles', $plugin_supports); | |
| 158 | + | |
| 159 | + $activeplugins = get_option('active_plugins'); | |
| 160 | + | |
| 161 | + foreach ($activeplugins as $plugin) { | |
| 162 | + $string = explode('/', $plugin); | |
| 163 | + $pluginname = $string[0]; | |
| 164 | + if (isset($plugin_supports[$pluginname])) { | |
| 165 | + if ($plugin_supports[$pluginname] != "") { | |
| 166 | + wp_register_style('wp-adminify_' . $pluginname . '_css', $plugin_supports[$pluginname], array(), WP_ADMINIFY_VER); | |
| 167 | + wp_enqueue_style('wp-adminify_' . $pluginname . '_css'); | |
| 797 | 168 | } |
| 798 | 169 | } |
| 799 | 170 | } |
| 800 | - // Check Plugin Activated for Individual Sites | |
| 801 | - $activeplugins = get_option( 'active_plugins' ); | |
| 802 | - foreach ( $activeplugins as $plugin ) { | |
| 803 | - if ( Utils::is_plugin_active( $plugin ) ) { | |
| 804 | - $string = explode( '/', $plugin ); | |
| 805 | - $pluginname = $string[0]; | |
| 806 | - if ( isset( $plugin_supports[$pluginname] ) ) { | |
| 807 | - if ( $plugin_supports[$pluginname] != '' ) { | |
| 808 | - wp_register_style( | |
| 809 | - 'adminify_' . $pluginname . '_css', | |
| 810 | - $plugin_supports[$pluginname], | |
| 811 | - [], | |
| 812 | - PXLBSADMINIFY_VER | |
| 813 | - ); | |
| 814 | - wp_enqueue_style( 'adminify_' . $pluginname . '_css' ); | |
| 815 | - } | |
| 816 | - } | |
| 817 | - } | |
| 818 | - } | |
| 819 | 171 | } |
| 820 | - | |
| 821 | - /** | |
| 822 | - * Inject layout-tightening CSS INTO the WP 6.3+/7.0 block editor iframe canvas. | |
| 823 | - * | |
| 824 | - * The Gutenberg canvas runs inside an iframe; styles enqueued via | |
| 825 | - * `enqueue_block_editor_assets` only reach the parent admin chrome. The | |
| 826 | - * `block_editor_settings_all` `styles` array IS injected into the iframe. | |
| 827 | - * | |
| 828 | - * The default Gutenberg post-title wrapper carries large block padding which, | |
| 829 | - * inside Adminify's iframe wrapper (already framed by topbar + sidebar), | |
| 830 | - * reads as a huge dead area between the editor toolbar and "Add title". | |
| 831 | - * Compress that wrapper + leading content padding so the title sits close | |
| 832 | - * under the toolbar. | |
| 833 | - */ | |
| 834 | - public function block_editor_iframe_layout_tweaks( $settings ) { | |
| 835 | - // Iframe body padding (Gutenberg ~50-60px default) + root container's first-child | |
| 836 | - // margin-block-start are the two real sources of the gap above "Add title". | |
| 837 | - // Multiple selectors cover WP 6.x ("edit-post-*") and WP 7.0+ ("editor-*", new | |
| 838 | - // "block-editor-iframe__body" body class on the iframe) class renames. | |
| 839 | - $css = 'html body.block-editor-iframe__body,' . 'html body.editor-styles-wrapper,' . '.block-editor-iframe__body,' . '.editor-styles-wrapper{padding-top:12px !important;margin-top:0 !important;}' . '.is-root-container,' . '.editor-styles-wrapper>.is-root-container,' . '.block-editor-block-list__layout.is-root-container,' . '.is-root-container.is-layout-flow,' . '.is-root-container.is-layout-constrained{padding-top:0 !important;margin-top:0 !important;}' . '.is-root-container>*:first-child,' . '.is-root-container>[data-block]:first-child,' . '.editor-styles-wrapper>[data-block]:first-child,' . '.editor-styles-wrapper>.wp-block:first-child{margin-block-start:0 !important;margin-top:0 !important;padding-top:0 !important;}' . '.wp-block-post-title,' . 'h1.wp-block-post-title,' . '.editor-post-title,' . 'h1.editor-post-title,' . '.editor-post-title__input,' . 'h1.editor-post-title__input{margin:0 !important;margin-block-start:0 !important;padding-top:0 !important;}' . '.edit-post-visual-editor,' . '.editor-visual-editor,' . '.edit-post-visual-editor__post-title-wrapper,' . '.editor-visual-editor__post-title-wrapper,' . '.edit-post-visual-editor__content-area,' . '.editor-visual-editor__content-area{padding-top:0 !important;margin-top:0 !important;}'; | |
| 840 | - if ( !isset( $settings['styles'] ) || !is_array( $settings['styles'] ) ) { | |
| 841 | - $settings['styles'] = array(); | |
| 842 | - } | |
| 843 | - $settings['styles'][] = array( | |
| 844 | - 'css' => $css, | |
| 845 | - ); | |
| 846 | - return $settings; | |
| 847 | - } | |
| 848 | - | |
| 849 | 172 | } |