PluginProbe
Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code / 5.2.0
Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code v5.2.0
5.5.3 3.1.0 3.2.0 3.2.1 3.3.0 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.6.0 3.7.0 3.8.0 3.8.1 3.8.2 3.8.3 4.0.0 4.0.2 4.0.3 4.0.4 4.0.5 4.1.0 4.1.1 All 78 releases
copy-the-code / includes / class-base.php

class-base.php in Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code 5.2.0, at includes/class-base.php

178 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Base
4 *
5 * @package CTC
6 * @since 5.1.0
7 */
8
9 namespace CTC;
10
11 use CTC\Dashboard;
12 use CTC\Global_Injector;
13 use CTC\Global_Injector\Main_Rule_List;
14
15 /**
16 * Base
17 *
18 * @since 5.1.0
19 */
20 class Base {
21
22 /**
23 * Instance
24 *
25 * @since 5.1.0
26 *
27 * @access private
28 * @var object Class object.
29 */
30 private static $instance;
31
32 /**
33 * Initiator
34 *
35 * @since 5.1.0
36 *
37 * @return object initialized object of class.
38 */
39 public static function get() {
40 if ( null === self::$instance ) {
41 self::$instance = new self();
42 }
43 return self::$instance;
44 }
45
46 /**
47 * Constructor
48 *
49 * @since 5.1.0
50 */
51 public function __construct() {
52 add_action( 'admin_menu', [ $this, 'register_menus' ] );
53 add_action( 'load-settings_page_ctc', [ $this, 'load_dashboard' ] );
54 }
55
56 /**
57 * Load dashboard assets and body class before admin header (required for page=ctc).
58 *
59 * @since 5.1.0
60 * @return void
61 */
62 public function load_dashboard() {
63 Dashboard::get()->bootstrap();
64 }
65
66 /**
67 * Register menus (all under Settings).
68 *
69 * @since 5.1.0
70 * @return void
71 */
72 public function register_menus() {
73 add_submenu_page(
74 'options-general.php',
75 __( 'Copy to Clipboard', 'ctc' ),
76 __( 'Copy to Clipboard', 'ctc' ),
77 'manage_options',
78 'ctc',
79 [ $this, 'render_dashboard' ]
80 );
81
82 add_submenu_page(
83 'options-general.php',
84 __( 'Global Injector', 'ctc' ),
85 '' . __( 'Global Injector', 'ctc' ),
86 'manage_options',
87 'ctc-rules',
88 [ $this, 'render_rules_list' ]
89 );
90
91 add_submenu_page(
92 'options-general.php',
93 __( 'Add New Rule', 'ctc' ),
94 '' . __( 'Add new', 'ctc' ),
95 'manage_options',
96 'ctc-global-injector',
97 [ Global_Injector::get(), 'render' ]
98 );
99
100 /*
101 add_submenu_page(
102 'options-general.php',
103 __( 'Copy to Clipboard Settings', 'ctc' ),
104 '↳ ' . __( 'Settings', 'ctc' ),
105 'manage_options',
106 'ctc-settings',
107 [ $this, 'render_settings_placeholder' ]
108 );
109 */
110
111 /*
112 add_submenu_page(
113 'options-general.php',
114 __( 'Help & Docs', 'ctc' ),
115 '↳ ' . __( 'Help & Docs', 'ctc' ),
116 'manage_options',
117 'ctc-help',
118 [ $this, 'render_help_placeholder' ]
119 );
120 */
121 }
122
123 /**
124 * Render dashboard (React app mounts here).
125 *
126 * @since 5.1.0
127 * @return void
128 */
129 public function render_dashboard() {
130 ?>
131 <div class="wrap ctc-admin-root ctc-dashboard-page" id="ctc-dashboard-root"></div>
132 <?php
133 }
134
135 /**
136 * Render rules list page (Main Rule List UI mounts here).
137 *
138 * @since 5.1.0
139 * @return void
140 */
141 public function render_rules_list() {
142 Main_Rule_List::get()->bootstrap();
143 ?>
144 <div class="wrap ctc-admin-root ctc-main-rule-list-page" id="ctc-main-rule-list-root"></div>
145 <?php
146 }
147
148 /**
149 * Placeholder for future Settings page.
150 *
151 * @since 5.1.0
152 * @return void
153 */
154 public function render_settings_placeholder() {
155 ?>
156 <div class="wrap">
157 <h1><?php esc_html_e( 'Copy to Clipboard Settings', 'ctc' ); ?></h1>
158 <p><?php esc_html_e( 'Settings will be available in a future release.', 'ctc' ); ?></p>
159 </div>
160 <?php
161 }
162
163 /**
164 * Placeholder for future Help & Docs page.
165 *
166 * @since 5.1.0
167 * @return void
168 */
169 public function render_help_placeholder() {
170 ?>
171 <div class="wrap">
172 <h1><?php esc_html_e( 'Help & Docs', 'ctc' ); ?></h1>
173 <p><?php esc_html_e( 'Documentation and help will be available here in a future release.', 'ctc' ); ?></p>
174 </div>
175 <?php
176 }
177 }
178