PluginProbe ʕ •ᴥ•ʔ
Admin Help Docs / 2.0.3
Admin Help Docs v2.0.3
2.0.3 2.0.2 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 / side.php
admin-help-docs / inc / docs / page-locations Last commit date
js 23 hours ago bottom.php 23 hours ago contextual.php 23 hours ago element.php 23 hours ago side.php 23 hours ago top.php 23 hours ago
side.php
83 lines
1 <?php
2 /**
3 * Sidebars
4 */
5
6 namespace PluginRx\AdminHelpDocs;
7
8 if ( ! defined( 'ABSPATH' ) ) exit;
9
10 class Side {
11
12 /**
13 * The docs to be rendered
14 *
15 * @var array
16 */
17 private array $docs = [];
18
19 /**
20 * Constructor
21 */
22 public function __construct( $docs = [] ) {
23 if ( empty( $docs ) ) {
24 return;
25 }
26
27 $this->docs = $docs;
28
29 add_action( 'submitpost_box', [ $this, 'render' ] );
30 add_action( 'admin_enqueue_scripts', [ $this, 'scripts' ] );
31 } // End __construct()
32
33
34 /**
35 * Render the docs
36 */
37 public function render() : void {
38 if ( Helpers::is_gutenberg() || empty( $this->docs ) ) {
39 return;
40 }
41
42 $allowed_tags = Helpers::allow_addt_tags( wp_kses_allowed_html( 'post' ) );
43
44 echo '<div class="helpdocs-side-wrapper">';
45 foreach ( $this->docs as $doc ) {
46 $content = apply_filters( 'the_content', $doc->post_content );
47 $html = Helpers::output_doc( $doc->ID, $doc->post_title, $content, 'side' );
48
49 echo wp_kses( $html, $allowed_tags );
50 }
51 echo '</div>';
52 } // End render()
53
54
55 /**
56 * Enqueue scripts
57 */
58 public function scripts() : void {
59 $screen = get_current_screen();
60 if ( ! $screen || ! Helpers::is_gutenberg() || empty( $this->docs ) ) {
61 return;
62 }
63
64 $docs = Helpers::clean_docs_for_gutenberg( $this->docs );
65
66 $text_domain = Bootstrap::textdomain();
67 $script_version = Bootstrap::script_version();
68
69 wp_enqueue_script( $text_domain . "-side", Bootstrap::url( "inc/docs/page-locations/js/side.js" ), [ 'jquery' ], $script_version, true );
70 wp_localize_script( $text_domain . "-side", "helpdocs_side", [
71 'docs' => $docs,
72 'template' => Helpers::output_doc( '{doc_id}', '{doc_title}', '{doc_content}', 'side' ),
73 ] );
74 } // End scripts()
75
76
77 /**
78 * Prevent cloning and unserializing
79 */
80 public function __clone() {}
81 public function __wakeup() {}
82
83 }