- Timestamp:
- 10/12/2015 05:45:14 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/classes/class-bp-activity-feed.php
r10248 r10253 1 1 <?php 2 2 /** 3 * BuddyPress Activity Classes 3 * BuddyPress Activity Classes. 4 4 * 5 5 * @package BuddyPress … … 7 7 */ 8 8 9 // Exit if accessed directly 9 // Exit if accessed directly. 10 10 defined( 'ABSPATH' ) || exit; 11 11 … … 16 16 * the appropriate screen. 17 17 * 18 * @since 1.8.0 19 * 18 20 * See {@link bp_activity_action_sitewide_feed()} as an example. 19 21 * 20 22 * @param array $args { 21 * @type string $id Required. Internal id for the feed; should be alphanumeric only.23 * @type string $id Required. Internal id for the feed; should be alphanumeric only. 22 24 * @type string $title Optional. RSS feed title. 23 25 * @type string $link Optional. Relevant link for the RSS feed. … … 31 33 * @type array $activity_args Optional. Arguments passed to {@link bp_has_activities()} 32 34 * } 33 * @since 1.8.034 35 */ 35 36 class BP_Activity_Feed { … … 49 50 * Magic method for checking the existence of a certain data variable. 50 51 * 51 * @param string $key 52 * @param string $key Property to check. 52 53 * 53 54 * @return bool Whether or not data variable exists. … … 58 59 * Magic method for getting a certain data variable. 59 60 * 60 * @param string $key 61 * @param string $key Property to get. 61 62 * 62 63 * @return mixed Data in variable if available or null. … … 91 92 global $wp_query; 92 93 93 // set feed flag to false94 // Set feed flag to false. 94 95 $wp_query->is_feed = false; 95 96 … … 97 98 } 98 99 99 // Setup data 100 // Setup data. 100 101 $this->data = wp_parse_args( $args, array( 101 // Internal identifier for the RSS feed - should be alphanumeric only 102 // Internal identifier for the RSS feed - should be alphanumeric only. 102 103 'id' => '', 103 104 104 // RSS title - should be plain-text 105 // RSS title - should be plain-text. 105 106 'title' => '', 106 107 107 // relevant link for the RSS feed108 // Relevant link for the RSS feed. 108 109 'link' => '', 109 110 110 // RSS description - should be plain-text 111 // RSS description - should be plain-text. 111 112 'description' => '', 112 113 … … 114 115 // requests it again. This is only acknowledged if the RSS client supports it 115 116 // 116 // See: http://www.rssboard.org/rss-profile#element-channel-ttl 117 // http://www.kbcafe.com/rss/rssfeedstate.html#ttl117 // See: http://www.rssboard.org/rss-profile#element-channel-ttl. 118 // See: http://www.kbcafe.com/rss/rssfeedstate.html#ttl. 118 119 'ttl' => '30', 119 120 … … 121 122 // clients 122 123 // 123 // See: http://web.resource.org/rss/1.0/modules/syndication/#description 124 // http://www.kbcafe.com/rss/rssfeedstate.html#syndicationmodule124 // See: http://web.resource.org/rss/1.0/modules/syndication/#description. 125 // See: http://www.kbcafe.com/rss/rssfeedstate.html#syndicationmodule. 125 126 'update_period' => 'hourly', 126 127 'update_frequency' => 2, 127 128 128 // Number of items to display 129 // Number of items to display. 129 130 'max' => 50, 130 131 131 // Activity arguments passed to bp_has_activities() 132 // Activity arguments passed to bp_has_activities(). 132 133 'activity_args' => array() 133 134 ) ); … … 142 143 do_action_ref_array( 'bp_activity_feed_prefetch', array( &$this ) ); 143 144 144 // Setup class properties 145 // Setup class properties. 145 146 $this->setup_properties(); 146 147 147 // Check if id is valid 148 // Check if id is valid. 148 149 if ( empty( $this->id ) ) { 149 150 _doing_it_wrong( 'BP_Activity_Feed', __( "RSS feed 'id' must be defined", 'buddypress' ), 'BP 1.8' ); … … 160 161 do_action_ref_array( 'bp_activity_feed_postfetch', array( &$this ) ); 161 162 162 // Setup feed hooks 163 // Setup feed hooks. 163 164 $this->setup_hooks(); 164 165 165 // Output the feed 166 // Output the feed. 166 167 $this->output(); 167 168 168 // Kill the rest of the output 169 // Kill the rest of the output. 169 170 die(); 170 171 } … … 242 243 switch ( $this->id ) { 243 244 244 // sitewide and friends feeds use the 'personal' hook245 // Sitewide and friends feeds use the 'personal' hook. 245 246 case 'sitewide' : 246 247 case 'friends' : … … 275 276 switch ( $this->id ) { 276 277 277 // also output parent activity item if we're on a specific feed278 // Also output parent activity item if we're on a specific feed. 278 279 case 'favorites' : 279 280 case 'friends' : … … 300 301 */ 301 302 protected function http_headers() { 302 // set up some additional headers if not on a directory page303 // this is done b/c BP uses pseudo-pages 303 // Set up some additional headers if not on a directory page 304 // this is done b/c BP uses pseudo-pages. 304 305 if ( ! bp_is_directory() ) { 305 306 global $wp_query; … … 309 310 } 310 311 311 // Set content-type 312 // Set content-type. 312 313 @header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true ); 313 314 send_nosniff_header(); 314 315 315 // Cache-related variables 316 // Cache-related variables. 316 317 $last_modified = mysql2date( 'D, d M Y H:i:s O', bp_activity_get_last_updated(), false ); 317 318 $modified_timestamp = strtotime( $last_modified ); 318 319 $etag = md5( $last_modified ); 319 320 320 // Set cache-related headers 321 // Set cache-related headers. 321 322 @header( 'Last-Modified: ' . $last_modified ); 322 323 @header( 'Pragma: no-cache' ); 323 324 @header( 'ETag: ' . '"' . $etag . '"' ); 324 325 325 // First commit of BuddyPress! (Easter egg) 326 // First commit of BuddyPress! (Easter egg). 326 327 @header( 'Expires: Tue, 25 Mar 2008 17:13:55 GMT'); 327 328 328 // Get ETag from supported user agents 329 // Get ETag from supported user agents. 329 330 if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) { 330 331 $client_etag = wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] ); 331 332 332 // Remove quotes from ETag 333 // Remove quotes from ETag. 333 334 $client_etag = trim( $client_etag, '"' ); 334 335 335 // Strip suffixes from ETag if they exist (eg. "-gzip") 336 // Strip suffixes from ETag if they exist (eg. "-gzip"). 336 337 $etag_suffix_pos = strpos( $client_etag, '-' ); 337 338 if ( ! empty( $etag_suffix_pos ) ) { … … 339 340 } 340 341 341 // No ETag found 342 // No ETag found. 342 343 } else { 343 344 $client_etag = false; 344 345 } 345 346 346 // Get client last modified timestamp from supported user agents 347 // Get client last modified timestamp from supported user agents. 347 348 $client_last_modified = empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ? '' : trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ); 348 349 $client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0; 349 350 350 // Set 304 status if feed hasn't been updated since last fetch 351 // Set 304 status if feed hasn't been updated since last fetch. 351 352 if ( ( $client_last_modified && $client_etag ) ? 352 353 ( ( $client_modified_timestamp >= $modified_timestamp ) && ( $client_etag == $etag ) ) : … … 357 358 } 358 359 359 // If feed hasn't changed as reported by the user agent, set 304 status header 360 // If feed hasn't changed as reported by the user agent, set 304 status header. 360 361 if ( ! empty( $status ) ) { 361 362 status_header( $status ); 362 363 363 // cached response, so stop now!364 // Cached response, so stop now! 364 365 if ( $status == 304 ) { 365 366 exit();
Note: See TracChangeset
for help on using the changeset viewer.