Changeset 7132
- Timestamp:
- 05/30/2013 11:00:12 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-theme-compatibility.php
r7131 r7132 337 337 } 338 338 } 339 339 340 /** 340 341 * This fun little function fills up some WordPress globals with dummy data to … … 349 350 global $wp_query, $post; 350 351 351 // Default arguments352 $defaults = array(353 'ID' => -9999,354 'post_status' => 'publish',355 'post_author' => 0,356 'post_parent' => 0,357 'post_type' => 'page',358 'post_date' => 0,359 'post_date_gmt' => 0,360 'post_modified' => 0,361 'post_modified_gmt' => 0,362 'post_content' => '',363 'post_title' => '',364 'post_category' => 0,365 'post_excerpt' => '',366 'post_content_filtered' => '',367 'post_mime_type' => '',368 'post_password' => '',369 'post_name' => '',370 'guid' => '',371 'menu_order' => 0,372 'pinged' => '',373 'to_ping' => '',374 'ping_status' => '',375 'comment_status' => 'closed',376 'comment_count' => 0,377 378 'is_404' => false,379 'is_page' => false,380 'is_single' => false,381 'is_archive' => false,382 'is_tax' => false,383 );384 385 352 // Switch defaults if post is set 386 353 if ( isset( $wp_query->post ) ) { 387 $d efaults =array(354 $dummy = bbp_parse_args( $args, array( 388 355 'ID' => $wp_query->post->ID, 389 356 'post_status' => $wp_query->post->post_status, … … 409 376 'comment_status' => $wp_query->post->comment_status, 410 377 'comment_count' => $wp_query->post->comment_count, 411 412 'is_404' => false, 413 'is_page' => false, 414 'is_single' => false, 415 'is_archive' => false, 416 'is_tax' => false, 417 ); 418 } 419 $dummy = wp_parse_args( $args, $defaults ); //, 'theme_compat_reset_post' ); 420 421 // Clear out the post related globals 422 unset( $wp_query->posts ); 423 unset( $wp_query->post ); 424 unset( $post ); 425 426 // Setup the dummy post object 427 $wp_query->post = new stdClass; 428 $wp_query->post->ID = $dummy['ID']; 429 $wp_query->post->post_status = $dummy['post_status']; 430 $wp_query->post->post_author = $dummy['post_author']; 431 $wp_query->post->post_parent = $dummy['post_parent']; 432 $wp_query->post->post_type = $dummy['post_type']; 433 $wp_query->post->post_date = $dummy['post_date']; 434 $wp_query->post->post_date_gmt = $dummy['post_date_gmt']; 435 $wp_query->post->post_modified = $dummy['post_modified']; 436 $wp_query->post->post_modified_gmt = $dummy['post_modified_gmt']; 437 $wp_query->post->post_content = $dummy['post_content']; 438 $wp_query->post->post_title = $dummy['post_title']; 439 $wp_query->post->post_excerpt = $dummy['post_excerpt']; 440 $wp_query->post->post_content_filtered = $dummy['post_content_filtered']; 441 $wp_query->post->post_mime_type = $dummy['post_mime_type']; 442 $wp_query->post->post_password = $dummy['post_password']; 443 $wp_query->post->post_name = $dummy['post_name']; 444 $wp_query->post->guid = $dummy['guid']; 445 $wp_query->post->menu_order = $dummy['menu_order']; 446 $wp_query->post->pinged = $dummy['pinged']; 447 $wp_query->post->to_ping = $dummy['to_ping']; 448 $wp_query->post->ping_status = $dummy['ping_status']; 449 $wp_query->post->comment_status = $dummy['comment_status']; 450 $wp_query->post->comment_count = $dummy['comment_count']; 378 'filter' => $wp_query->post->filter, 379 380 'is_404' => false, 381 'is_page' => false, 382 'is_single' => false, 383 'is_archive' => false, 384 'is_tax' => false, 385 ) ); 386 } else { 387 $dummy = wp_parse_args( $args, array( 388 'ID' => -9999, 389 'post_status' => bbp_get_public_status_id(), 390 'post_author' => 0, 391 'post_parent' => 0, 392 'post_type' => 'page', 393 'post_date' => 0, 394 'post_date_gmt' => 0, 395 'post_modified' => 0, 396 'post_modified_gmt' => 0, 397 'post_content' => '', 398 'post_title' => '', 399 'post_excerpt' => '', 400 'post_content_filtered' => '', 401 'post_mime_type' => '', 402 'post_password' => '', 403 'post_name' => '', 404 'guid' => '', 405 'menu_order' => 0, 406 'pinged' => '', 407 'to_ping' => '', 408 'ping_status' => '', 409 'comment_status' => 'closed', 410 'comment_count' => 0, 411 'filter' => 'raw', 412 413 'is_404' => false, 414 'is_page' => false, 415 'is_single' => false, 416 'is_archive' => false, 417 'is_tax' => false, 418 ) ); 419 } 420 421 // Bail if dummy post is empty 422 if ( empty( $dummy ) ) { 423 return; 424 } 451 425 452 426 // Set the $post global 453 $post = $wp_query->post; 454 455 // Setup the dummy post loop 456 $wp_query->posts[0] = $wp_query->post; 427 $post = new WP_Post( (object) $dummy ); 428 429 // Copy the new post global into the main $wp_query 430 $wp_query->post = $post; 431 $wp_query->posts = array( $post ); 457 432 458 433 // Prevent comments form from appearing … … 464 439 $wp_query->is_tax = $dummy['is_tax']; 465 440 441 // Clean up the dummy post 442 unset( $dummy ); 443 444 /** 445 * Force the header back to 200 status if not a deliberate 404 446 * 447 * @see http://bbpress.trac.wordpress.org/ticket/1973 448 */ 449 if ( ! $wp_query->is_404() ) { 450 status_header( 200 ); 451 } 452 466 453 // If we are resetting a post, we are in theme compat 467 bp_set_theme_compat_active( );454 bp_set_theme_compat_active( true ); 468 455 } 469 456
Note: See TracChangeset
for help on using the changeset viewer.