|
@@ -258,3 +258,88 @@ function uiu_acf_update_user_id($value, $post_id, $field)
|
|
}
|
|
}
|
|
|
|
|
|
add_filter('acf/update_value/name=employeeid', 'uiu_acf_update_user_id', 10, 3);
|
|
add_filter('acf/update_value/name=employeeid', 'uiu_acf_update_user_id', 10, 3);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Custom Walker class to add extra element to sub-menu ul.
|
|
|
|
+ */
|
|
|
|
+class Custom_Walker_Nav_Menu extends Walker_Nav_Menu
|
|
|
|
+{
|
|
|
|
+
|
|
|
|
+ public function start_lvl(&$output, $depth = 0, $args = array())
|
|
|
|
+ {
|
|
|
|
+ // Add your extra element here.
|
|
|
|
+ $output .= '<div class="container">';
|
|
|
|
+
|
|
|
|
+ parent::start_lvl($output, $depth, $args);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function end_lvl(&$output, $depth = 0, $args = array())
|
|
|
|
+ {
|
|
|
|
+ parent::end_lvl($output, $depth, $args);
|
|
|
|
+
|
|
|
|
+ // Add your extra element here.
|
|
|
|
+ $output .= '</div>';
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function custom_menu_walker($args)
|
|
|
|
+{
|
|
|
|
+ return array_merge($args, array(
|
|
|
|
+ 'walker' => new Custom_Walker_Nav_Menu(),
|
|
|
|
+ ));
|
|
|
|
+}
|
|
|
|
+add_filter('wp_nav_menu_args', 'custom_menu_walker');
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Insert_extra_element_to_submenu
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+function insert_extra_element_to_submenu($matches)
|
|
|
|
+{
|
|
|
|
+ $sub_menu_ul = $matches[0];
|
|
|
|
+ $extra_element = '<div class="extra-item col-breaker">
|
|
|
|
+ <img src="../wp-content/themes/uiu-cse/img/menu-background.jpg" alt="">
|
|
|
|
+ <div class="heading-text">
|
|
|
|
+ Research
|
|
|
|
+ </div>
|
|
|
|
+ <div class="text">
|
|
|
|
+ We collect personal information from you so we can provide investment services to you.
|
|
|
|
+ </div>
|
|
|
|
+ </div>';
|
|
|
|
+ $sub_menu_ul .= $extra_element;
|
|
|
|
+ return $sub_menu_ul;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+function custom_add_extra_element_to_submenu($nav_menu, $args)
|
|
|
|
+{
|
|
|
|
+ // Find all sub-menu ul elements and add the extra element after each one.
|
|
|
|
+ $nav_menu = preg_replace_callback('/(<ul\s*class="sub-menu[^"]*">)/', 'insert_extra_element_to_submenu', $nav_menu);
|
|
|
|
+
|
|
|
|
+ return $nav_menu;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+add_filter('wp_nav_menu', 'custom_add_extra_element_to_submenu', 10, 2);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Make theme option page field value available via REST API
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+function theme_options_route_menu()
|
|
|
|
+{
|
|
|
|
+ return get_field('menu_rich_content', 'option');
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+add_action("rest_api_init", function () {
|
|
|
|
+ register_rest_route("options", "/menu", [
|
|
|
|
+ "methods" => "GET",
|
|
|
|
+ "callback" => "theme_options_route_menu",
|
|
|
|
+ ]);
|
|
|
|
+});
|
|
|
|
+
|
|
|
|
+add_action('rest_api_init', function () {
|
|
|
|
+ header("Access-Control-Allow-Origin: *");
|
|
|
|
+});
|