Changeset 8004
- Timestamp:
- 12/20/2018 11:34:12 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/inc/rest-api.php
r8003 r8004 114 114 ); 115 115 } // End if(). 116 117 /** 118 * Session date and time 119 */ 120 register_rest_field( 121 'wcb_session', 122 'session_date_time', 123 [ 124 'get_callback' => function ( $object ) { 125 $object = (object) $object; 126 $raw = absint( get_post_meta( $object->id, '_wcpt_session_time', true ) ); 127 $return = [ 128 'date' => '', 129 'time' => '', 130 ]; 131 132 if ( $raw ) { 133 $return['date'] = date_i18n( get_option( 'date_format' ), $raw ); 134 $return['time'] = date_i18n( get_option( 'time_format' ), $raw ); 135 } 136 137 return $return; 138 }, 139 'schema' => [ 140 'description' => __( 'Date and time of the session', 'wordcamporg' ), 141 'type' => 'object', 142 'context' => array( 'embed', 'view' ), 143 'readonly' => true, 144 'properties' => [ 145 'date' => [ 146 'type' => 'string', 147 'context' => array( 'embed', 'view' ), 148 ], 149 'time' => [ 150 'type' => 'string', 151 'context' => array( 'embed', 'view' ), 152 ], 153 ], 154 ], 155 ] 156 ); 116 157 } 117 158 … … 196 237 $response->add_link( 197 238 'sessions', 198 get_rest_url( null, "/wp/v2/sessions/$session_id" ), 239 add_query_arg( 240 [ 241 // Ensure that taxonomy data gets included in the embed. 242 '_embed' => true, 243 'context' => 'view', 244 ], 245 get_rest_url( null, "/wp/v2/sessions/$session_id" ) 246 ), 199 247 array( 'embeddable' => true ) 200 248 );
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)