summaryrefslogtreecommitdiffstats
path: root/wp-inst/wp-admin/admin-functions.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2005-09-27 09:09:04 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2005-09-27 09:09:04 +0000
commit41c844d0db6d3f793b563ea69ab624a5a5cb5b1c (patch)
tree72d2d3ea4e82e0e48dca226704b80149284417cd /wp-inst/wp-admin/admin-functions.php
parent5184cda2b0c48d5f901381956348336b55d235d6 (diff)
downloadwordpress-mu-41c844d0db6d3f793b563ea69ab624a5a5cb5b1c.tar.gz
wordpress-mu-41c844d0db6d3f793b563ea69ab624a5a5cb5b1c.tar.xz
wordpress-mu-41c844d0db6d3f793b563ea69ab624a5a5cb5b1c.zip
WP Merge, Andy's new upload code, REQUIRES upgrading of db!
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@374 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-inst/wp-admin/admin-functions.php')
-rw-r--r--wp-inst/wp-admin/admin-functions.php52
1 files changed, 52 insertions, 0 deletions
diff --git a/wp-inst/wp-admin/admin-functions.php b/wp-inst/wp-admin/admin-functions.php
index f648f5e..55e4ea1 100644
--- a/wp-inst/wp-admin/admin-functions.php
+++ b/wp-inst/wp-admin/admin-functions.php
@@ -60,9 +60,21 @@ function write_post() {
$post_ID = wp_insert_post($_POST);
add_meta($post_ID);
+ // Reunite any orphaned subposts with their parent
+ if ( $_POST['temp_ID'] )
+ relocate_children($_POST['temp_ID'], $post_ID);
+
return $post_ID;
}
+// Move child posts to a new parent
+function relocate_children($old_ID, $new_ID) {
+ global $wpdb;
+ $old_ID = (int) $old_ID;
+ $new_ID = (int) $new_ID;
+ return $wpdb->query("UPDATE $wpdb->posts SET post_parent = $new_ID WHERE post_parent = $old_ID");
+}
+
// Update an existing post with values provided in $_POST.
function edit_post() {
global $user_ID;
@@ -1742,6 +1754,46 @@ function current_theme_info() {
return $ct;
}
+// Returns an array containing the current upload directory's path and url, or an error message.
+function wp_upload_dir() {
+ if ( defined('UPLOADS') )
+ $dir = UPLOADS;
+ else
+ $dir = 'wp-content/uploads';
+
+ $path = ABSPATH . $dir;
+
+ // Make sure we have an uploads dir
+ if ( ! file_exists( $path ) ) {
+ if ( ! mkdir( $path ) )
+ return array('error' => "Unable to create directory $path. Is its parent directory writable by the server?");
+ @ chmod( ABSPATH . $path, 0774 );
+ }
+
+ // Generate the yearly and monthly dirs
+ $time = current_time( 'mysql' );
+ $y = substr( $time, 0, 4 );
+ $m = substr( $time, 5, 2 );
+ $pathy = "$path/$y";
+ $pathym = "$path/$y/$m";
+
+ // Make sure we have a yearly dir
+ if ( ! file_exists( $pathy ) ) {
+ if ( ! mkdir( $pathy ) )
+ return array('error' => "Unable to create directory $pathy. Is $path writable?");
+ @ chmod( $pathy, 0774 );
+ }
+
+ // Make sure we have a monthly dir
+ if ( ! file_exists( $pathym ) ) {
+ if ( ! mkdir( $pathym ) )
+ return array('error' => "Unable to create directory $pathym. Is $pathy writable?");
+ @ chmod( $pathym, 0774 );
+ }
+
+ $uploads = array('path' => $pathym, 'url' => get_bloginfo('home') . "/$dir/$y/$m", 'error' => false);
+ return apply_filters('upload_dir', $uploads);
+}
function AJAX_search_box( $get_url, $search_field = 'newvalue', $search_results_field = 'searchresults' ) {
?>
<script language="JavaScript">