[44] | 1 | <?php
|
---|
| 2 | /**
|
---|
| 3 | * Post advanced form for inclusion in the administration panels.
|
---|
| 4 | *
|
---|
| 5 | * @package WordPress
|
---|
| 6 | * @subpackage Administration
|
---|
| 7 | */
|
---|
| 8 |
|
---|
| 9 | /**
|
---|
| 10 | * Post ID global
|
---|
| 11 | * @name $post_ID
|
---|
| 12 | * @var int
|
---|
| 13 | */
|
---|
| 14 | $post_ID = isset($post_ID) ? (int) $post_ID : 0;
|
---|
| 15 |
|
---|
| 16 | $action = isset($action) ? $action : '';
|
---|
| 17 | if ( isset($_GET['message']) )
|
---|
| 18 | $_GET['message'] = absint( $_GET['message'] );
|
---|
| 19 | $messages[1] = sprintf(__('Post updated. <a href="%s">View post</a>'), get_permalink($post_ID));
|
---|
| 20 | $messages[2] = __('Custom field updated.');
|
---|
| 21 | $messages[3] = __('Custom field deleted.');
|
---|
| 22 | $messages[4] = __('Post updated.');
|
---|
| 23 | $messages[6] = sprintf(__('Post published. <a href="%s">View post</a>'), get_permalink($post_ID));
|
---|
| 24 | $messages[7] = __('Post saved.');
|
---|
| 25 | $messages[8] = sprintf(__('Post submitted. <a href="%s">Preview post</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) );
|
---|
| 26 |
|
---|
| 27 | if ( isset($_GET['revision']) )
|
---|
| 28 | $messages[5] = sprintf( __('Post restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) );
|
---|
| 29 |
|
---|
| 30 | $notice = false;
|
---|
| 31 | $notices[1] = __( 'There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>.' );
|
---|
| 32 |
|
---|
| 33 | if ( 0 == $post_ID ) {
|
---|
| 34 | $form_action = 'post';
|
---|
| 35 | $temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post()
|
---|
| 36 | $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='" . esc_attr($temp_ID) . "' />";
|
---|
| 37 | $autosave = false;
|
---|
| 38 | } else {
|
---|
| 39 | $form_action = 'editpost';
|
---|
| 40 | $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr($post_ID) . "' />";
|
---|
| 41 | $autosave = wp_get_post_autosave( $post_ID );
|
---|
| 42 |
|
---|
| 43 | // Detect if there exists an autosave newer than the post and if that autosave is different than the post
|
---|
| 44 | if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
|
---|
| 45 | foreach ( _wp_post_revision_fields() as $autosave_field => $_autosave_field ) {
|
---|
| 46 | if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) {
|
---|
| 47 | $notice = sprintf( $notices[1], get_edit_post_link( $autosave->ID ) );
|
---|
| 48 | break;
|
---|
| 49 | }
|
---|
| 50 | }
|
---|
| 51 | unset($autosave_field, $_autosave_field);
|
---|
| 52 | }
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | // All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action).
|
---|
| 56 |
|
---|
| 57 | /**
|
---|
| 58 | * Display post submit form fields.
|
---|
| 59 | *
|
---|
| 60 | * @since 2.7.0
|
---|
| 61 | *
|
---|
| 62 | * @param object $post
|
---|
| 63 | */
|
---|
| 64 | function post_submit_meta_box($post) {
|
---|
| 65 | global $action;
|
---|
| 66 |
|
---|
| 67 | $can_publish = current_user_can('publish_posts');
|
---|
| 68 | ?>
|
---|
| 69 | <div class="submitbox" id="submitpost">
|
---|
| 70 |
|
---|
| 71 | <div id="minor-publishing">
|
---|
| 72 |
|
---|
| 73 | <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
|
---|
| 74 | <div style="display:none;">
|
---|
| 75 | <input type="submit" name="save" value="<?php esc_attr_e('Save'); ?>" />
|
---|
| 76 | </div>
|
---|
| 77 |
|
---|
| 78 | <div id="minor-publishing-actions">
|
---|
| 79 | <div id="save-action">
|
---|
| 80 | <?php if ( 'publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?>
|
---|
| 81 | <input <?php if ( 'private' == $post->post_status ) { ?>style="display:none"<?php } ?> type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save Draft'); ?>" tabindex="4" class="button button-highlighted" />
|
---|
| 82 | <?php } elseif ( 'pending' == $post->post_status && $can_publish ) { ?>
|
---|
| 83 | <input type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save as Pending'); ?>" tabindex="4" class="button button-highlighted" />
|
---|
| 84 | <?php } ?>
|
---|
| 85 | </div>
|
---|
| 86 |
|
---|
| 87 | <div id="preview-action">
|
---|
| 88 | <?php
|
---|
| 89 | if ( 'publish' == $post->post_status ) {
|
---|
| 90 | $preview_link = esc_url(get_permalink($post->ID));
|
---|
| 91 | $preview_button = __('Preview Changes');
|
---|
| 92 | } else {
|
---|
| 93 | $preview_link = esc_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID))));
|
---|
| 94 | $preview_button = __('Preview');
|
---|
| 95 | }
|
---|
| 96 | ?>
|
---|
| 97 | <a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview" id="post-preview" tabindex="4"><?php echo $preview_button; ?></a>
|
---|
| 98 | <input type="hidden" name="wp-preview" id="wp-preview" value="" />
|
---|
| 99 | </div>
|
---|
| 100 |
|
---|
| 101 | <div class="clear"></div>
|
---|
| 102 | </div><?php // /minor-publishing-actions ?>
|
---|
| 103 |
|
---|
| 104 | <div id="misc-publishing-actions">
|
---|
| 105 |
|
---|
| 106 | <div class="misc-pub-section<?php if ( !$can_publish ) { echo ' misc-pub-section-last'; } ?>"><label for="post_status"><?php _e('Status:') ?></label>
|
---|
| 107 | <span id="post-status-display">
|
---|
| 108 | <?php
|
---|
| 109 | switch ( $post->post_status ) {
|
---|
| 110 | case 'private':
|
---|
| 111 | _e('Privately Published');
|
---|
| 112 | break;
|
---|
| 113 | case 'publish':
|
---|
| 114 | _e('Published');
|
---|
| 115 | break;
|
---|
| 116 | case 'future':
|
---|
| 117 | _e('Scheduled');
|
---|
| 118 | break;
|
---|
| 119 | case 'pending':
|
---|
| 120 | _e('Pending Review');
|
---|
| 121 | break;
|
---|
| 122 | case 'draft':
|
---|
| 123 | _e('Draft');
|
---|
| 124 | break;
|
---|
| 125 | }
|
---|
| 126 | ?>
|
---|
| 127 | </span>
|
---|
| 128 | <?php if ( 'publish' == $post->post_status || 'private' == $post->post_status || $can_publish ) { ?>
|
---|
| 129 | <a href="#post_status" <?php if ( 'private' == $post->post_status ) { ?>style="display:none;" <?php } ?>class="edit-post-status hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a>
|
---|
| 130 |
|
---|
| 131 | <div id="post-status-select" class="hide-if-js">
|
---|
| 132 | <input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr($post->post_status); ?>" />
|
---|
| 133 | <select name='post_status' id='post_status' tabindex='4'>
|
---|
| 134 | <?php if ( 'publish' == $post->post_status ) : ?>
|
---|
| 135 | <option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e('Published') ?></option>
|
---|
| 136 | <?php elseif ( 'private' == $post->post_status ) : ?>
|
---|
| 137 | <option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e('Privately Published') ?></option>
|
---|
| 138 | <?php elseif ( 'future' == $post->post_status ) : ?>
|
---|
| 139 | <option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option>
|
---|
| 140 | <?php endif; ?>
|
---|
| 141 | <option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option>
|
---|
| 142 | <option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Draft') ?></option>
|
---|
| 143 | </select>
|
---|
| 144 | <a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e('OK'); ?></a>
|
---|
| 145 | <a href="#post_status" class="cancel-post-status hide-if-no-js"><?php _e('Cancel'); ?></a>
|
---|
| 146 | </div>
|
---|
| 147 |
|
---|
| 148 | <?php } ?>
|
---|
| 149 | </div><?php // /misc-pub-section ?>
|
---|
| 150 |
|
---|
| 151 | <div class="misc-pub-section " id="visibility">
|
---|
| 152 | <?php _e('Visibility:'); ?> <span id="post-visibility-display"><?php
|
---|
| 153 |
|
---|
| 154 | if ( 'private' == $post->post_status ) {
|
---|
| 155 | $post->post_password = '';
|
---|
| 156 | $visibility = 'private';
|
---|
| 157 | $visibility_trans = __('Private');
|
---|
| 158 | } elseif ( !empty( $post->post_password ) ) {
|
---|
| 159 | $visibility = 'password';
|
---|
| 160 | $visibility_trans = __('Password protected');
|
---|
| 161 | } elseif ( is_sticky( $post->ID ) ) {
|
---|
| 162 | $visibility = 'public';
|
---|
| 163 | $visibility_trans = __('Public, Sticky');
|
---|
| 164 | } else {
|
---|
| 165 | $visibility = 'public';
|
---|
| 166 | $visibility_trans = __('Public');
|
---|
| 167 | }
|
---|
| 168 |
|
---|
| 169 | ?><?php echo esc_html( $visibility_trans ); ?></span> <?php if ( $can_publish ) { ?> <a href="#visibility" class="edit-visibility hide-if-no-js"><?php _e('Edit'); ?></a>
|
---|
| 170 |
|
---|
| 171 | <div id="post-visibility-select" class="hide-if-js">
|
---|
| 172 | <input type="hidden" name="hidden_post_password" id="hidden-post-password" value="<?php echo esc_attr($post->post_password); ?>" />
|
---|
| 173 | <input type="checkbox" style="display:none" name="hidden_post_sticky" id="hidden-post-sticky" value="sticky" <?php checked(is_sticky($post->ID)); ?> />
|
---|
| 174 | <input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo esc_attr( $visibility ); ?>" />
|
---|
| 175 |
|
---|
| 176 |
|
---|
| 177 | <input type="radio" name="visibility" id="visibility-radio-public" value="public" <?php checked( $visibility, 'public' ); ?> /> <label for="visibility-radio-public" class="selectit"><?php _e('Public'); ?></label><br />
|
---|
| 178 | <span id="sticky-span"><input id="sticky" name="sticky" type="checkbox" value="sticky" <?php checked(is_sticky($post->ID)); ?> tabindex="4" /> <label for="sticky" class="selectit"><?php _e('Stick this post to the front page') ?></label><br /></span>
|
---|
| 179 | <input type="radio" name="visibility" id="visibility-radio-password" value="password" <?php checked( $visibility, 'password' ); ?> /> <label for="visibility-radio-password" class="selectit"><?php _e('Password protected'); ?></label><br />
|
---|
| 180 | <span id="password-span"><label for="post_password"><?php _e('Password:'); ?></label> <input type="text" name="post_password" id="post_password" value="<?php echo esc_attr($post->post_password); ?>" /><br /></span>
|
---|
| 181 | <input type="radio" name="visibility" id="visibility-radio-private" value="private" <?php checked( $visibility, 'private' ); ?> /> <label for="visibility-radio-private" class="selectit"><?php _e('Private'); ?></label><br />
|
---|
| 182 |
|
---|
| 183 | <p>
|
---|
| 184 | <a href="#visibility" class="save-post-visibility hide-if-no-js button"><?php _e('OK'); ?></a>
|
---|
| 185 | <a href="#visibility" class="cancel-post-visibility hide-if-no-js"><?php _e('Cancel'); ?></a>
|
---|
| 186 | </p>
|
---|
| 187 | </div>
|
---|
| 188 | <?php } ?>
|
---|
| 189 |
|
---|
| 190 | </div><?php // /misc-pub-section ?>
|
---|
| 191 |
|
---|
| 192 |
|
---|
| 193 | <?php
|
---|
| 194 | // translators: Publish box date formt, see http://php.net/date
|
---|
| 195 | $datef = __( 'M j, Y @ G:i' );
|
---|
| 196 | if ( 0 != $post->ID ) {
|
---|
| 197 | if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date
|
---|
| 198 | $stamp = __('Scheduled for: <b>%1$s</b>');
|
---|
| 199 | } else if ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published
|
---|
| 200 | $stamp = __('Published on: <b>%1$s</b>');
|
---|
| 201 | } else if ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified
|
---|
| 202 | $stamp = __('Publish <b>immediately</b>');
|
---|
| 203 | } else if ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified
|
---|
| 204 | $stamp = __('Schedule for: <b>%1$s</b>');
|
---|
| 205 | } else { // draft, 1 or more saves, date specified
|
---|
| 206 | $stamp = __('Publish on: <b>%1$s</b>');
|
---|
| 207 | }
|
---|
| 208 | $date = date_i18n( $datef, strtotime( $post->post_date ) );
|
---|
| 209 | } else { // draft (no saves, and thus no date specified)
|
---|
| 210 | $stamp = __('Publish <b>immediately</b>');
|
---|
| 211 | $date = date_i18n( $datef, strtotime( current_time('mysql') ) );
|
---|
| 212 | }
|
---|
| 213 |
|
---|
| 214 | if ( $can_publish ) : // Contributors don't get to choose the date of publish ?>
|
---|
| 215 | <div class="misc-pub-section curtime misc-pub-section-last">
|
---|
| 216 | <span id="timestamp">
|
---|
| 217 | <?php printf($stamp, $date); ?></span>
|
---|
| 218 | <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a>
|
---|
| 219 | <div id="timestampdiv" class="hide-if-js"><?php touch_time(($action == 'edit'),1,4); ?></div>
|
---|
| 220 | </div><?php // /misc-pub-section ?>
|
---|
| 221 | <?php endif; ?>
|
---|
| 222 |
|
---|
| 223 | </div>
|
---|
| 224 | <div class="clear"></div>
|
---|
| 225 | </div>
|
---|
| 226 |
|
---|
| 227 | <div id="major-publishing-actions">
|
---|
| 228 | <?php do_action('post_submitbox_start'); ?>
|
---|
| 229 | <div id="delete-action">
|
---|
| 230 | <?php
|
---|
| 231 | if ( ( 'edit' == $action ) && current_user_can('delete_post', $post->ID) ) { ?>
|
---|
| 232 | <a class="submitdelete deletion" href="<?php echo wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID); ?>" onclick="if ( confirm('<?php echo esc_js(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )); ?>') ) {return true;}return false;"><?php _e('Delete'); ?></a>
|
---|
| 233 | <?php } ?>
|
---|
| 234 | </div>
|
---|
| 235 |
|
---|
| 236 | <div id="publishing-action">
|
---|
| 237 | <?php
|
---|
| 238 | if ( !in_array( $post->post_status, array('publish', 'future', 'private') ) || 0 == $post->ID ) {
|
---|
| 239 | if ( current_user_can('publish_posts') ) :
|
---|
| 240 | if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?>
|
---|
| 241 | <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Schedule') ?>" />
|
---|
| 242 | <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php esc_attr_e('Schedule') ?>" />
|
---|
| 243 | <?php else : ?>
|
---|
| 244 | <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Publish') ?>" />
|
---|
| 245 | <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php esc_attr_e('Publish') ?>" />
|
---|
| 246 | <?php endif;
|
---|
| 247 | else : ?>
|
---|
| 248 | <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Submit for Review') ?>" />
|
---|
| 249 | <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php esc_attr_e('Submit for Review') ?>" />
|
---|
| 250 | <?php
|
---|
| 251 | endif;
|
---|
| 252 | } else { ?>
|
---|
| 253 | <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Update Post') ?>" />
|
---|
| 254 | <input name="save" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php esc_attr_e('Update Post') ?>" />
|
---|
| 255 | <?php
|
---|
| 256 | } ?>
|
---|
| 257 | </div>
|
---|
| 258 | <div class="clear"></div>
|
---|
| 259 | </div>
|
---|
| 260 | </div>
|
---|
| 261 |
|
---|
| 262 | <?php
|
---|
| 263 | }
|
---|
| 264 | add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', 'post', 'side', 'core');
|
---|
| 265 |
|
---|
| 266 | /**
|
---|
| 267 | * Display post tags form fields.
|
---|
| 268 | *
|
---|
| 269 | * @since 2.6.0
|
---|
| 270 | *
|
---|
| 271 | * @param object $post
|
---|
| 272 | */
|
---|
| 273 | function post_tags_meta_box($post, $box) {
|
---|
| 274 | $tax_name = esc_attr(substr($box['id'], 8));
|
---|
| 275 | $taxonomy = get_taxonomy($tax_name);
|
---|
| 276 | $helps = isset($taxonomy->helps) ? esc_attr($taxonomy->helps) : __('Separate tags with commas.');
|
---|
| 277 | ?>
|
---|
| 278 | <div class="tagsdiv" id="<?php echo $tax_name; ?>">
|
---|
| 279 | <div class="jaxtag">
|
---|
| 280 | <div class="nojs-tags hide-if-js">
|
---|
| 281 | <p><?php _e('Add or remove tags'); ?></p>
|
---|
| 282 | <textarea name="<?php echo "tax_input[$tax_name]"; ?>" class="the-tags" id="tax-input[<?php echo $tax_name; ?>]"><?php echo esc_attr(get_terms_to_edit( $post->ID, $tax_name )); ?></textarea></div>
|
---|
| 283 |
|
---|
| 284 | <span class="ajaxtag hide-if-no-js">
|
---|
| 285 | <label class="screen-reader-text" for="new-tag-<?php echo $tax_name; ?>"><?php echo $box['title']; ?></label>
|
---|
| 286 | <input type="text" id="new-tag-<?php echo $tax_name; ?>" name="newtag[<?php echo $tax_name; ?>]" class="newtag form-input-tip" size="16" autocomplete="off" value="<?php esc_attr_e('Add new tag'); ?>" />
|
---|
| 287 | <input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" tabindex="3" />
|
---|
| 288 | </span></div>
|
---|
| 289 | <p class="howto"><?php echo $helps; ?></p>
|
---|
| 290 | <div class="tagchecklist"></div>
|
---|
| 291 | </div>
|
---|
| 292 | <p class="tagcloud-link hide-if-no-js"><a href="#titlediv" class="tagcloud-link" id="link-<?php echo $tax_name; ?>"><?php printf( __('Choose from the most used tags in %s'), $box['title'] ); ?></a></p>
|
---|
| 293 | <?php
|
---|
| 294 | }
|
---|
| 295 |
|
---|
| 296 | // all tag-style post taxonomies
|
---|
| 297 | foreach ( get_object_taxonomies('post') as $tax_name ) {
|
---|
| 298 | if ( !is_taxonomy_hierarchical($tax_name) ) {
|
---|
| 299 | $taxonomy = get_taxonomy($tax_name);
|
---|
| 300 | $label = isset($taxonomy->label) ? esc_attr($taxonomy->label) : $tax_name;
|
---|
| 301 |
|
---|
| 302 | add_meta_box('tagsdiv-' . $tax_name, $label, 'post_tags_meta_box', 'post', 'side', 'core');
|
---|
| 303 | }
|
---|
| 304 | }
|
---|
| 305 |
|
---|
| 306 | /**
|
---|
| 307 | * Display post categories form fields.
|
---|
| 308 | *
|
---|
| 309 | * @since 2.6.0
|
---|
| 310 | *
|
---|
| 311 | * @param object $post
|
---|
| 312 | */
|
---|
| 313 | function post_categories_meta_box($post) {
|
---|
| 314 | ?>
|
---|
| 315 | <ul id="category-tabs">
|
---|
| 316 | <li class="tabs"><a href="#categories-all" tabindex="3"><?php _e( 'All Categories' ); ?></a></li>
|
---|
| 317 | <li class="hide-if-no-js"><a href="#categories-pop" tabindex="3"><?php _e( 'Most Used' ); ?></a></li>
|
---|
| 318 | </ul>
|
---|
| 319 |
|
---|
| 320 | <div id="categories-pop" class="tabs-panel" style="display: none;">
|
---|
| 321 | <ul id="categorychecklist-pop" class="categorychecklist form-no-clear" >
|
---|
| 322 | <?php $popular_ids = wp_popular_terms_checklist('category'); ?>
|
---|
| 323 | </ul>
|
---|
| 324 | </div>
|
---|
| 325 |
|
---|
| 326 | <div id="categories-all" class="tabs-panel">
|
---|
| 327 | <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
|
---|
| 328 | <?php wp_category_checklist($post->ID, false, false, $popular_ids) ?>
|
---|
| 329 | </ul>
|
---|
| 330 | </div>
|
---|
| 331 |
|
---|
| 332 | <?php if ( current_user_can('manage_categories') ) : ?>
|
---|
| 333 | <div id="category-adder" class="wp-hidden-children">
|
---|
| 334 | <h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4>
|
---|
| 335 | <p id="category-add" class="wp-hidden-child">
|
---|
| 336 | <label class="screen-reader-text" for="newcat"><?php _e( 'Add New Category' ); ?></label><input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php esc_attr_e( 'New category name' ); ?>" tabindex="3" aria-required="true"/>
|
---|
| 337 | <label class="screen-reader-text" for="newcat_parent"><?php _e('Parent category'); ?>:</label><?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?>
|
---|
| 338 | <input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php esc_attr_e( 'Add' ); ?>" tabindex="3" />
|
---|
| 339 | <?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?>
|
---|
| 340 | <span id="category-ajax-response"></span></p>
|
---|
| 341 | </div>
|
---|
| 342 | <?php
|
---|
| 343 | endif;
|
---|
| 344 |
|
---|
| 345 | }
|
---|
| 346 | add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', 'post', 'side', 'core');
|
---|
| 347 |
|
---|
| 348 | /**
|
---|
| 349 | * Display post password form fields.
|
---|
| 350 | *
|
---|
| 351 | * @since 2.6.0
|
---|
| 352 | *
|
---|
| 353 | * @param object $post
|
---|
| 354 | */
|
---|
| 355 | function post_password_meta_box($post) {
|
---|
| 356 | ?>
|
---|
| 357 | <p><label for="post_status_private" class="selectit"><input id="post_status_private" name="post_status" type="checkbox" value="private" <?php checked($post->post_status, 'private'); ?> tabindex="4" /> <?php _e('Keep this post private') ?></label></p>
|
---|
| 358 | <h4><?php _e( 'Post Password' ); ?></h4>
|
---|
| 359 | <p><label class="screen-reader-text" for="post_password"><?php _e('Password Protect This Post') ?></label><input name="post_password" type="text" size="25" id="post_password" value="<?php the_post_password(); ?>" /></p>
|
---|
| 360 | <p><?php _e('Setting a password will require people who visit your blog to enter the above password to view this post and its comments.'); ?></p>
|
---|
| 361 | <?php
|
---|
| 362 | }
|
---|
| 363 | // add_meta_box('passworddiv', __('Privacy Options'), 'post_password_meta_box', 'post', 'side', 'core');
|
---|
| 364 |
|
---|
| 365 | /**
|
---|
| 366 | * Display post excerpt form fields.
|
---|
| 367 | *
|
---|
| 368 | * @since 2.6.0
|
---|
| 369 | *
|
---|
| 370 | * @param object $post
|
---|
| 371 | */
|
---|
| 372 | function post_excerpt_meta_box($post) {
|
---|
| 373 | ?>
|
---|
| 374 | <label class="screen-reader-text" for="excerpt"><?php _e('Excerpt') ?></label><textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt"><?php echo $post->post_excerpt ?></textarea>
|
---|
| 375 | <p><?php _e('Excerpts are optional hand-crafted summaries of your content that can be used in your theme. <a href="http://codex.wordpress.org/Excerpt" target="_blank">Learn more about manual excerpts.</a>'); ?></p>
|
---|
| 376 | <?php
|
---|
| 377 | }
|
---|
| 378 | add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'post', 'normal', 'core');
|
---|
| 379 |
|
---|
| 380 | /**
|
---|
| 381 | * Display trackback links form fields.
|
---|
| 382 | *
|
---|
| 383 | * @since 2.6.0
|
---|
| 384 | *
|
---|
| 385 | * @param object $post
|
---|
| 386 | */
|
---|
| 387 | function post_trackback_meta_box($post) {
|
---|
| 388 | $form_trackback = '<input type="text" name="trackback_url" id="trackback_url" class="code" tabindex="7" value="'. esc_attr( str_replace("\n", ' ', $post->to_ping) ) .'" />';
|
---|
| 389 | if ('' != $post->pinged) {
|
---|
| 390 | $pings = '<p>'. __('Already pinged:') . '</p><ul>';
|
---|
| 391 | $already_pinged = explode("\n", trim($post->pinged));
|
---|
| 392 | foreach ($already_pinged as $pinged_url) {
|
---|
| 393 | $pings .= "\n\t<li>" . esc_html($pinged_url) . "</li>";
|
---|
| 394 | }
|
---|
| 395 | $pings .= '</ul>';
|
---|
| 396 | }
|
---|
| 397 |
|
---|
| 398 | ?>
|
---|
| 399 | <p><label for="trackback_url"><?php _e('Send trackbacks to:'); ?></label> <?php echo $form_trackback; ?><br /> (<?php _e('Separate multiple URLs with spaces'); ?>)</p>
|
---|
| 400 | <p><?php _e('Trackbacks are a way to notify legacy blog systems that you’ve linked to them. If you link other WordPress blogs they’ll be notified automatically using <a href="http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments" target="_blank">pingbacks</a>, no other action necessary.'); ?></p>
|
---|
| 401 | <?php
|
---|
| 402 | if ( ! empty($pings) )
|
---|
| 403 | echo $pings;
|
---|
| 404 | }
|
---|
| 405 | add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', 'post', 'normal', 'core');
|
---|
| 406 |
|
---|
| 407 | /**
|
---|
| 408 | * Display custom fields for the post form fields.
|
---|
| 409 | *
|
---|
| 410 | * @since 2.6.0
|
---|
| 411 | *
|
---|
| 412 | * @param object $post
|
---|
| 413 | */
|
---|
| 414 | function post_custom_meta_box($post) {
|
---|
| 415 | ?>
|
---|
| 416 | <div id="postcustomstuff">
|
---|
| 417 | <div id="ajax-response"></div>
|
---|
| 418 | <?php
|
---|
| 419 | $metadata = has_meta($post->ID);
|
---|
| 420 | list_meta($metadata);
|
---|
| 421 | meta_form(); ?>
|
---|
| 422 | </div>
|
---|
| 423 | <p><?php _e('Custom fields can be used to add extra metadata to a post that you can <a href="http://codex.wordpress.org/Using_Custom_Fields" target="_blank">use in your theme</a>.'); ?></p>
|
---|
| 424 | <?php
|
---|
| 425 | }
|
---|
| 426 | add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', 'post', 'normal', 'core');
|
---|
| 427 |
|
---|
| 428 | do_action('dbx_post_advanced');
|
---|
| 429 |
|
---|
| 430 | /**
|
---|
| 431 | * Display comment status for post form fields.
|
---|
| 432 | *
|
---|
| 433 | * @since 2.6.0
|
---|
| 434 | *
|
---|
| 435 | * @param object $post
|
---|
| 436 | */
|
---|
| 437 | function post_comment_status_meta_box($post) {
|
---|
| 438 | ?>
|
---|
| 439 | <input name="advanced_view" type="hidden" value="1" />
|
---|
| 440 | <p class="meta-options">
|
---|
| 441 | <label for="comment_status" class="selectit"> <input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> /> <?php _e('Allow comments on this post') ?></label><br />
|
---|
| 442 | <label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php _e('Allow <a href="http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments" target="_blank">trackbacks and pingbacks</a> on this post') ?></label></p>
|
---|
| 443 | <?php
|
---|
| 444 | }
|
---|
| 445 | add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', 'post', 'normal', 'core');
|
---|
| 446 |
|
---|
| 447 | /**
|
---|
| 448 | * Display comments for post.
|
---|
| 449 | *
|
---|
| 450 | * @since 2.8.0
|
---|
| 451 | *
|
---|
| 452 | * @param object $post
|
---|
| 453 | */
|
---|
| 454 | function post_comment_meta_box($post) {
|
---|
| 455 | global $wpdb, $post_ID;
|
---|
| 456 |
|
---|
| 457 | $total = $wpdb->get_var($wpdb->prepare("SELECT count(1) FROM $wpdb->comments WHERE comment_post_ID = '%d' AND ( comment_approved = '0' OR comment_approved = '1')", $post_ID));
|
---|
| 458 |
|
---|
| 459 | if ( 1 > $total ) {
|
---|
| 460 | echo '<p>' . __('No comments yet.') . '</p>';
|
---|
| 461 | return;
|
---|
| 462 | }
|
---|
| 463 |
|
---|
| 464 | wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
|
---|
| 465 | ?>
|
---|
| 466 |
|
---|
| 467 | <table class="widefat comments-box fixed" cellspacing="0" style="display:none;">
|
---|
| 468 | <thead><tr>
|
---|
| 469 | <th scope="col" class="column-author"><?php _e('Author') ?></th>
|
---|
| 470 | <th scope="col" class="column-comment">
|
---|
| 471 | <?php /* translators: field name in comment form */ echo _x('Comment', 'noun'); ?></th>
|
---|
| 472 | </tr></thead>
|
---|
| 473 | <tbody id="the-comment-list" class="list:comment"></tbody>
|
---|
| 474 | </table>
|
---|
| 475 | <p class="hide-if-no-js"><a href="#commentstatusdiv" id="show-comments" onclick="commentsBox.get(<?php echo $total; ?>);return false;"><?php _e('Show comments'); ?></a> <img class="waiting" style="display:none;" src="images/wpspin_light.gif" alt="" /></p>
|
---|
| 476 | <?php
|
---|
| 477 | $hidden = get_hidden_meta_boxes('post');
|
---|
| 478 | if ( ! in_array('commentsdiv', $hidden) ) { ?>
|
---|
| 479 | <script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php echo $total; ?>, 10);});</script>
|
---|
| 480 | <?php
|
---|
| 481 | }
|
---|
| 482 | }
|
---|
| 483 | if ( 'publish' == $post->post_status || 'private' == $post->post_status )
|
---|
| 484 | add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', 'post', 'normal', 'core');
|
---|
| 485 |
|
---|
| 486 | /**
|
---|
| 487 | * Display post slug form fields.
|
---|
| 488 | *
|
---|
| 489 | * @since 2.6.0
|
---|
| 490 | *
|
---|
| 491 | * @param object $post
|
---|
| 492 | */
|
---|
| 493 | function post_slug_meta_box($post) {
|
---|
| 494 | ?>
|
---|
| 495 | <label class="screen-reader-text" for="post_name"><?php _e('Post Slug') ?></label><input name="post_name" type="text" size="13" id="post_name" value="<?php echo esc_attr( $post->post_name ); ?>" />
|
---|
| 496 | <?php
|
---|
| 497 | }
|
---|
| 498 | if ( !( 'pending' == $post->post_status && !current_user_can( 'publish_posts' ) ) )
|
---|
| 499 | add_meta_box('slugdiv', __('Post Slug'), 'post_slug_meta_box', 'post', 'normal', 'core');
|
---|
| 500 |
|
---|
| 501 | $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
|
---|
| 502 | if ( $post->post_author && !in_array($post->post_author, $authors) )
|
---|
| 503 | $authors[] = $post->post_author;
|
---|
| 504 | if ( $authors && count( $authors ) > 1 ) :
|
---|
| 505 | /**
|
---|
| 506 | * Display form field with list of authors.
|
---|
| 507 | *
|
---|
| 508 | * @since 2.6.0
|
---|
| 509 | *
|
---|
| 510 | * @param object $post
|
---|
| 511 | */
|
---|
| 512 | function post_author_meta_box($post) {
|
---|
| 513 | global $current_user, $user_ID;
|
---|
| 514 | $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
|
---|
| 515 | if ( $post->post_author && !in_array($post->post_author, $authors) )
|
---|
| 516 | $authors[] = $post->post_author;
|
---|
| 517 | ?>
|
---|
| 518 | <label class="screen-reader-text" for="post_author_override"><?php _e('Post Author'); ?></label><?php wp_dropdown_users( array('include' => $authors, 'name' => 'post_author_override', 'selected' => empty($post->ID) ? $user_ID : $post->post_author) ); ?>
|
---|
| 519 | <?php
|
---|
| 520 | }
|
---|
| 521 | add_meta_box('authordiv', __('Post Author'), 'post_author_meta_box', 'post', 'normal', 'core');
|
---|
| 522 | endif;
|
---|
| 523 |
|
---|
| 524 | if ( 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) :
|
---|
| 525 | /**
|
---|
| 526 | * Display list of post revisions.
|
---|
| 527 | *
|
---|
| 528 | * @since 2.6.0
|
---|
| 529 | *
|
---|
| 530 | * @param object $post
|
---|
| 531 | */
|
---|
| 532 | function post_revisions_meta_box($post) {
|
---|
| 533 | wp_list_post_revisions();
|
---|
| 534 | }
|
---|
| 535 | add_meta_box('revisionsdiv', __('Post Revisions'), 'post_revisions_meta_box', 'post', 'normal', 'core');
|
---|
| 536 | endif;
|
---|
| 537 |
|
---|
| 538 | do_action('do_meta_boxes', 'post', 'normal', $post);
|
---|
| 539 | do_action('do_meta_boxes', 'post', 'advanced', $post);
|
---|
| 540 | do_action('do_meta_boxes', 'post', 'side', $post);
|
---|
| 541 |
|
---|
| 542 | require_once('admin-header.php');
|
---|
| 543 |
|
---|
| 544 | ?>
|
---|
| 545 |
|
---|
| 546 | <?php if ( (isset($mode) && 'bookmarklet' == $mode) || isset($_GET['popupurl']) ): ?>
|
---|
| 547 | <input type="hidden" name="mode" value="bookmarklet" />
|
---|
| 548 | <?php endif; ?>
|
---|
| 549 |
|
---|
| 550 | <div class="wrap">
|
---|
| 551 | <?php screen_icon(); ?>
|
---|
| 552 | <h2><?php echo esc_html( $title ); ?></h2>
|
---|
| 553 | <?php if ( $notice ) : ?>
|
---|
| 554 | <div id="notice" class="error"><p><?php echo $notice ?></p></div>
|
---|
| 555 | <?php endif; ?>
|
---|
| 556 | <?php if (isset($_GET['message'])) : ?>
|
---|
| 557 | <div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
|
---|
| 558 | <?php endif; ?>
|
---|
| 559 | <form name="post" action="post.php" method="post" id="post">
|
---|
| 560 | <?php
|
---|
| 561 |
|
---|
| 562 | if ( 0 == $post_ID)
|
---|
| 563 | wp_nonce_field('add-post');
|
---|
| 564 | else
|
---|
| 565 | wp_nonce_field('update-post_' . $post_ID);
|
---|
| 566 |
|
---|
| 567 | ?>
|
---|
| 568 |
|
---|
| 569 | <input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID ?>" />
|
---|
| 570 | <input type="hidden" id="hiddenaction" name="action" value="<?php echo esc_attr($form_action) ?>" />
|
---|
| 571 | <input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr($form_action) ?>" />
|
---|
| 572 | <input type="hidden" id="post_author" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" />
|
---|
| 573 | <input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr($post->post_type) ?>" />
|
---|
| 574 | <input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr($post->post_status) ?>" />
|
---|
| 575 | <input name="referredby" type="hidden" id="referredby" value="<?php echo esc_url(stripslashes(wp_get_referer())); ?>" />
|
---|
| 576 | <?php
|
---|
| 577 | if ( 'draft' != $post->post_status )
|
---|
| 578 | wp_original_referer_field(true, 'previous');
|
---|
| 579 |
|
---|
| 580 | echo $form_extra ?>
|
---|
| 581 |
|
---|
| 582 | <div id="poststuff" class="metabox-holder<?php echo 2 == $screen_layout_columns ? ' has-right-sidebar' : ''; ?>">
|
---|
| 583 | <div id="side-info-column" class="inner-sidebar">
|
---|
| 584 |
|
---|
| 585 | <?php do_action('submitpost_box'); ?>
|
---|
| 586 |
|
---|
| 587 | <?php $side_meta_boxes = do_meta_boxes('post', 'side', $post); ?>
|
---|
| 588 | </div>
|
---|
| 589 |
|
---|
| 590 | <div id="post-body">
|
---|
| 591 | <div id="post-body-content">
|
---|
| 592 | <div id="titlediv">
|
---|
| 593 | <div id="titlewrap">
|
---|
| 594 | <label class="screen-reader-text" for="title"><?php _e('Title') ?></label>
|
---|
| 595 | <input type="text" name="post_title" size="30" tabindex="1" value="<?php echo esc_attr( htmlspecialchars( $post->post_title ) ); ?>" id="title" autocomplete="off" />
|
---|
| 596 | </div>
|
---|
| 597 | <div class="inside">
|
---|
| 598 | <?php
|
---|
| 599 | $sample_permalink_html = get_sample_permalink_html($post->ID);
|
---|
| 600 | if ( !( 'pending' == $post->post_status && !current_user_can( 'publish_posts' ) ) ) { ?>
|
---|
| 601 | <div id="edit-slug-box">
|
---|
| 602 | <?php
|
---|
| 603 | if ( ! empty($post->ID) && ! empty($sample_permalink_html) ) :
|
---|
| 604 | echo $sample_permalink_html;
|
---|
| 605 | endif; ?>
|
---|
| 606 | </div>
|
---|
| 607 | <?php
|
---|
| 608 | } ?>
|
---|
| 609 | </div>
|
---|
| 610 | </div>
|
---|
| 611 |
|
---|
| 612 | <div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
|
---|
| 613 |
|
---|
| 614 | <?php the_editor($post->post_content); ?>
|
---|
| 615 |
|
---|
| 616 | <table id="post-status-info" cellspacing="0"><tbody><tr>
|
---|
| 617 | <td id="wp-word-count"></td>
|
---|
| 618 | <td class="autosave-info">
|
---|
| 619 | <span id="autosave"> </span>
|
---|
| 620 | <?php
|
---|
| 621 | if ( $post_ID ) {
|
---|
| 622 | echo '<span id="last-edit">';
|
---|
| 623 | if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) {
|
---|
| 624 | $last_user = get_userdata($last_id);
|
---|
| 625 | printf(__('Last edited by %1$s on %2$s at %3$s'), esc_html( $last_user->display_name ), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified));
|
---|
| 626 | } else {
|
---|
| 627 | printf(__('Last edited on %1$s at %2$s'), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified));
|
---|
| 628 | }
|
---|
| 629 | echo '</span>';
|
---|
| 630 | } ?>
|
---|
| 631 | </td>
|
---|
| 632 | </tr></tbody></table>
|
---|
| 633 |
|
---|
| 634 | <?php
|
---|
| 635 | wp_nonce_field( 'autosave', 'autosavenonce', false );
|
---|
| 636 | wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
|
---|
| 637 | wp_nonce_field( 'getpermalink', 'getpermalinknonce', false );
|
---|
| 638 | wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false );
|
---|
| 639 | wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
|
---|
| 640 | </div>
|
---|
| 641 |
|
---|
| 642 | <?php
|
---|
| 643 |
|
---|
| 644 | do_meta_boxes('post', 'normal', $post);
|
---|
| 645 |
|
---|
| 646 | do_action('edit_form_advanced');
|
---|
| 647 |
|
---|
| 648 | do_meta_boxes('post', 'advanced', $post);
|
---|
| 649 |
|
---|
| 650 | do_action('dbx_post_sidebar'); ?>
|
---|
| 651 |
|
---|
| 652 | </div>
|
---|
| 653 | </div>
|
---|
| 654 | <br class="clear" />
|
---|
| 655 | </div><!-- /poststuff -->
|
---|
| 656 | </form>
|
---|
| 657 | </div>
|
---|
| 658 |
|
---|
| 659 | <?php wp_comment_reply(); ?>
|
---|
| 660 |
|
---|
| 661 | <?php if ((isset($post->post_title) && '' == $post->post_title) || (isset($_GET['message']) && 2 > $_GET['message'])) : ?>
|
---|
| 662 | <script type="text/javascript">
|
---|
| 663 | try{document.post.title.focus();}catch(e){}
|
---|
| 664 | </script>
|
---|
| 665 | <?php endif; ?>
|
---|