Make WordPress Core

Changeset 4082


Ignore:
Timestamp:
08/11/2006 03:54:45 AM (18 years ago)
Author:
ryan
Message:

Autosave and prototype. Props masquerade. fixes #3020 #3017

Location:
trunk
Files:
2 added
7 edited

Legend:

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

    r4042 r4082  
    217217    die($r);
    218218    break;
     219case 'autosave' :
     220    $_POST['post_content'] = $_POST['content'];
     221    $_POST['post_excerpt'] = $_POST['excerpt'];
     222    $_POST['post_status'] = 'draft';
     223    $_POST['post_category'] = explode(",", $_POST['catslist']);
     224    if($_POST['post_type'] == 'page' || empty($_POST['post_category']))
     225        unset($_POST['post_category']);
     226   
     227    if($_POST['post_ID'] < 0) {
     228        $_POST['temp_ID'] = $_POST['post_ID'];
     229        $id = wp_write_post();
     230        if(is_wp_error($id))
     231            die($id->get_error_message());
     232        else
     233            die("$id");
     234    } else {
     235        $post_ID = (int) $_POST['post_ID'];
     236        $_POST['ID'] = $post_ID;
     237        $post = get_post($post_ID);
     238        if ( 'page' == $post->post_type ) {
     239            if ( !current_user_can('edit_page', $post_ID) )
     240                die(__('You are not allowed to edit this page.'));
     241        } else {
     242            if ( !current_user_can('edit_post', $post_ID) )
     243                die(__('You are not allowed to edit this post.'));
     244        }
     245        wp_update_post($_POST);
     246    }
     247    die('0');
     248break;
    219249default :
    220250    do_action( 'wp_ajax_' . $_POST['action'] );
  • trunk/wp-admin/admin-functions.php

    r4049 r4082  
    11<?php
    22
     3function write_post() {
     4    $result = wp_write_post();
     5    if( is_wp_error($result) )
     6        wp_die( $result->get_error_message() );
     7    else
     8        return $result;
     9}
     10
    311// Creates a new post from the "Write Post" form using $_POST information.
    4 function write_post() {
     12function wp_write_post() {
    513    global $user_ID;
    614
    715    if ( 'page' == $_POST['post_type'] ) {
    816        if ( !current_user_can('edit_pages') )
    9             wp_die(__('You are not allowed to create pages on this blog.'));
     17            return new WP_Error('edit_pages', __('You are not allowed to create pages on this blog.'));
    1018    } else {
    1119        if ( !current_user_can('edit_posts') )
    12             wp_die(__('You are not allowed to create posts or drafts on this blog.'));
     20            return new WP_Error('edit_posts', __('You are not allowed to create posts or drafts on this blog.'));
    1321    }
    1422
     
    3341        if ( 'page' == $_POST['post_type'] ) {
    3442            if ( !current_user_can('edit_others_pages') )
    35                 wp_die(__('You cannot create pages as this user.'));
     43                return new WP_Error('edit_others_pages', __('You cannot create pages as this user.'));
    3644        } else {
    3745            if ( !current_user_can('edit_others_posts') )
    38                 wp_die(__('You cannot post as this user.'));
     46                return new WP_Error('edit_others_posts', __('You cannot post as this user.'));
    3947
    4048        }
  • trunk/wp-admin/page-new.php

    r3726 r4082  
    44$parent_file = 'post-new.php';
    55$editing = true;
     6wp_enqueue_script('prototype');
     7wp_enqueue_script('autosave');
    68require_once('admin-header.php');
    79?>
  • trunk/wp-admin/page.php

    r3985 r4082  
    4343    $title = __('Edit');
    4444    $editing = true;
     45    $page_ID = $post_ID = $p = (int) $_GET['post'];
     46    $post = get_post_to_edit($page_ID);
     47    if($post->post_status == 'draft') {
     48        wp_enqueue_script('prototype');
     49        wp_enqueue_script('autosave');
     50    }
    4551    require_once('admin-header.php');
    46 
    47     $page_ID = $post_ID = $p = (int) $_GET['post'];
    4852
    4953    if ( !current_user_can('edit_page', $page_ID) )
    5054        die ( __('You are not allowed to edit this page.') );
    51 
    52     $post = get_post_to_edit($page_ID);
    5355
    5456    include('edit-page-form.php');
  • trunk/wp-admin/post-new.php

    r3685 r4082  
    44$parent_file = 'post-new.php';
    55$editing = true;
     6wp_enqueue_script('prototype');
     7wp_enqueue_script('autosave');
    68require_once ('./admin-header.php');
    79
  • trunk/wp-admin/post.php

    r4059 r4082  
    4646    $title = __('Edit');
    4747    $editing = true;
     48    $post_ID = $p = (int) $_GET['post'];
     49    $post = get_post($post_ID);
     50    if($post->post_status == 'draft') {
     51        wp_enqueue_script('prototype');
     52        wp_enqueue_script('autosave');
     53    }
    4854    require_once('admin-header.php');
    4955
    50     $post_ID = $p = (int) $_GET['post'];
    51 
    52     $post = get_post($post_ID);
    5356    if ( !current_user_can('edit_post', $post_ID) )
    5457        die ( __('You are not allowed to edit this post.') );
  • trunk/wp-includes/script-loader.php

    r4042 r4082  
    1818        $this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_gzip.php', false, '04162006' );
    1919        $this->add( 'wp_tiny_mce', '/wp-includes/js/tinymce/tiny_mce_config.php', array('tiny_mce'), '04162006' );
     20        $this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.5.0');
     21        $this->add( 'autosave', '/wp-includes/js/autosave.js.php', array('prototype', 'sack'), '4080');
    2022        if ( is_admin() ) {
    2123            $this->add( 'dbx-admin-key', '/wp-admin/dbx-admin-key-js.php', array('dbx'), '3651' );
Note: See TracChangeset for help on using the changeset viewer.