Coding standards, space after if

git-svn-id: https://develop.svn.wordpress.org/trunk@12752 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2010-01-18 20:34:48 +00:00
parent 333b3c517c
commit e2adfc832a
38 changed files with 349 additions and 398 deletions
@@ -156,7 +156,7 @@ class WP_Filesystem_Base {
$this->cache[ $folder ] = $folder;
return $folder;
}
if( $return = $this->search_for_folder($folder) )
if ( $return = $this->search_for_folder($folder) )
$this->cache[ $folder ] = $return;
return $return;
}
@@ -288,8 +288,8 @@ class WP_Filesystem_Base {
$legal = array('', 'w', 'r', 'x', '-');
$attarray = preg_split('//', $mode);
for($i=0; $i < count($attarray); $i++)
if($key = array_search($attarray[$i], $legal))
for ($i=0; $i < count($attarray); $i++)
if ($key = array_search($attarray[$i], $legal))
$realmode .= $legal[$key];
$mode = str_pad($realmode, 9, '-');
@@ -171,7 +171,7 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
function cwd() {
$cwd = $this->run_command('pwd');
if( $cwd )
if ( $cwd )
$cwd = trailingslashit($cwd);
return $cwd;
}
@@ -239,10 +239,10 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
}
function copy($source, $destination, $overwrite = false ) {
if( ! $overwrite && $this->exists($destination) )
if ( ! $overwrite && $this->exists($destination) )
return false;
$content = $this->get_contents($source);
if( false === $content)
if ( false === $content)
return false;
return $this->put_contents($destination, $content);
}
+1 -1
View File
@@ -912,7 +912,7 @@ class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
return;
$this->plugin = $this->upgrader->plugin_info();
if( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){
if ( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){
show_message(__('Reactivating the plugin&#8230;'));
echo '<iframe style="border:0;overflow:hidden" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&plugin=' . $this->plugin, 'activate-plugin_' . $this->plugin) .'"></iframe>';
}
+8 -8
View File
@@ -109,10 +109,10 @@ function get_real_file_to_edit( $file ) {
* @return bool|array False on failure, Else array of files
*/
function list_files( $folder = '', $levels = 100 ) {
if( empty($folder) )
if ( empty($folder) )
return false;
if( ! $levels )
if ( ! $levels )
return false;
$files = array();
@@ -122,7 +122,7 @@ function list_files( $folder = '', $levels = 100 ) {
continue;
if ( is_dir( $folder . '/' . $file ) ) {
$files2 = list_files( $folder . '/' . $file, $levels - 1);
if( $files2 )
if ( $files2 )
$files = array_merge($files, $files2 );
else
$files[] = $folder . '/' . $file . '/';
@@ -621,7 +621,7 @@ function WP_Filesystem( $args = false, $context = false ) {
if ( ! class_exists("WP_Filesystem_$method") ) {
$abstraction_file = apply_filters('filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method);
if( ! file_exists($abstraction_file) )
if ( ! file_exists($abstraction_file) )
return;
require_once($abstraction_file);
@@ -670,7 +670,7 @@ function WP_Filesystem( $args = false, $context = false ) {
function get_filesystem_method($args = array(), $context = false) {
$method = defined('FS_METHOD') ? FS_METHOD : false; //Please ensure that this is either 'direct', 'ssh', 'ftpext' or 'ftpsockets'
if( ! $method && function_exists('getmyuid') && function_exists('fileowner') ){
if ( ! $method && function_exists('getmyuid') && function_exists('fileowner') ){
if ( !$context )
$context = WP_CONTENT_DIR;
$context = trailingslashit($context);
@@ -807,12 +807,12 @@ jQuery(function($){
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="hostname"><?php _e('Hostname') ?></label></th>
<td><input name="hostname" type="text" id="hostname" value="<?php echo esc_attr($hostname); if ( !empty($port) ) echo ":$port"; ?>"<?php if( defined('FTP_HOST') ) echo ' disabled="disabled"' ?> size="40" /></td>
<td><input name="hostname" type="text" id="hostname" value="<?php echo esc_attr($hostname); if ( !empty($port) ) echo ":$port"; ?>"<?php if ( defined('FTP_HOST') ) echo ' disabled="disabled"' ?> size="40" /></td>
</tr>
<tr valign="top">
<th scope="row"><label for="username"><?php _e('Username') ?></label></th>
<td><input name="username" type="text" id="username" value="<?php echo esc_attr($username) ?>"<?php if( defined('FTP_USER') ) echo ' disabled="disabled"' ?> size="40" /></td>
<td><input name="username" type="text" id="username" value="<?php echo esc_attr($username) ?>"<?php if ( defined('FTP_USER') ) echo ' disabled="disabled"' ?> size="40" /></td>
</tr>
<tr valign="top">
@@ -827,7 +827,7 @@ jQuery(function($){
<label for="public_key"><?php _e('Public Key:') ?></label ><br />
<label for="private_key"><?php _e('Private Key:') ?></label>
</div></th>
<td><br /><input name="public_key" type="text" id="public_key" value="<?php echo esc_attr($public_key) ?>"<?php if( defined('FTP_PUBKEY') ) echo ' disabled="disabled"' ?> size="40" /><br /><input name="private_key" type="text" id="private_key" value="<?php echo esc_attr($private_key) ?>"<?php if( defined('FTP_PRIKEY') ) echo ' disabled="disabled"' ?> size="40" />
<td><br /><input name="public_key" type="text" id="public_key" value="<?php echo esc_attr($public_key) ?>"<?php if ( defined('FTP_PUBKEY') ) echo ' disabled="disabled"' ?> size="40" /><br /><input name="private_key" type="text" id="private_key" value="<?php echo esc_attr($private_key) ?>"<?php if ( defined('FTP_PRIKEY') ) echo ' disabled="disabled"' ?> size="40" />
<div><?php _e('Enter the location on the server where the keys are located. If a passphrase is needed, enter that in the password field above.') ?></div></td>
</tr>
<?php endif; ?>
+2 -2
View File
@@ -266,8 +266,8 @@ function wp_reset_vars( $vars ) {
* @param unknown_type $message
*/
function show_message($message) {
if( is_wp_error($message) ){
if( $message->get_error_data() )
if ( is_wp_error($message) ){
if ( $message->get_error_data() )
$message = $message->get_error_message() . ': ' . $message->get_error_data();
else
$message = $message->get_error_message();
+66 -66
View File
@@ -3,7 +3,7 @@ function check_upload_size( $file ) {
if ( get_site_option( 'upload_space_check_disabled' ) ) {
return $file;
}
if( $file['error'] != '0' ) // there's already an error
if ( $file['error'] != '0' ) // there's already an error
return $file;
if ( defined( 'WP_IMPORTING' ) )
@@ -13,14 +13,14 @@ function check_upload_size( $file ) {
$space_used = get_dirsize( BLOGUPLOADDIR );
$space_left = $space_allowed - $space_used;
$file_size = filesize( $file['tmp_name'] );
if( $space_left < $file_size )
if ( $space_left < $file_size )
$file['error'] = sprintf( __( 'Not enough space to upload. %1$s Kb needed.' ), number_format( ($file_size - $space_left) /1024 ) );
if( $file_size > ( 1024 * get_site_option( 'fileupload_maxk', 1500 ) ) )
if ( $file_size > ( 1024 * get_site_option( 'fileupload_maxk', 1500 ) ) )
$file['error'] = sprintf(__('This file is too big. Files must be less than %1$s Kb in size.'), get_site_option( 'fileupload_maxk', 1500 ) );
if( upload_is_user_over_quota( false ) ) {
if ( upload_is_user_over_quota( false ) ) {
$file['error'] = __('You have used your space quota. Please delete files before uploading.');
}
if( $file['error'] != '0' )
if ( $file['error'] != '0' )
wp_die( $file['error'] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' );
return $file;
@@ -90,7 +90,7 @@ function wpmu_delete_blog($blog_id, $drop = false) {
$blogs = get_site_option( "blog_list" );
if ( is_array( $blogs ) ) {
foreach( $blogs as $n => $blog ) {
if( $blog[ 'blog_id' ] == $blog_id ) {
if ( $blog[ 'blog_id' ] == $blog_id ) {
unset( $blogs[ $n ] );
}
}
@@ -138,7 +138,7 @@ function wpmu_delete_user($id) {
}
function confirm_delete_users( $users ) {
if( !is_array( $users ) )
if ( !is_array( $users ) )
return false;
echo '<p>' . __( 'Transfer posts before deleting users:' ) . '</p>';
@@ -147,25 +147,25 @@ function confirm_delete_users( $users ) {
echo '<input type="hidden" name="alluser_transfer_delete" />';
wp_nonce_field( 'allusers' );
foreach ( (array) $_POST['allusers'] as $key => $val ) {
if( $val != '' && $val != '0' ) {
if ( $val != '' && $val != '0' ) {
$user = new WP_User( $val );
if ( in_array( $user->user_login, get_site_option( 'site_admins', array( 'admin' ) ) ) ) {
wp_die( sprintf( __( 'Warning! User cannot be deleted. The user %s is a site admnistrator.' ), $user->user_login ) );
}
echo "<input type='hidden' name='user[]' value='{$val}'/>\n";
$blogs = get_blogs_of_user( $val, true );
if( !empty( $blogs ) ) {
if ( !empty( $blogs ) ) {
foreach ( (array) $blogs as $key => $details ) {
$blog_users = get_users_of_blog( $details->userblog_id );
if( is_array( $blog_users ) && !empty( $blog_users ) ) {
if ( is_array( $blog_users ) && !empty( $blog_users ) ) {
echo "<p><a href='http://{$details->domain}{$details->path}'>{$details->blogname}</a> ";
echo "<select name='blog[$val][{$key}]'>";
$out = '';
foreach( $blog_users as $user ) {
if( $user->user_id != $val )
if ( $user->user_id != $val )
$out .= "<option value='{$user->user_id}'>{$user->user_login}</option>";
}
if( $out == '' )
if ( $out == '' )
$out = "<option value='1'>admin</option>";
echo $out;
echo "</select>\n";
@@ -182,17 +182,17 @@ function confirm_delete_users( $users ) {
function wpmu_get_blog_allowedthemes( $blog_id = 0 ) {
$themes = get_themes();
if( $blog_id != 0 )
if ( $blog_id != 0 )
switch_to_blog( $blog_id );
$blog_allowed_themes = get_option( "allowedthemes" );
if( !is_array( $blog_allowed_themes ) || empty( $blog_allowed_themes ) ) { // convert old allowed_themes to new allowedthemes
if ( !is_array( $blog_allowed_themes ) || empty( $blog_allowed_themes ) ) { // convert old allowed_themes to new allowedthemes
$blog_allowed_themes = get_option( "allowed_themes" );
if( is_array( $blog_allowed_themes ) ) {
if ( is_array( $blog_allowed_themes ) ) {
foreach( (array) $themes as $key => $theme ) {
$theme_key = wp_specialchars( $theme[ 'Stylesheet' ] );
if( isset( $blog_allowed_themes[ $key ] ) == true ) {
if ( isset( $blog_allowed_themes[ $key ] ) == true ) {
$blog_allowedthemes[ $theme_key ] = 1;
}
}
@@ -202,7 +202,7 @@ function wpmu_get_blog_allowedthemes( $blog_id = 0 ) {
}
}
if( $blog_id != 0 )
if ( $blog_id != 0 )
restore_current_blog();
return $blog_allowed_themes;
@@ -256,9 +256,9 @@ function profile_page_email_warning_ob_content( $content ) {
function update_profile_email() {
global $current_user, $wpdb;
if( isset( $_GET[ 'newuseremail' ] ) && $current_user->ID ) {
if ( isset( $_GET[ 'newuseremail' ] ) && $current_user->ID ) {
$new_email = get_option( $current_user->ID . '_new_email' );
if( $new_email[ 'hash' ] == $_GET[ 'newuseremail' ] ) {
if ( $new_email[ 'hash' ] == $_GET[ 'newuseremail' ] ) {
$user->ID = $current_user->ID;
$user->user_email = wp_specialchars( trim( $new_email[ 'newemail' ] ) );
if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login ) ) ) {
@@ -277,16 +277,16 @@ function send_confirmation_on_profile_email() {
if ( ! is_object($errors) )
$errors = new WP_Error();
if( $current_user->id != $_POST[ 'user_id' ] )
if ( $current_user->id != $_POST[ 'user_id' ] )
return false;
if( $current_user->user_email != $_POST[ 'email' ] ) {
if ( $current_user->user_email != $_POST[ 'email' ] ) {
if ( !is_email( $_POST[ 'email' ] ) ) {
$errors->add( 'user_email', __( "<strong>ERROR</strong>: The e-mail address isn't correct." ), array( 'form-field' => 'email' ) );
return;
}
if( $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM {$wpdb->users} WHERE user_email=%s", $_POST[ 'email' ] ) ) ) {
if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM {$wpdb->users} WHERE user_email=%s", $_POST[ 'email' ] ) ) ) {
$errors->add( 'user_email', __( "<strong>ERROR</strong>: The e-mail address is already used." ), array( 'form-field' => 'email' ) );
delete_option( $current_user->ID . '_new_email' );
return;
@@ -327,7 +327,7 @@ add_action( 'personal_options_update', 'send_confirmation_on_profile_email' );
function new_user_email_admin_notice() {
global $current_user;
if( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET[ 'updated' ] ) && $email = get_option( $current_user->ID . '_new_email' ) )
if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET[ 'updated' ] ) && $email = get_option( $current_user->ID . '_new_email' ) )
echo "<div id='update-nag'>" . sprintf( __( "Your email address has not been updated yet. Please check your inbox at %s for a confirmation email." ), $email[ 'newemail' ] ) . "</div>";
}
add_action( 'admin_notices', 'new_user_email_admin_notice' );
@@ -335,14 +335,14 @@ add_action( 'admin_notices', 'new_user_email_admin_notice' );
function get_site_allowed_themes() {
$themes = get_themes();
$allowed_themes = get_site_option( 'allowedthemes' );
if( !is_array( $allowed_themes ) || empty( $allowed_themes ) ) {
if ( !is_array( $allowed_themes ) || empty( $allowed_themes ) ) {
$allowed_themes = get_site_option( "allowed_themes" ); // convert old allowed_themes format
if( !is_array( $allowed_themes ) ) {
if ( !is_array( $allowed_themes ) ) {
$allowed_themes = array();
} else {
foreach( (array) $themes as $key => $theme ) {
$theme_key = wp_specialchars( $theme[ 'Stylesheet' ] );
if( isset( $allowed_themes[ $key ] ) == true ) {
if ( isset( $allowed_themes[ $key ] ) == true ) {
$allowedthemes[ $theme_key ] = 1;
}
}
@@ -354,9 +354,9 @@ function get_site_allowed_themes() {
function get_space_allowed() {
$spaceAllowed = get_option("blog_upload_space");
if( $spaceAllowed == false )
if ( $spaceAllowed == false )
$spaceAllowed = get_site_option("blog_upload_space");
if( empty($spaceAllowed) || !is_numeric($spaceAllowed) )
if ( empty($spaceAllowed) || !is_numeric($spaceAllowed) )
$spaceAllowed = 50;
return $spaceAllowed;
@@ -369,7 +369,7 @@ function display_space_usage() {
if ($used > $space) $percentused = '100';
else $percentused = ( $used / $space ) * 100;
if( $space > 1000 ) {
if ( $space > 1000 ) {
$space = number_format( $space / 1024 );
$space .= __('GB');
} else {
@@ -407,13 +407,13 @@ function dashboard_quota() {
</div>
<?php
}
if( current_user_can('edit_posts') )
if ( current_user_can('edit_posts') )
add_action('activity_box_end', 'dashboard_quota');
// Edit blog upload space setting on Edit Blog page
function upload_space_setting( $id ) {
$quota = get_blog_option($id, "blog_upload_space");
if( !$quota )
if ( !$quota )
$quota = '';
?>
@@ -430,11 +430,11 @@ function update_user_status( $id, $pref, $value, $refresh = 1 ) {
$wpdb->update( $wpdb->users, array( $pref => $value ), array( 'ID' => $id ) );
if( $refresh == 1 )
if ( $refresh == 1 )
refresh_user_details($id);
if( $pref == 'spam' ) {
if( $value == 1 )
if ( $pref == 'spam' ) {
if ( $value == 1 )
do_action( "make_spam_user", $id );
else
do_action( "make_ham_user", $id );
@@ -482,7 +482,7 @@ function wpmu_checkAvailableSpace() {
$dir->close();
$size = $size / 1024 / 1024;
if( ($spaceAllowed - $size) <= 0 ) {
if ( ($spaceAllowed - $size) <= 0 ) {
wp_die( __('Sorry, you must delete files before you can upload any more.') );
}
}
@@ -496,8 +496,8 @@ function format_code_lang( $code = '' ) {
}
function sync_category_tag_slugs( $term, $taxonomy ) {
if( $taxonomy == 'category' || $taxonomy == 'post_tag' ) {
if( is_object( $term ) ) {
if ( $taxonomy == 'category' || $taxonomy == 'post_tag' ) {
if ( is_object( $term ) ) {
$term->slug = sanitize_title( $term->name );
} else {
$term[ 'slug' ] = sanitize_title( $term[ 'name' ] );
@@ -520,7 +520,7 @@ function redirect_user_to_blog() {
$blog = get_active_blog_for_user( $current_user->ID );
$dashboard_blog = get_dashboard_blog();
if( is_object( $blog ) ) {
if ( is_object( $blog ) ) {
$protocol = ( is_ssl() ? 'https://' : 'http://' );
wp_redirect( $protocol . $blog->domain . $blog->path . 'wp-admin/?c=' . $c ); // redirect and count to 5, "just in case"
exit;
@@ -625,17 +625,17 @@ function mu_media_buttons() {
$media_title = __('Add Media');
$mu_media_buttons = get_site_option( 'mu_media_buttons' );
$out = '';
if( $mu_media_buttons[ 'image' ] ) {
if ( $mu_media_buttons[ 'image' ] ) {
$image_upload_iframe_src = apply_filters('image_upload_iframe_src', "$media_upload_iframe_src&amp;type=image");
$image_title = __('Add an Image');
$out .= "<a href='{$image_upload_iframe_src}&amp;TB_iframe=true' id='add_image' class='thickbox' title='$image_title'><img src='images/media-button-image.gif' alt='$image_title' /></a>";
}
if( $mu_media_buttons[ 'video' ] ) {
if ( $mu_media_buttons[ 'video' ] ) {
$video_upload_iframe_src = apply_filters('video_upload_iframe_src', "$media_upload_iframe_src&amp;type=video");
$video_title = __('Add Video');
$out .= "<a href='{$video_upload_iframe_src}&amp;TB_iframe=true' id='add_video' class='thickbox' title='$video_title'><img src='images/media-button-video.gif' alt='$video_title' /></a>";
}
if( $mu_media_buttons[ 'audio' ] ) {
if ( $mu_media_buttons[ 'audio' ] ) {
$audio_upload_iframe_src = apply_filters('audio_upload_iframe_src', "$media_upload_iframe_src&amp;type=audio");
$audio_title = __('Add Audio');
$out .= "<a href='{$audio_upload_iframe_src}&amp;TB_iframe=true' id='add_audio' class='thickbox' title='$audio_title'><img src='images/media-button-music.gif' alt='$audio_title' /></a>";
@@ -648,15 +648,15 @@ remove_action( 'media_buttons', 'media_buttons' );
/* Warn the admin if SECRET SALT information is missing from wp-config.php */
function secret_salt_warning() {
if( !is_super_admin() )
if ( !is_super_admin() )
return;
$secret_keys = array( 'NONCE_KEY', 'AUTH_KEY', 'AUTH_SALT', 'LOGGED_IN_KEY', 'LOGGED_IN_SALT', 'SECURE_AUTH_KEY', 'SECURE_AUTH_SALT' );
$out = '';
foreach( $secret_keys as $key ) {
if( !defined( $key ) )
if ( !defined( $key ) )
$out .= "define( '$key', '" . wp_generate_password() . wp_generate_password() . "' );<br />";
}
if( $out != '' ) {
if ( $out != '' ) {
$msg = sprintf( __( 'Warning! WordPress encrypts user cookies, but you must add the following lines to <strong>%swp-config.php</strong> for it to be more secure.<br />Please add the code before the line, <code>/* That\'s all, stop editing! Happy blogging. */</code>' ), ABSPATH );
$msg .= "<blockquote>$out</blockquote>";
@@ -686,19 +686,19 @@ add_action ( 'myblogs_update', 'profile_update_primary_blog' );
function admin_notice_feed() {
global $current_user;
if( substr( $_SERVER[ 'PHP_SELF' ], -19 ) != '/wp-admin/index.php' )
if ( substr( $_SERVER[ 'PHP_SELF' ], -19 ) != '/wp-admin/index.php' )
return;
if( isset( $_GET[ 'feed_dismiss' ] ) )
if ( isset( $_GET[ 'feed_dismiss' ] ) )
update_user_option( $current_user->id, 'admin_feed_dismiss', $_GET[ 'feed_dismiss' ], true );
$url = get_site_option( 'admin_notice_feed' );
if( $url == '' )
if ( $url == '' )
return;
include_once( ABSPATH . 'wp-includes/rss.php' );
$rss = @fetch_rss( $url );
if( isset($rss->items) && 1 <= count($rss->items) ) {
if( md5( $rss->items[0][ 'title' ] ) == get_user_option( 'admin_feed_dismiss', $current_user->id ) )
if ( isset($rss->items) && 1 <= count($rss->items) ) {
if ( md5( $rss->items[0][ 'title' ] ) == get_user_option( 'admin_feed_dismiss', $current_user->id ) )
return;
$item = $rss->items[0];
$msg = "<h3>" . wp_specialchars( $item[ 'title' ] ) . "</h3>\n";
@@ -714,7 +714,7 @@ function admin_notice_feed() {
$link = clean_url( strip_tags( $item['link'] ) );
$msg .= "<p>" . $content . " <a href='$link'>" . __( 'Read More' ) . "</a> <a href='index.php?feed_dismiss=" . md5( $item[ 'title' ] ) . "'>" . __( "Dismiss" ) . "</a></p>";
echo "<div class='updated fade'>$msg</div>";
} elseif( is_super_admin() ) {
} elseif ( is_super_admin() ) {
printf("<div id='update-nag'>" . __("Your feed at %s is empty.") . "</div>", wp_specialchars( $url ));
}
}
@@ -722,7 +722,7 @@ add_action( 'admin_notices', 'admin_notice_feed' );
function site_admin_notice() {
global $current_user, $wp_db_version;
if( !is_super_admin() )
if ( !is_super_admin() )
return false;
printf("<div id='update-nag'>" . __("Hi %s! You're logged in as a site administrator.") . "</div>", $current_user->user_login);
if ( get_site_option( 'wpmu_upgrade_site' ) != $wp_db_version ) {
@@ -732,13 +732,13 @@ function site_admin_notice() {
add_action( 'admin_notices', 'site_admin_notice' );
function avoid_blog_page_permalink_collision( $data, $postarr ) {
if( is_subdomain_install() )
if ( is_subdomain_install() )
return $data;
if( $data[ 'post_type' ] != 'page' )
if ( $data[ 'post_type' ] != 'page' )
return $data;
if( !isset( $data[ 'post_name' ] ) || $data[ 'post_name' ] == '' )
if ( !isset( $data[ 'post_name' ] ) || $data[ 'post_name' ] == '' )
return $data;
if( !is_main_blog() )
if ( !is_main_blog() )
return $data;
$post_name = $data[ 'post_name' ];
@@ -747,7 +747,7 @@ function avoid_blog_page_permalink_collision( $data, $postarr ) {
$post_name .= mt_rand( 1, 10 );
$c ++;
}
if( $post_name != $data[ 'post_name' ] ) {
if ( $post_name != $data[ 'post_name' ] ) {
$data[ 'post_name' ] = $post_name;
}
return $data;
@@ -1033,7 +1033,7 @@ function check_wpmu_plugins_on_bulk_activate( $plugins ) {
function remove_edit_plugin_link( $action_links, $plugin_file, $plugin_data, $context ) {
foreach( $action_links as $t => $link ) {
if( !strpos( $link, __( "Open this file in the Plugin Editor" ) ) )
if ( !strpos( $link, __( "Open this file in the Plugin Editor" ) ) )
$links[ $t ] = $link;
}
return $links;
@@ -1050,25 +1050,25 @@ function choose_primary_blog() {
<?php
$all_blogs = get_blogs_of_user( $current_user->ID );
$primary_blog = get_usermeta($current_user->ID, 'primary_blog');
if( count( $all_blogs ) > 1 ) {
if ( count( $all_blogs ) > 1 ) {
$found = false;
?>
<select name="primary_blog">
<?php foreach( (array) $all_blogs as $blog ) {
if( $primary_blog == $blog->userblog_id )
if ( $primary_blog == $blog->userblog_id )
$found = true;
?><option value='<?php echo $blog->userblog_id ?>'<?php if( $primary_blog == $blog->userblog_id ) echo ' selected="selected"' ?>>http://<?php echo $blog->domain.$blog->path ?></option><?php
?><option value='<?php echo $blog->userblog_id ?>'<?php if ( $primary_blog == $blog->userblog_id ) echo ' selected="selected"' ?>>http://<?php echo $blog->domain.$blog->path ?></option><?php
} ?>
</select>
<?php
if( !$found ) {
if ( !$found ) {
$blog = array_shift( $all_blogs );
update_usermeta( $current_user->ID, 'primary_blog', $blog->userblog_id );
}
} elseif( count( $all_blogs ) == 1 ) {
} elseif ( count( $all_blogs ) == 1 ) {
$blog = array_shift( $all_blogs );
echo $blog->domain;
if( $primary_blog != $blog->userblog_id ) // Set the primary blog again if it's out of sync with blog list.
if ( $primary_blog != $blog->userblog_id ) // Set the primary blog again if it's out of sync with blog list.
update_usermeta( $current_user->ID, 'primary_blog', $blog->userblog_id );
} else {
echo "N/A";
@@ -1081,7 +1081,7 @@ function choose_primary_blog() {
}
add_action ( 'myblogs_allblogs_options', 'choose_primary_blog' );
if( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) ) {
if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) ) {
add_action( 'admin_init', 'update_profile_email' );
add_action( 'admin_init', 'profile_page_email_warning_ob_start' );
}
@@ -1132,7 +1132,7 @@ function blogs_listing() {
global $current_user;
$blogs = get_blogs_of_user( $current_user->ID );
if( !$blogs || ( is_array( $blogs ) && empty( $blogs ) ) ) {
if ( !$blogs || ( is_array( $blogs ) && empty( $blogs ) ) ) {
wp_die( __( 'You must be a member of at least one blog to use this page.' ) );
}
@@ -1140,7 +1140,7 @@ function blogs_listing() {
$title = apply_filters( 'my_blogs_title', __( 'My Blogs' ) );
?>
<div class="wrap">
<?php if( $_GET[ 'updated' ] ) { ?>
<?php if ( $_GET[ 'updated' ] ) { ?>
<div id="message" class="updated fade"><p><strong><?php _e( 'Your blog options have been updated.' ); ?></strong></p></div>
<?php } ?>
<?php screen_icon(); ?>
+6 -6
View File
@@ -28,7 +28,7 @@
*/
function plugins_api($action, $args = null) {
if( is_array($args) )
if ( is_array($args) )
$args = (object)$args;
if ( !isset($args->per_page) )
@@ -325,10 +325,10 @@ function display_plugins_table($plugins, $page = 1, $totalpages = 1){
<tbody class="plugins">
<?php
if( empty($plugins) )
if ( empty($plugins) )
echo '<tr><td colspan="5">', __('No plugins match your request.'), '</td></tr>';
foreach( (array) $plugins as $plugin ){
foreach ( (array) $plugins as $plugin ){
if ( is_object($plugin) )
$plugin = (array) $plugin;
@@ -349,12 +349,12 @@ function display_plugins_table($plugins, $page = 1, $totalpages = 1){
$name = strip_tags($title . ' ' . $version);
$author = $plugin['author'];
if( ! empty($plugin['author']) )
if ( ! empty($plugin['author']) )
$author = ' <cite>' . sprintf( __('By %s'), $author ) . '.</cite>';
$author = wp_kses($author, $plugins_allowedtags);
if( isset($plugin['homepage']) )
if ( isset($plugin['homepage']) )
$title = '<a target="_blank" href="' . esc_attr($plugin['homepage']) . '">' . $title . '</a>';
$action_links = array();
@@ -423,7 +423,7 @@ function install_plugin_information() {
$api->$key = wp_kses($api->$key, $plugins_allowedtags);
$section = isset($_REQUEST['section']) ? stripslashes( $_REQUEST['section'] ) : 'description'; //Default to the Description tab, Do not translate, API returns English.
if( empty($section) || ! isset($api->sections[ $section ]) )
if ( empty($section) || ! isset($api->sections[ $section ]) )
$section = array_shift( $section_titles = array_keys((array)$api->sections) );
iframe_header( __('Plugin Install') );
+11 -11
View File
@@ -92,8 +92,8 @@ function get_plugin_data( $plugin_file, $markup = true, $translate = true ) {
function _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup = true, $translate = true) {
//Translate fields
if( $translate && ! empty($plugin_data['TextDomain']) ) {
if( ! empty( $plugin_data['DomainPath'] ) )
if ( $translate && ! empty($plugin_data['TextDomain']) ) {
if ( ! empty( $plugin_data['DomainPath'] ) )
load_plugin_textdomain($plugin_data['TextDomain'], false, dirname($plugin_file). $plugin_data['DomainPath']);
else
load_plugin_textdomain($plugin_data['TextDomain'], false, dirname($plugin_file));
@@ -113,7 +113,7 @@ function _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup =
$plugin_data['Author'] = '<a href="' . $plugin_data['AuthorURI'] . '" title="' . __( 'Visit author homepage' ) . '">' . $plugin_data['Author'] . '</a>';
$plugin_data['Description'] = wptexturize( $plugin_data['Description'] );
if( ! empty($plugin_data['Author']) )
if ( ! empty($plugin_data['Author']) )
$plugin_data['Description'] .= ' <cite>' . sprintf( __('By %s'), $plugin_data['Author'] ) . '.</cite>';
}
@@ -198,7 +198,7 @@ function get_plugins($plugin_folder = '') {
$wp_plugins = array ();
$plugin_root = WP_PLUGIN_DIR;
if( !empty($plugin_folder) )
if ( !empty($plugin_folder) )
$plugin_root .= $plugin_folder;
// Files in wp-content/plugins directory
@@ -330,7 +330,7 @@ function deactivate_plugins($plugins, $silent= false) {
foreach ( $plugins as $plugin ) {
$plugin = plugin_basename($plugin);
if( ! is_plugin_active($plugin) )
if ( ! is_plugin_active($plugin) )
continue;
if ( ! $silent )
do_action( 'deactivate_plugin', trim( $plugin ) );
@@ -398,7 +398,7 @@ function activate_plugins($plugins, $redirect = '') {
function delete_plugins($plugins, $redirect = '' ) {
global $wp_filesystem;
if( empty($plugins) )
if ( empty($plugins) )
return false;
$checked = array();
@@ -410,7 +410,7 @@ function delete_plugins($plugins, $redirect = '' ) {
if ( false === ($credentials = request_filesystem_credentials($url)) ) {
$data = ob_get_contents();
ob_end_clean();
if( ! empty($data) ){
if ( ! empty($data) ){
include_once( ABSPATH . 'wp-admin/admin-header.php');
echo $data;
include( ABSPATH . 'wp-admin/admin-footer.php');
@@ -423,7 +423,7 @@ function delete_plugins($plugins, $redirect = '' ) {
request_filesystem_credentials($url, '', true); //Failed to connect, Error and request again
$data = ob_get_contents();
ob_end_clean();
if( ! empty($data) ){
if ( ! empty($data) ){
include_once( ABSPATH . 'wp-admin/admin-header.php');
echo $data;
include( ABSPATH . 'wp-admin/admin-footer.php');
@@ -1064,7 +1064,7 @@ add_filter( 'whitelist_options', 'option_update_filter' );
* @return unknown
*/
function add_option_whitelist( $new_options, $options = '' ) {
if( $options == '' ) {
if ( $options == '' ) {
global $whitelist_options;
} else {
$whitelist_options = $options;
@@ -1094,7 +1094,7 @@ function add_option_whitelist( $new_options, $options = '' ) {
* @return unknown
*/
function remove_option_whitelist( $del_options, $options = '' ) {
if( $options == '' ) {
if ( $options == '' ) {
global $whitelist_options;
} else {
$whitelist_options = $options;
@@ -1103,7 +1103,7 @@ function remove_option_whitelist( $del_options, $options = '' ) {
foreach( $keys as $key ) {
if ( isset($whitelist_options[ $page ]) && is_array($whitelist_options[ $page ]) ) {
$pos = array_search( $key, $whitelist_options[ $page ] );
if( $pos !== false )
if ( $pos !== false )
unset( $whitelist_options[ $page ][ $pos ] );
}
}
+1 -1
View File
@@ -535,7 +535,7 @@ function wp_write_post() {
*/
function write_post() {
$result = wp_write_post();
if( is_wp_error( $result ) )
if ( is_wp_error( $result ) )
wp_die( $result->get_error_message() );
else
return $result;
+2 -2
View File
@@ -1307,13 +1307,13 @@ function get_inline_data($post) {
<div class="ss">' . mysql2date( 's', $post->post_date, false ) . '</div>
<div class="post_password">' . esc_html( $post->post_password ) . '</div>';
if( $post->post_type == 'page' )
if ( $post->post_type == 'page' )
echo '
<div class="post_parent">' . $post->post_parent . '</div>
<div class="page_template">' . esc_html( get_post_meta( $post->ID, '_wp_page_template', true ) ) . '</div>
<div class="menu_order">' . $post->menu_order . '</div>';
if( $post->post_type == 'post' )
if ( $post->post_type == 'post' )
echo '
<div class="tags_input">' . esc_html( str_replace( ',', ', ', get_tags_to_edit($post->ID) ) ) . '</div>
<div class="post_category">' . implode( ',', wp_get_post_categories( $post->ID ) ) . '</div>
+1 -1
View File
@@ -65,7 +65,7 @@ function delete_theme($template) {
request_filesystem_credentials($url, '', true); // Failed to connect, Error and request again
$data = ob_get_contents();
ob_end_clean();
if( ! empty($data) ){
if ( ! empty($data) ) {
include_once( ABSPATH . 'wp-admin/admin-header.php');
echo $data;
include( ABSPATH . 'wp-admin/admin-footer.php');
+4 -4
View File
@@ -82,7 +82,7 @@ function find_core_update( $version, $locale ) {
}
function core_update_footer( $msg = '' ) {
if( is_multisite() && !is_super_admin() )
if ( is_multisite() && !is_super_admin() )
return false;
if ( !current_user_can('manage_options') )
@@ -118,7 +118,7 @@ function core_update_footer( $msg = '' ) {
add_filter( 'update_footer', 'core_update_footer' );
function update_nag() {
if( is_multisite() && !is_super_admin() )
if ( is_multisite() && !is_super_admin() )
return false;
global $pagenow;
@@ -142,7 +142,7 @@ add_action( 'admin_notices', 'update_nag', 3 );
// Called directly from dashboard
function update_right_now_message() {
if( is_multisite() && !is_super_admin() )
if ( is_multisite() && !is_super_admin() )
return false;
$cur = get_preferred_from_update_core();
@@ -205,7 +205,7 @@ function wp_plugin_update_row( $file, $plugin_data ) {
}
function wp_update_plugin($plugin, $feedback = '') {
if( is_multisite() && !is_super_admin() )
if ( is_multisite() && !is_super_admin() )
return false;
+34 -42
View File
@@ -267,7 +267,7 @@ function wp_upgrade() {
if ( $wp_db_version == $wp_current_db_version )
return;
if( ! is_blog_installed() )
if ( ! is_blog_installed() )
return;
wp_check_mysql_version();
@@ -631,7 +631,7 @@ function upgrade_160() {
// populate comment_count field of posts table
$comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" );
if( is_array( $comments ) )
if ( is_array( $comments ) )
foreach ($comments as $comment)
$wpdb->update( $wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID) );
@@ -1199,9 +1199,9 @@ function dbDelta($queries, $execute = true) {
global $wpdb;
// Separate individual queries into an array
if( !is_array($queries) ) {
if ( !is_array($queries) ) {
$queries = explode( ';', $queries );
if('' == $queries[count($queries) - 1]) array_pop($queries);
if ('' == $queries[count($queries) - 1]) array_pop($queries);
}
$cqueries = array(); // Creation Queries
@@ -1210,30 +1210,26 @@ function dbDelta($queries, $execute = true) {
// Create a tablename index for an array ($cqueries) of queries
foreach($queries as $qry) {
if(preg_match("|CREATE TABLE ([^ ]*)|", $qry, $matches)) {
if (preg_match("|CREATE TABLE ([^ ]*)|", $qry, $matches)) {
$cqueries[trim( strtolower($matches[1]), '`' )] = $qry;
$for_update[$matches[1]] = 'Created table '.$matches[1];
}
else if(preg_match("|CREATE DATABASE ([^ ]*)|", $qry, $matches)) {
} else if (preg_match("|CREATE DATABASE ([^ ]*)|", $qry, $matches)) {
array_unshift($cqueries, $qry);
}
else if(preg_match("|INSERT INTO ([^ ]*)|", $qry, $matches)) {
} else if (preg_match("|INSERT INTO ([^ ]*)|", $qry, $matches)) {
$iqueries[] = $qry;
}
else if(preg_match("|UPDATE ([^ ]*)|", $qry, $matches)) {
} else if (preg_match("|UPDATE ([^ ]*)|", $qry, $matches)) {
$iqueries[] = $qry;
}
else {
} else {
// Unrecognized query type
}
}
// Check to see which tables and fields exist
if($tables = $wpdb->get_col('SHOW TABLES;')) {
if ($tables = $wpdb->get_col('SHOW TABLES;')) {
// For every table in the database
foreach($tables as $table) {
foreach ($tables as $table) {
// If a table query exists for the database table...
if( array_key_exists(strtolower($table), $cqueries) ) {
if ( array_key_exists(strtolower($table), $cqueries) ) {
// Clear the field and index arrays
unset($cfields);
unset($indices);
@@ -1247,15 +1243,14 @@ function dbDelta($queries, $execute = true) {
//echo "<hr/><pre>\n".print_r(strtolower($table), true).":\n".print_r($cqueries, true)."</pre><hr/>";
// For every field line specified in the query
foreach($flds as $fld) {
foreach ($flds as $fld) {
// Extract the field name
preg_match("|^([^ ]*)|", trim($fld), $fvals);
$fieldname = trim( $fvals[1], '`' );
// Verify the found field name
$validfield = true;
switch(strtolower($fieldname))
{
switch (strtolower($fieldname)) {
case '':
case 'primary':
case 'index':
@@ -1269,7 +1264,7 @@ function dbDelta($queries, $execute = true) {
$fld = trim($fld);
// If it's a valid field, add it to the field array
if($validfield) {
if ($validfield) {
$cfields[strtolower($fieldname)] = trim($fld, ", \n");
}
}
@@ -1278,15 +1273,15 @@ function dbDelta($queries, $execute = true) {
$tablefields = $wpdb->get_results("DESCRIBE {$table};");
// For every field in the table
foreach($tablefields as $tablefield) {
foreach ($tablefields as $tablefield) {
// If the table field exists in the field array...
if(array_key_exists(strtolower($tablefield->Field), $cfields)) {
if (array_key_exists(strtolower($tablefield->Field), $cfields)) {
// Get the field type from the query
preg_match("|".$tablefield->Field." ([^ ]*( unsigned)?)|i", $cfields[strtolower($tablefield->Field)], $matches);
$fieldtype = $matches[1];
// Is actual field type different from the field type in query?
if($tablefield->Type != $fieldtype) {
if ($tablefield->Type != $fieldtype) {
// Add a query to change the column type
$cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN {$tablefield->Field} " . $cfields[strtolower($tablefield->Field)];
$for_update[$table.'.'.$tablefield->Field] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}";
@@ -1294,10 +1289,9 @@ function dbDelta($queries, $execute = true) {
// Get the default value from the array
//echo "{$cfields[strtolower($tablefield->Field)]}<br>";
if(preg_match("| DEFAULT '(.*)'|i", $cfields[strtolower($tablefield->Field)], $matches)) {
if (preg_match("| DEFAULT '(.*)'|i", $cfields[strtolower($tablefield->Field)], $matches)) {
$default_value = $matches[1];
if($tablefield->Default != $default_value)
{
if ($tablefield->Default != $default_value) {
// Add a query to change the column's default value
$cqueries[] = "ALTER TABLE {$table} ALTER COLUMN {$tablefield->Field} SET DEFAULT '{$default_value}'";
$for_update[$table.'.'.$tablefield->Field] = "Changed default value of {$table}.{$tablefield->Field} from {$tablefield->Default} to {$default_value}";
@@ -1306,14 +1300,13 @@ function dbDelta($queries, $execute = true) {
// Remove the field from the array (so it's not added)
unset($cfields[strtolower($tablefield->Field)]);
}
else {
} else {
// This field exists in the table, but not in the creation queries?
}
}
// For every remaining field specified for the table
foreach($cfields as $fieldname => $fielddef) {
foreach ($cfields as $fieldname => $fielddef) {
// Push a query line into $cqueries that adds the field to that table
$cqueries[] = "ALTER TABLE {$table} ADD COLUMN $fielddef";
$for_update[$table.'.'.$fieldname] = 'Added column '.$table.'.'.$fieldname;
@@ -1323,12 +1316,12 @@ function dbDelta($queries, $execute = true) {
// Fetch the table index structure from the database
$tableindices = $wpdb->get_results("SHOW INDEX FROM {$table};");
if($tableindices) {
if ($tableindices) {
// Clear the index array
unset($index_ary);
// For every index in the table
foreach($tableindices as $tableindex) {
foreach ($tableindices as $tableindex) {
// Add the index to the index data array
$keyname = $tableindex->Key_name;
$index_ary[$keyname]['columns'][] = array('fieldname' => $tableindex->Column_name, 'subpart' => $tableindex->Sub_part);
@@ -1336,32 +1329,31 @@ function dbDelta($queries, $execute = true) {
}
// For each actual index in the index array
foreach($index_ary as $index_name => $index_data) {
foreach ($index_ary as $index_name => $index_data) {
// Build a create string to compare to the query
$index_string = '';
if($index_name == 'PRIMARY') {
if ($index_name == 'PRIMARY') {
$index_string .= 'PRIMARY ';
}
else if($index_data['unique']) {
} else if($index_data['unique']) {
$index_string .= 'UNIQUE ';
}
$index_string .= 'KEY ';
if($index_name != 'PRIMARY') {
if ($index_name != 'PRIMARY') {
$index_string .= $index_name;
}
$index_columns = '';
// For each column in the index
foreach($index_data['columns'] as $column_data) {
if($index_columns != '') $index_columns .= ',';
foreach ($index_data['columns'] as $column_data) {
if ($index_columns != '') $index_columns .= ',';
// Add the field to the column list string
$index_columns .= $column_data['fieldname'];
if($column_data['subpart'] != '') {
if ($column_data['subpart'] != '') {
$index_columns .= '('.$column_data['subpart'].')';
}
}
// Add the column list to the index create string
$index_string .= ' ('.$index_columns.')';
if(!(($aindex = array_search($index_string, $indices)) === false)) {
if (!(($aindex = array_search($index_string, $indices)) === false)) {
unset($indices[$aindex]);
//echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br />Found index:".$index_string."</pre>\n";
}
@@ -1386,8 +1378,8 @@ function dbDelta($queries, $execute = true) {
}
$allqueries = array_merge($cqueries, $iqueries);
if($execute) {
foreach($allqueries as $query) {
if ($execute) {
foreach ($allqueries as $query) {
//echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">".print_r($query, true)."</pre>\n";
$wpdb->query($query);
}