equal
deleted
inserted
replaced
20 * |
20 * |
21 * All pointers can be disabled using the following: |
21 * All pointers can be disabled using the following: |
22 * remove_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts' ) ); |
22 * remove_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts' ) ); |
23 * |
23 * |
24 * Individual pointers (e.g. wp390_widgets) can be disabled using the following: |
24 * Individual pointers (e.g. wp390_widgets) can be disabled using the following: |
25 * remove_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_wp390_widgets' ) ); |
25 * |
|
26 * function yourprefix_remove_pointers() { |
|
27 * remove_action( |
|
28 * 'admin_print_footer_scripts', |
|
29 * array( 'WP_Internal_Pointers', 'pointer_wp390_widgets' ) |
|
30 * ); |
|
31 * } |
|
32 * add_action( 'admin_enqueue_scripts', 'yourprefix_remove_pointers', 11 ); |
26 * |
33 * |
27 * @param string $hook_suffix The current admin page. |
34 * @param string $hook_suffix The current admin page. |
28 */ |
35 */ |
29 public static function enqueue_scripts( $hook_suffix ) { |
36 public static function enqueue_scripts( $hook_suffix ) { |
30 /* |
37 /* |
39 * array( |
46 * array( |
40 * 'themes.php' => 'wp390_widgets' |
47 * 'themes.php' => 'wp390_widgets' |
41 * ) |
48 * ) |
42 */ |
49 */ |
43 $registered_pointers = array( |
50 $registered_pointers = array( |
44 //None currently. |
51 // None currently. |
45 ); |
52 ); |
46 |
53 |
47 // Check if screen related pointer is registered |
54 // Check if screen related pointer is registered. |
48 if ( empty( $registered_pointers[ $hook_suffix ] ) ) { |
55 if ( empty( $registered_pointers[ $hook_suffix ] ) ) { |
49 return; |
56 return; |
50 } |
57 } |
51 |
58 |
52 $pointers = (array) $registered_pointers[ $hook_suffix ]; |
59 $pointers = (array) $registered_pointers[ $hook_suffix ]; |
66 */ |
73 */ |
67 $caps_required = array( |
74 $caps_required = array( |
68 // None currently. |
75 // None currently. |
69 ); |
76 ); |
70 |
77 |
71 // Get dismissed pointers |
78 // Get dismissed pointers. |
72 $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ); |
79 $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ); |
73 |
80 |
74 $got_pointers = false; |
81 $got_pointers = false; |
75 foreach ( array_diff( $pointers, $dismissed ) as $pointer ) { |
82 foreach ( array_diff( $pointers, $dismissed ) as $pointer ) { |
76 if ( isset( $caps_required[ $pointer ] ) ) { |
83 if ( isset( $caps_required[ $pointer ] ) ) { |
79 continue 2; |
86 continue 2; |
80 } |
87 } |
81 } |
88 } |
82 } |
89 } |
83 |
90 |
84 // Bind pointer print function |
91 // Bind pointer print function. |
85 add_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_' . $pointer ) ); |
92 add_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_' . $pointer ) ); |
86 $got_pointers = true; |
93 $got_pointers = true; |
87 } |
94 } |
88 |
95 |
89 if ( ! $got_pointers ) { |
96 if ( ! $got_pointers ) { |
90 return; |
97 return; |
91 } |
98 } |
92 |
99 |
93 // Add pointers script and style to queue |
100 // Add pointers script and style to queue. |
94 wp_enqueue_style( 'wp-pointer' ); |
101 wp_enqueue_style( 'wp-pointer' ); |
95 wp_enqueue_script( 'wp-pointer' ); |
102 wp_enqueue_script( 'wp-pointer' ); |
96 } |
103 } |
97 |
104 |
98 /** |
105 /** |