for each error retrieved by get_settings_errors().
+ * Part of the Settings API. Outputs a div for each error retrieved by
+ * 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 register_setting().
*
- * The $sanitize option is passed into get_settings_errors() and will re-run the setting sanitization
+ * 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.
+ * 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 ) {
+function settings_errors( $setting = '', $sanitize = false, $hide_on_update = false ) {
- if ($hide_on_update AND $_GET['settings-updated']) return;
+ if ( $hide_on_update && ! empty( $_GET['settings-updated'] ) )
+ return;
$settings_errors = get_settings_errors( $setting, $sanitize );
- if ( !is_array($settings_errors) ) return;
+ 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";
@@ -1337,268 +1487,166 @@ 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 );
}
/**
- * {@internal Missing Short Description}}
+ * Get the post title.
+ *
+ * The post title is fetched and if it is blank then a default string is
+ * returned.
*
* @since 2.7.0
+ *
+ * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
+ * @return string The post title if set.
*/
-function favorite_actions( $screen = null ) {
- $default_action = false;
-
- if ( is_string($screen) )
- $screen = convert_to_screen($screen);
-
- if ( $screen->is_user )
- return;
-
- if ( isset($screen->post_type) ) {
- $post_type_object = get_post_type_object($screen->post_type);
- if ( 'add' != $screen->action )
- $default_action = array('post-new.php?post_type=' . $post_type_object->name => array($post_type_object->labels->new_item, $post_type_object->cap->edit_posts));
- else
- $default_action = array('edit.php?post_type=' . $post_type_object->name => array($post_type_object->labels->name, $post_type_object->cap->edit_posts));
- }
-
- if ( !$default_action ) {
- if ( $screen->is_network ) {
- $default_action = array('sites.php' => array( __('Sites'), 'manage_sites'));
- } else {
- switch ( $screen->id ) {
- case 'upload':
- $default_action = array('media-new.php' => array(__('New Media'), 'upload_files'));
- break;
- case 'media':
- $default_action = array('upload.php' => array(__('Edit Media'), 'upload_files'));
- break;
- case 'link-manager':
- case 'link':
- if ( 'add' != $screen->action )
- $default_action = array('link-add.php' => array(__('New Link'), 'manage_links'));
- else
- $default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links'));
- break;
- case 'users':
- $default_action = array('user-new.php' => array(__('New User'), 'create_users'));
- break;
- case 'user':
- $default_action = array('users.php' => array(__('Edit Users'), 'edit_users'));
- break;
- case 'plugins':
- $default_action = array('plugin-install.php' => array(__('Install Plugins'), 'install_plugins'));
- break;
- case 'plugin-install':
- $default_action = array('plugins.php' => array(__('Manage Plugins'), 'activate_plugins'));
- break;
- case 'themes':
- $default_action = array('theme-install.php' => array(__('Install Themes'), 'install_themes'));
- break;
- case 'theme-install':
- $default_action = array('themes.php' => array(__('Manage Themes'), 'switch_themes'));
- break;
- default:
- $default_action = array('post-new.php' => array(__('New Post'), 'edit_posts'));
- break;
- }
- }
- }
-
- if ( !$screen->is_network ) {
- $actions = array(
- 'post-new.php' => array(__('New Post'), 'edit_posts'),
- 'edit.php?post_status=draft' => array(__('Drafts'), 'edit_posts'),
- 'post-new.php?post_type=page' => array(__('New Page'), 'edit_pages'),
- 'media-new.php' => array(__('Upload'), 'upload_files'),
- 'edit-comments.php' => array(__('Comments'), 'moderate_comments')
- );
- } else {
- $actions = array(
- 'sites.php' => array( __('Sites'), 'manage_sites'),
- 'users.php' => array( __('Users'), 'manage_network_users')
- );
- }
-
- $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, $screen );
-
- $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";
-}
-
-/**
- * Get the post title.
- *
- * The post title is fetched and if it is blank then a default string is
- * 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
- */
-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($_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_screen, $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);
- $admin_body_class .= ' iframe';
-?>
- >
-
-
+ $current_screen = get_current_screen();
+
+ @header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
+ _wp_admin_html_begin();
+?>
› —
- class="no-js ">
+
+ 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' );
+?>
@@ -1622,10 +1686,14 @@ 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' );
+ }
+ }
+
+ /**
+ * 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 = ', ';
@@ -1654,32 +1743,75 @@ 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');
if ( current_theme_supports( 'custom-header') ) {
$meta_header = get_post_meta($post->ID, '_wp_attachment_is_custom_header', true );
- if ( ! empty( $meta_header ) && $meta_header == $stylesheet )
- $media_states[] = __( 'Header Image' );
+
+ if ( is_random_header_image() ) {
+ $header_images = wp_list_pluck( get_uploaded_header_images(), 'attachment_id' );
+
+ if ( $meta_header == $stylesheet && in_array( $post->ID, $header_images ) ) {
+ $media_states[] = __( 'Header Image' );
+ }
+ } else {
+ $header_image = get_header_image();
+
+ // 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' );
+ }
+
+ // 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' );
+ }
+ }
}
if ( current_theme_supports( 'custom-background') ) {
$meta_background = get_post_meta($post->ID, '_wp_attachment_is_custom_background', true );
- if ( ! empty( $meta_background ) && $meta_background == $stylesheet )
+
+ if ( ! empty( $meta_background ) && $meta_background == $stylesheet ) {
$media_states[] = __( 'Background Image' );
+
+ $background_image = get_background_image();
+ if ( $background_image && $background_image == wp_get_attachment_url( $post->ID ) ) {
+ $media_states[] = __( 'Current Background Image' );
+ }
+ }
+ }
+
+ if ( $post->ID == get_option( 'site_icon' ) ) {
+ $media_states[] = __( 'Site Icon' );
+ }
+
+ if ( $post->ID == get_theme_mod( 'site_logo' ) ) {
+ $media_states[] = __( 'Logo' );
}
+ /**
+ * 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( $media_states ) ) {
$state_count = count( $media_states );
$i = 0;
- echo ' - ';
+ echo ' — ';
foreach ( $media_states as $state ) {
++$i;
( $i == $state_count ) ? $sep = '' : $sep = ', ';
@@ -1688,310 +1820,6 @@ function _media_states( $post ) {
}
}
-/**
- * Convert a screen string to a screen object
- *
- * @since 3.0.0
- *
- * @param string $screen The name of the screen
- * @return object An object containing the safe screen name and id
- */
-function convert_to_screen( $screen ) {
- $screen = str_replace( array('.php', '-new', '-add', '-network', '-user' ), '', $screen);
-
- if ( is_network_admin() )
- $screen .= '-network';
- elseif ( is_user_admin() )
- $screen .= '-user';
-
- $screen = (string) apply_filters( 'screen_meta_screen', $screen );
- $screen = (object) array('id' => $screen, 'base' => $screen);
- return $screen;
-}
-
-function screen_meta($screen) {
- global $wp_meta_boxes, $_wp_contextual_help, $wp_list_table, $wp_current_screen_options;
-
- if ( is_string($screen) )
- $screen = convert_to_screen($screen);
-
- $columns = get_column_headers( $screen );
- $hidden = get_hidden_columns( $screen );
-
- $meta_screens = array('index' => 'dashboard');
-
- if ( isset($meta_screens[$screen->id]) ) {
- $screen->id = $meta_screens[$screen->id];
- $screen->base = $screen->id;
- }
-
- $show_screen = false;
- if ( !empty($wp_meta_boxes[$screen->id]) || !empty($columns) )
- $show_screen = true;
-
- $screen_options = screen_options($screen);
- if ( $screen_options )
- $show_screen = true;
-
- if ( !isset($_wp_contextual_help) )
- $_wp_contextual_help = array();
-
- $settings = apply_filters('screen_settings', '', $screen);
-
- switch ( $screen->id ) {
- case 'widgets':
- $settings = '
' . __('Enable accessibility mode') . '' . __('Disable accessibility mode') . "
\n";
- $show_screen = true;
- break;
- }
- if ( ! empty( $settings ) )
- $show_screen = true;
-
- if ( !empty($wp_current_screen_options) )
- $show_screen = true;
-
- $show_screen = apply_filters('screen_options_show_screen', $show_screen, $screen);
-
-?>
-
-id] = $help;
-}
-
-function screen_layout($screen) {
- global $screen_layout_columns, $wp_current_screen_options;
-
- if ( is_string($screen) )
- $screen = convert_to_screen($screen);
-
- // Back compat for plugins using the filter instead of add_screen_option()
- $columns = apply_filters('screen_layout_columns', array(), $screen->id, $screen);
- if ( !empty($columns) && isset($columns[$screen->id]) )
- add_screen_option('layout_columns', array('max' => $columns[$screen->id]) );
-
- if ( !isset($wp_current_screen_options['layout_columns']) ) {
- $screen_layout_columns = 0;
- return '';
- }
-
- $screen_layout_columns = get_user_option("screen_layout_$screen->id");
- $num = $wp_current_screen_options['layout_columns']['max'];
-
- if ( ! $screen_layout_columns ) {
- if ( isset($wp_current_screen_options['layout_columns']['default']) )
- $screen_layout_columns = $wp_current_screen_options['layout_columns']['default'];
- else
- $screen_layout_columns = 2;
- }
-
- $i = 1;
- $return = '
' . __('Screen Layout') . "
\n
" . __('Number of Columns:') . "\n";
- while ( $i <= $num ) {
- $return .= "\n";
- ++$i;
- }
- $return .= "
\n";
- return $return;
-}
-
-/**
- * Register and configure an admin screen option
- *
- * @since 3.1.0
- *
- * @param string $option An option name.
- * @param mixed $args Option dependent arguments
- * @return void
- */
-function add_screen_option( $option, $args = array() ) {
- global $wp_current_screen_options;
-
- if ( !isset($wp_current_screen_options) )
- $wp_current_screen_options = array();
-
- $wp_current_screen_options[$option] = $args;
-}
-
-function screen_options($screen) {
- global $wp_current_screen_options;
-
- if ( is_string($screen) )
- $screen = convert_to_screen($screen);
-
- if ( !isset($wp_current_screen_options['per_page']) )
- return '';
-
- $per_page_label = $wp_current_screen_options['per_page']['label'];
-
- if ( empty($wp_current_screen_options['per_page']['option']) ) {
- $option = str_replace( '-', '_', "{$screen->id}_per_page" );
- } else {
- $option = $wp_current_screen_options['per_page']['option'];
- }
-
- $per_page = (int) get_user_option( $option );
- if ( empty( $per_page ) || $per_page < 1 ) {
- if ( isset($wp_current_screen_options['per_page']['default']) )
- $per_page = $wp_current_screen_options['per_page']['default'];
- else
- $per_page = 20;
- }
-
- 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_per_page' == $option )
- $per_page = apply_filters( 'edit_categories_per_page', $per_page );
- else
- $per_page = apply_filters( $option, $per_page );
-
- // Back compat
- if ( isset( $screen->post_type ) )
- $per_page = apply_filters( 'edit_posts_per_page', $per_page, $screen->post_type );
-
- $return = "
\n";
- if ( !empty($per_page_label) )
- $return .= " \n";
- $return .= get_submit_button( __( 'Apply' ), 'button', 'screen-options-apply', false );
- $return .= "";
- $return .= "
\n";
- return $return;
-}
-
-function screen_icon( $screen = '' ) {
- echo get_screen_icon( $screen );
-}
-
-function get_screen_icon( $screen = '' ) {
- global $current_screen, $typenow;
-
- if ( empty($screen) )
- $screen = $current_screen;
- elseif ( is_string($screen) )
- $name = $screen;
-
- $class = 'icon32';
-
- if ( empty($name) ) {
- if ( !empty($screen->parent_base) )
- $name = $screen->parent_base;
- else
- $name = $screen->base;
-
- if ( 'edit' == $name && isset($screen->post_type) && 'page' == $screen->post_type )
- $name = 'edit-pages';
-
- $post_type = '';
- if ( isset( $screen->post_type ) )
- $post_type = $screen->post_type;
- elseif ( $current_screen == $screen )
- $post_type = $typenow;
- if ( $post_type )
- $class .= ' ' . sanitize_html_class( 'icon32-posts-' . $post_type );
- }
-
- return '
';
-}
-
/**
* Test support for compressing JavaScript from PHP
*
@@ -2005,7 +1833,7 @@ function get_screen_icon( $screen = '' ) {
function compression_test() {
?>
$current_screen, 'base' => $current_screen);
- } else {
- $id = sanitize_key($id);
- if ( false !== strpos($id, '-') ) {
- list( $id, $typenow ) = explode('-', $id, 2);
- if ( taxonomy_exists( $typenow ) ) {
- $id = 'edit-tags';
- $taxnow = $typenow;
- $typenow = '';
- }
- }
- $current_screen = array('id' => $id, 'base' => $id);
- }
-
- $current_screen = (object) $current_screen;
-
- $current_screen->action = $action;
-
- // Map index to dashboard
- if ( 'index' == $current_screen->base )
- $current_screen->base = 'dashboard';
- if ( 'index' == $current_screen->id )
- $current_screen->id = 'dashboard';
-
- if ( 'edit' == $current_screen->id ) {
- if ( empty($typenow) )
- $typenow = 'post';
- $current_screen->id .= '-' . $typenow;
- $current_screen->post_type = $typenow;
- } elseif ( 'post' == $current_screen->id ) {
- if ( empty($typenow) )
- $typenow = 'post';
- $current_screen->id = $typenow;
- $current_screen->post_type = $typenow;
- } elseif ( 'edit-tags' == $current_screen->id ) {
- if ( empty($taxnow) )
- $taxnow = 'post_tag';
- $current_screen->id = 'edit-' . $taxnow;
- $current_screen->taxonomy = $taxnow;
- }
-
- $current_screen->is_network = is_network_admin();
- $current_screen->is_user = is_user_admin();
-
- if ( $current_screen->is_network ) {
- $current_screen->base .= '-network';
- $current_screen->id .= '-network';
- } elseif ( $current_screen->is_user ) {
- $current_screen->base .= '-user';
- $current_screen->id .= '-user';
- }
-
- $current_screen = apply_filters('current_screen', $current_screen);
-}
-
-/**
- * Echos a submit button, with provided text and appropriate class
+ * Echoes a submit button, with provided text and appropriate class(es).
*
* @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 ouput 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 ) {
+function submit_button( $text = null, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = null ) {
echo get_submit_button( $text, $type, $name, $wrap, $other_attributes );
}
@@ -2175,31 +1915,37 @@ 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 ouput 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;
+ }
+ // 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;
@@ -2213,11 +1959,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 ) {
@@ -2226,3 +1976,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');
+
+?>
+
+
+
+ >
+
+
+
+ '_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.' ) . '
';
+}