PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.2.0
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.2.0
4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.5.2 All 199 releases
← All changes | includes/Plugin.php +369 -390 4.5.64.2.0 View file →
@@ -2,9 +2,9 @@
2 2
3 3 namespace WPDeveloper\BetterDocs;
4 4
5 5 if ( ! defined( 'ABSPATH' ) ) {
6 - exit; // Exit if accessed directly
6 + exit; // Exit if accessed directly
7 7 }
8 8
9 9 use WPDeveloper\BetterDocs\Admin\Analytics;
10 10 use WPDeveloper\BetterDocs\Admin\Customizer\Customizer;
@@ -22,15 +22,12 @@
22 22 use WPDeveloper\BetterDocs\Core\Settings;
23 23 use WPDeveloper\BetterDocs\Core\ShortcodeFactory;
24 24 use WPDeveloper\BetterDocs\Core\WriteWithAI;
25 25 use WPDeveloper\BetterDocs\Core\ArticleSummary;
26 -use WPDeveloper\BetterDocs\Core\ArticleQualityScore;
27 -use WPDeveloper\BetterDocs\Core\UnifiedMetabox;
28 26 use WPDeveloper\BetterDocs\Dependencies\DI\Container;
29 27 use WPDeveloper\BetterDocs\Dependencies\DI\ContainerBuilder;
30 28 use WPDeveloper\BetterDocs\Editors\Editor;
31 29 use WPDeveloper\BetterDocs\FrontEnd\FrontEnd;
32 -use WPDeveloper\BetterDocs\FrontEnd\SearchExtender;
33 30 use WPDeveloper\BetterDocs\FrontEnd\TemplateTags;
34 31 use WPDeveloper\BetterDocs\Modules\StyleHandler as ModulesStyleHandler;
35 32 use WPDeveloper\BetterDocs\Utils\Database;
36 33 use WPDeveloper\BetterDocs\Utils\Enqueue;
@@ -37,454 +34,436 @@
37 34 use WPDeveloper\BetterDocs\Utils\Helper;
38 35 use WPDeveloper\BetterDocs\Utils\Views;
39 36
40 37 final class Plugin {
41 - private static $_instance = null;
42 - /**
43 - * Assets manager
44 - *
45 - * @var Enqueue
46 - */
47 - public $assets;
48 - /**
49 - * View manager
50 - *
51 - * @var Views
52 - */
53 - public $views;
54 - /**
55 - * Container Manager
56 - *
57 - * @var Container
58 - */
59 - public $container;
60 - /**
61 - * Editor Manager
62 - * @var Editor
63 - */
64 - public $editor;
65 - /**
66 - * Helper class
67 - * @var Helper
68 - */
69 - public $helper;
70 - /**
71 - * KBMigration class
72 - * @var KBMigration
73 - */
74 - public $kbmigration;
75 - /**
76 - * KBMigration class
77 - * @var Admin
78 - */
79 - public $admin;
80 - /**
81 - * Helper class
82 - * @var Database
83 - */
84 - public $database;
85 - /**
86 - * Helper class
87 - * @var Settings
88 - */
89 - public $settings;
90 - /**
91 - * Helper class
92 - * @var TemplateTags
93 - */
94 - public $template_helper;
95 - /**
96 - * Article Summary class
97 - * @var ArticleSummary
98 - */
99 - public $article_summary;
100 - /**
101 - * Customizer class
102 - * @var Customizer
103 - */
104 - public $customizer;
105 - /**
106 - * Query class
107 - * @var Query
108 - */
109 - public $query;
110 - /**
111 - * Rewrite Class
112 - * @var Rewrite
113 - */
114 - public $rewrite;
115 - /**
116 - * Request Class
117 - * @var Request
118 - */
119 - public $request;
120 - /**
121 - * Analytics Class
122 - * @var Analytics
123 - */
124 - public $analytics;
125 - /**
126 - * Plugin Version
127 - * @var string
128 - */
129 - public $version = '4.5.6';
38 + private static $_instance = null;
39 + /**
40 + * Assets manager
41 + *
42 + * @var Enqueue
43 + */
44 + public $assets;
45 + /**
46 + * View manager
47 + *
48 + * @var Views
49 + */
50 + public $views;
51 + /**
52 + * Container Manager
53 + *
54 + * @var Container
55 + */
56 + public $container;
57 + /**
58 + * Editor Manager
59 + * @var Editor
60 + */
61 + public $editor;
62 + /**
63 + * Helper class
64 + * @var Helper
65 + */
66 + public $helper;
67 + /**
68 + * KBMigration class
69 + * @var KBMigration
70 + */
71 + public $kbmigration;
72 + /**
73 + * KBMigration class
74 + * @var Admin
75 + */
76 + public $admin;
77 + /**
78 + * Helper class
79 + * @var Database
80 + */
81 + public $database;
82 + /**
83 + * Helper class
84 + * @var Settings
85 + */
86 + public $settings;
87 + /**
88 + * Helper class
89 + * @var TemplateTags
90 + */
91 + public $template_helper;
92 + /**
93 + * Article Summary class
94 + * @var ArticleSummary
95 + */
96 + public $article_summary;
97 + /**
98 + * Customizer class
99 + * @var Customizer
100 + */
101 + public $customizer;
102 + /**
103 + * Query class
104 + * @var Query
105 + */
106 + public $query;
107 + /**
108 + * Rewrite Class
109 + * @var Rewrite
110 + */
111 + public $rewrite;
112 + /**
113 + * Request Class
114 + * @var Request
115 + */
116 + public $request;
117 + /**
118 + * Analytics Class
119 + * @var Analytics
120 + */
121 + public $analytics;
122 + /**
123 + * Plugin Version
124 + * @var string
125 + */
126 + public $version = '4.2.0';
130 127
131 - /**
132 - * WriteWithAI Class
133 - * @var string
134 - */
135 - public $ai_autowrtie;
136 - public $backgroundProccessor;
128 + /**
129 + * WriteWithAI Class
130 + * @var string
131 + */
132 + public $ai_autowrtie;
133 + public $backgroundProccessor;
137 134
138 - /**
139 - * ArticleQualityScore Class
140 - * @var ArticleQualityScore
141 - */
142 - public $article_quality_score;
135 + /**
136 + * Plugin DB Version
137 + * @var string
138 + */
139 + public $db_version = '1.0.1';
143 140
144 - /**
145 - * Plugin DB Version
146 - * @var string
147 - */
148 - public $db_version = '1.0.1';
141 + public function __construct() {
142 + $this->define_constants();
149 143
150 - public function __construct() {
151 - $this->define_constants();
144 + do_action( 'betterdocs_init_before' );
152 145
153 - do_action( 'betterdocs_init_before' );
146 + $this->setup_container();
147 + /**
148 + * Register activation and deactivation hooks
149 + * and version updates check
150 + */
151 + $this->container->get( Install::class );
154 152
155 - $this->setup_container();
156 - /**
157 - * Register activation and deactivation hooks
158 - * and version updates check
159 - */
160 - $this->container->get( Install::class );
153 + add_action( 'init', [ $this, 'initialize' ], 0 );
161 154
162 - add_action( 'init', array( $this, 'initialize' ), 0 );
155 + /**
156 + * Initialize API
157 + */
158 + add_action( 'rest_api_init', [ $this, 'api_initialization' ] );
163 159
164 - /**
165 - * Initialize API
166 - */
167 - add_action( 'rest_api_init', array( $this, 'api_initialization' ) );
160 + /**
161 + * For admin only
162 + */
163 + add_action( 'admin_init', [ $this, 'admin_init' ], 0 );
168 164
169 - /**
170 - * For admin only
171 - */
172 - add_action( 'admin_init', array( $this, 'admin_init' ), 0 );
165 + /**
166 + * For AJAX only
167 + */
168 + $this->ajax();
173 169
174 - /**
175 - * For AJAX only
176 - */
177 - $this->ajax();
170 + /**
171 + * Style Handler For Parsing and Saving Styles as file.
172 + */
173 + ModulesStyleHandler::init();
174 + }
178 175
179 - /**
180 - * Style Handler For Parsing and Saving Styles as file.
181 - */
182 - ModulesStyleHandler::init();
183 - }
176 + private function define_constants() {
177 + $this->define( 'BETTERDOCS_VERSION', $this->version );
178 + $this->define( 'BETTERDOCS_DB_VERSION', $this->db_version );
179 + $this->define( 'BETTERDOCS_ABSPATH', dirname( BETTERDOCS_PLUGIN_FILE ) . '/' );
180 + $this->define( 'BETTERDOCS_ABSURL', plugin_dir_url( BETTERDOCS_PLUGIN_FILE ) );
181 + $this->define( 'BETTERDOCS_PLUGIN_BASENAME', plugin_basename( BETTERDOCS_PLUGIN_FILE ) );
182 + $this->define( 'BETTERDOCS_BLOCKS_DIRECTORY', BETTERDOCS_ABSPATH . 'assets/blocks/' );
183 + $this->define( 'BETTERDOCS_ROOT_DIR_PATH', plugin_dir_path( BETTERDOCS_PLUGIN_FILE ) );
184 + $this->define( 'BETTERDOCS_FSE_TEMPLATES_PATH', BETTERDOCS_ROOT_DIR_PATH . 'views/templates/fse' );
184 185
185 - private function define_constants() {
186 - $this->define( 'BETTERDOCS_VERSION', $this->version );
187 - $this->define( 'BETTERDOCS_DB_VERSION', $this->db_version );
188 - $this->define( 'BETTERDOCS_ABSPATH', dirname( BETTERDOCS_PLUGIN_FILE ) . '/' );
189 - $this->define( 'BETTERDOCS_ABSURL', plugin_dir_url( BETTERDOCS_PLUGIN_FILE ) );
190 - $this->define( 'BETTERDOCS_PLUGIN_BASENAME', plugin_basename( BETTERDOCS_PLUGIN_FILE ) );
191 - $this->define( 'BETTERDOCS_BLOCKS_DIRECTORY', BETTERDOCS_ABSPATH . 'assets/blocks/' );
192 - $this->define( 'BETTERDOCS_ROOT_DIR_PATH', plugin_dir_path( BETTERDOCS_PLUGIN_FILE ) );
193 - $this->define( 'BETTERDOCS_FSE_TEMPLATES_PATH', BETTERDOCS_ROOT_DIR_PATH . 'views/templates/fse' );
186 + /**
187 + * Third Party Constants
188 + * @since 2.5.0
189 + *
190 + * WPML compatibility with Polylang
191 + */
192 + if ( Helper::is_plugin_active( 'polylang/polylang.php' ) ) {
193 + define( 'PLL_WPML_COMPAT', false );
194 + }
195 + }
194 196
195 - /**
196 - * Third Party Constants
197 - * @since 2.5.0
198 - *
199 - * WPML compatibility with Polylang
200 - */
201 - if ( Helper::is_plugin_active( 'polylang/polylang.php' ) ) {
202 - // Polylang's documented integration constant — must use the upstream-defined name.
203 - // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound
204 - define( 'PLL_WPML_COMPAT', false );
205 - }
206 - }
197 + /**
198 + * Define constant if not already set.
199 + *
200 + * @param string $name Constant name.
201 + * @param string|bool $value Constant value.
202 + */
203 + private function define( $name, $value ) {
204 + if ( ! defined( $name ) ) {
205 + define( $name, $value );
206 + }
207 + }
207 208
208 - /**
209 - * Define constant if not already set.
210 - *
211 - * @param string $name Constant name.
212 - * @param string|bool $value Constant value.
213 - */
214 - private function define( $name, $value ) {
215 - if ( ! defined( $name ) ) {
216 - // Caller passes plugin-prefixed names (BETTERDOCS_*); $name comes from a controlled internal allowlist.
217 - // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.VariableConstantNameFound
218 - define( $name, $value );
219 - }
220 - }
209 + public function setup_container() {
210 + $config_array = require_once BETTERDOCS_ABSPATH . 'includes/config.php';
211 + $config = apply_filters( 'betterdocs_container_config', $config_array );
212 + $builder = new ContainerBuilder();
221 213
222 - public function setup_container() {
223 - $config_array = require_once BETTERDOCS_ABSPATH . 'includes/config.php';
224 - $config = apply_filters( 'betterdocs_container_config', $config_array );
225 - $builder = new ContainerBuilder();
214 + $builder->addDefinitions( $config );
215 + $this->container = $builder->build();
216 + }
226 217
227 - $builder->addDefinitions( $config );
228 - $this->container = $builder->build();
229 - }
218 + public function initialize() {
230 219
231 - public function initialize() {
220 + /**
221 + * Setup localization.
222 + */
223 + $this->load_plugin_textdomain();
232 224
233 - /**
234 - * Setup localization.
235 - */
236 - $this->load_plugin_textdomain();
225 + $this->container->get( Scripts::class );
226 + $this->rewrite = $this->container->get( Rewrite::class );
227 + $this->request = $this->container->get( Request::class );
228 + $this->query = $this->container->get( Query::class );
237 229
238 - $this->container->get( Scripts::class );
239 - $this->rewrite = $this->container->get( Rewrite::class );
240 - $this->request = $this->container->get( Request::class );
241 - $this->query = $this->container->get( Query::class );
230 + // Initialize background process
231 + $this->backgroundProccessor = $this->container->get( HelpScoutMigration::class );
242 232
243 - // Initialize background process
244 - $this->backgroundProccessor = $this->container->get( HelpScoutMigration::class );
233 + $this->rewrite->init();
234 + $this->request->init();
245 235
246 - $this->rewrite->init();
247 - $this->request->init();
236 + $this->assets = $this->container->get( Enqueue::class );
237 + $this->views = $this->container->get( Views::class );
238 + $this->helper = $this->container->get( Helper::class );
239 + $this->kbmigration = $this->container->get( KBMigration::class );
240 + $this->admin = $this->container->get( Admin::class );
241 + $this->database = $this->container->get( Database::class );
242 + $this->settings = $this->container->get( Settings::class );
243 + $this->analytics = $this->container->get( Analytics::class );
248 244
249 - $this->assets = $this->container->get( Enqueue::class );
250 - $this->views = $this->container->get( Views::class );
251 - $this->helper = $this->container->get( Helper::class );
252 - $this->kbmigration = $this->container->get( KBMigration::class );
253 - $this->admin = $this->container->get( Admin::class );
254 - $this->database = $this->container->get( Database::class );
255 - $this->settings = $this->container->get( Settings::class );
256 - $this->analytics = $this->container->get( Analytics::class );
245 + $this->template_helper = $this->container->get( TemplateTags::class );
246 + $this->customizer = $this->container->get( Customizer::class );
247 + $this->editor = $this->container->get( Editor::class );
248 + $this->ai_autowrtie = $this->container->get( WriteWithAI::class );
249 + $this->article_summary = $this->container->get( ArticleSummary::class );
257 250
258 - $this->template_helper = $this->container->get( TemplateTags::class );
259 - $this->customizer = $this->container->get( Customizer::class );
260 - $this->editor = $this->container->get( Editor::class );
261 - $this->ai_autowrtie = $this->container->get( WriteWithAI::class );
262 - $this->article_summary = $this->container->get( ArticleSummary::class );
251 + $this->container->get( Admin::class );
252 + $this->container->get( Roles::class );
253 + $this->container->get( ReportEmail::class );
263 254
264 - // Initialize unified metabox before individual features
265 - $this->container->get( UnifiedMetabox::class );
266 - $this->article_quality_score = $this->container->get( ArticleQualityScore::class );
255 + /**
256 + * Initialize Shortcode
257 + * Make sure you have listed out all shortcode in shortcode factory.
258 + */
259 + $this->container->get( ShortcodeFactory::class )->init();
267 260
268 - $this->container->get( Admin::class );
269 - $this->container->get( Roles::class );
270 - $this->container->get( ReportEmail::class );
271 - // Usage-analytics collector. Registered here (runs on every request, incl.
272 - // WP-Cron) rather than in Admin so its `betterdocs_insights_data` filter
273 - // callback is present whenever the tracking payload is built.
274 - $this->container->get( \WPDeveloper\BetterDocs\Insights\Collector::class );
275 - /**
276 - * Initialize Shortcode
277 - * Make sure you have listed out all shortcode in shortcode factory.
278 - */
279 - $this->container->get( ShortcodeFactory::class )->init();
261 + $this->container->get( FrontEnd::class );
280 262
281 - $this->container->get( FrontEnd::class );
282 - $this->container->get( SearchExtender::class );
263 + do_action( 'betterdocs_init' );
283 264
284 - do_action( 'betterdocs_init' );
265 + $this->editor->init();
266 + }
285 267
286 - $this->editor->init();
287 - }
268 + /**
269 + * Load plugins textdomain `betterdocs` into actions.
270 + * @return void
271 + */
272 + public function load_plugin_textdomain( $textdomain = 'betterdocs', $plugin_file = BETTERDOCS_PLUGIN_FILE ) {
273 + $locale = determine_locale();
288 274
289 - /**
290 - * Load plugins textdomain `betterdocs` into actions.
291 - * @return void
292 - */
293 - public function load_plugin_textdomain( $textdomain = 'betterdocs', $plugin_file = BETTERDOCS_PLUGIN_FILE ) {
294 - $locale = determine_locale();
275 + /**
276 + * Filter to adjust the BetterDocs locale to use for translations.
277 + */
278 + $locale = apply_filters( 'plugin_locale', $locale, $textdomain );
295 279
296 - /**
297 - * Filter to adjust the BetterDocs locale to use for translations.
298 - */
299 - // 'plugin_locale' is a WP-core filter; using its documented name is required.
300 - // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
301 - $locale = apply_filters( 'plugin_locale', $locale, $textdomain );
280 + if ( file_exists( WP_LANG_DIR . "/$textdomain-" . $locale . '.mo' ) ) {
281 + unload_textdomain( $textdomain );
282 + load_textdomain( $textdomain, WP_LANG_DIR . "/$textdomain-" . $locale . '.mo' );
283 + }
302 284
303 - if ( file_exists( WP_LANG_DIR . "/$textdomain-" . $locale . '.mo' ) ) {
304 - unload_textdomain( $textdomain );
305 - load_textdomain( $textdomain, WP_LANG_DIR . "/$textdomain-" . $locale . '.mo' );
306 - }
307 - }
285 + load_plugin_textdomain( $textdomain, false, plugin_basename( dirname( $plugin_file ) ) . '/languages' );
286 + }
308 287
309 - /**
310 - * For AJAX Only
311 - * @return void
312 - */
313 - public function ajax() {
314 - }
288 + /**
289 + * For AJAX Only
290 + * @return void
291 + */
292 + public function ajax() {
293 + }
315 294
316 - /**
317 - * Create a plugin instance.
318 - *
319 - * @param mixed ...$args
320 - *
321 - * @return static
322 - *
323 - * @suppress PHP0441
324 - * @since 2.5.0
325 - */
326 - public static function get_instance() {
327 - if ( null == self::$_instance ) {
328 - self::$_instance = new self();
295 + /**
296 + * Create a plugin instance.
297 + *
298 + * @param mixed ...$args
299 + *
300 + * @return static
301 + *
302 + * @suppress PHP0441
303 + * @since 2.5.0
304 + */
305 + public static function get_instance() {
306 + if ( self::$_instance == null ) {
307 + self::$_instance = new self();
329 308
330 - do_action( 'betterdocs_loaded' );
331 - }
309 + do_action( 'betterdocs_loaded' );
310 + }
332 311
333 - return self::$_instance;
334 - }
312 + return self::$_instance;
313 + }
335 314
336 - /**
337 - * Hooked with `admin_init` action.
338 - * @return void
339 - */
340 - public function admin_init() {
341 - /**
342 - * Maybe Redirect
343 - * for setup related settings.
344 - */
345 - $this->maybe_redirect();
346 - }
315 + /**
316 + * Hooked with `admin_init` action.
317 + * @return void
318 + */
319 + public function admin_init() {
320 + /**
321 + * Maybe Redirect
322 + * for setup related settings.
323 + */
324 + $this->maybe_redirect();
325 + }
347 326
348 - /**
349 - * Summary of maybe_redirect
350 - * @return void
351 - */
352 - public function maybe_redirect() {
353 - // Bail if no activation transient is set.
354 - if ( ! $this->database->get_transient( 'betterdocs_maybe_redirect' ) ) {
355 - return;
356 - }
327 + /**
328 + * Summary of maybe_redirect
329 + * @return void
330 + */
331 + public function maybe_redirect() {
332 + // Bail if no activation transient is set.
333 + if ( ! $this->database->get_transient( 'betterdocs_maybe_redirect' ) ) {
334 + return;
335 + }
357 336
358 - // Delete the activation transient.
359 - $this->database->delete_transient( 'betterdocs_maybe_redirect' );
337 + // Delete the activation transient.
338 + $this->database->delete_transient( 'betterdocs_maybe_redirect' );
360 339
361 - if ( ! is_multisite() ) {
362 - $betterdocs_settings = get_option( 'betterdocs_settings' );
363 - if ( $betterdocs_settings ) {
364 - wp_safe_redirect( add_query_arg( array( 'page' => 'betterdocs-settings' ), admin_url( 'admin.php' ) ) );
365 - } else {
366 - wp_safe_redirect( add_query_arg( array( 'page' => 'betterdocs-setup' ), admin_url( 'admin.php' ) ) );
367 - }
368 - }
369 - }
340 + if ( ! is_multisite() ) {
341 + $betterdocs_settings = get_option( 'betterdocs_settings' );
342 + if ( $betterdocs_settings ) {
343 + wp_safe_redirect( add_query_arg( [ 'page' => 'betterdocs-settings' ], admin_url( 'admin.php' ) ) );
344 + } else {
345 + wp_safe_redirect( add_query_arg( [ 'page' => 'betterdocs-setup' ], admin_url( 'admin.php' ) ) );
346 + }
347 + }
348 + }
370 349
371 - /**
372 - * Is Pro Plugin Is Installed?
373 - * @return bool
374 - */
375 - public function is_pro_installed() {
376 - return $this->helper->get_plugins( 'betterdocs-pro/betterdocs-pro.php' );
377 - }
350 + /**
351 + * Is Pro Plugin Is Installed?
352 + * @return bool
353 + */
354 + public function is_pro_installed() {
355 + return $this->helper->get_plugins( 'betterdocs-pro/betterdocs-pro.php' );
356 + }
378 357
379 - /**
380 - * Is Pro Plugin Is Active?
381 - * @return bool
382 - */
383 - public function pro_file() {
384 - return WP_PLUGIN_DIR . '/betterdocs-pro/betterdocs-pro.php';
385 - }
358 + /**
359 + * Is Pro Plugin Is Active?
360 + * @return bool
361 + */
362 + public function pro_file() {
363 + return WP_PLUGIN_DIR . '/betterdocs-pro/betterdocs-pro.php';
364 + }
386 365
387 - public function is_pro_active() {
388 - if ( file_exists( $this->pro_file() ) ) {
389 - return $this->helper->is_plugin_active( 'betterdocs-pro/betterdocs-pro.php' );
390 - }
366 + public function is_pro_active() {
367 + if ( file_exists( $this->pro_file() ) ) {
368 + return $this->helper->is_plugin_active( 'betterdocs-pro/betterdocs-pro.php' );
369 + }
391 370
392 - return false;
393 - }
371 + return false;
372 + }
394 373
395 - public function chatbot_file() {
396 - return WP_PLUGIN_DIR . '/betterdocs-ai-chatbot/betterdocs-ai-chatbot.php';
397 - }
374 + public function chatbot_file() {
375 + return WP_PLUGIN_DIR . '/betterdocs-ai-chatbot/betterdocs-ai-chatbot.php';
376 + }
398 377
399 - public function is_chatbot_active() {
400 - if ( file_exists( $this->chatbot_file() ) ) {
401 - return $this->helper->is_plugin_active( 'betterdocs-ai-chatbot/betterdocs-ai-chatbot.php' );
402 - }
378 + public function is_chatbot_active() {
379 + if ( file_exists( $this->chatbot_file() ) ) {
380 + return $this->helper->is_plugin_active( 'betterdocs-ai-chatbot/betterdocs-ai-chatbot.php' );
381 + }
403 382
404 - return false;
405 - }
383 + return false;
384 + }
406 385
407 - public function pro_version() {
408 - if ( ! $this->is_pro_active() ) {
409 - return false;
410 - }
386 + public function pro_version() {
387 + if ( ! $this->is_pro_active() ) {
388 + return false;
389 + }
411 390
412 - if ( ! function_exists( 'get_plugin_data' ) ) {
413 - require_once ABSPATH . 'wp-admin/includes/plugin.php';
414 - }
391 + if ( ! function_exists( 'get_plugin_data' ) ) {
392 + require_once ABSPATH . 'wp-admin/includes/plugin.php';
393 + }
415 394
416 - $plugin_data = get_plugin_data( $this->pro_file() );
395 + $plugin_data = get_plugin_data( $this->pro_file() );
417 396
418 - return $plugin_data[ 'Version' ];
419 - }
397 + return $plugin_data['Version'];
398 + }
420 399
421 - /**
422 - * Get all the API initialized.
423 - * @return void
424 - */
425 - public function api_initialization() {
426 - $_api_classes = scandir( __DIR__ . DIRECTORY_SEPARATOR . 'REST' );
400 + /**
401 + * Get all the API initialized.
402 + * @return void
403 + */
404 + public function api_initialization() {
405 + $_api_classes = scandir( __DIR__ . DIRECTORY_SEPARATOR . 'REST' );
427 406
428 - if ( ! empty( $_api_classes ) && is_array( $_api_classes ) ) {
429 - foreach ( $_api_classes as $class ) {
430 - if ( '.' == $class || '..' == $class || strpos( $class, '.' ) === 0 ) {
431 - continue;
432 - }
407 + if ( ! empty( $_api_classes ) && is_array( $_api_classes ) ) {
408 + foreach ( $_api_classes as $class ) {
409 + if ( $class == '.' || $class == '..' || strpos( $class, '.' ) === 0 ) {
410 + continue;
411 + }
433 412
434 - $classname = basename( $class, '.php' );
435 - $classname = '\\' . __NAMESPACE__ . "\\REST\\$classname";
436 - $_api_class = $this->container->get( $classname );
413 + $classname = basename( $class, '.php' );
414 + $classname = '\\' . __NAMESPACE__ . "\\REST\\$classname";
415 + $_api_class = $this->container->get( $classname );
437 416
438 - if ( $_api_class instanceof BaseAPI ) {
439 - $_api_class->register();
440 - }
441 - }
442 - }
443 - }
417 + if ( $_api_class instanceof BaseAPI ) {
418 + $_api_class->register();
419 + }
420 + }
421 + }
422 + }
444 423
445 - public function is_betterdocs_screen( $hook, $admin_check = true ): bool {
446 - $screens = array(
447 - 'toplevel_page_betterdocs-dashboard',
448 - 'toplevel_page_betterdocs-admin',
449 - 'admin_page_betterdocs-admin',
450 - 'betterdocs_page_betterdocs-admin',
451 - 'betterdocs_page_betterdocs-analytics',
452 - 'betterdocs_page_betterdocs-settings',
453 - 'betterdocs_page_betterdocs-faq',
454 - 'betterdocs_page_betterdocs-glossaries',
455 - 'betterdocs_page_betterdocs-ai-chatbot'
456 - );
424 + public function is_betterdocs_screen( $hook, $admin_check = true ): bool {
425 + $screens = [
426 + 'toplevel_page_betterdocs-dashboard',
427 + 'toplevel_page_betterdocs-admin',
428 + 'admin_page_betterdocs-admin',
429 + 'betterdocs_page_betterdocs-admin',
430 + 'betterdocs_page_betterdocs-analytics',
431 + 'betterdocs_page_betterdocs-settings',
432 + 'betterdocs_page_betterdocs-faq',
433 + 'betterdocs_page_betterdocs-glossaries',
434 + 'betterdocs_page_betterdocs-ai-chatbot',
435 + ];
457 436
458 - if ( $admin_check ) {
459 - if ( in_array( $hook, $screens ) ) {
460 - return true;
461 - }
437 + if ( $admin_check ) {
438 + if ( in_array( $hook, $screens ) ) {
439 + return true;
440 + }
462 441
463 - return false;
464 - }
442 + return false;
443 + }
465 444
466 - return false;
467 - }
445 + return false;
446 + }
468 447
469 - public function get_betterdocs_screen() {
470 - $registered_screens = array(
471 - 'toplevel_page_betterdocs-dashboard',
472 - 'admin_page_betterdocs-admin',
473 - 'betterdocs_page_betterdocs-admin',
474 - 'betterdocs_page_betterdocs-settings',
475 - 'betterdocs_page_betterdocs-analytics',
476 - 'betterdocs_page_betterdocs-faq',
477 - 'betterdocs_page_betterdocs-glossaries',
448 + public function get_betterdocs_screen() {
449 + $registered_screens = [
450 + 'toplevel_page_betterdocs-dashboard',
451 + 'admin_page_betterdocs-admin',
452 + 'betterdocs_page_betterdocs-admin',
453 + 'betterdocs_page_betterdocs-settings',
454 + 'betterdocs_page_betterdocs-analytics',
455 + 'betterdocs_page_betterdocs-faq',
456 + 'betterdocs_page_betterdocs-glossaries',
478 457 'betterdocs_page_betterdocs-ai-chatbot',
479 - 'edit-docs'
480 - );
458 + 'edit-docs',
459 + ];
481 460
482 - $current_screen_id = get_current_screen() != null ? get_current_screen()->id : '';
461 + $current_screen_id = get_current_screen() != null ? get_current_screen()->id : '';
483 462
484 - if ( in_array( $current_screen_id, $registered_screens ) ) {
485 - return $current_screen_id;
486 - }
463 + if ( in_array( $current_screen_id, $registered_screens ) ) {
464 + return $current_screen_id;
465 + }
487 466
488 - return false;
489 - }
467 + return false;
468 + }
490 469 }