Changeset 15688 for trunk/wp-includes/post.php
- Timestamp:
- 10/03/2010 02:58:59 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post.php
r15635 r15688 2075 2075 $post = get_post($postid, $mode); 2076 2076 2077 if ( 2077 if ( 2078 2078 ( OBJECT == $mode && empty( $post->ID ) ) || 2079 2079 ( OBJECT != $mode && empty( $post['ID'] ) ) … … 4714 4714 } 4715 4715 } 4716 4717 4718 /** 4719 * Default post information to use when populating the "Write Post" form. 4720 * 4721 * @since unknown 4722 * 4723 *@param string A post type string, defaults to 'post'. 4724 * @return object stdClass object containing all the default post data as attributes 4725 */ 4726 function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) { 4727 global $wpdb; 4728 4729 $post_title = ''; 4730 if ( !empty( $_REQUEST['post_title'] ) ) 4731 $post_title = esc_html( stripslashes( $_REQUEST['post_title'] )); 4732 4733 $post_content = ''; 4734 if ( !empty( $_REQUEST['content'] ) ) 4735 $post_content = esc_html( stripslashes( $_REQUEST['content'] )); 4736 4737 $post_excerpt = ''; 4738 if ( !empty( $_REQUEST['excerpt'] ) ) 4739 $post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] )); 4740 4741 if ( $create_in_db ) { 4742 // Cleanup old auto-drafts more than 7 days old 4743 $old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" ); 4744 foreach ( (array) $old_posts as $delete ) 4745 wp_delete_post( $delete, true ); // Force delete 4746 $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ); 4747 $post = get_post( $post_id ); 4748 } else { 4749 $post->ID = 0; 4750 $post->post_author = ''; 4751 $post->post_date = ''; 4752 $post->post_date_gmt = ''; 4753 $post->post_password = ''; 4754 $post->post_type = $post_type; 4755 $post->post_status = 'draft'; 4756 $post->to_ping = ''; 4757 $post->pinged = ''; 4758 $post->comment_status = get_option( 'default_comment_status' ); 4759 $post->ping_status = get_option( 'default_ping_status' ); 4760 $post->post_pingback = get_option( 'default_pingback_flag' ); 4761 $post->post_category = get_option( 'default_category' ); 4762 $post->page_template = 'default'; 4763 $post->post_parent = 0; 4764 $post->menu_order = 0; 4765 } 4766 4767 $post->post_content = apply_filters( 'default_content', $post_content, $post ); 4768 $post->post_title = apply_filters( 'default_title', $post_title, $post ); 4769 $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post ); 4770 $post->post_name = ''; 4771 4772 return $post; 4773 }
Note: See TracChangeset
for help on using the changeset viewer.