` tags).
+ * @param string $type Optional. Message type, controls HTML class. Accepts 'error' or 'updated'.
+ * Default 'error'.
*/
-function manage_columns_prefs($page) {
- $columns = get_column_headers($page);
+function add_settings_error( $setting, $code, $message, $type = 'error' ) {
+ global $wp_settings_errors;
- $hidden = get_hidden_columns($page);
+ $wp_settings_errors[] = array(
+ 'setting' => $setting,
+ 'code' => $code,
+ 'message' => $message,
+ 'type' => $type
+ );
+}
- 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;
+/**
+ * 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.
+ *
+ * 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.
+ *
+ * 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 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 get_settings_errors( $setting = '', $sanitize = false ) {
+ global $wp_settings_errors;
+
+ /*
+ * 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 ) );
+
+ // 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;
+}
+
+/**
+ * Display settings errors registered by {@see add_settings_error()}.
+ *
+ * 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 {@see register_setting()}
+ *
+ * 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.
+ *
+ * @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.
+ */
+function settings_errors( $setting = '', $sanitize = false, $hide_on_update = false ) {
+
+ if ( $hide_on_update && ! empty( $_GET['settings-updated'] ) )
+ return;
+
+ $settings_errors = get_settings_errors( $setting, $sanitize );
- if ( 'comments' == $column )
- $title = __('Comments');
- $id = "$column-hide";
- echo '';
- echo ' ';
- echo "$title \n";
+ if ( empty( $settings_errors ) )
+ return;
+
+ $output = '';
+ foreach ( $settings_errors as $key => $details ) {
+ $css_id = 'setting-error-' . $details['code'];
+ $css_class = $details['type'] . ' settings-error notice is-dismissible';
+ $output .= "
\n";
}
+ echo $output;
}
/**
* {@internal Missing Short Description}}
*
- * @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 );
}
/**
@@ -3293,15 +1548,15 @@ 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 );
}
/**
@@ -3310,47 +1565,86 @@ 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($_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).
*
+ * @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.
+ */
+ ?>
+ /** 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' );
+?>
@@ -3375,24 +1677,40 @@ function iframe_footer() {
function _post_states($post) {
$post_states = array();
- if ( isset($_GET['post_status']) )
- $post_status = $_GET['post_status'];
+ if ( isset( $_REQUEST['post_status'] ) )
+ $post_status = $_REQUEST['post_status'];
else
$post_status = '';
if ( !empty($post->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 state');
if ( is_sticky($post->ID) )
- $post_states[] = __('Sticky');
+ $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);
@@ -3404,283 +1722,45 @@ function _post_states($post) {
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.') . '
-';
-}
-
-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.') . '
-';
-}
-
-function screen_layout($screen) {
- global $screen_layout_columns;
-
- $columns = array('dashboard' => 4, 'post' => 2, 'page' => 2, 'link' => 2);
- $columns = apply_filters('screen_layout_columns', $columns, $screen);
-
- if ( !isset($columns[$screen]) ) {
- $screen_layout_columns = 0;
- return '';
- }
-
- $screen_layout_columns = get_user_option("screen_layout_$screen");
- $num = $columns[$screen];
+function _media_states( $post ) {
+ $media_states = array();
+ $stylesheet = get_option('stylesheet');
- if ( ! $screen_layout_columns )
- $screen_layout_columns = 2;
-
- $i = 1;
- $return = '
' . __('Screen Layout') . " \n
" . __('Number of Columns:') . "\n";
- while ( $i <= $num ) {
- $return .= " $i \n";
- ++$i;
- }
- $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 ( 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' );
}
- $option = str_replace('-', '_', "${screen}_per_page");
- $per_page = get_user_option($option);
- if ( empty($per_page) ) {
- if ( 'plugins' == $screen )
- $per_page = 999;
- else
- $per_page = 20;
+ 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 )
+ $media_states[] = __( 'Background Image' );
}
- $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;
+ /**
+ * 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($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;
+ }
+ $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;
+ 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;
+}
+
+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(
+ '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
+ if ( empty( $registered_pointers[ $hook_suffix ] ) )
+ return;
+
+ $pointers = (array) $registered_pointers[ $hook_suffix ];
+
+ $caps_required = array(
+ 'wp390_widgets' => 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.js).
+ */
+ private static function print_js( $pointer_id, $selector, $args ) {
+ if ( empty( $pointer_id ) || empty( $selector ) || empty( $args ) || empty( $args['content'] ) )
+ return;
+
+ ?>
+
+ ' . __( 'Edit Lock' ) . '';
+ $content .= '
' . __( 'Someone else is editing this. No need to refresh; the lock will disappear when they’re done.' ) . '
';
+
+ self::print_js( 'wp360_locks', 'tr.wp-locked .locked-indicator', array(
+ 'content' => $content,
+ 'position' => array( 'edge' => 'left', 'align' => 'left' ),
+ ) );
+ }
+
+ public static function pointer_wp390_widgets() {
+ if ( ! current_theme_supports( 'widgets' ) ) {
+ return;
+ }
+
+ $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.' ) . '
';
+
+ 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' );
+ }
+ }
+
+ self::print_js( 'wp390_widgets', $selector, array(
+ 'content' => $content,
+ 'position' => $position,
+ ) );
+ }
+
+ public static function pointer_wp410_dfw() {
+ // Don't show when editor-scrolling is not used.
+ if ( empty( $GLOBALS['_wp_editor_expand'] ) ) {
+ return;
+ }
+
+ $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.' ) . '
';
+
+ 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,
+ ) );
+ }
+
+ /**
+ * 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', 'wp360_locks,wp390_widgets' );
+ }
+}
+
+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
+ *
+ * @param string $hook_name The hook name (also known as the hook suffix) used to determine the screen.
+ * @return WP_Screen Screen object.
+ */
+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 );
+}
+
+/**
+ * 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.' ) . '
';
+}