From ddc506f01cc333f3f4a15d059ac67edf925769ee Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Fri, 19 Mar 2010 21:15:00 +0000 Subject: [PATCH] Remove unnecessary ternary operators such as (expr) ? true : false. git-svn-id: https://develop.svn.wordpress.org/trunk@13769 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/import/wordpress.php | 2 +- wp-admin/includes/media.php | 2 +- wp-admin/includes/plugin.php | 2 +- wp-admin/includes/post.php | 2 +- wp-admin/includes/template.php | 2 +- wp-admin/includes/upgrade.php | 2 +- wp-admin/install.php | 2 +- wp-app.php | 4 ++-- wp-includes/comment-template.php | 4 ++-- wp-includes/functions.php | 12 ++++++------ wp-includes/media.php | 2 +- wp-includes/pluggable.php | 7 ++----- wp-includes/rewrite.php | 2 +- wp-includes/user.php | 2 +- 14 files changed, 22 insertions(+), 25 deletions(-) diff --git a/wp-admin/import/wordpress.php b/wp-admin/import/wordpress.php index 49166b80ee..0cd576295b 100644 --- a/wp-admin/import/wordpress.php +++ b/wp-admin/import/wordpress.php @@ -866,7 +866,7 @@ class WP_Import { break; case 2: check_admin_referer('import-wordpress'); - $fetch_attachments = (!empty($_POST['attachments'])) ? true : false; + $fetch_attachments = ! empty( $_POST['attachments'] ); $result = $this->import( $_GET['id'], $fetch_attachments); if ( is_wp_error( $result ) ) echo $result->get_error_message(); diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index cd9c8d3ff5..52c0782c6d 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -1191,7 +1191,7 @@ function get_media_item( $attachment_id, $args = null ) { $display_title = ( !empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case $display_title = $show_title ? "
" . wp_html_excerpt( $display_title, 60 ) . "
" : ''; - $gallery = ( ( isset( $_REQUEST['tab'] ) && 'gallery' == $_REQUEST['tab'] ) || ( isset( $redir_tab ) && 'gallery' == $redir_tab ) ) ? true : false; + $gallery = ( ( isset( $_REQUEST['tab'] ) && 'gallery' == $_REQUEST['tab'] ) || ( isset( $redir_tab ) && 'gallery' == $redir_tab ) ); $order = ''; foreach ( $form_fields as $key => $val ) { diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php index 6415a59f5f..901aa8e371 100644 --- a/wp-admin/includes/plugin.php +++ b/wp-admin/includes/plugin.php @@ -92,7 +92,7 @@ function get_plugin_data( $plugin_file, $markup = true, $translate = true ) { _deprecated_argument( __FUNCTION__, '3.0', sprintf( __( 'The %1$s plugin header is deprecated. Use %2$s instead.' ), 'Site Wide Only: true', 'Network: true' ) ); $plugin_data['Network'] = $plugin_data['_sitewide']; } - $plugin_data['Network'] = ( 'true' == strtolower( $plugin_data['Network'] ) ) ? true : false; + $plugin_data['Network'] = ( 'true' == strtolower( $plugin_data['Network'] ) ); unset( $plugin_data['_sitewide'] ); //For backward compatibility by default Title is the same as Name. diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index 86d5a49f10..9f857909f6 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -1457,7 +1457,7 @@ function wp_tiny_mce( $teeny = false, $settings = false ) { $mce_buttons_4 = apply_filters('mce_buttons_4', array()); $mce_buttons_4 = implode($mce_buttons_4, ','); } - $no_captions = ( apply_filters( 'disable_captions', '' ) ) ? true : false; + $no_captions = (bool) apply_filters( 'disable_captions', '' ); // TinyMCE init settings $initArray = array ( diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 6a6658b077..9c53608648 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -2463,7 +2463,7 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { global $wp_locale, $post, $comment; if ( $for_post ) - $edit = ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) ) ? false : true; + $edit = ! ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) ); $tab_index_attribute = ''; if ( (int) $tab_index > 0 ) diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index 87c1f6d8c4..b3008ef197 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -563,7 +563,7 @@ function upgrade_110() { // Check if we already set the GMT fields (if we did, then // MAX(post_date_gmt) can't be '0000-00-00 00:00:00' // I just slapped myself silly for not thinking about it earlier - $got_gmt_fields = ($wpdb->get_var("SELECT MAX(post_date_gmt) FROM $wpdb->posts") == '0000-00-00 00:00:00') ? false : true; + $got_gmt_fields = ! ($wpdb->get_var("SELECT MAX(post_date_gmt) FROM $wpdb->posts") == '0000-00-00 00:00:00'); if (!$got_gmt_fields) { diff --git a/wp-admin/install.php b/wp-admin/install.php index b721c4f188..94509fe8ba 100644 --- a/wp-admin/install.php +++ b/wp-admin/install.php @@ -75,7 +75,7 @@ function display_header() { */ function display_setup_form( $error = null ) { global $wpdb; - $user_table = ( $wpdb->get_var("SHOW TABLES LIKE '$wpdb->users'") != null ) ? true : false; + $user_table = ( $wpdb->get_var("SHOW TABLES LIKE '$wpdb->users'") != null ); // Ensure that Blogs appear in search engines by default $blog_public = 1; diff --git a/wp-app.php b/wp-app.php index d3d81de884..7e07309ce6 100644 --- a/wp-app.php +++ b/wp-app.php @@ -412,7 +412,7 @@ EOD; array_push($post_category, $cat->term_id); } - $publish = (isset($entry->draft) && trim($entry->draft) == 'yes') ? false : true; + $publish = ! ( isset( $entry->draft ) && 'yes' == trim( $entry->draft ) ); $cap = ($publish) ? 'publish_posts' : 'edit_posts'; @@ -505,7 +505,7 @@ EOD; if ( !current_user_can('edit_post', $entry['ID']) ) $this->auth_required(__('Sorry, you do not have the right to edit this post.')); - $publish = (isset($parsed->draft) && trim($parsed->draft) == 'yes') ? false : true; + $publish = ! ( isset($parsed->draft) && 'yes' == trim($parsed->draft) ); $post_status = ($publish) ? 'publish' : 'draft'; extract($entry); diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php index 8e171bd414..242cc7478d 100644 --- a/wp-includes/comment-template.php +++ b/wp-includes/comment-template.php @@ -1418,7 +1418,7 @@ function wp_list_comments($args = array(), $comments = null ) { if ( empty($overridden_cpage) ) { $r['page'] = get_query_var('cpage'); } else { - $threaded = ( -1 == $r['max_depth'] ) ? false : true; + $threaded = ( -1 != $r['max_depth'] ); $r['page'] = ( 'newest' == get_option('default_comments_page') ) ? get_comment_pages_count($_comments, $r['per_page'], $threaded) : 1; set_query_var( 'cpage', $r['page'] ); } @@ -1429,7 +1429,7 @@ function wp_list_comments($args = array(), $comments = null ) { $r['page'] = 1; if ( null === $r['reverse_top_level'] ) - $r['reverse_top_level'] = ( 'desc' == get_option('comment_order') ) ? TRUE : FALSE; + $r['reverse_top_level'] = ( 'desc' == get_option('comment_order') ); extract( $r, EXTR_SKIP ); diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 2e7588c9b4..c5733fd82b 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -3829,13 +3829,13 @@ function wp_timezone_choice( $selected_zone ) { // This determines what gets set and translated - we don't translate Etc/* strings here, they are done later $exists = array( - 0 => ( isset( $zone[0] ) && $zone[0] ) ? true : false, - 1 => ( isset( $zone[1] ) && $zone[1] ) ? true : false, - 2 => ( isset( $zone[2] ) && $zone[2] ) ? true : false + 0 => ( isset( $zone[0] ) && $zone[0] ), + 1 => ( isset( $zone[1] ) && $zone[1] ), + 2 => ( isset( $zone[2] ) && $zone[2] ), ); - $exists[3] = ( $exists[0] && 'Etc' !== $zone[0] ) ? true : false; - $exists[4] = ( $exists[1] && $exists[3] ) ? true : false; - $exists[5] = ( $exists[2] && $exists[3] ) ? true : false; + $exists[3] = ( $exists[0] && 'Etc' !== $zone[0] ); + $exists[4] = ( $exists[1] && $exists[3] ); + $exists[5] = ( $exists[2] && $exists[3] ); $zonen[] = array( 'continent' => ( $exists[0] ? $zone[0] : '' ), diff --git a/wp-includes/media.php b/wp-includes/media.php index 1b1959fbed..2e32367cb6 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -1116,7 +1116,7 @@ class WP_Embed { } // Use oEmbed to get the HTML - $attr['discover'] = ( apply_filters('embed_oembed_discover', false) && author_can( $post_ID, 'unfiltered_html' ) ) ? true : false; + $attr['discover'] = ( apply_filters('embed_oembed_discover', false) && author_can( $post_ID, 'unfiltered_html' ) ); $html = wp_oembed_get( $url, $attr ); // Cache the result diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index 0cc14e9f47..b2182c3209 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -684,7 +684,7 @@ function wp_set_auth_cookie($user_id, $remember = false, $secure = '') { } if ( '' === $secure ) - $secure = is_ssl() ? true : false; + $secure = is_ssl(); if ( $secure ) { $auth_cookie_name = SECURE_AUTH_COOKIE; @@ -777,10 +777,7 @@ if ( !function_exists('auth_redirect') ) : function auth_redirect() { // Checks if a user is logged in, if not redirects them to the login page - if ( is_ssl() || force_ssl_admin() ) - $secure = true; - else - $secure = false; + $secure = ( is_ssl() || force_ssl_admin() ); // If https is required and request is http, redirect if ( $secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin') ) { diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php index 31ccd761fa..cbfa71d6c2 100644 --- a/wp-includes/rewrite.php +++ b/wp-includes/rewrite.php @@ -1958,7 +1958,7 @@ class WP_Rewrite { unset($this->search_structure); unset($this->feed_structure); unset($this->comment_feed_structure); - $this->use_trailing_slashes = ( substr($this->permalink_structure, -1, 1) == '/' ) ? true : false; + $this->use_trailing_slashes = ( '/' == substr($this->permalink_structure, -1, 1) ); // Enable generic rules for pages if permalink structure doesn't begin with a wildcard. if ( preg_match("/^[^%]*%(?:postname|category|tag|author)%/", $this->permalink_structure) ) diff --git a/wp-includes/user.php b/wp-includes/user.php index 8dd1878d13..3dc8756c12 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -41,7 +41,7 @@ function wp_signon( $credentials = '', $secure_cookie = '' ) { do_action_ref_array('wp_authenticate', array(&$credentials['user_login'], &$credentials['user_password'])); if ( '' === $secure_cookie ) - $secure_cookie = is_ssl() ? true : false; + $secure_cookie = is_ssl(); global $auth_secure_cookie; // XXX ugly hack to pass this to wp_authenticate_cookie $auth_secure_cookie = $secure_cookie;