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. git-svn-id: https://develop.svn.wordpress.org/trunk@46176 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
48e280db32
commit
daa1da924d
@ -811,7 +811,7 @@ function wp_extract_urls( $content ) {
|
||||
function do_enclose( $content = null, $post ) {
|
||||
global $wpdb;
|
||||
|
||||
//TODO: Tidy this ghetto code up and make the debug code optional
|
||||
// @todo Tidy this code and make the debug code optional.
|
||||
include_once( ABSPATH . WPINC . '/class-IXR.php' );
|
||||
|
||||
$post = get_post( $post );
|
||||
@ -830,7 +830,8 @@ function do_enclose( $content = null, $post ) {
|
||||
$post_links_temp = wp_extract_urls( $content );
|
||||
|
||||
foreach ( $pung as $link_test ) {
|
||||
if ( ! in_array( $link_test, $post_links_temp ) ) { // link no longer in post
|
||||
// Link is no longer in post.
|
||||
if ( ! in_array( $link_test, $post_links_temp, true ) ) {
|
||||
$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 ) . '%' ) );
|
||||
foreach ( $mids as $mid ) {
|
||||
delete_metadata_by_mid( 'post', $mid );
|
||||
@ -839,14 +840,15 @@ function do_enclose( $content = null, $post ) {
|
||||
}
|
||||
|
||||
foreach ( (array) $post_links_temp as $link_test ) {
|
||||
if ( ! in_array( $link_test, $pung ) ) { // If we haven't pung it already
|
||||
// If we haven't pung it already.
|
||||
if ( ! in_array( $link_test, $pung, true ) ) {
|
||||
$test = @parse_url( $link_test );
|
||||
if ( false === $test ) {
|
||||
continue;
|
||||
}
|
||||
if ( isset( $test['query'] ) ) {
|
||||
$post_links[] = $link_test;
|
||||
} elseif ( isset( $test['path'] ) && ( $test['path'] != '/' ) && ( $test['path'] != '' ) ) {
|
||||
} elseif ( isset( $test['path'] ) && ( '/' !== $test['path'] ) && ( '' !== $test['path'] ) ) {
|
||||
$post_links[] = $link_test;
|
||||
}
|
||||
}
|
||||
@ -866,7 +868,7 @@ function do_enclose( $content = null, $post ) {
|
||||
$post_links = apply_filters( 'enclosure_links', $post_links, $post->ID );
|
||||
|
||||
foreach ( (array) $post_links as $url ) {
|
||||
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 ) . '%' ) ) ) {
|
||||
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 ) . '%' ) ) ) {
|
||||
|
||||
$headers = wp_get_http_headers( $url );
|
||||
if ( $headers ) {
|
||||
@ -889,7 +891,7 @@ function do_enclose( $content = null, $post ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( in_array( substr( $type, 0, strpos( $type, '/' ) ), $allowed_types ) ) {
|
||||
if ( in_array( substr( $type, 0, strpos( $type, '/' ) ), $allowed_types, true ) ) {
|
||||
add_post_meta( $post->ID, 'enclosure', "$url\n$len\n$mime\n" );
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user