Changeset 7477
- Timestamp:
- 10/24/2013 08:51:38 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-classes.php
r7466 r7477 1271 1271 } 1272 1272 1273 /** OUTPUT ***************************************************************/ 1274 1275 /** 1276 * Output the RSS feed. 1273 /** 1274 * Sets various HTTP headers related to Content-Type and browser caching. 1275 * 1276 * Most of this class method is derived from {@link WP::send_headers()}. 1277 * 1278 * @since BuddyPress (1.9.0) 1277 1279 * 1278 1280 * @access protected 1279 1281 */ 1280 protected function output() {1282 protected function http_headers() { 1281 1283 // set up some additional headers if not on a directory page 1282 1284 // this is done b/c BP uses pseudo-pages … … 1288 1290 } 1289 1291 1290 header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true ); 1292 // Set content-type 1293 @header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true ); 1294 1295 // Cache-related variables 1296 $last_modified = mysql2date( 'D, d M Y H:i:s O', bp_activity_get_last_updated(), false ); 1297 $modified_timestamp = strtotime( $last_modified ); 1298 $etag = md5( $last_modified ); 1299 1300 // Set cache-related headers 1301 @header( 'Last-Modified: ' . $last_modified ); 1302 @header( 'Pragma: no-cache' ); 1303 @header( 'ETag: ' . '"' . $etag . '"' ); 1304 1305 // First commit of BuddyPress! (Easter egg) 1306 @header( 'Expires: Tue, 25 Mar 2008 17:13:55 GMT'); 1307 1308 // Get ETag from supported user agents 1309 if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) { 1310 $client_etag = wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] ); 1311 1312 // Remove quotes from ETag 1313 $client_etag = trim( $client_etag, '"' ); 1314 1315 // Strip suffixes from ETag if they exist (eg. "-gzip") 1316 if ( $etag_suffix_pos = strpos( $client_etag, '-' ) ) { 1317 $client_etag = substr( $client_etag, 0, $etag_suffix_pos ); 1318 } 1319 1320 // No ETag found 1321 } else { 1322 $client_etag = false; 1323 } 1324 1325 // Get client last modified timestamp from supported user agents 1326 $client_last_modified = empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ? '' : trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ); 1327 $client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0; 1328 1329 // Set 304 status if feed hasn't been updated since last fetch 1330 if ( ( $client_last_modified && $client_etag ) ? 1331 ( ( $client_modified_timestamp >= $modified_timestamp ) && ( $client_etag == $etag ) ) : 1332 ( ( $client_modified_timestamp >= $modified_timestamp ) || ( $client_etag == $etag ) ) ) { 1333 $status = 304; 1334 } else { 1335 $status = false; 1336 } 1337 1338 // If feed hasn't changed as reported by the user agent, set 304 status header 1339 if ( ! empty( $status ) ) { 1340 status_header( $status ); 1341 1342 // cached response, so stop now! 1343 if ( $status == 304 ) { 1344 exit(); 1345 } 1346 } 1347 } 1348 1349 /** OUTPUT ***************************************************************/ 1350 1351 /** 1352 * Output the RSS feed. 1353 * 1354 * @access protected 1355 */ 1356 protected function output() { 1357 $this->http_headers(); 1291 1358 echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?'.'>'; 1292 1359 ?>
Note: See TracChangeset
for help on using the changeset viewer.