From a415c29efee45520ae252d2aa28f1083a521cd7b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 09:56:49 +0200 Subject: Adding upstream version 6.4.3+dfsg1. Signed-off-by: Daniel Baumann --- wp-admin/includes/class-wp-internal-pointers.php | 175 +++++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 wp-admin/includes/class-wp-internal-pointers.php (limited to 'wp-admin/includes/class-wp-internal-pointers.php') diff --git a/wp-admin/includes/class-wp-internal-pointers.php b/wp-admin/includes/class-wp-internal-pointers.php new file mode 100644 index 0000000..6d7ebe9 --- /dev/null +++ b/wp-admin/includes/class-wp-internal-pointers.php @@ -0,0 +1,175 @@ + pointer callback + * ) + * + * Example: + * array( + * 'themes.php' => 'wp390_widgets' + * ) + */ + $registered_pointers = array( + // None currently. + ); + + // Check if screen related pointer is registered. + if ( empty( $registered_pointers[ $hook_suffix ] ) ) { + return; + } + + $pointers = (array) $registered_pointers[ $hook_suffix ]; + + /* + * Specify required capabilities for feature pointers + * + * Format: + * array( + * pointer callback => Array of required capabilities + * ) + * + * Example: + * array( + * 'wp390_widgets' => array( 'edit_theme_options' ) + * ) + */ + $caps_required = array( + // None currently. + ); + + // Get dismissed pointers. + $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ); + + $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 ) ); + $got_pointers = true; + } + + if ( ! $got_pointers ) { + return; + } + + // Add pointers script and style to queue. + wp_enqueue_style( 'wp-pointer' ); + wp_enqueue_script( 'wp-pointer' ); + } + + /** + * Prints the pointer JavaScript data. + * + * @since 3.3.0 + * + * @param string $pointer_id The pointer ID. + * @param string $selector The HTML elements, on which the pointer should be attached. + * @param array $args Arguments to be passed to the pointer JS (see wp-pointer.js). + */ + private static function print_js( $pointer_id, $selector, $args ) { + if ( empty( $pointer_id ) || empty( $selector ) || empty( $args ) || empty( $args['content'] ) ) { + return; + } + + ?> + +