WordPress.org

Make WordPress Core

Changeset 18937


Ignore:
Timestamp:
10/10/11 23:31:36 (3 years ago)
Author:
nacin
Message:

Use AJAX request and usermeta rather than user settings for dismissing admin bar pointers. see #18693.

Location:
trunk/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-ajax.php

    r18852 r18937  
    15741574    update_post_meta( $post_id, '_edit_lock', $new_lock, implode( ':', $active_lock ) ); 
    15751575    die( '1' ); 
    1576  
     1576case 'dismiss-wp-pointer' : 
     1577    $pointer = $_POST['pointer']; 
     1578    if ( $pointer != sanitize_key( $pointer ) ) 
     1579        die( '0' ); 
     1580 
     1581//  check_ajax_referer( 'dismiss-pointer_' . $pointer ); 
     1582 
     1583    $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ); 
     1584 
     1585    if ( in_array( $pointer, $dismissed ) ) 
     1586        die( '0' ); 
     1587 
     1588    $dismissed[] = $pointer; 
     1589    $dismissed = implode( ',', $dismissed ); 
     1590 
     1591    update_user_meta( get_current_user_id(), 'dismissed_wp_pointers', $dismissed ); 
     1592    die( '1' ); 
     1593    break; 
    15771594default : 
    15781595    do_action( 'wp_ajax_' . $_POST['action'] ); 
  • trunk/wp-admin/includes/template.php

    r18882 r18937  
    16411641    $enqueue = false; 
    16421642 
    1643     $admin_bar = get_user_setting( 'p0', 0 ); 
    1644     if ( ! $admin_bar && apply_filters( 'show_wp_pointer_admin_bar', true ) ) { 
     1643    $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ); 
     1644 
     1645    if ( ! in_array( 'wp330-admin-bar', $dismissed ) && apply_filters( 'show_wp_pointer_admin_bar', true ) ) { 
    16451646        $enqueue = true; 
    16461647        add_action( 'admin_print_footer_scripts', '_wp_pointer_print_admin_bar' ); 
     
    16561657 
    16571658function _wp_pointer_print_admin_bar() { 
    1658     $pointer_content  = '<h3>' . ('The admin bar has been updated in WordPress 3.3.') . '</h3>'; 
    1659     $pointer_content .= '<p>' . sprintf( ('Have some feedback? Visit this <a href="%s">ticket</a>.'), 'http://core.trac.wordpress.org/ticket/18197' ) . '</p>'; 
    1660     $pointer_content .= '<p>' . sprintf( ('P.S. You are looking at a new admin pointer. Chime in <a href="%s">here</a>.'), 'http://core.trac.wordpress.org/ticket/18693' ) . '</p>'; 
     1659    $pointer_content  = '<h3>' . 'The admin bar has been updated in WordPress 3.3.' . '</h3>'; 
     1660    $pointer_content .= '<p>' . sprintf( 'Have some feedback? Visit the <a href="%s">forum</a>.', 'http://wordpress.org/support/forum/alphabeta' ) . '</p>'; 
     1661    $pointer_content .= '<p>' . 'P.S. You are looking at a new admin pointer.' . '</p>'; 
    16611662 
    16621663?> 
     
    16721673        }, 
    16731674        close: function() { 
    1674             setUserSetting( 'p0', '1' ); 
     1675            $.post( ajaxurl, { 
     1676                    pointer: 'wp330-admin-bar', 
     1677                //  _ajax_nonce: $('#_ajax_nonce').val(), 
     1678                    action: 'dismiss-wp-pointer' 
     1679            }); 
    16751680        } 
    16761681    }).pointer('open'); 
Note: See TracChangeset for help on using the changeset viewer.