Changeset 12987 for trunk/wp-admin/includes/post.php
- Timestamp:
- 02/06/2010 10:07:57 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/post.php
r12954 r12987 77 77 if ( isset( $post_data['ID'] ) ) 78 78 $post_id = $post_data['ID']; 79 elseif ( isset( $post_data['temp_ID'] ) )80 $post_id = $post_data['temp_ID'];81 79 else 82 80 $post_id = false; … … 337 335 * @return object stdClass object containing all the default post data as attributes 338 336 */ 339 function get_default_post_to_edit( $post_type = 'post' ) { 337 function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) { 338 global $wpdb; 340 339 341 340 $post_title = ''; … … 351 350 $post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] )); 352 351 353 $post->ID = 0; 352 if ( $create_in_db ) { 353 // Cleanup old auto-drafts more than 7 days old 354 $old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" ); 355 foreach ( (array) $old_posts as $delete ) 356 wp_delete_post( $delete, true ); // Force delete 357 $post = get_post( wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ) ); 358 } else { 359 $post->ID = 0; 360 $post->post_author = ''; 361 $post->post_date = ''; 362 $post->post_date_gmt = ''; 363 $post->post_password = ''; 364 $post->post_type = $post_type; 365 $post->post_status = 'draft'; 366 $post->to_ping = ''; 367 $post->pinged = ''; 368 $post->comment_status = get_option( 'default_comment_status' ); 369 $post->ping_status = get_option( 'default_ping_status' ); 370 $post->post_pingback = get_option( 'default_pingback_flag' ); 371 $post->post_category = get_option( 'default_category' ); 372 $post->page_template = 'default'; 373 $post->post_parent = 0; 374 $post->menu_order = 0; 375 } 376 377 $post->post_content = apply_filters( 'default_content', $post_content ); 378 $post->post_title = apply_filters( 'default_title', $post_title ); 379 $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt ); 354 380 $post->post_name = ''; 355 $post->post_author = '';356 $post->post_date = '';357 $post->post_date_gmt = '';358 $post->post_password = '';359 $post->post_status = 'draft';360 $post->post_type = $post_type;361 $post->to_ping = '';362 $post->pinged = '';363 $post->comment_status = get_option( 'default_comment_status' );364 $post->ping_status = get_option( 'default_ping_status' );365 $post->post_pingback = get_option( 'default_pingback_flag' );366 $post->post_category = get_option( 'default_category' );367 $post->post_content = apply_filters( 'default_content', $post_content);368 $post->post_title = apply_filters( 'default_title', $post_title );369 $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt);370 $post->page_template = 'default';371 $post->post_parent = 0;372 $post->menu_order = 0;373 381 374 382 return $post; … … 466 474 467 475 // Check for autosave collisions 476 // Does this need to be updated? ~ Mark 468 477 $temp_id = false; 469 478 if ( isset($_POST['temp_ID']) ) { … … 474 483 if ( time() + $temp > 86400 ) // 1 day: $temp is equal to -1 * time( then ) 475 484 unset($draft_ids[$temp]); 476 485 477 486 if ( isset($draft_ids[$temp_id]) ) { // Edit, don't write 478 487 $_POST['post_ID'] = $draft_ids[$temp_id]; … … 514 523 515 524 // Reunite any orphaned attachments with their parent 525 // Does this need to be udpated? ~ Mark 516 526 if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) ) 517 527 $draft_ids = array();
Note: See TracChangeset
for help on using the changeset viewer.