Skip to content

Commit

Permalink
Merge pull request #15 from scarstens/master
Browse files Browse the repository at this point in the history
add and document filter for CPT endpoints
  • Loading branch information
erwstout authored Feb 26, 2018
2 parents e1e660f + 4fb95e3 commit c5958f4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,19 @@ It returns a JSON response with the following (returns an empty array if no post
- Tags
- Tag IDs
- ACF fields, if applicable

## Hooks and Filters

### Filter the Custom Post Types endpoints

```php
add_filter('better_rest_endpoints_cpt_collection', function($cpt_collection){
$cpt_collection = array_flip($cpt_collection);
unset($cpt_collection['oembed_cache']);
unset($cpt_collection['_pods_template']);
unset($cpt_collection['_pods_pod']);
unset($cpt_collection['_pods_field']);
$cpt_collection = array_values( array_flip($cpt_collection) );
return $cpt_collection;
});
```
2 changes: 2 additions & 0 deletions includes/get_cpts.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ function bre_get_cpts() {
}
}

$bre_cpts = apply_filters( 'better_rest_endpoints_cpt_collection', $bre_cpts );

// check if array is empty, returns array if data exists, return false if empty
if( !empty($bre_cpts) ){
return $bre_cpts;
Expand Down

0 comments on commit c5958f4

Please sign in to comment.