WordPress.org

Make WordPress Core

Ticket #12976: refresh-12976-2015-09-01.diff

File refresh-12976-2015-09-01.diff, 12.6 KB (added by MikeSchinkel, 6 years ago)

Refreshed patch

  • wp-includes/revision.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    667667
    668668        return true;
    669669}
     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 */
     688function 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 */
     722function 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
     
    2323 * @return mixed
    2424 */
    2525function get_query_var( $var, $default = '' ) {
    26         global $wp_query;
     26                global $wp_query;
    2727        return $wp_query->get( $var, $default );
    2828}
    2929
     
    3838 * @return object
    3939 */
    4040function get_queried_object() {
    41         global $wp_query;
     41                global $wp_query;
    4242        return $wp_query->get_queried_object();
    4343}
    4444
     
    5353 * @return int
    5454 */
    5555function get_queried_object_id() {
    56         global $wp_query;
     56                global $wp_query;
    5757        return $wp_query->get_queried_object_id();
    5858}
    5959
     
    6868 * @param mixed  $value
    6969 */
    7070function set_query_var( $var, $value ) {
    71         global $wp_query;
     71                global $wp_query;
    7272        $wp_query->set( $var, $value );
    7373}
    7474
     
    116116 * @global WP_Query $wp_query
    117117 */
    118118function wp_reset_postdata() {
    119         global $wp_query;
     119                global $wp_query;
    120120
    121121        if ( isset( $wp_query ) ) {
    122122                $wp_query->reset_postdata();
     
    139139 * @return bool
    140140 */
    141141function is_archive() {
    142         global $wp_query;
     142                global $wp_query;
    143143
    144144        if ( ! isset( $wp_query ) ) {
    145145                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
     
    160160 * @return bool
    161161 */
    162162function is_post_type_archive( $post_types = '' ) {
    163         global $wp_query;
     163                global $wp_query;
    164164
    165165        if ( ! isset( $wp_query ) ) {
    166166                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
     
    181181 * @return bool
    182182 */
    183183function is_attachment( $attachment = '' ) {
    184         global $wp_query;
     184                global $wp_query;
    185185
    186186        if ( ! isset( $wp_query ) ) {
    187187                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
     
    205205 * @return bool
    206206 */
    207207function is_author( $author = '' ) {
    208         global $wp_query;
     208                global $wp_query;
    209209
    210210        if ( ! isset( $wp_query ) ) {
    211211                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
     
    229229 * @return bool
    230230 */
    231231function is_category( $category = '' ) {
    232         global $wp_query;
     232                global $wp_query;
    233233
    234234        if ( ! isset( $wp_query ) ) {
    235235                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
     
    253253 * @return bool
    254254 */
    255255function is_tag( $tag = '' ) {
    256         global $wp_query;
     256                global $wp_query;
    257257
    258258        if ( ! isset( $wp_query ) ) {
    259259                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
     
    282282 * @return bool
    283283 */
    284284function is_tax( $taxonomy = '', $term = '' ) {
    285         global $wp_query;
     285                global $wp_query;
    286286
    287287        if ( ! isset( $wp_query ) ) {
    288288                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
     
    302302 * @return bool
    303303 */
    304304function is_comments_popup() {
    305         global $wp_query;
     305                global $wp_query;
    306306
    307307        if ( ! isset( $wp_query ) ) {
    308308                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
     
    322322 * @return bool
    323323 */
    324324function is_date() {
    325         global $wp_query;
     325                global $wp_query;
    326326
    327327        if ( ! isset( $wp_query ) ) {
    328328                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
     
    342342 * @return bool
    343343 */
    344344function is_day() {
    345         global $wp_query;
     345                global $wp_query;
    346346
    347347        if ( ! isset( $wp_query ) ) {
    348348                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
     
    363363 * @return bool
    364364 */
    365365function is_feed( $feeds = '' ) {
    366         global $wp_query;
     366                global $wp_query;
    367367
    368368        if ( ! isset( $wp_query ) ) {
    369369                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
     
    383383 * @return bool
    384384 */
    385385function is_comment_feed() {
    386         global $wp_query;
     386                global $wp_query;
    387387
    388388        if ( ! isset( $wp_query ) ) {
    389389                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
     
    412412 * @return bool True, if front of site.
    413413 */
    414414function is_front_page() {
    415         global $wp_query;
     415                global $wp_query;
    416416
    417417        if ( ! isset( $wp_query ) ) {
    418418                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
     
    441441 * @return bool True if blog view homepage.
    442442 */
    443443function is_home() {
    444         global $wp_query;
     444                global $wp_query;
    445445
    446446        if ( ! isset( $wp_query ) ) {
    447447                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
     
    461461 * @return bool
    462462 */
    463463function is_month() {
    464         global $wp_query;
     464                global $wp_query;
    465465
    466466        if ( ! isset( $wp_query ) ) {
    467467                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
     
    488488 * @return bool
    489489 */
    490490function is_page( $page = '' ) {
    491         global $wp_query;
     491                global $wp_query;
    492492
    493493        if ( ! isset( $wp_query ) ) {
    494494                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
     
    508508 * @return bool
    509509 */
    510510function is_paged() {
    511         global $wp_query;
     511                global $wp_query;
    512512
    513513        if ( ! isset( $wp_query ) ) {
    514514                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
     
    528528 * @return bool
    529529 */
    530530function is_preview() {
    531         global $wp_query;
     531                global $wp_query;
    532532
    533533        if ( ! isset( $wp_query ) ) {
    534534                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
     
    548548 * @return bool
    549549 */
    550550function is_robots() {
    551         global $wp_query;
     551                global $wp_query;
    552552
    553553        if ( ! isset( $wp_query ) ) {
    554554                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
     
    568568 * @return bool
    569569 */
    570570function is_search() {
    571         global $wp_query;
     571                global $wp_query;
    572572
    573573        if ( ! isset( $wp_query ) ) {
    574574                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
     
    597597 * @return bool
    598598 */
    599599function is_single( $post = '' ) {
    600         global $wp_query;
     600                global $wp_query;
    601601
    602602        if ( ! isset( $wp_query ) ) {
    603603                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
     
    624624 * @return bool
    625625 */
    626626function is_singular( $post_types = '' ) {
    627         global $wp_query;
     627                global $wp_query;
    628628
    629629        if ( ! isset( $wp_query ) ) {
    630630                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
     
    644644 * @return bool
    645645 */
    646646function is_time() {
    647         global $wp_query;
     647                global $wp_query;
    648648
    649649        if ( ! isset( $wp_query ) ) {
    650650                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
     
    664664 * @return bool
    665665 */
    666666function is_trackback() {
    667         global $wp_query;
     667                global $wp_query;
    668668
    669669        if ( ! isset( $wp_query ) ) {
    670670                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
     
    730730                _doing_it_wrong( __FUNCTION__, $message, '3.7' );
    731731        }
    732732
    733         global $wp_query;
     733                global $wp_query;
    734734        return $wp_query->is_main_query();
    735735}
    736736
     
    748748 * @return bool
    749749 */
    750750function have_posts() {
    751         global $wp_query;
     751                global $wp_query;
    752752        return $wp_query->have_posts();
    753753}
    754754
     
    762762 * @return bool True if caller is within loop, false if loop hasn't started or ended.
    763763 */
    764764function in_the_loop() {
    765         global $wp_query;
     765                global $wp_query;
    766766        return $wp_query->in_the_loop;
    767767}
    768768
     
    774774 * @global WP_Query $wp_query
    775775 */
    776776function rewind_posts() {
    777         global $wp_query;
     777                global $wp_query;
    778778        $wp_query->rewind_posts();
    779779}
    780780
     
    786786 * @global WP_Query $wp_query
    787787 */
    788788function the_post() {
    789         global $wp_query;
     789                global $wp_query;
    790790        $wp_query->the_post();
    791791}
    792792
     
    47044704 * @global wpdb     $wpdb     WordPress database abstraction object.
    47054705 */
    47064706function wp_old_slug_redirect() {
    4707         global $wp_query;
     4707                global $wp_query;
    47084708        if ( is_404() && '' != $wp_query->query_vars['name'] ) :
    47094709                global $wpdb;
    47104710
     
    47634763 * @return bool True when finished.
    47644764 */
    47654765function setup_postdata( $post ) {
    4766         global $wp_query;
     4766                global $wp_query;
    47674767
    47684768        if ( ! empty( $wp_query ) && $wp_query instanceof WP_Query ) {
    47694769                return $wp_query->setup_postdata( $post );
     
    47714771
    47724772        return false;
    47734773}
     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 */
     4782function 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 */
     4798function 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}