summaryrefslogtreecommitdiffstats
path: root/wp-admin/includes
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2008-06-24 17:00:10 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2008-06-24 17:00:10 +0000
commit631c9bb4d60d242432052f56c00768392f42a392 (patch)
tree50d41b0248d5c5fb156c6d52020675208b77a3e6 /wp-admin/includes
parenta1fbe4e0694a66d7351e2f6280ab84568681e8e0 (diff)
downloadwordpress-mu-631c9bb4d60d242432052f56c00768392f42a392.tar.gz
wordpress-mu-631c9bb4d60d242432052f56c00768392f42a392.tar.xz
wordpress-mu-631c9bb4d60d242432052f56c00768392f42a392.zip
WP Merge to revision 8180
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1336 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-admin/includes')
-rw-r--r--wp-admin/includes/dashboard.php5
-rw-r--r--wp-admin/includes/file.php30
-rw-r--r--wp-admin/includes/media.php66
-rw-r--r--wp-admin/includes/plugin.php13
-rw-r--r--wp-admin/includes/schema.php4
-rw-r--r--wp-admin/includes/template.php196
-rw-r--r--wp-admin/includes/upgrade.php5
7 files changed, 207 insertions, 112 deletions
diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php
index 1b4f86e..27839fc 100644
--- a/wp-admin/includes/dashboard.php
+++ b/wp-admin/includes/dashboard.php
@@ -36,9 +36,10 @@ function wp_dashboard_setup() {
);
// Incoming Links Widget
- if ( !isset( $widget_options['dashboard_incoming_links'] ) ) {
+ if ( !isset( $widget_options['dashboard_incoming_links'] ) || !isset( $widget_options['dashboard_incoming_links']['home'] ) || $widget_options['dashboard_incoming_links']['home'] != get_option('home') ) {
$update = true;
$widget_options['dashboard_incoming_links'] = array(
+ 'home' => get_option('home'),
'link' => apply_filters( 'dashboard_incoming_links_link', 'http://blogsearch.google.com/blogsearch?hl=en&scoring=d&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ),
'url' => apply_filters( 'dashboard_incoming_links_feed', 'http://blogsearch.google.com/blogsearch_feeds?hl=en&scoring=d&ie=utf-8&num=10&output=rss&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ),
'items' => 5,
@@ -315,7 +316,7 @@ function wp_dashboard_incoming_links_output() {
$widgets = get_option( 'dashboard_widget_options' );
@extract( @$widgets['dashboard_incoming_links'], EXTR_SKIP );
$rss = @fetch_rss( $url );
- if ( isset($rss->items) && 1 < count($rss->items) ) {// Technorati returns a 1-item feed when it has no results
+ if ( isset($rss->items) && 0 < count($rss->items) ) {
echo "<ul>\n";
diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php
index 29609b2..078cb9d 100644
--- a/wp-admin/includes/file.php
+++ b/wp-admin/includes/file.php
@@ -41,6 +41,34 @@ function get_real_file_to_edit( $file ) {
return $real_file;
}
+//$folder = Full path to folder
+//$levels = Levels of folders to follow, Default: 100 (PHP Loop limit)
+function list_files( $folder = '', $levels = 100 ) {
+ if( empty($folder) )
+ return false;
+
+ if( ! $levels )
+ return false;
+
+ $files = array();
+ if ( $dir = @opendir( $folder ) ) {
+ while (($file = readdir( $dir ) ) !== false ) {
+ if ( in_array($file, array('.', '..') ) )
+ continue;
+ if ( is_dir( $folder . '/' . $file ) ) {
+ $files2 = list_files( $folder . '/' . $file, $levels - 1);
+ if( $files2 )
+ $files = array_merge($files, $files2 );
+ else
+ $files[] = $folder . '/' . $file . '/';
+ } else {
+ $files[] = $folder . '/' . $file;
+ }
+ }
+ }
+ @closedir( $dir );
+ return $files;
+}
function get_temp_dir() {
if ( defined('WP_TEMP_DIR') )
@@ -171,7 +199,7 @@ 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 ) ) {
- wp_die( __('There was a problem uploading your file. Please try again.' ) );
+ return $upload_error_handler( $file, __('The uploaded file could not be moved to the upload folder.' ) );
}
// Set correct file permissions
diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php
index 4d42def..d6fdec2 100644
--- a/wp-admin/includes/media.php
+++ b/wp-admin/includes/media.php
@@ -115,41 +115,6 @@ function media_handle_upload($file_id, $post_id, $post_data = array()) {
}
-
-function media_sideload_image($file, $post_id, $desc = null) {
-
- if (!empty($file) ) {
- // Upload File button was clicked
-
- $file_array['name'] = basename($file);
- $file_array['tmp_name'] = download_url($file);
- $desc = @$desc;
-
- $sideload = media_handle_sideload($file_array, $post_id, $desc);
-
- $id = $sideload['id'];
- $src = $sideload['src'];
-
- unset($file_array['tmp_name']);
- unset($file_array);
-
- if ( is_wp_error($id) ) {
- $errors['upload_error'] = $id;
- $id = false;
- }
- }
-
- if ( !empty($src) && !strpos($src, '://') )
-
- $src = "http://$src";
- $alt = @$desc;
-
- if ( !empty($src) )
- $html = "<img src='$src' alt='$alt' />";
- return $html;
-
-}
-
function media_handle_sideload($file_array, $post_id, $desc = null, $post_data = array()) {
$overrides = array('test_form'=>false);
$file = wp_handle_sideload($file_array, $overrides);
@@ -186,10 +151,9 @@ function media_handle_sideload($file_array, $post_id, $desc = null, $post_data =
$id = wp_insert_attachment($attachment, $file, $post_parent);
if ( !is_wp_error($id) ) {
wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
+ return $url;
}
-
- return array('id' => $id, 'src' => $url);
-
+ return $id;
}
@@ -348,6 +312,32 @@ function media_upload_image() {
return wp_iframe( 'media_upload_type_form', 'image', $errors, $id );
}
+function media_sideload_image($file, $post_id, $desc = null) {
+ if (!empty($file) ) {
+ $file_array['name'] = basename($file);
+ $file_array['tmp_name'] = download_url($file);
+ $desc = @$desc;
+
+ $id = media_handle_sideload($file_array, $post_id, $desc);
+ $src = $id;
+
+ unset($file_array);
+
+ if ( is_wp_error($id) ) {
+ $errors['upload_error'] = $id;
+ return $id;
+ }
+ }
+
+ if ( !empty($src) ) {
+ if ( !strpos($src, '://') )
+ $src = "http://$src";
+ $alt = @$desc;
+ $html = "<img src='$src' alt='$alt' />";
+ return $html;
+ }
+}
+
function media_upload_audio() {
if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
// Upload File button was clicked
diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php
index 3afaed9..72acd45 100644
--- a/wp-admin/includes/plugin.php
+++ b/wp-admin/includes/plugin.php
@@ -136,7 +136,6 @@ function deactivate_plugins($plugins, $silent= false) {
update_option('active_plugins', $current);
}
-//Replaces reactivate_all_plugins() / deactivate_all_plugins() = 'deactivated_plugins' is now useless
function activate_plugins($plugins, $redirect = '') {
if ( !is_array($plugins) )
$plugins = array($plugins);
@@ -167,7 +166,7 @@ function delete_plugins($plugins, $redirect = '' ) {
$checked[] = 'checked[]=' . $plugin;
ob_start();
- $url = wp_nonce_url('plugins.php?action=delete-selected&' . implode('&', $checked), 'mass-manage-plugins');
+ $url = wp_nonce_url('plugins.php?action=delete-selected&verify-delete=1&' . implode('&', $checked), 'bulk-manage-plugins');
if ( false === ($credentials = request_filesystem_credentials($url)) ) {
$data = ob_get_contents();
ob_end_clean();
@@ -243,13 +242,9 @@ function validate_active_plugins() {
// If a plugin file does not exist, remove it from the list of active
// plugins.
foreach ( $check_plugins as $check_plugin ) {
- if ( !file_exists(WP_PLUGIN_DIR . '/' . $check_plugin) ) {
- $current = get_option('active_plugins');
- $key = array_search($check_plugin, $current);
- if ( false !== $key && NULL !== $key ) {
- unset($current[$key]);
- update_option('active_plugins', $current);
- }
+ $result = validate_plugin($check_plugin);
+ if ( is_wp_error( $result ) ) {
+ deactivate_plugins( $check_plugin, true);
}
}
}
diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php
index 1c58b8f..afaee6b 100644
--- a/wp-admin/includes/schema.php
+++ b/wp-admin/includes/schema.php
@@ -331,7 +331,9 @@ function populate_options() {
// 2.6
add_option('avatar_default', 'mystery');
-
+ add_option('enable_app',0);
+ add_option('enable_xmlrpc',0);
+
// Delete unused options
$unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins');
foreach ($unusedoptions as $option) :
diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php
index c348e7f..346fe7e 100644
--- a/wp-admin/includes/template.php
+++ b/wp-admin/includes/template.php
@@ -4,35 +4,73 @@
// Big Mess
//
-// Dandy new recursive multiple category stuff.
-function cat_rows( $parent = 0, $level = 0, $categories = 0 ) {
- if ( !$categories ) {
+// Ugly recursive category stuff.
+function cat_rows( $parent = 0, $level = 0, $categories = 0, $page = 1, $per_page = 20 ) {
+ $count = 0;
+ _cat_rows($categories, $count, $parent, $level, $page, $per_page);
+}
+
+function _cat_rows( $categories, &$count, $parent = 0, $level = 0, $page = 1, $per_page = 20 ) {
+ if ( empty($categories) ) {
$args = array('hide_empty' => 0);
if ( !empty($_GET['s']) )
$args['search'] = $_GET['s'];
$categories = get_categories( $args );
}
+ if ( !$categories )
+ return false;
+
$children = _get_term_hierarchy('category');
- if ( $categories ) {
- ob_start();
- foreach ( $categories as $category ) {
- if ( $category->parent == $parent) {
- echo "\t" . _cat_row( $category, $level );
- if ( isset($children[$category->term_id]) )
- cat_rows( $category->term_id, $level +1, $categories );
+ $start = ($page - 1) * $per_page;
+ $end = $start + $per_page;
+ $i = -1;
+ ob_start();
+ foreach ( $categories as $category ) {
+ if ( $count >= $end )
+ break;
+
+ $i++;
+
+ if ( $category->parent != $parent )
+ continue;
+
+ // If the page starts in a subtree, print the parents.
+ if ( $count == $start && $category->parent > 0 ) {
+ $my_parents = array();
+ $my_parent = $category->parent;
+ while ( $my_parent) {
+ $my_parent = get_category($my_parent);
+ $my_parents[] = $my_parent;
+ if ( !$my_parent->parent )
+ break;
+ $my_parent = $my_parent->parent;
+ }
+ $num_parents = count($my_parents);
+ while( $my_parent = array_pop($my_parents) ) {
+ echo "\t" . _cat_row( $my_parent, $level - $num_parents );
+ $num_parents--;
}
}
- $output = ob_get_contents();
- ob_end_clean();
- $output = apply_filters('cat_rows', $output);
+ if ( $count >= $start )
+ echo "\t" . _cat_row( $category, $level );
+
+ unset($categories[$i]); // Prune the working set
+ $count++;
+
+ if ( isset($children[$category->term_id]) )
+ _cat_rows( $categories, $count, $category->term_id, $level + 1, $page, $per_page );
- echo $output;
- } else {
- return false;
}
+
+ $output = ob_get_contents();
+ ob_end_clean();
+
+ $output = apply_filters('cat_rows', $output);
+
+ echo $output;
}
function _cat_row( $category, $level, $name_override = false ) {
@@ -360,7 +398,7 @@ function wp_manage_pages_columns() {
* display one row if the page doesn't have any children
* otherwise, display the row and its children in subsequent rows
*/
-function display_page_row( $page, &$children_pages, $level = 0 ) {
+function display_page_row( $page, $level = 0 ) {
global $post;
static $class;
@@ -484,66 +522,104 @@ foreach ($posts_columns as $column_name=>$column_display_name) {
</tr>
<?php
-
- if ( ! $children_pages )
- return true;
-
- for ( $i = 0; $i < count($children_pages); $i++ ) {
-
- $child = $children_pages[$i];
-
- if ( $child->post_parent == $id ) {
- array_splice($children_pages, $i, 1);
- display_page_row($child, $children_pages, $level+1);
- $i = -1; //as numeric keys in $children_pages are not preserved after splice
- }
- }
}
/*
* displays pages in hierarchical order
*/
-function page_rows( $pages ) {
- if ( ! $pages )
+
+function page_rows($pages, $pagenum = 1, $per_page = 20) {
+ $level = 0;
+
+ if ( ! $pages ) {
$pages = get_pages( array('sort_column' => 'menu_order') );
- if ( ! $pages )
- return false;
+ if ( ! $pages )
+ return false;
+ }
// splice pages into two parts: those without parent and those with parent
-
$top_level_pages = array();
$children_pages = array();
+ // If searching, ignore hierarchy and treat everything as top level, otherwise split
+ // into top level and children
+ if ( empty($_GET['s']) ) {
+ foreach ( $pages as $page ) {
+ // catch and repair bad pages
+ if ( $page->post_parent == $page->ID ) {
+ $page->post_parent = 0;
+ $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = '0' WHERE ID = %d", $page->ID) );
+ clean_page_cache( $page->ID );
+ }
+
+ if ( 0 == $page->post_parent )
+ $top_level_pages[] = $page;
+ else
+ $children_pages[] = $page;
+ }
+
+ $pages = &$top_level_pages;
+ }
+
+ $count = 0;
+ $start = ($pagenum - 1) * $per_page;
+ $end = $start + $per_page;
foreach ( $pages as $page ) {
+ if ( $count >= $end )
+ break;
- // catch and repair bad pages
- if ( $page->post_parent == $page->ID ) {
- $page->post_parent = 0;
- $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = '0' WHERE ID = %d", $page->ID) );
- clean_page_cache( $page->ID );
- }
+ $i++;
- if ( 0 == $page->post_parent )
- $top_level_pages[] = $page;
- else
- $children_pages[] = $page;
+ if ( $count >= $start )
+ echo "\t" . display_page_row( $page, $level );
+
+ $count++;
+
+ if ( isset($children_pages) )
+ _page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
}
+}
+
+function _page_rows( $pages, &$count, $parent, $level, $pagenum, $per_page ) {
+ $start = ($pagenum - 1) * $per_page;
+ $end = $start + $per_page;
+ $i = -1;
+ foreach ( $pages as $page ) {
+ if ( $count >= $end )
+ break;
+
+ $i++;
+
+ if ( $page->post_parent != $parent )
+ continue;
- foreach ( $top_level_pages as $page )
- display_page_row($page, $children_pages, 0);
-
- /*
- * display the remaining children_pages which are orphans
- * having orphan requires parental attention
- */
- if ( count($children_pages) > 0 ) {
- $empty_array = array();
- foreach ( $children_pages as $orphan_page ) {
- clean_page_cache( $orphan_page->ID);
- display_page_row( $orphan_page, $empty_array, 0 );
+ // If the page starts in a subtree, print the parents.
+ if ( $count == $start && $page->post_parent > 0 ) {
+ $my_parents = array();
+ $my_parent = $page->post_parent;
+ while ( $my_parent) {
+ $my_parent = get_post($my_parent);
+ $my_parents[] = $my_parent;
+ if ( !$my_parent->post_parent )
+ break;
+ $my_parent = $my_parent->post_parent;
+ }
+ $num_parents = count($my_parents);
+ while( $my_parent = array_pop($my_parents) ) {
+ echo "\t" . display_page_row( $my_parent, $level - $num_parents );
+ $num_parents--;
+ }
}
- }
+
+ if ( $count >= $start )
+ echo "\t" . display_page_row( $page, $level );
+
+ unset($pages[$i]); // Prune the working set
+ $count++;
+
+ _page_rows( $pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
+ }
}
function user_row( $user_object, $style = '', $role = '' ) {
@@ -839,7 +915,7 @@ function meta_form() {
</tr>
<tr class="submit"><td colspan="3">
<?php wp_nonce_field( 'add-meta', '_ajax_nonce', false ); ?>
- <input type="submit" id="addmetasub" name="addmeta" class="add:the-list:newmeta::post_id=<?php echo $GLOBALS['post_ID'] ? $GLOBALS['post_ID'] : $GLOBALS['temp_ID']; ?>" tabindex="9" value="<?php _e( 'Add Custom Field' ) ?>" />
+ <input type="submit" id="addmetasub" name="addmeta" class="add:the-list:newmeta" tabindex="9" value="<?php _e( 'Add Custom Field' ) ?>" />
</td></tr>
</table>
<?php
diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php
index 1b15aae..07a4f9f 100644
--- a/wp-admin/includes/upgrade.php
+++ b/wp-admin/includes/upgrade.php
@@ -6,7 +6,7 @@ require_once(ABSPATH . 'wp-admin/includes/admin.php');
require_once(ABSPATH . 'wp-admin/includes/schema.php');
if ( !function_exists('wp_install') ) :
-function wp_install($blog_title, $user_name, $user_email, $public, $deprecated='') {
+function wp_install($blog_title, $user_name, $user_email, $public, $remote) {
global $wp_rewrite;
wp_check_mysql_version();
@@ -18,6 +18,9 @@ function wp_install($blog_title, $user_name, $user_email, $public, $deprecated='
update_option('blogname', $blog_title);
update_option('admin_email', $user_email);
update_option('blog_public', $public);
+ update_option('enable_app',$remote);
+ update_option('enable_xmlrpc',$remote);
+
$schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
if ( defined('WP_SITEURL') && '' != WP_SITEURL )