PluginProbe
Post Grid Gutenberg Blocks – PostX / 2.2.5
Post Grid Gutenberg Blocks – PostX v2.2.5
5.0.39 5.0.38 5.0.37 5.0.36 5.0.35 5.0.34 5.0.33 5.0.32 5.0.31 5.0.30 5.0.29 5.0.28 5.0.27 5.0.26 5.0.25 5.0.23 5.0.24 5.0.22 5.0.21 5.0.20 5.0.19 5.0.18 5.0.17 2.1.1 2.1.2 All 237 releases
← All changes | classes/REST_API.php +33 -26 2.1.22.2.5 View file →
@@ -7,9 +7,9 @@
7 7 add_action( 'rest_api_init', 'ultp_register_route' );
8 8 function ultp_register_route() {
9 9 register_rest_route( 'ultp', 'posts', array(
10 10 'methods' => WP_REST_Server::READABLE,
11 - 'args' => array('post_type', 'taxonomy', 'include', 'exclude', 'order', 'orderby', 'count', 'size', 'tag', 'cat', 'meta_key', 'queryQuick', 'wpnonce'),
11 + 'args' => array('post_type' => [], 'taxonomy' => [], 'include' => [], 'exclude' => [], 'order' => [], 'orderby' => [], 'count' => [], 'size' => [], 'tag' => [], 'cat' => [], 'meta_key' => [], 'queryQuick' => [], 'wpnonce' => []),
12 12 'callback' => 'ultp_route_post_data',
13 13 'permission_callback' => '__return_true'
14 14 )
15 15 );
@@ -14,9 +14,9 @@
14 14 )
15 15 );
16 16 register_rest_route( 'ultp', 'taxonomy', array(
17 17 'methods' => WP_REST_Server::READABLE,
18 - 'args' => array('taxonomy', 'wpnonce'),
18 + 'args' => array('wpnonce' => []),
19 19 'callback' => 'ultp_route_taxonomy_data',
20 20 'permission_callback' => '__return_true'
21 21 )
22 22 );
@@ -21,9 +21,9 @@
21 21 )
22 22 );
23 23 register_rest_route( 'ultp', 'imagesize', array(
24 24 'methods' => WP_REST_Server::READABLE,
25 - 'args' => array('taxonomy', 'wpnonce'),
25 + 'args' => array('taxonomy' => [], 'wpnonce' => []),
26 26 'callback' => 'ultp_route_imagesize_data',
27 27 'permission_callback' => '__return_true'
28 28 )
29 29 );
@@ -28,16 +28,16 @@
28 28 )
29 29 );
30 30 register_rest_route( 'ultp', 'posttype', array(
31 31 'methods' => WP_REST_Server::READABLE,
32 - 'args' => array('wpnonce'),
32 + 'args' => array('wpnonce' => []),
33 33 'callback' => 'ultp_route_posttype_data',
34 34 'permission_callback' => '__return_true'
35 35 )
36 36 );
37 - register_rest_route( 'ultp', 'tax_info', array(
37 + register_rest_route( 'ultp', 'specific_taxonomy', array(
38 38 'methods' => WP_REST_Server::READABLE,
39 - 'args' => array('taxonomy', 'wpnonce'),
39 + 'args' => array('taxonomy' => [], 'wpnonce' => []),
40 40 'callback' => 'ultp_route_taxonomy_info_data',
41 41 'permission_callback' => '__return_true'
42 42 )
43 43 );
@@ -104,11 +104,9 @@
104 104 }
105 105
106 106 if(isset($prams['queryQuick'])){
107 107 if($prams['queryQuick'] != ''){
108 - if(function_exists('ultimate_post_pro')){
109 - $args = ultimate_post_pro()->get_quick_query($prams, $args);
110 - }
108 + $args = ultimate_post()->get_quick_query($prams, $args);
111 109 }
112 110 }
113 111
114 112 if(isset($prams['include'])){
@@ -185,27 +183,36 @@
185 183 function ultp_route_taxonomy_data($prams) {
186 184 if (!wp_verify_nonce($_REQUEST['wpnonce'], 'ultp-nonce')){
187 185 return rest_ensure_response([]);
188 186 }
189 - return rest_ensure_response(ultimate_post()->taxonomy($prams['taxonomy']));
187 +
188 + $all_post_type = ultimate_post()->get_post_type();
189 + $data = array();
190 + foreach ($all_post_type as $post_type_slug => $post_type ) {
191 + $data_term = array();
192 + $taxonomies = get_object_taxonomies($post_type_slug);
193 + foreach ($taxonomies as $key => $taxonomy_slug) {
194 + $taxonomy_value = get_terms(array(
195 + 'taxonomy' => $taxonomy_slug,
196 + 'hide_empty' => false
197 + ));
198 + if (!is_wp_error($taxonomy_value)) {
199 + $data_tax = array();
200 + foreach ($taxonomy_value as $k => $taxonomy) {
201 + $data_tax[$taxonomy->slug] = $taxonomy->name;
202 + }
203 + $data_term[$taxonomy_slug] = $data_tax;
204 + }
205 + }
206 + $data[$post_type_slug] = $data_term;
207 + }
208 + return rest_ensure_response($data);
209 + // return rest_ensure_response(ultimate_post()->taxonomy($prams['taxonomy']));
190 210 }
191 211
192 212 function ultp_route_taxonomy_info_data($prams) {
193 - if (!wp_verify_nonce($_REQUEST['wpnonce'], 'ultp-nonce')){
213 + if (!wp_verify_nonce($_REQUEST['wpnonce'], 'ultp-nonce')) {
194 214 return rest_ensure_response([]);
195 215 }
196 -
197 - $data = array();
198 - $terms = get_terms( $prams, array(
199 - 'hide_empty' => true,
200 - ));
201 - if( !empty($terms) ){
202 - foreach ($terms as $val) {
203 - $data['name'] = $val->name;
204 - $data['count'] = $val->count;
205 - $data['url'] = get_term_link($val->term_id);
206 - $data['color'] = get_term_meta($val->term_id, '_background', true);
207 - }
208 - }
209 -
210 - return rest_ensure_response($data);
216 +
217 + return rest_ensure_response(ultimate_post()->taxonomy($prams['taxonomy']));
211 218 }