highlights = apply_filters( 'themeoo_megamenu_highlight_types', [ 'info' => __( 'Info', 'ayyash' ), 'success' => __( 'Success', 'ayyash' ), 'warning' => __( 'Warning', 'ayyash' ), 'danger' => __( 'Danger', 'ayyash' ), ] ); $this->mega_width = [ 'natural' => __( 'Natural Width', 'ayyash' ), 'custom' => __( 'Custom Width', 'ayyash' ), ]; $this->column_width = apply_filters( 'themeoo_megamenu_column_classes', [ 'col-md-1' => __( '1 Col', 'ayyash' ), 'col-md-2' => __( '2 Col', 'ayyash' ), 'col-md-3' => __( '3 Col', 'ayyash' ), 'col-md-4' => __( '4 Col', 'ayyash' ), 'col-md-5' => __( '5 Col', 'ayyash' ), 'col-md-6' => __( '6 Col (half)', 'ayyash' ), 'col-md-7' => __( '7 Col', 'ayyash' ), 'col-md-8' => __( '8 Col', 'ayyash' ), 'col-md-9' => __( '9 Col', 'ayyash' ), 'col-md-10' => __( '10 Col', 'ayyash' ), 'col-md-11' => __( '11 Col', 'ayyash' ), 'col-md-12' => __( '12 Col (full-width)', 'ayyash' ), ] ); add_filter( 'wp_nav_menu_args', array( $this, 'wp_nav_menu_args' ), 99 ); add_filter( 'wp_edit_nav_menu_walker', array( $this, 'wp_edit_nav_menu_walker' ), 10 ); add_filter( 'wp_setup_nav_menu_item', array( $this, 'wp_setup_nav_menu_item' ), 10 ); add_action( 'wp_update_nav_menu_item', array( $this, 'wp_update_nav_menu_item' ), 10, 3 ); add_action( 'themeoo_mega_menu_fields', array( $this, 'themeoo_mega_menu_fields' ), 10, 2 ); add_action( 'themeoo_mega_menu_labels', array( $this, 'themeoo_mega_menu_labels' ) ); } /** * Menu Menu Fields. * * @param int $item_id item id. * @param object $item item. * * @return void */ public function themeoo_mega_menu_fields( $item_id, $item ) { $hidden = ( empty( $item->icon ) ) ? ' hidden' : ''; ?>

', esc_attr( $item->icon ), sprintf( /* translators: 1. Icon Name */ esc_attr__( 'Icon ā€œ%sā€œ', 'ayyash' ), esc_attr( ucfirst( str_replace( 'ti-', '', $item->icon ) ) ) ) ); ?>

' . esc_html__( 'Mega Menu', 'ayyash' ) . ''; $out .= '' . esc_html__( 'Column', 'ayyash' ) . ''; echo wp_kses_post( $out ); } /** * * Custom Menu Args * * @param array $args menu args. * * @return array */ public function wp_nav_menu_args( $args ) { $location = $args['theme_location']; if ( ( 'primary' == $location || 'right' == $location ) && ! isset( $args['mobile'] ) ) { $args['container'] = false; $args['menu_class'] = 'main-navigation sf-menu'; $args['walker'] = new Themeoo_Walker_Nav_Menu_Custom(); } elseif ( isset( $args['mobile'] ) || 'mobile' == $location ) { $args['after'] = ''; } return $args; } /** * * Custom Nav Menu Edit. * * @return string */ public function wp_edit_nav_menu_walker() { return 'Themeoo_Walker_Nav_Menu_Edit_Custom'; } /** * Save Custom Fields. * * @param object $item item. * * @return object */ public function wp_setup_nav_menu_item( $item ) { foreach ( $this->extra_fields as $key ) { $item->$key = isset( $item->ID ) ? get_post_meta( $item->ID, '_menu_item_' . $key, true ) : ''; } return $item; } /** * Update Custom Fields. * * @param int $menu_id Menu id. * @param int $db_id Menu item db id. * @param array $args Menu args. * * @return void */ public function wp_update_nav_menu_item( $menu_id, $db_id, $args ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed,Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed $req = wp_unslash( $_REQUEST ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended foreach ( $this->extra_fields as $key ) { $_key = 'menu-item-' . $key; $value = ( isset( $req[ $_key ][ $db_id ] ) ) ? sanitize_text_field( $req[ $_key ][ $db_id ] ) : ''; update_post_meta( $db_id, '_menu_item_' . $key, $value ); } } } new Themeoo_Megamenu_API();