From 24d7c61eb5d39cc037b7586ec80d84c9f88759f0 Mon Sep 17 00:00:00 2001 From: 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: http://svn.automattic.com/wordpress/trunk@18937 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- 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 7d8a514ff..5560b3883 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 4ecb4a492..e0984d95e 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.' . '

'; ?>