Changeset 15688 for trunk/wp-admin/includes/post.php
- Timestamp:
- 10/03/2010 02:58:59 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/post.php
r15683 r15688 349 349 } 350 350 351 /** 352 * Default post information to use when populating the "Write Post" form. 353 * 354 * @since unknown 355 * 356 * @param string $post_type A post type string, defaults to 'post'. 357 * @return object stdClass object containing all the default post data as attributes 358 */ 359 function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) { 360 global $wpdb; 361 362 $post_title = ''; 363 if ( !empty( $_REQUEST['post_title'] ) ) 364 $post_title = esc_html( stripslashes( $_REQUEST['post_title'] )); 365 366 $post_content = ''; 367 if ( !empty( $_REQUEST['content'] ) ) 368 $post_content = esc_html( stripslashes( $_REQUEST['content'] )); 369 370 $post_excerpt = ''; 371 if ( !empty( $_REQUEST['excerpt'] ) ) 372 $post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] )); 373 374 if ( $create_in_db ) { 375 // Cleanup old auto-drafts more than 7 days old 376 $old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" ); 377 foreach ( (array) $old_posts as $delete ) 378 wp_delete_post( $delete, true ); // Force delete 379 $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ); 380 $post = get_post( $post_id ); 381 } else { 382 $post->ID = 0; 383 $post->post_author = ''; 384 $post->post_date = ''; 385 $post->post_date_gmt = ''; 386 $post->post_password = ''; 387 $post->post_type = $post_type; 388 $post->post_status = 'draft'; 389 $post->to_ping = ''; 390 $post->pinged = ''; 391 $post->comment_status = get_option( 'default_comment_status' ); 392 $post->ping_status = get_option( 'default_ping_status' ); 393 $post->post_pingback = get_option( 'default_pingback_flag' ); 394 $post->post_category = get_option( 'default_category' ); 395 $post->page_template = 'default'; 396 $post->post_parent = 0; 397 $post->menu_order = 0; 398 } 399 400 $post->post_content = apply_filters( 'default_content', $post_content, $post ); 401 $post->post_title = apply_filters( 'default_title', $post_title, $post ); 402 $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post ); 403 $post->post_name = ''; 404 405 return $post; 406 } 351 407 352 408 353 /**
Note: See TracChangeset
for help on using the changeset viewer.