WordPress.org

Make WordPress Core

Changeset 16535


Ignore:
Timestamp:
11/22/2010 05:17:26 PM (9 years ago)
Author:
nacin
Message:

Revert [15688], [15689], [15691]. Try again in 3.2. see #14966.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/media.php

    r16476 r16535  
    348348</html>
    349349<?php
     350}
     351
     352/**
     353 * {@internal Missing Short Description}}
     354 *
     355 * @since unknown
     356 */
     357function media_buttons() {
     358    $do_image = $do_audio = $do_video = true;
     359    if ( is_multisite() ) {
     360        $media_buttons = get_site_option( 'mu_media_buttons' );
     361        if ( empty($media_buttons['image']) )
     362            $do_image = false;
     363        if ( empty($media_buttons['audio']) )
     364            $do_audio = false;
     365        if ( empty($media_buttons['video']) )
     366            $do_video = false;
     367    }
     368    $out = '';
     369
     370    if ( $do_image )
     371        $out .= _media_button(__('Add an Image'), 'images/media-button-image.gif?ver=20100531', 'image');
     372    if ( $do_video )
     373        $out .= _media_button(__('Add Video'), 'images/media-button-video.gif?ver=20100531', 'video');
     374    if ( $do_audio )
     375        $out .= _media_button(__('Add Audio'), 'images/media-button-music.gif?ver=20100531', 'audio');
     376
     377    $out .= _media_button(__('Add Media'), 'images/media-button-other.gif?ver=20100531', 'media');
     378
     379    $context = apply_filters('media_buttons_context', __('Upload/Insert %s'));
     380
     381    printf($context, $out);
     382}
     383add_action( 'media_buttons', 'media_buttons' );
     384
     385function _media_button($title, $icon, $type) {
     386    return "<a href='" . esc_url( get_upload_iframe_src($type) ) . "' id='add_$type' class='thickbox' title='$title'><img src='" . esc_url( admin_url( $icon ) ) . "' alt='$title' /></a>";
     387}
     388
     389function get_upload_iframe_src($type) {
     390    global $post_ID, $temp_ID;
     391    $uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID);
     392    $upload_iframe_src = add_query_arg('post_id', $uploading_iframe_ID, 'media-upload.php');
     393
     394    if ( 'media' != $type )
     395        $upload_iframe_src = add_query_arg('type', $type, $upload_iframe_src);
     396    $upload_iframe_src = apply_filters($type . '_upload_iframe_src', $upload_iframe_src);
     397
     398    return add_query_arg('TB_iframe', true, $upload_iframe_src);
    350399}
    351400
  • trunk/wp-admin/includes/post.php

    r16459 r16535  
    362362}
    363363
    364 
     364/**
     365 * Default post information to use when populating the "Write Post" form.
     366 *
     367 * @since unknown
     368 *
     369 * @param string $post_type A post type string, defaults to 'post'.
     370 * @return object stdClass object containing all the default post data as attributes
     371 */
     372function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) {
     373    global $wpdb;
     374
     375    $post_title = '';
     376    if ( !empty( $_REQUEST['post_title'] ) )
     377        $post_title = esc_html( stripslashes( $_REQUEST['post_title'] ));
     378
     379    $post_content = '';
     380    if ( !empty( $_REQUEST['content'] ) )
     381        $post_content = esc_html( stripslashes( $_REQUEST['content'] ));
     382
     383    $post_excerpt = '';
     384    if ( !empty( $_REQUEST['excerpt'] ) )
     385        $post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] ));
     386
     387    if ( $create_in_db ) {
     388        // Cleanup old auto-drafts more than 7 days old
     389        $old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" );
     390        foreach ( (array) $old_posts as $delete )
     391            wp_delete_post( $delete, true ); // Force delete
     392        $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) );
     393        $post = get_post( $post_id );
     394    } else {
     395        $post->ID = 0;
     396        $post->post_author = '';
     397        $post->post_date = '';
     398        $post->post_date_gmt = '';
     399        $post->post_password = '';
     400        $post->post_type = $post_type;
     401        $post->post_status = 'draft';
     402        $post->to_ping = '';
     403        $post->pinged = '';
     404        $post->comment_status = get_option( 'default_comment_status' );
     405        $post->ping_status = get_option( 'default_ping_status' );
     406        $post->post_pingback = get_option( 'default_pingback_flag' );
     407        $post->post_category = get_option( 'default_category' );
     408        $post->page_template = 'default';
     409        $post->post_parent = 0;
     410        $post->menu_order = 0;
     411    }
     412
     413    $post->post_content = apply_filters( 'default_content', $post_content, $post );
     414    $post->post_title   = apply_filters( 'default_title',   $post_title, $post   );
     415    $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post );
     416    $post->post_name = '';
     417
     418    return $post;
     419}
    365420
    366421/**
  • trunk/wp-admin/includes/taxonomy.php

    r15690 r16535  
    200200 * @since unknown
    201201 *
     202 * @param unknown_type $post_id
     203 * @return unknown
     204 */
     205function get_tags_to_edit( $post_id, $taxonomy = 'post_tag' ) {
     206    return get_terms_to_edit( $post_id, $taxonomy);
     207}
     208
     209/**
     210 * {@internal Missing Short Description}}
     211 *
     212 * @since unknown
     213 *
     214 * @param unknown_type $post_id
     215 * @return unknown
     216 */
     217function get_terms_to_edit( $post_id, $taxonomy = 'post_tag' ) {
     218    $post_id = (int) $post_id;
     219    if ( !$post_id )
     220        return false;
     221
     222    $tags = wp_get_post_terms($post_id, $taxonomy, array());
     223
     224    if ( !$tags )
     225        return false;
     226
     227    if ( is_wp_error($tags) )
     228        return $tags;
     229
     230    foreach ( $tags as $tag )
     231        $tag_names[] = $tag->name;
     232    $tags_to_edit = join( ',', $tag_names );
     233    $tags_to_edit = esc_attr( $tags_to_edit );
     234    $tags_to_edit = apply_filters( 'terms_to_edit', $tags_to_edit, $taxonomy );
     235
     236    return $tags_to_edit;
     237}
     238
     239/**
     240 * {@internal Missing Short Description}}
     241 *
     242 * @since unknown
     243 *
    202244 * @param unknown_type $tag_name
    203245 * @return unknown
  • trunk/wp-includes/media.php

    r16358 r16535  
    13981398    $oembed->providers[$format] = array( $provider, $regex );
    13991399}
    1400 
    1401 /**
    1402  * Generate HTML for the editor media buttons (image, video, audio).
    1403  *
    1404  * @since 3.1.0
    1405  *
    1406  * @return string HTML
    1407  */
    1408 function get_media_buttons() {
    1409     $do_image = $do_audio = $do_video = true;
    1410     if ( is_multisite() ) {
    1411         $media_buttons = get_site_option( 'mu_media_buttons' );
    1412         if ( empty( $media_buttons['image'] ) )
    1413             $do_image = false;
    1414         if ( empty( $media_buttons['audio'] ) )
    1415             $do_audio = false;
    1416         if ( empty( $media_buttons['video'] ) )
    1417             $do_video = false;
    1418     }
    1419     $out = '';
    1420 
    1421     if ( $do_image )
    1422         $out .= _media_button( __( 'Add an Image' ), 'images/media-button-image.gif?ver=20100531', 'image' );
    1423     if ( $do_video )
    1424         $out .= _media_button( __( 'Add Video' ), 'images/media-button-video.gif?ver=20100531', 'video' );
    1425     if ( $do_audio )
    1426         $out .= _media_button( __( 'Add Audio' ), 'images/media-button-music.gif?ver=20100531', 'audio' );
    1427 
    1428     $out .= _media_button( __( 'Add Media' ), 'images/media-button-other.gif?ver=20100531', 'media' );
    1429 
    1430     $context = apply_filters( 'media_buttons_context', __( 'Upload/Insert: %s' ) );
    1431 
    1432     return sprintf($context, $out);
    1433 
    1434 
    1435 }
    1436 
    1437 /**
    1438  * {@internal Missing Short Description}}
    1439  *
    1440  * @since unknown
    1441  */
    1442 function media_buttons() {
    1443     echo get_media_buttons();
    1444 }
    1445 add_action( 'media_buttons', 'media_buttons' );
    1446 
    1447 /**
    1448  * {@internal Missing Short Description}}
    1449  *
    1450  * @since unknown
    1451  * @access private
    1452  */
    1453 function _media_button( $title, $icon, $type ) {
    1454     return "<a href='" . esc_url( get_upload_iframe_src( $type ) ) . "' id='add_$type' class='thickbox' title='$title'><img src='" . esc_url( admin_url( $icon ) ) . "' alt='$title' /></a>";
    1455 }
    1456 
    1457 /**
    1458  * {@internal Missing Short Description}}
    1459  *
    1460  * @since unknown
    1461  */
    1462 function get_upload_iframe_src( $type ) {
    1463     global $post_ID, $temp_ID;
    1464     $uploading_iframe_ID = (int) ( 0 == $post_ID ? $temp_ID : $post_ID );
    1465     $upload_iframe_src = add_query_arg( 'post_id', $uploading_iframe_ID, 'media-upload.php' );
    1466 
    1467     if ( 'media' != $type )
    1468         $upload_iframe_src = add_query_arg( 'type', $type, $upload_iframe_src );
    1469     $upload_iframe_src = apply_filters( $type . '_upload_iframe_src', $upload_iframe_src );
    1470 
    1471     return add_query_arg( 'TB_iframe', true, $upload_iframe_src );
    1472 }
  • trunk/wp-includes/post.php

    r16534 r16535  
    23182318    $post = get_post($postid, $mode);
    23192319
    2320     if (
     2320    if ( 
    23212321        ( OBJECT == $mode && empty( $post->ID ) ) ||
    23222322        ( OBJECT != $mode && empty( $post['ID'] ) )
     
    50395039
    50405040/**
    5041  * Default post information to use when populating the "Write Post" form.
    5042  *
    5043  * @since 2.0.0
    5044  *
    5045  * @param string $post_type A post type string, defaults to 'post'.
    5046  * @param bool $create_in_db If true then also insert an auto-draft into database
    5047  * @return object stdClass object containing all the default post data as attributes
    5048  */
    5049 function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) {
    5050     global $wpdb;
    5051 
    5052     $post_title = '';
    5053     if ( !empty( $_REQUEST['post_title'] ) )
    5054         $post_title = esc_html( stripslashes( $_REQUEST['post_title'] ));
    5055 
    5056     $post_content = '';
    5057     if ( !empty( $_REQUEST['content'] ) )
    5058         $post_content = esc_html( stripslashes( $_REQUEST['content'] ));
    5059 
    5060     $post_excerpt = '';
    5061     if ( !empty( $_REQUEST['excerpt'] ) )
    5062         $post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] ));
    5063 
    5064     if ( $create_in_db ) {
    5065         // Cleanup old auto-drafts more than 7 days old
    5066         $old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" );
    5067         foreach ( (array) $old_posts as $delete )
    5068             wp_delete_post( $delete, true ); // Force delete
    5069         $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) );
    5070         $post = get_post( $post_id );
    5071     } else {
    5072         $post->ID = 0;
    5073         $post->post_author = '';
    5074         $post->post_date = '';
    5075         $post->post_date_gmt = '';
    5076         $post->post_password = '';
    5077         $post->post_type = $post_type;
    5078         $post->post_status = 'draft';
    5079         $post->to_ping = '';
    5080         $post->pinged = '';
    5081         $post->comment_status = get_option( 'default_comment_status' );
    5082         $post->ping_status = get_option( 'default_ping_status' );
    5083         $post->post_pingback = get_option( 'default_pingback_flag' );
    5084         $post->post_category = get_option( 'default_category' );
    5085         $post->page_template = 'default';
    5086         $post->post_parent = 0;
    5087         $post->menu_order = 0;
    5088     }
    5089 
    5090     $post->post_content = apply_filters( 'default_content', $post_content, $post );
    5091     $post->post_title   = apply_filters( 'default_title',   $post_title, $post   );
    5092     $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post );
    5093     $post->post_name = '';
    5094 
    5095     return $post;
    5096 }
    5097 
    5098 /**
    5099  * Returns or echos a form containing a post box.
    5100  *
    5101  * Used for the QuickPress dashboard module.
    5102  *
    5103  * @since 3.1.0
    5104  *
    5105  * @param array $args Arguments.
    5106  * @param string $post_type Post type.
    5107  */
    5108 function wp_quickpress_form( $args = array(), $post_type = 'post'){
    5109     global $post_ID;
    5110 
    5111     $fields = array(
    5112         'title' => array(
    5113             'capability' => '', // Capability to check before outputing field
    5114             'output' => '<h4 id="%s-title"><label for="title">'. __('Title') .'</label></h4>
    5115         <div class="input-text-wrap">
    5116             <input type="text" name="post_title" id="%s-title" tabindex="%d" autocomplete="off" value="'. esc_attr( $post->post_title ).'" />
    5117         </div>'
    5118         ),
    5119         'media_buttons' => array(
    5120             'capability' => 'upload_files',
    5121             'output' => '<div id="%s-media-buttons" class="hide-if-no-js">'. get_media_buttons() .'</div>',
    5122         ),
    5123         'content' => array(
    5124             'capability' => '',
    5125             'output' => '<h4 id="%s-content-label"><label for="content">'. __('Content') .'</label></h4>
    5126         <div class="textarea-wrap">
    5127             <textarea name="content" id="%s-content" class="mceEditor" rows="3" cols="15" tabindex="%d">'. esc_textarea( $post->post_content ) .'</textarea>
    5128         </div>
    5129             '."     <script type='text/javascript'>edCanvas = document.getElementById('content');edInsertContent = null;</script>
    5130         "
    5131 
    5132         ),
    5133         'tags' => array(
    5134             'capability' =>'',
    5135             'output' => '
    5136             <h4><label for="%s-tags-input">'. __('Tags') .'</label></h4>
    5137             <div class="input-text-wrap">
    5138                 <input type="text" name="%s-tags_input" id="tags-input" tabindex="%d" value="'. get_tags_to_edit( $post->ID ) .'" />
    5139             </div>
    5140 '
    5141         ),
    5142 
    5143     );
    5144 
    5145     $hidden_fields = array(
    5146         'action' => '<input type="hidden" name="action" id="quickpost-action" value="'.$post_type.'-quickpress-save" />',
    5147         'post_id' => '<input type="hidden" name="quickpress_post_ID" value="'. $post_ID .'" />',
    5148         'post_type' => '<input type="hidden" name="post_type" value="'.$post_type.'" />',
    5149     );
    5150 
    5151     $submit_fields = array(
    5152         'save' => '<input type="submit" name="save" id="save-post" class="button" tabindex="%s" value="'.  esc_attr('Save Draft') .'" />',
    5153         'reset' => '<input type="reset" tabindex="%s" value="'. esc_attr( 'Reset' ).'" class="button" />',
    5154     );
    5155 
    5156     $publishing_action = current_user_can('publish_posts') ? esc_attr('Publish') : esc_attr('Submit for Review');
    5157 
    5158     $publishing_fields = array(
    5159     'submit' => '<input type="submit" name="publish" id="publish" accesskey="p" tabindex="%s" class="button-primary" value="' . $publishing_action . '" />',
    5160     /*'test' => '<input type="submit" name="publish" id="publish" accesskey="p" tabindex="%n" class="button-primary" value="'. esc_attr('Publish') .'" />', */
    5161 
    5162     );
    5163 
    5164     $defaults = array(
    5165         'action' => admin_url( 'post.php' ),
    5166         'fields' => $fields,
    5167         'form_id' => '',
    5168         'default_cap' => 'edit_posts',
    5169         'tabindex_start' => '1',
    5170         'ajax' => true,
    5171         'hidden_fields' => $hidden_fields,
    5172         'submit_fields' => $submit_fields,
    5173         'publishing_fields' => $publishing_fields,
    5174         'submit_class' => 'submit',
    5175         'publish_action_container' => 'span',
    5176         'publish_action_id' => 'publishing-action',
    5177         'hidden_and_submit_fields_container' => 'p',
    5178         'hidden_and_submit_fields_container_class' => 'submit',
    5179     );
    5180 
    5181     $args = wp_parse_args($args, $defaults);
    5182 
    5183     $tabindex =  apply_filters( 'quickpress_tabindex_start', $args['tabindex_start'], $args['form_id']  );
    5184 
    5185     if ( current_user_can( $args['default_cap'] ) ): ?>
    5186         <?php do_action('quickpress_form_before_form', $args['form_id'] ); ?>
    5187         <form name="post" action="<?php echo $args['action'] ?>" method="post" id="<?php echo $args['form_id']; ?>">
    5188             <?php do_action('quickpress_form_before_fields', $args['form_id']);
    5189 
    5190             $fields = apply_filters( 'quickpress_fields',  $args['fields'], $args['form_id'] );
    5191             foreach ($fields as $title => $field){
    5192                 if ( empty( $field['capability'] ) || current_user_can( $field['capability'] ) ){
    5193                     printf( $field['output'], $args['form_id'], $args['form_id'], $tabindex );
    5194                     $tabindex++;
    5195                 }
    5196             }
    5197             //Hidden Fields
    5198             do_action('quickpress_form_after_fields', $args['form_id'] );
    5199 
    5200             echo "<{$args['hidden_and_submit_fields_container']} class='{$args['hidden_and_submit_fields_container_class']}'>";
    5201 
    5202             $hidden_fields = apply_filters( 'quickpress_hidden_fields', $args['hidden_fields'] , $args['form_id'] );
    5203 
    5204             foreach( $hidden_fields as $hidden_field )
    5205                 echo $hidden_field;
    5206 
    5207             // nonce
    5208             wp_nonce_field('add-post');
    5209 
    5210             // submit
    5211             foreach( $args['submit_fields'] as $submit_field )
    5212                 printf( $submit_field, $tabindex++ );
    5213 
    5214             // publish
    5215             echo "<{$args['publish_action_container']} id='{$args['publish_action_id']}'>";
    5216 
    5217             $publishing_fields = apply_filters( 'quickpress_publishing_fields', $args['publishing_fields'] , $args['form_id'] );
    5218 
    5219             foreach( $publishing_fields as $publishing_field) {
    5220                 printf( $publishing_field, $tabindex );
    5221                     $tabindex++;
    5222             }
    5223 
    5224             if ($args['ajax'] == true)
    5225                 echo '<img class="waiting" src="'. esc_url( admin_url( 'images/wpspin_light.gif' ) ) .'" />';
    5226 
    5227             echo "</{$args['publish_action_container']}>";
    5228             echo "<br class='clear' />";
    5229             do_action( 'quickpress_form_after_submit_fields', $args['form_id']);
    5230 
    5231             echo "</{$args['hidden_and_submit_fields_container']}";
    5232         do_action( 'quickpress_form_after_form_content', $args['form_id']);
    5233         echo '</form>';
    5234         do_action('quickpress_form_after_form', $args['form_id'] );
    5235     else:
    5236         do_action( 'quickpress_form_no_form', $args['form_id'] );
    5237     endif;
    5238 }
    5239 
    5240 /**
    52415041 * Returns an array of post format slugs to their translated and pretty display versions
    52425042 *
  • trunk/wp-includes/taxonomy.php

    r16523 r16535  
    29472947}
    29482948
    2949 
    2950 /**
    2951  * {@internal Missing Short Description}}
    2952  *
    2953  * @since unknown
    2954  *
    2955  * @param unknown_type $post_id
    2956  * @return unknown
    2957  */
    2958 function get_tags_to_edit( $post_id, $taxonomy = 'post_tag' ) {
    2959     return get_terms_to_edit( $post_id, $taxonomy);
    2960 }
    2961 
    2962 /**
    2963  * {@internal Missing Short Description}}
    2964  *
    2965  * @since unknown
    2966  *
    2967  * @param unknown_type $post_id
    2968  * @return unknown
    2969  */
    2970 function get_terms_to_edit( $post_id, $taxonomy = 'post_tag' ) {
    2971     $post_id = (int) $post_id;
    2972     if ( !$post_id )
    2973         return false;
    2974 
    2975     $tags = wp_get_post_terms($post_id, $taxonomy, array());
    2976 
    2977     if ( !$tags )
    2978         return false;
    2979 
    2980     if ( is_wp_error($tags) )
    2981         return $tags;
    2982 
    2983     foreach ( $tags as $tag )
    2984         $tag_names[] = $tag->name;
    2985     $tags_to_edit = join( ',', $tag_names );
    2986     $tags_to_edit = esc_attr( $tags_to_edit );
    2987     $tags_to_edit = apply_filters( 'terms_to_edit', $tags_to_edit, $taxonomy );
    2988 
    2989     return $tags_to_edit;
    2990 }
    2991 
    29922949/**
    29932950 * Returns the term's parent's term_ID
Note: See TracChangeset for help on using the changeset viewer.