diff options
Diffstat (limited to 'wp-inst/wp-admin/admin-functions.php')
-rw-r--r-- | wp-inst/wp-admin/admin-functions.php | 252 |
1 files changed, 162 insertions, 90 deletions
diff --git a/wp-inst/wp-admin/admin-functions.php b/wp-inst/wp-admin/admin-functions.php index b33f94e..527df20 100644 --- a/wp-inst/wp-admin/admin-functions.php +++ b/wp-inst/wp-admin/admin-functions.php @@ -75,8 +75,8 @@ function write_post() { $hh = ($hh > 23) ? $hh -24 : $hh; $mn = ($mn > 59) ? $mn -60 : $mn; $ss = ($ss > 59) ? $ss -60 : $ss; - $_POST['post_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; - $_POST['post_date_gmt'] = get_gmt_from_date("$aa-$mm-$jj $hh:$mn:$ss"); + $_POST['post_date'] = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss); + $_POST['post_date_gmt'] = get_gmt_from_date($_POST['post_date']); } // Create the post. @@ -361,15 +361,38 @@ function get_category_to_edit($id) { return $category; } +function wp_dropdown_roles( $default = false ) { + global $wp_roles; + $r = ''; + foreach($wp_roles->role_names as $role => $name) + if ( $default == $role ) // Make default first in list + $p = "\n\t<option selected='selected' value='$role'>$name</option>"; + else + $r .= "\n\t<option value='$role'>$name</option>"; + echo $p . $r; +} + + // Creates a new user from the "Users" form using $_POST information. function add_user() { - return edit_user(); + if ( func_num_args() ) { // The hackiest hack that ever did hack + global $current_user, $wp_roles; + $user_id = func_get_arg(0); + if (isset ($_POST['role'])) { + if($user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap('edit_users')) { + $user = new WP_User($user_id); + $user->set_role($_POST['role']); + } + } + } else { + add_action('user_register', 'add_user'); // See above + return edit_user(); + } } function edit_user($user_id = 0) { global $current_user, $wp_roles, $wpdb; - if ($user_id != 0) { $update = true; $user->ID = $user_id; @@ -417,49 +440,49 @@ function edit_user($user_id = 0) { if (isset ($_POST['yim'])) $user->yim = wp_specialchars(trim($_POST['yim'])); - $errors = array (); + $errors = new WP_Error(); /* checking that username has been typed */ if ($user->user_login == '') - $errors['user_login'] = __('<strong>ERROR</strong>: Please enter a username.'); + $errors->add('user_login', __('<strong>ERROR</strong>: Please enter a username.')); /* checking the password has been typed twice */ do_action('check_passwords', array ($user->user_login, & $pass1, & $pass2)); if (!$update) { if ($pass1 == '' || $pass2 == '') - $errors['pass'] = __('<strong>ERROR</strong>: Please enter your password twice.'); + $errors->add('pass', __('<strong>ERROR</strong>: Please enter your password twice.')); } else { if ((empty ($pass1) && !empty ($pass2)) || (empty ($pass2) && !empty ($pass1))) - $errors['pass'] = __("<strong>ERROR</strong>: you typed your new password only once."); + $errors->add('pass', __("<strong>ERROR</strong>: you typed your new password only once.")); } /* Check for "\" in password */ if( strpos( " ".$pass1, "\\" ) ) - $errors['pass'] = __('<strong>ERROR</strong>: Passwords may not contain the character "\\".'); + $errors->add('pass', __('<strong>ERROR</strong>: Passwords may not contain the character "\\".')); /* checking the password has been typed twice the same */ if ($pass1 != $pass2) - $errors['pass'] = __('<strong>ERROR</strong>: Please type the same password in the two password fields.'); + $errors->add('pass', __('<strong>ERROR</strong>: Please type the same password in the two password fields.')); if (!empty ($pass1)) $user->user_pass = $pass1; if ( !validate_username($user->user_login) ) - $errors['user_login'] = __('<strong>ERROR</strong>: This username is invalid. Please enter a valid username.'); + $errors->add('user_login', __('<strong>ERROR</strong>: This username is invalid. Please enter a valid username.')); if (!$update && username_exists($user->user_login)) - $errors['user_login'] = __('<strong>ERROR</strong>: This username is already registered, please choose another one.'); + $errors->add('user_login', __('<strong>ERROR</strong>: This username is already registered, please choose another one.')); /* checking e-mail address */ if (empty ($user->user_email)) { - $errors['user_email'] = __("<strong>ERROR</strong>: please type an e-mail address"); + $errors->add('user_email', __("<strong>ERROR</strong>: please type an e-mail address")); } else if (!is_email($user->user_email)) { - $errors['user_email'] = __("<strong>ERROR</strong>: the email address isn't correct"); + $errors->add('user_email', __("<strong>ERROR</strong>: the email address isn't correct")); } - if (count($errors) != 0) + if ( $errors->get_error_codes() ) return $errors; if ($update) { @@ -468,8 +491,7 @@ function edit_user($user_id = 0) { $user_id = wp_insert_user(get_object_vars($user)); wp_new_user_notification($user_id); } - - return $errors; + return $user_id; } @@ -481,6 +503,7 @@ function get_link_to_edit($link_id) { $link->link_description = wp_specialchars($link->link_description); $link->link_notes = wp_specialchars($link->link_notes); $link->link_rss = wp_specialchars($link->link_rss); + $link->post_category = $link->link_category; return $link; } @@ -514,14 +537,7 @@ function edit_link($link_id = '') { $_POST['link_name'] = wp_specialchars($_POST['link_name']); $_POST['link_image'] = wp_specialchars($_POST['link_image']); $_POST['link_rss'] = wp_specialchars($_POST['link_rss']); - $auto_toggle = get_autotoggle($_POST['link_category']); - - // if we are in an auto toggle category and this one is visible then we - // need to make the others invisible before we add this new one. - // FIXME Add category toggle func. - //if (($auto_toggle == 'Y') && ($link_visible == 'Y')) { - // $wpdb->query("UPDATE $wpdb->links set link_visible = 'N' WHERE link_category = $link_category"); - //} + $_POST['link_category'] = $_POST['post_category']; if ( !empty($link_id) ) { $_POST['link_id'] = $link_id; @@ -553,7 +569,7 @@ function checked($checked, $current) { function return_categories_list($parent = 0) { global $wpdb; - return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY category_count DESC LIMIT 100"); + return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY category_count DESC"); } function sort_cats($cat1, $cat2) { @@ -561,7 +577,7 @@ function sort_cats($cat1, $cat2) { } function get_nested_categories($default = 0, $parent = 0) { - global $post_ID, $mode, $wpdb; + global $post_ID, $link_id, $mode, $wpdb; if ($post_ID) { $checked_categories = $wpdb->get_col(" @@ -574,7 +590,17 @@ function get_nested_categories($default = 0, $parent = 0) { // No selected categories, strange $checked_categories[] = $default; } + } else if ($link_id) { + $checked_categories = $wpdb->get_col(" + SELECT category_id + FROM $wpdb->categories, $wpdb->link2cat + WHERE $wpdb->link2cat.category_id = cat_ID AND $wpdb->link2cat.link_id = '$link_id' + "); + if (count($checked_categories) == 0) { + // No selected categories, strange + $checked_categories[] = $default; + } } else { $checked_categories[] = $default; } @@ -584,6 +610,10 @@ function get_nested_categories($default = 0, $parent = 0) { if (is_array($cats)) { foreach ($cats as $cat) { + if ( $cat == 0 ) { // HACK, added 2006-05-13 + $wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = 0"); + continue; + } $result[$cat]['children'] = get_nested_categories($default, $cat); $result[$cat]['cat_ID'] = $cat; $result[$cat]['checked'] = in_array($cat, $checked_categories); @@ -598,12 +628,12 @@ function get_nested_categories($default = 0, $parent = 0) { function write_nested_categories($categories) { foreach ($categories as $category) { - echo '<label for="category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : ""), '/> ', wp_specialchars($category['cat_name']), "</label>\n"; + echo '<li id="category-', $category['cat_ID'], '"><label for="in-category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="in-category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : ""), '/> ', wp_specialchars($category['cat_name']), "</label></li>\n"; - if (isset ($category['children'])) { - echo "\n<span class='cat-nest'>\n"; + if ( $category['children'] ) { + echo "<ul>\n"; write_nested_categories($category['children']); - echo "</span>\n"; + echo "</ul>\n"; } } } @@ -621,15 +651,20 @@ function cat_rows($parent = 0, $level = 0, $categories = 0) { if ($categories) { foreach ($categories as $category) { + if ( $category->cat_ID == 0 ) { // HACK, added 2006-05-13 + $wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = 0"); + continue; + } if ($category->category_parent == $parent) { - $category->cat_name = wp_specialchars($category->cat_name); + $category->cat_name = wp_specialchars($category->cat_name,'double'); $pad = str_repeat('— ', $level); if ( current_user_can('manage_categories') ) { $edit = "<a href='categories.php?action=edit&cat_ID=$category->cat_ID' class='edit'>".__('Edit')."</a></td>"; $default_cat_id = get_option('default_category'); + $default_link_cat_id = get_option('default_link_category'); - if ($category->cat_ID != $default_cat_id) - $edit .= "<td><a href='categories.php?action=delete&cat_ID=$category->cat_ID' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '".sprintf(__("You are about to delete the category "%s". All of its posts will go to the default category.\\n"OK" to delete, "Cancel" to stop."), wp_specialchars($category->cat_name, 1))."' );\" class='delete'>".__('Delete')."</a>"; + if ( ($category->cat_ID != $default_cat_id) && ($category->cat_ID != $default_link_cat_id) ) + $edit .= "<td><a href='categories.php?action=delete&cat_ID=$category->cat_ID' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '".sprintf(__("You are about to delete the category "%s".\\nAll of its posts will go into the default category of "%s"\\nAll of its bookmarks will go into the default category of "%s".\\n"OK" to delete, "Cancel" to stop."), addslashes($category->cat_name), addslashes(wp_specialchars(get_catname($default_cat_id),'double')), addslashes(wp_specialchars(get_catname($default_link_cat_id),'double')))."' );\" class='delete'>".__('Delete')."</a>"; else $edit .= "<td style='text-align:center'>".__("Default"); } @@ -637,9 +672,13 @@ function cat_rows($parent = 0, $level = 0, $categories = 0) { $edit = ''; $class = ('alternate' == $class) ? '' : 'alternate'; + + $category->category_count = number_format( $category->category_count ); + $category->link_count = number_format( $category->link_count ); echo "<tr id='cat-$category->cat_ID' class='$class'><th scope='row'>$category->cat_ID</th><td>$pad $category->cat_name</td> <td>$category->category_description</td> - <td>$category->category_count</td> + <td align='center'>$category->category_count</td> + <td align='center'>$category->link_count</td> <td>$edit</td> </tr>"; cat_rows($category->cat_ID, $level +1, $categories); @@ -678,7 +717,7 @@ function page_rows($parent = 0, $level = 0, $pages = 0, $hierarchy = true) { <td><?php echo mysql2date('Y-m-d g:i a', $post->post_modified); ?></td> <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td> <td><?php if ( current_user_can('edit_page', $id) ) { echo "<a href='page.php?action=edit&post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td> - <td><?php if ( current_user_can('edit_page', $id) ) { echo "<a href='page.php?action=delete&post=$id' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the "%s" page.\\n"OK" to delete, "Cancel" to stop."), wp_specialchars(get_the_title('','',0), 1)) . "' );\">" . __('Delete') . "</a>"; } ?></td> + <td><?php if ( current_user_can('edit_page', $id) ) { echo "<a href='page.php?action=delete&post=$id' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the "%s" page.\\n"OK" to delete, "Cancel" to stop."), addslashes(wp_specialchars(get_the_title(),'double')) ) . "' );\">" . __('Delete') . "</a>"; } ?></td> </tr> <?php @@ -686,6 +725,33 @@ function page_rows($parent = 0, $level = 0, $pages = 0, $hierarchy = true) { } } +function user_row( $user_object, $style = '' ) { + if ( !(is_object($user_object) && is_a($user_object, 'WP_User')) ) + $user_object = new WP_User( (int) $user_object ); + $email = $user_object->user_email; + $url = $user_object->user_url; + $short_url = str_replace('http://', '', $url); + $short_url = str_replace('www.', '', $short_url); + if ('/' == substr($short_url, -1)) + $short_url = substr($short_url, 0, -1); + if (strlen($short_url) > 35) + $short_url = substr($short_url, 0, 32).'...'; + $numposts = get_usernumposts($user_object->ID); + if (0 < $numposts) $numposts = "<a href='edit.php?author=$user_object->ID' title='" . __('View posts') . "'>$numposts</a>"; + $r = "<tr id='user-$user_object->ID'$style> + <td><input type='checkbox' name='users[]' id='user_{$user_object->ID}' value='{$user_object->ID}' /> <label for='user_{$user_object->ID}'>{$user_object->ID}</label></td> + <td><label for='user_{$user_object->ID}'><strong>$user_object->user_login</strong></label></td> + <td><label for='user_{$user_object->ID}'>$user_object->first_name $user_object->last_name</label></td> + <td><a href='mailto:$email' title='" . sprintf(__('e-mail: %s'), $email) . "'>$email</a></td> + <td><a href='$url' title='website: $url'>$short_url</a></td>"; + $r .= "\n\t\t<td align='right'>$numposts</td>"; + $r .= "\n\t\t<td>"; + if (current_user_can('edit_users')) + $r .= "<a href='user-edit.php?user_id=$user_object->ID' class='edit'>".__('Edit')."</a>"; + $r .= "</td>\n\t</tr>"; + return $r; +} + function wp_dropdown_cats($currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0) { global $wpdb, $bgcolor; if (!$categories) { @@ -694,7 +760,6 @@ function wp_dropdown_cats($currentcat = 0, $currentparent = 0, $parent = 0, $lev if ($categories) { foreach ($categories as $category) { if ($currentcat != $category->cat_ID && $parent == $category->category_parent) { - $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID"); $pad = str_repeat('– ', $level); $category->cat_name = wp_specialchars($category->cat_name); echo "\n\t<option value='$category->cat_ID'"; @@ -709,21 +774,9 @@ function wp_dropdown_cats($currentcat = 0, $currentparent = 0, $parent = 0, $lev } } -function link_category_dropdown($fieldname, $selected = 0) { +function return_link_categories_list($parent = 0) { global $wpdb; - - $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id"); - echo "\n<select name='$fieldname' size='1'>\n"; - foreach ($results as $row) { - echo "\n\t<option value='$row->cat_id'"; - if ($row->cat_id == $selected) - echo " selected='selected'"; - echo ">$row->cat_id : " . wp_specialchars($row->cat_name); - if ($row->auto_toggle == 'Y') - echo ' (auto toggle)'; - echo "</option>"; - } - echo "\n</select>\n"; + return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY link_count DESC"); } function wp_create_thumbnail($file, $max_side, $effect = '') { @@ -816,6 +869,7 @@ function wp_create_thumbnail($file, $max_side, $effect = '') { if (!empty ($error)) { return $error; } else { + apply_filters( 'wp_create_thumbnail', $thumbpath ); return $thumbpath; } } @@ -835,19 +889,21 @@ function has_meta($postid) { function list_meta($meta) { global $post_ID; // Exit if no meta - if (!$meta) + if (!$meta) { + echo '<tbody id="the-list"></tbody>'; //TBODY needed for list-manipulation JS return; + } $count = 0; ?> -<table id='meta-list' cellpadding="3"> + <thead> <tr> <th><?php _e('Key') ?></th> <th><?php _e('Value') ?></th> <th colspan='2'><?php _e('Action') ?></th> </tr> + </thead> <?php - - + $r ="\n\t<tbody id='the-list'>"; foreach ($meta as $entry) { ++ $count; if ($count % 2) @@ -856,18 +912,20 @@ function list_meta($meta) { $style = ''; if ('_' == $entry['meta_key'] { 0 }) $style .= ' hidden'; - echo " - <tr class='$style'> - <td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td> - <td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td> - <td align='center'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='".__('Update')."' /><br /> - <input name='deletemeta[{$entry['meta_id']}]' type='submit' class='deletemeta' tabindex='6' value='".__('Delete')."' /></td> - </tr> - "; - } - echo " - </table> - "; + $key_js = addslashes(wp_specialchars( $entry['meta_key'], 'double' )); + $entry['meta_key'] = wp_specialchars( $entry['meta_key'], true ); + $entry['meta_value'] = wp_specialchars( $entry['meta_value'], true ); + $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>"; + $r .= "\n\t\t<td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td>"; + $r .= "\n\t\t<td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>"; + $r .= "\n\t\t<td align='center'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='".__('Update')."' /><br />"; + $r .= "\n\t\t<input name='deletemeta[{$entry['meta_id']}]' type='submit' onclick=\"return deleteSomething( 'meta', {$entry['meta_id']}, '"; + $r .= sprintf(__("You are about to delete the "%s" custom field on this post.\\n"OK" to delete, "Cancel" to stop."), $key_js); + $r .= "' );\" class='deletemeta' tabindex='6' value='".__('Delete')."' /></td>"; + $r .= "\n\t</tr>"; + } + echo $r; + echo "\n\t</tbody>"; } // Get a list of previously defined keys @@ -893,7 +951,7 @@ function meta_form() { LIMIT 10"); ?> <h3><?php _e('Add a new custom field:') ?></h3> -<table cellspacing="3" cellpadding="3"> +<table id="newmeta" cellspacing="3" cellpadding="3"> <tr> <th colspan="2"><?php _e('Key') ?></th> <th><?php _e('Value') ?></th> @@ -917,13 +975,14 @@ function meta_form() { </tr> </table> -<p class="submit"><input type="submit" name="updatemeta" tabindex="9" value="<?php _e('Add Custom Field »') ?>" /></p> +<p class="submit"><input type="submit" id="updatemetasub" name="updatemeta" tabindex="9" value="<?php _e('Add Custom Field »') ?>" /></p> <?php } function add_meta($post_ID) { global $wpdb; + $post_ID = (int) $post_ID; $metakeyselect = $wpdb->escape(stripslashes(trim($_POST['metakeyselect']))); $metakeyinput = $wpdb->escape(stripslashes(trim($_POST['metakeyinput']))); @@ -933,7 +992,7 @@ function add_meta($post_ID) { // We have a key/value pair. If both the select and the // input for the key have data, the input takes precedence: - if ('#NONE#' != $metakeyselect) + if ('#NONE#' != $metakeyselect) $metakey = $metakeyselect; if ($metakeyinput) @@ -944,23 +1003,34 @@ function add_meta($post_ID) { (post_id,meta_key,meta_value) VALUES ('$post_ID','$metakey','$metavalue') "); + return $wpdb->insert_id; } + return false; } // add_meta function delete_meta($mid) { global $wpdb; + $mid = (int) $mid; - $result = $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'"); + return $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'"); } function update_meta($mid, $mkey, $mvalue) { global $wpdb; + $mid = (int) $mid; return $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '$mkey', meta_value = '$mvalue' WHERE meta_id = '$mid'"); } +function get_post_meta_by_id($mid) { + global $wpdb; + $mid = (int) $mid; + + return $wpdb->get_row("SELECT * FROM $wpdb->postmeta WHERE meta_id = '$mid'"); +} + function touch_time($edit = 1, $for_post = 1) { - global $month, $post, $comment; + global $wp_locale, $post, $comment; if ( $for_post ) $edit = ( ('draft' == $post->post_status) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date) ) ? false : true; @@ -976,29 +1046,25 @@ function touch_time($edit = 1, $for_post = 1) { $mn = ($edit) ? mysql2date('i', $post_date) : gmdate('i', $time_adj); $ss = ($edit) ? mysql2date('s', $post_date) : gmdate('s', $time_adj); - echo "<select name=\"mm\">\n"; + echo "<select name=\"mm\" onchange=\"edit_date.checked=true\">\n"; for ($i = 1; $i < 13; $i = $i +1) { echo "\t\t\t<option value=\"$i\""; if ($i == $mm) - echo " selected='selected'"; - if ($i < 10) { - $ii = "0".$i; - } else { - $ii = "$i"; - } - echo ">".$month["$ii"]."</option>\n"; + echo ' selected="selected"'; + echo '>' . $wp_locale->get_month($i) . "</option>\n"; } ?> </select> -<input type="text" id="jj" name="jj" value="<?php echo $jj; ?>" size="2" maxlength="2" /> -<input type="text" id="aa" name="aa" value="<?php echo $aa ?>" size="4" maxlength="5" /> @ -<input type="text" id="hh" name="hh" value="<?php echo $hh ?>" size="2" maxlength="2" /> : -<input type="text" id="mn" name="mn" value="<?php echo $mn ?>" size="2" maxlength="2" /> -<input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" /> +<input type="text" id="jj" name="jj" value="<?php echo $jj; ?>" size="2" maxlength="2" onchange="edit_date.checked=true"/> +<input type="text" id="aa" name="aa" value="<?php echo $aa ?>" size="4" maxlength="5" onchange="edit_date.checked=true" /> @ +<input type="text" id="hh" name="hh" value="<?php echo $hh ?>" size="2" maxlength="2" onchange="edit_date.checked=true" /> : +<input type="text" id="mn" name="mn" value="<?php echo $mn ?>" size="2" maxlength="2" onchange="edit_date.checked=true" /> +<input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" onchange="edit_date.checked=true" /> <?php if ( $edit ) { _e('Existing timestamp'); - echo ": {$month[$mm]} $jj, $aa @ $hh:$mn"; + //echo ': ' . $wp_locale->get_month($mm) . "$jj, $aa @ $hh:$mn"; + echo sprintf(__(': %1$s %2$s, %3$s @ %4$s:%5$s'), $wp_locale->get_month($mm), $jj, $aa, $hh, $mn); } ?> </fieldset> @@ -1023,11 +1089,15 @@ function insert_with_markers($filename, $marker, $insertion) { $foundit = false; if ($markerdata) { $state = true; - foreach ($markerdata as $markerline) { + foreach ($markerdata as $n => $markerline) { if (strstr($markerline, "# BEGIN {$marker}")) $state = false; - if ($state) - fwrite($f, "{$markerline}\n"); + if ($state) { + if ( $n + 1 < count($markerdata) ) + fwrite($f, "{$markerline}\n"); + else + fwrite($f, "{$markerline}"); + } if (strstr($markerline, "# END {$marker}")) { fwrite($f, "# BEGIN {$marker}\n"); if (is_array($insertion)) @@ -1829,8 +1899,10 @@ function wp_handle_upload(&$file, $overrides = false) { // Compute the URL $url = $uploads['url'] . "/$filename"; + + $return = apply_filters( 'wp_handle_upload', array('file' => $new_file, 'url' => $url, 'type' => $type) ); - return array('file' => $new_file, 'url' => $url, 'type' => $type); + return $return; } function wp_shrink_dimensions($width, $height, $wmax = 128, $hmax = 96) { |