Edit File: menu-options.php
<?php // Control core classes for avoid errors if (class_exists('CSF')) { // // Set a unique slug-like ID $prefix = 'orun_menu_options'; // // Create profile options CSF::createNavMenuOptions($prefix, array( 'data_type' => 'serialize', // The type of the database save options. `serialize` or `unserialize` )); // // Create a section CSF::createSection($prefix, array( 'fields' => array( array( 'id' => 'orun-menu-icon', 'type' => 'icon', 'title' => 'Menü Simgesi', ), array( 'id' => 'orun-mega-menu-switcher', 'type' => 'switcher', 'title' => __('Mega Menüyü Etkinleştir', 'orun'), 'default' => false, ), array( 'id' => 'orun-mega-menu-label-switcher', 'type' => 'switcher', 'title' => __('Menü Etiketini Etkinleştir', 'orun'), 'default' => false, ), array( 'id' => 'orun-mega-menu-label-text', 'type' => 'text', 'title' => __('Menü Etiketini Yazısı', 'orun'), 'default' => false, ), array( 'id' => 'orun-mega-menu-label-bg-color', 'type' => 'color', 'title' => __('Menü Etiketini Arkaplan Rengi', 'orun'), 'default' => false, ), array( 'id' => 'orun-mega-menu-label-text-color', 'type' => 'color', // Use 'color' type for text color 'title' => __('Menü Etiketini Yazı Rengi', 'orun'), 'default' => false, ), ) )); } if (!class_exists('orun_Walker_Menu_Icon')) { class orun_Walker_Menu_Icon extends Walker_Nav_Menu { public function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { $meta = $item->orun_menu_options; if (!empty($meta['orun-menu-icon'])) { $item->title = '<i class="' . $meta['orun-menu-icon'] . '"></i>' . $item->title; } parent::start_el($output, $item, $depth, $args, $id); } } } function orun_mega_menu_output($item_output, $item, $depth, $args) { $meta = get_post_meta($item->ID, 'orun_menu_options', true); $location = $args->theme_location; ob_start(); if (isset($meta['orun-mega-menu-label-switcher']) && $meta['orun-mega-menu-label-switcher'] == true && !empty($meta['orun-mega-menu-label-text'])) { $item_output = str_replace('</a>', '<span class="orun-mega-menu-label" style="background-color: ' . esc_attr($meta['orun-mega-menu-label-bg-color']) . '; color: ' . esc_attr($meta['orun-mega-menu-label-text-color']) . ';">' . esc_html($meta['orun-mega-menu-label-text']) . '</span></a>', $item_output); } if ($location == 'main-navbar-menu' && $meta['orun-mega-menu-switcher'] == true) { if (have_posts()) { $megamenupost_args = array( 'posts_per_page' => 5, 'cat' => $item->object_id, ); ?> <div class="orun-mega-menu-wrapper"> <div class="orun-mega-menu"> <?php $megamenupost = new WP_Query($megamenupost_args); while ($megamenupost->have_posts()): $megamenupost->the_post(); get_template_part('template-parts/header/mega', 'menu'); endwhile; ?> </div> </div> <?php } wp_reset_postdata(); ?> <?php } $custom_sub_menu_html = ob_get_clean(); $item_output .= $custom_sub_menu_html; return $item_output; } add_filter('walker_nav_menu_start_el', 'orun_mega_menu_output', 10, 4); function orun_mega_menu_classes($classes, $item, $args) { $meta = get_post_meta($item->ID, 'orun_menu_options', true); if ($args->theme_location == 'main-navbar-menu' && $meta['orun-mega-menu-switcher'] == true) { $classes[] = 'menu-has-orun-mega-menu'; } return $classes; } add_action('nav_menu_css_class', 'orun_mega_menu_classes', 10, 3);