+
@@ -2390,44 +472,11 @@ function wp_comment_trashnotice() {
}
/**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- *
- * @param unknown_type $currentcat
- * @param unknown_type $currentparent
- * @param unknown_type $parent
- * @param unknown_type $level
- * @param unknown_type $categories
- * @return unknown
- */
-function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) {
- if (!$categories )
- $categories = get_categories( array('hide_empty' => 0) );
-
- if ( $categories ) {
- foreach ( $categories as $category ) {
- if ( $currentcat != $category->term_id && $parent == $category->parent) {
- $pad = str_repeat( '– ', $level );
- $category->name = esc_html( $category->name );
- echo "\n\tterm_id )
- echo " selected='selected'";
- echo ">$pad$category->name ";
- wp_dropdown_cats( $currentcat, $currentparent, $category->term_id, $level +1, $categories );
- }
- }
- } else {
- return false;
- }
-}
-
-/**
- * {@internal Missing Short Description}}
+ * Outputs a post's public meta data in the Custom Fields meta box.
*
- * @since unknown
+ * @since 1.2.0
*
- * @param unknown_type $meta
+ * @param array $meta
*/
function list_meta( $meta ) {
// Exit if no meta
@@ -2436,11 +485,11 @@ function list_meta( $meta ) {
- ' . __( 'Name' ) . '
+ ' . _x( 'Name', 'meta name' ) . '
' . __( 'Value' ) . '
-
+
'; //TBODY needed for list-manipulation JS
@@ -2451,11 +500,11 @@ function list_meta( $meta ) {
-
+
-
+
+ $entry['meta_value'] = esc_textarea( $entry['meta_value'] ); // using a
$entry['meta_id'] = (int) $entry['meta_id'];
$delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] );
- $r .= "\n\t";
- $r .= "\n\t\t" . __( 'Key' ) . " ";
+ $r .= "\n\t ";
+ $r .= "\n\t\t" . __( 'Key' ) . " ";
- $r .= "\n\t\t ";
- $r .= "\n\t\t
";
+ $r .= "\n\t\t";
+ $r .= get_submit_button( __( 'Delete' ), 'deletemeta small', "deletemeta[{$entry['meta_id']}]", false, array( 'data-wp-lists' => "delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce" ) );
+ $r .= "\n\t\t";
+ $r .= get_submit_button( __( 'Update' ), 'updatemeta small', "meta-{$entry['meta_id']}-submit", false, array( 'data-wp-lists' => "add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce" ) );
+ $r .= "
";
$r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false );
$r .= " ";
- $r .= "\n\t\t" . __( 'Value' ) . " \n\t ";
+ $r .= "\n\t\t" . __( 'Value' ) . " \n\t";
return $r;
}
/**
- * {@internal Missing Short Description}}
+ * Prints the form in the Custom Fields meta box.
+ *
+ * @since 1.2.0
*
- * @since unknown
+ * @global wpdb $wpdb WordPress database abstraction object.
+ *
+ * @param WP_Post $post Optional. The post being edited.
*/
-function meta_form() {
+function meta_form( $post = null ) {
global $wpdb;
- $limit = (int) apply_filters( 'postmeta_form_limit', 30 );
- $keys = $wpdb->get_col( "
- SELECT meta_key
- FROM $wpdb->postmeta
- GROUP BY meta_key
- HAVING meta_key NOT LIKE '\_%'
- ORDER BY LOWER(meta_key)
- LIMIT $limit" );
- if ( $keys )
- natcasesort($keys);
+ $post = get_post( $post );
+
+ /**
+ * Filters values for the meta key dropdown in the Custom Fields meta box.
+ *
+ * Returning a non-null value will effectively short-circuit and avoid a
+ * potentially expensive query against postmeta.
+ *
+ * @since 4.4.0
+ *
+ * @param array|null $keys Pre-defined meta keys to be used in place of a postmeta query. Default null.
+ * @param WP_Post $post The current post object.
+ */
+ $keys = apply_filters( 'postmeta_form_keys', null, $post );
+
+ if ( null === $keys ) {
+ /**
+ * Filters the number of custom fields to retrieve for the drop-down
+ * in the Custom Fields meta box.
+ *
+ * @since 2.1.0
+ *
+ * @param int $limit Number of custom fields to retrieve. Default 30.
+ */
+ $limit = apply_filters( 'postmeta_form_limit', 30 );
+ $sql = "SELECT DISTINCT meta_key
+ FROM $wpdb->postmeta
+ WHERE meta_key NOT BETWEEN '_' AND '_z'
+ HAVING meta_key NOT LIKE %s
+ ORDER BY meta_key
+ LIMIT %d";
+ $keys = $wpdb->get_col( $wpdb->prepare( $sql, $wpdb->esc_like( '_' ) . '%', $limit ) );
+ }
+
+ if ( $keys ) {
+ natcasesort( $keys );
+ $meta_key_input_id = 'metakeyselect';
+ } else {
+ $meta_key_input_id = 'metakeyinput';
+ }
?>
-
+
@@ -2581,29 +669,35 @@ function meta_form() {
}
/**
- * {@internal Missing Short Description}}
+ * Print out HTML form date elements for editing post or comment publish date.
*
- * @since unknown
+ * @since 0.71
+ * @since 4.4.0 Converted to use get_comment() instead of the global `$comment`.
*
- * @param unknown_type $edit
- * @param unknown_type $for_post
- * @param unknown_type $tab_index
- * @param unknown_type $multi
+ * @global WP_Locale $wp_locale
+ *
+ * @param int|bool $edit Accepts 1|true for editing the date, 0|false for adding the date.
+ * @param int|bool $for_post Accepts 1|true for applying the date to a post, 0|false for a comment.
+ * @param int $tab_index The tabindex attribute to add. Default 0.
+ * @param int|bool $multi Optional. Whether the additional fields and buttons should be added.
+ * Default 0|false.
*/
function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
- global $wp_locale, $post, $comment;
+ global $wp_locale;
+ $post = get_post();
if ( $for_post )
- $edit = ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) ) ? false : true;
+ $edit = ! ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) );
$tab_index_attribute = '';
if ( (int) $tab_index > 0 )
$tab_index_attribute = " tabindex=\"$tab_index\"";
+ // todo: Remove this?
// echo ' '.__( 'Edit timestamp' ).' ';
- $time_adj = time() + (get_option( 'gmt_offset' ) * 3600 );
- $post_date = ($for_post) ? $post->post_date : $comment->comment_date;
+ $time_adj = current_time('timestamp');
+ $post_date = ($for_post) ? $post->post_date : get_comment()->comment_date;
$jj = ($edit) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj );
$mm = ($edit) ? mysql2date( 'm', $post_date, false ) : gmdate( 'm', $time_adj );
$aa = ($edit) ? mysql2date( 'Y', $post_date, false ) : gmdate( 'Y', $time_adj );
@@ -2617,91 +711,101 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
$cur_hh = gmdate( 'H', $time_adj );
$cur_mn = gmdate( 'i', $time_adj );
- $month = "\n";
+ $month = '' . __( 'Month' ) . ' \n";
for ( $i = 1; $i < 13; $i = $i +1 ) {
- $month .= "\t\t\t" . 'get_month_abbrev( $wp_locale->get_month( $i ) ) . " \n";
+ $monthnum = zeroise($i, 2);
+ $monthtext = $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) );
+ $month .= "\t\t\t" . '';
+ /* translators: 1: month number (01, 02, etc.), 2: month abbreviation */
+ $month .= sprintf( __( '%1$s-%2$s' ), $monthnum, $monthtext ) . " \n";
}
- $month .= ' ';
+ $month .= ' ';
- $day = ' ';
- $year = ' ';
- $hour = ' ';
- $minute = ' ';
+ $day = '' . __( 'Day' ) . ' ';
+ $year = '' . __( 'Year' ) . ' ';
+ $hour = '' . __( 'Hour' ) . ' ';
+ $minute = '' . __( 'Minute' ) . ' ';
echo '';
- /* translators: 1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input */
- printf(__('%1$s%2$s, %3$s @ %4$s : %5$s'), $month, $day, $year, $hour, $minute);
+ /* translators: 1: month, 2: day, 3: year, 4: hour, 5: minute */
+ printf( __( '%1$s %2$s, %3$s @ %4$s:%5$s' ), $month, $day, $year, $hour, $minute );
echo '
';
if ( $multi ) return;
echo "\n\n";
- foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) {
- echo ' ' . "\n";
+ $map = array(
+ 'mm' => array( $mm, $cur_mm ),
+ 'jj' => array( $jj, $cur_jj ),
+ 'aa' => array( $aa, $cur_aa ),
+ 'hh' => array( $hh, $cur_hh ),
+ 'mn' => array( $mn, $cur_mn ),
+ );
+ foreach ( $map as $timeunit => $value ) {
+ list( $unit, $curr ) = $value;
+
+ echo ' ' . "\n";
$cur_timeunit = 'cur_' . $timeunit;
- echo ' ' . "\n";
+ echo ' ' . "\n";
}
?>
-
+
$template";
- endforeach;
+ foreach ( array_keys( $templates ) as $template ) {
+ $selected = selected( $default, $templates[ $template ], false );
+ echo "\n\t$template ";
+ }
}
/**
- * {@internal Missing Short Description}}
+ * Print out option HTML elements for the page parents drop-down.
+ *
+ * @since 1.5.0
+ * @since 4.4.0 `$post` argument was added.
*
- * @since unknown
+ * @global wpdb $wpdb WordPress database abstraction object.
*
- * @param unknown_type $default
- * @param unknown_type $parent
- * @param unknown_type $level
- * @return unknown
+ * @param int $default Optional. The default page ID to be pre-selected. Default 0.
+ * @param int $parent Optional. The parent page ID. Default 0.
+ * @param int $level Optional. Page depth level. Default 0.
+ * @param int|WP_Post $post Post ID or WP_Post object.
+ *
+ * @return null|false Boolean False if page has no children, otherwise print out html elements
*/
-function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
- global $wpdb, $post_ID;
+function parent_dropdown( $default = 0, $parent = 0, $level = 0, $post = null ) {
+ global $wpdb;
+ $post = get_post( $post );
$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 ) {
// A page cannot be its own parent.
- if (!empty ( $post_ID ) ) {
- if ( $item->ID == $post_ID ) {
- continue;
- }
- }
+ if ( $post && $post->ID && $item->ID == $post->ID )
+ continue;
+
$pad = str_repeat( ' ', $level * 3 );
- if ( $item->ID == $default)
- $current = ' selected="selected"';
- else
- $current = '';
+ $selected = selected( $default, $item->ID, false );
- echo "\n\t$pad " . esc_html($item->post_title) . " ";
+ echo "\n\t$pad " . esc_html($item->post_title) . " ";
parent_dropdown( $default, $item->ID, $level +1 );
}
} else {
@@ -2710,89 +814,21 @@ function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
}
/**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- */
-function browse_happy() {
- $getit = __( 'WordPress recommends a better browser' );
- echo '
-
-';
-}
-
-/**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- *
- * @param unknown_type $id
- * @return unknown
- */
-function the_attachment_links( $id = false ) {
- $id = (int) $id;
- $post = & get_post( $id );
-
- if ( $post->post_type != 'attachment' )
- return false;
-
- $icon = get_attachment_icon( $post->ID );
- $attachment_data = wp_get_attachment_metadata( $id );
- $thumb = isset( $attachment_data['thumb'] );
-?>
-
- html elements for role selectors based on $wp_roles
+ * Print out option html elements for role selectors.
*
- * @package WordPress
- * @subpackage Administration
- * @since 2.1
+ * @since 2.1.0
*
- * @uses $wp_roles
- * @param string $default slug for the role that should be already selected
+ * @param string $selected Slug for the role that should be already selected.
*/
-function wp_dropdown_roles( $selected = false ) {
- global $wp_roles;
+function wp_dropdown_roles( $selected = '' ) {
$p = '';
$r = '';
- $editable_roles = get_editable_roles();
+ $editable_roles = array_reverse( get_editable_roles() );
- foreach( $editable_roles as $role => $details ) {
+ foreach ( $editable_roles as $role => $details ) {
$name = translate_user_role($details['name'] );
- if ( $selected == $role ) // Make default first in list
+ if ( $selected == $role ) // preselect specified role
$p = "\n\t$name ";
else
$r .= "\n\t$name ";
@@ -2800,114 +836,92 @@ function wp_dropdown_roles( $selected = false ) {
echo $p . $r;
}
-/**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- *
- * @param unknown_type $size
- * @return unknown
- */
-function wp_convert_hr_to_bytes( $size ) {
- $size = strtolower($size);
- $bytes = (int) $size;
- if ( strpos($size, 'k') !== false )
- $bytes = intval($size) * 1024;
- elseif ( strpos($size, 'm') !== false )
- $bytes = intval($size) * 1024 * 1024;
- elseif ( strpos($size, 'g') !== false )
- $bytes = intval($size) * 1024 * 1024 * 1024;
- return $bytes;
-}
-
-/**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- *
- * @param unknown_type $bytes
- * @return unknown
- */
-function wp_convert_bytes_to_hr( $bytes ) {
- $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' );
- $log = log( $bytes, 1024 );
- $power = (int) $log;
- $size = pow(1024, $log - $power);
- return $size . $units[$power];
-}
-
-/**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- *
- * @return unknown
- */
-function wp_max_upload_size() {
- $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) );
- $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) );
- $bytes = apply_filters( 'upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes );
- return $bytes;
-}
-
/**
* Outputs the form used by the importers to accept the data to be imported
*
- * @since 2.0
+ * @since 2.0.0
*
* @param string $action The action attribute for the form.
*/
function wp_import_upload_form( $action ) {
+
+ /**
+ * Filters the maximum allowed upload size for import files.
+ *
+ * @since 2.3.0
+ *
+ * @see wp_max_upload_size()
+ *
+ * @param int $max_upload_size Allowed upload size. Default 1 MB.
+ */
$bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
- $size = wp_convert_bytes_to_hr( $bytes );
+ $size = size_format( $bytes );
$upload_dir = wp_upload_dir();
if ( ! empty( $upload_dir['error'] ) ) :
?>
-
+
()
-
-
-
+
post_name); // just in case
- if ( strlen($name) )
- echo ' ';
-}
-
-/**
- * Add a meta box to an edit form.
+ * Adds a meta box to one or more screens.
*
* @since 2.5.0
- *
- * @param string $id String for use in the 'id' attribute of tags.
- * @param string $title Title of the meta box.
- * @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', $priority = 'default', $callback_args=null) {
+ * @since 4.4.0 The `$screen` parameter now accepts an array of screen IDs.
+ *
+ * @global array $wp_meta_boxes
+ *
+ * @param string $id Meta box ID (used in the 'id' attribute for the meta box).
+ * @param string $title Title of the meta box.
+ * @param callable $callback Function that fills the box with the desired content.
+ * The function should echo its output.
+ * @param string|array|WP_Screen $screen Optional. The screen or screens on which to show the box
+ * (such as a post type, 'link', or 'comment'). Accepts a single
+ * screen ID, WP_Screen object, or array of screen IDs. Default
+ * is the current screen.
+ * @param string $context Optional. The context within the screen where the boxes
+ * should display. Available contexts vary from screen to
+ * screen. Post edit screen contexts include 'normal', 'side',
+ * and 'advanced'. Comments screen contexts include 'normal'
+ * and 'side'. Menus meta boxes (accordion sections) all use
+ * the 'side' context. Global default is 'advanced'.
+ * @param string $priority Optional. The priority within the context where the boxes
+ * should show ('high', 'low'). Default 'default'.
+ * @param array $callback_args Optional. Data that should be set as the $args property
+ * of the box array (which is the second parameter passed
+ * to your callback). Default null.
+ */
+function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null ) {
global $wp_meta_boxes;
+ if ( empty( $screen ) ) {
+ $screen = get_current_screen();
+ } elseif ( is_string( $screen ) ) {
+ $screen = convert_to_screen( $screen );
+ } elseif ( is_array( $screen ) ) {
+ foreach ( $screen as $single_screen ) {
+ add_meta_box( $id, $title, $callback, $single_screen, $context, $priority, $callback_args );
+ }
+ }
+
+ if ( ! isset( $screen->id ) ) {
+ return;
+ }
+
+ $page = $screen->id;
+
if ( !isset($wp_meta_boxes) )
$wp_meta_boxes = array();
if ( !isset($wp_meta_boxes[$page]) )
@@ -2916,35 +930,42 @@ function add_meta_box($id, $title, $callback, $page, $context = 'advanced', $pri
$wp_meta_boxes[$page][$context] = array();
foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) {
- foreach ( array('high', 'core', 'default', 'low') as $a_priority ) {
- if ( !isset($wp_meta_boxes[$page][$a_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][$a_context][$a_priority][$id] )
+ foreach ( array('high', 'core', 'default', 'low') as $a_priority ) {
+ if ( !isset($wp_meta_boxes[$page][$a_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][$a_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][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
+ unset($wp_meta_boxes[$page][$a_context]['default'][$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][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
- unset($wp_meta_boxes[$page][$a_context]['default'][$id]);
}
- return;
- }
- // If no priority given and id already present, use existing priority
- if ( empty($priority) ) {
- $priority = $a_priority;
- // else if we're adding to the sorted priortiy, we don't know the title or callback. Glab them from the previously added context/priority.
- } elseif ( 'sorted' == $priority ) {
- $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
- $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
- $callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args'];
+ // If no priority given and id already present, use existing priority.
+ if ( empty($priority) ) {
+ $priority = $a_priority;
+ /*
+ * Else, if we're adding to the sorted priority, we don't know the title
+ * or callback. Grab them from the previously added context/priority.
+ */
+ } elseif ( 'sorted' == $priority ) {
+ $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
+ $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
+ $callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args'];
+ }
+ // An id can be in only one priority and one context.
+ if ( $priority != $a_priority || $context != $a_context )
+ unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
}
- // An id can be in only one priority and one context
- if ( $priority != $a_priority || $context != $a_context )
- unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
- }
}
if ( empty($priority) )
@@ -2957,51 +978,72 @@ function add_meta_box($id, $title, $callback, $page, $context = 'advanced', $pri
}
/**
- * {@internal Missing Short Description}}
+ * Meta-Box template function
*
- * @since unknown
+ * @since 2.5.0
+ *
+ * @global array $wp_meta_boxes
*
- * @param unknown_type $page
- * @param unknown_type $context
- * @param unknown_type $object
+ * @staticvar bool $already_sorted
+ * @param string|WP_Screen $screen Screen identifier
+ * @param string $context box context
+ * @param mixed $object gets passed to the box callback function as first parameter
* @return int number of meta_boxes
*/
-function do_meta_boxes($page, $context, $object) {
+function do_meta_boxes( $screen, $context, $object ) {
global $wp_meta_boxes;
static $already_sorted = false;
- //do_action('do_meta_boxes', $page, $context, $object);
+ if ( empty( $screen ) )
+ $screen = get_current_screen();
+ elseif ( is_string( $screen ) )
+ $screen = convert_to_screen( $screen );
- $hidden = get_hidden_meta_boxes($page);
+ $page = $screen->id;
- echo "\n";
+ $hidden = get_hidden_meta_boxes( $screen );
- $i = 0;
- do {
- // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose
- if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page", 0, false ) ) {
- foreach ( $sorted as $box_context => $ids )
- foreach ( explode(',', $ids) as $id )
- if ( $id )
- add_meta_box( $id, null, null, $page, $box_context, 'sorted' );
+ printf('
', htmlspecialchars($context));
+
+ // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose
+ if ( ! $already_sorted && $sorted = get_user_option( "meta-box-order_$page" ) ) {
+ foreach ( $sorted as $box_context => $ids ) {
+ foreach ( explode( ',', $ids ) as $id ) {
+ if ( $id && 'dashboard_browser_nag' !== $id ) {
+ add_meta_box( $id, null, null, $screen, $box_context, 'sorted' );
+ }
+ }
}
- $already_sorted = true;
+ }
+
+ $already_sorted = true;
- if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) )
- break;
+ $i = 0;
- foreach ( array('high', 'sorted', 'core', 'default', 'low') as $priority ) {
- if ( isset($wp_meta_boxes[$page][$context][$priority]) ) {
- foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) {
+ if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
+ foreach ( array( 'high', 'sorted', 'core', 'default', 'low' ) as $priority ) {
+ if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ]) ) {
+ foreach ( (array) $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
if ( false == $box || ! $box['title'] )
continue;
$i++;
- $style = '';
- if ( in_array($box['id'], $hidden) )
- $style = 'style="display:none;"';
- echo '
' . "\n";
- echo '
';
- echo "
{$box['title']} \n";
+ $hidden_class = in_array($box['id'], $hidden) ? ' hide-if-js' : '';
+ echo '
' . "\n";
+ if ( 'dashboard_browser_nag' != $box['id'] ) {
+ $widget_title = $box[ 'title' ];
+
+ if ( is_array( $box[ 'args' ] ) && isset( $box[ 'args' ][ '__widget_basename' ] ) ) {
+ $widget_title = $box[ 'args' ][ '__widget_basename' ];
+ // Do not pass this parameter to the user callback function.
+ unset( $box[ 'args' ][ '__widget_basename' ] );
+ }
+
+ echo '
';
+ echo '' . sprintf( __( 'Toggle panel: %s' ), $widget_title ) . ' ';
+ echo ' ';
+ echo ' ';
+ }
+ echo "
{$box['title']} \n";
echo '
' . "\n";
call_user_func($box['callback'], $object, $box);
echo "
\n";
@@ -3009,7 +1051,7 @@ function do_meta_boxes($page, $context, $object) {
}
}
}
- } while(0);
+ }
echo "
";
@@ -3018,17 +1060,42 @@ function do_meta_boxes($page, $context, $object) {
}
/**
- * Remove a meta box from an edit form.
+ * Removes a meta box from one or more screens.
*
* @since 2.6.0
+ * @since 4.4.0 The `$screen` parameter now accepts an array of screen IDs.
+ *
+ * @global array $wp_meta_boxes
*
- * @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').
+ * @param string $id Meta box ID (used in the 'id' attribute for the meta box).
+ * @param string|array|WP_Screen $screen The screen or screens on which the meta box is shown (such as a
+ * post type, 'link', or 'comment'). Accepts a single screen ID,
+ * WP_Screen object, or array of screen IDs.
+ * @param string $context The context within the screen where the box is set to display.
+ * Contexts vary from screen to screen. Post edit screen contexts
+ * include 'normal', 'side', and 'advanced'. Comments screen contexts
+ * include 'normal' and 'side'. Menus meta boxes (accordion sections)
+ * all use the 'side' context.
*/
-function remove_meta_box($id, $page, $context) {
+function remove_meta_box( $id, $screen, $context ) {
global $wp_meta_boxes;
+ if ( empty( $screen ) ) {
+ $screen = get_current_screen();
+ } elseif ( is_string( $screen ) ) {
+ $screen = convert_to_screen( $screen );
+ } elseif ( is_array( $screen ) ) {
+ foreach ( $screen as $single_screen ) {
+ remove_meta_box( $id, $single_screen, $context );
+ }
+ }
+
+ if ( ! isset( $screen->id ) ) {
+ return;
+ }
+
+ $page = $screen->id;
+
if ( !isset($wp_meta_boxes) )
$wp_meta_boxes = array();
if ( !isset($wp_meta_boxes[$page]) )
@@ -3041,316 +1108,432 @@ function remove_meta_box($id, $page, $context) {
}
/**
- * {@internal Missing Short Description}}
+ * Meta Box Accordion Template Function
+ *
+ * Largely made up of abstracted code from do_meta_boxes(), this
+ * function serves to build meta boxes as list items for display as
+ * a collapsible accordion.
*
- * @since unknown
+ * @since 3.6.0
*
- * @param unknown_type $page
+ * @uses global $wp_meta_boxes Used to retrieve registered meta boxes.
+ *
+ * @param string|object $screen The screen identifier.
+ * @param string $context The meta box context.
+ * @param mixed $object gets passed to the section callback function as first parameter.
+ * @return int number of meta boxes as accordion sections.
*/
-function meta_box_prefs($page) {
+function do_accordion_sections( $screen, $context, $object ) {
global $wp_meta_boxes;
- if ( empty($wp_meta_boxes[$page]) )
- return;
+ wp_enqueue_script( 'accordion' );
- $hidden = get_hidden_meta_boxes($page);
-
- foreach ( array_keys($wp_meta_boxes[$page]) as $context ) {
- foreach ( array_keys($wp_meta_boxes[$page][$context]) as $priority ) {
- foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) {
- if ( false == $box || ! $box['title'] )
- continue;
- // Submit box cannot be hidden
- if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] )
- continue;
- $box_id = $box['id'];
- echo '
';
- echo ' ';
- echo "{$box['title']} \n";
- }
- }
- }
-}
+ if ( empty( $screen ) )
+ $screen = get_current_screen();
+ elseif ( is_string( $screen ) )
+ $screen = convert_to_screen( $screen );
-function get_hidden_meta_boxes($page) {
- $hidden = (array) get_user_option( "meta-box-hidden_$page", 0, false );
+ $page = $screen->id;
- // Hide slug boxes by default
- if ( empty($hidden[0]) ) {
- $hidden = array('slugdiv');
- }
+ $hidden = get_hidden_meta_boxes( $screen );
+ ?>
+
+ $id, 'title' => $title, 'callback' => $callback);
}
/**
- * Add a new field to a settings page.
+ * Add a new field to a section of a settings page
*
- * @since 2.7.0
+ * Part of the Settings API. Use this to define a settings field that will show
+ * as part of a settings section inside a settings page. The fields are shown using
+ * do_settings_fields() in do_settings-sections()
+ *
+ * The $callback argument should be the name of a function that echoes out the
+ * html input tags for this setting field. Use get_option() to retrieve existing
+ * values to show.
*
- * @param string $id String for use in the 'id' attribute of tags.
- * @param string $title Title of the field.
- * @param string $callback Function that fills the field with the desired content. The function should echo its output.
- * @param string $page The type of settings page on which to show the field (general, reading, writing, ...).
- * @param string $section The section of the settingss page in which to show the box (default, ...).
- * @param array $args Additional arguments
+ * @since 2.7.0
+ * @since 4.2.0 The `$class` argument was added.
+ *
+ * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
+ *
+ * @param string $id Slug-name to identify the field. Used in the 'id' attribute of tags.
+ * @param string $title Formatted title of the field. Shown as the label for the field
+ * during output.
+ * @param callable $callback Function that fills the field with the desired form inputs. The
+ * function should echo its output.
+ * @param string $page The slug-name of the settings page on which to show the section
+ * (general, reading, writing, ...).
+ * @param string $section Optional. The slug-name of the section of the settings page
+ * in which to show the box. Default 'default'.
+ * @param array $args {
+ * Optional. Extra arguments used when outputting the field.
+ *
+ * @type string $label_for When supplied, the setting title will be wrapped
+ * in a `
` element, its `for` attribute populated
+ * with this value.
+ * @type string $class CSS Class to be added to the `` element when the
+ * field is output.
+ * }
*/
function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) {
global $wp_settings_fields;
- if ( !isset($wp_settings_fields) )
- $wp_settings_fields = array();
- if ( !isset($wp_settings_fields[$page]) )
- $wp_settings_fields[$page] = array();
- if ( !isset($wp_settings_fields[$page][$section]) )
- $wp_settings_fields[$page][$section] = array();
+ if ( 'misc' == $page ) {
+ _deprecated_argument( __FUNCTION__, '3.0.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) );
+ $page = 'general';
+ }
+
+ if ( 'privacy' == $page ) {
+ _deprecated_argument( __FUNCTION__, '3.5.0', __( 'The privacy options group has been removed. Use another settings group.' ) );
+ $page = 'reading';
+ }
$wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args);
}
/**
- * {@internal Missing Short Description}}
+ * Prints out all settings sections added to a particular settings page
*
- * @since unknown
+ * Part of the Settings API. Use this in a settings page callback function
+ * to output all the sections and fields that were added to that $page with
+ * add_settings_section() and add_settings_field()
*
- * @param unknown_type $page
+ * @global $wp_settings_sections Storage array of all settings sections added to admin pages
+ * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
+ * @since 2.7.0
+ *
+ * @param string $page The slug name of the page whose settings sections you want to output
*/
-function do_settings_sections($page) {
+function do_settings_sections( $page ) {
global $wp_settings_sections, $wp_settings_fields;
- if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) )
+ if ( ! isset( $wp_settings_sections[$page] ) )
return;
foreach ( (array) $wp_settings_sections[$page] as $section ) {
- echo "{$section['title']} \n";
- call_user_func($section['callback'], $section);
- if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']]) )
+ if ( $section['title'] )
+ echo "{$section['title']} \n";
+
+ if ( $section['callback'] )
+ call_user_func( $section['callback'], $section );
+
+ if ( ! isset( $wp_settings_fields ) || !isset( $wp_settings_fields[$page] ) || !isset( $wp_settings_fields[$page][$section['id']] ) )
continue;
echo '';
}
}
/**
- * {@internal Missing Short Description}}
+ * Print out the settings fields for a particular settings section
+ *
+ * Part of the Settings API. Use this in a settings page to output
+ * a specific section. Should normally be called by do_settings_sections()
+ * rather than directly.
+ *
+ * @global $wp_settings_fields Storage array of settings fields and their pages/sections
+ *
+ * @since 2.7.0
+ *
+ * @param string $page Slug title of the admin page who's settings fields you want to show.
+ * @param string $section Slug title of the settings section who's fields you want to show.
+ */
+function do_settings_fields($page, $section) {
+ global $wp_settings_fields;
+
+ if ( ! isset( $wp_settings_fields[$page][$section] ) )
+ return;
+
+ foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
+ $class = '';
+
+ if ( ! empty( $field['args']['class'] ) ) {
+ $class = ' class="' . esc_attr( $field['args']['class'] ) . '"';
+ }
+
+ echo " ";
+
+ if ( ! empty( $field['args']['label_for'] ) ) {
+ echo '' . $field['title'] . ' ';
+ } else {
+ echo '' . $field['title'] . ' ';
+ }
+
+ echo '';
+ call_user_func($field['callback'], $field['args']);
+ echo ' ';
+ echo ' ';
+ }
+}
+
+/**
+ * Register a settings error to be displayed to the user
+ *
+ * Part of the Settings API. Use this to show messages to users about settings validation
+ * problems, missing settings or anything else.
+ *
+ * Settings errors should be added inside the $sanitize_callback function defined in
+ * register_setting() for a given setting to give feedback about the submission.
+ *
+ * By default messages will show immediately after the submission that generated the error.
+ * Additional calls to settings_errors() can be used to show errors even when the settings
+ * page is first accessed.
+ *
+ * @since 3.0.0
+ *
+ * @global array $wp_settings_errors Storage array of errors registered during this pageload
+ *
+ * @param string $setting Slug title of the setting to which this error applies
+ * @param string $code Slug-name to identify the error. Used as part of 'id' attribute in HTML output.
+ * @param string $message The formatted message text to display to the user (will be shown inside styled
+ * `` and `
` tags).
+ * @param string $type Optional. Message type, controls HTML class. Accepts 'error' or 'updated'.
+ * Default 'error'.
+ */
+function add_settings_error( $setting, $code, $message, $type = 'error' ) {
+ global $wp_settings_errors;
+
+ $wp_settings_errors[] = array(
+ 'setting' => $setting,
+ 'code' => $code,
+ 'message' => $message,
+ 'type' => $type
+ );
+}
+
+/**
+ * Fetch settings errors registered by add_settings_error()
+ *
+ * Checks the $wp_settings_errors array for any errors declared during the current
+ * pageload and returns them.
*
- * @since unknown
+ * If changes were just submitted ($_GET['settings-updated']) and settings errors were saved
+ * to the 'settings_errors' transient then those errors will be returned instead. This
+ * is used to pass errors back across pageloads.
*
- * @param unknown_type $page
- * @param unknown_type $section
+ * Use the $sanitize argument to manually re-sanitize the option before returning errors.
+ * This is useful if you have errors or notices you want to show even when the user
+ * hasn't submitted data (i.e. when they first load an options page, or in the {@see 'admin_notices'}
+ * action hook).
+ *
+ * @since 3.0.0
+ *
+ * @global array $wp_settings_errors Storage array of errors registered during this pageload
+ *
+ * @param string $setting Optional slug title of a specific setting who's errors you want.
+ * @param boolean $sanitize Whether to re-sanitize the setting value before returning errors.
+ * @return array Array of settings errors
*/
-function do_settings_fields($page, $section) {
- global $wp_settings_fields;
+function get_settings_errors( $setting = '', $sanitize = false ) {
+ global $wp_settings_errors;
- if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) )
- return;
+ /*
+ * If $sanitize is true, manually re-run the sanitization for this option
+ * This allows the $sanitize_callback from register_setting() to run, adding
+ * any settings errors you want to show by default.
+ */
+ if ( $sanitize )
+ sanitize_option( $setting, get_option( $setting ) );
- foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
- echo '
';
- if ( !empty($field['args']['label_for']) )
- echo '' . $field['title'] . ' ';
- else
- echo '' . $field['title'] . ' ';
- echo '';
- call_user_func($field['callback'], $field['args']);
- echo ' ';
- echo ' ';
+ // If settings were passed back from options.php then use them.
+ if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] && get_transient( 'settings_errors' ) ) {
+ $wp_settings_errors = array_merge( (array) $wp_settings_errors, get_transient( 'settings_errors' ) );
+ delete_transient( 'settings_errors' );
+ }
+
+ // Check global in case errors have been added on this pageload.
+ if ( ! count( $wp_settings_errors ) )
+ return array();
+
+ // Filter the results to those of a specific setting if one was set.
+ if ( $setting ) {
+ $setting_errors = array();
+ foreach ( (array) $wp_settings_errors as $key => $details ) {
+ if ( $setting == $details['setting'] )
+ $setting_errors[] = $wp_settings_errors[$key];
+ }
+ return $setting_errors;
}
+
+ return $wp_settings_errors;
}
/**
- * {@internal Missing Short Description}}
+ * Display settings errors registered by add_settings_error().
*
- * @since unknown
+ * Part of the Settings API. Outputs a div for each error retrieved by
+ * get_settings_errors().
*
- * @param unknown_type $page
+ * This is called automatically after a settings page based on the
+ * Settings API is submitted. Errors should be added during the validation
+ * callback function for a setting defined in register_setting().
+ *
+ * The $sanitize option is passed into get_settings_errors() and will
+ * re-run the setting sanitization
+ * on its current value.
+ *
+ * The $hide_on_update option will cause errors to only show when the settings
+ * page is first loaded. if the user has already saved new values it will be
+ * hidden to avoid repeating messages already shown in the default error
+ * reporting after submission. This is useful to show general errors like
+ * missing settings when the user arrives at the settings page.
+ *
+ * @since 3.0.0
+ *
+ * @param string $setting Optional slug title of a specific setting who's errors you want.
+ * @param bool $sanitize Whether to re-sanitize the setting value before returning errors.
+ * @param bool $hide_on_update If set to true errors will not be shown if the settings page has
+ * already been submitted.
*/
-function manage_columns_prefs($page) {
- $columns = get_column_headers($page);
+function settings_errors( $setting = '', $sanitize = false, $hide_on_update = false ) {
- $hidden = get_hidden_columns($page);
+ if ( $hide_on_update && ! empty( $_GET['settings-updated'] ) )
+ return;
- foreach ( $columns as $column => $title ) {
- // Can't hide these
- if ( 'cb' == $column || 'title' == $column || 'name' == $column || 'username' == $column || 'media' == $column || 'comment' == $column )
- continue;
- if ( empty($title) )
- continue;
+ $settings_errors = get_settings_errors( $setting, $sanitize );
+
+ if ( empty( $settings_errors ) )
+ return;
- if ( 'comments' == $column )
- $title = __('Comments');
- $id = "$column-hide";
- echo '
';
- echo ' ';
- echo "$title \n";
+ $output = '';
+ foreach ( $settings_errors as $key => $details ) {
+ $css_id = 'setting-error-' . $details['code'];
+ $css_class = $details['type'] . ' settings-error notice is-dismissible';
+ $output .= "
\n";
+ $output .= "
{$details['message']}
";
+ $output .= "
\n";
}
+ echo $output;
}
/**
- * {@internal Missing Short Description}}
+ * Outputs the modal window used for attaching media to posts or pages in the media-listing screen.
*
- * @since unknown
+ * @since 2.7.0
*
- * @param unknown_type $found_action
+ * @param string $found_action
*/
function find_posts_div($found_action = '') {
?>
-
-
+
post_password ) ) echo esc_attr( $post->post_password );
-}
-
-/**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- */
-function favorite_actions( $screen = null ) {
- switch ( $screen ) {
- case 'post-new.php':
- $default_action = array('edit.php' => array(__('Edit Posts'), 'edit_posts'));
- break;
- case 'edit-pages.php':
- $default_action = array('page-new.php' => array(__('New Page'), 'edit_pages'));
- break;
- case 'page-new.php':
- $default_action = array('edit-pages.php' => array(__('Edit Pages'), 'edit_pages'));
- break;
- case 'upload.php':
- $default_action = array('media-new.php' => array(__('New Media'), 'upload_files'));
- break;
- case 'media-new.php':
- $default_action = array('upload.php' => array(__('Edit Media'), 'upload_files'));
- break;
- case 'link-manager.php':
- $default_action = array('link-add.php' => array(__('New Link'), 'manage_links'));
- break;
- case 'link-add.php':
- $default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links'));
- break;
- case 'users.php':
- $default_action = array('user-new.php' => array(__('New User'), 'create_users'));
- break;
- case 'user-new.php':
- $default_action = array('users.php' => array(__('Edit Users'), 'edit_users'));
- break;
- case 'plugins.php':
- $default_action = array('plugin-install.php' => array(__('Install Plugins'), 'install_plugins'));
- break;
- case 'plugin-install.php':
- $default_action = array('plugins.php' => array(__('Manage Plugins'), 'activate_plugins'));
- break;
- case 'themes.php':
- $default_action = array('theme-install.php' => array(__('Install Themes'), 'install_themes'));
- break;
- case 'theme-install.php':
- $default_action = array('themes.php' => array(__('Manage Themes'), 'switch_themes'));
- break;
- default:
- $default_action = array('post-new.php' => array(__('New Post'), 'edit_posts'));
- break;
- }
-
- $actions = array(
- 'post-new.php' => array(__('New Post'), 'edit_posts'),
- 'edit.php?post_status=draft' => array(__('Drafts'), 'edit_posts'),
- 'page-new.php' => array(__('New Page'), 'edit_pages'),
- 'media-new.php' => array(__('Upload'), 'upload_files'),
- 'edit-comments.php' => array(__('Comments'), 'moderate_comments')
- );
-
- $default_key = array_keys($default_action);
- $default_key = $default_key[0];
- if ( isset($actions[$default_key]) )
- unset($actions[$default_key]);
- $actions = array_merge($default_action, $actions);
- $actions = apply_filters('favorite_actions', $actions);
-
- $allowed_actions = array();
- foreach ( $actions as $action => $data ) {
- if ( current_user_can($data[1]) )
- $allowed_actions[$action] = $data[0];
- }
-
- if ( empty($allowed_actions) )
- return;
-
- $first = array_keys($allowed_actions);
- $first = $first[0];
- echo '
';
- echo '
';
- echo '
';
-
- array_shift($allowed_actions);
-
- foreach ( $allowed_actions as $action => $label) {
- echo "
\n";
- }
- echo "
\n";
+ $post = get_post();
+ if ( isset( $post->post_password ) )
+ echo esc_attr( $post->post_password );
}
/**
@@ -3360,64 +1543,111 @@ function favorite_actions( $screen = null ) {
* returned.
*
* @since 2.7.0
- * @param int $id The post id. If not supplied the global $post is used.
*
+ * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
+ * @return string The post title if set.
*/
-function _draft_or_post_title($post_id = 0)
-{
- $title = get_the_title($post_id);
- if ( empty($title) )
- $title = __('(no title)');
- return $title;
+function _draft_or_post_title( $post = 0 ) {
+ $title = get_the_title( $post );
+ if ( empty( $title ) )
+ $title = __( '(no title)' );
+ return esc_html( $title );
}
/**
- * Display the search query.
+ * Displays the search query.
*
- * A simple wrapper to display the "s" parameter in a GET URI. This function
- * should only be used when {@link the_search_query()} cannot.
+ * A simple wrapper to display the "s" parameter in a `GET` URI. This function
+ * should only be used when the_search_query() cannot.
*
- * @uses attr
* @since 2.7.0
- *
*/
function _admin_search_query() {
- echo isset($_GET['s']) ? esc_attr( stripslashes( $_GET['s'] ) ) : '';
+ echo isset($_REQUEST['s']) ? esc_attr( wp_unslash( $_REQUEST['s'] ) ) : '';
}
/**
* Generic Iframe header for use with Thickbox
*
* @since 2.7.0
- * @param string $title Title of the Iframe page.
- * @param bool $limit_styles Limit styles to colour-related styles only (unless others are enqueued).
*
+ * @global string $hook_suffix
+ * @global string $admin_body_class
+ * @global WP_Locale $wp_locale
+ *
+ * @param string $title Optional. Title of the Iframe page. Default empty.
+ * @param bool $deprecated Not used.
*/
-function iframe_header( $title = '', $limit_styles = false ) {
-?>
- >
-
-
+function iframe_header( $title = '', $deprecated = false ) {
+ show_admin_bar( false );
+ global $hook_suffix, $admin_body_class, $wp_locale;
+ $admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);
+
+ $current_screen = get_current_screen();
+
+ @header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
+ _wp_admin_html_begin();
+?>
› —
->
+
+ class="wp-admin wp-core-ui no-js iframe ">
+
+ /*
+ * We're going to hide any footer output on iFrame pages,
+ * but run the hooks anyway since they output JavaScript
+ * or other needed content.
+ */
+
+ /**
+ * @global string $hook_suffix
+ */
+ global $hook_suffix;
+ ?>
+ /** This action is documented in wp-admin/admin-footer.php */
+ do_action( 'admin_footer', $hook_suffix );
+
+ /** This action is documented in wp-admin/admin-footer.php */
+ do_action( "admin_print_footer_scripts-$hook_suffix" );
+
+ /** This action is documented in wp-admin/admin-footer.php */
+ do_action( 'admin_print_footer_scripts' );
+?>
@@ -3440,320 +1686,138 @@ function iframe_footer() {
post_password) )
- $post_states[] = __('Password protected');
+ $post_states['protected'] = __('Password protected');
if ( 'private' == $post->post_status && 'private' != $post_status )
- $post_states[] = __('Private');
+ $post_states['private'] = __('Private');
if ( 'draft' == $post->post_status && 'draft' != $post_status )
- $post_states[] = __('Draft');
+ $post_states['draft'] = __('Draft');
if ( 'pending' == $post->post_status && 'pending' != $post_status )
- /* translators: post state */
- $post_states[] = _x('Pending', 'post state');
+ $post_states['pending'] = _x('Pending', 'post status');
if ( is_sticky($post->ID) )
- $post_states[] = __('Sticky');
+ $post_states['sticky'] = __('Sticky');
+
+ if ( 'future' === $post->post_status ) {
+ $post_states['scheduled'] = __( 'Scheduled' );
+ }
- $post_states = apply_filters( 'display_post_states', $post_states );
+ if ( 'page' === get_option( 'show_on_front' ) ) {
+ if ( intval( get_option( 'page_on_front' ) ) === $post->ID ) {
+ $post_states['page_on_front'] = __( 'Front Page' );
+ }
+
+ if ( intval( get_option( 'page_for_posts' ) ) === $post->ID ) {
+ $post_states['page_for_posts'] = __( 'Posts Page' );
+ }
+ }
+
+ /**
+ * Filters the default post display states used in the posts list table.
+ *
+ * @since 2.8.0
+ *
+ * @param array $post_states An array of post display states.
+ * @param WP_Post $post The current post object.
+ */
+ $post_states = apply_filters( 'display_post_states', $post_states, $post );
if ( ! empty($post_states) ) {
$state_count = count($post_states);
$i = 0;
- echo ' - ';
+ echo ' — ';
foreach ( $post_states as $state ) {
++$i;
( $i == $state_count ) ? $sep = '' : $sep = ', ';
echo "
$state$sep ";
}
}
-}
-
-function screen_meta($screen) {
- global $wp_meta_boxes, $_wp_contextual_help;
-
- $screen = str_replace('.php', '', $screen);
- $screen = str_replace('-new', '', $screen);
- $screen = str_replace('-add', '', $screen);
- $screen = apply_filters('screen_meta_screen', $screen);
-
- $column_screens = get_column_headers($screen);
- $meta_screens = array('index' => 'dashboard');
-
- if ( isset($meta_screens[$screen]) )
- $screen = $meta_screens[$screen];
- $show_screen = false;
- $show_on_screen = false;
- if ( !empty($wp_meta_boxes[$screen]) || !empty($column_screens) ) {
- $show_screen = true;
- $show_on_screen = true;
- }
-
- $screen_options = screen_options($screen);
- if ( $screen_options )
- $show_screen = true;
-
- if ( !isset($_wp_contextual_help) )
- $_wp_contextual_help = array();
-
- $settings = '';
-
- switch ( $screen ) {
- case 'post':
- if ( !isset($_wp_contextual_help['post']) ) {
- $help = drag_drop_help();
- $help .= '
' . __('Writing Posts ') . '
';
- $_wp_contextual_help['post'] = $help;
- }
- break;
- case 'page':
- if ( !isset($_wp_contextual_help['page']) ) {
- $help = drag_drop_help();
- $_wp_contextual_help['page'] = $help;
- }
- break;
- case 'dashboard':
- if ( !isset($_wp_contextual_help['dashboard']) ) {
- $help = '
' . __('The modules on this screen can be arranged in several columns. You can select the number of columns from the Screen Options tab.') . "
\n";
- $help .= drag_drop_help();
- $_wp_contextual_help['dashboard'] = $help;
- }
- break;
- case 'link':
- if ( !isset($_wp_contextual_help['link']) ) {
- $help = drag_drop_help();
- $_wp_contextual_help['link'] = $help;
- }
- break;
- case 'options-general':
- if ( !isset($_wp_contextual_help['options-general']) )
- $_wp_contextual_help['options-general'] = __('
General Settings ');
- break;
- case 'theme-install':
- case 'plugin-install':
- if ( ( !isset($_GET['tab']) || 'dashboard' == $_GET['tab'] ) && !isset($_wp_contextual_help[$screen]) ) {
- $help = plugins_search_help();
- $_wp_contextual_help[$screen] = $help;
- }
- break;
- case 'widgets':
- if ( !isset($_wp_contextual_help['widgets']) ) {
- $help = widgets_help();
- $_wp_contextual_help['widgets'] = $help;
- }
- $settings = '
' . __('Enable accessibility mode') . ' ' . __('Disable accessibility mode') . "
\n";
- $show_screen = true;
- break;
- }
-?>
-
-' . __('Most of the modules on this screen can be moved. If you hover your mouse over the title bar of a module you’ll notice the 4 arrow cursor appears to let you know it is movable. Click on it, hold down the mouse button and start dragging the module to a new location. As you drag the module, notice the dotted gray box that also moves. This box indicates where the module will be placed when you release the mouse button.') . '
-
' . __('The same modules can be expanded and collapsed by clicking once on their title bar and also completely hidden from the Screen Options tab.') . '
-';
-}
-
-function plugins_search_help() {
- return '
-
' . __('Search help') . '
' .
- '
' . __('You may search based on 3 criteria:') . ' ' .
- __('Term: Searches theme names and descriptions for the specified term.') . ' ' .
- __('Tag: Searches for themes tagged as such.') . ' ' .
- __('Author: Searches for themes created by the Author, or which the Author contributed to.') . '
-';
-}
+ if ( current_theme_supports( 'custom-header') ) {
+ $meta_header = get_post_meta($post->ID, '_wp_attachment_is_custom_header', true );
-function widgets_help() {
- return '
-
' . __('Widgets are added and arranged by simple drag ’n’ drop. If you hover your mouse over the titlebar of a widget, you’ll see a 4-arrow cursor which indicates that the widget is movable. Click on the titlebar, hold down the mouse button and drag the widget to a sidebar. As you drag, you’ll see a dotted box that also moves. This box shows where the widget will go once you drop it.') . '
-
' . __('To remove a widget from a sidebar, drag it back to Available Widgets or click on the arrow on its titlebar to reveal its settings, and then click Remove.') . '
-
' . __('To remove a widget from a sidebar and keep its configuration , drag it to Inactive Widgets.') . '
-
' . __('The Inactive Widgets area stores widgets that are configured but not curently used. If you change themes and the new theme has fewer sidebars than the old, all extra widgets will be stored to Inactive Widgets automatically.') . '
-';
-}
+ if ( is_random_header_image() ) {
+ $header_images = wp_list_pluck( get_uploaded_header_images(), 'attachment_id' );
-function screen_layout($screen) {
- global $screen_layout_columns;
+ if ( $meta_header == $stylesheet && in_array( $post->ID, $header_images ) ) {
+ $media_states[] = __( 'Header Image' );
+ }
+ } else {
+ $header_image = get_header_image();
- $columns = array('dashboard' => 4, 'post' => 2, 'page' => 2, 'link' => 2);
- $columns = apply_filters('screen_layout_columns', $columns, $screen);
+ // Display "Header Image" if the image was ever used as a header image
+ if ( ! empty( $meta_header ) && $meta_header == $stylesheet && $header_image !== wp_get_attachment_url( $post->ID ) ) {
+ $media_states[] = __( 'Header Image' );
+ }
- if ( !isset($columns[$screen]) ) {
- $screen_layout_columns = 0;
- return '';
- }
+ // Display "Current Header Image" if the image is currently the header image
+ if ( $header_image && $header_image == wp_get_attachment_url( $post->ID ) ) {
+ $media_states[] = __( 'Current Header Image' );
+ }
+ }
+ }
- $screen_layout_columns = get_user_option("screen_layout_$screen");
- $num = $columns[$screen];
+ if ( current_theme_supports( 'custom-background') ) {
+ $meta_background = get_post_meta($post->ID, '_wp_attachment_is_custom_background', true );
- if ( ! $screen_layout_columns )
- $screen_layout_columns = 2;
+ if ( ! empty( $meta_background ) && $meta_background == $stylesheet ) {
+ $media_states[] = __( 'Background Image' );
- $i = 1;
- $return = '
' . __('Screen Layout') . " \n
" . __('Number of Columns:') . "\n";
- while ( $i <= $num ) {
- $return .= " $i \n";
- ++$i;
+ $background_image = get_background_image();
+ if ( $background_image && $background_image == wp_get_attachment_url( $post->ID ) ) {
+ $media_states[] = __( 'Current Background Image' );
+ }
+ }
}
- $return .= "
\n";
- return $return;
-}
-function screen_options($screen) {
- switch ( $screen ) {
- case 'edit':
- $per_page_label = __('Posts per page:');
- break;
- case 'edit-pages':
- $per_page_label = __('Pages per page:');
- break;
- case 'edit-comments':
- $per_page_label = __('Comments per page:');
- break;
- case 'upload':
- $per_page_label = __('Media items per page:');
- break;
- case 'categories':
- $per_page_label = __('Categories per page:');
- break;
- case 'edit-tags':
- $per_page_label = __('Tags per page:');
- break;
- case 'plugins':
- $per_page_label = __('Plugins per page:');
- break;
- default:
- return '';
+ if ( $post->ID == get_option( 'site_icon' ) ) {
+ $media_states[] = __( 'Site Icon' );
}
- $option = str_replace( '-', '_', "${screen}_per_page" );
- $per_page = (int) get_user_option( $option, 0, false );
- if ( empty( $per_page ) || $per_page < 1 ) {
- if ( 'plugins' == $screen )
- $per_page = 999;
- else
- $per_page = 20;
+ if ( $post->ID == get_theme_mod( 'site_logo' ) ) {
+ $media_states[] = __( 'Logo' );
}
- if ( 'edit_comments_per_page' == $option )
- $per_page = apply_filters( 'comments_per_page', $per_page, isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all' );
- elseif ( 'categories' == $option )
- $per_page = apply_filters( 'edit_categories_per_page', $per_page );
- else
- $per_page = apply_filters( $option, $per_page );
-
- $return = '
' . __('Options') . " \n";
- $return .= "
\n";
- if ( !empty($per_page_label) )
- $return .= "$per_page_label \n";
- $return .= " ";
- $return .= " ";
- $return .= "
\n";
- return $return;
-}
-function screen_icon($name = '') {
- global $parent_file, $hook_suffix;
+ /**
+ * Filters the default media display states for items in the Media list table.
+ *
+ * @since 3.2.0
+ *
+ * @param array $media_states An array of media states. Default 'Header Image',
+ * 'Background Image', 'Site Icon', 'Logo'.
+ */
+ $media_states = apply_filters( 'display_media_states', $media_states );
- if ( empty($name) ) {
- if ( isset($parent_file) && !empty($parent_file) )
- $name = substr($parent_file, 0, -4);
- else
- $name = str_replace(array('.php', '-new', '-add'), '', $hook_suffix);
+ if ( ! empty( $media_states ) ) {
+ $state_count = count( $media_states );
+ $i = 0;
+ echo ' — ';
+ foreach ( $media_states as $state ) {
+ ++$i;
+ ( $i == $state_count ) ? $sep = '' : $sep = ', ';
+ echo "
$state$sep ";
+ }
}
-?>
-
-
'1' )`.
+ * These attributes will be output as `attribute="value"`, such as
+ * `tabindex="1"`. Other attributes can also be provided as a string such
+ * as `tabindex="1"`, though the array format is typically cleaner.
+ * Default empty.
+ * @return string Submit button HTML.
+ */
+function get_submit_button( $text = '', $type = 'primary large', $name = 'submit', $wrap = true, $other_attributes = '' ) {
+ if ( ! is_array( $type ) )
+ $type = explode( ' ', $type );
+
+ $button_shorthand = array( 'primary', 'small', 'large' );
+ $classes = array( 'button' );
+ foreach ( $type as $t ) {
+ if ( 'secondary' === $t || 'button-secondary' === $t )
+ continue;
+ $classes[] = in_array( $t, $button_shorthand ) ? 'button-' . $t : $t;
+ }
+ // Remove empty items, remove duplicate items, and finally build a string.
+ $class = implode( ' ', array_unique( array_filter( $classes ) ) );
+
+ $text = $text ? $text : __( 'Save Changes' );
+
+ // Default the id attribute to $name unless an id was specifically provided in $other_attributes
+ $id = $name;
+ if ( is_array( $other_attributes ) && isset( $other_attributes['id'] ) ) {
+ $id = $other_attributes['id'];
+ unset( $other_attributes['id'] );
+ }
+
+ $attributes = '';
+ if ( is_array( $other_attributes ) ) {
+ foreach ( $other_attributes as $attribute => $value ) {
+ $attributes .= $attribute . '="' . esc_attr( $value ) . '" '; // Trailing space is important
+ }
+ } elseif ( ! empty( $other_attributes ) ) { // Attributes provided as a string
+ $attributes = $other_attributes;
+ }
+
+ // Don't output empty name and id attributes.
+ $name_attr = $name ? ' name="' . esc_attr( $name ) . '"' : '';
+ $id_attr = $id ? ' id="' . esc_attr( $id ) . '"' : '';
+
+ $button = '
';
+
+ if ( $wrap ) {
+ $button = '
' . $button . '
';
+ }
+
+ return $button;
+}
+
+/**
+ *
+ * @global bool $is_IE
+ */
+function _wp_admin_html_begin() {
+ global $is_IE;
+
+ $admin_html_class = ( is_admin_bar_showing() ) ? 'wp-toolbar' : '';
+
+ if ( $is_IE )
+ @header('X-UA-Compatible: IE=edge');
+
?>
+
+
+
+ >
+
+
+
+ '_invalid', 'base' => '_are_belong_to_us' );
+ }
+
+ return WP_Screen::get( $hook_name );
+}
+
+/**
+ * Output the HTML for restoring the post data from DOM storage
+ *
+ * @since 3.6.0
+ * @access private
+ */
+function _local_storage_notice() {
+ ?>
+
+ 0,
+ 'type' => 'rating',
+ 'number' => 0,
+ 'echo' => true,
+ );
+ $r = wp_parse_args( $args, $defaults );
+
+ // Non-english decimal places when the $rating is coming from a string
+ $rating = str_replace( ',', '.', $r['rating'] );
+
+ // Convert Percentage to star rating, 0..5 in .5 increments
+ if ( 'percent' == $r['type'] ) {
+ $rating = round( $rating / 10, 0 ) / 2;
+ }
+
+ // Calculate the number of each type of star needed
+ $full_stars = floor( $rating );
+ $half_stars = ceil( $rating - $full_stars );
+ $empty_stars = 5 - $full_stars - $half_stars;
+
+ if ( $r['number'] ) {
+ /* translators: 1: The rating, 2: The number of ratings */
+ $format = _n( '%1$s rating based on %2$s rating', '%1$s rating based on %2$s ratings', $r['number'] );
+ $title = sprintf( $format, number_format_i18n( $rating, 1 ), number_format_i18n( $r['number'] ) );
+ } else {
+ /* translators: 1: The rating */
+ $title = sprintf( __( '%s rating' ), number_format_i18n( $rating, 1 ) );
+ }
+
+ $output = '
';
+ $output .= '
' . $title . ' ';
+ $output .= str_repeat( '
', $full_stars );
+ $output .= str_repeat( '
', $half_stars );
+ $output .= str_repeat( '
', $empty_stars );
+ $output .= '
';
+
+ if ( $r['echo'] ) {
+ echo $output;
+ }
+
+ return $output;
+}
+
+/**
+ * Output a notice when editing the page for posts (internal use only).
+ *
+ * @ignore
+ * @since 4.2.0
+ */
+function _wp_posts_page_notice() {
+ echo '
' . __( 'You are currently editing the page that shows your latest posts.' ) . '
';
+}