Making WordPress.org

Changeset 8382


Ignore:
Timestamp:
03/01/2019 09:28:58 AM (7 years ago)
Author:
dd32
Message:

WordPress.tv: Standardise some of the new API fields.

See #4230.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/plugins/wordpresstv-rest/wordpresstv-rest.php

    r8379 r8382  
    8585                                                'permalink'   => get_permalink( get_the_ID() ),
    8686                                                'thumbnail'   => $thumbnail,
    87                                                 'date'        => get_the_date(),
    88                                                 'description' => $post->post_excerpt,
     87                                                'date'        => $post->post_date_gmt,
     88                                                'description' => get_the_excerpt(),
    8989                                                'slides'      => get_post_meta( $post->ID, '_wptv_slides_url', true ),
    9090                                                'speakers'    => array(),
     
    9393                                                'tags'        => array(),
    9494                                                'category'    => array(),
    95                                                 'year'        => false,
    96                                                 'location'    => false,
     95                                                'year'        => array(),
     96                                                'location'    => array(),
    9797                                                'producer'    => array(),
    9898                                                'video'       => array(
     
    110110                                                        // Special Cases
    111111                                                        if ( 'category' == $tax && $t->parent == 91093 /* Year */ ) {
    112                                                                 $video['year'] = $t->name;
     112                                                                $video['year'] = array(
     113                                                                        'slug' => $t->slug,
     114                                                                        'name' => $t->name,
     115                                                                        'link' => get_term_link( $t )
     116                                                                );
    113117                                                                continue;
    114118                                                        } elseif ( 'category' == $tax && $t->parent == 6418 /* Location */ ) {
    115                                                                 $video['location'] = $t->name;
     119                                                                $video['location'] = array(
     120                                                                        'slug' => $t->slug,
     121                                                                        'name' => $t->name,
     122                                                                        'link' => get_term_link( $t )
     123                                                                );
    116124                                                                continue;
    117125                                                        }
     
    130138                                        if ( $producer_username = get_the_terms( get_the_ID(), 'producer-username' ) ) {
    131139                                                $video['producer']['username'] = $producer_username[0]->name;
     140                                                $video['producer']['link'] = 'https://profiles.wordpress.org/' . urlencode( $producer_username[0]->name ) . '/';
    132141                                        }
    133142
     
    217226                        switch ( $format ) {
    218227                                case 'json':
    219                                         echo json_encode( $response );
     228                                        header( 'Content-type: application/json' );
     229                                        echo wp_json_encode( $response );
    220230                                        break;
    221231                                case 'array':
    222232                                        if ( defined( 'WPCOM_SANDBOXED' ) && WPCOM_SANDBOXED ) {
     233                                                header( 'Content-Type: text/plain' );
    223234                                                print_r( $response );
    224235                                        }
Note: See TracChangeset for help on using the changeset viewer.