Forráskód Böngészése

Page option field avaible in API

Md Mozahidur Rahman 1 éve
szülő
commit
c67493dffa
4 módosított fájl, 223 hozzáadás és 3 törlés
  1. 0 2
      footer.php
  2. 85 0
      functions.php
  3. 1 1
      header.php
  4. 137 0
      inc/acf-json/group_648ad0b0ca222.json

+ 0 - 2
footer.php

@@ -204,9 +204,7 @@
 	</div>
 </div>
 
-
 <?php wp_footer(); ?>
-
 </body>
 
 </html>

+ 85 - 0
functions.php

@@ -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);
+
+
+/**
+ * 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: *");
+});

+ 1 - 1
header.php

@@ -579,7 +579,7 @@
 
 		</header>
 
-		<?php //wp_nav_menu(array('theme_location' => 'uiu-header-menu', 'container_class' => 'custom-menu-class'));
+		<?php wp_nav_menu(array('theme_location' => 'uiu-header-menu', 'container_class' => 'custom-menu-class'));
 		?>
 
 

+ 137 - 0
inc/acf-json/group_648ad0b0ca222.json

@@ -0,0 +1,137 @@
+{
+    "key": "group_648ad0b0ca222",
+    "title": "Menu Options",
+    "fields": [
+        {
+            "key": "field_648ad18328484",
+            "label": "Menu Rich content",
+            "name": "menu_rich_content",
+            "aria-label": "",
+            "type": "repeater",
+            "instructions": "",
+            "required": 0,
+            "conditional_logic": 0,
+            "wrapper": {
+                "width": "",
+                "class": "",
+                "id": ""
+            },
+            "min": 0,
+            "max": 0,
+            "rows_per_page": 20,
+            "layout": "table",
+            "button_label": "Add Row",
+            "collapsed": "",
+            "sub_fields": [
+                {
+                    "key": "field_648ad0b1a815d",
+                    "label": "Menu Parent Class",
+                    "name": "menu_parent_class",
+                    "aria-label": "",
+                    "type": "text",
+                    "instructions": "",
+                    "required": 0,
+                    "conditional_logic": 0,
+                    "wrapper": {
+                        "width": "",
+                        "class": "",
+                        "id": ""
+                    },
+                    "default_value": "",
+                    "maxlength": "",
+                    "placeholder": "",
+                    "prepend": "",
+                    "append": "",
+                    "parent_repeater": "field_648ad18328484"
+                },
+                {
+                    "key": "field_648ad0f5337c0",
+                    "label": "Menu Feature Image",
+                    "name": "menu_feature_image",
+                    "aria-label": "",
+                    "type": "image",
+                    "instructions": "",
+                    "required": 0,
+                    "conditional_logic": 0,
+                    "wrapper": {
+                        "width": "",
+                        "class": "",
+                        "id": ""
+                    },
+                    "return_format": "url",
+                    "library": "all",
+                    "min_width": "",
+                    "min_height": "",
+                    "min_size": "",
+                    "max_width": "",
+                    "max_height": "",
+                    "max_size": "",
+                    "mime_types": "",
+                    "preview_size": "medium",
+                    "parent_repeater": "field_648ad18328484"
+                },
+                {
+                    "key": "field_648ad60cca7dc",
+                    "label": "Menu Title",
+                    "name": "menu_title",
+                    "aria-label": "",
+                    "type": "text",
+                    "instructions": "",
+                    "required": 0,
+                    "conditional_logic": 0,
+                    "wrapper": {
+                        "width": "",
+                        "class": "",
+                        "id": ""
+                    },
+                    "default_value": "",
+                    "maxlength": "",
+                    "placeholder": "",
+                    "prepend": "",
+                    "append": "",
+                    "parent_repeater": "field_648ad18328484"
+                },
+                {
+                    "key": "field_648ad13b337c1",
+                    "label": "Menu Description",
+                    "name": "menu_description",
+                    "aria-label": "",
+                    "type": "wysiwyg",
+                    "instructions": "",
+                    "required": 0,
+                    "conditional_logic": 0,
+                    "wrapper": {
+                        "width": "",
+                        "class": "",
+                        "id": ""
+                    },
+                    "tabs": "all",
+                    "toolbar": "full",
+                    "media_upload": 1,
+                    "default_value": "",
+                    "delay": 0,
+                    "parent_repeater": "field_648ad18328484"
+                }
+            ]
+        }
+    ],
+    "location": [
+        [
+            {
+                "param": "options_page",
+                "operator": "==",
+                "value": "uiu-cse-general-settings"
+            }
+        ]
+    ],
+    "menu_order": 0,
+    "position": "normal",
+    "style": "default",
+    "label_placement": "top",
+    "instruction_placement": "label",
+    "hide_on_screen": "",
+    "active": true,
+    "description": "",
+    "show_in_rest": 1,
+    "modified": 1686822076
+}