Make WordPress Core

Changeset 2921


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

Image uploading widget from skeltoac. fixes #1710

Location:
trunk
Files:
1 added
5 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?>
  • trunk/wp-admin/edit-form-advanced.php

    r2906 r2921  
    1818if (0 == $post_ID) {
    1919        $form_action = 'post';
     20        $temp_ID = -1 * time();
     21        $form_extra = "<input type='hidden' name='temp_ID' value='$temp_ID' />";
    2022} else {
    2123        $form_action = 'editpost';
    … …  
    173175<div id="advancedstuff" class="dbx-group" >
    174176
     177<fieldset id="imageuploading" class="dbx-box">
     178<h3 class="dbx-handle"><?php _e('Image Uploading') ?></h3>
     179<div class="dbx-content"><iframe src="image-uploading.php?action=view&amp;post=<?php echo 0 == $post_ID ? $temp_ID : $post_ID; ?>" id="imageup"></iframe></div>
     180</fieldset>
     181
    175182<fieldset id="postexcerpt" class="dbx-box">
    176183<h3 class="dbx-handle"><?php _e('Optional Excerpt') ?></h3>
  • trunk/wp-admin/upgrade-schema.php

    r2912 r2921  
    120120  guid varchar(255) NOT NULL default '',
    121121  menu_order int(11) NOT NULL default '0',
     122  post_type varchar(100) NOT NULL,
    122123  PRIMARY KEY  (ID),
    123124  KEY post_name (post_name)
  • trunk/wp-admin/wp-admin.css

    r2906 r2921  
    149149}
    150150
    151 textarea, input, select {
     151textarea, input, select, iframe#imageup {
    152152        background: #f4f4f4;
    153153        border: 1px solid #b2b2b2;
    … …  
    156156        margin: 1px;
    157157        padding: 3px;
     158}
     159
     160iframe#imageup {
     161        margin: 0px;
     162        padding: 0px;
     163        border: 1px solid #ccc;
     164        height: 13em;
     165        width: 98%;
    158166}
    159167
  • trunk/wp-includes/functions-post.php

    r2894 r2921  
    129129                $postquery =
    130130                        "INSERT INTO $wpdb->posts
    131                         (ID, post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt,  post_status, comment_status, ping_status, post_password, post_name, to_ping, post_modified, post_modified_gmt, post_parent, menu_order)
     131                        (ID, post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt,  post_status, comment_status, ping_status, post_password, post_name, to_ping, post_modified, post_modified_gmt, post_parent, menu_order, post_type)
    132132                        VALUES
    133                         ('$post_ID', '$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_title', '$post_excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$to_ping', '$post_date', '$post_date_gmt', '$post_parent', '$menu_order')";
     133                        ('$post_ID', '$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_title', '$post_excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$to_ping', '$post_date', '$post_date_gmt', '$post_parent', '$menu_order', '$post_type')";
    134134        }
    135135       
    … …  
    186186}
    187187
     188function wp_attach_object($object, $post_parent = 0) {
     189        global $wpdb, $user_ID;
     190       
     191        // Export array as variables
     192        extract($object);
     193
     194        // Get the basics.
     195        $post_content    = apply_filters('content_save_pre',   $post_content);
     196        $post_excerpt    = apply_filters('excerpt_save_pre',   $post_excerpt);
     197        $post_title      = apply_filters('title_save_pre',     $post_title);
     198        $post_category   = apply_filters('category_save_pre',  $post_category);
     199        $post_name       = apply_filters('name_save_pre',      $post_name);
     200        $comment_status  = apply_filters('comment_status_pre', $comment_status);
     201        $ping_status     = apply_filters('ping_status_pre',    $ping_status);
     202        $post_type       = apply_filters('post_type_pre',      $post_type);
     203
     204        // Make sure we set a valid category
     205        if (0 == count($post_category) || !is_array($post_category)) {
     206                $post_category = array(get_option('default_category'));
     207        }
     208        $post_cat = $post_category[0];
     209
     210        if ( empty($post_author) )
     211                $post_author = $user_ID;
     212
     213        $post_status = 'object';
     214
     215        // Get the post ID.
     216        if ( $update ) {
     217                $post_ID = $ID;
     218        } else {
     219                $id_result = $wpdb->get_row("SHOW TABLE STATUS LIKE '$wpdb->posts'");
     220                $post_ID = $id_result->Auto_increment;
     221        }
     222
     223        // Create a valid post name.
     224        if ( empty($post_name) ) {
     225                $post_name = sanitize_title($post_title, $post_ID);
     226        } else {
     227                $post_name = sanitize_title($post_name, $post_ID);
     228        }
     229       
     230        if (empty($post_date))
     231                $post_date = current_time('mysql');
     232        if (empty($post_date_gmt))
     233                $post_date_gmt = current_time('mysql', 1);
     234
     235        if ( empty($comment_status) ) {
     236                if ( $update )
     237                        $comment_status = 'closed';
     238                else
     239                        $comment_status = get_settings('default_comment_status');
     240        }
     241        if ( empty($ping_status) )
     242                $ping_status = get_settings('default_ping_status');
     243        if ( empty($post_pingback) )
     244                $post_pingback = get_option('default_pingback_flag');
     245
     246        if ( isset($to_ping) )
     247                $to_ping = preg_replace('|\s+|', "\n", $to_ping);
     248        else
     249                $to_ping = '';
     250       
     251        $post_parent = (int) $post_parent;
     252
     253        if ( isset($menu_order) )
     254                $menu_order = (int) $menu_order;
     255        else
     256                $menu_order = 0;
     257
     258        if ( !isset($post_password) )
     259                $post_password = '';
     260
     261        if ($update) {
     262                $postquery =
     263                        "UPDATE $wpdb->posts SET
     264                        post_author = '$post_author',
     265                        post_date = '$post_date',
     266                        post_date_gmt = '$post_date_gmt',
     267                        post_content = '$post_content',
     268                        post_title = '$post_title',
     269                        post_excerpt = '$post_excerpt',
     270                        post_status = '$post_status',
     271                        comment_status = '$comment_status',
     272                        ping_status = '$ping_status',
     273                        post_password = '$post_password',
     274                        post_name = '$post_name',
     275                        to_ping = '$to_ping',
     276                        post_modified = '$post_date',
     277                        post_modified_gmt = '$post_date_gmt',
     278                        post_parent = '$post_parent',
     279                        menu_order = '$menu_order',
     280                        post_type = '$post_type',
     281                        guid = '$guid'
     282                        WHERE ID = $post_ID";
     283        } else {
     284                $postquery =
     285                        "INSERT INTO $wpdb->posts
     286                        (ID, post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt,  post_status, comment_status, ping_status, post_password, post_name, to_ping, post_modified, post_modified_gmt, post_parent, menu_order, post_type, guid)
     287                        VALUES
     288                        ('$post_ID', '$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_title', '$post_excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$to_ping', '$post_date', '$post_date_gmt', '$post_parent', '$menu_order', '$post_type', '$guid')";
     289        }
     290       
     291        $result = $wpdb->query($postquery);
     292
     293        wp_set_post_cats('', $post_ID, $post_category);
     294
     295        clean_post_cache($post_ID);
     296
     297        if ( $update) {
     298                do_action('edit_object', $post_ID);
     299        } else {
     300                do_action('attach_object', $post_ID);
     301        }
     302       
     303        return $post_ID;
     304}
     305
    188306function wp_get_single_post($postid = 0, $mode = OBJECT) {
    189307        global $wpdb;
Note: See TracChangeset for help on using the changeset viewer.