Coding Standards: Use Yoda conditions where appropriate.
See #49222. Built from https://develop.svn.wordpress.org/trunk@47219 git-svn-id: http://core.svn.wordpress.org/trunk@47019 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -696,7 +696,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
|
||||
foreach ( $blogs as $blog ) {
|
||||
// Don't include blogs that aren't hosted at this site.
|
||||
if ( $blog->site_id != get_current_network_id() ) {
|
||||
if ( get_current_network_id() != $blog->site_id ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -827,7 +827,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
* @return IXR_Date IXR_Date object.
|
||||
*/
|
||||
protected function _convert_date( $date ) {
|
||||
if ( $date === '0000-00-00 00:00:00' ) {
|
||||
if ( '0000-00-00 00:00:00' === $date ) {
|
||||
return new IXR_Date( '00000000T00:00:00Z' );
|
||||
}
|
||||
return new IXR_Date( mysql2date( 'Ymd\TH:i:s', $date, false ) );
|
||||
@@ -841,7 +841,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
* @return IXR_Date IXR_Date object.
|
||||
*/
|
||||
protected function _convert_date_gmt( $date_gmt, $date ) {
|
||||
if ( $date !== '0000-00-00 00:00:00' && $date_gmt === '0000-00-00 00:00:00' ) {
|
||||
if ( '0000-00-00 00:00:00' !== $date && '0000-00-00 00:00:00' === $date_gmt ) {
|
||||
return new IXR_Date( get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $date, false ), 'Ymd\TH:i:s' ) );
|
||||
}
|
||||
return $this->_convert_date( $date_gmt );
|
||||
@@ -879,7 +879,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
'menu_order' => intval( $post['menu_order'] ),
|
||||
'comment_status' => $post['comment_status'],
|
||||
'ping_status' => $post['ping_status'],
|
||||
'sticky' => ( $post['post_type'] === 'post' && is_sticky( $post['ID'] ) ),
|
||||
'sticky' => ( 'post' === $post['post_type'] && is_sticky( $post['ID'] ) ),
|
||||
);
|
||||
|
||||
// Thumbnail.
|
||||
@@ -891,7 +891,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
}
|
||||
|
||||
// Consider future posts as published.
|
||||
if ( $post_fields['post_status'] === 'future' ) {
|
||||
if ( 'future' === $post_fields['post_status'] ) {
|
||||
$post_fields['post_status'] = 'publish';
|
||||
}
|
||||
|
||||
@@ -1286,7 +1286,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
* since _insert_post() will ignore the non-GMT date if the GMT date is set.
|
||||
*/
|
||||
if ( isset( $content_struct['post_date_gmt'] ) && ! ( $content_struct['post_date_gmt'] instanceof IXR_Date ) ) {
|
||||
if ( $content_struct['post_date_gmt'] == '0000-00-00 00:00:00' || isset( $content_struct['post_date'] ) ) {
|
||||
if ( '0000-00-00 00:00:00' === $content_struct['post_date_gmt'] || isset( $content_struct['post_date'] ) ) {
|
||||
unset( $content_struct['post_date_gmt'] );
|
||||
} else {
|
||||
$content_struct['post_date_gmt'] = $this->_convert_date( $content_struct['post_date_gmt'] );
|
||||
@@ -1401,7 +1401,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
if ( ! current_user_can( 'edit_post', $post_data['ID'] ) ) {
|
||||
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
|
||||
}
|
||||
if ( $post_data['post_type'] != get_post_type( $post_data['ID'] ) ) {
|
||||
if ( get_post_type( $post_data['ID'] ) !== $post_data['post_type'] ) {
|
||||
return new IXR_Error( 401, __( 'The post type may not be changed.' ) );
|
||||
}
|
||||
} else {
|
||||
@@ -1451,11 +1451,11 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
$post_data['post_author'] = $user->ID;
|
||||
}
|
||||
|
||||
if ( isset( $post_data['comment_status'] ) && $post_data['comment_status'] != 'open' && $post_data['comment_status'] != 'closed' ) {
|
||||
if ( isset( $post_data['comment_status'] ) && 'open' !== $post_data['comment_status'] && 'closed' !== $post_data['comment_status'] ) {
|
||||
unset( $post_data['comment_status'] );
|
||||
}
|
||||
|
||||
if ( isset( $post_data['ping_status'] ) && $post_data['ping_status'] != 'open' && $post_data['ping_status'] != 'closed' ) {
|
||||
if ( isset( $post_data['ping_status'] ) && 'open' !== $post_data['ping_status'] && 'closed' !== $post_data['ping_status'] ) {
|
||||
unset( $post_data['ping_status'] );
|
||||
}
|
||||
|
||||
@@ -1483,7 +1483,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
}
|
||||
$post_ID = $post_data['ID'];
|
||||
|
||||
if ( $post_data['post_type'] == 'post' ) {
|
||||
if ( 'post' === $post_data['post_type'] ) {
|
||||
$error = $this->_toggle_sticky( $post_data, $update );
|
||||
if ( $error ) {
|
||||
return $error;
|
||||
@@ -1708,7 +1708,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
* Ignore the existing GMT date if it is empty or a non-GMT date was supplied in $content_struct,
|
||||
* since _insert_post() will ignore the non-GMT date if the GMT date is set.
|
||||
*/
|
||||
if ( $post['post_date_gmt'] == '0000-00-00 00:00:00' || isset( $content_struct['post_date'] ) ) {
|
||||
if ( '0000-00-00 00:00:00' === $post['post_date_gmt'] || isset( $content_struct['post_date'] ) ) {
|
||||
unset( $post['post_date_gmt'] );
|
||||
} else {
|
||||
$post['post_date_gmt'] = $this->_convert_date( $post['post_date_gmt'] );
|
||||
@@ -2929,7 +2929,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
do_action( 'xmlrpc_call', 'wp.getPage' );
|
||||
|
||||
// If we found the page then format the data.
|
||||
if ( $page->ID && ( $page->post_type == 'page' ) ) {
|
||||
if ( $page->ID && ( 'page' === $page->post_type ) ) {
|
||||
return $this->_prepare_page( $page );
|
||||
} else {
|
||||
// If the page doesn't exist, indicate that.
|
||||
@@ -3066,7 +3066,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
// Get the current page based on the 'page_id' and
|
||||
// make sure it is a page and not a post.
|
||||
$actual_page = get_post( $page_id, ARRAY_A );
|
||||
if ( ! $actual_page || ( $actual_page['post_type'] != 'page' ) ) {
|
||||
if ( ! $actual_page || ( 'page' !== $actual_page['post_type'] ) ) {
|
||||
return new IXR_Error( 404, __( 'Sorry, no such page.' ) );
|
||||
}
|
||||
|
||||
@@ -3132,7 +3132,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
|
||||
// Get the page data and make sure it is a page.
|
||||
$actual_page = get_post( $page_id, ARRAY_A );
|
||||
if ( ! $actual_page || ( $actual_page['post_type'] != 'page' ) ) {
|
||||
if ( ! $actual_page || ( 'page' !== $actual_page['post_type'] ) ) {
|
||||
return new IXR_Error( 404, __( 'Sorry, no such page.' ) );
|
||||
}
|
||||
|
||||
@@ -4238,7 +4238,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( $this->blog_options[ $o_name ]['readonly'] == true ) {
|
||||
if ( true == $this->blog_options[ $o_name ]['readonly'] ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -5114,7 +5114,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
|
||||
$actual_post = get_post( $post_ID, ARRAY_A );
|
||||
|
||||
if ( ! $actual_post || $actual_post['post_type'] != 'post' ) {
|
||||
if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) {
|
||||
return new IXR_Error( 404, __( 'Sorry, no such post.' ) );
|
||||
}
|
||||
|
||||
@@ -5123,7 +5123,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
if ( ! current_user_can( 'edit_post', $post_ID ) ) {
|
||||
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
|
||||
}
|
||||
if ( 'publish' == $actual_post['post_status'] && ! current_user_can( 'publish_posts' ) ) {
|
||||
if ( 'publish' === $actual_post['post_status'] && ! current_user_can( 'publish_posts' ) ) {
|
||||
return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) );
|
||||
}
|
||||
|
||||
@@ -5188,7 +5188,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
|
||||
$actual_post = get_post( $post_ID, ARRAY_A );
|
||||
|
||||
if ( ! $actual_post || $actual_post['post_type'] != 'post' ) {
|
||||
if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) {
|
||||
return new IXR_Error( 404, __( 'Sorry, no such post.' ) );
|
||||
}
|
||||
|
||||
@@ -5276,10 +5276,10 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
|
||||
$page_template = '';
|
||||
if ( ! empty( $content_struct['post_type'] ) ) {
|
||||
if ( $content_struct['post_type'] == 'page' ) {
|
||||
if ( 'page' === $content_struct['post_type'] ) {
|
||||
if ( $publish ) {
|
||||
$cap = 'publish_pages';
|
||||
} elseif ( isset( $content_struct['page_status'] ) && 'publish' == $content_struct['page_status'] ) {
|
||||
} elseif ( isset( $content_struct['page_status'] ) && 'publish' === $content_struct['page_status'] ) {
|
||||
$cap = 'publish_pages';
|
||||
} else {
|
||||
$cap = 'edit_pages';
|
||||
@@ -5289,10 +5289,10 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
if ( ! empty( $content_struct['wp_page_template'] ) ) {
|
||||
$page_template = $content_struct['wp_page_template'];
|
||||
}
|
||||
} elseif ( $content_struct['post_type'] == 'post' ) {
|
||||
} elseif ( 'post' === $content_struct['post_type'] ) {
|
||||
if ( $publish ) {
|
||||
$cap = 'publish_posts';
|
||||
} elseif ( isset( $content_struct['post_status'] ) && 'publish' == $content_struct['post_status'] ) {
|
||||
} elseif ( isset( $content_struct['post_status'] ) && 'publish' === $content_struct['post_status'] ) {
|
||||
$cap = 'publish_posts';
|
||||
} else {
|
||||
$cap = 'edit_posts';
|
||||
@@ -5306,7 +5306,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
} else {
|
||||
if ( $publish ) {
|
||||
$cap = 'publish_posts';
|
||||
} elseif ( isset( $content_struct['post_status'] ) && 'publish' == $content_struct['post_status'] ) {
|
||||
} elseif ( isset( $content_struct['post_status'] ) && 'publish' === $content_struct['post_status'] ) {
|
||||
$cap = 'publish_posts';
|
||||
} else {
|
||||
$cap = 'edit_posts';
|
||||
@@ -5513,7 +5513,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
$postdata['ID'] = $post_ID;
|
||||
|
||||
// Only posts can be sticky.
|
||||
if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) {
|
||||
if ( 'post' === $post_type && isset( $content_struct['sticky'] ) ) {
|
||||
$data = $postdata;
|
||||
$data['sticky'] = $content_struct['sticky'];
|
||||
$error = $this->_toggle_sticky( $data );
|
||||
@@ -5846,7 +5846,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
|
||||
$tags_input = isset( $content_struct['mt_keywords'] ) ? $content_struct['mt_keywords'] : null;
|
||||
|
||||
if ( 'publish' == $post_status || 'private' == $post_status ) {
|
||||
if ( 'publish' === $post_status || 'private' === $post_status ) {
|
||||
if ( 'page' == $post_type && ! current_user_can( 'publish_pages' ) ) {
|
||||
return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this page.' ) );
|
||||
} elseif ( ! current_user_can( 'publish_posts' ) ) {
|
||||
@@ -5901,7 +5901,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
}
|
||||
|
||||
// Only posts can be sticky.
|
||||
if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) {
|
||||
if ( 'post' === $post_type && isset( $content_struct['sticky'] ) ) {
|
||||
$data = $newpost;
|
||||
$data['sticky'] = $content_struct['sticky'];
|
||||
$data['post_type'] = 'post';
|
||||
@@ -5991,7 +5991,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
|
||||
do_action( 'xmlrpc_call', 'metaWeblog.getPost' );
|
||||
|
||||
if ( $postdata['post_date'] != '' ) {
|
||||
if ( '' != $postdata['post_date'] ) {
|
||||
$post_date = $this->_convert_date( $postdata['post_date'] );
|
||||
$post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] );
|
||||
$post_modified = $this->_convert_date( $postdata['post_modified'] );
|
||||
@@ -6024,7 +6024,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
$allow_pings = ( 'open' == $postdata['ping_status'] ) ? 1 : 0;
|
||||
|
||||
// Consider future posts as published.
|
||||
if ( $postdata['post_status'] === 'future' ) {
|
||||
if ( 'future' === $postdata['post_status'] ) {
|
||||
$postdata['post_status'] = 'publish';
|
||||
}
|
||||
|
||||
@@ -6041,7 +6041,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
|
||||
$enclosure = array();
|
||||
foreach ( (array) get_post_custom( $post_ID ) as $key => $val ) {
|
||||
if ( $key == 'enclosure' ) {
|
||||
if ( 'enclosure' === $key ) {
|
||||
foreach ( (array) $val as $enc ) {
|
||||
$encdata = explode( "\n", $enc );
|
||||
$enclosure['url'] = trim( htmlspecialchars( $encdata[0] ) );
|
||||
@@ -6176,7 +6176,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
$allow_pings = ( 'open' == $entry['ping_status'] ) ? 1 : 0;
|
||||
|
||||
// Consider future posts as published.
|
||||
if ( $entry['post_status'] === 'future' ) {
|
||||
if ( 'future' === $entry['post_status'] ) {
|
||||
$entry['post_status'] = 'publish';
|
||||
}
|
||||
|
||||
@@ -6213,7 +6213,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
'wp_post_format' => $post_format,
|
||||
'date_modified' => $post_modified,
|
||||
'date_modified_gmt' => $post_modified_gmt,
|
||||
'sticky' => ( $entry['post_type'] === 'post' && is_sticky( $entry['ID'] ) ),
|
||||
'sticky' => ( 'post' === $entry['post_type'] && is_sticky( $entry['ID'] ) ),
|
||||
'wp_post_thumbnail' => get_post_thumbnail_id( $entry['ID'] ),
|
||||
);
|
||||
}
|
||||
@@ -6839,7 +6839,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.' ) );
|
||||
}
|
||||
|
||||
if ( $post_ID == url_to_postid( $pagelinkedfrom ) ) {
|
||||
if ( url_to_postid( $pagelinkedfrom ) == $post_ID ) {
|
||||
return $this->pingback_error( 0, __( 'The source URL and the target URL cannot both point to the same resource.' ) );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user