for each error retrieved by get_settings_errors().
+ * Part of the Settings API. Outputs a div for each error retrieved by
+ * {@see get_settings_errors()}.
*
- * 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()
+ * 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 {@see register_setting()}
*
- * The $sanitize option is passed into get_settings_errors() and will re-run the setting sanitization
+ * The $sanitize option is passed into {@see 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.
+ * 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
*
@@ -1276,13 +1476,13 @@ function settings_errors( $setting = '', $sanitize = false, $hide_on_update = fa
$settings_errors = get_settings_errors( $setting, $sanitize );
- if ( ! is_array( $settings_errors ) )
+ if ( empty( $settings_errors ) )
return;
$output = '';
foreach ( $settings_errors as $key => $details ) {
$css_id = 'setting-error-' . $details['code'];
- $css_class = $details['type'] . ' settings-error';
+ $css_class = $details['type'] . ' settings-error notice is-dismissible';
$output .= "
\n";
@@ -1295,40 +1495,33 @@ function settings_errors( $setting = '', $sanitize = false, $hide_on_update = fa
*
* @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 );
+ $post = get_post();
+ if ( isset( $post->post_password ) )
+ echo esc_attr( $post->post_password );
}
/**
@@ -1355,14 +1548,15 @@ function the_post_password() {
* returned.
*
* @since 2.7.0
- * @param int $post_id The post id. If not supplied the global $post is used.
- * @return string The post title if set
+ *
+ * @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 );
}
/**
@@ -1371,29 +1565,28 @@ function _draft_or_post_title( $post_id = 0 ) {
* A simple wrapper to display the "s" parameter in a GET URI. This function
* should only be used when {@link the_search_query()} cannot.
*
- * @uses attr
* @since 2.7.0
- *
*/
function _admin_search_query() {
- echo isset($_REQUEST['s']) ? esc_attr( stripslashes( $_REQUEST['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).
*
+ * @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, $current_user, $admin_body_class, $wp_locale;
+ 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();
?>
› —
@@ -1401,44 +1594,56 @@ function iframe_header( $title = '', $limit_styles = false ) {
wp_enqueue_style( 'colors' );
?>
- class="wp-admin no-js iframe ">
+
+ 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.
+ */
+ ?>
+ /** This action is documented in wp-admin/admin-footer.php */
+ do_action( 'admin_footer', '' );
+
+ /** This action is documented in wp-admin/admin-footer.php */
+ do_action( 'admin_print_footer_scripts' );
+?>
@@ -1481,7 +1694,23 @@ function _post_states($post) {
if ( is_sticky($post->ID) )
$post_states['sticky'] = __('Sticky');
- $post_states = apply_filters( 'display_post_states', $post_states );
+ if ( get_option( 'page_on_front' ) == $post->ID ) {
+ $post_states['page_on_front'] = __( 'Front Page' );
+ }
+
+ if ( get_option( 'page_for_posts' ) == $post->ID ) {
+ $post_states['page_for_posts'] = __( 'Posts Page' );
+ }
+
+ /**
+ * Filter 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 int $post The post ID.
+ */
+ $post_states = apply_filters( 'display_post_states', $post_states, $post );
if ( ! empty($post_states) ) {
$state_count = count($post_states);
@@ -1494,8 +1723,6 @@ function _post_states($post) {
}
}
- if ( get_post_format( $post->ID ) )
- echo ' -
' . get_post_format_string( get_post_format( $post->ID ) ) . ' ';
}
function _media_states( $post ) {
@@ -1514,6 +1741,14 @@ function _media_states( $post ) {
$media_states[] = __( 'Background Image' );
}
+ /**
+ * Filter 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'.
+ */
$media_states = apply_filters( 'display_media_states', $media_states );
if ( ! empty( $media_states ) ) {
@@ -1541,7 +1776,6 @@ function _media_states( $post ) {
function compression_test() {
?>
'1' ).
- * These attributes will be output as attribute="value", such as tabindex="1".
- * Defaults to no other attributes. Other attributes can also be provided as a
- * string such as 'tabindex="1"', though the array format is typically cleaner.
+ * @see get_submit_button()
+ *
+ * @param string $text The text of the button (defaults to 'Save Changes')
+ * @param string $type Optional. The type and CSS class(es) of the button. Core values
+ * include 'primary', 'secondary', 'delete'. Default 'primary'
+ * @param string $name The HTML name of the submit button. Defaults to "submit". If no
+ * id attribute is given in $other_attributes below, $name will be
+ * used as the button's id.
+ * @param bool $wrap True if the output button should be wrapped in a paragraph tag,
+ * false otherwise. Defaults to true
+ * @param array|string $other_attributes Other attributes that should be output with the button, mapping
+ * attributes to their values, such as setting tabindex to 1, etc.
+ * These key/value attribute pairs will be output as attribute="value",
+ * where attribute is the key. Other attributes can also be provided
+ * as a string such as 'tabindex="1"', though the array format is
+ * preferred. Default null.
*/
function submit_button( $text = null, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = null ) {
echo get_submit_button( $text, $type, $name, $wrap, $other_attributes );
@@ -1619,31 +1857,39 @@ function submit_button( $text = null, $type = 'primary', $name = 'submit', $wrap
*
* @since 3.1.0
*
- * @param string $text The text of the button (defaults to 'Save Changes')
- * @param string $type The type of button. One of: primary, secondary, delete
- * @param string $name The HTML name of the submit button. Defaults to "submit". If no id attribute
- * is given in $other_attributes below, $name will be used as the button's id.
- * @param bool $wrap True if the output button should be wrapped in a paragraph tag,
- * false otherwise. Defaults to true
- * @param array|string $other_attributes Other attributes that should be output with the button,
- * mapping attributes to their values, such as array( 'tabindex' => '1' ).
- * These attributes will be output as attribute="value", such as tabindex="1".
- * Defaults to no other attributes. Other attributes can also be provided as a
- * string such as 'tabindex="1"', though the array format is typically cleaner.
+ * @param string $text Optional. The text of the button. Default 'Save Changes'.
+ * @param string $type Optional. The type of button. Accepts 'primary', 'secondary',
+ * or 'delete'. Default 'primary large'.
+ * @param string $name Optional. The HTML name of the submit button. Defaults to "submit".
+ * If no id attribute is given in $other_attributes below, `$name` will
+ * be used as the button's id. Default 'submit'.
+ * @param bool $wrap Optional. True if the output button should be wrapped in a paragraph
+ * tag, false otherwise. Default true.
+ * @param array|string $other_attributes Optional. Other attributes that should be output with the button,
+ * mapping attributes to their values, such as `array( 'tabindex' => '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 = null, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = null ) {
- switch ( $type ) :
- case 'primary' :
- case 'secondary' :
- $class = 'button-' . $type;
- break;
- case 'delete' :
- $class = 'button-secondary delete';
- break;
- default :
- $class = $type; // Custom cases can just pass in the classes they want to be used
- endswitch;
- $text = ( null == $text ) ? __( 'Save Changes' ) : $text;
+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;
+ }
+ $class = implode( ' ', array_unique( $classes ) );
+
+ if ( 'delete' === $type )
+ $class = 'button-secondary delete';
+
+ $text = $text ? $text : __( 'Save Changes' );
// Default the id attribute to $name unless an id was specifically provided in $other_attributes
$id = $name;
@@ -1657,11 +1903,15 @@ function get_submit_button( $text = null, $type = 'primary', $name = 'submit', $
foreach ( $other_attributes as $attribute => $value ) {
$attributes .= $attribute . '="' . esc_attr( $value ) . '" '; // Trailing space is important
}
- } else if ( !empty( $other_attributes ) ) { // Attributes provided as a string
+ } elseif ( ! empty( $other_attributes ) ) { // Attributes provided as a string
$attributes = $other_attributes;
}
- $button = '
';
if ( $wrap ) {
@@ -1672,14 +1922,30 @@ function get_submit_button( $text = null, $type = 'primary', $name = 'submit', $
}
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');
+
?>
- >
+ >
@@ -1695,8 +1961,10 @@ final class WP_Internal_Pointers {
* All pointers can be disabled using the following:
* remove_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts' ) );
*
- * Individual pointers (e.g. wp330_toolbar) can be disabled using the following:
- * remove_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_wp330_toolbar' ) );
+ * Individual pointers (e.g. wp390_widgets) can be disabled using the following:
+ * remove_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_wp390_widgets' ) );
+ *
+ * @param string $hook_suffix The current admin page.
*/
public static function enqueue_scripts( $hook_suffix ) {
/*
@@ -1705,12 +1973,11 @@ final class WP_Internal_Pointers {
*/
$registered_pointers = array(
- 'index.php' => 'wp330_toolbar',
- 'post-new.php' => 'wp330_media_uploader',
- 'post.php' => 'wp330_media_uploader',
- 'themes.php' => array( 'wp330_saving_widgets', 'wp340_customize_current_theme_link' ),
- 'appearance_page_custom-header' => 'wp340_choose_image_from_library',
- 'appearance_page_custom-background' => 'wp340_choose_image_from_library',
+ 'post-new.php' => 'wp410_dfw',
+ 'post.php' => 'wp410_dfw',
+ 'edit.php' => 'wp360_locks',
+ 'widgets.php' => 'wp390_widgets',
+ 'themes.php' => 'wp390_widgets',
);
// Check if screen related pointer is registered
@@ -1720,10 +1987,7 @@ final class WP_Internal_Pointers {
$pointers = (array) $registered_pointers[ $hook_suffix ];
$caps_required = array(
- 'wp330_media_uploader' => array( 'upload_files' ),
- 'wp330_saving_widgets' => array( 'edit_theme_options', 'switch_themes' ),
- 'wp340_customize_current_theme_link' => array( 'edit_theme_options' ),
- 'wp340_choose_image_from_library' => array( 'edit_theme_options' ),
+ 'wp390_widgets' => array( 'edit_theme_options' ),
);
// Get dismissed pointers
@@ -1752,13 +2016,13 @@ final class WP_Internal_Pointers {
}
/**
- * Print the pointer javascript data.
+ * Print the pointer JavaScript data.
*
* @since 3.3.0
*
* @param string $pointer_id The pointer ID.
* @param string $selector The HTML elements, on which the pointer should be attached.
- * @param array $args Arguments to be passed to the pointer JS (see wp-pointer.dev.js).
+ * @param array $args Arguments to be passed to the pointer JS (see wp-pointer.js).
*/
private static function print_js( $pointer_id, $selector, $args ) {
if ( empty( $pointer_id ) || empty( $selector ) || empty( $args ) || empty( $args['content'] ) )
@@ -1766,9 +2030,8 @@ final class WP_Internal_Pointers {
?>
' . __( 'New Feature: Toolbar' ) . '';
- $content .= '
' . __( 'We’ve combined the admin bar and the old Dashboard header into one persistent toolbar. Hover over the toolbar items to see what’s new.' ) . '
';
+ public static function pointer_wp330_toolbar() {}
+ public static function pointer_wp330_media_uploader() {}
+ public static function pointer_wp330_saving_widgets() {}
+ public static function pointer_wp340_customize_current_theme_link() {}
+ public static function pointer_wp340_choose_image_from_library() {}
+ public static function pointer_wp350_media() {}
+ public static function pointer_wp360_revisions() {}
- if ( is_multisite() && is_super_admin() )
- $content .= '
' . __( 'Network Admin is now located in the My Sites menu.' ) . '
';
+ public static function pointer_wp360_locks() {
+ if ( ! is_multi_author() ) {
+ return;
+ }
+
+ $content = '
' . __( 'Edit Lock' ) . ' ';
+ $content .= '
' . __( 'Someone else is editing this. No need to refresh; the lock will disappear when they’re done.' ) . '
';
- WP_Internal_Pointers::print_js( 'wp330_toolbar', '#wpadminbar', array(
- 'content' => $content,
- 'position' => array( 'edge' => 'top', 'align' => 'center' ),
+ self::print_js( 'wp360_locks', 'tr.wp-locked .locked-indicator', array(
+ 'content' => $content,
+ 'position' => array( 'edge' => 'left', 'align' => 'left' ),
) );
}
- /**
- * Print 'Updated Media Uploader' for 3.3.0.
- *
- * @since 3.3.0
- */
- public static function pointer_wp330_media_uploader() {
- $content = '
' . __( 'Updated Media Uploader' ) . ' ';
- $content .= '
' . __( 'The single media icon now launches the uploader for all file types, and the new drag and drop interface makes uploading a breeze.' ) . '
';
+ public static function pointer_wp390_widgets() {
+ if ( ! current_theme_supports( 'widgets' ) ) {
+ return;
+ }
- WP_Internal_Pointers::print_js( 'wp330_media_uploader', '#content-add_media', array(
- 'content' => $content,
- 'position' => array( 'edge' => is_rtl() ? 'right' : 'left', 'align' => 'center' ),
- ) );
- }
+ $content = '
' . __( 'New Feature: Live Widget Previews' ) . ' ';
+ $content .= '
' . __( 'Add, edit, and play around with your widgets from the Customizer.' ) . ' ' . __( 'Preview your changes in real-time and only save them when you’re ready.' ) . '
';
- /**
- * Print 'New Feature: Saving Widgets' for 3.3.0.
- *
- * @since 3.3.0
- */
- public static function pointer_wp330_saving_widgets() {
- $content = '
' . __( 'New Feature: Saving Widgets' ) . ' ';
- $content .= '
' . __( 'If you change your mind and revert to your previous theme, we’ll put the widgets back the way you had them.' ) . '
';
+ if ( 'themes' === get_current_screen()->id ) {
+ $selector = '.theme.active .customize';
+ $position = array( 'edge' => is_rtl() ? 'right' : 'left', 'align' => 'center' );
+ } else {
+ $selector = 'a[href^="customize.php"]';
+ if ( is_rtl() ) {
+ $position = array( 'edge' => 'right', 'align' => 'center', 'my' => 'right-5px' );
+ } else {
+ $position = array( 'edge' => 'left', 'align' => 'center', 'my' => 'left-5px' );
+ }
+ }
- WP_Internal_Pointers::print_js( 'wp330_saving_widgets', '#message2', array(
- 'content' => $content,
- 'position' => array( 'edge' => 'top', 'align' => is_rtl() ? 'right' : 'left' ),
+ self::print_js( 'wp390_widgets', $selector, array(
+ 'content' => $content,
+ 'position' => $position,
) );
}
- /**
- * Print 'New Feature: Current Theme Customize Link' for 3.4.0.
- *
- * @since 3.4.0
- */
- public static function pointer_wp340_customize_current_theme_link() {
- $content = '
' . __( 'New Feature: Customizer' ) . ' ';
- $content .= '
' . __( 'Click Customize to change the header, background, title and menus of the current theme, all in one place.' ) . '
';
- $content .= '
' . __( 'Click the Live Preview links in the Available Themes list below to customize and preview another theme before activating it.' ) . '
';
-
- WP_Internal_Pointers::print_js( 'wp340_customize_current_theme_link', '#customize-current-theme-link', array(
- 'content' => $content,
- 'position' => array( 'edge' => 'top', 'align' => is_rtl() ? 'right' : 'left', 'offset' => is_rtl() ? '32 0' : '-32 0' ),
- ) );
- }
+ public static function pointer_wp410_dfw() {
+ // Don't show when editor-scrolling is not used.
+ if ( empty( $GLOBALS['_wp_editor_expand'] ) ) {
+ return;
+ }
- /**
- * Print 'New Feature: Choose Image from Library' for 3.4.0.
- *
- * @since 3.4.0
- */
- public static function pointer_wp340_choose_image_from_library() {
- $content = '
' . __( 'New Feature: Choose Image from Library' ) . ' ';
- $content .= '
' . __( 'Want to use an image you uploaded earlier? Select it from your media library instead of uploading it again.' ) . '
';
+ $content = '
' . __( 'Distraction-Free Writing' ) . ' ';
+ $content .= '
' . __( 'Enable distraction-free writing mode, and everything surrounding the editor will fade away when you start typing. Move your mouse out of the editor to reveal everything again.' ) . '
';
- WP_Internal_Pointers::print_js( 'wp340_choose_image_from_library', '#choose-from-library-link', array(
- 'content' => $content,
- 'position' => array( 'edge' => 'top', 'align' => is_rtl() ? 'right' : 'left', 'defer_loading' => true ),
+ if ( is_rtl() ) {
+ $position = array( 'edge' => 'left', 'align' => 'center', 'my' => 'left+40 top-11', 'at' => 'left top' );
+ } else {
+ $position = array( 'edge' => 'right', 'align' => 'center', 'my' => 'right-40 top-11', 'at' => 'right top' );
+ }
+
+ self::print_js( 'wp410_dfw', '#wp-content-wrap', array(
+ 'content' => $content,
+ 'position' => $position,
) );
}
@@ -1875,9 +2132,11 @@ final class WP_Internal_Pointers {
* Prevents new users from seeing existing 'new feature' pointers.
*
* @since 3.3.0
+ *
+ * @param int $user_id User ID.
*/
public static function dismiss_pointers_for_new_users( $user_id ) {
- add_user_meta( $user_id, 'dismissed_wp_pointers', 'wp330_toolbar,wp330_media_uploader,wp330_saving_widgets,wp340_choose_image_from_library,wp340_customize_current_theme_link' );
+ add_user_meta( $user_id, 'dismissed_wp_pointers', 'wp360_locks,wp390_widgets' );
}
}
@@ -1900,3 +2159,90 @@ function convert_to_screen( $hook_name ) {
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,
+ );
+ $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 ) );
+ }
+
+ echo '
';
+ echo '
' . $title . ' ';
+ echo str_repeat( '
', $full_stars );
+ echo str_repeat( '
', $half_stars );
+ echo str_repeat( '
', $empty_stars);
+ echo '
';
+}
+
+/**
+ * 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.' ) . '
';
+}