settings->get( 'disable_megamenu' ) ) { add_filter( 'avada_menu_options', [ $this, 'add_megamenu_fields' ], 20 ); } // Add the menu arrow highlights. add_filter( 'avada_menu_arrow_hightlight', [ $this, 'add_menu_arrow_highlight' ], 10, 2 ); // Add special menu items meta box. add_action( 'admin_head-nav-menus.php', [ $this, 'add_special_links_meta_box' ] ); // AutoComplete field ajax. add_action( 'wp_ajax_avada_mega_menu_autocomplete', [ $this, 'get_autocomplete' ] ); } /** * Register megamenu javascript assets. * * @since 3.4 * @access public * @param string $hook The hook we're currently on. * @return void */ public function register_scripts( $hook ) { if ( 'nav-menus.php' === $hook ) { // Scripts. wp_enqueue_media(); wp_register_script( 'avada-megamenu', Avada::$template_dir_url . '/assets/admin/js/mega-menu.js', [], self::$theme_info->get( 'Version' ), false ); wp_enqueue_script( 'avada-megamenu' ); wp_localize_script( 'avada-megamenu', 'AvadaMegaMenuVars', [ 'nonce' => wp_create_nonce( 'avada_mega_menu_nonce' ), 'text_loading' => __( 'Loading...', 'Avada' ), ] ); } } /** * Enqueue megamenu stylesheets * * @since 3.4 * @access public * @param string $hook The hook we're currently on. * @return void */ public function register_stylesheets( $hook ) { if ( 'nav-menus.php' === $hook ) { wp_enqueue_style( 'avada-megamenu', Avada::$template_dir_url . '/assets/admin/css/mega-menu.css', false, self::$theme_info->get( 'Version' ) ); } } /** * Adds the menu button fields. * * @static * @access public * @since 6.0.0 * @return array. */ public static function menu_options_map() { $choices = [ '0' => esc_attr__( 'None', 'Avada' ), ]; $mega_menus = get_posts( [ 'post_type' => 'fusion_element', 'posts_per_page' => '-1', // phpcs:ignore WPThemeReview.CoreFunctionality.PostsPerPage.posts_per_page_posts_per_page 'tax_query' => [ // phpcs:ignore WordPress.DB.SlowDBQuery [ 'taxonomy' => 'element_category', 'field' => 'slug', 'terms' => 'mega_menus', ], ], ] ); if ( $mega_menus ) { foreach ( $mega_menus as $mega_menu ) { $choices[ $mega_menu->ID ] = $mega_menu->post_title; } } $label = esc_html__( 'Flyout Menu Background Image', 'Avada' ); $desc = __( 'Select an image for the flyout menu background. The image will be shown full screen when hovering the corresponding menu item.', 'Avada' ); if ( Avada()->settings->get( 'disable_megamenu' ) ) { $label = esc_html__( 'Legacy Mega Menu / Flyout Menu Background Image', 'Avada' ); $desc = __( 'Select an image for the legacy mega menu or flyout menu background.
Legacy Mega Menu: In case of legacy mega menu, if left empty, the Main Menu Dropdown Background Color will be used. Each mega menu column can have its own background image, or you can have one image that spreads across the entire mega menu width.
Flyout Menu: When used in the flyout menu, the image will be shown full screen when hovering the corresponding menu item.', 'Avada' ); } return [ 'megamenu-select' => [ 'id' => 'megamenu-select', 'label' => esc_attr__( 'Mega Menu', 'Avada' ), 'choices' => $choices, /* translators: %s: URL. */ 'description' => sprintf( __( 'Select a pre-created mega menu item from the Avada Library, that should be displayed. To create a new mega menu, visit the Avada Library. Mega menus are disabled on menus in mobile mode and are replaced by sub-menu items that have been added to a parent mega menu item.', 'Avada' ), admin_url( 'admin.php?page=avada-library' ) ), 'type' => 'select', 'default' => '0', 'save_id' => 'fusion_megamenu_select', ], 'megamenu-style' => [ 'id' => 'megamenu-style', 'label' => esc_attr__( 'Menu Button', 'Avada' ), 'choices' => [ '' => esc_attr__( 'Default Style', 'Avada' ), 'fusion-button-small' => esc_attr__( 'Button Small', 'Avada' ), 'fusion-button-medium' => esc_attr__( 'Button Medium', 'Avada' ), 'fusion-button-large' => esc_attr__( 'Button Large', 'Avada' ), 'fusion-button-xlarge' => esc_attr__( 'Button xLarge', 'Avada' ), ], 'description' => esc_attr__( 'Select to use normal text (default) for the parent level menu item, or a button. Button styles are controlled in Global Options > Avada Builder Elements.', 'Avada' ), 'type' => 'select', 'default' => '', 'save_id' => 'fusion_menu_style', ], 'megamenu-icon' => [ 'id' => 'megamenu-icon', 'label' => esc_attr__( 'Icon Select', 'Avada' ), 'description' => esc_attr__( 'Select an icon for your menu item. For top-level menu items, icon styles can be controlled in the Menu element.', 'Avada' ), 'type' => 'iconpicker', 'default' => '', ], 'megamenu-thumbnail' => [ 'id' => 'megamenu-thumbnail', 'label' => esc_html__( 'Image Thumbnail', 'Avada' ), 'description' => esc_html__( 'Select an image to use as a thumbnail for the menu item. For top-level items, the size of the thumbnail can be controlled in the Menu element.', 'Avada' ), 'type' => 'media', ], 'megamenu-icononly' => [ 'id' => 'megamenu-icononly', 'label' => esc_attr__( 'Icon/Thumbnail Only', 'Avada' ), 'description' => esc_attr__( 'Turn on to only show the icon/image thumbnail while hiding the menu text. Important: this does not apply to the mobile menu.', 'Avada' ), 'type' => 'radio-buttonset', 'default' => 'off', 'choices' => [ 'icononly' => esc_attr__( 'On', 'Avada' ), 'off' => esc_attr__( 'Off', 'Avada' ), ], 'save_id' => 'fusion_menu_icononly', ], 'megamenu-highlight-label' => [ 'id' => 'megamenu-highlight-label', 'label' => esc_attr__( 'Menu Highlight Label', 'Avada' ), 'description' => esc_attr__( 'Set the highlight label for menu item.', 'Avada' ), 'type' => 'text', 'save_id' => 'fusion_highlight_label', ], 'megamenu-highlight-label-background' => [ 'id' => 'megamenu-highlight-label-background', /* translators: "" tags. */ 'label' => sprintf( esc_html__( '%1$sMenu Highlight Label Background Color%2$s%3$sCart Counter Background Color%4$s', 'Avada' ), '', '', '', '' ), /* translators: %1$s: tag. %2$s: "TGlobal Options" link. %3$s: tag. %4$s: tag. %5$s: tag. */ 'description' => sprintf( esc_html__( '%1$sSet the highlight label background color. To set a border radius, visit %2$s and modify the Menu Highlight Label Radius option.%3$s%4$s Set cart counter background color.%5$s', 'Avada' ), '', '' . esc_html__( 'Global Options', 'Avada' ) . '', '', '', '' ), 'type' => 'color-alpha', 'save_id' => 'fusion_highlight_label_background', 'dependency' => [ [ 'field' => 'megamenu-highlight-label', 'value' => '', 'comparison' => '!=', ], ], ], 'megamenu-highlight-label-color' => [ 'id' => 'megamenu-highlight-label-color', /* translators: "" tags. */ 'label' => sprintf( esc_html__( '%1$sMenu Highlight Label Text Color%2$s%3$sCart Counter Text Color%4$s', 'Avada' ), '', '', '', '' ), /* translators: "" tags. */ 'description' => sprintf( esc_html__( '%1$sSet the highlight label text color.%2$s%3$sSet the cart counter text color.%4$s', 'Avada' ), '', '', '', '' ), 'type' => 'color', 'save_id' => 'fusion_highlight_label_color', 'dependency' => [ [ 'field' => 'megamenu-highlight-label', 'value' => '', 'comparison' => '!=', ], ], ], 'megamenu-highlight-label-border-color' => [ 'id' => 'megamenu-highlight-label-border-color', /* translators: "" tags. */ 'label' => sprintf( esc_html__( '%1$sMenu Highlight Label Border Color%2$s%3$sCart Counter Border Color %4$s', 'Avada' ), '', '', '', '' ), /* translators: "" tags. */ 'description' => sprintf( esc_html__( '%1$sSet the highlight label border color.%2$s%3$sSet the cart counter border color.%4$s', 'Avada' ), '', '', '', '' ), 'type' => 'color', 'save_id' => 'fusion_highlight_label_border_color', 'dependency' => [ [ 'field' => 'megamenu-highlight-label', 'value' => '', 'comparison' => '!=', ], ], ], 'megamenu-modal' => [ 'id' => 'megamenu-modal', 'label' => esc_attr__( 'Modal Window Anchor', 'Avada' ), 'description' => esc_attr__( 'Add the class name of the modal window you want to open on menu item click.', 'Avada' ), 'type' => 'text', ], 'megamenu-background-image' => [ 'id' => 'megamenu-background-image', 'label' => $label, 'description' => $desc, 'type' => 'media', 'dependency' => [ [ 'field' => 'depth', 'value' => '3', 'comparison' => '<', ], ], ], ]; } /** * Adds Avada special menu items meta box. * * @since 7.0 * @access public * @return void */ public function add_special_links_meta_box() { add_meta_box( 'avada_special_items_nav_link', __( 'Avada Special Menu Items', 'Avada' ), [ $this, 'special_menut_items' ], 'nav-menus', 'side', 'low' ); } /** * Outputs contents of Avada special menu items meta box. * * @since 7.0 * @access public * @return void */ public function special_menut_items() { ?>
IMPORTANT NOTE: These items only work in Avada Builder Menu element.', 'Avada' ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
    esc_html__( 'Search', 'Avada' ), '#awb-user-logout' => esc_html__( 'Log Out', 'Avada' ), '#fusion-sliding-bar-toggle' => esc_html__( 'Sliding Bar Toggle', 'Avada' ), '#awb-off-canvas-menu-trigger' => esc_html__( 'Off Canvas Toggle', 'Avada' ), ]; if ( class_exists( 'WooCommerce' ) ) { $endpoints['#fusion-woo-cart'] = esc_html__( 'WooCommerce Cart', 'Avada' ); $endpoints['#fusion-woo-my-account'] = esc_html__( 'WooCommerce My Account', 'Avada' ); } $i = -1; foreach ( $endpoints as $key => $value ) : ?>

__( 'Select Off Canvas', 'Avada' ) ]; $off_canvas_available_items = []; if ( property_exists( wp_count_posts( 'awb_off_canvas' ), 'publish' ) && 25 > wp_count_posts( 'awb_off_canvas' )->publish ) { $off_canvas_field_type = 'select'; $off_canvas_available_items = class_exists( 'AWB_Off_Canvas_Front_End' ) ? AWB_Off_Canvas_Front_End()->get_available_items() : []; } $custom_fields = [ 'fusion-megamenu-special-link-note' => [ 'id' => 'fusion-megamenu-special-link-note', 'label' => esc_attr__( 'Important Note', 'Avada' ), 'description' => esc_attr__( 'Avada Special Menu Items can only be used as top-level items. Please move the item to top-level to see the available options.', 'Avada' ), 'type' => 'note', 'save_id' => 'fusion_special_link_note', 'dependency' => [ [ 'field' => 'depth', 'value' => '1', 'comparison' => '>', ], ], ], 'fusion-megamenu-special-link' => [ 'id' => 'fusion-megamenu-special-link', 'label' => esc_attr__( 'Special Link Type', 'Avada' ), 'description' => esc_attr__( 'Select to add a special link type.', 'Avada' ), 'type' => 'hidden', 'value' => 0 === $depth ? ltrim( $item_url, '#' ) : '', 'save_id' => 'fusion_special_link', ], 'megamenu-show-woo-cart-counter' => [ 'id' => 'megamenu-show-woo-cart-counter', 'label' => esc_attr__( 'Show WooCommerce Cart Counter', 'Avada' ), 'description' => esc_attr__( 'Turn on to show the cart products counter.', 'Avada' ), 'type' => 'radio-buttonset', 'default' => 'no', 'choices' => [ 'yes' => esc_attr__( 'On', 'Avada' ), 'no' => esc_attr__( 'Off', 'Avada' ), ], 'save_id' => 'fusion_show_woo_cart_counter', 'dependency' => [ [ 'field' => 'fusion-megamenu-special-link', 'value' => 'fusion-woo-cart', 'comparison' => '==', ], ], ], 'megamenu-cart-counter-display' => [ 'id' => 'megamenu-cart-counter-display', 'label' => esc_html__( 'Cart Counter Display', 'Avada' ), 'description' => esc_html__( 'Select the display style you would like for the cart counter. Badge display will be smaller and positioned on the top corner of the menu item. Note: badge styling will only be used in the menu element.', 'Avada' ), 'save_id' => 'fusion_cart_counter_display', 'type' => 'radio-buttonset', 'default' => 'inline', 'choices' => [ 'inline' => esc_attr__( 'Inline', 'Avada' ), 'badge' => esc_attr__( 'Badge', 'Avada' ), ], 'dependency' => [ [ 'field' => 'fusion-megamenu-special-link', 'value' => 'fusion-woo-cart', 'comparison' => '==', ], [ 'field' => 'megamenu-show-woo-cart-counter', 'value' => 'yes', 'comparison' => '==', ], ], ], 'megamenu-show-empty-woo-cart-counter' => [ 'id' => 'megamenu-show-empty-woo-cart-counter', 'label' => esc_attr__( 'Show WooCommerce Empty Cart Counter', 'Avada' ), 'description' => esc_attr__( 'Turn on to show the cart counter when cart is empty.', 'Avada' ), 'type' => 'radio-buttonset', 'default' => 'yes', 'choices' => [ 'yes' => esc_attr__( 'On', 'Avada' ), 'no' => esc_attr__( 'Off', 'Avada' ), ], 'save_id' => 'fusion_show_empty_woo_cart_counter', 'dependency' => [ [ 'field' => 'fusion-megamenu-special-link', 'value' => 'fusion-woo-cart', 'comparison' => '==', ], [ 'field' => 'megamenu-show-woo-cart-counter', 'value' => 'yes', 'comparison' => '==', ], ], ], 'megamenu-show-woo-cart-contents' => [ 'id' => 'megamenu-show-woo-cart-contents', 'label' => esc_attr__( 'Show WooCommerce Cart Contents Dropdown', 'Avada' ), 'description' => esc_attr__( 'Turn on to show the cart contents dropdown.', 'Avada' ), 'type' => 'radio-buttonset', 'default' => 'no', 'choices' => [ 'yes' => esc_attr__( 'On', 'Avada' ), 'no' => esc_attr__( 'Off', 'Avada' ), ], 'save_id' => 'fusion_show_woo_cart_contents', 'dependency' => [ [ 'field' => 'fusion-megamenu-special-link', 'value' => 'fusion-woo-cart', 'comparison' => '==', ], ], ], 'megamenu-searchform-mode' => [ 'id' => 'megamenu-searchform-mode', 'label' => esc_html__( 'Search-Form Mode', 'Avada' ), 'description' => esc_html__( 'Select how your search-form will be displayed.', 'Avada' ), 'type' => 'radio-buttonset', 'default' => 'inline', 'choices' => [ 'inline' => esc_html__( 'Inline', 'Avada' ), 'dropdown' => esc_html__( 'Dropdown', 'Avada' ), 'overlay' => esc_html__( 'Overlay', 'Avada' ), ], 'save_id' => 'fusion_searchform_mode', 'dependency' => [ [ 'field' => 'fusion-megamenu-special-link', 'value' => 'fusion-search', 'comparison' => '==', ], ], ], 'megamenu-off-canvas-id' => [ 'id' => 'megamenu-off-canvas-id', 'label' => esc_html__( 'Off Canvas', 'Avada' ), 'description' => esc_html__( 'Select off canvas to show when click on menu item.', 'Avada' ), 'type' => $off_canvas_field_type, 'choices' => $off_canvas_items + $off_canvas_available_items, 'post_type' => 'awb_off_canvas', 'save_id' => 'fusion_off_canvas_id', 'dependency' => [ [ 'field' => 'fusion-megamenu-special-link', 'value' => 'awb-off-canvas-menu-trigger', 'comparison' => '==', ], ], ], ]; return array_merge( $custom_fields, $fields ); } /** * Adds the megamenu fields. * * @access public * @since 6.0.0 * @param array $fields Current fields map. * @return array. */ public function add_megamenu_fields( $fields ) { global $wp_registered_sidebars; $sidebars = [ '0' => esc_attr__( 'Select Widget Area', 'Avada' ), ]; if ( ! empty( $wp_registered_sidebars ) && is_array( $wp_registered_sidebars ) ) { foreach ( $wp_registered_sidebars as $sidebar ) { $sidebars[ esc_attr( $sidebar['id'] ) ] = esc_attr( $sidebar['name'] ); } } $mega_fields = [ 'megamenu-status' => [ 'id' => 'megamenu-status', 'label' => esc_html__( 'Legacy Mega Menu', 'Avada' ), 'choices' => [ 'enabled' => esc_attr__( 'On', 'Avada' ), 'off' => esc_attr__( 'Off', 'Avada' ), ], 'description' => esc_html__( 'Turn on to enable the legacy mega menu. Note this will only work for the main menu.', 'Avada' ), 'type' => 'radio-buttonset', 'default' => 'off', 'dependency' => [ [ 'field' => 'depth', 'value' => '1', 'comparison' => '==', ], ], ], 'megamenu-width' => [ 'id' => 'megamenu-width', 'label' => esc_attr__( 'Legacy Mega Menu Wrapper Width', 'Avada' ), 'choices' => [ 'fullwidth' => esc_attr__( 'Max Width', 'Avada' ), 'off' => esc_attr__( 'Fit Content', 'Avada' ), ], /* translators: %s: "Global Options" link. */ 'description' => sprintf( esc_attr__( 'Controls the width of legacy mega menu. In case of max width, it is taken from the site width option in %s. Note this overrides the column width option.', 'Avada' ), '' . esc_html__( 'Global Options', 'Avada' ) . '' ), 'type' => 'radio-buttonset', 'default' => 'off', 'dependency' => [ [ 'field' => 'depth', 'value' => '1', 'comparison' => '==', ], [ 'field' => 'megamenu-status', 'value' => 'enabled', 'comparison' => '==', ], ], ], 'megamenu-columns' => [ 'id' => 'megamenu-columns', 'label' => esc_attr__( 'Legacy Mega Menu Number of Columns', 'Avada' ), 'choices' => [ 'auto' => esc_attr__( 'Auto', 'Avada' ), '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', ], 'description' => esc_attr__( 'Select the number of columns you want to use.', 'Avada' ), 'type' => 'select', 'default' => 'auto', 'dependency' => [ [ 'field' => 'depth', 'value' => '1', 'comparison' => '==', ], [ 'field' => 'megamenu-status', 'value' => 'enabled', 'comparison' => '==', ], ], ], 'megamenu-columnwidth' => [ 'id' => 'megamenu-columnwidth', 'label' => esc_attr__( 'Legacy Mega Menu Column Width', 'Avada' ), 'description' => esc_attr__( 'Set the width of the column. In percentage, ex 60%.', 'Avada' ), 'type' => 'text', 'dependency' => [ [ 'field' => 'depth', 'value' => '2', 'comparison' => '==', ], [ 'field' => 'parent_megamenu-status', 'value' => 'enabled', 'comparison' => '==', ], [ 'field' => 'parent_megamenu-width', 'value' => 'fullwidth', 'comparison' => '!=', ], ], ], 'megamenu-title' => [ 'id' => 'megamenu-title', 'label' => esc_attr__( 'Legacy Mega Menu Column Title', 'Avada' ), 'choices' => [ 'enabled' => esc_attr__( 'On', 'Avada' ), 'disabled' => esc_attr__( 'Off', 'Avada' ), ], 'description' => esc_attr__( 'Turn on to display item as linked column title. Turn off to display item as normal mega menu entry.', 'Avada' ), 'type' => 'radio-buttonset', 'default' => 'enabled', 'dependency' => [ [ 'field' => 'depth', 'value' => '2', 'comparison' => '==', ], [ 'field' => 'parent_megamenu-status', 'value' => 'enabled', 'comparison' => '==', ], ], ], 'megamenu-widgetarea' => [ 'id' => 'megamenu-widgetarea', 'label' => esc_attr__( 'Legacy Mega Menu Widget Area', 'Avada' ), 'choices' => $sidebars, 'description' => esc_attr__( 'Select a widget area to be used as the content for the column.', 'Avada' ), 'type' => 'select', 'default' => '0', 'dependency' => [ [ 'field' => 'depth', 'value' => '1', 'comparison' => '>', ], [ 'field' => 'depth', 'value' => '4', 'comparison' => '<', ], [ 'field' => 'parent_megamenu-status', 'value' => 'enabled', 'comparison' => '==', ], ], ], ]; return array_merge( $fields, $mega_fields ); } /** * Adds the markup for the options. * * @access public * @since 6.0.0 * @param string $item_id The ID of the menu item. * @param object $item The menu item object. * @param int $depth The menu item depth (starts at 0). * @return void. */ public function parse_options( $item_id, $item, $depth ) { $fields = self::menu_options_map(); $specials = [ '#fusion-woo-cart', '#fusion-woo-my-account', '#fusion-search', '#awb-user-logout', '#fusion-sliding-bar-toggle', '#awb-off-canvas-menu-trigger' ]; // Add special-links options. if ( isset( $item->object ) && 'custom' === $item->object && in_array( $item->url, $specials, true ) ) { $fields = self::special_link_options_map( $fields, $item->url, $depth ); // Do not show URL field for special links options. $this->hide_url_field( $item->ID ); } $fields = apply_filters( 'avada_menu_options', $fields ); if ( is_array( $fields ) ) { foreach ( $fields as $field ) { // Defaults. $field['id'] = isset( $field['id'] ) ? $field['id'] : ''; $field['label'] = isset( $field['label'] ) ? $field['label'] : ''; $field['choices'] = isset( $field['choices'] ) ? $field['choices'] : []; $field['description'] = isset( $field['description'] ) ? $field['description'] : ''; $field['default'] = isset( $field['default'] ) ? $field['default'] : ''; $field['dependency'] = isset( $field['dependency'] ) ? $field['dependency'] : []; $field['save_id'] = isset( $field['save_id'] ) ? $field['save_id'] : 'fusion_' . str_replace( '-', '_', $field['id'] ); if ( isset( $field['type'] ) ) { switch ( $field['type'] ) { case 'note': $this->note( $field['id'], $field['label'], $field['description'], $field['dependency'], $item_id, $item, $field['save_id'] ); break; case 'text': $this->text( $field['id'], $field['label'], $field['description'], $field['dependency'], $item_id, $item, $field['save_id'] ); break; case 'hidden': $this->hidden( $field['id'], $item_id, $item, $field['value'] ); break; case 'radio-buttonset': $this->radio_buttonset( $field['id'], $field['label'], $field['choices'], $field['description'], $field['default'], $field['dependency'], $item_id, $item, $field['save_id'] ); break; case 'select': $this->select( $field['id'], $field['label'], $field['choices'], $field['description'], $field['default'], $field['dependency'], $item_id, $item, $field['save_id'] ); break; case 'color-alpha': $this->color_alpha( $field['id'], $field['label'], $field['description'], $field['default'], $field['dependency'], $item_id, $item, $field['save_id'] ); break; case 'color': $this->color( $field['id'], $field['label'], $field['description'], $field['default'], $field['dependency'], $item_id, $item, $field['save_id'] ); break; case 'media': $this->media( $field['id'], $field['label'], $field['description'], $field['dependency'], $item_id, $item, $field['save_id'] ); break; case 'iconpicker': $this->iconpicker( $field['id'], $field['label'], $field['description'], $field['dependency'], $item_id, $item, $field['save_id'] ); break; case 'autocomplete': $post_type = isset( $field['post_type'] ) ? $field['post_type'] : ''; $this->autocomplete( $field['id'], $field['label'], $post_type, $field['description'], $field['default'], $field['dependency'], $item_id, $item, $field['save_id'] ); break; } } } } } /** * Note control. * * @access public * @since 7.1 * @param string $id The ID. * @param string $label The label. * @param string $desc The description. * @param array $dependency The dependencies array. * @param string $item_id The ID of the menu item. * @param object $item The menu item object. * @param string $save_id The save ID if it is different from ID. */ public function note( $id, $label, $desc = '', $dependency = [], $item_id = 0, $item = null, $save_id = '' ) { ?>
:

$label ) : ?> { $save_id } ) ? $item->{ $save_id } : $default; ?>

color_alpha( $id, $label, $desc, $default, $dependency, $item_id, $item, $save_id ); } /** * Media field. * * @access public * @since 6.0.0 * @param string $id ID of input field. * @param string $label Label of field. * @param string $desc Description of field. * @param array $dependency The dependencies array. * @param string $item_id The ID of the menu item. * @param object $item The menu item object. * @param string $save_id The save ID if it is different from ID. */ public function media( $id, $label, $desc = '', $dependency = [], $item_id = 0, $item = null, $save_id = '' ) { $media_id = str_replace( 'megamenu-', '', $id ); ?>

fusion_megamenu_thumbnail ) ? $item->fusion_megamenu_thumbnail_id : 0; if ( ! $thumbnail_id && isset( $item->fusion_megamenu_thumbnail ) && '' !== $item->fusion_megamenu_thumbnail ) { $thumbnail_id = Fusion_Images::get_attachment_id_from_url( $item->fusion_megamenu_thumbnail ); } ?>
fusion_megamenu_thumbnail ) ) ? 'style="display:inline;"' : ''; ?>" />
settings->get( 'menu_highlight_style' ); $header_layout = Avada()->settings->get( 'header_layout' ); $svg = ''; if ( 'arrow' === $menu_highlight_style && 'v6' !== $header_layout ) { $header_position = fusion_get_option( 'header_position' ); $svg_height = Fusion_Sanitize::size( Avada()->settings->get( 'menu_arrow_size', 'height' ) ); $svg_height_int = intval( $svg_height ); $svg_width = Fusion_Sanitize::size( Avada()->settings->get( 'menu_arrow_size', 'width' ) ); $svg_width_int = intval( $svg_width ); $svg_bg = 'fill="' . Fusion_Sanitize::color( fusion_get_option( 'header_bg_color' ) ) . '"'; $svg_border = ''; $header_2_3_border = ( 'v2' === $header_layout || 'v3' === $header_layout ); $header_4_5_border = ( ( 'v4' === $header_layout || 'v5' === $header_layout ) && 1 === Fusion_Color::new_color( Fusion_Sanitize::color( fusion_get_option( 'header_bg_color' ) ) )->alpha ); if ( 'top' !== $header_position || $header_2_3_border || $header_4_5_border ) { $svg_border = 'class="header_border_color_stroke" stroke-width="1"'; } if ( 'left' === $header_position ) { $svg = ' '; } elseif ( 'right' === $header_position ) { $svg = ' '; } elseif ( 'top' === $header_position ) { $svg = ' '; } // Add svg markup for dropdown. if ( $has_children ) { $svg_bg = 'fill="' . Fusion_Sanitize::color( Avada()->settings->get( 'menu_sub_bg_color' ) ) . '"'; if ( 'top' === $header_position ) { $dropdownsvg = ' '; } elseif ( 'left' === $header_position ) { $dropdownsvg = ' '; } elseif ( 'right' === $header_position ) { $dropdownsvg = ' '; } $svg = $svg . $dropdownsvg; } } return $title . $svg; } /** * Autocomplete controls. * * @access public * @since 7.6 * @param string $id The ID. * @param string $label The label. * @param string $post_type The post type. * @param string $desc The description. * @param string $default The default value. * @param array $dependency The dependencies array. * @param string $item_id The ID of the menu item. * @param object $item The menu item object. * @param string $save_id The save ID if it is different from ID. * @param string $placeholder Search text. */ public function autocomplete( $id, $label, $post_type = '', $desc = '', $default = '', $dependency = [], $item_id = 0, $item = null, $save_id = '', $placeholder = '' ) { $placeholder = $placeholder ? $placeholder : __( 'Search ...', 'Avada' ); $value = $item->{ $save_id }; $name = '' !== $value ? wp_strip_all_tags( get_the_title( $value ) ) : ''; $search_class = '' !== $value ? 'hidden' : ''; ?>

' . $name . '
'; // phpcs:ignore } ?>
$post_type, 'ignore_sticky_posts' => 1, 'posts_per_page' => -1, // phpcs:ignore WPThemeReview.CoreFunctionality.PostsPerPage.posts_per_page_posts_per_page 's' => $keyword, ]; $query = new WP_Query( $args ); if ( $query->have_posts() ) { echo '
'; while ( $query->have_posts() ) { $query->the_post(); ?> '; } else { echo esc_html__( 'Sorry, no posts matched your criteria.', 'Avada' ); } } $content = ob_get_clean(); $return_data = [ 'code' => 200, 'html' => $content, ]; echo wp_json_encode( $return_data ); wp_die(); } } } /* Omit closing PHP tag to avoid "Headers already sent" issues. */