1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
<?php /** * Class AMP_Admin_Pointers * * @package AMP * @since 1.2 */
/** * Class managing admin pointers to enhance discoverability. * * @since 1.2 * @internal */ class AMP_Admin_Pointers {
/** * Registers functionality through WordPress hooks. * * @since 1.2 */ public function init() { add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] ); }
/** * Initializes admin pointers by enqueuing necessary scripts. * * @since 1.2 * * @param string $hook_suffix The current admin screen hook suffix. */ public function enqueue_scripts( $hook_suffix ) { $pointers = $this->get_pointers(); if ( empty( $pointers ) ) { return; }
// Only enqueue one pointer at a time to prevent them overlaying each other. foreach ( $pointers as $pointer ) { if ( ! $pointer->is_active( $hook_suffix ) ) { continue; }
$pointer->enqueue(); return; } }
/** * Gets available admin pointers. * * @since 1.2 * * @return array List of AMP_Admin_Pointer instances. */ private function get_pointers() { return [ new AMP_Admin_Pointer( 'amp_template_mode_pointer_10', [ 'selector' => '#toplevel_page_amp-options', 'heading' => esc_html__( 'AMP', 'amp' ), 'subheading' => esc_html__( 'New AMP Template Modes', 'amp' ), 'description' => esc_html__( 'You can now reuse your theme\'s templates and styles in AMP responses, in both “Transitional” and “Standard” modes.', 'amp' ), 'position' => [ 'align' => 'middle', ], 'active_callback' => static function() { return version_compare( strtok( AMP__VERSION, '-' ), '1.1', '<' ); }, ] ), ]; } }
|