diff options
Diffstat (limited to 'wp-admin/includes/template.php')
-rw-r--r-- | wp-admin/includes/template.php | 100 |
1 files changed, 80 insertions, 20 deletions
diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 19f11f6..c348e7f 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -302,7 +302,7 @@ function tag_rows( $page = 1, $pagesize = 20, $searchterms = '' ) { // define the columns to display, the syntax is 'internal name' => 'display name' function wp_manage_posts_columns() { $posts_columns = array(); - $posts_columns['cb'] = '<input type="checkbox" onclick="checkAll(document.getElementById(\'posts-filter\'));" />'; + $posts_columns['cb'] = '<input type="checkbox" />'; if ( 'draft' === $_GET['post_status'] ) $posts_columns['modified'] = __('Modified'); elseif ( 'pending' === $_GET['post_status'] ) @@ -324,7 +324,7 @@ function wp_manage_posts_columns() { // define the columns to display, the syntax is 'internal name' => 'display name' function wp_manage_media_columns() { $posts_columns = array(); - $posts_columns['cb'] = '<input type="checkbox" onclick="checkAll(document.getElementById(\'posts-filter\'));" />'; + $posts_columns['cb'] = '<input type="checkbox" />'; $posts_columns['icon'] = ''; $posts_columns['media'] = _c('Media|media column header'); $posts_columns['desc'] = _c('Description|media column header'); @@ -339,7 +339,7 @@ function wp_manage_media_columns() { function wp_manage_pages_columns() { $posts_columns = array(); - $posts_columns['cb'] = '<input type="checkbox" onclick="checkAll(document.getElementById(\'posts-filter\'));" />'; + $posts_columns['cb'] = '<input type="checkbox" />'; if ( 'draft' === $_GET['post_status'] ) $posts_columns['modified'] = __('Modified'); elseif ( 'pending' === $_GET['post_status'] ) @@ -505,7 +505,7 @@ foreach ($posts_columns as $column_name=>$column_display_name) { */ function page_rows( $pages ) { if ( ! $pages ) - $pages = get_pages( 'sort_column=menu_order' ); + $pages = get_pages( array('sort_column' => 'menu_order') ); if ( ! $pages ) return false; @@ -717,7 +717,7 @@ function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) { if (!$categories ) - $categories = get_categories( 'hide_empty=0' ); + $categories = get_categories( array('hide_empty' => 0) ); if ( $categories ) { foreach ( $categories as $category ) { @@ -790,8 +790,8 @@ function _list_meta_row( $entry, &$count ) { $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] ); $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>"; - $r .= "\n\t\t<td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td>"; - $r .= "\n\t\t<td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>"; + $r .= "\n\t\t<td valign='top'><label class='hidden' for='meta[{$entry['meta_id']}][key]'>" . __( 'Key' ) . "</label><input name='meta[{$entry['meta_id']}][key]' id='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td>"; + $r .= "\n\t\t<td><label class='hidden' for='meta[{$entry['meta_id']}][value]'>" . __( 'Value' ) . "</label><textarea name='meta[{$entry['meta_id']}][value]' id='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>"; $r .= "\n\t\t<td style='text-align: center;'><input name='updatemeta' type='submit' tabindex='6' value='".attribute_escape(__( 'Update' ))."' class='add:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$update_nonce updatemeta' /><br />"; $r .= "\n\t\t<input name='deletemeta[{$entry['meta_id']}]' type='submit' "; $r .= "class='delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce deletemeta' tabindex='6' value='".attribute_escape(__( 'Delete' ))."' />"; @@ -816,8 +816,8 @@ function meta_form() { <p><strong><?php _e( 'Add a new custom field:' ) ?></strong></p> <table id="newmeta" cellspacing="3" cellpadding="3"> <tr> -<th colspan="2"><?php _e( 'Key' ) ?></th> -<th><?php _e( 'Value' ) ?></th> +<th colspan="2"><label <?php if ( $keys ) : ?> for="metakeyselect" <?php else : ?> for="metakeyinput" <?php endif; ?>><?php _e( 'Key' ) ?></label></th> +<th><label for="metavalue"><?php _e( 'Value' ) ?></label></th> </tr> <tr valign="top"> <td style="width: 18%;" class="textright"> @@ -831,7 +831,7 @@ function meta_form() { echo "\n\t<option value='$key'>$key</option>"; } ?> -</select> <?php _e( 'or' ); ?> +</select> <label for="metakeyinput"><?php _e( 'or' ); ?></label> <?php endif; ?> </td> <td><input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" /></td> @@ -904,7 +904,7 @@ function page_template_dropdown( $default = '' ) { function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) { global $wpdb, $post_ID; - $items = $wpdb->get_results( "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_type = 'page' ORDER BY menu_order" ); + $items = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent) ); if ( $items ) { foreach ( $items as $item ) { @@ -1057,10 +1057,12 @@ function wp_remember_old_slug() { * @param string $callback Function that fills the box with the desired content. The function should echo its output. * @param string $page The type of edit page on which to show the box (post, page, link) * @param string $context The context within the page where the boxes should show ('normal', 'advanced') + * @param string $priority The priority within the context where the boxes should show ('high', 'low') */ -function add_meta_box($id, $title, $callback, $page, $context = 'advanced') { +function add_meta_box($id, $title, $callback, $page, $context = 'advanced', $priority = 'default') { global $wp_meta_boxes; + if ( !isset($wp_meta_boxes) ) $wp_meta_boxes = array(); if ( !isset($wp_meta_boxes[$page]) ) @@ -1068,23 +1070,81 @@ function add_meta_box($id, $title, $callback, $page, $context = 'advanced') { if ( !isset($wp_meta_boxes[$page][$context]) ) $wp_meta_boxes[$page][$context] = array(); - $wp_meta_boxes[$page][$context][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback); + foreach ( array('high', 'core', 'default', 'low') as $a_priority ) { + if ( !isset($wp_meta_boxes[$page][$context][$a_priority][$id]) ) + continue; + // If a core box was previously added or removed by a plugin, don't add. + if ( 'core' == $priority ) { + // If core box previously deleted, don't add + if ( false === $wp_meta_boxes[$page][$context][$a_priority][$id] ) + return; + // If box was added with default priority, give it core priority to maintain sort order + if ( 'default' == $a_priority ) { + $wp_meta_boxes[$page][$context]['core'][$id] = $wp_meta_boxes[$page][$context]['default'][$id]; + unset($wp_meta_boxes[$page][$context]['default'][$id]); + } + return; + } + // If no priority given and id already present, use existing priority + if ( empty($priority) ) + $priority = $a_priority; + // An id can be in only one priority + if ( $priority != $a_priority ) + unset($wp_meta_boxes[$page][$context][$a_priority][$id]); + } + + if ( empty($priority) ) + $priority = low; + + if ( !isset($wp_meta_boxes[$page][$context][$priority]) ) + $wp_meta_boxes[$page][$context][$priority] = array(); + + $wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback); } function do_meta_boxes($page, $context, $object) { global $wp_meta_boxes; + do_action('do_meta_boxes', $page, $context, $object); + if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) ) return; - foreach ( (array) $wp_meta_boxes[$page][$context] as $box ) { - echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . '">' . "\n"; - echo "<h3>{$box['title']}</h3>\n"; - echo '<div class="inside">' . "\n"; - call_user_func($box['callback'], $object, $box); - echo "</div>\n"; - echo "</div>\n"; + foreach ( array('high', 'core', 'default', 'low') as $priority ) { + foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) { + if ( false === $box ) + continue; + echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . '">' . "\n"; + echo "<h3>{$box['title']}</h3>\n"; + echo '<div class="inside">' . "\n"; + call_user_func($box['callback'], $object, $box); + echo "</div>\n"; + echo "</div>\n"; + } } } +/** + * remove_meta_box() - Remove a meta box from an edit form + * + * @since 2.6 + * + * @param string $id String for use in the 'id' attribute of tags. + * @param string $page The type of edit page on which to show the box (post, page, link) + * @param string $context The context within the page where the boxes should show ('normal', 'advanced') + */ +function remove_meta_box($id, $page, $context) { + global $wp_meta_boxes; + + if ( !isset($wp_meta_boxes) ) + $wp_meta_boxes = array(); + if ( !isset($wp_meta_boxes[$page]) ) + $wp_meta_boxes[$page] = array(); + if ( !isset($wp_meta_boxes[$page][$context]) ) + $wp_meta_boxes[$page][$context] = array(); + + foreach ( array('high', 'core', 'default', 'low') as $priority ) + $wp_meta_boxes[$page][$context][$priority][$id] = false; +} + ?> |