Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (9 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/link-template.php

    r42228 r42343  
    4545 * @return string The URL with the trailing slash appended or stripped.
    4646 */
    47 function user_trailingslashit($string, $type_of_url = '') {
     47function user_trailingslashit( $string, $type_of_url = '' ) {
    4848        global $wp_rewrite;
    49         if ( $wp_rewrite->use_trailing_slashes )
    50                 $string = trailingslashit($string);
    51         else
    52                 $string = untrailingslashit($string);
     49        if ( $wp_rewrite->use_trailing_slashes ) {
     50                $string = trailingslashit( $string );
     51        } else {
     52                $string = untrailingslashit( $string );
     53        }
    5354
    5455        /**
    … …  
    8081                case 'title':
    8182                        $title = sanitize_title( $post->post_title ) . '-' . $post->ID;
    82                         echo '<a id="'.$title.'"></a>';
     83                        echo '<a id="' . $title . '"></a>';
    8384                        break;
    8485                case 'id':
    … …  
    124125                '%minute%',
    125126                '%second%',
    126                 $leavename? '' : '%postname%',
     127                $leavename ? '' : '%postname%',
    127128                '%post_id%',
    128129                '%category%',
    129130                '%author%',
    130                 $leavename? '' : '%pagename%',
     131                $leavename ? '' : '%pagename%',
    131132        );
    132133
    … …  
    134135                $sample = true;
    135136        } else {
    136                 $post = get_post( $post );
     137                $post   = get_post( $post );
    137138                $sample = false;
    138139        }
    139140
    140         if ( empty($post->ID) )
     141        if ( empty( $post->ID ) ) {
    141142                return false;
    142 
    143         if ( $post->post_type == 'page' )
    144                 return get_page_link($post, $leavename, $sample);
    145         elseif ( $post->post_type == 'attachment' )
     143        }
     144
     145        if ( $post->post_type == 'page' ) {
     146                return get_page_link( $post, $leavename, $sample );
     147        } elseif ( $post->post_type == 'attachment' ) {
    146148                return get_attachment_link( $post, $leavename );
    147         elseif ( in_array($post->post_type, get_post_types( array('_builtin' => false) ) ) )
    148                 return get_post_permalink($post, $leavename, $sample);
    149 
    150         $permalink = get_option('permalink_structure');
     149        } elseif ( in_array( $post->post_type, get_post_types( array( '_builtin' => false ) ) ) ) {
     150                return get_post_permalink( $post, $leavename, $sample );
     151        }
     152
     153        $permalink = get_option( 'permalink_structure' );
    151154
    152155        /**
    … …  
    163166        $permalink = apply_filters( 'pre_post_link', $permalink, $post, $leavename );
    164167
    165         if ( '' != $permalink && !in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft', 'future' ) ) ) {
    166                 $unixtime = strtotime($post->post_date);
     168        if ( '' != $permalink && ! in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft', 'future' ) ) ) {
     169                $unixtime = strtotime( $post->post_date );
    167170
    168171                $category = '';
    169                 if ( strpos($permalink, '%category%') !== false ) {
    170                         $cats = get_the_category($post->ID);
     172                if ( strpos( $permalink, '%category%' ) !== false ) {
     173                        $cats = get_the_category( $post->ID );
    171174                        if ( $cats ) {
    172                                 $cats = wp_list_sort( $cats, array(
    173                                         'term_id' => 'ASC',
    174                                 ) );
     175                                $cats = wp_list_sort(
     176                                        $cats, array(
     177                                                'term_id' => 'ASC',
     178                                        )
     179                                );
    175180
    176181                                /**
    … …  
    186191
    187192                                $category_object = get_term( $category_object, 'category' );
    188                                 $category = $category_object->slug;
    189                                 if ( $parent = $category_object->parent )
    190                                         $category = get_category_parents($parent, false, '/', true) . $category;
     193                                $category        = $category_object->slug;
     194                                if ( $parent = $category_object->parent ) {
     195                                        $category = get_category_parents( $parent, false, '/', true ) . $category;
     196                                }
    191197                        }
    192198                        // show default category in permalinks, without
    193199                        // having to assign it explicitly
    194                         if ( empty($category) ) {
     200                        if ( empty( $category ) ) {
    195201                                $default_category = get_term( get_option( 'default_category' ), 'category' );
    196202                                if ( $default_category && ! is_wp_error( $default_category ) ) {
    … …  
    201207
    202208                $author = '';
    203                 if ( strpos($permalink, '%author%') !== false ) {
    204                         $authordata = get_userdata($post->post_author);
    205                         $author = $authordata->user_nicename;
    206                 }
    207 
    208                 $date = explode(" ",date('Y m d H i s', $unixtime));
     209                if ( strpos( $permalink, '%author%' ) !== false ) {
     210                        $authordata = get_userdata( $post->post_author );
     211                        $author     = $authordata->user_nicename;
     212                }
     213
     214                $date           = explode( ' ', date( 'Y m d H i s', $unixtime ) );
    209215                $rewritereplace =
    210216                array(
    … …  
    221227                        $post->post_name,
    222228                );
    223                 $permalink = home_url( str_replace($rewritecode, $rewritereplace, $permalink) );
    224                 $permalink = user_trailingslashit($permalink, 'single');
     229                $permalink      = home_url( str_replace( $rewritecode, $rewritereplace, $permalink ) );
     230                $permalink      = user_trailingslashit( $permalink, 'single' );
    225231        } else { // if they're not using the fancy permalink option
    226                 $permalink = home_url('?p=' . $post->ID);
     232                $permalink = home_url( '?p=' . $post->ID );
    227233        }
    228234
    … …  
    256262        global $wp_rewrite;
    257263
    258         $post = get_post($id);
    259 
    260         if ( is_wp_error( $post ) )
     264        $post = get_post( $id );
     265
     266        if ( is_wp_error( $post ) ) {
    261267                return $post;
    262 
    263         $post_link = $wp_rewrite->get_extra_permastruct($post->post_type);
     268        }
     269
     270        $post_link = $wp_rewrite->get_extra_permastruct( $post->post_type );
    264271
    265272        $slug = $post->post_name;
    … …  
    267274        $draft_or_pending = get_post_status( $post ) && in_array( get_post_status( $post ), array( 'draft', 'pending', 'auto-draft', 'future' ) );
    268275
    269         $post_type = get_post_type_object($post->post_type);
     276        $post_type = get_post_type_object( $post->post_type );
    270277
    271278        if ( $post_type->hierarchical ) {
    … …  
    273280        }
    274281
    275         if ( !empty($post_link) && ( !$draft_or_pending || $sample ) ) {
     282        if ( ! empty( $post_link ) && ( ! $draft_or_pending || $sample ) ) {
    276283                if ( ! $leavename ) {
    277                         $post_link = str_replace("%$post->post_type%", $slug, $post_link);
    278                 }
    279                 $post_link = home_url( user_trailingslashit($post_link) );
    280         } else {
    281                 if ( $post_type->query_var && ( isset($post->post_status) && !$draft_or_pending ) )
    282                         $post_link = add_query_arg($post_type->query_var, $slug, '');
    283                 else
    284                         $post_link = add_query_arg(array('post_type' => $post->post_type, 'p' => $post->ID), '');
    285                 $post_link = home_url($post_link);
     284                        $post_link = str_replace( "%$post->post_type%", $slug, $post_link );
     285                }
     286                $post_link = home_url( user_trailingslashit( $post_link ) );
     287        } else {
     288                if ( $post_type->query_var && ( isset( $post->post_status ) && ! $draft_or_pending ) ) {
     289                        $post_link = add_query_arg( $post_type->query_var, $slug, '' );
     290                } else {
     291                        $post_link = add_query_arg(
     292                                array(
     293                                        'post_type' => $post->post_type,
     294                                        'p'         => $post->ID,
     295                                ), ''
     296                        );
     297                }
     298                $post_link = home_url( $post_link );
    286299        }
    287300
    … …  
    315328        $post = get_post( $post );
    316329
    317         if ( 'page' == get_option( 'show_on_front' ) && $post->ID == get_option( 'page_on_front' ) )
    318                 $link = home_url('/');
    319         else
     330        if ( 'page' == get_option( 'show_on_front' ) && $post->ID == get_option( 'page_on_front' ) ) {
     331                $link = home_url( '/' );
     332        } else {
    320333                $link = _get_page_link( $post, $leavename, $sample );
     334        }
    321335
    322336        /**
    … …  
    357371        $link = $wp_rewrite->get_page_permastruct();
    358372
    359         if ( !empty($link) && ( ( isset($post->post_status) && !$draft_or_pending ) || $sample ) ) {
     373        if ( ! empty( $link ) && ( ( isset( $post->post_status ) && ! $draft_or_pending ) || $sample ) ) {
    360374                if ( ! $leavename ) {
    361                         $link = str_replace('%pagename%', get_page_uri( $post ), $link);
    362                 }
    363 
    364                 $link = home_url($link);
    365                 $link = user_trailingslashit($link, 'page');
     375                        $link = str_replace( '%pagename%', get_page_uri( $post ), $link );
     376                }
     377
     378                $link = home_url( $link );
     379                $link = user_trailingslashit( $link, 'page' );
    366380        } else {
    367381                $link = home_url( '?page_id=' . $post->ID );
    … …  
    397411        $link = false;
    398412
    399         $post = get_post( $post );
     413        $post   = get_post( $post );
    400414        $parent = ( $post->post_parent > 0 && $post->post_parent != $post->ID ) ? get_post( $post->post_parent ) : false;
    401415        if ( $parent && ! in_array( $parent->post_type, get_post_types() ) ) {
    … …  
    404418
    405419        if ( $wp_rewrite->using_permalinks() && $parent ) {
    406                 if ( 'page' == $parent->post_type )
     420                if ( 'page' == $parent->post_type ) {
    407421                        $parentlink = _get_page_link( $post->post_parent ); // Ignores page_on_front
    408                 else
     422                } else {
    409423                        $parentlink = get_permalink( $post->post_parent );
    410 
    411                 if ( is_numeric($post->post_name) || false !== strpos(get_option('permalink_structure'), '%category%') )
     424                }
     425
     426                if ( is_numeric( $post->post_name ) || false !== strpos( get_option( 'permalink_structure' ), '%category%' ) ) {
    412427                        $name = 'attachment/' . $post->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker
    413                 else
     428                } else {
    414429                        $name = $post->post_name;
    415 
    416                 if ( strpos($parentlink, '?') === false )
    417                         $link = user_trailingslashit( trailingslashit($parentlink) . '%postname%' );
    418 
    419                 if ( ! $leavename )
     430                }
     431
     432                if ( strpos( $parentlink, '?' ) === false ) {
     433                        $link = user_trailingslashit( trailingslashit( $parentlink ) . '%postname%' );
     434                }
     435
     436                if ( ! $leavename ) {
    420437                        $link = str_replace( '%postname%', $name, $link );
     438                }
    421439        } elseif ( $wp_rewrite->using_permalinks() && ! $leavename ) {
    422440                $link = home_url( user_trailingslashit( $post->post_name ) );
    423441        }
    424442
    425         if ( ! $link )
     443        if ( ! $link ) {
    426444                $link = home_url( '/?attachment_id=' . $post->ID );
     445        }
    427446
    428447        /**
    … …  
    449468function get_year_link( $year ) {
    450469        global $wp_rewrite;
    451         if ( !$year )
    452                 $year = gmdate('Y', current_time('timestamp'));
     470        if ( ! $year ) {
     471                $year = gmdate( 'Y', current_time( 'timestamp' ) );
     472        }
    453473        $yearlink = $wp_rewrite->get_year_permastruct();
    454         if ( !empty($yearlink) ) {
    455                 $yearlink = str_replace('%year%', $year, $yearlink);
     474        if ( ! empty( $yearlink ) ) {
     475                $yearlink = str_replace( '%year%', $year, $yearlink );
    456476                $yearlink = home_url( user_trailingslashit( $yearlink, 'year' ) );
    457477        } else {
    … …  
    481501 * @return string The permalink for the specified month and year archive.
    482502 */
    483 function get_month_link($year, $month) {
     503function get_month_link( $year, $month ) {
    484504        global $wp_rewrite;
    485         if ( !$year )
    486                 $year = gmdate('Y', current_time('timestamp'));
    487         if ( !$month )
    488                 $month = gmdate('m', current_time('timestamp'));
     505        if ( ! $year ) {
     506                $year = gmdate( 'Y', current_time( 'timestamp' ) );
     507        }
     508        if ( ! $month ) {
     509                $month = gmdate( 'm', current_time( 'timestamp' ) );
     510        }
    489511        $monthlink = $wp_rewrite->get_month_permastruct();
    490         if ( !empty($monthlink) ) {
    491                 $monthlink = str_replace('%year%', $year, $monthlink);
    492                 $monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink);
     512        if ( ! empty( $monthlink ) ) {
     513                $monthlink = str_replace( '%year%', $year, $monthlink );
     514                $monthlink = str_replace( '%monthnum%', zeroise( intval( $month ), 2 ), $monthlink );
    493515                $monthlink = home_url( user_trailingslashit( $monthlink, 'month' ) );
    494516        } else {
    … …  
    520542 * @return string The permalink for the specified day, month, and year archive.
    521543 */
    522 function get_day_link($year, $month, $day) {
     544function get_day_link( $year, $month, $day ) {
    523545        global $wp_rewrite;
    524         if ( !$year )
    525                 $year = gmdate('Y', current_time('timestamp'));
    526         if ( !$month )
    527                 $month = gmdate('m', current_time('timestamp'));
    528         if ( !$day )
    529                 $day = gmdate('j', current_time('timestamp'));
     546        if ( ! $year ) {
     547                $year = gmdate( 'Y', current_time( 'timestamp' ) );
     548        }
     549        if ( ! $month ) {
     550                $month = gmdate( 'm', current_time( 'timestamp' ) );
     551        }
     552        if ( ! $day ) {
     553                $day = gmdate( 'j', current_time( 'timestamp' ) );
     554        }
    530555
    531556        $daylink = $wp_rewrite->get_day_permastruct();
    532         if ( !empty($daylink) ) {
    533                 $daylink = str_replace('%year%', $year, $daylink);
    534                 $daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink);
    535                 $daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink);
     557        if ( ! empty( $daylink ) ) {
     558                $daylink = str_replace( '%year%', $year, $daylink );
     559                $daylink = str_replace( '%monthnum%', zeroise( intval( $month ), 2 ), $daylink );
     560                $daylink = str_replace( '%day%', zeroise( intval( $day ), 2 ), $daylink );
    536561                $daylink = home_url( user_trailingslashit( $daylink, 'day' ) );
    537562        } else {
    … …  
    590615        $permalink = $wp_rewrite->get_feed_permastruct();
    591616        if ( '' != $permalink ) {
    592                 if ( false !== strpos($feed, 'comments_') ) {
    593                         $feed = str_replace('comments_', '', $feed);
     617                if ( false !== strpos( $feed, 'comments_' ) ) {
     618                        $feed      = str_replace( 'comments_', '', $feed );
    594619                        $permalink = $wp_rewrite->get_comment_feed_permastruct();
    595620                }
    596621
    597                 if ( get_default_feed() == $feed )
     622                if ( get_default_feed() == $feed ) {
    598623                        $feed = '';
    599 
    600                 $permalink = str_replace('%feed%', $feed, $permalink);
    601                 $permalink = preg_replace('#/+#', '/', "/$permalink");
    602                 $output =  home_url( user_trailingslashit($permalink, 'feed') );
    603         } else {
    604                 if ( empty($feed) )
     624                }
     625
     626                $permalink = str_replace( '%feed%', $feed, $permalink );
     627                $permalink = preg_replace( '#/+#', '/', "/$permalink" );
     628                $output    = home_url( user_trailingslashit( $permalink, 'feed' ) );
     629        } else {
     630                if ( empty( $feed ) ) {
    605631                        $feed = get_default_feed();
    606 
    607                 if ( false !== strpos($feed, 'comments_') )
    608                         $feed = str_replace('comments_', 'comments-', $feed);
    609 
    610                 $output = home_url("?feed={$feed}");
     632                }
     633
     634                if ( false !== strpos( $feed, 'comments_' ) ) {
     635                        $feed = str_replace( 'comments_', 'comments-', $feed );
     636                }
     637
     638                $output = home_url( "?feed={$feed}" );
    611639        }
    612640
    … …  
    634662        $post_id = absint( $post_id );
    635663
    636         if ( ! $post_id )
     664        if ( ! $post_id ) {
    637665                $post_id = get_the_ID();
    638 
    639         if ( empty( $feed ) )
     666        }
     667
     668        if ( empty( $feed ) ) {
    640669                $feed = get_default_feed();
    641 
    642         $post = get_post( $post_id );
     670        }
     671
     672        $post       = get_post( $post_id );
    643673        $unattached = 'attachment' === $post->post_type && 0 === (int) $post->post_parent;
    644674
    645         if ( '' != get_option('permalink_structure') ) {
    646                 if ( 'page' == get_option('show_on_front') && $post_id == get_option('page_on_front') )
     675        if ( '' != get_option( 'permalink_structure' ) ) {
     676                if ( 'page' == get_option( 'show_on_front' ) && $post_id == get_option( 'page_on_front' ) ) {
    647677                        $url = _get_page_link( $post_id );
    648                 else
    649                         $url = get_permalink($post_id);
     678                } else {
     679                        $url = get_permalink( $post_id );
     680                }
    650681
    651682                if ( $unattached ) {
    652                         $url =  home_url( '/feed/' );
     683                        $url = home_url( '/feed/' );
    653684                        if ( $feed !== get_default_feed() ) {
    654685                                $url .= "$feed/";
    … …  
    656687                        $url = add_query_arg( 'attachment_id', $post_id, $url );
    657688                } else {
    658                         $url = trailingslashit($url) . 'feed';
    659                         if ( $feed != get_default_feed() )
     689                        $url = trailingslashit( $url ) . 'feed';
     690                        if ( $feed != get_default_feed() ) {
    660691                                $url .= "/$feed";
    661                         $url = user_trailingslashit($url, 'single_feed');
     692                        }
     693                        $url = user_trailingslashit( $url, 'single_feed' );
    662694                }
    663695        } else {
    664696                if ( $unattached ) {
    665                         $url = add_query_arg( array( 'feed' => $feed, 'attachment_id' => $post_id ), home_url( '/' ) );
     697                        $url = add_query_arg(
     698                                array(
     699                                        'feed'          => $feed,
     700                                        'attachment_id' => $post_id,
     701                                ), home_url( '/' )
     702                        );
    666703                } elseif ( 'page' == $post->post_type ) {
    667                         $url = add_query_arg( array( 'feed' => $feed, 'page_id' => $post_id ), home_url( '/' ) );
     704                        $url = add_query_arg(
     705                                array(
     706                                        'feed'    => $feed,
     707                                        'page_id' => $post_id,
     708                                ), home_url( '/' )
     709                        );
    668710                } else {
    669                         $url = add_query_arg( array( 'feed' => $feed, 'p' => $post_id ), home_url( '/' ) );
     711                        $url = add_query_arg(
     712                                array(
     713                                        'feed' => $feed,
     714                                        'p'    => $post_id,
     715                                ), home_url( '/' )
     716                        );
    670717                }
    671718        }
    … …  
    697744        $url = get_post_comments_feed_link( $post_id, $feed );
    698745        if ( empty( $link_text ) ) {
    699                 $link_text = __('Comments Feed');
     746                $link_text = __( 'Comments Feed' );
    700747        }
    701748
    … …  
    726773 */
    727774function get_author_feed_link( $author_id, $feed = '' ) {
    728         $author_id = (int) $author_id;
    729         $permalink_structure = get_option('permalink_structure');
    730 
    731         if ( empty($feed) )
     775        $author_id           = (int) $author_id;
     776        $permalink_structure = get_option( 'permalink_structure' );
     777
     778        if ( empty( $feed ) ) {
    732779                $feed = get_default_feed();
     780        }
    733781
    734782        if ( '' == $permalink_structure ) {
    735                 $link = home_url("?feed=$feed&amp;author=" . $author_id);
    736         } else {
    737                 $link = get_author_posts_url($author_id);
    738                 if ( $feed == get_default_feed() )
     783                $link = home_url( "?feed=$feed&amp;author=" . $author_id );
     784        } else {
     785                $link = get_author_posts_url( $author_id );
     786                if ( $feed == get_default_feed() ) {
    739787                        $feed_link = 'feed';
    740                 else
     788                } else {
    741789                        $feed_link = "feed/$feed";
    742 
    743                 $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed');
     790                }
     791
     792                $link = trailingslashit( $link ) . user_trailingslashit( $feed_link, 'feed' );
    744793        }
    745794
    … …  
    787836 */
    788837function get_term_feed_link( $term_id, $taxonomy = 'category', $feed = '' ) {
    789         $term_id = ( int ) $term_id;
    790 
    791         $term = get_term( $term_id, $taxonomy  );
    792 
    793         if ( empty( $term ) || is_wp_error( $term ) )
     838        $term_id = (int) $term_id;
     839
     840        $term = get_term( $term_id, $taxonomy );
     841
     842        if ( empty( $term ) || is_wp_error( $term ) ) {
    794843                return false;
    795 
    796         if ( empty( $feed ) )
     844        }
     845
     846        if ( empty( $feed ) ) {
    797847                $feed = get_default_feed();
     848        }
    798849
    799850        $permalink_structure = get_option( 'permalink_structure' );
    … …  
    801852        if ( '' == $permalink_structure ) {
    802853                if ( 'category' == $taxonomy ) {
    803                         $link = home_url("?feed=$feed&amp;cat=$term_id");
    804                 }
    805                 elseif ( 'post_tag' == $taxonomy ) {
    806                         $link = home_url("?feed=$feed&amp;tag=$term->slug");
     854                        $link = home_url( "?feed=$feed&amp;cat=$term_id" );
     855                } elseif ( 'post_tag' == $taxonomy ) {
     856                        $link = home_url( "?feed=$feed&amp;tag=$term->slug" );
    807857                } else {
    808                         $t = get_taxonomy( $taxonomy );
    809                         $link = home_url("?feed=$feed&amp;$t->query_var=$term->slug");
     858                        $t    = get_taxonomy( $taxonomy );
     859                        $link = home_url( "?feed=$feed&amp;$t->query_var=$term->slug" );
    810860                }
    811861        } else {
    812862                $link = get_term_link( $term_id, $term->taxonomy );
    813                 if ( $feed == get_default_feed() )
     863                if ( $feed == get_default_feed() ) {
    814864                        $feed_link = 'feed';
    815                 else
     865                } else {
    816866                        $feed_link = "feed/$feed";
     867                }
    817868
    818869                $link = trailingslashit( $link ) . user_trailingslashit( $feed_link, 'feed' );
    … …  
    9801031 */
    9811032function edit_term_link( $link = '', $before = '', $after = '', $term = null, $echo = true ) {
    982         if ( is_null( $term ) )
     1033        if ( is_null( $term ) ) {
    9831034                $term = get_queried_object();
    984 
    985         if ( ! $term )
     1035        }
     1036
     1037        if ( ! $term ) {
    9861038                return;
     1039        }
    9871040
    9881041        $tax = get_taxonomy( $term->taxonomy );
    … …  
    9911044        }
    9921045
    993         if ( empty( $link ) )
    994                 $link = __('Edit This');
     1046        if ( empty( $link ) ) {
     1047                $link = __( 'Edit This' );
     1048        }
    9951049
    9961050        $link = '<a href="' . get_edit_term_link( $term->term_id, $term->taxonomy ) . '">' . $link . '</a>';
    … …  
    10061060        $link = $before . apply_filters( 'edit_term_link', $link, $term->term_id ) . $after;
    10071061
    1008         if ( $echo )
     1062        if ( $echo ) {
    10091063                echo $link;
    1010         else
     1064        } else {
    10111065                return $link;
     1066        }
    10121067}
    10131068
    … …  
    10251080        global $wp_rewrite;
    10261081
    1027         if ( empty($query) )
     1082        if ( empty( $query ) ) {
    10281083                $search = get_search_query( false );
    1029         else
    1030                 $search = stripslashes($query);
     1084        } else {
     1085                $search = stripslashes( $query );
     1086        }
    10311087
    10321088        $permastruct = $wp_rewrite->get_search_permastruct();
    10331089
    10341090        if ( empty( $permastruct ) ) {
    1035                 $link = home_url('?s=' . urlencode($search) );
    1036         } else {
    1037                 $search = urlencode($search);
    1038                 $search = str_replace('%2F', '/', $search); // %2F(/) is not valid within a URL, send it un-encoded.
    1039                 $link = str_replace( '%search%', $search, $permastruct );
    1040                 $link = home_url( user_trailingslashit( $link, 'search' ) );
     1091                $link = home_url( '?s=' . urlencode( $search ) );
     1092        } else {
     1093                $search = urlencode( $search );
     1094                $search = str_replace( '%2F', '/', $search ); // %2F(/) is not valid within a URL, send it un-encoded.
     1095                $link   = str_replace( '%search%', $search, $permastruct );
     1096                $link   = home_url( user_trailingslashit( $link, 'search' ) );
    10411097        }
    10421098
    … …  
    10631119 * @return string The search results feed permalink.
    10641120 */
    1065 function get_search_feed_link($search_query = '', $feed = '') {
     1121function get_search_feed_link( $search_query = '', $feed = '' ) {
    10661122        global $wp_rewrite;
    1067         $link = get_search_link($search_query);
    1068 
    1069         if ( empty($feed) )
     1123        $link = get_search_link( $search_query );
     1124
     1125        if ( empty( $feed ) ) {
    10701126                $feed = get_default_feed();
     1127        }
    10711128
    10721129        $permastruct = $wp_rewrite->get_search_permastruct();
    10731130
    1074         if ( empty($permastruct) ) {
    1075                 $link = add_query_arg('feed', $feed, $link);
    1076         } else {
    1077                 $link = trailingslashit($link);
     1131        if ( empty( $permastruct ) ) {
     1132                $link = add_query_arg( 'feed', $feed, $link );
     1133        } else {
     1134                $link  = trailingslashit( $link );
    10781135                $link .= "feed/$feed/";
    10791136        }
    … …  
    11021159 * @return string The comments feed search results permalink.
    11031160 */
    1104 function get_search_comments_feed_link($search_query = '', $feed = '') {
     1161function get_search_comments_feed_link( $search_query = '', $feed = '' ) {
    11051162        global $wp_rewrite;
    11061163
    1107         if ( empty($feed) )
     1164        if ( empty( $feed ) ) {
    11081165                $feed = get_default_feed();
    1109 
    1110         $link = get_search_feed_link($search_query, $feed);
     1166        }
     1167
     1168        $link = get_search_feed_link( $search_query, $feed );
    11111169
    11121170        $permastruct = $wp_rewrite->get_search_permastruct();
    11131171
    1114         if ( empty($permastruct) )
    1115                 $link = add_query_arg('feed', 'comments-' . $feed, $link);
    1116         else
    1117                 $link = add_query_arg('withcomments', 1, $link);
     1172        if ( empty( $permastruct ) ) {
     1173                $link = add_query_arg( 'feed', 'comments-' . $feed, $link );
     1174        } else {
     1175                $link = add_query_arg( 'withcomments', 1, $link );
     1176        }
    11181177
    11191178        /** This filter is documented in wp-includes/link-template.php */
    … …  
    11341193function get_post_type_archive_link( $post_type ) {
    11351194        global $wp_rewrite;
    1136         if ( ! $post_type_obj = get_post_type_object( $post_type ) )
     1195        if ( ! $post_type_obj = get_post_type_object( $post_type ) ) {
    11371196                return false;
     1197        }
    11381198
    11391199        if ( 'post' === $post_type ) {
    1140                 $show_on_front = get_option( 'show_on_front' );
    1141                 $page_for_posts  = get_option( 'page_for_posts' );
     1200                $show_on_front  = get_option( 'show_on_front' );
     1201                $page_for_posts = get_option( 'page_for_posts' );
    11421202
    11431203                if ( 'page' == $show_on_front && $page_for_posts ) {
    … …  
    11501210        }
    11511211
    1152         if ( ! $post_type_obj->has_archive )
     1212        if ( ! $post_type_obj->has_archive ) {
    11531213                return false;
     1214        }
    11541215
    11551216        if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) ) {
    11561217                $struct = ( true === $post_type_obj->has_archive ) ? $post_type_obj->rewrite['slug'] : $post_type_obj->has_archive;
    1157                 if ( $post_type_obj->rewrite['with_front'] )
     1218                if ( $post_type_obj->rewrite['with_front'] ) {
    11581219                        $struct = $wp_rewrite->front . $struct;
    1159                 else
     1220                } else {
    11601221                        $struct = $wp_rewrite->root . $struct;
     1222                }
    11611223                $link = home_url( user_trailingslashit( $struct, 'post_type_archive' ) );
    11621224        } else {
    … …  
    11861248function get_post_type_archive_feed_link( $post_type, $feed = '' ) {
    11871249        $default_feed = get_default_feed();
    1188         if ( empty( $feed ) )
     1250        if ( empty( $feed ) ) {
    11891251                $feed = $default_feed;
    1190 
    1191         if ( ! $link = get_post_type_archive_link( $post_type ) )
     1252        }
     1253
     1254        if ( ! $link = get_post_type_archive_link( $post_type ) ) {
    11921255                return false;
     1256        }
    11931257
    11941258        $post_type_obj = get_post_type_object( $post_type );
    11951259        if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) && $post_type_obj->rewrite['feeds'] ) {
    1196                 $link = trailingslashit( $link );
     1260                $link  = trailingslashit( $link );
    11971261                $link .= 'feed/';
    1198                 if ( $feed != $default_feed )
     1262                if ( $feed != $default_feed ) {
    11991263                        $link .= "$feed/";
     1264                }
    12001265        } else {
    12011266                $link = add_query_arg( 'feed', $feed, $link );
    … …  
    12401305
    12411306                $query_args['preview'] = 'true';
    1242                 $preview_link = add_query_arg( $query_args, $preview_link );
     1307                $preview_link          = add_query_arg( $query_args, $preview_link );
    12431308        }
    12441309
    … …  
    12691334 */
    12701335function get_edit_post_link( $id = 0, $context = 'display' ) {
    1271         if ( ! $post = get_post( $id ) )
     1336        if ( ! $post = get_post( $id ) ) {
    12721337                return;
    1273 
    1274         if ( 'revision' === $post->post_type )
     1338        }
     1339
     1340        if ( 'revision' === $post->post_type ) {
    12751341                $action = '';
    1276         elseif ( 'display' == $context )
     1342        } elseif ( 'display' == $context ) {
    12771343                $action = '&amp;action=edit';
    1278         else
     1344        } else {
    12791345                $action = '&action=edit';
     1346        }
    12801347
    12811348        $post_type_object = get_post_type_object( $post->post_type );
    1282         if ( !$post_type_object )
     1349        if ( ! $post_type_object ) {
    12831350                return;
    1284 
    1285         if ( !current_user_can( 'edit_post', $post->ID ) )
     1351        }
     1352
     1353        if ( ! current_user_can( 'edit_post', $post->ID ) ) {
    12861354                return;
     1355        }
    12871356
    12881357        if ( $post_type_object->_edit_link ) {
    … …  
    13571426 */
    13581427function get_delete_post_link( $id = 0, $deprecated = '', $force_delete = false ) {
    1359         if ( ! empty( $deprecated ) )
     1428        if ( ! empty( $deprecated ) ) {
    13601429                _deprecated_argument( __FUNCTION__, '3.0.0' );
    1361 
    1362         if ( !$post = get_post( $id ) )
     1430        }
     1431
     1432        if ( ! $post = get_post( $id ) ) {
    13631433                return;
     1434        }
    13641435
    13651436        $post_type_object = get_post_type_object( $post->post_type );
    1366         if ( !$post_type_object )
     1437        if ( ! $post_type_object ) {
    13671438                return;
    1368 
    1369         if ( !current_user_can( 'delete_post', $post->ID ) )
     1439        }
     1440
     1441        if ( ! current_user_can( 'delete_post', $post->ID ) ) {
    13701442                return;
    1371 
    1372         $action = ( $force_delete || !EMPTY_TRASH_DAYS ) ? 'delete' : 'trash';
     1443        }
     1444
     1445        $action = ( $force_delete || ! EMPTY_TRASH_DAYS ) ? 'delete' : 'trash';
    13731446
    13741447        $delete_link = add_query_arg( 'action', $action, admin_url( sprintf( $post_type_object->_edit_link, $post->ID ) ) );
    … …  
    13971470        $comment = get_comment( $comment_id );
    13981471
    1399         if ( !current_user_can( 'edit_comment', $comment->comment_ID ) )
     1472        if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) {
    14001473                return;
    1401 
    1402         $location = admin_url('comment.php?action=editcomment&amp;c=') . $comment->comment_ID;
     1474        }
     1475
     1476        $location = admin_url( 'comment.php?action=editcomment&amp;c=' ) . $comment->comment_ID;
    14031477
    14041478        /**
    … …  
    14571531        $link = get_bookmark( $link );
    14581532
    1459         if ( !current_user_can('manage_links') )
     1533        if ( ! current_user_can( 'manage_links' ) ) {
    14601534                return;
    1461 
    1462         $location = admin_url('link.php?action=edit&amp;link_id=') . $link->link_id;
     1535        }
     1536
     1537        $location = admin_url( 'link.php?action=edit&amp;link_id=' ) . $link->link_id;
    14631538
    14641539        /**
    … …  
    14841559 */
    14851560function edit_bookmark_link( $link = '', $before = '', $after = '', $bookmark = null ) {
    1486         $bookmark = get_bookmark($bookmark);
    1487 
    1488         if ( !current_user_can('manage_links') )
     1561        $bookmark = get_bookmark( $bookmark );
     1562
     1563        if ( ! current_user_can( 'manage_links' ) ) {
    14891564                return;
    1490 
    1491         if ( empty($link) )
    1492                 $link = __('Edit This');
     1565        }
     1566
     1567        if ( empty( $link ) ) {
     1568                $link = __( 'Edit This' );
     1569        }
    14931570
    14941571        $link = '<a href="' . esc_url( get_edit_bookmark_link( $bookmark ) ) . '">' . $link . '</a>';
    … …  
    15141591 */
    15151592function get_edit_user_link( $user_id = null ) {
    1516         if ( ! $user_id )
     1593        if ( ! $user_id ) {
    15171594                $user_id = get_current_user_id();
    1518 
    1519         if ( empty( $user_id ) || ! current_user_can( 'edit_user', $user_id ) )
     1595        }
     1596
     1597        if ( empty( $user_id ) || ! current_user_can( 'edit_user', $user_id ) ) {
    15201598                return '';
     1599        }
    15211600
    15221601        $user = get_userdata( $user_id );
    15231602
    1524         if ( ! $user )
     1603        if ( ! $user ) {
    15251604                return '';
    1526 
    1527         if ( get_current_user_id() == $user->ID )
     1605        }
     1606
     1607        if ( get_current_user_id() == $user->ID ) {
    15281608                $link = get_edit_profile_url( $user->ID );
    1529         else
     1609        } else {
    15301610                $link = add_query_arg( 'user_id', $user->ID, self_admin_url( 'user-edit.php' ) );
     1611        }
    15311612
    15321613        /**
    … …  
    15921673        global $wpdb;
    15931674
    1594         if ( ( ! $post = get_post() ) || ! taxonomy_exists( $taxonomy ) )
     1675        if ( ( ! $post = get_post() ) || ! taxonomy_exists( $taxonomy ) ) {
    15951676                return null;
     1677        }
    15961678
    15971679        $current_post_date = $post->post_date;
    15981680
    1599         $join = '';
    1600         $where = '';
     1681        $join     = '';
     1682        $where    = '';
    16011683        $adjacent = $previous ? 'previous' : 'next';
    16021684
    … …  
    16151697
    16161698                if ( $in_same_term ) {
    1617                         $join .= " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id";
    1618                         $where .= $wpdb->prepare( "AND tt.taxonomy = %s", $taxonomy );
    1619 
    1620                         if ( ! is_object_in_taxonomy( $post->post_type, $taxonomy ) )
     1699                        $join  .= " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id";
     1700                        $where .= $wpdb->prepare( 'AND tt.taxonomy = %s', $taxonomy );
     1701
     1702                        if ( ! is_object_in_taxonomy( $post->post_type, $taxonomy ) ) {
    16211703                                return '';
     1704                        }
    16221705                        $term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
    16231706
    … …  
    16261709                        $term_array = array_map( 'intval', $term_array );
    16271710
    1628                         if ( ! $term_array || is_wp_error( $term_array ) )
     1711                        if ( ! $term_array || is_wp_error( $term_array ) ) {
    16291712                                return '';
    1630 
    1631                         $where .= " AND tt.term_id IN (" . implode( ',', $term_array ) . ")";
     1713                        }
     1714
     1715                        $where .= ' AND tt.term_id IN (' . implode( ',', $term_array ) . ')';
    16321716                }
    16331717
    … …  
    16661750                 */
    16671751                $private_states = get_post_stati( array( 'private' => true ) );
    1668                 $where .= " AND ( p.post_status = 'publish'";
     1752                $where         .= " AND ( p.post_status = 'publish'";
    16691753                foreach ( (array) $private_states as $state ) {
    16701754                        if ( current_user_can( $read_private_cap ) ) {
    1671                                 $where .= $wpdb->prepare( " OR p.post_status = %s", $state );
     1755                                $where .= $wpdb->prepare( ' OR p.post_status = %s', $state );
    16721756                        } else {
    1673                                 $where .= $wpdb->prepare( " OR (p.post_author = %d AND p.post_status = %s)", $user_id, $state );
     1757                                $where .= $wpdb->prepare( ' OR (p.post_author = %d AND p.post_status = %s)', $user_id, $state );
    16741758                        }
    16751759                }
    1676                 $where .= " )";
     1760                $where .= ' )';
    16771761        } else {
    16781762                $where .= " AND p.post_status = 'publish'";
    16791763        }
    16801764
    1681         $op = $previous ? '<' : '>';
     1765        $op    = $previous ? '<' : '>';
    16821766        $order = $previous ? 'DESC' : 'ASC';
    16831767
    … …  
    17301814         * @param string  $order   Sort order. 'DESC' for previous post, 'ASC' for next.
    17311815         */
    1732         $sort  = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1", $post, $order );
    1733 
    1734         $query = "SELECT p.ID FROM $wpdb->posts AS p $join $where $sort";
     1816        $sort = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1", $post, $order );
     1817
     1818        $query     = "SELECT p.ID FROM $wpdb->posts AS p $join $where $sort";
    17351819        $query_key = 'adjacent_post_' . md5( $query );
    1736         $result = wp_cache_get( $query_key, 'counts' );
     1820        $result    = wp_cache_get( $query_key, 'counts' );
    17371821        if ( false !== $result ) {
    1738                 if ( $result )
     1822                if ( $result ) {
    17391823                        $result = get_post( $result );
     1824                }
    17401825                return $result;
    17411826        }
    17421827
    17431828        $result = $wpdb->get_var( $query );
    1744         if ( null === $result )
     1829        if ( null === $result ) {
    17451830                $result = '';
     1831        }
    17461832
    17471833        wp_cache_set( $query_key, $result, 'counts' );
    17481834
    1749         if ( $result )
     1835        if ( $result ) {
    17501836                $result = get_post( $result );
     1837        }
    17511838
    17521839        return $result;
    … …  
    17681855 */
    17691856function get_adjacent_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) {
    1770         if ( $previous && is_attachment() && $post = get_post() )
     1857        if ( $previous && is_attachment() && $post = get_post() ) {
    17711858                $post = get_post( $post->post_parent );
    1772         else
     1859        } else {
    17731860                $post = get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy );
    1774 
    1775         if ( empty( $post ) )
     1861        }
     1862
     1863        if ( empty( $post ) ) {
    17761864                return;
    1777 
    1778         $post_title = the_title_attribute( array( 'echo' => false, 'post' => $post ) );
    1779 
    1780         if ( empty( $post_title ) )
     1865        }
     1866
     1867        $post_title = the_title_attribute(
     1868                array(
     1869                        'echo' => false,
     1870                        'post' => $post,
     1871                )
     1872        );
     1873
     1874        if ( empty( $post_title ) ) {
    17811875                $post_title = $previous ? __( 'Previous Post' ) : __( 'Next Post' );
     1876        }
    17821877
    17831878        $date = mysql2date( get_option( 'date_format' ), $post->post_date );
    … …  
    17861881        $title = str_replace( '%date', $date, $title );
    17871882
    1788         $link = $previous ? "<link rel='prev' title='" : "<link rel='next' title='";
     1883        $link  = $previous ? "<link rel='prev' title='" : "<link rel='next' title='";
    17891884        $link .= esc_attr( $title );
    17901885        $link .= "' href='" . get_permalink( $post ) . "' />\n";
    … …  
    18871982function get_boundary_post( $in_same_term = false, $excluded_terms = '', $start = true, $taxonomy = 'category' ) {
    18881983        $post = get_post();
    1889         if ( ! $post || ! is_single() || is_attachment() || ! taxonomy_exists( $taxonomy ) )
     1984        if ( ! $post || ! is_single() || is_attachment() || ! taxonomy_exists( $taxonomy ) ) {
    18901985                return null;
     1986        }
    18911987
    18921988        $query_args = array(
    1893                 'posts_per_page' => 1,
    1894                 'order' => $start ? 'ASC' : 'DESC',
     1989                'posts_per_page'         => 1,
     1990                'order'                  => $start ? 'ASC' : 'DESC',
    18951991                'update_post_term_cache' => false,
    1896                 'update_post_meta_cache' => false
     1992                'update_post_meta_cache' => false,
    18971993        );
    18981994
    … …  
    19001996
    19011997        if ( ! is_array( $excluded_terms ) ) {
    1902                 if ( ! empty( $excluded_terms ) )
     1998                if ( ! empty( $excluded_terms ) ) {
    19031999                        $excluded_terms = explode( ',', $excluded_terms );
    1904                 else
     2000                } else {
    19052001                        $excluded_terms = array();
     2002                }
    19062003        }
    19072004
    19082005        if ( $in_same_term || ! empty( $excluded_terms ) ) {
    1909                 if ( $in_same_term )
     2006                if ( $in_same_term ) {
    19102007                        $term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
     2008                }
    19112009
    19122010                if ( ! empty( $excluded_terms ) ) {
    … …  
    19152013
    19162014                        $inverse_terms = array();
    1917                         foreach ( $excluded_terms as $excluded_term )
     2015                        foreach ( $excluded_terms as $excluded_term ) {
    19182016                                $inverse_terms[] = $excluded_term * -1;
     2017                        }
    19192018                        $excluded_terms = $inverse_terms;
    19202019                }
    19212020
    1922                 $query_args[ 'tax_query' ] = array( array(
    1923                         'taxonomy' => $taxonomy,
    1924                         'terms' => array_merge( $term_array, $excluded_terms )
    1925                 ) );
     2021                $query_args['tax_query'] = array(
     2022                        array(
     2023                                'taxonomy' => $taxonomy,
     2024                                'terms'    => array_merge( $term_array, $excluded_terms ),
     2025                        ),
     2026                );
    19262027        }
    19272028
    … …  
    20102111 */
    20112112function get_adjacent_post_link( $format, $link, $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) {
    2012         if ( $previous && is_attachment() )
     2113        if ( $previous && is_attachment() ) {
    20132114                $post = get_post( get_post()->post_parent );
    2014         else
     2115        } else {
    20152116                $post = get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy );
     2117        }
    20162118
    20172119        if ( ! $post ) {
    … …  
    20202122                $title = $post->post_title;
    20212123
    2022                 if ( empty( $post->post_title ) )
     2124                if ( empty( $post->post_title ) ) {
    20232125                        $title = $previous ? __( 'Previous Post' ) : __( 'Next Post' );
     2126                }
    20242127
    20252128                /** This filter is documented in wp-includes/post-template.php */
    … …  
    20272130
    20282131                $date = mysql2date( get_option( 'date_format' ), $post->post_date );
    2029                 $rel = $previous ? 'prev' : 'next';
    2030 
    2031                 $string = '<a href="' . get_permalink( $post ) . '" rel="'.$rel.'">';
     2132                $rel  = $previous ? 'prev' : 'next';
     2133
     2134                $string = '<a href="' . get_permalink( $post ) . '" rel="' . $rel . '">';
    20322135                $inlink = str_replace( '%title', $title, $link );
    20332136                $inlink = str_replace( '%date', $date, $inlink );
    … …  
    20842187 * @param int  $pagenum Optional. Page ID. Default 1.
    20852188 * @param bool $escape  Optional. Whether to escape the URL for display, with esc_url(). Defaults to true.
    2086  *                          Otherwise, prepares the URL with esc_url_raw().
     2189 *                      Otherwise, prepares the URL with esc_url_raw().
    20872190 * @return string The link URL for the given page number.
    20882191 */
    2089 function get_pagenum_link($pagenum = 1, $escape = true ) {
     2192function get_pagenum_link( $pagenum = 1, $escape = true ) {
    20902193        global $wp_rewrite;
    20912194
    … …  
    20942197        $request = remove_query_arg( 'paged' );
    20952198
    2096         $home_root = parse_url(home_url());
    2097         $home_root = ( isset($home_root['path']) ) ? $home_root['path'] : '';
     2199        $home_root = parse_url( home_url() );
     2200        $home_root = ( isset( $home_root['path'] ) ) ? $home_root['path'] : '';
    20982201        $home_root = preg_quote( $home_root, '|' );
    20992202
    2100         $request = preg_replace('|^'. $home_root . '|i', '', $request);
    2101         $request = preg_replace('|^/+|', '', $request);
    2102 
    2103         if ( !$wp_rewrite->using_permalinks() || is_admin() ) {
     2203        $request = preg_replace( '|^' . $home_root . '|i', '', $request );
     2204        $request = preg_replace( '|^/+|', '', $request );
     2205
     2206        if ( ! $wp_rewrite->using_permalinks() || is_admin() ) {
    21042207                $base = trailingslashit( get_bloginfo( 'url' ) );
    21052208
    … …  
    21132216                preg_match( $qs_regex, $request, $qs_match );
    21142217
    2115                 if ( !empty( $qs_match[0] ) ) {
     2218                if ( ! empty( $qs_match[0] ) ) {
    21162219                        $query_string = $qs_match[0];
    2117                         $request = preg_replace( $qs_regex, '', $request );
     2220                        $request      = preg_replace( $qs_regex, '', $request );
    21182221                } else {
    21192222                        $query_string = '';
    21202223                }
    21212224
    2122                 $request = preg_replace( "|$wp_rewrite->pagination_base/\d+/?$|", '', $request);
    2123                 $request = preg_replace( '|^' . preg_quote( $wp_rewrite->index, '|' ) . '|i', '', $request);
    2124                 $request = ltrim($request, '/');
     2225                $request = preg_replace( "|$wp_rewrite->pagination_base/\d+/?$|", '', $request );
     2226                $request = preg_replace( '|^' . preg_quote( $wp_rewrite->index, '|' ) . '|i', '', $request );
     2227                $request = ltrim( $request, '/' );
    21252228
    21262229                $base = trailingslashit( get_bloginfo( 'url' ) );
    21272230
    2128                 if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' != $request ) )
     2231                if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' != $request ) ) {
    21292232                        $base .= $wp_rewrite->index . '/';
     2233                }
    21302234
    21312235                if ( $pagenum > 1 ) {
    2132                         $request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( $wp_rewrite->pagination_base . "/" . $pagenum, 'paged' );
     2236                        $request = ( ( ! empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( $wp_rewrite->pagination_base . '/' . $pagenum, 'paged' );
    21332237                }
    21342238
    … …  
    21452249        $result = apply_filters( 'get_pagenum_link', $result );
    21462250
    2147         if ( $escape )
     2251        if ( $escape ) {
    21482252                return esc_url( $result );
    2149         else
     2253        } else {
    21502254                return esc_url_raw( $result );
     2255        }
    21512256}
    21522257
    … …  
    21632268 * @return string|void The link URL for next posts page.
    21642269 */
    2165 function get_next_posts_page_link($max_page = 0) {
     2270function get_next_posts_page_link( $max_page = 0 ) {
    21662271        global $paged;
    21672272
    2168         if ( !is_single() ) {
    2169                 if ( !$paged )
     2273        if ( ! is_single() ) {
     2274                if ( ! $paged ) {
    21702275                        $paged = 1;
    2171                 $nextpage = intval($paged) + 1;
    2172                 if ( !$max_page || $max_page >= $nextpage )
    2173                         return get_pagenum_link($nextpage);
     2276                }
     2277                $nextpage = intval( $paged ) + 1;
     2278                if ( ! $max_page || $max_page >= $nextpage ) {
     2279                        return get_pagenum_link( $nextpage );
     2280                }
    21742281        }
    21752282}
    … …  
    21872294        $output = esc_url( get_next_posts_page_link( $max_page ) );
    21882295
    2189         if ( $echo )
     2296        if ( $echo ) {
    21902297                echo $output;
    2191         else
     2298        } else {
    21922299                return $output;
     2300        }
    21932301}
    21942302
    … …  
    22082316        global $paged, $wp_query;
    22092317
    2210         if ( !$max_page )
     2318        if ( ! $max_page ) {
    22112319                $max_page = $wp_query->max_num_pages;
    2212 
    2213         if ( !$paged )
     2320        }
     2321
     2322        if ( ! $paged ) {
    22142323                $paged = 1;
    2215 
    2216         $nextpage = intval($paged) + 1;
    2217 
    2218         if ( null === $label )
     2324        }
     2325
     2326        $nextpage = intval( $paged ) + 1;
     2327
     2328        if ( null === $label ) {
    22192329                $label = __( 'Next Page &raquo;' );
    2220 
    2221         if ( !is_single() && ( $nextpage <= $max_page ) ) {
     2330        }
     2331
     2332        if ( ! is_single() && ( $nextpage <= $max_page ) ) {
    22222333                /**
    22232334                 * Filters the anchor tag attributes for the next posts page link.
    … …  
    22292340                $attr = apply_filters( 'next_posts_link_attributes', '' );
    22302341
    2231                 return '<a href="' . next_posts( $max_page, false ) . "\" $attr>" . preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label) . '</a>';
     2342                return '<a href="' . next_posts( $max_page, false ) . "\" $attr>" . preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label ) . '</a>';
    22322343        }
    22332344}
    … …  
    22612372        global $paged;
    22622373
    2263         if ( !is_single() ) {
    2264                 $nextpage = intval($paged) - 1;
    2265                 if ( $nextpage < 1 )
     2374        if ( ! is_single() ) {
     2375                $nextpage = intval( $paged ) - 1;
     2376                if ( $nextpage < 1 ) {
    22662377                        $nextpage = 1;
    2267                 return get_pagenum_link($nextpage);
     2378                }
     2379                return get_pagenum_link( $nextpage );
    22682380        }
    22692381}
    … …  
    22802392        $output = esc_url( get_previous_posts_page_link() );
    22812393
    2282         if ( $echo )
     2394        if ( $echo ) {
    22832395                echo $output;
    2284         else
     2396        } else {
    22852397                return $output;
     2398        }
    22862399}
    22872400
    … …  
    22992412        global $paged;
    23002413
    2301         if ( null === $label )
     2414        if ( null === $label ) {
    23022415                $label = __( '&laquo; Previous Page' );
    2303 
    2304         if ( !is_single() && $paged > 1 ) {
     2416        }
     2417
     2418        if ( ! is_single() && $paged > 1 ) {
    23052419                /**
    23062420                 * Filters the anchor tag attributes for the previous posts page link.
    … …  
    23112425                 */
    23122426                $attr = apply_filters( 'previous_posts_link_attributes', '' );
    2313                 return '<a href="' . previous_posts( false ) . "\" $attr>". preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label ) .'</a>';
     2427                return '<a href="' . previous_posts( false ) . "\" $attr>" . preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label ) . '</a>';
    23142428        }
    23152429}
    … …  
    23492463        $return = '';
    23502464
    2351         if ( !is_singular() ) {
     2465        if ( ! is_singular() ) {
    23522466                $defaults = array(
    2353                         'sep' => ' &#8212; ',
    2354                         'prelabel' => __('&laquo; Previous Page'),
    2355                         'nxtlabel' => __('Next Page &raquo;'),
     2467                        'sep'      => ' &#8212; ',
     2468                        'prelabel' => __( '&laquo; Previous Page' ),
     2469                        'nxtlabel' => __( 'Next Page &raquo;' ),
    23562470                );
    2357                 $args = wp_parse_args( $args, $defaults );
     2471                $args     = wp_parse_args( $args, $defaults );
    23582472
    23592473                $max_num_pages = $wp_query->max_num_pages;
    2360                 $paged = get_query_var('paged');
     2474                $paged         = get_query_var( 'paged' );
    23612475
    23622476                //only have sep if there's both prev and next results
    2363                 if ($paged < 2 || $paged >= $max_num_pages) {
     2477                if ( $paged < 2 || $paged >= $max_num_pages ) {
    23642478                        $args['sep'] = '';
    23652479                }
    23662480
    23672481                if ( $max_num_pages > 1 ) {
    2368                         $return = get_previous_posts_link($args['prelabel']);
    2369                         $return .= preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $args['sep']);
    2370                         $return .= get_next_posts_link($args['nxtlabel']);
     2482                        $return  = get_previous_posts_link( $args['prelabel'] );
     2483                        $return .= preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $args['sep'] );
     2484                        $return .= get_next_posts_link( $args['nxtlabel'] );
    23712485                }
    23722486        }
    … …  
    23852499 */
    23862500function posts_nav_link( $sep = '', $prelabel = '', $nxtlabel = '' ) {
    2387         $args = array_filter( compact('sep', 'prelabel', 'nxtlabel') );
    2388         echo get_posts_nav_link($args);
     2501        $args = array_filter( compact( 'sep', 'prelabel', 'nxtlabel' ) );
     2502        echo get_posts_nav_link( $args );
    23892503}
    23902504
    … …  
    24082522 */
    24092523function get_the_post_navigation( $args = array() ) {
    2410         $args = wp_parse_args( $args, array(
    2411                 'prev_text'          => '%title',
    2412                 'next_text'          => '%title',
    2413                 'in_same_term'       => false,
    2414                 'excluded_terms'     => '',
    2415                 'taxonomy'           => 'category',
    2416                 'screen_reader_text' => __( 'Post navigation' ),
    2417         ) );
     2524        $args = wp_parse_args(
     2525                $args, array(
     2526                        'prev_text'          => '%title',
     2527                        'next_text'          => '%title',
     2528                        'in_same_term'       => false,
     2529                        'excluded_terms'     => '',
     2530                        'taxonomy'           => 'category',
     2531                        'screen_reader_text' => __( 'Post navigation' ),
     2532                )
     2533        );
    24182534
    24192535        $navigation = '';
    … …  
    24792595        // Don't print empty markup if there's only one page.
    24802596        if ( $GLOBALS['wp_query']->max_num_pages > 1 ) {
    2481                 $args = wp_parse_args( $args, array(
    2482                         'prev_text'          => __( 'Older posts' ),
    2483                         'next_text'          => __( 'Newer posts' ),
    2484                         'screen_reader_text' => __( 'Posts navigation' ),
    2485                 ) );
     2597                $args = wp_parse_args(
     2598                        $args, array(
     2599                                'prev_text'          => __( 'Older posts' ),
     2600                                'next_text'          => __( 'Newer posts' ),
     2601                                'screen_reader_text' => __( 'Posts navigation' ),
     2602                        )
     2603                );
    24862604
    24872605                $next_link = get_previous_posts_link( $args['next_text'] );
    … …  
    25322650        // Don't print empty markup if there's only one page.
    25332651        if ( $GLOBALS['wp_query']->max_num_pages > 1 ) {
    2534                 $args = wp_parse_args( $args, array(
    2535                         'mid_size'           => 1,
    2536                         'prev_text'          => _x( 'Previous', 'previous set of posts' ),
    2537                         'next_text'          => _x( 'Next', 'next set of posts' ),
    2538                         'screen_reader_text' => __( 'Posts navigation' ),
    2539                 ) );
     2652                $args = wp_parse_args(
     2653                        $args, array(
     2654                                'mid_size'           => 1,
     2655                                'prev_text'          => _x( 'Previous', 'previous set of posts' ),
     2656                                'next_text'          => _x( 'Next', 'next set of posts' ),
     2657                                'screen_reader_text' => __( 'Posts navigation' ),
     2658                        )
     2659                );
    25402660
    25412661                // Make sure we get a string back. Plain is the next best thing.
    … …  
    26302750        $result = get_permalink();
    26312751
    2632         if ( 'newest' == get_option('default_comments_page') ) {
     2752        if ( 'newest' == get_option( 'default_comments_page' ) ) {
    26332753                if ( $pagenum != $max_page ) {
    2634                         if ( $wp_rewrite->using_permalinks() )
    2635                                 $result = user_trailingslashit( trailingslashit($result) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged');
    2636                         else
     2754                        if ( $wp_rewrite->using_permalinks() ) {
     2755                                $result = user_trailingslashit( trailingslashit( $result ) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged' );
     2756                        } else {
    26372757                                $result = add_query_arg( 'cpage', $pagenum, $result );
     2758                        }
    26382759                }
    26392760        } elseif ( $pagenum > 1 ) {
    2640                 if ( $wp_rewrite->using_permalinks() )
    2641                         $result = user_trailingslashit( trailingslashit($result) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged');
    2642                 else
     2761                if ( $wp_rewrite->using_permalinks() ) {
     2762                        $result = user_trailingslashit( trailingslashit( $result ) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged' );
     2763                } else {
    26432764                        $result = add_query_arg( 'cpage', $pagenum, $result );
     2765                }
    26442766        }
    26452767
    … …  
    26702792        global $wp_query;
    26712793
    2672         if ( ! is_singular() )
     2794        if ( ! is_singular() ) {
    26732795                return;
    2674 
    2675         $page = get_query_var('cpage');
     2796        }
     2797
     2798        $page = get_query_var( 'cpage' );
    26762799
    26772800        if ( ! $page ) {
    … …  
    26792802        }
    26802803
    2681         $nextpage = intval($page) + 1;
    2682 
    2683         if ( empty($max_page) )
     2804        $nextpage = intval( $page ) + 1;
     2805
     2806        if ( empty( $max_page ) ) {
    26842807                $max_page = $wp_query->max_num_comment_pages;
    2685 
    2686         if ( empty($max_page) )
     2808        }
     2809
     2810        if ( empty( $max_page ) ) {
    26872811                $max_page = get_comment_pages_count();
    2688 
    2689         if ( $nextpage > $max_page )
     2812        }
     2813
     2814        if ( $nextpage > $max_page ) {
    26902815                return;
    2691 
    2692         if ( empty($label) )
    2693                 $label = __('Newer Comments &raquo;');
     2816        }
     2817
     2818        if ( empty( $label ) ) {
     2819                $label = __( 'Newer Comments &raquo;' );
     2820        }
    26942821
    26952822        /**
    … …  
    27002827         * @param string $attributes Attributes for the anchor tag.
    27012828         */
    2702         return '<a href="' . esc_url( get_comments_pagenum_link( $nextpage, $max_page ) ) . '" ' . apply_filters( 'next_comments_link_attributes', '' ) . '>'. preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label) .'</a>';
     2829        return '<a href="' . esc_url( get_comments_pagenum_link( $nextpage, $max_page ) ) . '" ' . apply_filters( 'next_comments_link_attributes', '' ) . '>' . preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label ) . '</a>';
    27032830}
    27042831
    … …  
    27242851 */
    27252852function get_previous_comments_link( $label = '' ) {
    2726         if ( ! is_singular() )
     2853        if ( ! is_singular() ) {
    27272854                return;
    2728 
    2729         $page = get_query_var('cpage');
    2730 
    2731         if ( intval($page) <= 1 )
     2855        }
     2856
     2857        $page = get_query_var( 'cpage' );
     2858
     2859        if ( intval( $page ) <= 1 ) {
    27322860                return;
    2733 
    2734         $prevpage = intval($page) - 1;
    2735 
    2736         if ( empty($label) )
    2737                 $label = __('&laquo; Older Comments');
     2861        }
     2862
     2863        $prevpage = intval( $page ) - 1;
     2864
     2865        if ( empty( $label ) ) {
     2866                $label = __( '&laquo; Older Comments' );
     2867        }
    27382868
    27392869        /**
    … …  
    27442874         * @param string $attributes Attributes for the anchor tag.
    27452875         */
    2746         return '<a href="' . esc_url( get_comments_pagenum_link( $prevpage ) ) . '" ' . apply_filters( 'previous_comments_link_attributes', '' ) . '>' . preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label) .'</a>';
     2876        return '<a href="' . esc_url( get_comments_pagenum_link( $prevpage ) ) . '" ' . apply_filters( 'previous_comments_link_attributes', '' ) . '>' . preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label ) . '</a>';
    27472877}
    27482878
    … …  
    27722902        global $wp_rewrite;
    27732903
    2774         if ( ! is_singular() )
     2904        if ( ! is_singular() ) {
    27752905                return;
    2776 
    2777         $page = get_query_var('cpage');
    2778         if ( !$page )
     2906        }
     2907
     2908        $page = get_query_var( 'cpage' );
     2909        if ( ! $page ) {
    27792910                $page = 1;
     2911        }
    27802912        $max_page = get_comment_pages_count();
    27812913        $defaults = array(
    2782                 'base' => add_query_arg( 'cpage', '%#%' ),
    2783                 'format' => '',
    2784                 'total' => $max_page,
    2785                 'current' => $page,
    2786                 'echo' => true,
    2787                 'add_fragment' => '#comments'
     2914                'base'         => add_query_arg( 'cpage', '%#%' ),
     2915                'format'       => '',
     2916                'total'        => $max_page,
     2917                'current'      => $page,
     2918                'echo'         => true,
     2919                'add_fragment' => '#comments',
    27882920        );
    2789         if ( $wp_rewrite->using_permalinks() )
    2790                 $defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()) . $wp_rewrite->comments_pagination_base . '-%#%', 'commentpaged');
    2791 
    2792         $args = wp_parse_args( $args, $defaults );
     2921        if ( $wp_rewrite->using_permalinks() ) {
     2922                $defaults['base'] = user_trailingslashit( trailingslashit( get_permalink() ) . $wp_rewrite->comments_pagination_base . '-%#%', 'commentpaged' );
     2923        }
     2924
     2925        $args       = wp_parse_args( $args, $defaults );
    27932926        $page_links = paginate_links( $args );
    27942927
    2795         if ( $args['echo'] )
     2928        if ( $args['echo'] ) {
    27962929                echo $page_links;
    2797         else
     2930        } else {
    27982931                return $page_links;
     2932        }
    27992933}
    28002934
    … …  
    28202954        // Are there comments to navigate through?
    28212955        if ( get_comment_pages_count() > 1 ) {
    2822                 $args = wp_parse_args( $args, array(
    2823                         'prev_text'          => __( 'Older comments' ),
    2824                         'next_text'          => __( 'Newer comments' ),
    2825                         'screen_reader_text' => __( 'Comments navigation' ),
    2826                 ) );
     2956                $args = wp_parse_args(
     2957                        $args, array(
     2958                                'prev_text'          => __( 'Older comments' ),
     2959                                'next_text'          => __( 'Newer comments' ),
     2960                                'screen_reader_text' => __( 'Comments navigation' ),
     2961                        )
     2962                );
    28272963
    28282964                $prev_link = get_previous_comments_link( $args['prev_text'] );
    … …  
    28693005 */
    28703006function get_the_comments_pagination( $args = array() ) {
    2871         $navigation = '';
    2872         $args       = wp_parse_args( $args, array(
    2873                 'screen_reader_text' => __( 'Comments navigation' ),
    2874         ) );
     3007        $navigation   = '';
     3008        $args         = wp_parse_args(
     3009                $args, array(
     3010                        'screen_reader_text' => __( 'Comments navigation' ),
     3011                )
     3012        );
    28753013        $args['echo'] = false;
    28763014
    … …  
    29403078        $orig_scheme = $scheme;
    29413079
    2942         if ( empty( $blog_id ) || !is_multisite() ) {
     3080        if ( empty( $blog_id ) || ! is_multisite() ) {
    29433081                $url = get_option( 'home' );
    29443082        } else {
    … …  
    29493087
    29503088        if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) {
    2951                 if ( is_ssl() && ! is_admin() && 'wp-login.php' !== $pagenow )
     3089                if ( is_ssl() && ! is_admin() && 'wp-login.php' !== $pagenow ) {
    29523090                        $scheme = 'https';
    2953                 else
     3091                } else {
    29543092                        $scheme = parse_url( $url, PHP_URL_SCHEME );
     3093                }
    29553094        }
    29563095
    29573096        $url = set_url_scheme( $url, $scheme );
    29583097
    2959         if ( $path && is_string( $path ) )
     3098        if ( $path && is_string( $path ) ) {
    29603099                $url .= '/' . ltrim( $path, '/' );
     3100        }
    29613101
    29623102        /**
    … …  
    30103150 */
    30113151function get_site_url( $blog_id = null, $path = '', $scheme = null ) {
    3012         if ( empty( $blog_id ) || !is_multisite() ) {
     3152        if ( empty( $blog_id ) || ! is_multisite() ) {
    30133153                $url = get_option( 'siteurl' );
    30143154        } else {
    … …  
    30203160        $url = set_url_scheme( $url, $scheme );
    30213161
    3022         if ( $path && is_string( $path ) )
     3162        if ( $path && is_string( $path ) ) {
    30233163                $url .= '/' . ltrim( $path, '/' );
     3164        }
    30243165
    30253166        /**
    … …  
    30643205 */
    30653206function get_admin_url( $blog_id = null, $path = '', $scheme = 'admin' ) {
    3066         $url = get_site_url($blog_id, 'wp-admin/', $scheme);
    3067 
    3068         if ( $path && is_string( $path ) )
     3207        $url = get_site_url( $blog_id, 'wp-admin/', $scheme );
     3208
     3209        if ( $path && is_string( $path ) ) {
    30693210                $url .= ltrim( $path, '/' );
     3211        }
    30703212
    30713213        /**
    … …  
    30943236        $url = site_url( '/' . WPINC . '/', $scheme );
    30953237
    3096         if ( $path && is_string( $path ) )
    3097                 $url .= ltrim($path, '/');
     3238        if ( $path && is_string( $path ) ) {
     3239                $url .= ltrim( $path, '/' );
     3240        }
    30983241
    30993242        /**
    … …  
    31203263        $url = set_url_scheme( WP_CONTENT_URL );
    31213264
    3122         if ( $path && is_string( $path ) )
    3123                 $url .= '/' . ltrim($path, '/');
     3265        if ( $path && is_string( $path ) ) {
     3266                $url .= '/' . ltrim( $path, '/' );
     3267        }
    31243268
    31253269        /**
    … …  
    31323276         *                     if no path is specified.
    31333277         */
    3134         return apply_filters( 'content_url', $url, $path);
     3278        return apply_filters( 'content_url', $url, $path );
    31353279}
    31363280
    … …  
    31513295function plugins_url( $path = '', $plugin = '' ) {
    31523296
    3153         $path = wp_normalize_path( $path );
    3154         $plugin = wp_normalize_path( $plugin );
     3297        $path          = wp_normalize_path( $path );
     3298        $plugin        = wp_normalize_path( $plugin );
    31553299        $mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR );
    31563300
    3157         if ( !empty($plugin) && 0 === strpos($plugin, $mu_plugin_dir) )
     3301        if ( ! empty( $plugin ) && 0 === strpos( $plugin, $mu_plugin_dir ) ) {
    31583302                $url = WPMU_PLUGIN_URL;
    3159         else
     3303        } else {
    31603304                $url = WP_PLUGIN_URL;
    3161 
     3305        }
    31623306
    31633307        $url = set_url_scheme( $url );
    31643308
    3165         if ( !empty($plugin) && is_string($plugin) ) {
    3166                 $folder = dirname(plugin_basename($plugin));
    3167                 if ( '.' != $folder )
    3168                         $url .= '/' . ltrim($folder, '/');
    3169         }
    3170 
    3171         if ( $path && is_string( $path ) )
    3172                 $url .= '/' . ltrim($path, '/');
     3309        if ( ! empty( $plugin ) && is_string( $plugin ) ) {
     3310                $folder = dirname( plugin_basename( $plugin ) );
     3311                if ( '.' != $folder ) {
     3312                        $url .= '/' . ltrim( $folder, '/' );
     3313                }
     3314        }
     3315
     3316        if ( $path && is_string( $path ) ) {
     3317                $url .= '/' . ltrim( $path, '/' );
     3318        }
    31733319
    31743320        /**
    … …  
    32033349 */
    32043350function network_site_url( $path = '', $scheme = null ) {
    3205         if ( ! is_multisite() )
    3206                 return site_url($path, $scheme);
     3351        if ( ! is_multisite() ) {
     3352                return site_url( $path, $scheme );
     3353        }
    32073354
    32083355        $current_network = get_network();
    32093356
    3210         if ( 'relative' == $scheme )
     3357        if ( 'relative' == $scheme ) {
    32113358                $url = $current_network->path;
    3212         else
     3359        } else {
    32133360                $url = set_url_scheme( 'http://' . $current_network->domain . $current_network->path, $scheme );
    3214 
    3215         if ( $path && is_string( $path ) )
     3361        }
     3362
     3363        if ( $path && is_string( $path ) ) {
    32163364                $url .= ltrim( $path, '/' );
     3365        }
    32173366
    32183367        /**
    … …  
    32453394 */
    32463395function network_home_url( $path = '', $scheme = null ) {
    3247         if ( ! is_multisite() )
    3248                 return home_url($path, $scheme);
     3396        if ( ! is_multisite() ) {
     3397                return home_url( $path, $scheme );
     3398        }
    32493399
    32503400        $current_network = get_network();
    3251         $orig_scheme = $scheme;
    3252 
    3253         if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) )
     3401        $orig_scheme     = $scheme;
     3402
     3403        if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) {
    32543404                $scheme = is_ssl() && ! is_admin() ? 'https' : 'http';
    3255 
    3256         if ( 'relative' == $scheme )
     3405        }
     3406
     3407        if ( 'relative' == $scheme ) {
    32573408                $url = $current_network->path;
    3258         else
     3409        } else {
    32593410                $url = set_url_scheme( 'http://' . $current_network->domain . $current_network->path, $scheme );
    3260 
    3261         if ( $path && is_string( $path ) )
     3411        }
     3412
     3413        if ( $path && is_string( $path ) ) {
    32623414                $url .= ltrim( $path, '/' );
     3415        }
    32633416
    32643417        /**
    … …  
    32733426         *                                 'relative' or null.
    32743427         */
    3275         return apply_filters( 'network_home_url', $url, $path, $orig_scheme);
     3428        return apply_filters( 'network_home_url', $url, $path, $orig_scheme );
    32763429}
    32773430
    … …  
    32873440 */
    32883441function network_admin_url( $path = '', $scheme = 'admin' ) {
    3289         if ( ! is_multisite() )
     3442        if ( ! is_multisite() ) {
    32903443                return admin_url( $path, $scheme );
    3291 
    3292         $url = network_site_url('wp-admin/network/', $scheme);
    3293 
    3294         if ( $path && is_string( $path ) )
    3295                 $url .= ltrim($path, '/');
     3444        }
     3445
     3446        $url = network_site_url( 'wp-admin/network/', $scheme );
     3447
     3448        if ( $path && is_string( $path ) ) {
     3449                $url .= ltrim( $path, '/' );
     3450        }
    32963451
    32973452        /**
    … …  
    33183473 */
    33193474function user_admin_url( $path = '', $scheme = 'admin' ) {
    3320         $url = network_site_url('wp-admin/user/', $scheme);
    3321 
    3322         if ( $path && is_string( $path ) )
    3323                 $url .= ltrim($path, '/');
     3475        $url = network_site_url( 'wp-admin/user/', $scheme );
     3476
     3477        if ( $path && is_string( $path ) ) {
     3478                $url .= ltrim( $path, '/' );
     3479        }
    33243480
    33253481        /**
    … …  
    33893545
    33903546        $url = trim( $url );
    3391         if ( substr( $url, 0, 2 ) === '//' )
     3547        if ( substr( $url, 0, 2 ) === '//' ) {
    33923548                $url = 'http:' . $url;
     3549        }
    33933550
    33943551        if ( 'relative' == $scheme ) {
    33953552                $url = ltrim( preg_replace( '#^\w+://[^/]*#', '', $url ) );
    3396                 if ( $url !== '' && $url[0] === '/' )
    3397                         $url = '/' . ltrim($url , "/ \t\n\r\0\x0B" );
     3553                if ( $url !== '' && $url[0] === '/' ) {
     3554                        $url = '/' . ltrim( $url, "/ \t\n\r\0\x0B" );
     3555                }
    33983556        } else {
    33993557                $url = preg_replace( '#^\w+://#', $scheme . '://', $url );
    … …  
    34333591
    34343592        $blogs = get_blogs_of_user( $user_id );
    3435         if ( is_multisite() && ! user_can( $user_id, 'manage_network' ) && empty($blogs) ) {
     3593        if ( is_multisite() && ! user_can( $user_id, 'manage_network' ) && empty( $blogs ) ) {
    34363594                $url = user_admin_url( $path, $scheme );
    34373595        } elseif ( ! is_multisite() ) {
    … …  
    34393597        } else {
    34403598                $current_blog = get_current_blog_id();
    3441                 if ( $current_blog  && ( user_can( $user_id, 'manage_network' ) || in_array( $current_blog, array_keys( $blogs ) ) ) ) {
     3599                if ( $current_blog && ( user_can( $user_id, 'manage_network' ) || in_array( $current_blog, array_keys( $blogs ) ) ) ) {
    34423600                        $url = admin_url( $path, $scheme );
    34433601                } else {
    34443602                        $active = get_active_blog_for_user( $user_id );
    3445                         if ( $active )
     3603                        if ( $active ) {
    34463604                                $url = get_admin_url( $active->blog_id, $path, $scheme );
    3447                         else
     3605                        } else {
    34483606                                $url = user_admin_url( $path, $scheme );
     3607                        }
    34493608                }
    34503609        }
    … …  
    34613620         *                        'login_post', 'admin', 'relative' or null.
    34623621         */
    3463         return apply_filters( 'user_dashboard_url', $url, $user_id, $path, $scheme);
     3622        return apply_filters( 'user_dashboard_url', $url, $user_id, $path, $scheme );
    34643623}
    34653624
    … …  
    34773636        $user_id = $user_id ? (int) $user_id : get_current_user_id();
    34783637
    3479         if ( is_user_admin() )
     3638        if ( is_user_admin() ) {
    34803639                $url = user_admin_url( 'profile.php', $scheme );
    3481         elseif ( is_network_admin() )
     3640        } elseif ( is_network_admin() ) {
    34823641                $url = network_admin_url( 'profile.php', $scheme );
    3483         else
     3642        } else {
    34843643                $url = get_dashboard_url( $user_id, 'profile.php', $scheme );
     3644        }
    34853645
    34863646        /**
    … …  
    34943654         *                        'login_post', 'admin', 'relative' or null.
    34953655         */
    3496         return apply_filters( 'edit_profile_url', $url, $user_id, $scheme);
     3656        return apply_filters( 'edit_profile_url', $url, $user_id, $scheme );
    34973657}
    34983658
    … …  
    36173777        if ( 'query' == $context && is_singular() ) {
    36183778                $post_id = get_queried_object_id();
    3619                 $post = get_post( $post_id );
     3779                $post    = get_post( $post_id );
    36203780        } elseif ( 'post' == $context ) {
    36213781                $post = get_post( $id );
    3622                 if ( ! empty( $post->ID ) )
     3782                if ( ! empty( $post->ID ) ) {
    36233783                        $post_id = $post->ID;
     3784                }
    36243785        }
    36253786
    … …  
    36603821        $shortlink = wp_get_shortlink( 0, 'query' );
    36613822
    3662         if ( empty( $shortlink ) )
     3823        if ( empty( $shortlink ) ) {
    36633824                return;
     3825        }
    36643826
    36653827        echo "<link rel='shortlink' href='" . esc_url( $shortlink ) . "' />\n";
    … …  
    36743836 */
    36753837function wp_shortlink_header() {
    3676         if ( headers_sent() )
     3838        if ( headers_sent() ) {
    36773839                return;
    3678 
    3679         $shortlink = wp_get_shortlink(0, 'query');
    3680 
    3681         if ( empty($shortlink) )
     3840        }
     3841
     3842        $shortlink = wp_get_shortlink( 0, 'query' );
     3843
     3844        if ( empty( $shortlink ) ) {
    36823845                return;
    3683 
    3684         header('Link: <' . $shortlink . '>; rel=shortlink', false);
     3846        }
     3847
     3848        header( 'Link: <' . $shortlink . '>; rel=shortlink', false );
    36853849}
    36863850
    … …  
    37023866        $post = get_post();
    37033867
    3704         if ( empty( $text ) )
    3705                 $text = __('This is the short link.');
    3706 
    3707         if ( empty( $title ) )
     3868        if ( empty( $text ) ) {
     3869                $text = __( 'This is the short link.' );
     3870        }
     3871
     3872        if ( empty( $title ) ) {
    37083873                $title = the_title_attribute( array( 'echo' => false ) );
     3874        }
    37093875
    37103876        $shortlink = wp_get_shortlink( $post->ID );
    37113877
    3712         if ( !empty( $shortlink ) ) {
     3878        if ( ! empty( $shortlink ) ) {
    37133879                $link = '<a rel="shortlink" href="' . esc_url( $shortlink ) . '" title="' . $title . '">' . $text . '</a>';
    37143880
    … …  
    37983964 */
    37993965function get_avatar_data( $id_or_email, $args = null ) {
    3800         $args = wp_parse_args( $args, array(
    3801                 'size'           => 96,
    3802                 'height'         => null,
    3803                 'width'          => null,
    3804                 'default'        => get_option( 'avatar_default', 'mystery' ),
    3805                 'force_default'  => false,
    3806                 'rating'         => get_option( 'avatar_rating' ),
    3807                 'scheme'         => null,
    3808                 'processed_args' => null, // if used, should be a reference
    3809                 'extra_attr'     => '',
    3810         ) );
     3966        $args = wp_parse_args(
     3967                $args, array(
     3968                        'size'           => 96,
     3969                        'height'         => null,
     3970                        'width'          => null,
     3971                        'default'        => get_option( 'avatar_default', 'mystery' ),
     3972                        'force_default'  => false,
     3973                        'rating'         => get_option( 'avatar_rating' ),
     3974                        'scheme'         => null,
     3975                        'processed_args' => null, // if used, should be a reference
     3976                        'extra_attr'     => '',
     3977                )
     3978        );
    38113979
    38123980        if ( is_numeric( $args['size'] ) ) {
    … …  
    38424010
    38434011        switch ( $args['default'] ) {
    3844                 case 'mm' :
    3845                 case 'mystery' :
    3846                 case 'mysteryman' :
     4012                case 'mm':
     4013                case 'mystery':
     4014                case 'mysteryman':
    38474015                        $args['default'] = 'mm';
    38484016                        break;
    3849                 case 'gravatar_default' :
     4017                case 'gravatar_default':
    38504018                        $args['default'] = false;
    38514019                        break;
    … …  
    38794047
    38804048        $email_hash = '';
    3881         $user = $email = false;
     4049        $user       = $email = false;
    38824050
    38834051        if ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) {
    … …  
    39374105        if ( $email_hash ) {
    39384106                $args['found_avatar'] = true;
    3939                 $gravatar_server = hexdec( $email_hash[0] ) % 3;
     4107                $gravatar_server      = hexdec( $email_hash[0] ) % 3;
    39404108        } else {
    39414109                $gravatar_server = rand( 0, 2 );
Note: See TracChangeset for help on using the changeset viewer.