Index: wp-admin/includes/template.php =================================================================== --- wp-admin/includes/template.php (revision 19367) +++ wp-admin/includes/template.php (working copy) @@ -1669,45 +1669,79 @@ * * @since 3.3.0 * - * Pointer user settings: - * p0 - Admin bar pointer, added 3.3. */ function wp_pointer_enqueue( $hook_suffix ) { - $enqueue = false; + /* + * Register feature pointers + * Format: array( hook_suffix => pointer_id ) + */ + $registered_pointers = apply_filters( 'wp_pointers', array( + 'index.php' => array( 'wp330-toolbar', 'wp330-flyout-menus' ), + 'post-new.php' => 'wp330-media-uploader', + 'themes.php' => 'wp330-saving-widgets' + ) ); + // Check if screen related pointers are registered + if ( empty( $registered_pointers[$hook_suffix] ) ) + return; + + // Get dismissed pointers $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ); - if ( ! in_array( 'wp330-admin-bar', $dismissed ) ) { - $enqueue = true; - add_action( 'admin_print_footer_scripts', '_wp_pointer_print_admin_bar' ); - } + // Sort dismissed pointers out + $pointers = array_diff( (array) $registered_pointers[$hook_suffix], $dismissed ); - if ( $enqueue ) { - wp_enqueue_style( 'wp-pointer' ); - wp_enqueue_script( 'wp-pointer' ); - } + // Pointers were already shown + if ( empty( $pointers ) ) + return; + + // Init pointers print functions + foreach ( $pointers as $pointer ) + add_action( 'admin_print_footer_scripts', '_wp_pointer_print_' . str_replace( '-', '_', $pointer ) ); + + // Add pointers script and style to queue + wp_enqueue_style( 'wp-pointer' ); + wp_enqueue_script( 'wp-pointer' ); } add_action( 'admin_enqueue_scripts', 'wp_pointer_enqueue' ); -function _wp_pointer_print_admin_bar() { - $pointer_content = '
' . sprintf( 'Have some feedback? Visit the forum.', 'http://wordpress.org/support/forum/alphabeta' ) . '
'; - $pointer_content .= '' . 'P.S. You are looking at a new admin 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 string $content The pointer content + * @param array|string $position The pointer position, see wp-pointer.dev.js + */ +function _wp_pointer_print_js_data( $pointer_id, $selector, $content, $position ) { + if ( empty( $pointer_id ) || empty( $selector ) || empty( $content ) ) + return; + // Set arrow and pointer position + $_position = ''; + if ( is_string( $position ) ) + $_position = "position: '{$position}',"; + elseif( is_array( $position ) ) { + if ( ! empty( $position['edge'] ) && ! empty( $position['align'] ) ) { + $_position = "position: { edge: '{$position['edge']}', align: '{$position['align']}' },"; + } elseif ( ! empty( $position['edge'] ) ) { + $_position = "position: { edge: '{$position['edge']}' },"; + } elseif ( ! empty( $position['align'] ) ) { + $_position = "position: { align: '{$position['align']}' },"; + } + } ?> ' . esc_js( __( 'New Feature: Toolbar' ) ). ''; + $content .= '' . esc_js( __( "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." ) ) . '
'; + + if ( is_multisite() && is_super_admin() ) + $content .= '' .esc_js( __( 'Network Admin is now located in the My Sites menu.' ) ) . '
'; + + $position['edge'] = 'top'; + $position['align'] = 'right'; + + _wp_pointer_print_js_data( 'wp330-toolbar', '#wpadminbar', $content, $position ); +} + +/** + * Print 'New Feature: Flyout Menus' for 3.3.0. + * + * @since 3.3.0 + */ +function _wp_pointer_print_wp330_flyout_menus() { + $content = '' . esc_js( __( 'Instead of clicking to open and close navigation sections, just hover over a menu item and the submenu will "fly out" to the side, allowing single-click access to any screen.' ) ) . '
'; + + $position['edge'] = 'left'; + $position['align'] = 'center'; + + _wp_pointer_print_js_data( 'wp330-flyout-menus', '#menu-users', $content, $position ); +} + +/** + * Print 'Updated Media Uploader' for 3.3.0. + * + * @since 3.3.0 + */ +function _wp_pointer_print_wp330_media_uploader() { + $content = '' . esc_js( __( 'The single media icon now launches the uploader for all file types, and the new drag and drop interface makes uploading a breeze.' ) ) . '
'; + + $position['edge'] = 'left'; + $position['align'] = 'center'; + + _wp_pointer_print_js_data( 'wp330-media-uploader', '#content-add_media', $content, $position ); +} + +/** + * Print 'New Feature: Saving Widgets' for 3.3.0. + * + * @since 3.3.0 + */ +function _wp_pointer_print_wp330_saving_widgets() { + $content = '' . esc_js( __( "If you change your mind and revert to your previous theme, we'll put the widgets back the way you had them." ) ) . '
'; + + $position['edge'] = 'top'; + $position['align'] = 'left'; + + _wp_pointer_print_js_data( 'wp330-saving-widgets', '#message2', $content, $position ); +}