Make WordPress Core

Ticket #14966: 15922.diff

File 15922.diff, 14.2 KB (added by jorbin, 14 years ago)
  • wp-includes/post.php

     
    50015001 * @param array $args Arguments.
    50025002 * @param string $post_type Post type.
    50035003 */
    5004 function wp_quickpress_form( $args = array(), $post_type = 'post'){
    5005         global $post_ID;
     5004function wp_quickpress_form( $args = array() ){
    50065005
     5006    if (! isset( $args['post'] ) )
     5007        $post = null;
     5008    else
     5009        $post = $args['post'];
     5010
     5011    if (! isset( $args['post_id'] ) ){
     5012        $args['post_id'] = null;
     5013    }
     5014    if (! isset( $args['post_type'] ) ){
     5015        $args['post_type']  = null;
     5016    }
     5017
     5018
    50075019        $fields = array(
    50085020                'title' => array(
    50095021                        'capability' => '', // Capability to check before outputing field
    5010                         'output' => '<h4 id="%s-title"><label for="title">'. __('Title') .'</label></h4>
     5022                        'output' => '<h4 id="%1$s-title"><label for="title">'. __('Title') .'</label></h4>
    50115023                <div class="input-text-wrap">
    5012                         <input type="text" name="post_title" id="%s-title" tabindex="%d" autocomplete="off" value="'. esc_attr( $post->post_title ).'" />
     5024                        <input type="text" name="post_title" id="%1$s-title" autocomplete="off" value="'. esc_attr( $post->post_title ).'" />
    50135025                </div>'
    50145026                ),
    5015                 'media_buttons' => array(
    5016                         'capability' => 'upload_files',
    5017                         'output' => '<div id="%s-media-buttons" class="hide-if-no-js">'. get_media_buttons() .'</div>',
    5018                 ),
    50195027                'content' => array(
    50205028                        'capability' => '',
    5021                         'output' => '<h4 id="%s-content-label"><label for="content">'. __('Content') .'</label></h4>
     5029                        'output' => '<h4 id="%1$s-content-label"><label for="content">'. __('Content') .'</label></h4>
    50225030                <div class="textarea-wrap">
    5023                         <textarea name="content" id="%s-content" class="mceEditor" rows="3" cols="15" tabindex="%d">'. $post->post_content.'</textarea>
     5031                        <textarea name="content" id="%1$s-content" class="mceEditor" rows="3" cols="15" >'. $post->post_content.'</textarea>
    50245032                </div>
    5025                         '."     <script type='text/javascript'>edCanvas = document.getElementById('content');edInsertContent = null;</script>
    5026                 "
    5027 
     5033                '
    50285034                ),
    5029                 'tags' => array(
    5030                         'capability' =>'',
    5031                         'output' => '
    5032                         <h4><label for="%s-tags-input">'. __('Tags') .'</label></h4>
    5033                         <div class="input-text-wrap">
    5034                                 <input type="text" name="%s-tags_input" id="tags-input" tabindex="%d" value="'. get_tags_to_edit( $post->ID ) .'" />
    5035                         </div>
    5036 '
    5037                 ),
    5038 
    50395035        );
    50405036
    50415037        $hidden_fields = array(
    5042                 'action' => '<input type="hidden" name="action" id="quickpost-action" value="'.$post_type.'-quickpress-save" />',
    5043                 'post_id' => '<input type="hidden" name="quickpress_post_ID" value="'. $post_ID .'" />',
    5044                 'post_type' => '<input type="hidden" name="post_type" value="'.$post_type.'" />',
     5038                'action' => '<input type="hidden" name="action" id="quickpost-action" value="'.$args['post_type'] .'-quickpress-save" />',
     5039                'post_id' => '<input type="hidden" name="quickpress_post_ID" value="'. $args['post_id'] .'" />',
     5040                'post_type' => '<input type="hidden" name="post_type" value="'. $args['post_type'] .'" />',
    50455041        );
    50465042
    50475043        $submit_fields = array(
    5048                 'save' => '<input type="submit" name="save" id="save-post" class="button" tabindex="%s" value="'.  esc_attr('Save Draft') .'" />',
     5044                'save' => '<input type="submit" name="save" id="save-post" class="button" value="'.  esc_attr('Save Draft') .'" />',
    50495045                'reset' => '<input type="reset" tabindex="%s" value="'. esc_attr( 'Reset' ).'" class="button" />',
    50505046        );
    50515047
    50525048        $publishing_action = current_user_can('publish_posts') ? esc_attr('Publish') : esc_attr('Submit for Review');
    50535049
    50545050        $publishing_fields = array(
    5055         'submit' => '<input type="submit" name="publish" id="publish" accesskey="p" tabindex="%s" class="button-primary" value="' . $publishing_action . '" />',
    5056         /*'test' => '<input type="submit" name="publish" id="publish" accesskey="p" tabindex="%n" class="button-primary" value="'. esc_attr('Publish') .'" />', */
     5051        'submit' => '<input type="submit" name="publish" id="publish" accesskey="p" class="button-primary" value="' . $publishing_action . '" />',
    50575052
    50585053        );
    50595054
     
    50725067                'publish_action_id' => 'publishing-action',
    50735068                'hidden_and_submit_fields_container' => 'p',
    50745069                'hidden_and_submit_fields_container_class' => 'submit',
    5075         );
     5070        'post_type' => 'post',
     5071        'post' => null,
     5072        'post_id' => null
     5073);
    50765074
    50775075        $args = wp_parse_args($args, $defaults);
    50785076
    5079         $tabindex =  apply_filters( 'quickpress_tabindex_start', $args['tabindex_start'], $args['form_id']  );
    5080 
    50815077        if ( current_user_can( $args['default_cap'] ) ): ?>
    50825078                <?php do_action('quickpress_form_before_form', $args['form_id'] ); ?>
    50835079                <form name="post" action="<?php echo $args['action'] ?>" method="post" id="<?php echo $args['form_id']; ?>">
    5084                         <?php do_action('quickpress_form_before_fields', $args['form_id']);
     5080                        <?php do_action('quickpress_form_before_fields', $args);
    50855081
    5086                         $fields = apply_filters( 'quickpress_fields',  $args['fields'], $args['form_id'] );
     5082                        $fields = apply_filters( 'quickpress_fields',  $args['fields'], $args );
    50875083                        foreach ($fields as $title => $field){
    50885084                                if ( empty( $field['capability'] ) || current_user_can( $field['capability'] ) ){
    5089                                         printf( $field['output'], $args['form_id'], $args['form_id'], $tabindex );
    5090                                         $tabindex++;
    5091                                 }
     5085                                        printf( $field['output'], $args['form_id'] );
     5086                                    do_action('quickpress_form_field_after', $title, $args);
     5087                }
    50925088                        }
    50935089                        //Hidden Fields
    5094                         do_action('quickpress_form_after_fields', $args['form_id'] );
     5090                        do_action('quickpress_form_after_fields', $args );
    50955091
    50965092                        echo "<{$args['hidden_and_submit_fields_container']} class='{$args['hidden_and_submit_fields_container_class']}'>";
    50975093
    5098                         $hidden_fields = apply_filters( 'quickpress_hidden_fields', $args['hidden_fields'] , $args['form_id'] );
     5094                        $hidden_fields = apply_filters( 'quickpress_hidden_fields', $args['hidden_fields'] , $args );
    50995095
    51005096                        foreach( $hidden_fields as $hidden_field )
    51015097                                echo $hidden_field;
     
    51055101
    51065102                        // submit
    51075103                        foreach( $args['submit_fields'] as $submit_field )
    5108                                 printf( $submit_field, $tabindex++ );
     5104                                echo  $submit_field;
    51095105
    51105106                        // publish
    51115107                        echo "<{$args['publish_action_container']} id='{$args['publish_action_id']}'>";
    51125108
    5113                         $publishing_fields = apply_filters( 'quickpress_publishing_fields', $args['publishing_fields'] , $args['form_id'] );
     5109                        $publishing_fields = apply_filters( 'quickpress_publishing_fields', $args['publishing_fields'] , $args );
    51145110
    5115                         foreach( $publishing_fields as $publishing_field) {
    5116                                 printf( $publishing_field, $tabindex );
    5117                                         $tabindex++;
    5118                         }
     5111                        foreach( $publishing_fields as $publishing_field)
     5112                                echo  $publishing_field;
     5113                       
    51195114
    5120                         if ($args['ajax'] == true)
    5121                                 echo '<img class="waiting" src="'. esc_url( admin_url( 'images/wpspin_light.gif' ) ) .'" />';
    5122 
    51235115                        echo "</{$args['publish_action_container']}>";
    51245116                        echo "<br class='clear' />";
    5125                         do_action( 'quickpress_form_after_submit_fields', $args['form_id']);
     5117                        do_action( 'quickpress_form_after_submit_fields', $args);
    51265118
    51275119                        echo "</{$args['hidden_and_submit_fields_container']}";
    5128                 do_action( 'quickpress_form_after_form_content', $args['form_id']);
     5120                do_action( 'quickpress_form_after_form_content', $args );
    51295121                echo '</form>';
    5130                 do_action('quickpress_form_after_form', $args['form_id'] );
     5122                do_action( 'quickpress_form_after_form', $args );
    51315123        else:
    5132                 do_action( 'quickpress_form_no_form', $args['form_id'] );
     5124                do_action( 'quickpress_form_no_form', $args );
    51335125        endif;
    51345126}
    5135 
    51365127?>
  • wp-admin/includes/dashboard.php

     
    448448        }
    449449
    450450        $post_ID = (int) $post->ID;
    451 ?>
     451   
     452    $quickpress_args = array(
     453        'post_id' => $post_ID,
     454        'post' => $post,
     455        'form_id' => 'dashboard_quick-press',
     456        'post_type' => 'post',
     457   );
    452458
    453         <form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press">
    454                 <h4 id="quick-post-title"><label for="title"><?php _e('Title') ?></label></h4>
    455                 <div class="input-text-wrap">
    456                         <input type="text" name="post_title" id="title" tabindex="1" autocomplete="off" value="<?php echo esc_attr( $post->post_title ); ?>" />
    457                 </div>
     459    wp_quickpress_form( $quickpress_args );
    458460
    459                 <?php if ( current_user_can( 'upload_files' ) ) : ?>
    460                 <div id="media-buttons" class="hide-if-no-js">
    461                         <?php do_action( 'media_buttons' ); ?>
    462                 </div>
    463                 <?php endif; ?>
     461        if ( $drafts )
     462                wp_dashboard_recent_drafts( $drafts );
     463}
    464464
    465                 <h4 id="content-label"><label for="content"><?php _e('Content') ?></label></h4>
    466                 <div class="textarea-wrap">
    467                         <textarea name="content" id="content" class="mceEditor" rows="3" cols="15" tabindex="2"><?php echo $post->post_content; ?></textarea>
    468                 </div>
     465function _dashboard_quickpress_media_buttons( $title,  $args){
     466    if ( ! isset( $args['form_id'] ) || $args['form_id'] != 'dashboard_quick-press' || $title != 'title' )
     467        return;
    469468
    470                 <script type="text/javascript">edCanvas = document.getElementById('content');edInsertContent = null;</script>
     469    echo '<div id="'.$args['form_id'].'-media-buttons" class="hide-if-no-js">'. get_media_buttons() .'</div>';
     470}
    471471
    472                 <h4><label for="tags-input"><?php _e('Tags') ?></label></h4>
    473                 <div class="input-text-wrap">
    474                         <input type="text" name="tags_input" id="tags-input" tabindex="3" value="<?php echo get_tags_to_edit( $post->ID ); ?>" />
    475                 </div>
     472add_action( 'quickpress_form_field_after', '_dashboard_quickpress_media_buttons', 10 , 2 );
    476473
    477                 <p class="submit">
    478                         <input type="hidden" name="action" id="quickpost-action" value="post-quickpress-save" />
    479                         <input type="hidden" name="quickpress_post_ID" value="<?php echo $post_ID; ?>" />
    480                         <input type="hidden" name="post_type" value="post" />
    481                         <?php wp_nonce_field('add-post'); ?>
    482                         <input type="submit" name="save" id="save-post" class="button" tabindex="4" value="<?php esc_attr_e('Save Draft'); ?>" />
    483                         <input type="reset" value="<?php esc_attr_e( 'Reset' ); ?>" class="button" />
    484                         <span id="publishing-action">
    485                                 <input type="submit" name="publish" id="publish" accesskey="p" tabindex="5" class="button-primary" value="<?php current_user_can('publish_posts') ? esc_attr_e('Publish') : esc_attr_e('Submit for Review'); ?>" />
    486                                 <img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" />
    487                         </span>
    488                         <br class="clear" />
    489                 </p>
    490474
    491         </form>
     475function _dashboard_quickpress_publish_actions( $fields,  $args ) {
     476    if ( ! isset( $args['form_id'] ) || $args['form_id'] != 'dashboard_quick-press' )
     477           return $fields;
     478    $ajax_field = array('ajax' => '<img class="waiting" src="'. esc_url( admin_url( 'images/wpspin_light.gif' ) ) .'" />' );
    492479
    493 <?php
    494         if ( $drafts )
    495                 wp_dashboard_recent_drafts( $drafts );
     480    return array_merge( $ajax_field , $fields);
     481    }
     482   
     483add_filter('quickpress_publishing_fields' , '_dashboard_quickpress_publish_actions', 10, 2);
     484
     485function _dashboard_quickpress_non_hierarchical_taxonomy( $taxonomy_name , $args ){
     486if (! taxonomy_exists( $taxonomy_name ) )
     487        return;
     488
     489    $taxonomy = get_taxonomy($taxonomy_name);
     490
     491    $taxonomy_short_name = $taxonomy->query_var;
     492    $taxonomy_title = $taxonomy->label;
     493   
     494    echo '<h4><label for="'.$args['form_id'].'-'.$taxonomy_short_name.'-input">'. __($taxonomy_title) .'</label></h4>
     495          <div class="input-text-wrap">
     496          <input type="text" name="'.$args['form_id'].'-'.$taxonomy_short_name.'_input" id="'.$taxonomy_short_name.'-input" value="" />
     497          </div> ';
     498
    496499}
    497500
     501function _dashboard_quickpress_post_tags($title, $args){
     502    if ( ! isset( $args['form_id'] ) || $args['form_id'] != 'dashboard_quick-press' || $title != 'content' )
     503        return;
     504    _dashboard_quickpress_non_hierarchical_taxonomy( 'post_tag' , $args );
     505
     506}
     507
     508add_action( 'quickpress_form_field_after' , '_dashboard_quickpress_post_tags' , 10, 2);
     509
     510
     511
     512
    498513function wp_dashboard_quick_press() {
    499514        echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
    500515}
  • wp-admin/js/dashboard.dev.js

     
    4747        /* QuickPress */
    4848        quickPressLoad = function() {
    4949                var act = $('#quickpost-action'), t;
    50                 t = $('#quick-press').submit( function() {
     50                t = $('#dashboard_quick-press').submit( function() {
    5151                        $('#dashboard_quick_press #publishing-action img.waiting').css('visibility', 'visible');
    5252                        $('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr('disabled','disabled');
    5353
  • wp-admin/css/dashboard.dev.css

     
    262262
    263263/* QuickPress */
    264264
    265 #dashboard_quick_press h4 {
     265#dashboard_quick-press h4 {
    266266        font-family: Verdana, Arial, "Bitstream Vera Sans", sans-serif;
    267267        float: left;
    268268        width: 5.5em;
     
    273273        font-size: 12px;
    274274}
    275275
    276 #dashboard_quick_press h4 label {
    277         margin-right: 10px;
     276#dashboard_quick-press h4 label {
     277        margin-right: 8px;
    278278}
    279279
    280280#dashboard_quick_press .input-text-wrap,
     
    282282        margin: 0 0 1em 5em;
    283283}
    284284
    285 #dashboard_quick_press #media-buttons {
     285#dashboard_quick_press #dashboard_quick-press-media-buttons {
    286286        margin: 0 0 .5em 5em;
    287287        padding: 0 0 0 10px;
    288288        font-size: 11px;
    289289}
    290290
    291 #dashboard_quick_press #media-buttons a {
     291#dashboard_quick-press-media-buttons {
     292    cursor: default;
     293    padding: 8px 8px 0;
     294}
     295                                 
     296#dashboard_quick-press-media-buttons a {
     297    cursor: pointer;
     298    padding: 0 0 5px 10px;
     299}
     300                                                                 
     301                                                                    #dashboard_quick-press-media-buttons img,
     302                                                                        {
     303                                                                                        vertical-align: middle;
     304                                                                        }
     305
     306
     307#dashboard_quick-press #dashboard_quick-press-media-buttons a {
    292308        vertical-align: bottom;
    293309}
    294310