Ticket #12976: refresh-12976-2015-09-01.diff
File refresh-12976-2015-09-01.diff, 12.6 KB (added by , 9 years ago) |
---|
-
wp-includes/revision.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
667 667 668 668 return true; 669 669 } 670 671 /** 672 * Retrieve content from the specified post. 673 * 674 * wp_get_post_content() assumes setup_postdata() has previously been called. 675 * In order to call get_the_content() without side-effects you must first 676 * collect up the values of the global variables assigned in setup_postdata() 677 * and afterwards restore those global variables. 678 * 679 * @since 4.4.0 680 * 681 * @uses save_postdata(), setup_postdata(), restore_postdata(), get_the_content() 682 * 683 * @param object|null|int $post Post data. 684 * @param string $more_link_text Optional. Content for when there is more text. 685 * @param bool $strip_teaser Optional. Teaser content before the more text. 686 * @return string|null The Post's content 687 */ 688 function wp_get_post_content( $post = null, $more_link_text = null, $strip_teaser = false ) { 689 690 if ( ! is_object( $post = get_post( $post ) ) ) { 691 692 $the_content = null; 693 694 } else { 695 696 $save = wp_save_postdata(); 697 setup_postdata( $post ); 698 $the_content = get_the_content( $more_link_text, $stripteaser ); 699 wp_restore_postdata( $save ); 700 701 } 702 703 return $the_content; 704 705 } 706 707 /** 708 * Retrieve the excerpt from the specified post. 709 * 710 * wp_get_post_excerpt() assumes setup_postdata() has previously been called. 711 * In order to call get_the_excerpt() without side-effects you must first 712 * collect up the values of the global variables assigned in setup_postdata() 713 * and afterwards restore those global variables. 714 * 715 * @since 4.4.0 716 * 717 * @uses save_postdata(), setup_postdata(), restore_postdata(), get_the_excerpt() 718 * 719 * @param object|null|int $post Post data. 720 * @return string|null The Post's excerpt 721 */ 722 function get_post_excerpt( $post = null ) { 723 724 if ( ! is_object( $post = get_post( $post ) ) ) { 725 726 $the_excerpt = null; 727 728 } else { 729 730 $save = wp_save_postdata(); 731 setup_postdata( $post ); 732 $the_excerpt = get_the_excerpt(); 733 wp_restore_postdata( $save ); 734 735 } 736 return $the_excerpt; 737 738 } -
wp-includes/query.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
23 23 * @return mixed 24 24 */ 25 25 function get_query_var( $var, $default = '' ) { 26 global $wp_query;26 global $wp_query; 27 27 return $wp_query->get( $var, $default ); 28 28 } 29 29 … … 38 38 * @return object 39 39 */ 40 40 function get_queried_object() { 41 global $wp_query;41 global $wp_query; 42 42 return $wp_query->get_queried_object(); 43 43 } 44 44 … … 53 53 * @return int 54 54 */ 55 55 function get_queried_object_id() { 56 global $wp_query;56 global $wp_query; 57 57 return $wp_query->get_queried_object_id(); 58 58 } 59 59 … … 68 68 * @param mixed $value 69 69 */ 70 70 function set_query_var( $var, $value ) { 71 global $wp_query;71 global $wp_query; 72 72 $wp_query->set( $var, $value ); 73 73 } 74 74 … … 116 116 * @global WP_Query $wp_query 117 117 */ 118 118 function wp_reset_postdata() { 119 global $wp_query;119 global $wp_query; 120 120 121 121 if ( isset( $wp_query ) ) { 122 122 $wp_query->reset_postdata(); … … 139 139 * @return bool 140 140 */ 141 141 function is_archive() { 142 global $wp_query;142 global $wp_query; 143 143 144 144 if ( ! isset( $wp_query ) ) { 145 145 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); … … 160 160 * @return bool 161 161 */ 162 162 function is_post_type_archive( $post_types = '' ) { 163 global $wp_query;163 global $wp_query; 164 164 165 165 if ( ! isset( $wp_query ) ) { 166 166 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); … … 181 181 * @return bool 182 182 */ 183 183 function is_attachment( $attachment = '' ) { 184 global $wp_query;184 global $wp_query; 185 185 186 186 if ( ! isset( $wp_query ) ) { 187 187 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); … … 205 205 * @return bool 206 206 */ 207 207 function is_author( $author = '' ) { 208 global $wp_query;208 global $wp_query; 209 209 210 210 if ( ! isset( $wp_query ) ) { 211 211 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); … … 229 229 * @return bool 230 230 */ 231 231 function is_category( $category = '' ) { 232 global $wp_query;232 global $wp_query; 233 233 234 234 if ( ! isset( $wp_query ) ) { 235 235 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); … … 253 253 * @return bool 254 254 */ 255 255 function is_tag( $tag = '' ) { 256 global $wp_query;256 global $wp_query; 257 257 258 258 if ( ! isset( $wp_query ) ) { 259 259 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); … … 282 282 * @return bool 283 283 */ 284 284 function is_tax( $taxonomy = '', $term = '' ) { 285 global $wp_query;285 global $wp_query; 286 286 287 287 if ( ! isset( $wp_query ) ) { 288 288 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); … … 302 302 * @return bool 303 303 */ 304 304 function is_comments_popup() { 305 global $wp_query;305 global $wp_query; 306 306 307 307 if ( ! isset( $wp_query ) ) { 308 308 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); … … 322 322 * @return bool 323 323 */ 324 324 function is_date() { 325 global $wp_query;325 global $wp_query; 326 326 327 327 if ( ! isset( $wp_query ) ) { 328 328 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); … … 342 342 * @return bool 343 343 */ 344 344 function is_day() { 345 global $wp_query;345 global $wp_query; 346 346 347 347 if ( ! isset( $wp_query ) ) { 348 348 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); … … 363 363 * @return bool 364 364 */ 365 365 function is_feed( $feeds = '' ) { 366 global $wp_query;366 global $wp_query; 367 367 368 368 if ( ! isset( $wp_query ) ) { 369 369 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); … … 383 383 * @return bool 384 384 */ 385 385 function is_comment_feed() { 386 global $wp_query;386 global $wp_query; 387 387 388 388 if ( ! isset( $wp_query ) ) { 389 389 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); … … 412 412 * @return bool True, if front of site. 413 413 */ 414 414 function is_front_page() { 415 global $wp_query;415 global $wp_query; 416 416 417 417 if ( ! isset( $wp_query ) ) { 418 418 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); … … 441 441 * @return bool True if blog view homepage. 442 442 */ 443 443 function is_home() { 444 global $wp_query;444 global $wp_query; 445 445 446 446 if ( ! isset( $wp_query ) ) { 447 447 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); … … 461 461 * @return bool 462 462 */ 463 463 function is_month() { 464 global $wp_query;464 global $wp_query; 465 465 466 466 if ( ! isset( $wp_query ) ) { 467 467 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); … … 488 488 * @return bool 489 489 */ 490 490 function is_page( $page = '' ) { 491 global $wp_query;491 global $wp_query; 492 492 493 493 if ( ! isset( $wp_query ) ) { 494 494 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); … … 508 508 * @return bool 509 509 */ 510 510 function is_paged() { 511 global $wp_query;511 global $wp_query; 512 512 513 513 if ( ! isset( $wp_query ) ) { 514 514 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); … … 528 528 * @return bool 529 529 */ 530 530 function is_preview() { 531 global $wp_query;531 global $wp_query; 532 532 533 533 if ( ! isset( $wp_query ) ) { 534 534 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); … … 548 548 * @return bool 549 549 */ 550 550 function is_robots() { 551 global $wp_query;551 global $wp_query; 552 552 553 553 if ( ! isset( $wp_query ) ) { 554 554 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); … … 568 568 * @return bool 569 569 */ 570 570 function is_search() { 571 global $wp_query;571 global $wp_query; 572 572 573 573 if ( ! isset( $wp_query ) ) { 574 574 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); … … 597 597 * @return bool 598 598 */ 599 599 function is_single( $post = '' ) { 600 global $wp_query;600 global $wp_query; 601 601 602 602 if ( ! isset( $wp_query ) ) { 603 603 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); … … 624 624 * @return bool 625 625 */ 626 626 function is_singular( $post_types = '' ) { 627 global $wp_query;627 global $wp_query; 628 628 629 629 if ( ! isset( $wp_query ) ) { 630 630 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); … … 644 644 * @return bool 645 645 */ 646 646 function is_time() { 647 global $wp_query;647 global $wp_query; 648 648 649 649 if ( ! isset( $wp_query ) ) { 650 650 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); … … 664 664 * @return bool 665 665 */ 666 666 function is_trackback() { 667 global $wp_query;667 global $wp_query; 668 668 669 669 if ( ! isset( $wp_query ) ) { 670 670 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); … … 730 730 _doing_it_wrong( __FUNCTION__, $message, '3.7' ); 731 731 } 732 732 733 global $wp_query;733 global $wp_query; 734 734 return $wp_query->is_main_query(); 735 735 } 736 736 … … 748 748 * @return bool 749 749 */ 750 750 function have_posts() { 751 global $wp_query;751 global $wp_query; 752 752 return $wp_query->have_posts(); 753 753 } 754 754 … … 762 762 * @return bool True if caller is within loop, false if loop hasn't started or ended. 763 763 */ 764 764 function in_the_loop() { 765 global $wp_query;765 global $wp_query; 766 766 return $wp_query->in_the_loop; 767 767 } 768 768 … … 774 774 * @global WP_Query $wp_query 775 775 */ 776 776 function rewind_posts() { 777 global $wp_query;777 global $wp_query; 778 778 $wp_query->rewind_posts(); 779 779 } 780 780 … … 786 786 * @global WP_Query $wp_query 787 787 */ 788 788 function the_post() { 789 global $wp_query;789 global $wp_query; 790 790 $wp_query->the_post(); 791 791 } 792 792 … … 4704 4704 * @global wpdb $wpdb WordPress database abstraction object. 4705 4705 */ 4706 4706 function wp_old_slug_redirect() { 4707 global $wp_query;4707 global $wp_query; 4708 4708 if ( is_404() && '' != $wp_query->query_vars['name'] ) : 4709 4709 global $wpdb; 4710 4710 … … 4763 4763 * @return bool True when finished. 4764 4764 */ 4765 4765 function setup_postdata( $post ) { 4766 global $wp_query;4766 global $wp_query; 4767 4767 4768 4768 if ( ! empty( $wp_query ) && $wp_query instanceof WP_Query ) { 4769 4769 return $wp_query->setup_postdata( $post ); … … 4771 4771 4772 4772 return false; 4773 4773 } 4774 4775 /** 4776 * Save global post data into an array for later restore. 4777 * 4778 * @since 4.4.0 4779 * 4780 * @return array Values of selected global variables to be restored by restore_postdata(). 4781 */ 4782 function wp_save_postdata() { 4783 4784 global $id, $authordata, $day, $currentmonth, $page, $pages, $multipage, $more, $numpages; 4785 4786 $postdata = array( $id, $authordata, $day, $currentmonth, $page, $pages, $multipage, $more, $numpages ); 4787 4788 return $postdata; 4789 } 4790 4791 /** 4792 * Save global post data into an array for later restore. 4793 * 4794 * @since 4.4.0 4795 * 4796 * @param array Values of selected global variables collected by save_postdata(). 4797 */ 4798 function wp_restore_postdata( $postdata ) { 4799 4800 global $id, $day, $more, $post, $page, $pages, $numpages, $multipage, $authordata, $currentmonth; 4801 4802 list( $id, $authordata, $day, $currentmonth, $page, $pages, $multipage, $more, $numpages ) = $postdata; 4803 4804 }