![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /proc/self/cwd/wp-content/plugins/colibri-page-builder/extend-builder/api/ |
<?php namespace ExtendBuilder; function wp_colibri_v1_get_all_menus() { if(!colibri_user_can_customize()) { return new \WP_REST_Response(null, 401); } $menus_names = []; $menus = wp_get_nav_menus(); foreach ($menus as $menu) { $obj = new \stdClass; foreach (get_object_vars($menu) as $key => $value) { $obj->$key = $value; } // $obj->name = $menu->name; $menus_names[] = $obj; } return $menus_names; } add_action('rest_api_init', function () { register_rest_route('colibri/v1', '/menus', array( 'methods' => 'GET', 'callback' => '\ExtendBuilder\wp_colibri_v1_get_all_menus', 'permission_callback' => function () { return current_user_can( 'edit_theme_options' ); } )); });