From e2a720ee12effa1d324974cb6885f2dca5e47279 Mon Sep 17 00:00:00 2001 From: westi Date: Fri, 14 Aug 2009 17:37:40 +0000 Subject: [PATCH] Refactor the meta boxes out of the edit pages and into an include file. See #9674 props wnorris. git-svn-id: http://svn.automattic.com/wordpress/trunk@11815 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit-form-advanced.php | 455 +------------------------------- wp-admin/edit-link-form.php | 309 +--------------------- wp-admin/edit-page-form.php | 342 +----------------------- 3 files changed, 16 insertions(+), 1090 deletions(-) diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index 61aac06346..73a252d39d 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -57,246 +57,10 @@ if ( 0 == $post_ID ) { } // All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action). +require_once('includes/meta-boxes.php'); -/** - * Display post submit form fields. - * - * @since 2.7.0 - * - * @param object $post - */ -function post_submit_meta_box($post) { - global $action; - - $can_publish = current_user_can('publish_posts'); -?> -
- -
- - -
- -
- -
-
-post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?> -post_status ) { ?>style="display:none" type="submit" name="save" id="save-post" value="" tabindex="4" class="button button-highlighted" /> -post_status && $can_publish ) { ?> - - -
- -
-post_status ) { - $preview_link = esc_url(get_permalink($post->ID)); - $preview_button = __('Preview Changes'); -} else { - $preview_link = esc_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); - $preview_button = __('Preview'); -} -?> - - -
- -
-
- -
- -
- -post_status ) { - case 'private': - _e('Privately Published'); - break; - case 'publish': - _e('Published'); - break; - case 'future': - _e('Scheduled'); - break; - case 'pending': - _e('Pending Review'); - break; - case 'draft': - _e('Draft'); - break; -} -?> - -post_status || 'private' == $post->post_status || $can_publish ) { ?> -post_status ) { ?>style="display:none;" class="edit-post-status hide-if-no-js" tabindex='4'> - -
- - - - -
- - -
- -
- post_status ) { - $post->post_password = ''; - $visibility = 'private'; - $visibility_trans = __('Private'); -} elseif ( !empty( $post->post_password ) ) { - $visibility = 'password'; - $visibility_trans = __('Password protected'); -} elseif ( is_sticky( $post->ID ) ) { - $visibility = 'public'; - $visibility_trans = __('Public, Sticky'); -} else { - $visibility = 'public'; - $visibility_trans = __('Public'); -} - -?> - -
- -ID)); ?> /> - - - - />
-ID)); ?> tabindex="4" />
- />
-
- />
- -

- - -

-
- - -
- - -ID ) { - if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date - $stamp = __('Scheduled for: %1$s'); - } else if ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published - $stamp = __('Published on: %1$s'); - } else if ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified - $stamp = __('Publish immediately'); - } else if ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified - $stamp = __('Schedule for: %1$s'); - } else { // draft, 1 or more saves, date specified - $stamp = __('Publish on: %1$s'); - } - $date = date_i18n( $datef, strtotime( $post->post_date ) ); -} else { // draft (no saves, and thus no date specified) - $stamp = __('Publish immediately'); - $date = date_i18n( $datef, strtotime( current_time('mysql') ) ); -} - -if ( $can_publish ) : // Contributors don't get to choose the date of publish ?> -
- - - -
-
- - -
-
-
- -
- - - -
-post_status, array('publish', 'future', 'private') ) || 0 == $post->ID ) { - if ( current_user_can('publish_posts') ) : - if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?> - - - - - - - - - - - - -
-
-
-
- -helps) ? esc_attr($taxonomy->helps) : __('Separate tags with commas.'); -?> -
-
-
-

-
- - - - - -
-

-
-
- - - - - - -
- -
- - -
-

-

- - 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?> - - -

-
- -

-

-

-

- - -

Learn more about manual excerpts.'); ?>

-to_ping) ) .'" />'; - if ('' != $post->pinged) { - $pings = '

'. __('Already pinged:') . '

'; - } - -?> -


()

-

pingbacks, no other action necessary.'); ?>

- -
-
-ID); -list_meta($metadata); -meta_form(); ?> -
-

use in your theme.'); ?>

- - -

-
-

-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)); - - if ( 1 > $total ) { - echo '

' . __('No comments yet.') . '

'; - return; - } - - wp_nonce_field( 'get-comments', 'add_comment_nonce', false ); -?> - - - - - - - - -

- - -post_status || 'private' == $post->post_status ) add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', 'post', 'normal', 'core'); -/** - * Display post slug form fields. - * - * @since 2.6.0 - * - * @param object $post - */ -function post_slug_meta_box($post) { -?> - -post_status && !current_user_can( 'publish_posts' ) ) ) add_meta_box('slugdiv', __('Post Slug'), 'post_slug_meta_box', 'post', 'normal', 'core'); $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM if ( $post->post_author && !in_array($post->post_author, $authors) ) $authors[] = $post->post_author; -if ( $authors && count( $authors ) > 1 ) : -/** - * Display form field with list of authors. - * - * @since 2.6.0 - * - * @param object $post - */ -function post_author_meta_box($post) { - global $current_user, $user_ID; - $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM - if ( $post->post_author && !in_array($post->post_author, $authors) ) - $authors[] = $post->post_author; -?> - $authors, 'name' => 'post_author_override', 'selected' => empty($post->ID) ? $user_ID : $post->post_author) ); ?> - 1 ) + add_meta_box('authordiv', __('Post Author'), 'post_author_meta_box', 'post', 'normal', 'core'); -if ( 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) : -/** - * Display list of post revisions. - * - * @since 2.6.0 - * - * @param object $post - */ -function post_revisions_meta_box($post) { - wp_list_post_revisions(); -} -add_meta_box('revisionsdiv', __('Post Revisions'), 'post_revisions_meta_box', 'post', 'normal', 'core'); -endif; +if ( 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) + add_meta_box('revisionsdiv', __('Post Revisions'), 'post_revisions_meta_box', 'post', 'normal', 'core'); do_action('do_meta_boxes', 'post', 'normal', $post); do_action('do_meta_boxes', 'post', 'advanced', $post); diff --git a/wp-admin/edit-link-form.php b/wp-admin/edit-link-form.php index 11ec684b08..7d0c3edc46 100644 --- a/wp-admin/edit-link-form.php +++ b/wp-admin/edit-link-form.php @@ -22,319 +22,12 @@ if ( ! empty($link_id) ) { $nonce_action = 'add-bookmark'; } -/** - * Display checked checkboxes attribute for xfn microformat options. - * - * @since 1.0.1 - * - * @param string $class - * @param string $value - * @param mixed $deprecated Not used. - */ -function xfn_check($class, $value = '', $deprecated = '') { - global $link; +require_once('includes/meta-boxes.php'); - $link_rel = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: ''; - $rels = preg_split('/\s+/', $link_rel); - - if ('' != $value && in_array($value, $rels) ) { - echo ' checked="checked"'; - } - - if ('' == $value) { - if ('family' == $class && strpos($link_rel, 'child') === false && strpos($link_rel, 'parent') === false && strpos($link_rel, 'sibling') === false && strpos($link_rel, 'spouse') === false && strpos($link_rel, 'kin') === false) echo ' checked="checked"'; - if ('friendship' == $class && strpos($link_rel, 'friend') === false && strpos($link_rel, 'acquaintance') === false && strpos($link_rel, 'contact') === false) echo ' checked="checked"'; - if ('geographical' == $class && strpos($link_rel, 'co-resident') === false && strpos($link_rel, 'neighbor') === false) echo ' checked="checked"'; - if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"'; - } -} - -/** - * Display link create form fields. - * - * @since 2.7.0 - * - * @param object $link - */ -function link_submit_meta_box($link) { -?> - - - - -
- -
- - - -
-

- -
- -
-

-

-

-
-

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - - -
- -
- - -
- - - -
- - - - - - -
- - - - -
-
-

XFN.'); ?>

- - - - - - - - - - - - - - - - - - -
  -
- -
- -
- - -
- -
- -
-
-post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?> -post_status ) { ?>style="display:none" type="submit" name="save" id="save-post" value="" tabindex="4" class="button button-highlighted" /> -post_status && $can_publish ) { ?> - - -
- -
-post_status ) { - $preview_link = esc_url(get_permalink($post->ID)); - $preview_button = __('Preview Changes'); -} else { - $preview_link = esc_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); - $preview_button = __('Preview'); -} -?> - - -
- -
-
- -
- -
- -post_status ) { - case 'private': - _e('Privately Published'); - break; - case 'publish': - _e('Published'); - break; - case 'future': - _e('Scheduled'); - break; - case 'pending': - _e('Pending Review'); - break; - case 'draft': - _e('Draft'); - break; -} -?> - -post_status || 'private' == $post->post_status || $can_publish ) { ?> -post_status ) { ?>style="display:none;" class="edit-post-status hide-if-no-js" tabindex='4'> - -
- - - - - -
- - -
- -
- post_status ) { - $post->post_password = ''; - $visibility = 'private'; - $visibility_trans = __('Private'); -} elseif ( !empty( $post->post_password ) ) { - $visibility = 'password'; - $visibility_trans = __('Password protected'); -} else { - $visibility = 'public'; - $visibility_trans = __('Public'); -} - -echo esc_html( $visibility_trans ); ?> - - - -
- - - - />
- />
-
- />
- -

-

-
- - -
- -ID ) { - if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date - $stamp = __('Scheduled for: %1$s'); - } else if ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published - $stamp = __('Published on: %1$s'); - } else if ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified - $stamp = __('Publish immediately'); - } else if ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified - $stamp = __('Schedule for: %1$s'); - } else { // draft, 1 or more saves, date specified - $stamp = __('Publish on: %1$s'); - } - $date = date_i18n( $datef, strtotime( $post->post_date ) ); -} else { // draft (no saves, and thus no date specified) - $stamp = __('Publish immediately'); - $date = date_i18n( $datef, strtotime( current_time('mysql') ) ); -} - -if ( $can_publish ) : // Contributors don't get to choose the date of publish ?> -
- - -
-
- -
-
-
- -
- - - -
-post_status, array('publish', 'future', 'private') ) || 0 == $post->ID ) { ?> -post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?> - - - - - - - - - - - - -
-
-
-
- -

-

-

-

- -
- - $post->ID, 'selected' => $post->post_parent, 'name' => 'parent_id', 'show_option_none' => __('Main Page (no parent)'), 'sort_column'=> 'menu_order, post_title')); ?> -

- -
- -

- -
-

-

- -
-ID); - list_meta($metadata); - meta_form(); ?> -
-
-

use in your theme.'); ?>

- - -

-

-

trackbacks and pingbacks.'); ?>

- - -id, true, 'page' ); // TODO: ROLE SYSTEM if ( $post->post_author && !in_array($post->post_author, $authors) ) $authors[] = $post->post_author; -if ( $authors && count( $authors ) > 1 ) { - /** - * Display page author form fields, when more than one author exists. - * - * @since 2.6.0 - * - * @param object $post - */ - function page_author_meta_box($post){ - global $current_user, $user_ID; - $authors = get_editable_user_ids( $current_user->id, true, 'page' ); // TODO: ROLE SYSTEM - if ( $post->post_author && !in_array($post->post_author, $authors) ) - $authors[] = $post->post_author; -?> - $authors, 'name' => 'post_author_override', 'selected' => empty($post->ID) ? $user_ID : $post->post_author) ); ?> - 1 ) + add_meta_box('pageauthordiv', __('Page Author'), 'post_author_meta_box', 'page', 'normal', 'core'); -if ( 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) : -/** - * Display list of page revisions. - * - * @since 2.6.0 - * - * @param object $post - */ -function page_revisions_meta_box($post) { - wp_list_post_revisions(); -} -add_meta_box('revisionsdiv', __('Page Revisions'), 'page_revisions_meta_box', 'page', 'normal', 'core'); -endif; +if ( 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) + add_meta_box('revisionsdiv', __('Page Revisions'), 'post_revisions_meta_box', 'page', 'normal', 'core'); do_action('do_meta_boxes', 'page', 'normal', $post); do_action('do_meta_boxes', 'page', 'advanced', $post);