Ticket #14966: 15922.diff
File 15922.diff, 14.2 KB (added by , 14 years ago) |
---|
-
wp-includes/post.php
5001 5001 * @param array $args Arguments. 5002 5002 * @param string $post_type Post type. 5003 5003 */ 5004 function wp_quickpress_form( $args = array(), $post_type = 'post'){ 5005 global $post_ID; 5004 function wp_quickpress_form( $args = array() ){ 5006 5005 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 5007 5019 $fields = array( 5008 5020 'title' => array( 5009 5021 '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> 5011 5023 <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 ).'" /> 5013 5025 </div>' 5014 5026 ), 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 ),5019 5027 'content' => array( 5020 5028 '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> 5022 5030 <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> 5024 5032 </div> 5025 '." <script type='text/javascript'>edCanvas = document.getElementById('content');edInsertContent = null;</script> 5026 " 5027 5033 ' 5028 5034 ), 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 5039 5035 ); 5040 5036 5041 5037 $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'] .'" />', 5045 5041 ); 5046 5042 5047 5043 $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') .'" />', 5049 5045 'reset' => '<input type="reset" tabindex="%s" value="'. esc_attr( 'Reset' ).'" class="button" />', 5050 5046 ); 5051 5047 5052 5048 $publishing_action = current_user_can('publish_posts') ? esc_attr('Publish') : esc_attr('Submit for Review'); 5053 5049 5054 5050 $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 . '" />', 5057 5052 5058 5053 ); 5059 5054 … … 5072 5067 'publish_action_id' => 'publishing-action', 5073 5068 'hidden_and_submit_fields_container' => 'p', 5074 5069 'hidden_and_submit_fields_container_class' => 'submit', 5075 ); 5070 'post_type' => 'post', 5071 'post' => null, 5072 'post_id' => null 5073 ); 5076 5074 5077 5075 $args = wp_parse_args($args, $defaults); 5078 5076 5079 $tabindex = apply_filters( 'quickpress_tabindex_start', $args['tabindex_start'], $args['form_id'] );5080 5081 5077 if ( current_user_can( $args['default_cap'] ) ): ?> 5082 5078 <?php do_action('quickpress_form_before_form', $args['form_id'] ); ?> 5083 5079 <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); 5085 5081 5086 $fields = apply_filters( 'quickpress_fields', $args['fields'], $args ['form_id']);5082 $fields = apply_filters( 'quickpress_fields', $args['fields'], $args ); 5087 5083 foreach ($fields as $title => $field){ 5088 5084 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 } 5092 5088 } 5093 5089 //Hidden Fields 5094 do_action('quickpress_form_after_fields', $args ['form_id']);5090 do_action('quickpress_form_after_fields', $args ); 5095 5091 5096 5092 echo "<{$args['hidden_and_submit_fields_container']} class='{$args['hidden_and_submit_fields_container_class']}'>"; 5097 5093 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 ); 5099 5095 5100 5096 foreach( $hidden_fields as $hidden_field ) 5101 5097 echo $hidden_field; … … 5105 5101 5106 5102 // submit 5107 5103 foreach( $args['submit_fields'] as $submit_field ) 5108 printf( $submit_field, $tabindex++ );5104 echo $submit_field; 5109 5105 5110 5106 // publish 5111 5107 echo "<{$args['publish_action_container']} id='{$args['publish_action_id']}'>"; 5112 5108 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 ); 5114 5110 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 5119 5114 5120 if ($args['ajax'] == true)5121 echo '<img class="waiting" src="'. esc_url( admin_url( 'images/wpspin_light.gif' ) ) .'" />';5122 5123 5115 echo "</{$args['publish_action_container']}>"; 5124 5116 echo "<br class='clear' />"; 5125 do_action( 'quickpress_form_after_submit_fields', $args ['form_id']);5117 do_action( 'quickpress_form_after_submit_fields', $args); 5126 5118 5127 5119 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 ); 5129 5121 echo '</form>'; 5130 do_action( 'quickpress_form_after_form', $args['form_id']);5122 do_action( 'quickpress_form_after_form', $args ); 5131 5123 else: 5132 do_action( 'quickpress_form_no_form', $args ['form_id']);5124 do_action( 'quickpress_form_no_form', $args ); 5133 5125 endif; 5134 5126 } 5135 5136 5127 ?> -
wp-admin/includes/dashboard.php
448 448 } 449 449 450 450 $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 ); 452 458 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 ); 458 460 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 } 464 464 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> 465 function _dashboard_quickpress_media_buttons( $title, $args){ 466 if ( ! isset( $args['form_id'] ) || $args['form_id'] != 'dashboard_quick-press' || $title != 'title' ) 467 return; 469 468 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 } 471 471 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> 472 add_action( 'quickpress_form_field_after', '_dashboard_quickpress_media_buttons', 10 , 2 ); 476 473 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>490 474 491 </form> 475 function _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' ) ) .'" />' ); 492 479 493 <?php 494 if ( $drafts ) 495 wp_dashboard_recent_drafts( $drafts ); 480 return array_merge( $ajax_field , $fields); 481 } 482 483 add_filter('quickpress_publishing_fields' , '_dashboard_quickpress_publish_actions', 10, 2); 484 485 function _dashboard_quickpress_non_hierarchical_taxonomy( $taxonomy_name , $args ){ 486 if (! 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 496 499 } 497 500 501 function _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 508 add_action( 'quickpress_form_field_after' , '_dashboard_quickpress_post_tags' , 10, 2); 509 510 511 512 498 513 function wp_dashboard_quick_press() { 499 514 echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>'; 500 515 } -
wp-admin/js/dashboard.dev.js
47 47 /* QuickPress */ 48 48 quickPressLoad = function() { 49 49 var act = $('#quickpost-action'), t; 50 t = $('# quick-press').submit( function() {50 t = $('#dashboard_quick-press').submit( function() { 51 51 $('#dashboard_quick_press #publishing-action img.waiting').css('visibility', 'visible'); 52 52 $('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr('disabled','disabled'); 53 53 -
wp-admin/css/dashboard.dev.css
262 262 263 263 /* QuickPress */ 264 264 265 #dashboard_quick _press h4 {265 #dashboard_quick-press h4 { 266 266 font-family: Verdana, Arial, "Bitstream Vera Sans", sans-serif; 267 267 float: left; 268 268 width: 5.5em; … … 273 273 font-size: 12px; 274 274 } 275 275 276 #dashboard_quick _press h4 label {277 margin-right: 10px;276 #dashboard_quick-press h4 label { 277 margin-right: 8px; 278 278 } 279 279 280 280 #dashboard_quick_press .input-text-wrap, … … 282 282 margin: 0 0 1em 5em; 283 283 } 284 284 285 #dashboard_quick_press # media-buttons {285 #dashboard_quick_press #dashboard_quick-press-media-buttons { 286 286 margin: 0 0 .5em 5em; 287 287 padding: 0 0 0 10px; 288 288 font-size: 11px; 289 289 } 290 290 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 { 292 308 vertical-align: bottom; 293 309 } 294 310