/** * Enqueue scripts & styles for Appearance > Menus page * * @since Menu Icons 0.3.0 * @wp_hook action admin_enqueue_scripts */ public static function _enqueue_assets() { $url = Buddyboss_Menu_Icons::get( 'url' ); $suffix = function_exists('kucrut_get_script_suffix') ? kucrut_get_script_suffix() : ''; // ✅ Parche: si no se pudo obtener la instancia del plugin, salimos if ( empty( $url ) ) { return; } if ( defined( 'MENU_ICONS_SCRIPT_DEBUG' ) && MENU_ICONS_SCRIPT_DEBUG ) { $script_url = '//localhost:8081/'; } else { $script_url = $url; } wp_enqueue_style( 'menu-icons', "{$url}css/admin{$suffix}.css", false, Buddyboss_Menu_Icons::VERSION ); wp_enqueue_script( 'menu-icons', "{$script_url}js/admin{$suffix}.js", self::$script_deps, Buddyboss_Menu_Icons::VERSION, true ); // ✅ Extra: comprobamos que funciones básicas existen antes de continuar if ( ! function_exists('admin_url') || ! function_exists('wp_get_theme') ) { return; } $customizer_url = add_query_arg( array( 'autofocus[section]' => 'custom_css', 'return' => admin_url( 'nav-menus.php' ), ), admin_url( 'customize.php' ) ); // --- resto del código original --- $menu_current_theme = ''; $theme = wp_get_theme(); if ( ! empty( $theme ) ) { if ( is_child_theme() ) { $menu_current_theme = $theme->parent()->get( 'Name' ); } else { $menu_current_theme = $theme->get( 'Name' ); } } $active_types = self::get( 'global', 'icon_types' ); if ( is_array( $active_types ) && ! in_array( 'image', $active_types, true ) ) { $active_types[] = 'image'; } if ( is_array( $active_types ) && ! in_array( 'manage', $active_types, true ) ) { $active_types[] = 'manage'; } $menu_id = self::get_current_menu_id(); $locations = get_nav_menu_locations(); $is_header_menu = false; $header_menus = array(); $menu_style = function_exists('buddyboss_menu_icons') ? buddyboss_menu_icons()->get_menu_style() : ''; $menu_style_link = esc_url( admin_url( 'admin.php?page=buddyboss_theme_options&tab=23' ) ); if ( isset( $locations['header-menu'] ) ) { $header_menus[] = $locations['header-menu']; } if ( isset( $locations['header-menu-logout'] ) ) { $header_menus[] = $locations['header-menu-logout']; } if ( in_array( $menu_id, $header_menus, true ) ) { $is_header_menu = true; } $js_data = apply_filters( 'menu_icons_settings_js_data', array( 'text' => array( 'title' => esc_html__( 'Select Icon', 'buddyboss-theme' ), 'select' => esc_html__( 'Select', 'buddyboss-theme' ), 'remove' => esc_html__( 'Remove', 'buddyboss-theme' ), 'change' => esc_html__( 'Change', 'buddyboss-theme' ), 'all' => esc_html__( 'All', 'buddyboss-theme' ), 'preview' => esc_html__( 'Preview', 'buddyboss-theme' ), 'settings' => esc_html__( 'Icon Settings', 'buddyboss-theme' ), 'header_menu' => esc_html__( 'Header Menu', 'buddyboss-theme' ), 'instruction' => esc_html__( 'Select an icon to configure its appearance.', 'buddyboss-theme' ), 'settings_tip' => sprintf( '%s %s', esc_html__( 'Tip:', 'buddyboss-theme' ), esc_html__( 'If you select lined, the icon will be dynamically changed to filled when the menu item is active.', 'buddyboss-theme' ) ), 'tab_style_info' => sprintf( __( 'Menu labels are hidden in your header menu as you\'ve set your %s to Tab Bar Menu.', 'buddyboss-theme' ), sprintf( '%2$s', esc_url( $menu_style_link ), esc_html__( 'Menu Style', 'buddyboss-theme' ) ) ), ), 'is_header_menu' => $is_header_menu, 'menu_style' => $menu_style, 'settingsFields' => self::get_settings_fields(), 'activeTypes' => $active_types, 'ajaxUrls' => array( 'update' => add_query_arg( 'action', 'menu_icons_update_settings', admin_url( '/admin-ajax.php' ) ), ), 'menuSettings' => self::get_menu_settings( self::get_current_menu_id() ), ) ); // ✅ Seguridad: solo pasar datos si es array if ( is_array( $js_data ) ) { wp_localize_script( 'menu-icons', 'menuIcons', $js_data ); } }