Changeset 15691 for trunk/wp-includes/post.php
- Timestamp:
- 10/03/2010 07:41:48 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post.php
r15688 r15691 4772 4772 return $post; 4773 4773 } 4774 4775 /** 4776 * Returns or echos a form containing a post box. 4777 * 4778 * Used for the QuickPress dashboard module. 4779 * 4780 * @since 3.1.0 4781 * 4782 * @param array $args Arguments. 4783 * @param string $post_type Post type. 4784 */ 4785 function wp_quickpress_form( $args = array(), $post_type = 'post'){ 4786 global $post_ID; 4787 4788 $fields = array( 4789 'title' => array( 4790 'capability' => '', // Capability to check before outputing field 4791 'output' => '<h4 id="%s-title"><label for="title">'. __('Title') .'</label></h4> 4792 <div class="input-text-wrap"> 4793 <input type="text" name="post_title" id="%s-title" tabindex="%d" autocomplete="off" value="'. esc_attr( $post->post_title ).'" /> 4794 </div>' 4795 ), 4796 'media_buttons' => array( 4797 'capability' => 'upload_files', 4798 'output' => '<div id="%s-media-buttons" class="hide-if-no-js">'. get_media_buttons() .'</div>', 4799 ), 4800 'content' => array( 4801 'capability' => '', 4802 'output' => '<h4 id="%s-content-label"><label for="content">'. __('Content') .'</label></h4> 4803 <div class="textarea-wrap"> 4804 <textarea name="content" id="%s-content" class="mceEditor" rows="3" cols="15" tabindex="%d">'. $post->post_content.'</textarea> 4805 </div> 4806 '." <script type='text/javascript'>edCanvas = document.getElementById('content');edInsertContent = null;</script> 4807 " 4808 4809 ), 4810 'tags' => array( 4811 'capability' =>'', 4812 'output' => ' 4813 <h4><label for="%s-tags-input">'. __('Tags') .'</label></h4> 4814 <div class="input-text-wrap"> 4815 <input type="text" name="%s-tags_input" id="tags-input" tabindex="%d" value="'. get_tags_to_edit( $post->ID ) .'" /> 4816 </div> 4817 ' 4818 ), 4819 4820 ); 4821 4822 $hidden_fields = array( 4823 'action' => '<input type="hidden" name="action" id="quickpost-action" value="'.$post_type.'-quickpress-save" />', 4824 'post_id' => '<input type="hidden" name="quickpress_post_ID" value="'. $post_ID .'" />', 4825 'post_type' => '<input type="hidden" name="post_type" value="'.$post_type.'" />', 4826 ); 4827 4828 $submit_fields = array( 4829 'save' => '<input type="submit" name="save" id="save-post" class="button" tabindex="%s" value="'. esc_attr('Save Draft') .'" />', 4830 'reset' => '<input type="reset" tabindex="%s" value="'. esc_attr( 'Reset' ).'" class="button" />', 4831 ); 4832 4833 $publishing_action = current_user_can('publish_posts') ? esc_attr('Publish') : esc_attr('Submit for Review'); 4834 4835 $publishing_fields = array( 4836 'submit' => '<input type="submit" name="publish" id="publish" accesskey="p" tabindex="%s" class="button-primary" value="' . $publishing_action . '" />', 4837 /*'test' => '<input type="submit" name="publish" id="publish" accesskey="p" tabindex="%n" class="button-primary" value="'. esc_attr('Publish') .'" />', */ 4838 4839 ); 4840 4841 $defaults = array( 4842 'action' => admin_url( 'post.php' ), 4843 'fields' => $fields, 4844 'form_id' => '', 4845 'default_cap' => 'edit_posts', 4846 'tabindex_start' => '1', 4847 'ajax' => true, 4848 'hidden_fields' => $hidden_fields, 4849 'submit_fields' => $submit_fields, 4850 'publishing_fields' => $publishing_fields, 4851 'submit_class' => 'submit', 4852 'publish_action_container' => 'span', 4853 'publish_action_id' => 'publishing-action', 4854 'hidden_and_submit_fields_container' => 'p', 4855 'hidden_and_submit_fields_container_class' => 'submit', 4856 ); 4857 4858 $args = wp_parse_args($args, $defaults); 4859 4860 $tabindex = apply_filters( 'quickpress_tabindex_start', $args['tabindex_start'], $args['form_id'] ); 4861 4862 if ( current_user_can( $args['default_cap'] ) ): ?> 4863 <?php do_action('quickpress_form_before_form', $args['form_id'] ); ?> 4864 <form name="post" action="<?php echo $args['action'] ?>" method="post" id="<?php echo $args['form_id']; ?>"> 4865 <?php do_action('quickpress_form_before_fields', $args['form_id']); 4866 4867 $fields = apply_filters( 'quickpress_fields', $args['fields'], $args['form_id'] ); 4868 foreach ($fields as $title => $field){ 4869 if ( empty( $field['capability'] ) || current_user_can( $field['capability'] ) ){ 4870 printf( $field['output'], $args['form_id'], $args['form_id'], $tabindex ); 4871 $tabindex++; 4872 } 4873 } 4874 //Hidden Fields 4875 do_action('quickpress_form_after_fields', $args['form_id'] ); 4876 4877 echo "<{$args['hidden_and_submit_fields_container']} class='{$args['hidden_and_submit_fields_container_class']}'>"; 4878 4879 $hidden_fields = apply_filters( 'quickpress_hidden_fields', $args['hidden_fields'] , $args['form_id'] ); 4880 4881 foreach( $hidden_fields as $hidden_field ) 4882 echo $hidden_field; 4883 4884 // nonce 4885 wp_nonce_field('add-post'); 4886 4887 // submit 4888 foreach( $args['submit_fields'] as $submit_field ) 4889 printf( $submit_field, $tabindex++ ); 4890 4891 // publish 4892 echo "<{$args['publish_action_container']} id='{$args['publish_action_id']}'>"; 4893 4894 $publishing_fields = apply_filters( 'quickpress_publishing_fields', $args['publishing_fields'] , $args['form_id'] ); 4895 4896 foreach( $publishing_fields as $publishing_field) { 4897 printf( $publishing_field, $tabindex ); 4898 $tabindex++; 4899 } 4900 4901 if ($args['ajax'] == true) 4902 echo '<img class="waiting" src="'. esc_url( admin_url( 'images/wpspin_light.gif' ) ) .'" />'; 4903 4904 echo "</{$args['publish_action_container']}>"; 4905 echo "<br class='clear' />"; 4906 do_action( 'quickpress_form_after_submit_fields', $args['form_id']); 4907 4908 echo "</{$args['hidden_and_submit_fields_container']}"; 4909 do_action( 'quickpress_form_after_form_content', $args['form_id']); 4910 echo '</form>'; 4911 do_action('quickpress_form_after_form', $args['form_id'] ); 4912 else: 4913 do_action( 'quickpress_form_no_form', $args['form_id'] ); 4914 endif; 4915 } 4916 4917 ?>
Note: See TracChangeset
for help on using the changeset viewer.