Make WordPress Core

Ticket #20554: 20554.diff

File 20554.diff, 4.0 KB (added by ryan, 13 years ago)

Allow multiple pointers per hook name. Rough in pointer to current theme customize link.

  • wp-admin/includes/template.php

     
    17051705                        'index.php'    => 'wp330_toolbar',
    17061706                        'post-new.php' => 'wp330_media_uploader',
    17071707                        'post.php'     => 'wp330_media_uploader',
    1708                         'themes.php'   => 'wp330_saving_widgets',
     1708                        'themes.php'   => array( 'wp330_saving_widgets', 'wp340_customize_current_theme_link' ),
    17091709                );
    17101710
    17111711                // Check if screen related pointer is registered
    17121712                if ( empty( $registered_pointers[ $hook_suffix ] ) )
    17131713                        return;
    17141714
    1715                 $pointer = $registered_pointers[ $hook_suffix ];
     1715                $pointers = (array) $registered_pointers[ $hook_suffix ];
    17161716
    17171717                $caps_required = array(
    17181718                        'wp330_media_uploader' => array( 'upload_files' ),
    17191719                        'wp330_saving_widgets' => array( 'edit_theme_options', 'switch_themes' ),
     1720                        'wp340_customize_current_theme_link' => array( 'edit_theme_options' ),
    17201721                );
    17211722
    1722                 if ( isset( $caps_required[ $pointer ] ) ) {
    1723                         foreach ( $caps_required[ $pointer ] as $cap ) {
    1724                                 if ( ! current_user_can( $cap ) )
    1725                                         return;
     1723                // Get dismissed pointers
     1724                $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
     1725
     1726                $got_pointers = false;
     1727                foreach ( $pointers as $pointer ) {
     1728                        if ( isset( $caps_required[ $pointer ] ) ) {
     1729                                foreach ( $caps_required[ $pointer ] as $cap ) {
     1730                                        if ( ! current_user_can( $cap ) )
     1731                                                continue 2;
     1732                                }
    17261733                        }
     1734
     1735                        // Pointer has been dismissed
     1736                        if ( in_array( $pointer, $dismissed ) )
     1737                                continue;
     1738
     1739                        // Bind pointer print function
     1740                        add_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_' . $pointer ) );
     1741                        $got_pointers = true;
    17271742                }
    17281743
    1729                 // Get dismissed pointers
    1730                 $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
    1731 
    1732                 // Pointer has been dismissed
    1733                 if ( in_array( $pointer, $dismissed ) )
     1744                if ( ! $got_pointers )
    17341745                        return;
    17351746
    1736                 // Bind pointer print function
    1737                 add_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_' . $pointer ) );
    1738 
    17391747                // Add pointers script and style to queue
    17401748                wp_enqueue_style( 'wp-pointer' );
    17411749                wp_enqueue_script( 'wp-pointer' );
     
    18231831        }
    18241832
    18251833        /**
     1834         * Print 'New Feature: Current Theme Customize Link' for 3.4.0.
     1835         *
     1836         * @since 3.3.0
     1837         */
     1838        public static function pointer_wp340_customize_current_theme_link() {
     1839                $content  = '<h3>' . __( 'New Feature: Customizer' ) . '</h3>';
     1840                $content .= '<p>' . __( 'Click Customize to change the header, background, title and menus of the current theme, all in one place.' ) . '</p>';
     1841                $content .= '<p>' . __( 'Click the Customize links in the Available Themes list below to customize, preview, and optionally activate the selected theme.' ) . '</p>';
     1842
     1843                WP_Internal_Pointers::print_js( 'wp340_customize_current_theme_link', '#customize-current-theme-link', array(
     1844                        'content'  => $content,
     1845                        'position' => array( 'edge' => 'top', 'align' => is_rtl() ? 'right' : 'left' ),
     1846                ) );
     1847        }
     1848
     1849        /**
    18261850         * Prevents new users from seeing existing 'new feature' pointers.
    18271851         *
    18281852         * @since 3.3.0
  • wp-admin/themes.php

     
    122122        </div>
    123123
    124124<div class="theme-options">
    125         <a href="<?php echo wp_customize_url( $ct->get_stylesheet() ); ?>" class="load-customize hide-if-no-customize" title="<?php echo esc_attr( sprintf( __( 'Customize &#8220;%s&#8221;' ), $ct->display('Name') ) ); ?>"><?php _e( 'Customize' )?></a>
     125        <a id="customize-current-theme-link" href="<?php echo wp_customize_url( $ct->get_stylesheet() ); ?>" class="load-customize hide-if-no-customize" title="<?php echo esc_attr( sprintf( __( 'Customize &#8220;%s&#8221;' ), $ct->display('Name') ) ); ?>"><?php _e( 'Customize' )?></a>
    126126        <span><?php _e( 'Options:' )?></span>
    127127        <?php
    128128        // Pretend you didn't see this.