Make WordPress Core

Changeset 18707


Ignore:
Timestamp:
09/18/2011 09:17:09 PM (13 years ago)
Author:
koopersmith
Message:

Add pointers feature, and pointer to admin bar, props nacin for PHP bits, see #18693.

Location:
trunk
Files:
4 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/template.php

    r18683 r18707  
    22182218    return $button;
    22192219}
     2220
     2221/**
     2222 * Initializes the new feature pointers.
     2223 *
     2224 * @since 3.3.0
     2225 *
     2226 * Pointer user settings:
     2227 *    p0 - Admin bar pointer, added 3.3.
     2228 */
     2229function wp_pointer_enqueue( $hook_suffix ) {
     2230    $enqueue = false;
     2231
     2232    $admin_bar = get_user_setting( 'p0', 0 );
     2233    if ( ! $admin_bar && apply_filters( 'show_wp_pointer_admin_bar', true ) ) {
     2234        $enqueue = true;
     2235        add_action( 'admin_print_footer_scripts', '_wp_pointer_print_admin_bar' );
     2236    }
     2237
     2238    if ( $enqueue ) {
     2239        wp_enqueue_style( 'wp-pointer' );
     2240        wp_enqueue_script( 'wp-pointer' );
     2241        wp_enqueue_script( 'utils' );
     2242    }
     2243}
     2244add_action( 'admin_enqueue_scripts', 'wp_pointer_enqueue' );
     2245
     2246function _wp_pointer_print_admin_bar() {
     2247    $pointer_content  = '<h3>' . __('The admin bar has been updated in WordPress 3.3.') . '</h3>';
     2248    $pointer_content .= '<p>' . sprintf( __('Have some feedback? Visit this <a href="%s">ticket</a>.'), 'http://core.trac.wordpress.org/ticket/18197' ) . '</p>';
     2249    $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>';
     2250
     2251?>
     2252<script type="text/javascript">
     2253//<![CDATA[
     2254jQuery(document).ready( function($) {
     2255    $('#wpadminbar').pointer({
     2256        content: '<?php echo $pointer_content; ?>',
     2257        position: {
     2258            my: 'left top',
     2259            at: 'center bottom',
     2260            offset: '-25 0'
     2261        },
     2262        close: function() {
     2263            setUserSetting( 'p0', '1' );
     2264        }
     2265    }).pointer('open');
     2266});
     2267//]]>
     2268</script>
     2269<?php
     2270}
  • trunk/wp-includes/script-loader.php

    r18704 r18707  
    9595        'noPerm' => __('You do not have permission to do that.'),
    9696        'broken' => __('An unidentified error has occurred.')
     97    ) );
     98
     99    $scripts->add( 'wp-pointer', "/wp-includes/js/wp-pointer$suffix.js", array( 'jquery-ui-widget', 'jquery-ui-position' ), '20110918', 1 );
     100    $scripts->add_script_data( 'wp-pointer', 'wpPointerL10n', array(
     101        'close' => __('Close'),
    97102    ) );
    98103
     
    426431    $styles->add( 'wp-jquery-ui-dialog', "/wp-includes/css/jquery-ui-dialog$suffix.css", array(), '20101224' );
    427432    $styles->add( 'editor-buttons', "/wp-includes/css/editor-buttons$suffix.css", array(), '20110802' );
     433    $styles->add( 'wp-pointer', "/wp-includes/css/wp-pointer$suffix.css", array(), '20110918' );
    428434
    429435    foreach ( $rtl_styles as $rtl_style ) {
Note: See TracChangeset for help on using the changeset viewer.