'GET', 'permission_callback' => '__return_true', 'args' => array( 'q' => array( 'type' => 'string', 'default' => '{}' ), 'offset' => array( 'type' => 'integer', 'default' => 0, 'sanitize_callback' => 'absint' ), 'term' => array( 'type' => 'integer', 'default' => 0, 'sanitize_callback' => 'absint' ), ), 'callback' => function ( WP_REST_Request $r ) { $cfg = json_decode( (string) $r['q'], true ); $n = swapfeed_normalize_atts( is_array( $cfg ) ? $cfg : array() ); $q = new WP_Query( swapfeed_query_args( $n, (int) $r['offset'], (int) $r['term'] ) ); $out = array(); foreach ( $q->posts as $p ) { $out[] = swapfeed_item( $p, $n ); } $res = new WP_REST_Response( array( 'items' => $out, 'end' => count( $out ) < $n['count'] ) ); $res->header( 'Cache-Control', 'public, max-age=300' ); return $res; }, ) ); } );