@@ -14,7 +14,7 @@ public function register_routes() {
14
14
register_rest_route ( $ this ->namespace , '/ ' . $ this ->rest_base , [
15
15
/**
16
16
* Get contents
17
- * AJAX check jQuery.ajax( { url :'https://ipsen.beapi.space /wp-json/bea/silo?post_types[]=post&term_id=4', params : { 'post_types' : [ 'post', 'page' ], term_id : 34 }, method : "GET" });
17
+ * AJAX check jQuery.ajax( { url :'https://yourdomain.com /wp-json/bea/silo?post_types[]=post&term_id=4', params : { 'post_types' : [ 'post', 'page' ], term_id : 34 }, method : "GET" });
18
18
*/
19
19
[
20
20
'methods ' => \WP_REST_Server::READABLE ,
@@ -92,7 +92,14 @@ public function get_contents( $request ) {
92
92
*/
93
93
public function get_contents_check ( \WP_REST_Request $ request ) {
94
94
$ term = \WP_Term::get_instance ( (int ) $ request ->get_param ( 'term_id ' ) );
95
+ if ( is_wp_error ( $ term ) ) {
96
+ return new \WP_Error ( 'rest_error_silo_no_term ' , __ ( 'Term is missing. ' , 'bea-silo ' ), [ 'status ' => rest_authorization_required_code () ] );
97
+ }
98
+
95
99
$ post_types = (array ) $ request ->get_param ( 'post_types ' );
100
+ if ( empty ( $ post_types ) ) {
101
+ return new \WP_Error ( 'rest_error_silo_no_post_types ' , __ ( 'Post Types are missing. ' , 'bea-silo ' ), [ 'status ' => rest_authorization_required_code () ] );
102
+ }
96
103
97
104
if ( ! Main::is_silotable_term ( $ post_types , $ term ) ) {
98
105
return new \WP_Error ( 'rest_error_silo_content_args ' , __ ( 'Given args are not silotable ones. ' , 'bea-silo ' ), [ 'status ' => rest_authorization_required_code () ] );
0 commit comments