public function get_menu() { global $json_api; $wp_menus = new WP_REST_Menus(); $name = $json_api->query->name; return $wp_menus->get_menu($name); }
/** * Gets global posts data from the JSON API server * * @param null $posts * * @return array */ public function get_menu_data($posts = null) { $menu = array(); $request = new \WP_REST_Request(); $request['context'] = 'view'; $request['location'] = 'primary'; if (class_exists('WP_REST_Menus')) { $menu_api = new WP_REST_Menus(); $menu = $menu_api->get_menu_location($request); } return $menu; }