From 69b3167678fd78d95b407b93109b98e05ed5635b Mon Sep 17 00:00:00 2001 From: nacin Date: Mon, 22 Nov 2010 17:17:26 +0000 Subject: [PATCH] Revert [15688], [15689], [15691]. Try again in 3.2. see #14966. git-svn-id: http://svn.automattic.com/wordpress/trunk@16535 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/media.php | 49 ++++++++ wp-admin/includes/post.php | 55 +++++++++ wp-admin/includes/taxonomy.php | 42 +++++++ wp-includes/media.php | 75 +----------- wp-includes/post.php | 202 +-------------------------------- wp-includes/taxonomy.php | 43 ------- 6 files changed, 148 insertions(+), 318 deletions(-) diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 408854e70..100e97386 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -349,6 +349,55 @@ if ( is_string($content_func) ) $title"; +} + +function get_upload_iframe_src($type) { + global $post_ID, $temp_ID; + $uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID); + $upload_iframe_src = add_query_arg('post_id', $uploading_iframe_ID, 'media-upload.php'); + + if ( 'media' != $type ) + $upload_iframe_src = add_query_arg('type', $type, $upload_iframe_src); + $upload_iframe_src = apply_filters($type . '_upload_iframe_src', $upload_iframe_src); + + return add_query_arg('TB_iframe', true, $upload_iframe_src); +} + /** * {@internal Missing Short Description}} * diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index 301642657..19b7d636e 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -361,7 +361,62 @@ function bulk_edit_posts( $post_data = null ) { return array( 'updated' => $updated, 'skipped' => $skipped, 'locked' => $locked ); } +/** + * Default post information to use when populating the "Write Post" form. + * + * @since unknown + * + * @param string $post_type A post type string, defaults to 'post'. + * @return object stdClass object containing all the default post data as attributes + */ +function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) { + global $wpdb; + $post_title = ''; + if ( !empty( $_REQUEST['post_title'] ) ) + $post_title = esc_html( stripslashes( $_REQUEST['post_title'] )); + + $post_content = ''; + if ( !empty( $_REQUEST['content'] ) ) + $post_content = esc_html( stripslashes( $_REQUEST['content'] )); + + $post_excerpt = ''; + if ( !empty( $_REQUEST['excerpt'] ) ) + $post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] )); + + if ( $create_in_db ) { + // Cleanup old auto-drafts more than 7 days old + $old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" ); + foreach ( (array) $old_posts as $delete ) + wp_delete_post( $delete, true ); // Force delete + $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ); + $post = get_post( $post_id ); + } else { + $post->ID = 0; + $post->post_author = ''; + $post->post_date = ''; + $post->post_date_gmt = ''; + $post->post_password = ''; + $post->post_type = $post_type; + $post->post_status = 'draft'; + $post->to_ping = ''; + $post->pinged = ''; + $post->comment_status = get_option( 'default_comment_status' ); + $post->ping_status = get_option( 'default_ping_status' ); + $post->post_pingback = get_option( 'default_pingback_flag' ); + $post->post_category = get_option( 'default_category' ); + $post->page_template = 'default'; + $post->post_parent = 0; + $post->menu_order = 0; + } + + $post->post_content = apply_filters( 'default_content', $post_content, $post ); + $post->post_title = apply_filters( 'default_title', $post_title, $post ); + $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post ); + $post->post_name = ''; + + return $post; +} /** * Get the default page information to use. diff --git a/wp-admin/includes/taxonomy.php b/wp-admin/includes/taxonomy.php index a47793b1e..b063897da 100644 --- a/wp-admin/includes/taxonomy.php +++ b/wp-admin/includes/taxonomy.php @@ -194,6 +194,48 @@ function wp_create_tag($tag_name) { return wp_create_term( $tag_name, 'post_tag'); } +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $post_id + * @return unknown + */ +function get_tags_to_edit( $post_id, $taxonomy = 'post_tag' ) { + return get_terms_to_edit( $post_id, $taxonomy); +} + +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $post_id + * @return unknown + */ +function get_terms_to_edit( $post_id, $taxonomy = 'post_tag' ) { + $post_id = (int) $post_id; + if ( !$post_id ) + return false; + + $tags = wp_get_post_terms($post_id, $taxonomy, array()); + + if ( !$tags ) + return false; + + if ( is_wp_error($tags) ) + return $tags; + + foreach ( $tags as $tag ) + $tag_names[] = $tag->name; + $tags_to_edit = join( ',', $tag_names ); + $tags_to_edit = esc_attr( $tags_to_edit ); + $tags_to_edit = apply_filters( 'terms_to_edit', $tags_to_edit, $taxonomy ); + + return $tags_to_edit; +} + /** * {@internal Missing Short Description}} * diff --git a/wp-includes/media.php b/wp-includes/media.php index d8e00888f..c471518ee 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -1396,77 +1396,4 @@ function wp_oembed_add_provider( $format, $provider, $regex = false ) { require_once( ABSPATH . WPINC . '/class-oembed.php' ); $oembed = _wp_oembed_get_object(); $oembed->providers[$format] = array( $provider, $regex ); -} - -/** - * Generate HTML for the editor media buttons (image, video, audio). - * - * @since 3.1.0 - * - * @return string HTML - */ -function get_media_buttons() { - $do_image = $do_audio = $do_video = true; - if ( is_multisite() ) { - $media_buttons = get_site_option( 'mu_media_buttons' ); - if ( empty( $media_buttons['image'] ) ) - $do_image = false; - if ( empty( $media_buttons['audio'] ) ) - $do_audio = false; - if ( empty( $media_buttons['video'] ) ) - $do_video = false; - } - $out = ''; - - if ( $do_image ) - $out .= _media_button( __( 'Add an Image' ), 'images/media-button-image.gif?ver=20100531', 'image' ); - if ( $do_video ) - $out .= _media_button( __( 'Add Video' ), 'images/media-button-video.gif?ver=20100531', 'video' ); - if ( $do_audio ) - $out .= _media_button( __( 'Add Audio' ), 'images/media-button-music.gif?ver=20100531', 'audio' ); - - $out .= _media_button( __( 'Add Media' ), 'images/media-button-other.gif?ver=20100531', 'media' ); - - $context = apply_filters( 'media_buttons_context', __( 'Upload/Insert: %s' ) ); - - return sprintf($context, $out); - - -} - -/** - * {@internal Missing Short Description}} - * - * @since unknown - */ -function media_buttons() { - echo get_media_buttons(); -} -add_action( 'media_buttons', 'media_buttons' ); - -/** - * {@internal Missing Short Description}} - * - * @since unknown - * @access private - */ -function _media_button( $title, $icon, $type ) { - return "$title"; -} - -/** - * {@internal Missing Short Description}} - * - * @since unknown - */ -function get_upload_iframe_src( $type ) { - global $post_ID, $temp_ID; - $uploading_iframe_ID = (int) ( 0 == $post_ID ? $temp_ID : $post_ID ); - $upload_iframe_src = add_query_arg( 'post_id', $uploading_iframe_ID, 'media-upload.php' ); - - if ( 'media' != $type ) - $upload_iframe_src = add_query_arg( 'type', $type, $upload_iframe_src ); - $upload_iframe_src = apply_filters( $type . '_upload_iframe_src', $upload_iframe_src ); - - return add_query_arg( 'TB_iframe', true, $upload_iframe_src ); -} +} \ No newline at end of file diff --git a/wp-includes/post.php b/wp-includes/post.php index 66fbb0290..c76988fb6 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -2317,7 +2317,7 @@ function wp_get_single_post($postid = 0, $mode = OBJECT) { $post = get_post($postid, $mode); - if ( + if ( ( OBJECT == $mode && empty( $post->ID ) ) || ( OBJECT != $mode && empty( $post['ID'] ) ) ) @@ -5037,206 +5037,6 @@ function wp_check_post_hierarchy_for_loops( $post_parent, $post_ID ) { return $post_parent; } -/** - * Default post information to use when populating the "Write Post" form. - * - * @since 2.0.0 - * - * @param string $post_type A post type string, defaults to 'post'. - * @param bool $create_in_db If true then also insert an auto-draft into database - * @return object stdClass object containing all the default post data as attributes - */ -function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) { - global $wpdb; - - $post_title = ''; - if ( !empty( $_REQUEST['post_title'] ) ) - $post_title = esc_html( stripslashes( $_REQUEST['post_title'] )); - - $post_content = ''; - if ( !empty( $_REQUEST['content'] ) ) - $post_content = esc_html( stripslashes( $_REQUEST['content'] )); - - $post_excerpt = ''; - if ( !empty( $_REQUEST['excerpt'] ) ) - $post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] )); - - if ( $create_in_db ) { - // Cleanup old auto-drafts more than 7 days old - $old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" ); - foreach ( (array) $old_posts as $delete ) - wp_delete_post( $delete, true ); // Force delete - $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ); - $post = get_post( $post_id ); - } else { - $post->ID = 0; - $post->post_author = ''; - $post->post_date = ''; - $post->post_date_gmt = ''; - $post->post_password = ''; - $post->post_type = $post_type; - $post->post_status = 'draft'; - $post->to_ping = ''; - $post->pinged = ''; - $post->comment_status = get_option( 'default_comment_status' ); - $post->ping_status = get_option( 'default_ping_status' ); - $post->post_pingback = get_option( 'default_pingback_flag' ); - $post->post_category = get_option( 'default_category' ); - $post->page_template = 'default'; - $post->post_parent = 0; - $post->menu_order = 0; - } - - $post->post_content = apply_filters( 'default_content', $post_content, $post ); - $post->post_title = apply_filters( 'default_title', $post_title, $post ); - $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post ); - $post->post_name = ''; - - return $post; -} - -/** - * Returns or echos a form containing a post box. - * - * Used for the QuickPress dashboard module. - * - * @since 3.1.0 - * - * @param array $args Arguments. - * @param string $post_type Post type. - */ -function wp_quickpress_form( $args = array(), $post_type = 'post'){ - global $post_ID; - - $fields = array( - 'title' => array( - 'capability' => '', // Capability to check before outputing field - 'output' => '

-
- -
' - ), - 'media_buttons' => array( - 'capability' => 'upload_files', - 'output' => '
'. get_media_buttons() .'
', - ), - 'content' => array( - 'capability' => '', - 'output' => '

-
- -
- '." - " - - ), - 'tags' => array( - 'capability' =>'', - 'output' => ' -

-
- -
-' - ), - - ); - - $hidden_fields = array( - 'action' => '', - 'post_id' => '', - 'post_type' => '', - ); - - $submit_fields = array( - 'save' => '', - 'reset' => '', - ); - - $publishing_action = current_user_can('publish_posts') ? esc_attr('Publish') : esc_attr('Submit for Review'); - - $publishing_fields = array( - 'submit' => '', - /*'test' => '', */ - - ); - - $defaults = array( - 'action' => admin_url( 'post.php' ), - 'fields' => $fields, - 'form_id' => '', - 'default_cap' => 'edit_posts', - 'tabindex_start' => '1', - 'ajax' => true, - 'hidden_fields' => $hidden_fields, - 'submit_fields' => $submit_fields, - 'publishing_fields' => $publishing_fields, - 'submit_class' => 'submit', - 'publish_action_container' => 'span', - 'publish_action_id' => 'publishing-action', - 'hidden_and_submit_fields_container' => 'p', - 'hidden_and_submit_fields_container_class' => 'submit', - ); - - $args = wp_parse_args($args, $defaults); - - $tabindex = apply_filters( 'quickpress_tabindex_start', $args['tabindex_start'], $args['form_id'] ); - - if ( current_user_can( $args['default_cap'] ) ): ?> - -
- $field){ - if ( empty( $field['capability'] ) || current_user_can( $field['capability'] ) ){ - printf( $field['output'], $args['form_id'], $args['form_id'], $tabindex ); - $tabindex++; - } - } - //Hidden Fields - do_action('quickpress_form_after_fields', $args['form_id'] ); - - echo "<{$args['hidden_and_submit_fields_container']} class='{$args['hidden_and_submit_fields_container_class']}'>"; - - $hidden_fields = apply_filters( 'quickpress_hidden_fields', $args['hidden_fields'] , $args['form_id'] ); - - foreach( $hidden_fields as $hidden_field ) - echo $hidden_field; - - // nonce - wp_nonce_field('add-post'); - - // submit - foreach( $args['submit_fields'] as $submit_field ) - printf( $submit_field, $tabindex++ ); - - // publish - echo "<{$args['publish_action_container']} id='{$args['publish_action_id']}'>"; - - $publishing_fields = apply_filters( 'quickpress_publishing_fields', $args['publishing_fields'] , $args['form_id'] ); - - foreach( $publishing_fields as $publishing_field) { - printf( $publishing_field, $tabindex ); - $tabindex++; - } - - if ($args['ajax'] == true) - echo ''; - - echo ""; - echo "
"; - do_action( 'quickpress_form_after_submit_fields', $args['form_id']); - - echo "'; - do_action('quickpress_form_after_form', $args['form_id'] ); - else: - do_action( 'quickpress_form_no_form', $args['form_id'] ); - endif; -} - /** * Returns an array of post format slugs to their translated and pretty display versions * diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index bb3e081c3..72badd7d3 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -2946,49 +2946,6 @@ function get_ancestors($object_id = 0, $object_type = '') { return apply_filters('get_ancestors', $ancestors, $object_id, $object_type); } - -/** - * {@internal Missing Short Description}} - * - * @since unknown - * - * @param unknown_type $post_id - * @return unknown - */ -function get_tags_to_edit( $post_id, $taxonomy = 'post_tag' ) { - return get_terms_to_edit( $post_id, $taxonomy); -} - -/** - * {@internal Missing Short Description}} - * - * @since unknown - * - * @param unknown_type $post_id - * @return unknown - */ -function get_terms_to_edit( $post_id, $taxonomy = 'post_tag' ) { - $post_id = (int) $post_id; - if ( !$post_id ) - return false; - - $tags = wp_get_post_terms($post_id, $taxonomy, array()); - - if ( !$tags ) - return false; - - if ( is_wp_error($tags) ) - return $tags; - - foreach ( $tags as $tag ) - $tag_names[] = $tag->name; - $tags_to_edit = join( ',', $tag_names ); - $tags_to_edit = esc_attr( $tags_to_edit ); - $tags_to_edit = apply_filters( 'terms_to_edit', $tags_to_edit, $taxonomy ); - - return $tags_to_edit; -} - /** * Returns the term's parent's term_ID *