PluginProbe ʕ •ᴥ•ʔ
Admin Help Docs / 2.0.0.1
Admin Help Docs v2.0.0.1
2.0.1.1 trunk 1.4.3.2 2.0.0 2.0.0.1 2.0.0.2 2.0.1
admin-help-docs / inc / docs / page-locations / element.php
admin-help-docs / inc / docs / page-locations Last commit date
js 3 months ago bottom.php 3 months ago contextual.php 3 months ago element.php 3 months ago side.php 3 months ago top.php 3 months ago
element.php
64 lines
1 <?php
2 /**
3 * Element (CSS Selector) Location
4 */
5
6 namespace PluginRx\AdminHelpDocs;
7
8 if ( ! defined( 'ABSPATH' ) ) exit;
9
10 class Element {
11
12
13 /**
14 * The docs to be rendered
15 *
16 * @var array
17 */
18 private array $docs = [];
19
20
21 /**
22 * Constructor
23 */
24 public function __construct( $docs = [] ) {
25 if ( empty( $docs ) ) {
26 return;
27 }
28
29 $this->docs = $docs;
30
31 add_action( 'admin_enqueue_scripts', [ $this, 'scripts' ] );
32 } // End __construct()
33
34
35 /**
36 * Add a help tab button for the current gutenberg screen
37 */
38 public function scripts() : void {
39 $screen = get_current_screen();
40 if ( ! $screen || empty( $this->docs ) ) {
41 return;
42 }
43
44 $is_gutenberg = Helpers::is_gutenberg();
45 $docs = Helpers::clean_docs_for_gutenberg( $this->docs );
46
47 $text_domain = Bootstrap::textdomain();
48 $script_version = Bootstrap::script_version();
49
50 wp_enqueue_script( $text_domain . "-element", Bootstrap::url( "inc/docs/page-locations/js/element.js" ), [ 'jquery' ], $script_version, true );
51 wp_localize_script( $text_domain . "-element", "helpdocs_element", [
52 'docs' => $docs,
53 'is_gutenberg' => $is_gutenberg,
54 ] );
55 } // End scripts()
56
57
58 /**
59 * Prevent cloning and unserializing
60 */
61 public function __clone() {}
62 public function __wakeup() {}
63
64 }