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

See #47632.



git-svn-id: https://develop.svn.wordpress.org/trunk@45583 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast
2019-07-01 12:50:14 +00:00
parent 5fe76184f2
commit 9a1549767e
74 changed files with 634 additions and 337 deletions
+33 -18
View File
@@ -339,7 +339,8 @@ function edit_post( $post_data = null ) {
// Meta Stuff
if ( isset( $post_data['meta'] ) && $post_data['meta'] ) {
foreach ( $post_data['meta'] as $key => $value ) {
if ( ! $meta = get_post_meta_by_id( $key ) ) {
$meta = get_post_meta_by_id( $key );
if ( ! $meta ) {
continue;
}
if ( $meta->post_id != $post_ID ) {
@@ -357,7 +358,8 @@ function edit_post( $post_data = null ) {
if ( isset( $post_data['deletemeta'] ) && $post_data['deletemeta'] ) {
foreach ( $post_data['deletemeta'] as $key => $value ) {
if ( ! $meta = get_post_meta_by_id( $key ) ) {
$meta = get_post_meta_by_id( $key );
if ( ! $meta ) {
continue;
}
if ( $meta->post_id != $post_ID ) {
@@ -531,7 +533,8 @@ function bulk_edit_posts( $post_data = null ) {
}
}
if ( isset( $post_data['post_parent'] ) && ( $parent = (int) $post_data['post_parent'] ) ) {
if ( isset( $post_data['post_parent'] ) && (int) $post_data['post_parent'] ) {
$parent = (int) $post_data['post_parent'];
$pages = $wpdb->get_results( "SELECT ID, post_parent FROM $wpdb->posts WHERE post_type = 'page'" );
$children = array();
@@ -547,7 +550,9 @@ function bulk_edit_posts( $post_data = null ) {
}
}
$updated = $skipped = $locked = array();
$updated = array();
$skipped = array();
$locked = array();
$shared_post_data = $post_data;
foreach ( $post_IDs as $post_ID ) {
@@ -1281,7 +1286,8 @@ function wp_edit_attachments_query( $q = false ) {
function postbox_classes( $box_id, $screen_id ) {
if ( isset( $_GET['edit'] ) && $_GET['edit'] == $box_id ) {
$classes = array( '' );
} elseif ( $closed = get_user_option( 'closedpostboxes_' . $screen_id ) ) {
} elseif ( get_user_option( 'closedpostboxes_' . $screen_id ) ) {
$closed = get_user_option( 'closedpostboxes_' . $screen_id );
if ( ! is_array( $closed ) ) {
$classes = array( '' );
} else {
@@ -1556,11 +1562,13 @@ function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) {
* the user with lock does not exist, or the post is locked by current user.
*/
function wp_check_post_lock( $post_id ) {
if ( ! $post = get_post( $post_id ) ) {
$post = get_post( $post_id );
if ( ! $post ) {
return false;
}
if ( ! $lock = get_post_meta( $post->ID, '_edit_lock', true ) ) {
$lock = get_post_meta( $post->ID, '_edit_lock', true );
if ( ! $lock ) {
return false;
}
@@ -1592,11 +1600,13 @@ function wp_check_post_lock( $post_id ) {
* there is no current user.
*/
function wp_set_post_lock( $post_id ) {
if ( ! $post = get_post( $post_id ) ) {
$post = get_post( $post_id );
if ( ! $post ) {
return false;
}
if ( 0 == ( $user_id = get_current_user_id() ) ) {
$user_id = get_current_user_id();
if ( 0 == $user_id ) {
return false;
}
@@ -1615,12 +1625,14 @@ function wp_set_post_lock( $post_id ) {
* @return none
*/
function _admin_notice_post_locked() {
if ( ! $post = get_post() ) {
$post = get_post();
if ( ! $post ) {
return;
}
$user = null;
if ( $user_id = wp_check_post_lock( $post->ID ) ) {
$user = null;
$user_id = wp_check_post_lock( $post->ID );
if ( $user_id ) {
$user = get_userdata( $user_id );
}
@@ -1646,8 +1658,8 @@ function _admin_notice_post_locked() {
$locked = false;
}
if ( $locked && ( $sendback = wp_get_referer() ) &&
false === strpos( $sendback, 'post.php' ) && false === strpos( $sendback, 'post-new.php' ) ) {
$sendback = wp_get_referer();
if ( $locked && $sendback && false === strpos( $sendback, 'post.php' ) && false === strpos( $sendback, 'post-new.php' ) ) {
$sendback_text = __( 'Go back' );
} else {
@@ -1793,7 +1805,8 @@ function wp_create_post_autosave( $post_data ) {
$post_author = get_current_user_id();
// Store one autosave per author. If there is already an autosave, overwrite it.
if ( $old_autosave = wp_get_post_autosave( $post_id, $post_author ) ) {
$old_autosave = wp_get_post_autosave( $post_id, $post_author );
if ( $old_autosave ) {
$new_autosave = _wp_post_revision_data( $post_data, true );
$new_autosave['ID'] = $old_autosave->ID;
$new_autosave['post_author'] = $post_author;
@@ -1844,7 +1857,8 @@ function post_preview() {
$post_ID = (int) $_POST['post_ID'];
$_POST['ID'] = $post_ID;
if ( ! $post = get_post( $post_ID ) ) {
$post = get_post( $post_ID );
if ( ! $post ) {
wp_die( __( 'Sorry, you are not allowed to edit this post.' ) );
}
@@ -1905,8 +1919,9 @@ function wp_autosave( $post_data ) {
define( 'DOING_AUTOSAVE', true );
}
$post_id = (int) $post_data['post_id'];
$post_data['ID'] = $post_data['post_ID'] = $post_id;
$post_id = (int) $post_data['post_id'];
$post_data['ID'] = $post_id;
$post_data['post_ID'] = $post_id;
if ( false === wp_verify_nonce( $post_data['_wpnonce'], 'update-post_' . $post_id ) ) {
return new WP_Error( 'invalid_nonce', __( 'Error while saving.' ) );