From 1db90d21e0bd2e5bd44bd882135f5590477c1e1e Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Mon, 10 Oct 2011 23:31:36 +0000 Subject: [PATCH] Use AJAX request and usermeta rather than user settings for dismissing admin bar pointers. see #18693. git-svn-id: https://develop.svn.wordpress.org/trunk@18937 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/admin-ajax.php | 17 +++++++++++++++++ wp-admin/includes/template.php | 17 +++++++++++------ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php index 7d8a514ff8..5560b38834 100644 --- a/wp-admin/admin-ajax.php +++ b/wp-admin/admin-ajax.php @@ -1573,7 +1573,24 @@ case 'wp-remove-post-lock' : $new_lock = ( time() - apply_filters( 'wp_check_post_lock_window', AUTOSAVE_INTERVAL * 2 ) + 5 ) . ':' . $active_lock[1]; update_post_meta( $post_id, '_edit_lock', $new_lock, implode( ':', $active_lock ) ); die( '1' ); +case 'dismiss-wp-pointer' : + $pointer = $_POST['pointer']; + if ( $pointer != sanitize_key( $pointer ) ) + die( '0' ); +// check_ajax_referer( 'dismiss-pointer_' . $pointer ); + + $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ); + + if ( in_array( $pointer, $dismissed ) ) + die( '0' ); + + $dismissed[] = $pointer; + $dismissed = implode( ',', $dismissed ); + + update_user_meta( get_current_user_id(), 'dismissed_wp_pointers', $dismissed ); + die( '1' ); + break; default : do_action( 'wp_ajax_' . $_POST['action'] ); die('0'); diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 4ecb4a4929..e0984d95e7 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -1640,8 +1640,9 @@ function get_submit_button( $text = NULL, $type = 'primary', $name = 'submit', $ 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 ) ) { + $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ); + + if ( ! in_array( 'wp330-admin-bar', $dismissed ) && apply_filters( 'show_wp_pointer_admin_bar', true ) ) { $enqueue = true; add_action( 'admin_print_footer_scripts', '_wp_pointer_print_admin_bar' ); } @@ -1655,9 +1656,9 @@ function wp_pointer_enqueue( $hook_suffix ) { 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 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 = '

' . '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.' . '

'; ?>