Make WordPress Core

Changeset 46176


Ignore:
Timestamp:
09/19/2019 01:53:03 AM (5 years ago)
Author:
boonebgorges
Message:

PHPCS: Fix coding standards violations in do_enclose().

  • Use strict checking when appropriate in in_array() checks.
  • Improved comment formatting.
  • Yoda and strict equality checks where appropriate.

See #36824.

File:
1 edited

Legend:

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

    r46175 r46176  
    812812    global $wpdb;
    813813
    814     //TODO: Tidy this ghetto code up and make the debug code optional
     814    // @todo Tidy this code and make the debug code optional.
    815815    include_once( ABSPATH . WPINC . '/class-IXR.php' );
    816816
     
    831831
    832832    foreach ( $pung as $link_test ) {
    833         if ( ! in_array( $link_test, $post_links_temp ) ) { // link no longer in post
     833        // Link is no longer in post.
     834        if ( ! in_array( $link_test, $post_links_temp, true ) ) {
    834835            $mids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post->ID, $wpdb->esc_like( $link_test ) . '%' ) );
    835836            foreach ( $mids as $mid ) {
     
    840841
    841842    foreach ( (array) $post_links_temp as $link_test ) {
    842         if ( ! in_array( $link_test, $pung ) ) { // If we haven't pung it already
     843        // If we haven't pung it already.
     844        if ( ! in_array( $link_test, $pung, true ) ) {
    843845            $test = @parse_url( $link_test );
    844846            if ( false === $test ) {
     
    847849            if ( isset( $test['query'] ) ) {
    848850                $post_links[] = $link_test;
    849             } elseif ( isset( $test['path'] ) && ( $test['path'] != '/' ) && ( $test['path'] != '' ) ) {
     851            } elseif ( isset( $test['path'] ) && ( '/' !== $test['path'] ) && ( '' !== $test['path'] ) ) {
    850852                $post_links[] = $link_test;
    851853            }
     
    867869
    868870    foreach ( (array) $post_links as $url ) {
    869         if ( $url != '' && ! $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post->ID, $wpdb->esc_like( $url ) . '%' ) ) ) {
     871        if ( '' !== $url && ! $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post->ID, $wpdb->esc_like( $url ) . '%' ) ) ) {
    870872
    871873            $headers = wp_get_http_headers( $url );
     
    890892                }
    891893
    892                 if ( in_array( substr( $type, 0, strpos( $type, '/' ) ), $allowed_types ) ) {
     894                if ( in_array( substr( $type, 0, strpos( $type, '/' ) ), $allowed_types, true ) ) {
    893895                    add_post_meta( $post->ID, 'enclosure', "$url\n$len\n$mime\n" );
    894896                }
Note: See TracChangeset for help on using the changeset viewer.