Changeset 1817679
- Timestamp:
- 02/07/2018 09:55:53 PM (8 years ago)
- Location:
- better-rest-endpoints/trunk
- Files:
-
- 11 edited
-
CHANGELOG.md (modified) (1 diff)
-
README.md (modified) (5 diffs)
-
better-wp-endpoints.php (modified) (1 diff)
-
includes/create_cpt_endpoints.php (modified) (3 diffs)
-
includes/get_pages.php (modified) (3 diffs)
-
includes/get_posts.php (modified) (3 diffs)
-
includes/get_posts_tax.php (modified) (3 diffs)
-
includes/get_search.php (modified) (3 diffs)
-
package-lock.json (modified) (1 diff)
-
package.json (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
better-rest-endpoints/trunk/CHANGELOG.md
r1809677 r1817679 8 8 n/a 9 9 10 ## [1.2.0] - 2018-02-07 11 ### Added 12 - ACF query in endpoint url to hide acf values from the response where applicable (all collections) 13 - Media query in endpoint url to hide featured media from the response where applicable (all collections) 14 10 15 ## [1.1.2] - 2018-01-25 11 16 ### Update 12 17 - Fix issue where get post by slug was returning just the first post 13 - Fix instance of lefover $bwe variable naming 18 - Fix instance of lefover $bwe variable naming 14 19 15 20 ## [1.1.1] - 2018-01-25 -
better-rest-endpoints/trunk/README.md
r1809642 r1817679 18 18 - exclude (int) a post ID to exclude from the response 19 19 - author (string) limit posts by author nice name (user_nicename) 20 - acf (boolean - setting to false omits `acf` from being returned) 21 - media (boolean - setting to false omits `media` (featured media) from being returned) 20 22 21 23 It returns a JSON response with the following: … … 93 95 - content (boolean - setting to false hides the content from the response) 94 96 - exclude (int) a post ID to exclude from the response 97 - acf (boolean - setting to false omits `acf` from being returned) 98 - media (boolean - setting to false omits `media` (featured media) from being returned) 95 99 96 100 Returns the following JSON Response: … … 131 135 - orderby (string) - see the [codex](https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters) for options, currently does not support multiple values 132 136 - exclude (int) a post ID to exclude from the response 137 - acf (boolean - setting to false omits `acf` from being returned) 138 - media (boolean - setting to false omits `media` (featured media) from being returned) 133 139 134 140 Returns the following JSON response: … … 192 198 - orderby (string) - see the [codex](https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters) for options, currently does not support multiple values 193 199 - exclude (int) a post ID to exclude from the response 200 - acf (boolean - setting to false omits `acf` from being returned) 201 - media (boolean - setting to false omits `media` (featured media) from being returned) 194 202 195 203 Returns the following JSON Response: … … 243 251 - content (boolean) set to false to omit content from showing in JSON response 244 252 - search (string | required) 253 - acf (boolean - setting to false omits `acf` from being returned) 254 - media (boolean - setting to false omits `media` (featured media) from being returned) 245 255 246 256 It returns a JSON response with the following (returns an empty array if no posts found): -
better-rest-endpoints/trunk/better-wp-endpoints.php
r1809677 r1817679 4 4 Plugin URI: https://github.com/factor1/better-rest-endpoints/ 5 5 Description: Serves up slimmer WordPress Rest API endpoints, with some great enhancements. 6 Version: 1. 1.26 Version: 1.2.0 7 7 Author: Eric Stout, Factor1 Studios 8 8 Author URI: https://factor1studios.com/ -
better-rest-endpoints/trunk/includes/create_cpt_endpoints.php
r1806011 r1817679 29 29 $content = $request['content']; 30 30 $show_content = filter_var($content, FILTER_VALIDATE_BOOLEAN); 31 $acf = $request['acf']; 32 $show_acf = filter_var($acf, FILTER_VALIDATE_BOOLEAN); 33 $media = $request['media']; 34 $show_media = filter_var($media, FILTER_VALIDATE_BOOLEAN); 31 35 $orderby = $request['orderby']?: null; 32 36 $order = $request['order']?: null; … … 95 99 /* 96 100 * 97 * return acf fields if they exist 101 * return acf fields if they exist and depending on query string 98 102 * 99 103 */ 100 $bre_post->acf = bre_get_acf(); 104 if( $acf === null || $show_acf === true ) { 105 $bre_post->acf = bre_get_acf(); 106 } 101 107 102 108 /* 103 109 * 104 * get possible thumbnail sizes and urls 110 * get possible thumbnail sizes and urls if query set to true or by default 105 111 * 106 112 */ 107 $thumbnail_names = get_intermediate_image_sizes(); 108 $bre_thumbnails = new stdClass(); 109 110 if( has_post_thumbnail() ){ 111 foreach ($thumbnail_names as $key => $name) { 112 $bre_thumbnails->$name = esc_url(get_the_post_thumbnail_url($post->ID, $name)); 113 114 if( $media === null || $show_media === true ) { 115 $thumbnail_names = get_intermediate_image_sizes(); 116 $bre_thumbnails = new stdClass(); 117 118 if( has_post_thumbnail() ){ 119 foreach ($thumbnail_names as $key => $name) { 120 $bre_thumbnails->$name = esc_url(get_the_post_thumbnail_url($post->ID, $name)); 121 } 122 123 $bre_post->media = $bre_thumbnails; 124 } else { 125 $bre_post->media = false; 113 126 } 114 115 $bre_post->media = $bre_thumbnails;116 } else {117 $bre_post->media = false;118 127 } 119 128 … … 168 177 } 169 178 ), 179 'acf' => array( 180 'description' => 'Hide or show acf fields from the collection.', 181 'type' => 'boolean', 182 'validate_callback' => function( $param, $request, $key ) { 183 184 if ( $param == 'true' || $param == 'TRUE' ) { 185 $param = true; 186 } else if( $param == 'false' || $param == 'FALSE') { 187 $param = false; 188 } 189 190 return is_bool( $param ); 191 } 192 ), 170 193 'order' => array( 171 194 'description' => 'Change order of the collection.', -
better-rest-endpoints/trunk/includes/get_pages.php
r1806011 r1817679 17 17 $content = $request['content']; 18 18 $show_content = filter_var($content, FILTER_VALIDATE_BOOLEAN); 19 $acf = $request['acf']; 20 $show_acf = filter_var($acf, FILTER_VALIDATE_BOOLEAN); 21 $media = $request['media']; 22 $show_media = filter_var($media, FILTER_VALIDATE_BOOLEAN); 19 23 $orderby = $request['orderby']?: null; 20 24 $order = $request['order']?: null; … … 99 103 * 100 104 */ 101 $bre_page->acf = bre_get_acf(); 102 103 /* 104 * 105 * get possible thumbnail sizes and urls 106 * 107 */ 108 $thumbnail_names = get_intermediate_image_sizes(); 109 $bre_thumbnails = new stdClass(); 110 111 if( has_post_thumbnail() ){ 112 foreach ($thumbnail_names as $key => $name) { 113 $bre_thumbnails->$name = esc_url(get_the_post_thumbnail_url($post->ID, $name)); 114 } 115 116 $bre_page->media = $bre_thumbnails; 117 } else { 118 $bre_page->media = false; 119 } 105 if( $acf === null || $show_acf === true ) { 106 $bre_page->acf = bre_get_acf(); 107 } 108 109 /* 110 * 111 * get possible thumbnail sizes and urls if query set to true or by default 112 * 113 */ 114 115 if( $media === null || $show_media === true ) { 116 $thumbnail_names = get_intermediate_image_sizes(); 117 $bre_thumbnails = new stdClass(); 118 119 if( has_post_thumbnail() ){ 120 foreach ($thumbnail_names as $key => $name) { 121 $bre_thumbnails->$name = esc_url(get_the_post_thumbnail_url($post->ID, $name)); 122 } 123 124 $bre_page->media = $bre_thumbnails; 125 } else { 126 $bre_page->media = false; 127 } 128 } 120 129 121 130 // Push the post to the main $post array … … 206 215 } 207 216 ), 217 'acf' => array( 218 'description' => 'Hide or show acf fields from the collection.', 219 'type' => 'boolean', 220 'validate_callback' => function( $param, $request, $key ) { 221 222 if ( $param == 'true' || $param == 'TRUE' ) { 223 $param = true; 224 } else if( $param == 'false' || $param == 'FALSE') { 225 $param = false; 226 } 227 228 return is_bool( $param ); 229 } 230 ), 231 'media' => array( 232 'description' => 'Hide or show featured media from the collection.', 233 'type' => 'boolean', 234 'validate_callback' => function( $param, $request, $key ) { 235 236 if ( $param == 'true' || $param == 'TRUE' ) { 237 $param = true; 238 } else if( $param == 'false' || $param == 'FALSE') { 239 $param = false; 240 } 241 242 return is_bool( $param ); 243 } 244 ), 208 245 ), 209 246 ) ); -
better-rest-endpoints/trunk/includes/get_posts.php
r1806011 r1817679 19 19 $content = $request['content']; 20 20 $show_content = filter_var($content, FILTER_VALIDATE_BOOLEAN); 21 $acf = $request['acf']; 22 $show_acf = filter_var($acf, FILTER_VALIDATE_BOOLEAN); 23 $media = $request['media']; 24 $show_media = filter_var($media, FILTER_VALIDATE_BOOLEAN); 21 25 $orderby = $request['orderby']?: null; 22 26 $order = $request['order']?: null; … … 115 119 /* 116 120 * 117 * return acf fields if they exist 118 * 119 */ 120 $bre_post->acf = bre_get_acf(); 121 122 /* 123 * 124 * get possible thumbnail sizes and urls 125 * 126 */ 127 $thumbnail_names = get_intermediate_image_sizes(); 128 $bre_thumbnails = new stdClass(); 129 130 if( has_post_thumbnail() ){ 131 foreach ($thumbnail_names as $key => $name) { 132 $bre_thumbnails->$name = esc_url(get_the_post_thumbnail_url($post->ID, $name)); 121 * return acf fields if they exist and depending on query string 122 * 123 */ 124 if( $acf === null || $show_acf === true ) { 125 $bre_post->acf = bre_get_acf(); 126 } 127 128 /* 129 * 130 * get possible thumbnail sizes and urls if query set to true or by default 131 * 132 */ 133 134 if( $media === null || $show_media === true ) { 135 $thumbnail_names = get_intermediate_image_sizes(); 136 $bre_thumbnails = new stdClass(); 137 138 if( has_post_thumbnail() ){ 139 foreach ($thumbnail_names as $key => $name) { 140 $bre_thumbnails->$name = esc_url(get_the_post_thumbnail_url($post->ID, $name)); 141 } 142 143 $bre_post->media = $bre_thumbnails; 144 } else { 145 $bre_post->media = false; 133 146 } 134 135 $bre_post->media = $bre_thumbnails;136 } else {137 $bre_post->media = false;138 147 } 139 148 … … 223 232 } 224 233 ), 234 'acf' => array( 235 'description' => 'Hide or show acf fields from the collection.', 236 'type' => 'boolean', 237 'validate_callback' => function( $param, $request, $key ) { 238 239 if ( $param == 'true' || $param == 'TRUE' ) { 240 $param = true; 241 } else if( $param == 'false' || $param == 'FALSE') { 242 $param = false; 243 } 244 245 return is_bool( $param ); 246 } 247 ), 248 'media' => array( 249 'description' => 'Hide or show featured media from the collection.', 250 'type' => 'boolean', 251 'validate_callback' => function( $param, $request, $key ) { 252 253 if ( $param == 'true' || $param == 'TRUE' ) { 254 $param = true; 255 } else if( $param == 'false' || $param == 'FALSE') { 256 $param = false; 257 } 258 259 return is_bool( $param ); 260 } 261 ), 225 262 'order' => array( 226 263 'description' => 'Change order of the collection.', -
better-rest-endpoints/trunk/includes/get_posts_tax.php
r1806011 r1817679 36 36 $content = $request['content']; 37 37 $show_content = filter_var($content, FILTER_VALIDATE_BOOLEAN); 38 $acf = $request['acf']; 39 $show_acf = filter_var($acf, FILTER_VALIDATE_BOOLEAN); 40 $media = $request['media']; 41 $show_media = filter_var($media, FILTER_VALIDATE_BOOLEAN); 38 42 $orderby = $request['orderby']?: null; 39 43 $order = $request['order']?: null; … … 108 112 * 109 113 */ 110 $bre_tax_post->acf = bre_get_acf(); 111 112 /* 113 * 114 * get possible thumbnail sizes and urls 115 * 116 */ 117 $thumbnail_names = get_intermediate_image_sizes(); 118 $bre_thumbnails = new stdClass(); 119 120 if( has_post_thumbnail() ){ 121 foreach ($thumbnail_names as $key => $name) { 122 $bre_thumbnails->$name = esc_url(get_the_post_thumbnail_url($post->ID, $name)); 123 } 124 125 $bre_tax_post->media = $bre_thumbnails; 126 } else { 127 $bre_tax_post->media = false; 128 } 114 if( $acf === null || $show_acf === true ) { 115 $bre_tax_post->acf = bre_get_acf(); 116 } 117 118 /* 119 * 120 * get possible thumbnail sizes and urls if query set to true or by default 121 * 122 */ 123 124 if( $media === null || $show_media === true ) { 125 $thumbnail_names = get_intermediate_image_sizes(); 126 $bre_thumbnails = new stdClass(); 127 128 if( has_post_thumbnail() ){ 129 foreach ($thumbnail_names as $key => $name) { 130 $bre_thumbnails->$name = esc_url(get_the_post_thumbnail_url($post->ID, $name)); 131 } 132 133 $bre_tax_post->media = $bre_thumbnails; 134 } else { 135 $bre_tax_post->media = false; 136 } 137 } 129 138 130 139 // push the post to the main array … … 167 176 'content' => array( 168 177 'description' => 'Hide or show the_content from the collection.', 178 'type' => 'boolean', 179 'validate_callback' => function( $param, $request, $key ) { 180 181 if ( $param == 'true' || $param == 'TRUE' ) { 182 $param = true; 183 } else if( $param == 'false' || $param == 'FALSE') { 184 $param = false; 185 } 186 187 return is_bool( $param ); 188 } 189 ), 190 'acf' => array( 191 'description' => 'Hide or show acf fields from the collection.', 192 'type' => 'boolean', 193 'validate_callback' => function( $param, $request, $key ) { 194 195 if ( $param == 'true' || $param == 'TRUE' ) { 196 $param = true; 197 } else if( $param == 'false' || $param == 'FALSE') { 198 $param = false; 199 } 200 201 return is_bool( $param ); 202 } 203 ), 204 'media' => array( 205 'description' => 'Hide or show featured media from the collection.', 169 206 'type' => 'boolean', 170 207 'validate_callback' => function( $param, $request, $key ) { -
better-rest-endpoints/trunk/includes/get_search.php
r1806011 r1817679 18 18 $content = $request['content']; 19 19 $show_content = filter_var($content, FILTER_VALIDATE_BOOLEAN); 20 $acf = $request['acf']; 21 $show_acf = filter_var($acf, FILTER_VALIDATE_BOOLEAN); 22 $media = $request['media']; 23 $show_media = filter_var($media, FILTER_VALIDATE_BOOLEAN); 20 24 $search = $request['search']?: null; 21 25 … … 107 111 /* 108 112 * 109 * return acf fields if they exist 110 * 111 */ 112 $bre_post->acf = bre_get_acf(); 113 114 /* 115 * 116 * get possible thumbnail sizes and urls 117 * 118 */ 119 $thumbnail_names = get_intermediate_image_sizes(); 120 $bre_thumbnails = new stdClass(); 121 122 if( has_post_thumbnail() ){ 123 foreach ($thumbnail_names as $key => $name) { 124 $bre_thumbnails->$name = esc_url(get_the_post_thumbnail_url($post->ID, $name)); 113 * return acf fields if they exist and depending on query string 114 * 115 */ 116 if( $acf === null || $show_acf === true ) { 117 $bre_post->acf = bre_get_acf(); 118 } 119 120 /* 121 * 122 * get possible thumbnail sizes and urls if query set to true or by default 123 * 124 */ 125 126 if( $media === null || $show_media === true ) { 127 $thumbnail_names = get_intermediate_image_sizes(); 128 $bre_thumbnails = new stdClass(); 129 130 if( has_post_thumbnail() ){ 131 foreach ($thumbnail_names as $key => $name) { 132 $bre_thumbnails->$name = esc_url(get_the_post_thumbnail_url($post->ID, $name)); 133 } 134 135 $bre_post->media = $bre_thumbnails; 136 } else { 137 $bre_post->media = false; 125 138 } 126 127 $bre_post->media = $bre_thumbnails;128 } else {129 $bre_post->media = false;130 139 } 131 140 … … 205 214 } 206 215 ), 216 'acf' => array( 217 'description' => 'Hide or show acf fields from the collection.', 218 'type' => 'boolean', 219 'validate_callback' => function( $param, $request, $key ) { 220 221 if ( $param == 'true' || $param == 'TRUE' ) { 222 $param = true; 223 } else if( $param == 'false' || $param == 'FALSE') { 224 $param = false; 225 } 226 227 return is_bool( $param ); 228 } 229 ), 230 'media' => array( 231 'description' => 'Hide or show featured media from the collection.', 232 'type' => 'boolean', 233 'validate_callback' => function( $param, $request, $key ) { 234 235 if ( $param == 'true' || $param == 'TRUE' ) { 236 $param = true; 237 } else if( $param == 'false' || $param == 'FALSE') { 238 $param = false; 239 } 240 241 return is_bool( $param ); 242 } 243 ), 207 244 'search' => array( 208 245 'description' => 'The search term used to fetch the collection.', -
better-rest-endpoints/trunk/package-lock.json
r1809677 r1817679 1 1 { 2 2 "name": "better-rest-endpoints", 3 "version": "1. 1.2",3 "version": "1.2.0", 4 4 "lockfileVersion": 1, 5 5 "requires": true, -
better-rest-endpoints/trunk/package.json
r1809677 r1817679 1 1 { 2 2 "name": "better-rest-endpoints", 3 "version": "1. 1.2",3 "version": "1.2.0", 4 4 "description": "Serves up slimmer WordPress Rest API endpoints.", 5 5 "main": "index.js", -
better-rest-endpoints/trunk/readme.txt
r1809677 r1817679 6 6 Tags: rest, api, endpoints, acf, json 7 7 Requires at least: 4.7.1 8 Tested up to: 4.9. 29 Stable Tag: 1. 1.28 Tested up to: 4.9.4 9 Stable Tag: 1.2.0 10 10 License: GNU Version 3 or Any Later Version 11 11 … … 43 43 == Changelog == 44 44 45 = 1.2.0, Febuary 7, 2018 = 46 * Add: ACF query in endpoint url to hide acf values from the response where applicable (all collections) 47 * Add: Media query in endpoint url to hide featured media from the response where applicable (all collections) 48 45 49 = 1.1.2, January 25, 2018 = 46 50 * Fix: issue where get post by slug was returning just the first post 47 * Fix: instance of lefover $bwe variable naming 51 * Fix: instance of lefover $bwe variable naming 48 52 49 53 = 1.1.1, January 25, 2018 =
Note: See TracChangeset
for help on using the changeset viewer.