Ticket #14966: quickpress.patch
File quickpress.patch, 20.5 KB (added by , 14 years ago) |
---|
-
wp-includes/taxonomy.php
2693 2693 2694 2694 return false; 2695 2695 } 2696 2697 2698 /** 2699 * {@internal Missing Short Description}} 2700 * 2701 * @since unknown 2702 * 2703 * @param unknown_type $post_id 2704 * @return unknown 2705 */ 2706 function get_tags_to_edit( $post_id, $taxonomy = 'post_tag' ) { 2707 return get_terms_to_edit( $post_id, $taxonomy); 2708 } 2709 2710 /** 2711 * {@internal Missing Short Description}} 2712 * 2713 * @since unknown 2714 * 2715 * @param unknown_type $post_id 2716 * @return unknown 2717 */ 2718 function get_terms_to_edit( $post_id, $taxonomy = 'post_tag' ) { 2719 $post_id = (int) $post_id; 2720 if ( !$post_id ) 2721 return false; 2722 2723 $tags = wp_get_post_terms($post_id, $taxonomy, array()); 2724 2725 if ( !$tags ) 2726 return false; 2727 2728 if ( is_wp_error($tags) ) 2729 return $tags; 2730 2731 foreach ( $tags as $tag ) 2732 $tag_names[] = $tag->name; 2733 $tags_to_edit = join( ',', $tag_names ); 2734 $tags_to_edit = esc_attr( $tags_to_edit ); 2735 $tags_to_edit = apply_filters( 'terms_to_edit', $tags_to_edit, $taxonomy ); 2736 2737 return $tags_to_edit; 2738 } -
wp-includes/post.php
4713 4713 add_filter('the_preview', '_set_preview'); 4714 4714 } 4715 4715 } 4716 4717 /** 4718 * Default post information to use when populating the "Write Post" form. 4719 * 4720 * @since unknown 4721 * 4722 *@param string A post type string, defaults to 'post'. 4723 * @return object stdClass object containing all the default post data as attributes 4724 */ 4725 function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) { 4726 global $wpdb; 4727 4728 $post_title = ''; 4729 if ( !empty( $_REQUEST['post_title'] ) ) 4730 $post_title = esc_html( stripslashes( $_REQUEST['post_title'] )); 4731 4732 $post_content = ''; 4733 if ( !empty( $_REQUEST['content'] ) ) 4734 $post_content = esc_html( stripslashes( $_REQUEST['content'] )); 4735 4736 $post_excerpt = ''; 4737 if ( !empty( $_REQUEST['excerpt'] ) ) 4738 $post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] )); 4739 4740 if ( $create_in_db ) { 4741 // Cleanup old auto-drafts more than 7 days old 4742 $old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" ); 4743 foreach ( (array) $old_posts as $delete ) 4744 wp_delete_post( $delete, true ); // Force delete 4745 $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ); 4746 $post = get_post( $post_id ); 4747 } else { 4748 $post->ID = 0; 4749 $post->post_author = ''; 4750 $post->post_date = ''; 4751 $post->post_date_gmt = ''; 4752 $post->post_password = ''; 4753 $post->post_type = $post_type; 4754 $post->post_status = 'draft'; 4755 $post->to_ping = ''; 4756 $post->pinged = ''; 4757 $post->comment_status = get_option( 'default_comment_status' ); 4758 $post->ping_status = get_option( 'default_ping_status' ); 4759 $post->post_pingback = get_option( 'default_pingback_flag' ); 4760 $post->post_category = get_option( 'default_category' ); 4761 $post->page_template = 'default'; 4762 $post->post_parent = 0; 4763 $post->menu_order = 0; 4764 } 4765 4766 $post->post_content = apply_filters( 'default_content', $post_content, $post ); 4767 $post->post_title = apply_filters( 'default_title', $post_title, $post ); 4768 $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post ); 4769 $post->post_name = ''; 4770 4771 return $post; 4772 } 4773 4774 4775 /** 4776 * Returns or echos a form containing a post box 4777 * 4778 */ 4779 function wp_quickpress_form( $args = array(), $post_type = 'post'){ 4780 4781 global $post_ID; 4782 4783 $fields = array( 4784 'title' => array( 4785 'capability' => '', // Capability to check before outputing field 4786 'output' => '<h4 id="%s-title"><label for="title">'. __('Title') .'</label></h4> 4787 <div class="input-text-wrap"> 4788 <input type="text" name="post_title" id="%s-title" tabindex="%d" autocomplete="off" value="'. esc_attr( $post->post_title ).'" /> 4789 </div>' 4790 ), 4791 'media_buttons' => array( 4792 'capability' => 'upload_files', 4793 'output' => '<div id="%s-media-buttons" class="hide-if-no-js">'. get_media_buttons() .'</div>', 4794 ), 4795 'content' => array( 4796 'capability' => '', 4797 'output' => '<h4 id="%s-content-label"><label for="content">'. __('Content') .'</label></h4> 4798 <div class="textarea-wrap"> 4799 <textarea name="content" id="%s-content" class="mceEditor" rows="3" cols="15" tabindex="%d">'. $post->post_content.'</textarea> 4800 </div> 4801 '." <script type='text/javascript'>edCanvas = document.getElementById('content');edInsertContent = null;</script> 4802 " 4803 4804 ), 4805 'tags' => array( 4806 'capability' =>'', 4807 'output' => ' 4808 <h4><label for="%s-tags-input">'. __('Tags') .'</label></h4> 4809 <div class="input-text-wrap"> 4810 <input type="text" name="%s-tags_input" id="tags-input" tabindex="%d" value="'. get_tags_to_edit( $post->ID ) .'" /> 4811 </div> 4812 ' 4813 ), 4814 4815 ); 4816 4817 $hidden_fields = array( 4818 'action' => '<input type="hidden" name="action" id="quickpost-action" value="'.$post_type.'-quickpress-save" />', 4819 'post_id' => '<input type="hidden" name="quickpress_post_ID" value="'. $post_ID .'" />', 4820 'post_type' => '<input type="hidden" name="post_type" value="'.$post_type.'" />', 4821 4822 4823 ); 4824 4825 $submit_fields = array( 4826 'save' => '<input type="submit" name="save" id="save-post" class="button" tabindex="%s" value="'. esc_attr('Save Draft') .'" />', 4827 'reset' => '<input type="reset" tabindex="%s" value="'. esc_attr( 'Reset' ).'" class="button" />', 4828 ); 4829 4830 $publishing_action = current_user_can('publish_posts') ? esc_attr('Publish') : esc_attr('Submit for Review'); 4831 4832 $publishing_fields = array( 4833 'submit' => '<input type="submit" name="publish" id="publish" accesskey="p" tabindex="%s" class="button-primary" value="' . $publishing_action . '" />', 4834 /*'test' => '<input type="submit" name="publish" id="publish" accesskey="p" tabindex="%n" class="button-primary" value="'. esc_attr('Publish') .'" />', */ 4835 4836 ); 4837 4838 4839 $defaults = array( 4840 'action' => admin_url( 'post.php' ), 4841 'fields' => $fields, 4842 'form_id' => '', 4843 'default_cap' => 'edit_posts', 4844 'tabindex_start' => '1', 4845 'ajax' => true, 4846 'hidden_fields' => $hidden_fields, 4847 'submit_fields' => $submit_fields, 4848 'publishing_fields' => $publishing_fields, 4849 'submit_class' => 'submit', 4850 'publish_action_container' => 'span', 4851 'publish_action_id' => 'publishing-action', 4852 'hidden_and_submit_fields_container' => 'p', 4853 'hidden_and_submit_fields_container_class' => 'submit', 4854 ); 4855 4856 4857 $args = wp_parse_args($args, $defaults); 4858 4859 $tabindex = apply_filters( $args['form_id'] . '_quickpress_tabindex_start', $args['tabindex_start'] ); 4860 4861 if (current_user_can( $args['default_cap'] ) ): ?> 4862 <?php do_action($args['form_id'] . '_quickpress_form_before_form') ?> 4863 <form name="post" action="<?php echo $args['action'] ?>" method="post" id="<?php echo $args['form_id']; ?>_quick-press"> 4864 <?php do_action($args['form_id'] . '_quickpress_form_before_fields'); 4865 4866 $fields = apply_filters( $args['form_id'] . '_quickpress_fields', $args['fields'] ); 4867 foreach ($fields as $title => $field){ 4868 $capability = ($field['capability'] === '') ? $args['default_cap'] : $field['capability']; 4869 if ( current_user_can($capability) ){ 4870 _e( sprintf( $field['output'], $args['form_id'], $args['form_id'], $tabindex ) ); 4871 $tabindex++; 4872 } 4873 } 4874 //Hidden Fields 4875 do_action($args['form_id'] . '_quickpress_form_after_fields'); 4876 4877 echo "<{$args['hidden_and_submit_fields_container']} class='{$args['hidden_and_submit_fields_container_class']}'>"; 4878 4879 $hidden_fields = apply_filters( $args['form_id'] . '_quickpress_hidden_fields', $args['hidden_fields'] ); 4880 4881 foreach( $hidden_fields as $hidden_field ) 4882 echo $hidden_field; 4883 4884 4885 //nonce 4886 wp_nonce_field('add-post'); 4887 4888 //submit 4889 4890 foreach($args['submit_fields'] as $submit_field){ 4891 _e( sprintf( $submit_field, $tabindex ) ); 4892 $tabindex++; 4893 } 4894 4895 4896 // publish 4897 4898 echo "<{$args['publish_action_container']} id='{$args['publish_action_id']}'>"; 4899 4900 foreach($args['publishing_fields'] as $publishing_field){ 4901 _e( sprintf( $publishing_field, $tabindex ) ); 4902 $tabindex++; 4903 } 4904 4905 4906 if ($args['ajax'] == true) 4907 echo '<img class="waiting" src="'. esc_url( admin_url( 'images/wpspin_light.gif' ) ) .'" />'; 4908 4909 4910 4911 echo "</{$args['publish_action_container']}>"; 4912 echo "<br class='clear' />"; 4913 do_action($args['form_id'] . '_quickpress_form_after_submit_fields'); 4914 4915 echo "</{$args['hidden_and_submit_fields_container']}"; 4916 do_action($args['form_id'] . '_quickpress_form_after_form_content'); 4917 echo '</form>'; 4918 do_action($args['form_id'] . '_quickpress_form_after_form'); 4919 else: 4920 do_action($args['form_id'] . '_quickpress_form_no_form'); 4921 4922 endif; 4923 4924 } -
wp-includes/media.php
1395 1395 $oembed = _wp_oembed_get_object(); 1396 1396 $oembed->providers[$format] = array( $provider, $regex ); 1397 1397 } 1398 1399 /** 1400 * 1401 * 1402 * 1403 */ 1404 function get_media_buttons(){ 1405 $do_image = $do_audio = $do_video = true; 1406 if ( is_multisite() ) { 1407 $media_buttons = get_site_option( 'mu_media_buttons' ); 1408 if ( empty($media_buttons['image']) ) 1409 $do_image = false; 1410 if ( empty($media_buttons['audio']) ) 1411 $do_audio = false; 1412 if ( empty($media_buttons['video']) ) 1413 $do_video = false; 1414 } 1415 $out = ''; 1416 1417 if ( $do_image ) 1418 $out .= _media_button(__('Add an Image'), 'images/media-button-image.gif?ver=20100531', 'image'); 1419 if ( $do_video ) 1420 $out .= _media_button(__('Add Video'), 'images/media-button-video.gif?ver=20100531', 'video'); 1421 if ( $do_audio ) 1422 $out .= _media_button(__('Add Audio'), 'images/media-button-music.gif?ver=20100531', 'audio'); 1423 1424 $out .= _media_button(__('Add Media'), 'images/media-button-other.gif?ver=20100531', 'media'); 1425 1426 $context = apply_filters('media_buttons_context', __('Upload/Insert %s')); 1427 1428 return sprintf($context, $out); 1429 1430 1431 } 1432 1433 /** 1434 * {@internal Missing Short Description}} 1435 * 1436 * @since unknown 1437 */ 1438 function media_buttons() { 1439 echo get_media_buttons(); 1440 } 1441 add_action( 'media_buttons', 'media_buttons' ); 1442 1443 function _media_button($title, $icon, $type) { 1444 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>"; 1445 } 1446 1447 function get_upload_iframe_src($type) { 1448 global $post_ID, $temp_ID; 1449 $uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID); 1450 $upload_iframe_src = add_query_arg('post_id', $uploading_iframe_ID, 'media-upload.php'); 1451 1452 if ( 'media' != $type ) 1453 $upload_iframe_src = add_query_arg('type', $type, $upload_iframe_src); 1454 $upload_iframe_src = apply_filters($type . '_upload_iframe_src', $upload_iframe_src); 1455 1456 return add_query_arg('TB_iframe', true, $upload_iframe_src); 1457 } -
wp-admin/includes/taxonomy.php
194 194 * 195 195 * @since unknown 196 196 * 197 * @param unknown_type $post_id198 * @return unknown199 */200 function get_tags_to_edit( $post_id, $taxonomy = 'post_tag' ) {201 return get_terms_to_edit( $post_id, $taxonomy);202 }203 204 /**205 * {@internal Missing Short Description}}206 *207 * @since unknown208 *209 * @param unknown_type $post_id210 * @return unknown211 */212 function get_terms_to_edit( $post_id, $taxonomy = 'post_tag' ) {213 $post_id = (int) $post_id;214 if ( !$post_id )215 return false;216 217 $tags = wp_get_post_terms($post_id, $taxonomy, array());218 219 if ( !$tags )220 return false;221 222 if ( is_wp_error($tags) )223 return $tags;224 225 foreach ( $tags as $tag )226 $tag_names[] = $tag->name;227 $tags_to_edit = join( ',', $tag_names );228 $tags_to_edit = esc_attr( $tags_to_edit );229 $tags_to_edit = apply_filters( 'terms_to_edit', $tags_to_edit, $taxonomy );230 231 return $tags_to_edit;232 }233 234 /**235 * {@internal Missing Short Description}}236 *237 * @since unknown238 *239 197 * @param unknown_type $tag_name 240 198 * @return unknown 241 199 */ -
wp-admin/includes/post.php
348 348 return array( 'updated' => $updated, 'skipped' => $skipped, 'locked' => $locked ); 349 349 } 350 350 351 /**352 * Default post information to use when populating the "Write Post" form.353 *354 * @since unknown355 *356 * @param string $post_type A post type string, defaults to 'post'.357 * @return object stdClass object containing all the default post data as attributes358 */359 function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) {360 global $wpdb;361 351 362 $post_title = '';363 if ( !empty( $_REQUEST['post_title'] ) )364 $post_title = esc_html( stripslashes( $_REQUEST['post_title'] ));365 352 366 $post_content = '';367 if ( !empty( $_REQUEST['content'] ) )368 $post_content = esc_html( stripslashes( $_REQUEST['content'] ));369 370 $post_excerpt = '';371 if ( !empty( $_REQUEST['excerpt'] ) )372 $post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] ));373 374 if ( $create_in_db ) {375 // Cleanup old auto-drafts more than 7 days old376 $old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" );377 foreach ( (array) $old_posts as $delete )378 wp_delete_post( $delete, true ); // Force delete379 $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) );380 $post = get_post( $post_id );381 } else {382 $post->ID = 0;383 $post->post_author = '';384 $post->post_date = '';385 $post->post_date_gmt = '';386 $post->post_password = '';387 $post->post_type = $post_type;388 $post->post_status = 'draft';389 $post->to_ping = '';390 $post->pinged = '';391 $post->comment_status = get_option( 'default_comment_status' );392 $post->ping_status = get_option( 'default_ping_status' );393 $post->post_pingback = get_option( 'default_pingback_flag' );394 $post->post_category = get_option( 'default_category' );395 $post->page_template = 'default';396 $post->post_parent = 0;397 $post->menu_order = 0;398 }399 400 $post->post_content = apply_filters( 'default_content', $post_content, $post );401 $post->post_title = apply_filters( 'default_title', $post_title, $post );402 $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post );403 $post->post_name = '';404 405 return $post;406 }407 408 353 /** 409 354 * Get the default page information to use. 410 355 * -
wp-admin/includes/dashboard.php
429 429 } 430 430 431 431 $post_ID = (int) $post->ID; 432 ?>433 432 434 <form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press"> 435 <h4 id="quick-post-title"><label for="title"><?php _e('Title') ?></label></h4> 436 <div class="input-text-wrap"> 437 <input type="text" name="post_title" id="title" tabindex="1" autocomplete="off" value="<?php echo esc_attr( $post->post_title ); ?>" /> 438 </div> 433 wp_quickpress_form( array('form_id' => 'dashboard') ); 439 434 440 <?php if ( current_user_can( 'upload_files' ) ) : ?>441 <div id="media-buttons" class="hide-if-no-js">442 <?php do_action( 'media_buttons' ); ?>443 </div>444 <?php endif; ?>445 446 <h4 id="content-label"><label for="content"><?php _e('Content') ?></label></h4>447 <div class="textarea-wrap">448 <textarea name="content" id="content" class="mceEditor" rows="3" cols="15" tabindex="2"><?php echo $post->post_content; ?></textarea>449 </div>450 451 <script type="text/javascript">edCanvas = document.getElementById('content');edInsertContent = null;</script>452 453 <h4><label for="tags-input"><?php _e('Tags') ?></label></h4>454 <div class="input-text-wrap">455 <input type="text" name="tags_input" id="tags-input" tabindex="3" value="<?php echo get_tags_to_edit( $post->ID ); ?>" />456 </div>457 458 <p class="submit">459 <input type="hidden" name="action" id="quickpost-action" value="post-quickpress-save" />460 <input type="hidden" name="quickpress_post_ID" value="<?php echo $post_ID; ?>" />461 <input type="hidden" name="post_type" value="post" />462 <?php wp_nonce_field('add-post'); ?>463 <input type="submit" name="save" id="save-post" class="button" tabindex="4" value="<?php esc_attr_e('Save Draft'); ?>" />464 <input type="reset" value="<?php esc_attr_e( 'Reset' ); ?>" class="button" />465 <span id="publishing-action">466 <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'); ?>" />467 <img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" />468 </span>469 <br class="clear" />470 </p>471 472 </form>473 474 <?php475 435 if ( $drafts ) 476 436 wp_dashboard_recent_drafts( $drafts ); 477 437 } -
wp-admin/includes/media.php
349 349 * {@internal Missing Short Description}} 350 350 * 351 351 * @since unknown 352 */353 function media_buttons() {354 $do_image = $do_audio = $do_video = true;355 if ( is_multisite() ) {356 $media_buttons = get_site_option( 'mu_media_buttons' );357 if ( empty($media_buttons['image']) )358 $do_image = false;359 if ( empty($media_buttons['audio']) )360 $do_audio = false;361 if ( empty($media_buttons['video']) )362 $do_video = false;363 }364 $out = '';365 366 if ( $do_image )367 $out .= _media_button(__('Add an Image'), 'images/media-button-image.gif?ver=20100531', 'image');368 if ( $do_video )369 $out .= _media_button(__('Add Video'), 'images/media-button-video.gif?ver=20100531', 'video');370 if ( $do_audio )371 $out .= _media_button(__('Add Audio'), 'images/media-button-music.gif?ver=20100531', 'audio');372 373 $out .= _media_button(__('Add Media'), 'images/media-button-other.gif?ver=20100531', 'media');374 375 $context = apply_filters('media_buttons_context', __('Upload/Insert %s'));376 377 printf($context, $out);378 }379 add_action( 'media_buttons', 'media_buttons' );380 381 function _media_button($title, $icon, $type) {382 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>";383 }384 385 function get_upload_iframe_src($type) {386 global $post_ID, $temp_ID;387 $uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID);388 $upload_iframe_src = add_query_arg('post_id', $uploading_iframe_ID, 'media-upload.php');389 390 if ( 'media' != $type )391 $upload_iframe_src = add_query_arg('type', $type, $upload_iframe_src);392 $upload_iframe_src = apply_filters($type . '_upload_iframe_src', $upload_iframe_src);393 394 return add_query_arg('TB_iframe', true, $upload_iframe_src);395 }396 397 /**398 * {@internal Missing Short Description}}399 352 * 400 * @since unknown401 *402 353 * @return unknown 403 354 */ 404 355 function media_upload_form_handler() { -
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
282 282 margin: 0 0 1em 5em; 283 283 } 284 284 285 #dashboard_quick_press # media-buttons {285 #dashboard_quick_press #dashboard-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 #dashboard-media-buttons a { 292 292 vertical-align: bottom; 293 293 } 294 294 … … 314 314 margin: 4px 6px 0 0; 315 315 } 316 316 317 #dashboard-media-buttons { 318 cursor: default; 319 padding: 8px 8px 0; 320 } 321 322 #dashboard-media-buttons a { 323 cursor: pointer; 324 padding: 0 0 5px 10px; 325 } 326 327 #dashboard-media-buttons img, 328 { 329 vertical-align: middle; 330 } 331 317 332 /* Recent Drafts */ 318 333 #dashboard_recent_drafts ul { 319 334 margin: 0;