| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- function make_taxonomy_endpoint_for( $terms ) {
- $type_slugs = [];
- foreach ($terms as $type_slug):
- array_push($type_slugs, $type_slug->slug);
- endforeach;
- return $type_slugs;
- }
-
-
- function default_post_format( $item ) {
- $filtered = array();
- $filtered[id] = $item->ID;
- $filtered[slug] = $item->post_name;
- $filtered[type] = $item->post_type;
- $filtered[title] = $item->post_title;
- $filtered[excerpt] = $item->post_excerpt;
- $filtered[date] = $item->post_date;
- $filtered[content] = $item->post_content;
-
-
- // Materials + type endpoints
- // if($item->post_type === 'artist' || $item->post_type === 'event' || $item->post_type === 'exhibition') {
- $posts_with_type = ['artist', 'exhbition', 'event'];
- if( in_array($item->post_type, $posts_with_type) ) {
- $filtered[materials] = make_taxonomy_endpoint_for( get_the_terms( $item, 'material' ) );
- $filtered[type] = make_taxonomy_endpoint_for( get_the_terms( $item, $item->post_type . '_type' ) );
- }
-
- // Custom fields endpoint
- if($item->post_type === 'artist') $filtered[sortname] = get_post_meta( $item->ID, 'artist-sort-name', true );
-
- if($item->post_type === 'event') {
- $filtered[start] = get_post_meta( $item->ID, 'event-start-time', true );
- $filtered[end] = get_post_meta( $item->ID, 'event-end-time', true );
- }
- if($item->post_type === 'exhibition') {
- $filtered[start] = get_post_meta( $item->ID, 'exhibit-start-date', true );
- $filtered[end] = get_post_meta( $item->ID, 'exhibit-end-date', true );
- }
-
- // Post categories and tags (store just the slugs)
- if($item->post_type === 'post') {
- $filtered[categories] = make_taxonomy_endpoint_for(get_the_terms( $item, 'category' ));
- $filtered[tags] = make_taxonomy_endpoint_for(get_the_terms( $item, 'post_tag' ));
- }
-
- return $filtered;
- }
-
- ?>
|