class-kubio-menu-wallker.php
1 year ago
class-wp-rest-menu-locations-controller.php
4 years ago
class-wp-rest-menus-controller.php
1 year ago
index.php
1 year ago
locations.php
1 year ago
menu-rest-controller.php
1 year ago
index.php
48 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | |
| 5 | if ( ! defined( 'ABSPATH' ) ) { |
| 6 | die( '-1' ); |
| 7 | } |
| 8 | |
| 9 | require_once __DIR__ . '/locations.php'; |
| 10 | |
| 11 | |
| 12 | function kubio_register_rest_menu_location() { |
| 13 | $nav_menu_location = new WP_REST_Menu_Locations_Controller(); |
| 14 | $nav_menu_location->register_routes(); |
| 15 | } |
| 16 | |
| 17 | function kubio_api_nav_menus_taxonomy_args( $args, $taxonomy ) { |
| 18 | if ( 'nav_menu' === $taxonomy ) { |
| 19 | $args['show_in_rest'] = true; |
| 20 | $args['rest_base'] = 'menus'; |
| 21 | $args['rest_controller_class'] = 'WP_REST_Menus_Controller'; |
| 22 | } |
| 23 | |
| 24 | return $args; |
| 25 | } |
| 26 | |
| 27 | if ( class_exists( 'WP_REST_Controller' ) ) { |
| 28 | require_once __DIR__ . '/menu-rest-controller.php'; |
| 29 | |
| 30 | if ( ! class_exists( 'WP_REST_Menus_Controller' ) ) { |
| 31 | require_once __DIR__ . '/class-wp-rest-menus-controller.php'; |
| 32 | add_filter( 'register_taxonomy_args', 'kubio_api_nav_menus_taxonomy_args', 10, 2 ); |
| 33 | } |
| 34 | |
| 35 | |
| 36 | if ( ! class_exists( 'WP_REST_Menu_Locations_Controller' ) ) { |
| 37 | require_once __DIR__ . '/class-wp-rest-menu-locations-controller.php'; |
| 38 | add_action( 'rest_api_init', 'kubio_register_rest_menu_location' ); |
| 39 | } |
| 40 | |
| 41 | function kubio_register_rest_menu_controller() { |
| 42 | $nav_menu_location = new Kubio_Menu_Rest_Controller(); |
| 43 | $nav_menu_location->register_routes(); |
| 44 | } |
| 45 | |
| 46 | add_action( 'rest_api_init', 'kubio_register_rest_menu_controller' ); |
| 47 | } |
| 48 |