Make WordPress Core


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

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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/bookmark.php

    r42228 r42343  
    3535    }
    3636
    37     $_POST['link_url'] = esc_html( $_POST['link_url'] );
    38     $_POST['link_url'] = esc_url($_POST['link_url']);
    39     $_POST['link_name'] = esc_html( $_POST['link_name'] );
     37    $_POST['link_url']   = esc_html( $_POST['link_url'] );
     38    $_POST['link_url']   = esc_url( $_POST['link_url'] );
     39    $_POST['link_name']  = esc_html( $_POST['link_name'] );
    4040    $_POST['link_image'] = esc_html( $_POST['link_image'] );
    41     $_POST['link_rss'] = esc_url($_POST['link_rss']);
    42     if ( !isset($_POST['link_visible']) || 'N' != $_POST['link_visible'] )
     41    $_POST['link_rss']   = esc_url( $_POST['link_rss'] );
     42    if ( ! isset( $_POST['link_visible'] ) || 'N' != $_POST['link_visible'] ) {
    4343        $_POST['link_visible'] = 'Y';
    44 
    45     if ( !empty( $link_id ) ) {
     44    }
     45
     46    if ( ! empty( $link_id ) ) {
    4647        $_POST['link_id'] = $link_id;
    4748        return wp_update_link( $_POST );
     
    6061function get_default_link_to_edit() {
    6162    $link = new stdClass;
    62     if ( isset( $_GET['linkurl'] ) )
     63    if ( isset( $_GET['linkurl'] ) ) {
    6364        $link->link_url = esc_url( wp_unslash( $_GET['linkurl'] ) );
    64     else
     65    } else {
    6566        $link->link_url = '';
    66 
    67     if ( isset( $_GET['name'] ) )
     67    }
     68
     69    if ( isset( $_GET['name'] ) ) {
    6870        $link->link_name = esc_attr( wp_unslash( $_GET['name'] ) );
    69     else
     71    } else {
    7072        $link->link_name = '';
     73    }
    7174
    7275    $link->link_visible = 'Y';
     
    123126 */
    124127function wp_get_link_cats( $link_id = 0 ) {
    125     $cats = wp_get_object_terms( $link_id, 'link_category', array('fields' => 'ids') );
     128    $cats = wp_get_object_terms( $link_id, 'link_category', array( 'fields' => 'ids' ) );
    126129    return array_unique( $cats );
    127130}
     
    153156    global $wpdb;
    154157
    155     $defaults = array( 'link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0 );
     158    $defaults = array(
     159        'link_id'     => 0,
     160        'link_name'   => '',
     161        'link_url'    => '',
     162        'link_rating' => 0,
     163    );
    156164
    157165    $args = wp_parse_args( $linkdata, $defaults );
    158     $r = wp_unslash( sanitize_bookmark( $args, 'db' ) );
     166    $r    = wp_unslash( sanitize_bookmark( $args, 'db' ) );
    159167
    160168    $link_id   = $r['link_id'];
     
    250258function wp_set_link_cats( $link_id = 0, $link_categories = array() ) {
    251259    // If $link_categories isn't already an array, make it one:
    252     if ( !is_array( $link_categories ) || 0 == count( $link_categories ) )
     260    if ( ! is_array( $link_categories ) || 0 == count( $link_categories ) ) {
    253261        $link_categories = array( get_option( 'default_link_category' ) );
     262    }
    254263
    255264    $link_categories = array_map( 'intval', $link_categories );
     
    278287
    279288    // Passed link category list overwrites existing category list if not empty.
    280     if ( isset( $linkdata['link_category'] ) && is_array( $linkdata['link_category'] ) && 0 != count( $linkdata['link_category'] ) )
     289    if ( isset( $linkdata['link_category'] ) && is_array( $linkdata['link_category'] ) && 0 != count( $linkdata['link_category'] ) ) {
    281290        $link_cats = $linkdata['link_category'];
    282     else
     291    } else {
    283292        $link_cats = $link['link_category'];
     293    }
    284294
    285295    // Merge old and new fields with new fields overwriting old ones.
    286     $linkdata = array_merge( $link, $linkdata );
     296    $linkdata                  = array_merge( $link, $linkdata );
    287297    $linkdata['link_category'] = $link_cats;
    288298
     
    300310function wp_link_manager_disabled_message() {
    301311    global $pagenow;
    302     if ( 'link-manager.php' != $pagenow && 'link-add.php' != $pagenow && 'link.php' != $pagenow )
     312    if ( 'link-manager.php' != $pagenow && 'link-add.php' != $pagenow && 'link.php' != $pagenow ) {
    303313        return;
     314    }
    304315
    305316    add_filter( 'pre_option_link_manager_enabled', '__return_true', 100 );
Note: See TracChangeset for help on using the changeset viewer.