Index: wp-admin/includes/template.php =================================================================== --- wp-admin/includes/template.php (revision 18921) +++ wp-admin/includes/template.php (working copy) @@ -1630,52 +1630,125 @@ } /** - * Initializes the new feature pointers. + * Special function for managing WP one off pointer registrations. * + * @since 3.3-aortic-dissection + * + * It's likely better to call wp_register_pointer() in somewhere in upgrade.php + * So that this function isn't necassary. Up for discussion + */ +function wp_core_pointers() { + $pointer = 'wp330-admin-bar'; + + $done = (array) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ); + + if ( ! in_array( $pointer, $done ) && apply_filters( 'show_wp_pointer_admin_bar', true ) ) { + wp_register_pointer( $pointer, '_wp_pointer_print_admin_bar' ); + $done[] = $pointer; + update_user_meta( get_current_user_id(), 'dismissed_wp_pointers', $done ); + + } +} +add_action( 'admin_enqueue_scripts', 'wp_core_pointers' ); + +/** + * Register a pointer. + * * @since 3.3.0 * - * Pointer user settings: - * p0 - Admin bar pointer, added 3.3. + * Should only be called where the code is executed once, for example, on upgrade, install, or on user-action. + * */ +function wp_register_pointer( $pointer, $callback, $hook_suffix = 'all', $args = array() ) { + $queued = (array) get_user_meta( get_current_user_id(), 'queued_wp_pointers', true ); + $queued[ $hook_suffix ][ $pointer ] = array_merge( array( 'callback' => $callback ), $args ); + update_user_meta( get_current_user_id(), 'queued_wp_pointers', $queued ); +} + +/** + * Initializes the new feature pointers. + * + * @since 3.3.0 + */ function wp_pointer_enqueue( $hook_suffix ) { - $enqueue = false; - - $admin_bar = get_user_setting( 'p0', 0 ); - if ( ! $admin_bar && apply_filters( 'show_wp_pointer_admin_bar', true ) ) { - $enqueue = true; - add_action( 'admin_print_footer_scripts', '_wp_pointer_print_admin_bar' ); + $queued = (array) get_user_meta( get_current_user_id(), 'queued_wp_pointers', true ); + + if ( empty( $queued[ 'all' ] ) && empty( $queued[ $hook_suffix] ) ) return; + + if ( ! empty( $queued[ 'all' ] ) ) { + foreach( $queued[ 'all' ] as $pointer ) { + add_action( 'admin_print_footer_scripts', $pointer[ 'callback' ] ); + } } - - if ( $enqueue ) { - wp_enqueue_style( 'wp-pointer' ); - wp_enqueue_script( 'wp-pointer' ); - wp_enqueue_script( 'utils' ); + if ( ! empty( $queued[ $hook_suffix] ) ) { + foreach( $queued[ $hook_suffix] as $pointer ) { + add_action( 'admin_print_footer_scripts', $pointer[ 'callback' ] ); + } } + wp_enqueue_style( 'wp-pointer' ); + wp_enqueue_script( 'wp-pointer' ); + wp_enqueue_script( 'utils' ); } add_action( 'admin_enqueue_scripts', 'wp_pointer_enqueue' ); +/** + * Prints admin_bar pointer. + * + * @since 3.3.0 + */ function _wp_pointer_print_admin_bar() { - $pointer_content = '
' . sprintf( ('Have some feedback? Visit this ticket.'), 'http://core.trac.wordpress.org/ticket/18197' ) . '
'; - $pointer_content .= '' . sprintf( ('P.S. You are looking at a new admin pointer. Chime in here.'), 'http://core.trac.wordpress.org/ticket/18693' ) . '
'; + $pointer_content = '' . sprintf( __('Have some feedback? Visit this ticket.'), 'http://core.trac.wordpress.org/ticket/18197' ) . '
'; + $pointer_content .= '' . sprintf( __('P.S. You are looking at a new admin pointer. Chime in here.'), 'http://core.trac.wordpress.org/ticket/18693' ) . '
'; -?> - - + +