Make WordPress Core


Ignore:
Timestamp:
07/01/2019 12:50:14 PM (6 years ago)
Author:
pento
Message:

Coding Standards: Fix the Squiz.PHP.DisallowMultipleAssignments violations in wp-admin.

See #47632.

File:
1 edited

Legend:

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

    r45499 r45583  
    288288
    289289    $time = current_time( 'mysql' );
    290     if ( $post = get_post( $post_id ) ) {
     290    $post = get_post( $post_id );
     291    if ( $post ) {
    291292        // The post date doesn't usually matter for pages, so don't backdate this upload.
    292293        if ( 'page' !== $post->post_type && substr( $post->post_date, 0, 4 ) > 0 ) {
     
    370371
    371372        // Use image exif/iptc data for title and caption defaults if possible.
    372     } elseif ( 0 === strpos( $type, 'image/' ) && $image_meta = wp_read_image_metadata( $file ) ) {
    373         if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) {
    374             $title = $image_meta['title'];
    375         }
    376 
    377         if ( trim( $image_meta['caption'] ) ) {
    378             $excerpt = $image_meta['caption'];
     373    } elseif ( 0 === strpos( $type, 'image/' ) ) {
     374        $image_meta = wp_read_image_metadata( $file );
     375        if ( $image_meta ) {
     376            if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) {
     377                $title = $image_meta['title'];
     378            }
     379
     380            if ( trim( $image_meta['caption'] ) ) {
     381                $excerpt = $image_meta['caption'];
     382            }
    379383        }
    380384    }
     
    421425
    422426    $time = current_time( 'mysql' );
    423     if ( $post = get_post( $post_id ) ) {
     427    $post = get_post( $post_id );
     428    if ( $post ) {
    424429        if ( substr( $post->post_date, 0, 4 ) > 0 ) {
    425430            $time = $post->post_date;
     
    439444
    440445    // Use image exif/iptc data for title and caption defaults if possible.
    441     if ( $image_meta = wp_read_image_metadata( $file ) ) {
     446    $image_meta = wp_read_image_metadata( $file );
     447    if ( $image_meta ) {
    442448        if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) {
    443449            $title = $image_meta['title'];
     
    693699    if ( ! empty( $_POST['attachments'] ) ) {
    694700        foreach ( $_POST['attachments'] as $attachment_id => $attachment ) {
    695             $post = $_post = get_post( $attachment_id, ARRAY_A );
     701            $post  = get_post( $attachment_id, ARRAY_A );
     702            $_post = $post;
    696703
    697704            if ( ! current_user_can( 'edit_post', $attachment_id ) ) {
     
    836843
    837844            $type = 'file';
    838             if ( ( $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src ) ) && ( $ext_type = wp_ext2type( $ext ) )
    839                 && ( 'audio' == $ext_type || 'video' == $ext_type ) ) {
     845            $ext  = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src );
     846            if ( $ext ) {
     847                $ext_type = wp_ext2type( $ext );
     848                if ( 'audio' == $ext_type || 'video' == $ext_type ) {
    840849                    $type = $ext_type;
     850                }
    841851            }
    842852
     
    14411451            continue;
    14421452        }
    1443         if ( $item = get_media_item( $id, array( 'errors' => isset( $errors[ $id ] ) ? $errors[ $id ] : null ) ) ) {
     1453        $item = get_media_item( $id, array( 'errors' => isset( $errors[ $id ] ) ? $errors[ $id ] : null ) );
     1454        if ( $item ) {
    14441455            $output .= "\n<div id='media-item-$id' class='media-item child-of-$attachment->post_parent preloaded'><div class='progress hidden'><div class='bar'></div></div><div id='media-upload-error-$id' class='hidden'></div><div class='filename hidden'></div>$item\n</div>";
    14451456        }
     
    14631474    global $redir_tab;
    14641475
    1465     if ( ( $attachment_id = intval( $attachment_id ) ) && $thumb_url = wp_get_attachment_image_src( $attachment_id, 'thumbnail', true ) ) {
    1466         $thumb_url = $thumb_url[0];
    1467     } else {
    1468         $thumb_url = false;
     1476    $thumb_url     = false;
     1477    $attachment_id = intval( $attachment_id );
     1478
     1479    if ( $attachment_id ) {
     1480        $thumb_url = wp_get_attachment_image_src( $attachment_id, 'thumbnail', true );
     1481        if ( $thumb_url ) {
     1482            $thumb_url = $thumb_url[0];
     1483        }
    14691484    }
    14701485
     
    27542769        $table_class = '';
    27552770    } else {
    2756         $view = $table_class = 'not-image';
     2771        $view        = 'not-image';
     2772        $table_class = $view;
    27572773    }
    27582774
     
    28372853    $browser_uploader = admin_url( 'media-new.php?browser-uploader' );
    28382854
    2839     if ( $post = get_post() ) {
     2855    $post = get_post();
     2856    if ( $post ) {
    28402857        $browser_uploader .= '&amp;post_id=' . intval( $post->ID );
    28412858    } elseif ( ! empty( $GLOBALS['post_ID'] ) ) {
     
    28772894function media_upload_max_image_resize() {
    28782895    $checked = get_user_setting( 'upload_resize' ) ? ' checked="true"' : '';
    2879     $a       = $end = '';
     2896    $a       = '';
     2897    $end     = '';
    28802898
    28812899    if ( current_user_can( 'manage_options' ) ) {
     
    29202938    }
    29212939
    2922     $thumb_url = false;
    2923     if ( $attachment_id = intval( $post->ID ) ) {
     2940    $thumb_url     = false;
     2941    $attachment_id = intval( $post->ID );
     2942    if ( $attachment_id ) {
    29242943        $thumb_url = wp_get_attachment_image_src( $attachment_id, array( 900, 450 ), true );
    29252944    }
     
    29382957        }
    29392958
    2940         $open_style = $not_open_style = '';
     2959        $open_style     = '';
     2960        $not_open_style = '';
    29412961        if ( $open ) {
    29422962            $open_style = ' style="display:none"';
     
    35123532    if ( isset( $result ) ) {
    35133533        $location = 'upload.php';
    3514         if ( $referer = wp_get_referer() ) {
     3534        $referer  = wp_get_referer();
     3535        if ( $referer ) {
    35153536            if ( false !== strpos( $referer, 'upload.php' ) ) {
    35163537                $location = remove_query_arg( array( 'attached', 'detach' ), $referer );
Note: See TracChangeset for help on using the changeset viewer.