Make WordPress Core


Ignore:
Timestamp:
09/26/2005 11:55:36 PM (20 years ago)
Author:
ryan
Message:

Image uploading widget from skeltoac. fixes #1710

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-functions.php

    r2901 r2921  
    6161    add_meta($post_ID);
    6262
     63    // Reunite any orphaned subposts with their parent
     64    if ( $_POST['temp_ID'] )
     65        relocate_children($_POST['temp_ID'], $post_ID);
     66
    6367    return $post_ID;
     68}
     69
     70// Move child posts to a new parent
     71function relocate_children($old_ID, $new_ID) {
     72    global $wpdb;
     73    $wpdb->query("UPDATE $wpdb->posts SET post_parent = $new_ID WHERE post_parent = $old_ID");
    6474}
    6575
     
    17401750    return $ct;
    17411751}
     1752
     1753// Returns an array containing the current upload directory's path and url, or an error message.
     1754function wp_upload_dir() {
     1755        if ( defined('UPLOADS') )
     1756                $dir = UPLOADS;
     1757        else
     1758                $dir = 'wp-content/uploads';
     1759
     1760    $path = ABSPATH . $dir;
     1761
     1762        // Make sure we have an uploads dir
     1763        if ( ! file_exists( $path ) ) {
     1764                if ( ! mkdir( $path ) )
     1765                        return array('error' => "Unable to create directory $path. Is its parent directory writable by the server?");
     1766        @ chmod( ABSPATH . $path, 0774 );
     1767    }
     1768
     1769        // Generate the yearly and monthly dirs
     1770        $time = current_time( 'mysql' );
     1771        $y = substr( $time, 0, 4 );
     1772        $m = substr( $time, 5, 2 );
     1773        $pathy = "$path/$y";
     1774        $pathym = "$path/$y/$m";
     1775
     1776        // Make sure we have a yearly dir
     1777        if ( ! file_exists( $pathy ) ) {
     1778                if ( ! mkdir( $pathy ) )
     1779                        return array('error' => "Unable to create directory $pathy. Is $path writable?");
     1780        @ chmod( $pathy, 0774 );
     1781    }
     1782
     1783        // Make sure we have a monthly dir
     1784        if ( ! file_exists( $pathym ) ) {
     1785                if ( ! mkdir( $pathym ) )
     1786                        return array('error' => "Unable to create directory $pathym. Is $pathy writable?");
     1787        @ chmod( $pathym, 0774 );
     1788    }
     1789
     1790        $uploads = array('path' => $pathym, 'url' => get_bloginfo('home') . "/$dir/$y/$m", 'error' => false);
     1791    return apply_filters('upload_dir', $uploads);
     1792}
     1793
    17421794?>
Note: See TracChangeset for help on using the changeset viewer.