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
*
- * @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.
- * @param boolean $hide_on_update If set to true errors will not be shown if the settings page has already been submitted.
+ * @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 settings_errors( $setting = '', $sanitize = false, $hide_on_update = false ) {
@@ -1276,13 +1460,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";
@@ -1291,44 +1475,37 @@ function settings_errors( $setting = '', $sanitize = false, $hide_on_update = fa
}
/**
- * {@internal Missing Short Description}}
+ * Outputs the modal window used for attaching media to posts or pages in the media-listing screen.
*
* @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 +1532,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 +1549,32 @@ 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).
*
+ * @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, $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 +1582,60 @@ 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' );
+?>
@@ -1462,6 +1667,10 @@ function iframe_footer() {
post_status && 'draft' != $post_status )
$post_states['draft'] = __('Draft');
if ( 'pending' == $post->post_status && 'pending' != $post_status )
- /* translators: post state */
- $post_states['pending'] = _x('Pending', 'post state');
+ $post_states['pending'] = _x('Pending', 'post status');
if ( is_sticky($post->ID) )
$post_states['sticky'] = __('Sticky');
- $post_states = apply_filters( 'display_post_states', $post_states );
+ if ( 'future' === $post->post_status ) {
+ $post_states['scheduled'] = __( 'Scheduled' );
+ }
+
+ 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' );
+ }
+ }
+
+ /**
+ * 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 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 = ', ';
@@ -1494,10 +1724,12 @@ function _post_states($post) {
}
}
- if ( get_post_format( $post->ID ) )
- echo ' -
' . get_post_format_string( get_post_format( $post->ID ) ) . '';
}
+/**
+ *
+ * @param WP_Post $post
+ */
function _media_states( $post ) {
$media_states = array();
$stylesheet = get_option('stylesheet');
@@ -1514,12 +1746,28 @@ function _media_states( $post ) {
$media_states[] = __( 'Background Image' );
}
+ if ( $post->ID == get_option( 'site_icon' ) ) {
+ $media_states[] = __( 'Site Icon' );
+ }
+
+ if ( $post->ID == get_theme_mod( 'site_logo' ) ) {
+ $media_states[] = __( 'Logo' );
+ }
+
+ /**
+ * 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', 'Site Icon', 'Logo'.
+ */
$media_states = apply_filters( 'display_media_states', $media_states );
if ( ! empty( $media_states ) ) {
$state_count = count( $media_states );
$i = 0;
- echo ' - ';
+ echo ' — ';
foreach ( $media_states as $state ) {
++$i;
( $i == $state_count ) ? $sep = '' : $sep = ', ';
@@ -1541,7 +1789,7 @@ 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 +1871,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 +1917,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 ) {
@@ -1671,232 +1935,152 @@ function get_submit_button( $text = null, $type = 'primary', $name = 'submit', $
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');
+
?>
- >
+ >
pointer_id )
- */
-
- $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',
- );
-
- // Check if screen related pointer is registered
- if ( empty( $registered_pointers[ $hook_suffix ] ) )
- return;
-
- $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' ),
- );
-
- // Get dismissed pointers
- $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
-
- $got_pointers = false;
- foreach ( array_diff( $pointers, $dismissed ) as $pointer ) {
- if ( isset( $caps_required[ $pointer ] ) ) {
- foreach ( $caps_required[ $pointer ] as $cap ) {
- if ( ! current_user_can( $cap ) )
- continue 2;
- }
- }
-
- // Bind pointer print function
- add_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_' . $pointer ) );
- $got_pointers = true;
- }
-
- if ( ! $got_pointers )
- return;
-
- // Add pointers script and style to queue
- wp_enqueue_style( 'wp-pointer' );
- wp_enqueue_script( 'wp-pointer' );
- }
-
- /**
- * 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).
- */
- private static function print_js( $pointer_id, $selector, $args ) {
- if ( empty( $pointer_id ) || empty( $selector ) || empty( $args ) || empty( $args['content'] ) )
- return;
-
- ?>
-
- '_invalid', 'base' => '_are_belong_to_us' );
}
- public static function pointer_wp330_toolbar() {
- $content = '
' . __( '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.' ) . '
';
+ return WP_Screen::get( $hook_name );
+}
- if ( is_multisite() && is_super_admin() )
- $content .= '
' . __( 'Network Admin is now located in the My Sites menu.' ) . '
';
+/**
+ * Output the HTML for restoring the post data from DOM storage
+ *
+ * @since 3.6.0
+ * @access private
+ */
+function _local_storage_notice() {
+ ?>
+
+ $content,
- 'position' => array( 'edge' => 'top', 'align' => 'center' ),
- ) );
- }
+/**
+ * Output a HTML element with a star rating for a given rating.
+ *
+ * Outputs a HTML element with the star rating exposed on a 0..5 scale in
+ * half star increments (ie. 1, 1.5, 2 stars). Optionally, if specified, the
+ * number of ratings may also be displayed by passing the $number parameter.
+ *
+ * @since 3.8.0
+ * @since 4.4.0 Introduced the `echo` parameter.
+ *
+ * @param array $args {
+ * Optional. Array of star ratings arguments.
+ *
+ * @type int $rating The rating to display, expressed in either a 0.5 rating increment,
+ * or percentage. Default 0.
+ * @type string $type Format that the $rating is in. Valid values are 'rating' (default),
+ * or, 'percent'. Default 'rating'.
+ * @type int $number The number of ratings that makes up this rating. Default 0.
+ * @type bool $echo Whether to echo the generated markup. False to return the markup instead
+ * of echoing it. Default true.
+ * }
+ */
+function wp_star_rating( $args = array() ) {
+ $defaults = array(
+ 'rating' => 0,
+ 'type' => 'rating',
+ 'number' => 0,
+ 'echo' => true,
+ );
+ $r = wp_parse_args( $args, $defaults );
- /**
- * 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.' ) . '
';
+ // Non-english decimal places when the $rating is coming from a string
+ $rating = str_replace( ',', '.', $r['rating'] );
- WP_Internal_Pointers::print_js( 'wp330_media_uploader', '#content-add_media', array(
- 'content' => $content,
- 'position' => array( 'edge' => is_rtl() ? 'right' : 'left', 'align' => 'center' ),
- ) );
+ // Convert Percentage to star rating, 0..5 in .5 increments
+ if ( 'percent' == $r['type'] ) {
+ $rating = round( $rating / 10, 0 ) / 2;
}
- /**
- * 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.' ) . '
';
-
- WP_Internal_Pointers::print_js( 'wp330_saving_widgets', '#message2', array(
- 'content' => $content,
- 'position' => array( 'edge' => 'top', 'align' => is_rtl() ? 'right' : 'left' ),
- ) );
- }
+ // 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;
- /**
- * 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' ),
- ) );
+ 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 ) );
}
- /**
- * 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.' ) . '
';
+ $output = '
';
+ $output .= '
' . $title . '';
+ $output .= str_repeat( '
', $full_stars );
+ $output .= str_repeat( '
', $half_stars );
+ $output .= str_repeat( '
', $empty_stars );
+ $output .= '
';
- 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 ( $r['echo'] ) {
+ echo $output;
}
- /**
- * Prevents new users from seeing existing 'new feature' pointers.
- *
- * @since 3.3.0
- */
- 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' );
- }
+ return $output;
}
-add_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts' ) );
-add_action( 'user_register', array( 'WP_Internal_Pointers', 'dismiss_pointers_for_new_users' ) );
-
/**
- * Convert a screen string to a screen object
- *
- * @since 3.0.0
+ * Output a notice when editing the page for posts (internal use only).
*
- * @param string $hook_name The hook name (also known as the hook suffix) used to determine the screen.
- * @return WP_Screen Screen object.
+ * @ignore
+ * @since 4.2.0
*/
-function convert_to_screen( $hook_name ) {
- if ( ! class_exists( 'WP_Screen' ) ) {
- _doing_it_wrong( 'convert_to_screen(), add_meta_box()', __( "Likely direct inclusion of wp-admin/includes/template.php in order to use add_meta_box(). This is very wrong. Hook the add_meta_box() call into the add_meta_boxes action instead." ), '3.3' );
- return (object) array( 'id' => '_invalid', 'base' => '_are_belong_to_us' );
- }
-
- return WP_Screen::get( $hook_name );
+function _wp_posts_page_notice() {
+ echo '
' . __( 'You are currently editing the page that shows your latest posts.' ) . '
';
}