@@ -21,16 +21,16 @@ discard block |
||
21 | 21 | public function register_routes() { |
22 | 22 | |
23 | 23 | $version = '1'; |
24 | - $namespace = 'vendor/v' . $version; |
|
25 | - $base = 'route'; |
|
24 | + $namespace = 'vendor/v' . $version; |
|
25 | + $base = 'route'; |
|
26 | 26 | |
27 | 27 | //Available options for methods are CREATABLE, READABLE, EDITABLE, DELETABLE |
28 | 28 | register_rest_route( $namespace, '/' . $base, array( |
29 | - 'methods' => WP_REST_Server::READABLE, |
|
30 | - 'callback' => array( $this, 'callback' ), |
|
31 | - 'permission_callback' => array( $this, 'permission' ), |
|
32 | - 'args' => array('sample', 'list', 'of', 'args'), |
|
33 | - ), |
|
29 | + 'methods' => WP_REST_Server::READABLE, |
|
30 | + 'callback' => array( $this, 'callback' ), |
|
31 | + 'permission_callback' => array( $this, 'permission' ), |
|
32 | + 'args' => array('sample', 'list', 'of', 'args'), |
|
33 | + ), |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | |
@@ -41,13 +41,13 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function callback() { |
43 | 43 | |
44 | - $params = $request->get_params(); |
|
45 | - $items = array(); |
|
46 | - $data = $this->prepare_item_for_response( $items, $request ); |
|
44 | + $params = $request->get_params(); |
|
45 | + $items = array(); |
|
46 | + $data = $this->prepare_item_for_response( $items, $request ); |
|
47 | 47 | |
48 | - if ( $data ) { |
|
49 | - return new WP_REST_Response( $data, 200 ); |
|
50 | - } else { |
|
48 | + if ( $data ) { |
|
49 | + return new WP_REST_Response( $data, 200 ); |
|
50 | + } else { |
|
51 | 51 | return new WP_Error( 'status_code', __( 'message', 'text-domain' ) ); |
52 | 52 | } |
53 | 53 | } |
@@ -49,24 +49,24 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function labels() { |
51 | 51 | |
52 | - $labels = array( |
|
53 | - 'name' => _x( '', 'Post Type General Name', 'textdomain' ), |
|
54 | - 'singular_name' => _x( '', 'Post Type Singular Name', 'textdomain' ), |
|
55 | - 'menu_name' => __( '', 'textdomain' ), |
|
56 | - 'parent_item_colon' => __( '', 'textdomain' ), |
|
57 | - 'all_items' => __( '', 'textdomain' ), |
|
58 | - 'view_item' => __( '', 'textdomain' ), |
|
59 | - 'add_new_item' => __( '', 'textdomain' ), |
|
60 | - 'add_new' => __( '', 'textdomain' ), |
|
61 | - 'edit_item' => __( '', 'textdomain' ), |
|
62 | - 'update_item' => __( '', 'textdomain' ), |
|
63 | - 'search_items' => __( '', 'textdomain' ), |
|
64 | - 'not_found' => __( '', 'textdomain' ), |
|
65 | - 'not_found_in_trash' => __( '', 'textdomain' ), |
|
66 | - ); |
|
67 | - |
|
68 | - return $labels; |
|
69 | - } |
|
52 | + $labels = array( |
|
53 | + 'name' => _x( '', 'Post Type General Name', 'textdomain' ), |
|
54 | + 'singular_name' => _x( '', 'Post Type Singular Name', 'textdomain' ), |
|
55 | + 'menu_name' => __( '', 'textdomain' ), |
|
56 | + 'parent_item_colon' => __( '', 'textdomain' ), |
|
57 | + 'all_items' => __( '', 'textdomain' ), |
|
58 | + 'view_item' => __( '', 'textdomain' ), |
|
59 | + 'add_new_item' => __( '', 'textdomain' ), |
|
60 | + 'add_new' => __( '', 'textdomain' ), |
|
61 | + 'edit_item' => __( '', 'textdomain' ), |
|
62 | + 'update_item' => __( '', 'textdomain' ), |
|
63 | + 'search_items' => __( '', 'textdomain' ), |
|
64 | + 'not_found' => __( '', 'textdomain' ), |
|
65 | + 'not_found_in_trash' => __( '', 'textdomain' ), |
|
66 | + ); |
|
67 | + |
|
68 | + return $labels; |
|
69 | + } |
|
70 | 70 | |
71 | 71 | |
72 | 72 | /** |
@@ -76,44 +76,44 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @return Array |
78 | 78 | */ |
79 | - public function args( $labels ) { |
|
80 | - |
|
81 | - $args = array( |
|
82 | - 'label' => __( '', 'textdomain' ), |
|
83 | - 'description' => __( '', 'textdomain' ), |
|
84 | - 'labels' => $labels, |
|
85 | - 'supports' => array( 'title', 'editor', 'thumbnail' ), |
|
86 | - 'taxonomies' => array( 'topics', 'post_tag' ), |
|
87 | - 'hierarchical' => true, |
|
88 | - 'public' => true, |
|
79 | + public function args( $labels ) { |
|
80 | + |
|
81 | + $args = array( |
|
82 | + 'label' => __( '', 'textdomain' ), |
|
83 | + 'description' => __( '', 'textdomain' ), |
|
84 | + 'labels' => $labels, |
|
85 | + 'supports' => array( 'title', 'editor', 'thumbnail' ), |
|
86 | + 'taxonomies' => array( 'topics', 'post_tag' ), |
|
87 | + 'hierarchical' => true, |
|
88 | + 'public' => true, |
|
89 | 89 | 'rewrite' => array( 'slug' => 'slug_name' ), |
90 | - 'show_ui' => true, |
|
91 | - 'show_in_menu' => true, |
|
90 | + 'show_ui' => true, |
|
91 | + 'show_in_menu' => true, |
|
92 | 92 | 'menu_icon' => 'data:image/svg+xml;base64,' . self::$menu_svg, |
93 | - 'show_in_nav_menus' => true, |
|
94 | - 'show_in_admin_bar' => true, |
|
95 | - 'menu_position' => 5, |
|
96 | - 'can_export' => true, |
|
97 | - 'has_archive' => true, |
|
98 | - 'exclude_from_search' => false, |
|
99 | - 'publicly_queryable' => true, |
|
100 | - 'capability_type' => 'post', |
|
101 | - 'show_in_rest' => true, |
|
93 | + 'show_in_nav_menus' => true, |
|
94 | + 'show_in_admin_bar' => true, |
|
95 | + 'menu_position' => 5, |
|
96 | + 'can_export' => true, |
|
97 | + 'has_archive' => true, |
|
98 | + 'exclude_from_search' => false, |
|
99 | + 'publicly_queryable' => true, |
|
100 | + 'capability_type' => 'post', |
|
101 | + 'show_in_rest' => true, |
|
102 | 102 | //Controls WP REST API behaviour |
103 | 103 | 'rest_controller_class' => 'WP_REST_Terms_Controller', |
104 | - ); |
|
104 | + ); |
|
105 | 105 | |
106 | - return $args; |
|
107 | - } |
|
106 | + return $args; |
|
107 | + } |
|
108 | 108 | |
109 | 109 | |
110 | 110 | /** |
111 | - * Modify the cpt messages |
|
111 | + * Modify the cpt messages |
|
112 | 112 | * |
113 | 113 | * @param Array $messages |
114 | 114 | * |
115 | 115 | * @return Array |
116 | - */ |
|
116 | + */ |
|
117 | 117 | public function cpt_updated_messages( $messages ) { |
118 | 118 | |
119 | 119 | global $post, $post_ID; |