Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (7 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post-template.php

    r42225 r42343  
    4343    $title = get_the_title();
    4444
    45     if ( strlen($title) == 0 )
     45    if ( strlen( $title ) == 0 ) {
    4646        return;
     47    }
    4748
    4849    $title = $before . $title . $after;
    4950
    50     if ( $echo )
     51    if ( $echo ) {
    5152        echo $title;
    52     else
     53    } else {
    5354        return $title;
     55    }
    5456}
    5557
     
    7779 */
    7880function the_title_attribute( $args = '' ) {
    79     $defaults = array( 'before' => '', 'after' =>  '', 'echo' => true, 'post' => get_post() );
    80     $r = wp_parse_args( $args, $defaults );
     81    $defaults = array(
     82        'before' => '',
     83        'after'  => '',
     84        'echo'   => true,
     85        'post'   => get_post(),
     86    );
     87    $r        = wp_parse_args( $args, $defaults );
    8188
    8289    $title = get_the_title( $r['post'] );
     
    112119
    113120    $title = isset( $post->post_title ) ? $post->post_title : '';
    114     $id = isset( $post->ID ) ? $post->ID : 0;
     121    $id    = isset( $post->ID ) ? $post->ID : 0;
    115122
    116123    if ( ! is_admin() ) {
     
    129136             */
    130137            $protected_title_format = apply_filters( 'protected_title_format', __( 'Protected: %s' ), $post );
    131             $title = sprintf( $protected_title_format, $title );
     138            $title                  = sprintf( $protected_title_format, $title );
    132139        } elseif ( isset( $post->post_status ) && 'private' == $post->post_status ) {
    133140
     
    144151             */
    145152            $private_title_format = apply_filters( 'private_title_format', __( 'Private: %s' ), $post );
    146             $title = sprintf( $private_title_format, $title );
     153            $title                = sprintf( $private_title_format, $title );
    147154        }
    148155    }
     
    228235 * @param bool   $strip_teaser   Optional. Strip teaser content before the more text. Default is false.
    229236 */
    230 function the_content( $more_link_text = null, $strip_teaser = false) {
     237function the_content( $more_link_text = null, $strip_teaser = false ) {
    231238    $content = get_the_content( $more_link_text, $strip_teaser );
    232239
     
    275282    }
    276283
    277     $output = '';
     284    $output     = '';
    278285    $has_teaser = false;
    279286
    280287    // If post password required and it doesn't match the cookie.
    281     if ( post_password_required( $post ) )
     288    if ( post_password_required( $post ) ) {
    282289        return get_the_password_form( $post );
    283 
    284     if ( $page > count( $pages ) ) // if the requested page doesn't exist
     290    }
     291
     292    if ( $page > count( $pages ) ) { // if the requested page doesn't exist
    285293        $page = count( $pages ); // give them the highest numbered page that DOES exist
    286 
    287     $content = $pages[$page - 1];
     294    }
     295
     296    $content = $pages[ $page - 1 ];
    288297    if ( preg_match( '/<!--more(.*?)?-->/', $content, $matches ) ) {
    289298        $content = explode( $matches[0], $content, 2 );
    290         if ( ! empty( $matches[1] ) && ! empty( $more_link_text ) )
     299        if ( ! empty( $matches[1] ) && ! empty( $more_link_text ) ) {
    291300            $more_link_text = strip_tags( wp_kses_no_null( trim( $matches[1] ) ) );
     301        }
    292302
    293303        $has_teaser = true;
     
    296306    }
    297307
    298     if ( false !== strpos( $post->post_content, '<!--noteaser-->' ) && ( ! $multipage || $page == 1 ) )
     308    if ( false !== strpos( $post->post_content, '<!--noteaser-->' ) && ( ! $multipage || $page == 1 ) ) {
    299309        $strip_teaser = true;
     310    }
    300311
    301312    $teaser = $content[0];
    302313
    303     if ( $more && $strip_teaser && $has_teaser )
     314    if ( $more && $strip_teaser && $has_teaser ) {
    304315        $teaser = '';
     316    }
    305317
    306318    $output .= $teaser;
     
    310322            $output .= '<span id="more-' . $post->ID . '"></span>' . $content[1];
    311323        } else {
    312             if ( ! empty( $more_link_text ) )
     324            if ( ! empty( $more_link_text ) ) {
    313325
    314326                /**
     
    321333                 */
    322334                $output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink() . "#more-{$post->ID}\" class=\"more-link\">$more_link_text</a>", $more_link_text );
     335            }
    323336            $output = force_balance_tags( $output );
    324337        }
    325338    }
    326339
    327     if ( $preview ) // Preview fix for JavaScript bug with foreign languages.
    328         $output =   preg_replace_callback( '/\%u([0-9A-F]{4})/', '_convert_urlencoded_to_entities', $output );
     340    if ( $preview ) { // Preview fix for JavaScript bug with foreign languages.
     341        $output = preg_replace_callback( '/\%u([0-9A-F]{4})/', '_convert_urlencoded_to_entities', $output );
     342    }
    329343
    330344    return $output;
     
    408422function has_excerpt( $post = 0 ) {
    409423    $post = get_post( $post );
    410     return ( !empty( $post->post_excerpt ) );
     424    return ( ! empty( $post->post_excerpt ) );
    411425}
    412426
     
    465479
    466480    $classes[] = 'post-' . $post->ID;
    467     if ( ! is_admin() )
     481    if ( ! is_admin() ) {
    468482        $classes[] = $post->post_type;
     483    }
    469484    $classes[] = 'type-' . $post->post_type;
    470485    $classes[] = 'status-' . $post->post_status;
     
    474489        $post_format = get_post_format( $post->ID );
    475490
    476         if ( $post_format && !is_wp_error($post_format) )
     491        if ( $post_format && ! is_wp_error( $post_format ) ) {
    477492            $classes[] = 'format-' . sanitize_html_class( $post_format );
    478         else
     493        } else {
    479494            $classes[] = 'format-standard';
     495        }
    480496    }
    481497
     
    573589    $classes = array();
    574590
    575     if ( is_rtl() )
     591    if ( is_rtl() ) {
    576592        $classes[] = 'rtl';
    577 
    578     if ( is_front_page() )
     593    }
     594
     595    if ( is_front_page() ) {
    579596        $classes[] = 'home';
    580     if ( is_home() )
     597    }
     598    if ( is_home() ) {
    581599        $classes[] = 'blog';
    582     if ( is_archive() )
     600    }
     601    if ( is_archive() ) {
    583602        $classes[] = 'archive';
    584     if ( is_date() )
     603    }
     604    if ( is_date() ) {
    585605        $classes[] = 'date';
     606    }
    586607    if ( is_search() ) {
    587608        $classes[] = 'search';
    588609        $classes[] = $wp_query->posts ? 'search-results' : 'search-no-results';
    589610    }
    590     if ( is_paged() )
     611    if ( is_paged() ) {
    591612        $classes[] = 'paged';
    592     if ( is_attachment() )
     613    }
     614    if ( is_attachment() ) {
    593615        $classes[] = 'attachment';
    594     if ( is_404() )
     616    }
     617    if ( is_404() ) {
    595618        $classes[] = 'error404';
     619    }
    596620
    597621    if ( is_singular() ) {
    598         $post_id = $wp_query->get_queried_object_id();
    599         $post = $wp_query->get_queried_object();
     622        $post_id   = $wp_query->get_queried_object_id();
     623        $post      = $wp_query->get_queried_object();
    600624        $post_type = $post->post_type;
    601625
     
    624648                    $post_format = get_post_format( $post->ID );
    625649
    626                     if ( $post_format && !is_wp_error($post_format) )
     650                    if ( $post_format && ! is_wp_error( $post_format ) ) {
    627651                        $classes[] = 'single-format-' . sanitize_html_class( $post_format );
    628                     else
     652                    } else {
    629653                        $classes[] = 'single-format-standard';
     654                    }
    630655                }
    631656            }
     
    633658
    634659        if ( is_attachment() ) {
    635             $mime_type = get_post_mime_type($post_id);
     660            $mime_type   = get_post_mime_type( $post_id );
    636661            $mime_prefix = array( 'application/', 'image/', 'text/', 'audio/', 'video/', 'music/' );
    637             $classes[] = 'attachmentid-' . $post_id;
    638             $classes[] = 'attachment-' . str_replace( $mime_prefix, '', $mime_type );
     662            $classes[]   = 'attachmentid-' . $post_id;
     663            $classes[]   = 'attachment-' . str_replace( $mime_prefix, '', $mime_type );
    639664        } elseif ( is_page() ) {
    640665            $classes[] = 'page';
     
    642667            $page_id = $wp_query->get_queried_object_id();
    643668
    644             $post = get_post($page_id);
     669            $post = get_post( $page_id );
    645670
    646671            $classes[] = 'page-id-' . $page_id;
    647672
    648             if ( get_pages( array( 'parent' => $page_id, 'number' => 1 ) ) ) {
     673            if ( get_pages(
     674                array(
     675                    'parent' => $page_id,
     676                    'number' => 1,
     677                )
     678            ) ) {
    649679                $classes[] = 'page-parent';
    650680            }
     
    659689            $classes[] = 'post-type-archive';
    660690            $post_type = get_query_var( 'post_type' );
    661             if ( is_array( $post_type ) )
     691            if ( is_array( $post_type ) ) {
    662692                $post_type = reset( $post_type );
     693            }
    663694            $classes[] = 'post-type-archive-' . sanitize_html_class( $post_type );
    664695        } elseif ( is_author() ) {
    665             $author = $wp_query->get_queried_object();
     696            $author    = $wp_query->get_queried_object();
    666697            $classes[] = 'author';
    667698            if ( isset( $author->user_nicename ) ) {
     
    670701            }
    671702        } elseif ( is_category() ) {
    672             $cat = $wp_query->get_queried_object();
     703            $cat       = $wp_query->get_queried_object();
    673704            $classes[] = 'category';
    674705            if ( isset( $cat->term_id ) ) {
     
    682713            }
    683714        } elseif ( is_tag() ) {
    684             $tag = $wp_query->get_queried_object();
     715            $tag       = $wp_query->get_queried_object();
    685716            $classes[] = 'tag';
    686717            if ( isset( $tag->term_id ) ) {
     
    708739    }
    709740
    710     if ( is_user_logged_in() )
     741    if ( is_user_logged_in() ) {
    711742        $classes[] = 'logged-in';
     743    }
    712744
    713745    if ( is_admin_bar_showing() ) {
     
    716748    }
    717749
    718     if ( get_background_color() !== get_theme_support( 'custom-background', 'default-color' ) || get_background_image() )
     750    if ( get_background_color() !== get_theme_support( 'custom-background', 'default-color' ) || get_background_image() ) {
    719751        $classes[] = 'custom-background';
     752    }
    720753
    721754    if ( has_custom_logo() ) {
     
    725758    $page = $wp_query->get( 'page' );
    726759
    727     if ( ! $page || $page < 2 )
     760    if ( ! $page || $page < 2 ) {
    728761        $page = $wp_query->get( 'paged' );
     762    }
    729763
    730764    if ( $page && $page > 1 && ! is_404() ) {
    731765        $classes[] = 'paged-' . $page;
    732766
    733         if ( is_single() )
     767        if ( is_single() ) {
    734768            $classes[] = 'single-paged-' . $page;
    735         elseif ( is_page() )
     769        } elseif ( is_page() ) {
    736770            $classes[] = 'page-paged-' . $page;
    737         elseif ( is_category() )
     771        } elseif ( is_category() ) {
    738772            $classes[] = 'category-paged-' . $page;
    739         elseif ( is_tag() )
     773        } elseif ( is_tag() ) {
    740774            $classes[] = 'tag-paged-' . $page;
    741         elseif ( is_date() )
     775        } elseif ( is_date() ) {
    742776            $classes[] = 'date-paged-' . $page;
    743         elseif ( is_author() )
     777        } elseif ( is_author() ) {
    744778            $classes[] = 'author-paged-' . $page;
    745         elseif ( is_search() )
     779        } elseif ( is_search() ) {
    746780            $classes[] = 'search-paged-' . $page;
    747         elseif ( is_post_type_archive() )
     781        } elseif ( is_post_type_archive() ) {
    748782            $classes[] = 'post-type-paged-' . $page;
     783        }
    749784    }
    750785
    751786    if ( ! empty( $class ) ) {
    752         if ( !is_array( $class ) )
     787        if ( ! is_array( $class ) ) {
    753788            $class = preg_split( '#\s+#', $class );
     789        }
    754790        $classes = array_merge( $classes, $class );
    755791    } else {
     
    782818 */
    783819function post_password_required( $post = null ) {
    784     $post = get_post($post);
     820    $post = get_post( $post );
    785821
    786822    if ( empty( $post->post_password ) ) {
     
    867903        'previouspagelink' => __( 'Previous page' ),
    868904        'pagelink'         => '%',
    869         'echo'             => 1
     905        'echo'             => 1,
    870906    );
    871907
     
    907943        } elseif ( $more ) {
    908944            $output .= $r['before'];
    909             $prev = $page - 1;
     945            $prev    = $page - 1;
    910946            if ( $prev > 0 ) {
    911947                $link = _wp_link_page( $prev ) . $r['link_before'] . $r['previouspagelink'] . $r['link_after'] . '</a>';
     
    957993function _wp_link_page( $i ) {
    958994    global $wp_rewrite;
    959     $post = get_post();
     995    $post       = get_post();
    960996    $query_args = array();
    961997
     
    963999        $url = get_permalink();
    9641000    } else {
    965         if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
     1001        if ( '' == get_option( 'permalink_structure' ) || in_array( $post->post_status, array( 'draft', 'pending' ) ) ) {
    9661002            $url = add_query_arg( 'page', $i, get_permalink() );
    967         elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID )
    968             $url = trailingslashit(get_permalink()) . user_trailingslashit("$wp_rewrite->pagination_base/" . $i, 'single_paged');
    969         else
    970             $url = trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged');
     1003        } elseif ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post->ID ) {
     1004            $url = trailingslashit( get_permalink() ) . user_trailingslashit( "$wp_rewrite->pagination_base/" . $i, 'single_paged' );
     1005        } else {
     1006            $url = trailingslashit( get_permalink() ) . user_trailingslashit( $i, 'single_paged' );
     1007        }
    9711008    }
    9721009
     
    9741011
    9751012        if ( ( 'draft' !== $post->post_status ) && isset( $_GET['preview_id'], $_GET['preview_nonce'] ) ) {
    976             $query_args['preview_id'] = wp_unslash( $_GET['preview_id'] );
     1013            $query_args['preview_id']    = wp_unslash( $_GET['preview_id'] );
    9771014            $query_args['preview_nonce'] = wp_unslash( $_GET['preview_nonce'] );
    9781015        }
     
    9991036    $custom = get_post_custom();
    10001037
    1001     if ( !isset( $custom[$key] ) )
     1038    if ( ! isset( $custom[ $key ] ) ) {
    10021039        return false;
    1003     elseif ( 1 == count($custom[$key]) )
    1004         return $custom[$key][0];
    1005     else
    1006         return $custom[$key];
     1040    } elseif ( 1 == count( $custom[ $key ] ) ) {
     1041        return $custom[ $key ][0];
     1042    } else {
     1043        return $custom[ $key ];
     1044    }
    10071045}
    10081046
     
    10131051 *
    10141052 * @internal This will probably change at some point...
    1015  *
    10161053 */
    10171054function the_meta() {
     
    10251062
    10261063            $values = array_map( 'trim', get_post_custom_values( $key ) );
    1027             $value = implode( $values, ', ' );
    1028 
    1029             $html = sprintf( "<li><span class='post-meta-key'>%s</span> %s</li>\n",
     1064            $value  = implode( $values, ', ' );
     1065
     1066            $html = sprintf(
     1067                "<li><span class='post-meta-key'>%s</span> %s</li>\n",
    10301068                /* translators: %s: Post custom field name */
    10311069                sprintf( _x( '%s:', 'Post custom field name' ), $key ),
     
    10851123function wp_dropdown_pages( $args = '' ) {
    10861124    $defaults = array(
    1087         'depth' => 0, 'child_of' => 0,
    1088         'selected' => 0, 'echo' => 1,
    1089         'name' => 'page_id', 'id' => '',
    1090         'class' => '',
    1091         'show_option_none' => '', 'show_option_no_change' => '',
    1092         'option_none_value' => '',
    1093         'value_field' => 'ID',
     1125        'depth'                 => 0,
     1126        'child_of'              => 0,
     1127        'selected'              => 0,
     1128        'echo'                  => 1,
     1129        'name'                  => 'page_id',
     1130        'id'                    => '',
     1131        'class'                 => '',
     1132        'show_option_none'      => '',
     1133        'show_option_no_change' => '',
     1134        'option_none_value'     => '',
     1135        'value_field'           => 'ID',
    10941136    );
    10951137
    10961138    $r = wp_parse_args( $args, $defaults );
    10971139
    1098     $pages = get_pages( $r );
     1140    $pages  = get_pages( $r );
    10991141    $output = '';
    11001142    // Back-compat with old system where both id and name were based on $name argument
     
    11291171     * @param array  $r      The parsed arguments array.
    11301172     * @param array  $pages  List of WP_Post objects returned by `get_pages()`
    1131      */
     1173     */
    11321174    $html = apply_filters( 'wp_dropdown_pages', $output, $r, $pages );
    11331175
     
    12021244    }
    12031245
    1204     $output = '';
     1246    $output       = '';
    12051247    $current_page = 0;
    12061248
     
    12221264    // Query pages.
    12231265    $r['hierarchical'] = 0;
    1224     $pages = get_pages( $r );
     1266    $pages             = get_pages( $r );
    12251267
    12261268    if ( ! empty( $pages ) ) {
     
    13111353        'walker'       => '',
    13121354    );
    1313     $args = wp_parse_args( $args, $defaults );
     1355    $args     = wp_parse_args( $args, $defaults );
    13141356
    13151357    if ( ! in_array( $args['item_spacing'], array( 'preserve', 'discard' ) ) ) {
     
    13421384
    13431385    // Show Home in the menu
    1344     if ( ! empty($args['show_home']) ) {
    1345         if ( true === $args['show_home'] || '1' === $args['show_home'] || 1 === $args['show_home'] )
    1346             $text = __('Home');
    1347         else
     1386    if ( ! empty( $args['show_home'] ) ) {
     1387        if ( true === $args['show_home'] || '1' === $args['show_home'] || 1 === $args['show_home'] ) {
     1388            $text = __( 'Home' );
     1389        } else {
    13481390            $text = $args['show_home'];
     1391        }
    13491392        $class = '';
    1350         if ( is_front_page() && !is_paged() )
     1393        if ( is_front_page() && ! is_paged() ) {
    13511394            $class = 'class="current_page_item"';
     1395        }
    13521396        $menu .= '<li ' . $class . '><a href="' . home_url( '/' ) . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>';
    13531397        // If the front page is a page, add it to the exclude list
    1354         if (get_option('show_on_front') == 'page') {
    1355             if ( !empty( $list_args['exclude'] ) ) {
     1398        if ( get_option( 'show_on_front' ) == 'page' ) {
     1399            if ( ! empty( $list_args['exclude'] ) ) {
    13561400                $list_args['exclude'] .= ',';
    13571401            } else {
    13581402                $list_args['exclude'] = '';
    13591403            }
    1360             $list_args['exclude'] .= get_option('page_on_front');
    1361         }
    1362     }
    1363 
    1364     $list_args['echo'] = false;
     1404            $list_args['exclude'] .= get_option( 'page_on_front' );
     1405        }
     1406    }
     1407
     1408    $list_args['echo']     = false;
    13651409    $list_args['title_li'] = '';
    1366     $menu .= wp_list_pages( $list_args );
     1410    $menu                 .= wp_list_pages( $list_args );
    13671411
    13681412    $container = sanitize_text_field( $args['container'] );
     
    13801424            'ul' !== $container ) {
    13811425            $args['before'] = "<ul>{$n}";
    1382             $args['after'] = '</ul>';
     1426            $args['after']  = '</ul>';
    13831427        }
    13841428
     
    14081452     */
    14091453    $menu = apply_filters( 'wp_page_menu', $menu, $args );
    1410     if ( $args['echo'] )
     1454    if ( $args['echo'] ) {
    14111455        echo $menu;
    1412     else
     1456    } else {
    14131457        return $menu;
     1458    }
    14141459}
    14151460
     
    14311476 */
    14321477function walk_page_tree( $pages, $depth, $current_page, $r ) {
    1433     if ( empty($r['walker']) )
     1478    if ( empty( $r['walker'] ) ) {
    14341479        $walker = new Walker_Page;
    1435     else
     1480    } else {
    14361481        $walker = $r['walker'];
     1482    }
    14371483
    14381484    foreach ( (array) $pages as $page ) {
    1439         if ( $page->post_parent )
     1485        if ( $page->post_parent ) {
    14401486            $r['pages_with_children'][ $page->post_parent ] = true;
    1441     }
    1442 
    1443     $args = array($pages, $depth, $r, $current_page);
    1444     return call_user_func_array(array($walker, 'walk'), $args);
     1487        }
     1488    }
     1489
     1490    $args = array( $pages, $depth, $r, $current_page );
     1491    return call_user_func_array( array( $walker, 'walk' ), $args );
    14451492}
    14461493
     
    14561503function walk_page_dropdown_tree() {
    14571504    $args = func_get_args();
    1458     if ( empty($args[2]['walker']) ) // the user's options are the third parameter
     1505    if ( empty( $args[2]['walker'] ) ) { // the user's options are the third parameter
    14591506        $walker = new Walker_PageDropdown;
    1460     else
     1507    } else {
    14611508        $walker = $args[2]['walker'];
    1462 
    1463     return call_user_func_array(array($walker, 'walk'), $args);
     1509    }
     1510
     1511    return call_user_func_array( array( $walker, 'walk' ), $args );
    14641512}
    14651513
     
    14791527 */
    14801528function the_attachment_link( $id = 0, $fullsize = false, $deprecated = false, $permalink = false ) {
    1481     if ( !empty( $deprecated ) )
     1529    if ( ! empty( $deprecated ) ) {
    14821530        _deprecated_argument( __FUNCTION__, '2.5.0' );
    1483 
    1484     if ( $fullsize )
    1485         echo wp_get_attachment_link($id, 'full', $permalink);
    1486     else
    1487         echo wp_get_attachment_link($id, 'thumbnail', $permalink);
     1531    }
     1532
     1533    if ( $fullsize ) {
     1534        echo wp_get_attachment_link( $id, 'full', $permalink );
     1535    } else {
     1536        echo wp_get_attachment_link( $id, 'thumbnail', $permalink );
     1537    }
    14881538}
    14891539
     
    15551605 * @return string
    15561606 */
    1557 function prepend_attachment($content) {
     1607function prepend_attachment( $content ) {
    15581608    $post = get_post();
    15591609
    1560     if ( empty($post->post_type) || $post->post_type != 'attachment' )
     1610    if ( empty( $post->post_type ) || $post->post_type != 'attachment' ) {
    15611611        return $content;
     1612    }
    15621613
    15631614    if ( wp_attachment_is( 'video', $post ) ) {
     
    15651616        $atts = array( 'src' => wp_get_attachment_url() );
    15661617        if ( ! empty( $meta['width'] ) && ! empty( $meta['height'] ) ) {
    1567             $atts['width'] = (int) $meta['width'];
     1618            $atts['width']  = (int) $meta['width'];
    15681619            $atts['height'] = (int) $meta['height'];
    15691620        }
     
    15771628        $p = '<p class="attachment">';
    15781629        // show the medium sized image representation of the attachment if available, and link to the raw file
    1579         $p .= wp_get_attachment_link(0, 'medium', false);
     1630        $p .= wp_get_attachment_link( 0, 'medium', false );
    15801631        $p .= '</p>';
    15811632    }
     
    16081659 */
    16091660function get_the_password_form( $post = 0 ) {
    1610     $post = get_post( $post );
    1611     $label = 'pwbox-' . ( empty($post->ID) ? rand() : $post->ID );
     1661    $post   = get_post( $post );
     1662    $label  = 'pwbox-' . ( empty( $post->ID ) ? rand() : $post->ID );
    16121663    $output = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" class="post-password-form" method="post">
    16131664    <p>' . __( 'This content is password protected. To view it please enter your password below:' ) . '</p>
     
    16501701    $page_template = get_page_template_slug( get_queried_object_id() );
    16511702
    1652     if ( empty( $template ) )
     1703    if ( empty( $template ) ) {
    16531704        return (bool) $page_template;
    1654 
    1655     if ( $template == $page_template )
     1705    }
     1706
     1707    if ( $template == $page_template ) {
    16561708        return true;
     1709    }
    16571710
    16581711    if ( is_array( $template ) ) {
     
    16751728 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
    16761729 * @return string|false Page template filename. Returns an empty string when the default page template
    1677  *  is in use. Returns false if the post does not exist.
     1730 *  is in use. Returns false if the post does not exist.
    16781731 */
    16791732function get_page_template_slug( $post = null ) {
     
    17031756 */
    17041757function wp_post_revision_title( $revision, $link = true ) {
    1705     if ( !$revision = get_post( $revision ) )
     1758    if ( ! $revision = get_post( $revision ) ) {
    17061759        return $revision;
    1707 
    1708     if ( !in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) )
     1760    }
     1761
     1762    if ( ! in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) ) {
    17091763        return false;
     1764    }
    17101765
    17111766    /* translators: revision date format, see https://secure.php.net/date */
     
    17141769    $autosavef = __( '%s [Autosave]' );
    17151770    /* translators: %s: revision date */
    1716     $currentf  = __( '%s [Current Revision]' );
     1771    $currentf = __( '%s [Current Revision]' );
    17171772
    17181773    $date = date_i18n( $datef, strtotime( $revision->post_modified ) );
    1719     if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) )
     1774    if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) ) {
    17201775        $date = "<a href='$link'>$date</a>";
    1721 
    1722     if ( !wp_is_post_revision( $revision ) )
     1776    }
     1777
     1778    if ( ! wp_is_post_revision( $revision ) ) {
    17231779        $date = sprintf( $currentf, $date );
    1724     elseif ( wp_is_post_autosave( $revision ) )
     1780    } elseif ( wp_is_post_autosave( $revision ) ) {
    17251781        $date = sprintf( $autosavef, $date );
     1782    }
    17261783
    17271784    return $date;
     
    17381795 */
    17391796function wp_post_revision_title_expanded( $revision, $link = true ) {
    1740     if ( !$revision = get_post( $revision ) )
     1797    if ( ! $revision = get_post( $revision ) ) {
    17411798        return $revision;
    1742 
    1743     if ( !in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) )
     1799    }
     1800
     1801    if ( ! in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) ) {
    17441802        return false;
     1803    }
    17451804
    17461805    $author = get_the_author_meta( 'display_name', $revision->post_author );
     
    17511810
    17521811    $date = date_i18n( $datef, strtotime( $revision->post_modified ) );
    1753     if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) )
     1812    if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) ) {
    17541813        $date = "<a href='$link'>$date</a>";
     1814    }
    17551815
    17561816    $revision_date_author = sprintf(
     
    17661826    $autosavef = __( '%s [Autosave]' );
    17671827    /* translators: %s: revision date with author avatar */
    1768     $currentf  = __( '%s [Current Revision]' );
    1769 
    1770     if ( !wp_is_post_revision( $revision ) )
     1828    $currentf = __( '%s [Current Revision]' );
     1829
     1830    if ( ! wp_is_post_revision( $revision ) ) {
    17711831        $revision_date_author = sprintf( $currentf, $revision_date_author );
    1772     elseif ( wp_is_post_autosave( $revision ) )
     1832    } elseif ( wp_is_post_autosave( $revision ) ) {
    17731833        $revision_date_author = sprintf( $autosavef, $revision_date_author );
     1834    }
    17741835
    17751836    /**
     
    17981859 */
    17991860function wp_list_post_revisions( $post_id = 0, $type = 'all' ) {
    1800     if ( ! $post = get_post( $post_id ) )
     1861    if ( ! $post = get_post( $post_id ) ) {
    18011862        return;
     1863    }
    18021864
    18031865    // $args array with (parent, format, right, left, type) deprecated since 3.6
    18041866    if ( is_array( $type ) ) {
    1805         $type = ! empty( $type['type'] ) ? $type['type']  : $type;
     1867        $type = ! empty( $type['type'] ) ? $type['type'] : $type;
    18061868        _deprecated_argument( __FUNCTION__, '3.6.0' );
    18071869    }
    18081870
    1809     if ( ! $revisions = wp_get_post_revisions( $post->ID ) )
     1871    if ( ! $revisions = wp_get_post_revisions( $post->ID ) ) {
    18101872        return;
     1873    }
    18111874
    18121875    $rows = '';
    18131876    foreach ( $revisions as $revision ) {
    1814         if ( ! current_user_can( 'read_post', $revision->ID ) )
     1877        if ( ! current_user_can( 'read_post', $revision->ID ) ) {
    18151878            continue;
     1879        }
    18161880
    18171881        $is_autosave = wp_is_post_autosave( $revision );
    1818         if ( ( 'revision' === $type && $is_autosave ) || ( 'autosave' === $type && ! $is_autosave ) )
     1882        if ( ( 'revision' === $type && $is_autosave ) || ( 'autosave' === $type && ! $is_autosave ) ) {
    18191883            continue;
     1884        }
    18201885
    18211886        $rows .= "\t<li>" . wp_post_revision_title_expanded( $revision ) . "</li>\n";
     
    18261891    echo "<ul class='post-revisions hide-if-no-js'>\n";
    18271892    echo $rows;
    1828     echo "</ul>";
    1829 }
     1893    echo '</ul>';
     1894}
Note: See TracChangeset for help on using the changeset viewer.