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