summaryrefslogtreecommitdiffstats
path: root/wp-admin/includes
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2008-04-24 11:45:39 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2008-04-24 11:45:39 +0000
commitcf9f85dc8121a359d550ffa3b735fb48859eee88 (patch)
tree9f90be15fc46163f5656f019f2a2866414b7c9f2 /wp-admin/includes
parentf10f9f5b05e23ce4c07479b094bd3ff4bbfd86d0 (diff)
downloadwordpress-mu-cf9f85dc8121a359d550ffa3b735fb48859eee88.tar.gz
wordpress-mu-cf9f85dc8121a359d550ffa3b735fb48859eee88.tar.xz
wordpress-mu-cf9f85dc8121a359d550ffa3b735fb48859eee88.zip
Merged with WP 2.5, revision 7806
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1260 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-admin/includes')
-rw-r--r--wp-admin/includes/admin.php3
-rw-r--r--wp-admin/includes/class-wp-filesystem-direct.php84
-rw-r--r--wp-admin/includes/comment.php27
-rw-r--r--wp-admin/includes/dashboard.php3
-rw-r--r--wp-admin/includes/file.php3
-rw-r--r--wp-admin/includes/image.php2
-rw-r--r--wp-admin/includes/media.php37
-rw-r--r--wp-admin/includes/post.php9
-rw-r--r--wp-admin/includes/schema.php2
-rw-r--r--wp-admin/includes/template.php147
-rw-r--r--wp-admin/includes/upgrade.php18
-rw-r--r--wp-admin/includes/widgets.php24
12 files changed, 194 insertions, 165 deletions
diff --git a/wp-admin/includes/admin.php b/wp-admin/includes/admin.php
index 7f1c12c..992fcce 100644
--- a/wp-admin/includes/admin.php
+++ b/wp-admin/includes/admin.php
@@ -1,8 +1,5 @@
<?php
-if ( !defined( 'AUTOSAVE_INTERVAL' ) )
- define( 'AUTOSAVE_INTERVAL', 60 );
-
require_once(ABSPATH . 'wp-admin/includes/bookmark.php');
require_once(ABSPATH . 'wp-admin/includes/comment.php');
require_once(ABSPATH . 'wp-admin/includes/file.php');
diff --git a/wp-admin/includes/class-wp-filesystem-direct.php b/wp-admin/includes/class-wp-filesystem-direct.php
index dc74f52..45972a3 100644
--- a/wp-admin/includes/class-wp-filesystem-direct.php
+++ b/wp-admin/includes/class-wp-filesystem-direct.php
@@ -26,8 +26,7 @@ class WP_Filesystem_Direct{
return @file($file);
}
function put_contents($file,$contents,$mode=false,$type=''){
- $fp=@fopen($file,'w'.$type);
- if (!$fp)
+ if ( ! ($fp = @fopen($file,'w'.$type)) )
return false;
@fwrite($fp,$contents);
@fclose($fp);
@@ -37,6 +36,9 @@ class WP_Filesystem_Direct{
function cwd(){
return @getcwd();
}
+ function chdir($dir){
+ return @chdir($dir);
+ }
function chgrp($file,$group,$recursive=false){
if( ! $this->exists($file) )
return false;
@@ -45,10 +47,11 @@ class WP_Filesystem_Direct{
if( ! $this->is_dir($file) )
return @chgrp($file,$group);
//Is a directory, and we want recursive
+ $file = trailingslashit($file);
$filelist = $this->dirlist($file);
- foreach($filelist as $filename){
- $this->chgrp($file.'/'.$filename,$group,$recursive);
- }
+ foreach($filelist as $filename)
+ $this->chgrp($file . $filename, $group, $recursive);
+
return true;
}
function chmod($file,$mode=false,$recursive=false){
@@ -61,10 +64,11 @@ class WP_Filesystem_Direct{
if( ! $this->is_dir($file) )
return @chmod($file,$mode);
//Is a directory, and we want recursive
+ $file = trailingslashit($file);
$filelist = $this->dirlist($file);
- foreach($filelist as $filename){
- $this->chmod($file.'/'.$filename,$mode,$recursive);
- }
+ foreach($filelist as $filename)
+ $this->chmod($file . $filename, $mode, $recursive);
+
return true;
}
function chown($file,$owner,$recursive=false){
@@ -82,12 +86,12 @@ class WP_Filesystem_Direct{
return true;
}
function owner($file){
- $owneruid=@fileowner($file);
+ $owneruid = @fileowner($file);
if( ! $owneruid )
return false;
if( !function_exists('posix_getpwuid') )
return $owneruid;
- $ownerarray=posix_getpwuid($owneruid);
+ $ownerarray = posix_getpwuid($owneruid);
return $ownerarray['name'];
}
function getchmod($file){
@@ -163,23 +167,23 @@ class WP_Filesystem_Direct{
return $newmode;
}
function group($file){
- $gid=@filegroup($file);
+ $gid = @filegroup($file);
if( ! $gid )
return false;
if( !function_exists('posix_getgrgid') )
return $gid;
- $grouparray=posix_getgrgid($gid);
+ $grouparray = posix_getgrgid($gid);
return $grouparray['name'];
}
function copy($source,$destination,$overwrite=false){
- if( $overwrite && $this->exists($destination) )
+ if( ! $overwrite && $this->exists($destination) )
return false;
return copy($source,$destination);
}
function move($source,$destination,$overwrite=false){
- //Possible to use rename()
+ //Possible to use rename()?
if( $this->copy($source,$destination,$overwrite) && $this->exists($destination) ){
$this->delete($source);
return true;
@@ -188,24 +192,24 @@ class WP_Filesystem_Direct{
}
}
- function delete($file,$recursive=false){
+ function delete($file, $recursive=false){
$file = str_replace('\\','/',$file); //for win32, occasional problems deleteing files otherwise
if( $this->is_file($file) )
return @unlink($file);
-
if( !$recursive && $this->is_dir($file) )
return @rmdir($file);
- $filelist = $this->dirlist($file);
- if( ! $filelist )
- return true; //No files exist, Say we've deleted them
+ //At this point its a folder, and we're in recursive mode
+ $file = trailingslashit($file);
+ $filelist = $this->dirlist($file, true);
$retval = true;
- foreach($filelist as $filename=>$fileinfo){
- if( ! $this->delete($file.'/'.$filename,$recursive) )
- $retval = false;
- }
+ if( is_array($filelist) ) //false if no files, So check first.
+ foreach($filelist as $filename=>$fileinfo)
+ if( ! $this->delete($file . $filename, $recursive) )
+ $retval = false;
+
if( ! @rmdir($file) )
return false;
return $retval;
@@ -224,7 +228,7 @@ class WP_Filesystem_Direct{
}
function is_readable($file){
- return @is_readable($file);
+ return @is_readable($file);
}
function is_writable($file){
@@ -242,15 +246,15 @@ class WP_Filesystem_Direct{
return @filesize($file);
}
- function touch($file,$time=0,$atime=0){
- if($time==0)
+ function touch($file, $time = 0, $atime = 0){
+ if($time == 0)
$time = time();
- if($atime==0)
+ if($atime == 0)
$atime = time();
return @touch($file,$time,$atime);
}
- function mkdir($path,$chmod=false,$chown=false,$chgrp=false){
+ function mkdir($path, $chmod = false, $chown = false, $chgrp = false){
if( ! $chmod)
$chmod = $this->permission;
@@ -264,6 +268,7 @@ class WP_Filesystem_Direct{
}
function rmdir($path,$recursive=false){
+ //Currently unused and untested, Use delete() instead.
if( ! $recursive )
return @rmdir($path);
//recursive:
@@ -292,6 +297,8 @@ class WP_Filesystem_Direct{
$struc = array();
$struc['name'] = $entry;
+ if( '.' == $struc['name'] || '..' == $struc['name'] )
+ continue; //Do not care about these folders.
if( '.' == $struc['name'][0] && !$incdot)
continue;
if( $limitFile && $struc['name'] != $limitFile)
@@ -307,22 +314,15 @@ class WP_Filesystem_Direct{
$struc['lastmod'] = date('M j',$struc['lastmodunix']);
$struc['time'] = date('h:i:s',$struc['lastmodunix']);
$struc['type'] = $this->is_dir($path.'/'.$entry) ? 'd' : 'f';
- if ('d' == $struc['type'] ){
- $struc['files'] = array();
- if( $incdot ){
- //We're including the doted starts
- if( '.' != $struc['name'] && '..' != $struc['name'] ){ //Ok, It isnt a special folder
- if ($recursive)
- $struc['files'] = $this->dirlist($path.'/'.$struc['name'],$incdot,$recursive);
- }
- } else { //No dots
- if ($recursive)
- $struc['files'] = $this->dirlist($path.'/'.$struc['name'],$incdot,$recursive);
- }
+ if ('d' == $struc['type'] ){
+ if( $recursive )
+ $struc['files'] = $this->dirlist($path.'/'.$struc['name'], $incdot, $recursive);
+ else
+ $struc['files'] = array();
}
- //File
- $ret[$struc['name']] = $struc;
+
+ $ret[ $struc['name'] ] = $struc;
}
$dir->close();
unset($dir);
diff --git a/wp-admin/includes/comment.php b/wp-admin/includes/comment.php
index e08ae4d..0f2aa61 100644
--- a/wp-admin/includes/comment.php
+++ b/wp-admin/includes/comment.php
@@ -21,7 +21,7 @@ function edit_comment() {
$_POST['comment_content'] = $_POST['content'];
$_POST['comment_ID'] = (int) $_POST['comment_ID'];
- foreach ( array ('aa', 'mm', 'jj', 'hh', 'mm') as $timeunit ) {
+ foreach ( array ('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) {
if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) {
$_POST['edit_date'] = '1';
break;
@@ -66,9 +66,28 @@ function get_comment_to_edit( $id ) {
function get_pending_comments_num( $post_id ) {
global $wpdb;
- $post_id = (int) $post_id;
- $pending = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = $post_id AND comment_approved = '0'" );
- return $pending;
+
+ $single = false;
+ if ( !is_array($post_id) ) {
+ $post_id = (array) $post_id;
+ $single = true;
+ }
+ $post_id = array_map('intval', $post_id);
+ $post_id = "'" . implode("', '", $post_id) . "'";
+
+ $pending = $wpdb->get_results( "SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id ) AND comment_approved = '0' GROUP BY comment_post_ID", ARRAY_N );
+
+ if ( empty($pending) )
+ return 0;
+
+ if ( $single )
+ return $pending[0][1];
+
+ $pending_keyed = array();
+ foreach ( $pending as $pend )
+ $pending_keyed[$pend[0]] = $pend[1];
+
+ return $pending_keyed;
}
// Add avatars to relevant places in admin, or try to
diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php
index 72a6dbc..9ce9db9 100644
--- a/wp-admin/includes/dashboard.php
+++ b/wp-admin/includes/dashboard.php
@@ -4,7 +4,8 @@
function wp_dashboard_setup() {
global $wpdb, $wp_dashboard_sidebars;
$update = false;
- if ( !$widget_options = get_option( 'dashboard_widget_options' ) )
+ $widget_options = get_option( 'dashboard_widget_options' );
+ if ( !$widget_options || !is_array($widget_options) )
$widget_options = array();
diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php
index 75ef4e3..a399a5a 100644
--- a/wp-admin/includes/file.php
+++ b/wp-admin/includes/file.php
@@ -174,8 +174,9 @@ function wp_handle_upload( &$file, $overrides = false ) {
// Move the file to the uploads dir
$new_file = $uploads['path'] . "/$filename";
- if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file ) )
+ if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file ) ) {
wp_die( __('There was a problem uploading your file. Please try again.' ) );
+ }
// Set correct file permissions
$stat = stat( dirname( $new_file ));
diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php
index 2af026d..7699f98 100644
--- a/wp-admin/includes/image.php
+++ b/wp-admin/includes/image.php
@@ -235,7 +235,7 @@ function wp_read_image_metadata( $file ) {
// fetch additional info from exif if available
if ( is_callable('exif_read_data') && in_array($sourceImageType, apply_filters('wp_read_image_metadata_types', array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM)) ) ) {
- $exif = exif_read_data( $file );
+ $exif = @exif_read_data( $file );
if (!empty($exif['FNumber']))
$meta['aperture'] = round( wp_exif_frac2dec( $exif['FNumber'] ), 2 );
if (!empty($exif['Model']))
diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php
index d8c3858..6b28c96 100644
--- a/wp-admin/includes/media.php
+++ b/wp-admin/includes/media.php
@@ -57,7 +57,7 @@ function get_image_send_to_editor($id, $alt, $title, $align, $url='', $rel = fal
if ( $url )
$html = "<a href='".attribute_escape($url)."'$rel>$html</a>";
- $html = apply_filters( 'image_send_to_editor', $html, $id, $alt, $title, $align, $url );
+ $html = apply_filters( 'image_send_to_editor', $html, $id, $alt, $title, $align, $url, $size );
return $html;
}
@@ -202,18 +202,6 @@ add_action('media_upload_media', 'media_upload_handler');
function media_upload_form_handler() {
check_admin_referer('media-form');
- // Insert media button was clicked
- if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
- // Upload File button was clicked
-
- $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
-
- if ( is_wp_error($id) ) {
- $errors['upload_error'] = $id;
- $id = false;
- }
- }
-
if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) {
$post = $_post = get_post($attachment_id, ARRAY_A);
if ( isset($attachment['post_content']) )
@@ -590,8 +578,9 @@ function get_attachment_fields_to_edit($post, $errors = null) {
}
function get_media_items( $post_id, $errors ) {
- if ( $post_id && $post = get_post($post_id) ) {
- if ( $post->post_type == 'attachment' )
+ if ( $post_id ) {
+ $post = get_post($post_id);
+ if ( $post && $post->post_type == 'attachment' )
$attachments = array($post->ID => $post);
else
$attachments = get_children("post_parent=$post_id&post_type=attachment&orderby=menu_order ASC, ID&order=DESC");
@@ -606,7 +595,7 @@ function get_media_items( $post_id, $errors ) {
foreach ( $attachments as $id => $attachment )
if ( $item = get_media_item( $id, array( 'errors' => isset($errors[$id]) ? $errors[$id] : null) ) )
- $output .= "\n<div id='media-item-$id' class='media-item child-of-$attachment->post_parent preloaded'><div id='media-upload-error-$id'></div><div class='filename'></div><div class='progress'><div class='bar'></div></div>$item<div class='progress clickmask'></div>\n</div>";
+ $output .= "\n<div id='media-item-$id' class='media-item child-of-$attachment->post_parent preloaded'><div class='progress'><div class='bar'></div></div><div id='media-upload-error-$id'></div><div class='filename'></div>$item\n</div>";
return $output;
}
@@ -665,15 +654,15 @@ function get_media_item( $attachment_id, $args = null ) {
$toggle_links
<div class='filename new'>$display_title</div>
<table class='slidetoggle describe $class'>
- <tbody class='media-item-info'>
+ <thead class='media-item-info'>
<tr>
<td class='A1B1' rowspan='4'><img class='thumbnail' src='$thumb_url' alt='' /></td>
<td>$filename</td>
</tr>
- <td>$post->post_mime_type</td></tr>
+ <tr><td>$post->post_mime_type</td></tr>
<tr><td>" . mysql2date($post->post_date, get_option('time_format')) . "</td></tr>
- <tr><td>" . apply_filters('media_meta', '', $post) . "</tr></td>
- </tbody>
+ <tr><td>" . apply_filters('media_meta', '', $post) . "</td></tr>
+ </thead>
<tbody>\n";
$defaults = array(
@@ -685,7 +674,7 @@ function get_media_item( $attachment_id, $args = null ) {
$delete_href = wp_nonce_url("post.php?action=delete-post&amp;post=$attachment_id", 'delete-post_' . $attachment_id);
if ( $send )
- $send = "<button type='submit' class='button' value='1' name='send[$attachment_id]'>" . __('Insert into Post') . '</button>';
+ $send = "<input type='submit' class='button' name='send[$attachment_id]' value='" . __('Insert into Post') . "' />";
if ( $delete )
$delete = "<a href='$delete_href' id='del[$attachment_id]' disabled='disabled' class='delete'>" . __('Delete') . "</button>";
if ( ( $send || $delete ) && !isset($form_fields['buttons']) )
@@ -744,6 +733,7 @@ function get_media_item( $attachment_id, $args = null ) {
if ( !empty($form_fields['_final']) )
$item .= "\t\t<tr class='final'><td colspan='2'>{$form_fields['_final']}</td></tr>\n";
+ $item .= "\t</tbody>\n";
$item .= "\t</table>\n";
foreach ( $hidden_fields as $name => $value )
@@ -794,12 +784,13 @@ jQuery(function($){
upload_url : "<?php echo attribute_escape( $flash_action_url ); ?>",
flash_url : "<?php echo get_option('siteurl').'/wp-includes/js/swfupload/swfupload_f9.swf'; ?>",
file_post_name: "async-upload",
- file_types: "*.*",
+ file_types: "<?php echo apply_filters('upload_file_glob', '*.*'); ?>",
post_params : {
"post_id" : "<?php echo $post_id; ?>",
"auth_cookie" : "<?php echo $_COOKIE[AUTH_COOKIE]; ?>",
"type" : "<?php echo $type; ?>",
- "tab" : "<?php echo $tab; ?>"
+ "tab" : "<?php echo $tab; ?>",
+ "short" : "1"
},
file_size_limit : "<?php echo wp_max_upload_size(); ?>b",
swfupload_element_id : "flash-upload-ui", // id of the element displayed when swfupload is available
diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php
index 2ee6210..aa1e833 100644
--- a/wp-admin/includes/post.php
+++ b/wp-admin/includes/post.php
@@ -74,7 +74,7 @@ function edit_post() {
if (!isset( $_POST['ping_status'] ))
$_POST['ping_status'] = 'closed';
- foreach ( array ('aa', 'mm', 'jj', 'hh', 'mm') as $timeunit ) {
+ foreach ( array ('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) {
if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) {
$_POST['edit_date'] = '1';
break;
@@ -288,7 +288,7 @@ function wp_write_post() {
if (!isset( $_POST['ping_status'] ))
$_POST['ping_status'] = 'closed';
- foreach ( array ('aa', 'mm', 'jj', 'hh', 'mm') as $timeunit ) {
+ foreach ( array ('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) {
if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) {
$_POST['edit_date'] = '1';
break;
@@ -506,10 +506,9 @@ function _relocate_children( $old_ID, $new_ID ) {
}
function get_available_post_statuses($type = 'post') {
- global $wpdb;
+ $stati = wp_count_posts($type);
- $stati = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT post_status FROM $wpdb->posts WHERE post_type = %s", $type));
- return $stati;
+ return array_keys(get_object_vars($stati));
}
function wp_edit_posts_query( $q = false ) {
diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php
index 7b78d93..2d5ddcf 100644
--- a/wp-admin/includes/schema.php
+++ b/wp-admin/includes/schema.php
@@ -306,7 +306,7 @@ function populate_options() {
}
// 2.0.3
- add_option('secret', wp_generate_password());
+ add_option('secret', wp_generate_password(64));
// 2.1
add_option('blog_public', '1');
diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php
index 3e67338..db80bf8 100644
--- a/wp-admin/includes/template.php
+++ b/wp-admin/includes/template.php
@@ -55,11 +55,12 @@ function _cat_row( $category, $level, $name_override = false ) {
$output = "<tr id='cat-$category->term_id'$class>
<th scope='row' class='check-column'>";
if ( absint(get_option( 'default_category' ) ) != $category->term_id ) {
- $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' /></th>";
+ $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />";
} else {
$output .= "&nbsp;";
}
- $output .= "<td>$edit</td>
+ $output .= "</th>
+ <td>$edit</td>
<td>$category->description</td>
<td class='num'>$posts_count</td>\n\t</tr>\n";
@@ -86,11 +87,17 @@ function link_cat_row( $category ) {
$category->count = number_format_i18n( $category->count );
$count = ( $category->count > 0 ) ? "<a href='link-manager.php?cat_id=$category->term_id'>$category->count</a>" : $category->count;
- $output = "<tr id='link-cat-$category->term_id'$class>" .
- '<th scope="row" class="check-column"> <input type="checkbox" name="delete[]" value="' . $category->term_id . '" /></th>' .
- "<td>$edit</td>
- <td>$category->description</td>
- <td class='num'>$count</td></tr>";
+ $output = "<tr id='link-cat-$category->term_id'$class>
+ <th scope='row' class='check-column'>";
+ if ( absint( get_option( 'default_link_category' ) ) != $category->term_id ) {
+ $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />";
+ } else {
+ $output .= "&nbsp;";
+ }
+ $output .= "</th>
+ <td>$edit</td>
+ <td>$category->description</td>
+ <td class='num'>$count</td></tr>";
return apply_filters( 'link_cat_row', $output );
}
@@ -106,93 +113,83 @@ function selected( $selected, $current) {
}
//
-// Nasty Category Stuff
+// Category Checklists
//
-function sort_cats( $cat1, $cat2 ) {
- if ( $cat1['checked'] || $cat2['checked'] )
- return ( $cat1['checked'] && !$cat2['checked'] ) ? -1 : 1;
- else
- return strcasecmp( $cat1['cat_name'], $cat2['cat_name'] );
+// Deprecated. Use wp_link_category_checklist
+function dropdown_categories( $default = 0, $parent = 0, $popular_ids = array() ) {
+ global $post_ID;
+ wp_category_checklist($post_ID);
}
-function wp_set_checked_post_categories( $default = 0 ) {
- global $post_ID, $checked_categories;
+class Walker_Category_Checklist extends Walker {
+ var $tree_type = 'category';
+ var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
- if ( empty($checked_categories) ) {
- if ( $post_ID ) {
- $checked_categories = wp_get_post_categories($post_ID);
-
- if ( count( $checked_categories ) == 0 ) {
- // No selected categories, strange
- $checked_categories[] = $default;
- }
- } else {
- $checked_categories[] = $default;
- }
+ function start_lvl(&$output, $depth, $args) {
+ $indent = str_repeat("\t", $depth);
+ $output .= "$indent<ul class='children'>\n";
}
-}
-function get_nested_categories( $default = 0, $parent = 0 ) {
- global $checked_categories;
-
- wp_set_checked_post_categories( $default = 0 );
-
- if ( is_object($parent) ) { // Hack: if passed a category object, will return nested cats with parent as root
- $root = array(
- 'children' => get_nested_categories( $default, $parent->term_id ),
- 'cat_ID' => $parent->term_id,
- 'checked' => in_array( $parent->term_id, $checked_categories ),
- 'cat_name' => get_the_category_by_ID( $parent->term_id )
- );
- $result = array( $parent->term_id => $root );
- } else {
- $parent = (int) $parent;
+ function end_lvl(&$output, $depth, $args) {
+ $indent = str_repeat("\t", $depth);
+ $output .= "$indent</ul>\n";
+ }
- $cats = get_categories("parent=$parent&hide_empty=0&fields=ids");
+ function start_el(&$output, $category, $depth, $args) {
+ extract($args);
- $result = array();
- if ( is_array( $cats ) ) {
- foreach ( $cats as $cat ) {
- $result[$cat]['children'] = get_nested_categories( $default, $cat );
- $result[$cat]['cat_ID'] = $cat;
- $result[$cat]['checked'] = in_array( $cat, $checked_categories );
- $result[$cat]['cat_name'] = get_the_category_by_ID( $cat );
- }
- }
+ $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : '';
+ $output .= "\n<li id='category-$category->term_id'$class>" . '<label for="in-category-' . $category->term_id . '" class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="post_category[]" id="in-category-' . $category->term_id . '"' . (in_array( $category->term_id, $selected_cats ) ? ' checked="checked"' : "" ) . '/> ' . wp_specialchars( apply_filters('the_category', $category->name )) . '</label>';
}
- $result = apply_filters('get_nested_categories', $result);
- usort( $result, 'sort_cats' );
-
- return $result;
+ function end_el(&$output, $category, $depth, $args) {
+ $output .= "</li>\n";
+ }
}
-function write_nested_categories( $categories ) {
- foreach ( $categories as $category ) {
- echo "\n", '<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( apply_filters('the_category', $category['cat_name'] )), '</label>';
+function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false ) {
+ $walker = new Walker_Category_Checklist;
+ $descendants_and_self = (int) $descendants_and_self;
- if ( $category['children'] ) {
- echo "\n<ul>";
- write_nested_categories( $category['children'] );
- echo "\n</ul>";
- }
- echo '</li>';
+ $args = array();
+
+ if ( $post_id )
+ $args['selected_cats'] = wp_get_post_categories($post_id);
+ else
+ $args['selected_cats'] = array();
+ if ( is_array( $selected_cats ) )
+ $args['selected_cats'] = $selected_cats;
+ $args['popular_cats'] = get_terms( 'category', array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
+ if ( $descendants_and_self ) {
+ $categories = get_categories( "child_of=$descendants_and_self&hierarchical=0&hide_empty=0" );
+ $self = get_category( $descendants_and_self );
+ array_unshift( $categories, $self );
+ } else {
+ $categories = get_categories('get=all');
}
-}
-function dropdown_categories( $default = 0, $parent = 0 ) {
- write_nested_categories( get_nested_categories( $default, $parent ) );
+ $args = array($categories, 0, $args);
+ $output = call_user_func_array(array(&$walker, 'walk'), $args);
+
+ echo $output;
}
function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10 ) {
- $categories = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number ) );
+ global $post_ID;
+ if ( $post_ID )
+ $checked_categories = wp_get_post_categories($post_ID);
+ else
+ $checked_categories = array();
+ $categories = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) );
+ $popular_ids = array();
foreach ( (array) $categories as $category ) {
+ $popular_ids[] = $category->term_id;
$id = "popular-category-$category->term_id";
?>
- <li id="<?php echo $id; ?>" >
+ <li id="<?php echo $id; ?>" class="popular-category">
<label class="selectit" for="in-<?php echo $id; ?>">
<input id="in-<?php echo $id; ?>" type="checkbox" value="<?php echo (int) $category->term_id; ?>" />
<?php echo wp_specialchars( apply_filters( 'the_category', $category->name ) ); ?>
@@ -201,11 +198,17 @@ function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10 ) {
<?php
}
+ return $popular_ids;
}
+// Deprecated. Use wp_link_category_checklist
function dropdown_link_categories( $default = 0 ) {
global $link_id;
+ wp_link_category_checklist($link_id);
+}
+
+function wp_link_category_checklist( $link_id = 0 ) {
if ( $link_id ) {
$checked_categories = wp_get_link_cats($link_id);
@@ -585,7 +588,7 @@ function _wp_get_comment_list( $status = '', $s = false, $start, $num ) {
elseif ( 'spam' == $status )
$approved = "comment_approved = 'spam'";
else
- $approved = "comment_approved != 'spam'";
+ $approved = "( comment_approved = '0' OR comment_approved = '1' )";
if ( $s ) {
$s = $wpdb->escape($s);
@@ -1049,7 +1052,7 @@ function add_meta_box($id, $title, $callback, $page, $context = 'advanced') {
if ( !isset($wp_meta_boxes[$page][$context]) )
$wp_meta_boxes[$page][$context] = array();
- $wp_meta_boxes[$page][$context][] = array('id' => $id, 'title' => $title, 'callback' => $callback);
+ $wp_meta_boxes[$page][$context][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
}
function do_meta_boxes($page, $context, $object) {
diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php
index 1cc9df9..94bdbd3 100644
--- a/wp-admin/includes/upgrade.php
+++ b/wp-admin/includes/upgrade.php
@@ -62,13 +62,13 @@ function wp_install_defaults($user_id) {
// Default category
$cat_name = $wpdb->escape(__('Uncategorized'));
- $cat_slug = sanitize_title(__('Uncategorized'));
+ $cat_slug = sanitize_title(_c('Uncategorized|Default category slug'));
$wpdb->query("INSERT INTO $wpdb->terms (name, slug, term_group) VALUES ('$cat_name', '$cat_slug', '0')");
$wpdb->query("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ('1', 'category', '', '0', '1')");
// Default link category
$cat_name = $wpdb->escape(__('Blogroll'));
- $cat_slug = sanitize_title(__('Blogroll'));
+ $cat_slug = sanitize_title(_c('Blogroll|Default link category slug'));
$wpdb->query("INSERT INTO $wpdb->terms (name, slug, term_group) VALUES ('$cat_name', '$cat_slug', '0')");
$wpdb->query("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ('2', 'link_category', '', '0', '7')");
@@ -98,7 +98,7 @@ function wp_install_defaults($user_id) {
$now = date('Y-m-d H:i:s');
$now_gmt = gmdate('Y-m-d H:i:s');
$first_post_guid = get_option('home') . '/?p=1';
- $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, guid, comment_count, to_ping, pinged, post_content_filtered) VALUES ($user_id, '$now', '$now_gmt', '".$wpdb->escape(__('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!'))."', '', '".$wpdb->escape(__('Hello world!'))."', '0', '".$wpdb->escape(__('hello-world'))."', '$now', '$now_gmt', '$first_post_guid', '1', '', '', '')");
+ $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, guid, comment_count, to_ping, pinged, post_content_filtered) VALUES ($user_id, '$now', '$now_gmt', '".$wpdb->escape(__('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!'))."', '', '".$wpdb->escape(__('Hello world!'))."', '0', '".$wpdb->escape(_c('hello-world|Default post slug'))."', '$now', '$now_gmt', '$first_post_guid', '1', '', '', '')");
$wpdb->query( "INSERT INTO $wpdb->term_relationships (`object_id`, `term_taxonomy_id`) VALUES (1, 1)" );
// Default comment
@@ -106,7 +106,7 @@ function wp_install_defaults($user_id) {
// First Page
$first_post_guid = get_option('home') . '/?page_id=2';
- $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, guid, post_status, post_type, to_ping, pinged, post_content_filtered) VALUES ($user_id, '$now', '$now_gmt', '".$wpdb->escape(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '', '".$wpdb->escape(__('About'))."', '0', '".$wpdb->escape(__('about'))."', '$now', '$now_gmt','$first_post_guid', 'publish', 'page', '', '', '')");
+ $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, guid, post_status, post_type, to_ping, pinged, post_content_filtered) VALUES ($user_id, '$now', '$now_gmt', '".$wpdb->escape(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '', '".$wpdb->escape(__('About'))."', '0', '".$wpdb->escape(_c('about|Default page slug'))."', '$now', '$now_gmt','$first_post_guid', 'publish', 'page', '', '', '')");
}
endif;
@@ -202,6 +202,9 @@ function upgrade_all() {
if ( $wp_current_db_version < 7499 )
upgrade_250();
+ if ( $wp_current_db_version < 7796 )
+ upgrade_251();
+
maybe_disable_automattic_widgets();
$wp_rewrite->flush_rules();
@@ -737,6 +740,13 @@ function upgrade_250() {
}
+function upgrade_251() {
+ global $wp_current_db_version;
+
+ // Make the secret longer
+ update_option('secret', wp_generate_password(64));
+}
+
// The functions we use to actually do stuff
// General
diff --git a/wp-admin/includes/widgets.php b/wp-admin/includes/widgets.php
index bd425f9..da8b822 100644
--- a/wp-admin/includes/widgets.php
+++ b/wp-admin/includes/widgets.php
@@ -21,7 +21,7 @@ function wp_list_widgets( $show = 'all', $_search = false ) {
$no_widgets_shown = true;
$already_shown = array();
foreach ( $wp_registered_widgets as $name => $widget ) :
- if ( in_array( $widget['callback'], $already_shown ) ) // We already showed this multi-widget
+ if ( 'all' == $show && in_array( $widget['callback'], $already_shown ) ) // We already showed this multi-widget
continue;
if ( $search_terms ) {
@@ -47,7 +47,7 @@ function wp_list_widgets( $show = 'all', $_search = false ) {
continue;
ob_start();
- $args = wp_list_widget_controls_dynamic_sidebar( array( 0 => array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template' ) ) );
+ $args = wp_list_widget_controls_dynamic_sidebar( array( 0 => array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template', '_show' => $show ), 1 => $widget['params'][0] ) );
$sidebar_args = call_user_func_array( 'wp_widget_control', $args );
$widget_control_template = ob_get_contents();
ob_end_clean();
@@ -61,7 +61,7 @@ function wp_list_widgets( $show = 'all', $_search = false ) {
'key' => false,
'edit' => false
);
- if ( $is_multi ) {
+ if ( 'all' == $show && $is_multi ) {
// it's a multi-widget. We only need to show it in the list once.
$already_shown[] = $widget['callback'];
$num = (int) array_pop( explode( '-', $widget['id'] ) );
@@ -92,12 +92,17 @@ function wp_list_widgets( $show = 'all', $_search = false ) {
$no_widgets_shown = false;
+
+ if ( 'all' != $show && $sidebar_args['_widget_title'] )
+ $widget_title = $sidebar_args['_widget_title'];
+ else
+ $widget_title = $widget['name'];
?>
<li id="widget-list-item-<?php echo attribute_escape( $widget['id'] ); ?>" class="widget-list-item">
<h4 class="widget-title widget-draggable">
- <?php echo wp_specialchars( $widget['name'] ); ?>
+ <?php echo $widget_title; ?>
<?php if ( 'add' == $action ) : ?>
@@ -192,7 +197,7 @@ function wp_widget_control( $sidebar_args ) {
$id_format = $widget['id'];
// We aren't showing a widget control, we're outputing a template for a mult-widget control
- if ( 'template' == $sidebar_args['_display'] && isset($control['params'][0]['number']) ) {
+ if ( 'all' == $sidebar_args['_show'] && 'template' == $sidebar_args['_display'] && isset($control['params'][0]['number']) ) {
// number == -1 implies a template where id numbers are replaced by a generic '%i%'
$control['params'][0]['number'] = -1;
// if given, id_base means widget id's should be constructed like {$id_base}-{$id_number}
@@ -202,7 +207,7 @@ function wp_widget_control( $sidebar_args ) {
$widget_title = '';
// We grab the normal widget output to find the widget's title
- if ( is_callable( $widget['_callback'] ) ) {
+ if ( ( 'all' != $sidebar_args['_show'] || 'template' != $sidebar_args['_display'] ) && is_callable( $widget['_callback'] ) ) {
ob_start();
$args = func_get_args();
call_user_func_array( $widget['_callback'], $args );
@@ -212,11 +217,13 @@ function wp_widget_control( $sidebar_args ) {
$wp_registered_widgets[$widget_id]['callback'] = $wp_registered_widgets[$widget_id]['_callback'];
unset($wp_registered_widgets[$widget_id]['_callback']);
- if ( $widget_title && $widget_title != $control['name'] )
+ if ( $widget_title && $widget_title != $sidebar_args['widget_name'] )
$widget_title = sprintf( _c('%1$s: %2$s|1: widget name, 2: widget title' ), $sidebar_args['widget_name'], $widget_title );
else
$widget_title = wp_specialchars( strip_tags( $sidebar_args['widget_name'] ) );
+ $sidebar_args['_widget_title'] = $widget_title;
+
if ( empty($sidebar_args['_display']) || 'template' != $sidebar_args['_display'] )
echo $sidebar_args['before_widget'];
?>
@@ -270,7 +277,8 @@ function wp_widget_control_ob_filter( $string ) {
if ( false === $end = strpos( $string, '%END_OF_TITLE%' ) )
return '';
$string = substr( $string, $beg + 14 , $end - $beg - 14);
- return wp_specialchars( strip_tags( $string ) );
+ $string = str_replace( '&nbsp;', ' ', $string );
+ return trim( wp_specialchars( strip_tags( $string ) ) );
}
function widget_css() {