From e44a0c3930a52fe9b40670b78d532f7f42f3cd6b Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 11 May 2012 20:29:08 +0000 Subject: [PATCH] First pass at 3.4 pointers. Add pointer to the customize link for the current theme on themes.php. Support multiple pointers per page. Props scribu. see #20554 git-svn-id: http://core.svn.wordpress.org/trunk@20774 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/template.php | 48 ++++++++++++++++++++++++---------- wp-admin/themes.php | 2 +- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 1c4310336..b06c903dd 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -1707,36 +1707,40 @@ final class WP_Internal_Pointers { 'index.php' => 'wp330_toolbar', 'post-new.php' => 'wp330_media_uploader', 'post.php' => 'wp330_media_uploader', - 'themes.php' => 'wp330_saving_widgets', + 'themes.php' => array( 'wp330_saving_widgets', 'wp340_customize_current_theme_link' ), ); // Check if screen related pointer is registered if ( empty( $registered_pointers[ $hook_suffix ] ) ) return; - $pointer = $registered_pointers[ $hook_suffix ]; + $pointers = (array) $registered_pointers[ $hook_suffix ]; $caps_required = array( 'wp330_media_uploader' => array( 'upload_files' ), 'wp330_saving_widgets' => array( 'edit_theme_options', 'switch_themes' ), + 'wp340_customize_current_theme_link' => array( 'edit_theme_options' ), ); - if ( isset( $caps_required[ $pointer ] ) ) { - foreach ( $caps_required[ $pointer ] as $cap ) { - if ( ! current_user_can( $cap ) ) - return; - } - } - // Get dismissed pointers $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ); - // Pointer has been dismissed - if ( in_array( $pointer, $dismissed ) ) - return; + $got_pointers = false; + foreach ( array_diff( $pointers, $dismissed ) as $pointer ) { + if ( isset( $caps_required[ $pointer ] ) ) { + foreach ( $caps_required[ $pointer ] as $cap ) { + if ( ! current_user_can( $cap ) ) + continue 2; + } + } - // Bind pointer print function - add_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_' . $pointer ) ); + // Bind pointer print function + add_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_' . $pointer ) ); + $got_pointers = true; + } + + if ( ! $got_pointers ) + return; // Add pointers script and style to queue wp_enqueue_style( 'wp-pointer' ); @@ -1824,6 +1828,22 @@ final class WP_Internal_Pointers { ) ); } + /** + * Print 'New Feature: Current Theme Customize Link' for 3.4.0. + * + * @since 3.4.0 + */ + public static function pointer_wp340_customize_current_theme_link() { + $content = '

' . __( 'New Feature: Customizer' ) . '

'; + $content .= '

' . __( 'Click Customize to change the header, background, title and menus of the current theme, all in one place.' ) . '

'; + $content .= '

' . __( 'Click the Customize links in the Available Themes list below to customize, preview, and optionally activate the selected theme.' ) . '

'; + + WP_Internal_Pointers::print_js( 'wp340_customize_current_theme_link', '#customize-current-theme-link', array( + 'content' => $content, + 'position' => array( 'edge' => 'top', 'align' => is_rtl() ? 'right' : 'left' ), + ) ); + } + /** * Prevents new users from seeing existing 'new feature' pointers. * diff --git a/wp-admin/themes.php b/wp-admin/themes.php index 16217104e..c8bdd797c 100644 --- a/wp-admin/themes.php +++ b/wp-admin/themes.php @@ -140,7 +140,7 @@ $customize_title = sprintf( __( 'Customize “%s”' ), $ct->display('Na
- +