Skip to content

Commit 5d0bdd0

Browse files
committed
add get menu and add get list menu
from @dmassiani - dphiffer#17
1 parent af9f622 commit 5d0bdd0

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

controllers/core.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,22 @@ public function get_page_index() {
264264
);
265265
}
266266

267+
public function get_menu() {
268+
global $json_api;
269+
$menu = $json_api->introspector->get_menu();
270+
return array(
271+
'menu' => $menu
272+
);
273+
}
274+
275+
public function get_list_menu() {
276+
global $json_api;
277+
$menu = $json_api->introspector->get_list_menu();
278+
return array(
279+
'menus' => $menu
280+
);
281+
}
282+
267283
public function get_nonce() {
268284
global $json_api;
269285
extract($json_api->query->get(array('controller', 'method')));

singletons/introspector.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,19 @@ public function get_categories($args = null) {
7979
return $categories;
8080
}
8181

82+
public function get_menu() {
83+
global $json_api;
84+
extract($json_api->query->get(array('name')));
85+
$items = wp_get_nav_menu_items($name);
86+
return $items;
87+
}
88+
89+
public function get_list_menu() {
90+
global $json_api;
91+
$menus = get_terms('nav_menu');
92+
return $menus;
93+
}
94+
8295
public function get_current_post() {
8396
global $json_api;
8497
extract($json_api->query->get(array('id', 'slug', 'post_id', 'post_slug')));

0 commit comments

Comments
 (0)