diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 5886eba54c..ef9851926c 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -1664,56 +1664,130 @@ function _wp_admin_html_begin() { pointer_id ) + */ + $registered_pointers = array( + 'index.php' => 'wp330-toolbar', + 'post-new.php' => 'wp330-media-uploader', + 'themes.php' => 'wp330-saving-widgets', + ); - $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ); + // Check if screen related pointer is registered + if ( empty( $registered_pointers[ $hook_suffix ] ) ) + return; - if ( ! in_array( 'wp330-admin-bar', $dismissed ) ) { - $enqueue = true; - add_action( 'admin_print_footer_scripts', '_wp_pointer_print_admin_bar' ); - } + $pointer = $registered_pointers[ $hook_suffix ]; - if ( $enqueue ) { + // Get dismissed pointers + $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ); + + // Pointer has been dismissed + if ( in_array( $pointer, $dismissed ) ) + return; + + // Bind pointer print function + add_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_' . 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 = '

' . 'The admin bar has been updated in WordPress 3.3.' . '

'; - $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 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; -?> - -').pointer( options ).pointer('open'); + }); + //]]> + + ' . 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.' ) ) . '

'; + + WP_Internal_Pointers::print_js( 'wp330-toolbar', '#wpadminbar', array( + 'content' => $content, + 'position' => array( 'edge' => 'top', 'align' => 'center' ), + ) ); + } + + /** + * Print 'Updated Media Uploader' for 3.3.0. + * + * @since 3.3.0 + */ + public static function pointer_wp330_media_uploader() { + $content = '

' . esc_js( __( 'Updated 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.' ) ) . '

'; + + WP_Internal_Pointers::print_js( 'wp330-media-uploader', '#content-add_media', array( + 'content' => $content, + 'position' => array( 'edge' => 'left', 'align' => 'center' ), + ) ); + } + + /** + * Print 'New Feature: Saving Widgets' for 3.3.0. + * + * @since 3.3.0 + */ + public static function pointer_wp330_saving_widgets() { + $content = '

' . esc_js( __( 'New Feature: 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.' ) ) . '

'; + + WP_Internal_Pointers::print_js( 'wp330-saving-widgets', '#message2', array( + 'content' => $content, + 'position' => array( 'edge' => 'top', 'align' => 'left' ), + ) ); + } } + +add_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts' ) ); \ No newline at end of file