PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 3.3.4
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v3.3.4
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
betterdocs / includes / Core / Admin.php

Admin.php in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 3.3.4, at includes/Core/Admin.php

629 lines 22.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPDeveloper\BetterDocs\Core;
4
5 use Exception;
6 use PriyoMukul\WPNotice\Notices;
7 use PriyoMukul\WPNotice\Utils\CacheBank;
8 use PriyoMukul\WPNotice\Utils\NoticeRemover;
9 use WPDeveloper\BetterDocs\Admin\Analytics;
10 use WPDeveloper\BetterDocs\Dependencies\DI\Container;
11 use WPDeveloper\BetterDocs\Utils\Base;
12 use WPDeveloper\BetterDocs\Utils\Enqueue;
13 use WPDeveloper\BetterDocs\Utils\Helper;
14 use WPDeveloper\BetterDocs\Utils\Insights;
15 use WPDeveloper\BetterDocs\Core\KBMigration;
16
17 class Admin extends Base {
18 /**
19 * @var CacheBank
20 */
21 private static $cache_bank;
22 /**
23 * Admin Root Menu Slug
24 * @var string
25 */
26 private $slug = 'betterdocs-admin';
27 /**
28 * Insights
29 *
30 * @var Insights
31 */
32 private $insights = null;
33
34 /**
35 * DI\Container
36 *
37 * @var Container
38 */
39 private $container;
40
41 /**
42 * Database Wrapper
43 *
44 * @var Settings
45 */
46 private $settings;
47
48 /**
49 * Enqueue
50 * @var Enqueue
51 */
52 private $assets;
53
54 /**
55 * FAQBuilder
56 * @var FAQBuilder
57 */
58 private $faq_builder;
59
60 public function __construct( Container $container, PostType $type, Enqueue $assets, Settings $settings ) {
61 $this->container = $container;
62 $this->assets = $assets;
63 $this->settings = $settings;
64 $this->slug = 'betterdocs-admin';
65
66 add_action( 'init', [ $type, 'register' ], 9 );
67
68 $type->init();
69 $type->admin_init();
70
71 $this->faq_builder = $this->container->get( FAQBuilder::class );
72
73 if ( ! is_admin() ) {
74 return;
75 }
76
77 $this->plugin_insights();
78 add_action( 'admin_notices', [$this, 'compatibility_notices'] );
79 // add_action( 'admin_init', [$this, 'notices'], 9 );
80 add_filter( 'admin_init', [$this, 'save_admin_page'], 99 );
81
82 add_action( 'admin_menu', [$this, 'menus'] );
83 add_action( 'admin_menu', [$this, 'reset_submenu'] );
84 add_filter( 'plugin_action_links_' . BETTERDOCS_PLUGIN_BASENAME, [$this, 'insert_plugin_links'] );
85
86 // $this->container->get( SetupWizard::class )->init();
87
88 add_action( 'admin_enqueue_scripts', [ $this, 'styles' ] );
89 add_action( 'admin_enqueue_scripts', [ $this, 'scripts' ] );
90 add_action( 'betterdocs_listing_header', [ $this, 'header' ], 10, 1 );
91 add_action( 'admin_bar_menu', [ $this, 'toolbar_menu' ], 32 );
92
93 add_filter( 'admin_body_class', [ $this, 'body_classes' ] );
94 add_filter( 'parent_file', [ $type, 'highlight_admin_menu' ] );
95 add_filter( 'submenu_file', [ $type, 'highlight_admin_submenu' ], 10, 2 );
96 add_filter( 'betterdocs_admin_menu', [ $this, 'quick_setup_menu' ], 10, 1 );
97
98 /**
99 * Remove Comments Column from List Table.
100 */
101 add_filter( 'manage_docs_posts_columns', [ $this, 'set_custom_edit_action_columns' ] );
102 add_filter( 'manage_docs_posts_custom_column', [ $this, 'manage_custom_columns' ], 10, 2 );
103
104 self::$cache_bank = CacheBank::get_instance();
105 try {
106 $this->notices();
107 } catch ( Exception $e ) {
108 unset( $e );
109 }
110 // Remove OLD notice from 1.0.0 (if other WPDeveloper plugin has notice)
111 NoticeRemover::get_instance( '1.0.0' );
112 }
113
114 public function compatibility_notices() {
115 if ( betterdocs()->is_pro_active() ) {
116 $plugins = Helper::get_plugins();
117 $plugin_data = $plugins['betterdocs-pro/betterdocs-pro.php'];
118
119 if ( isset( $plugin_data['Version'] ) && version_compare( $plugin_data['Version'], '2.5.0', '>=' ) ) {
120 return;
121 }
122
123 betterdocs()->views->get( 'admin/notices/compatibility', [ 'version' => $plugin_data['Version'] ] );
124 }
125 }
126
127 public function plugin_insights( $prevent_init = false ) {
128 $this->insights = Insights::get_instance( BETTERDOCS_PLUGIN_FILE, [
129 'opt_in' => true,
130 'goodbye_form' => true,
131 'item_id' => 'c7b16777b4f1b83f6083'
132 ] );
133
134 $this->insights->set_notice_options( [
135 'notice' => __( 'Want to help make <strong>BetterDocs</strong> even more awesome? You can get a <strong>10% discount coupon</strong> for Premium extensions if you allow us to track the usage.', 'betterdocs' ),
136 'extra_notice' => __( 'We collect non-sensitive diagnostic data and plugin usage information. Your site URL, WordPress & PHP version, plugins & themes and email address to send you the discount coupon. This data lets us make sure this plugin always stays compatible with the most popular plugins and themes. No spam, I promise.', 'betterdocs' )
137 ] );
138
139 if ( ! $prevent_init ) {
140 $this->insights->init();
141 }
142
143 return $this->insights;
144 }
145
146 /**
147 * Admin notices for Review and others.
148 *
149 * @return void
150 * @throws Exception
151 */
152 public function notices() {
153 $notices = new Notices( [
154 'id' => 'betterdocs',
155 'storage_key' => 'notices',
156 'lifetime' => 3,
157 'stylesheet_url' => $this->assets->asset_url( 'admin/css/notices.css' ),
158 'styles' => $this->assets->asset_url( 'admin/css/notices.css' ),
159 'priority' => 4
160 ] );
161
162 /**
163 * Review Notice
164 * @var mixed $message
165 */
166
167 $message = __( 'We hope you\'re enjoying BetterDocs! Could you please do us a BIG favor and give it a 5-star rating on WordPress to help us spread the word and boost our motivation?', 'betterdocs' );
168
169 $_review_notice = [
170 'thumbnail' => $this->assets->icon( 'betterdocs-logo.svg', true ),
171 'html' => '<p>' . $message . '</p>',
172 'links' => [
173 'later' => [
174 'link' => 'https://wordpress.org/plugins/betterdocs/#reviews',
175 'target' => '_blank',
176 'label' => __( 'Sure, you deserve it!', 'betterdocs' ),
177 'icon_class' => 'dashicons dashicons-external'
178 ],
179 'allready' => [
180 'label' => __( 'I already did', 'betterdocs' ),
181 'icon_class' => 'dashicons dashicons-smiley',
182 'attributes' => [
183 'data-dismiss' => true
184 ]
185 ],
186 'maybe_later' => [
187 'label' => __( 'Maybe Later', 'betterdocs' ),
188 'icon_class' => 'dashicons dashicons-calendar-alt',
189 'attributes' => [
190 'data-later' => true,
191 'class' => 'dismiss-btn'
192 ]
193 ],
194 'support' => [
195 'link' => 'https://wpdeveloper.com/support',
196 'attributes' => [
197 'target' => '_blank'
198 ],
199 'label' => __( 'I need help', 'betterdocs' ),
200 'icon_class' => 'dashicons dashicons-sos'
201 ],
202 'never_show_again' => [
203 'label' => __( 'Never show again', 'betterdocs' ),
204 'icon_class' => 'dashicons dashicons-dismiss',
205 'attributes' => [
206 'data-dismiss' => true
207 ]
208 ]
209 ]
210 ];
211
212 $notices->add( 'review', $_review_notice, [
213 'start' => $notices->strtotime( '+10 days' ),
214 'recurrence' => 30,
215 'dismissible' => true
216 // 'screens' => [
217 // 'dashboard', 'plugins', 'themes', 'edit-page',
218 // 'edit-post', 'users', 'tools', 'options-general',
219 // 'nav-menus', 'toplevel_page_betterdocs-admin', 'betterdocs_page_betterdocs-settings', 'betterdocs_page_betterdocs-analytics', 'betterdocs_page_betterdocs-faq', 'edit-doc_tag', 'edit-doc_category'
220 // ]
221 ] );
222
223 /**
224 * Opt-In Notice
225 */
226 if ( $this->insights != null ) {
227 $notices->add( 'opt_in', [ $this->insights, 'notice' ], [
228 'classes' => 'updated put-dismiss-notice',
229 'start' => $notices->strtotime( '+20 days' ),
230 'dismissible' => true,
231 'do_action' => 'wpdeveloper_notice_clicked_for_betterdocs',
232 'display_if' => ! function_exists( 'betterdocs_pro' )
233 ] );
234 }
235
236 $b_message = '<p style="margin-top: 0; margin-bottom: 10px;">Black Friday Sale: Enjoy 40% off & unlock <strong>premium features to streamline customer support</strong> & knowledge base 🎁</p><a class="button button-primary" href="https://wpdeveloper.com/upgrade/betterdocs-bfcm" target="_blank">Upgrade to pro</a> <button data-dismiss="true" class="dismiss-btn button button-link">I don’t want to save money</button>';
237 $_black_friday_notice = [
238 'thumbnail' => $this->assets->icon( 'betterdocs-logo.svg', true ),
239 'html' => $b_message,
240 ];
241
242 $notices->add( 'black_friday_notice', $_black_friday_notice, [
243 'start' => $notices->time(),
244 'recurrence' => false,
245 'dismissible' => true,
246 'refresh' => BETTERDOCS_VERSION,
247 "expire" => strtotime( '11:59:59pm 2nd December, 2023' ),
248 'display_if' => ! is_plugin_active( 'betterdocs-pro/betterdocs-pro.php' )
249 ] );
250
251 self::$cache_bank->create_account( $notices );
252 self::$cache_bank->calculate_deposits( $notices );
253 }
254
255 public function body_classes( $classes ) {
256 $saved_settings = get_option( 'betterdocs_settings', false );
257 $dark_mode = isset( $saved_settings['dark_mode'] ) ? $saved_settings['dark_mode'] : false;
258 $dark_mode = ! empty( $dark_mode ) ? boolval( $dark_mode ) : false;
259
260 if ( $dark_mode === true ) {
261 $classes .= ' betterdocs-dark-mode ';
262 }
263
264 return $classes;
265 }
266
267 /**
268 * Remove Comments Column From List Table
269 *
270 * @param array $columns
271 *
272 * @return array
273 * @since 1.0.0
274 */
275 public function set_custom_edit_action_columns( $columns ) {
276 unset( $columns['comments'] );
277 $new_columns = [];
278 foreach ( $columns as $key => $value ) {
279 if ( $key == 'date' ) {
280 $new_columns['betterdocs_word_count'] = __( 'Word Count', 'betterdocs' ); // put the tags column before it
281 }
282 $new_columns[ $key ] = $value;
283 }
284
285 return $new_columns;
286 }
287
288 public function manage_custom_columns( $column, $post_id ) {
289 switch ( $column ) {
290 case 'betterdocs_word_count':
291 $word_count = str_word_count( trim( strip_tags( get_post_field( 'post_content', $post_id ) ) ) );
292 echo '<span>' . $word_count . '</span>';
293 break;
294 }
295 }
296
297 /**
298 * Enqueue Assets for Admin ( Styles )
299 *
300 * @param string $hook
301 *
302 * @return void
303 * @since 1.0.0
304 */
305 public function styles( $hook ) {
306 $this->assets->enqueue( 'betterdocs-global', 'admin/css/global.css', [], 'all' );
307
308 if ( ! in_array( $hook, [
309 'toplevel_page_betterdocs-admin',
310 'betterdocs_page_betterdocs-settings',
311 'betterdocs_page_betterdocs-analytics'
312 ] ) ) {
313 return;
314 }
315
316 $this->assets->enqueue( 'betterdocs-select2', 'vendor/css/select2.min.css', [], 'all' );
317 $this->assets->enqueue( 'betterdocs-daterangepicker', 'vendor/css/daterangepicker.css', [], 'all' );
318 $this->assets->enqueue( 'betterdocs', 'admin/css/betterdocs.css', [], 'all' );
319 }
320
321 /**
322 * Enqueue Assets for Admin ( Scripts )
323 *
324 * @param string $hook
325 *
326 * @return void
327 * @since 1.0.0
328 */
329 public function scripts( $hook ) {
330 $this->assets->register( 'betterdocs-admin', 'admin/js/betterdocs.js', [ 'jquery', 'jquery-ui-sortable' ] );
331
332 $saved_settings = get_option( 'betterdocs_settings', false );
333 $dark_mode = isset( $saved_settings['dark_mode'] ) ? $saved_settings['dark_mode'] : false;
334 $dark_mode = ! empty( $dark_mode ) ? boolval( $dark_mode ) : false;
335 $this->assets->localize( 'betterdocs-admin', 'betterdocs_admin', [
336 'ajaxurl' => admin_url( 'admin-ajax.php' ),
337 'doc_cat_order_nonce' => wp_create_nonce( 'doc_cat_order_nonce' ),
338 'knowledge_base_order_nonce' => wp_create_nonce( 'knowledge_base_order_nonce' ),
339 'paged' => isset( $_GET['paged'] ) ? absint( wp_unslash( $_GET['paged'] ) ) : 0,
340 'per_page_id' => "edit_doc_category_per_page",
341 'menu_title' => __( 'Switch to BetterDocs UI', 'betterdocs' ),
342 'dark_mode' => ! empty( $dark_mode ) ? boolval( $dark_mode ) : false,
343 'text' => __( 'Copied!', 'betterdocs' ),
344 'test_report' => __( 'Test Report!', 'betterdocs' ),
345 'sending' => __( 'Sending...', 'betterdocs' )
346 ] );
347
348 if ( ( $hook === 'edit.php' || $hook === 'toplevel_page_betterdocs-admin' ) && get_post_type() == 'docs' ) {
349 $this->assets->enqueue( 'betterdocs-switcher', 'admin/js/switcher.js', [
350 'jquery'
351 ] );
352
353 $this->assets->localize( 'betterdocs-switcher', 'betterdocsSwitcher', [
354 'menu_title' => __( 'Switch to BetterDocs UI', 'betterdocs' ),
355 'site_address' => get_bloginfo( 'url' ),
356 'betterdocs_pro_plugin' => betterdocs()->is_pro_active()
357 ] );
358 }
359
360 if ( ! in_array( $hook, [ 'toplevel_page_betterdocs-admin', 'betterdocs_page_betterdocs-analytics' ] ) ) {
361 return;
362 }
363
364 wp_enqueue_script( 'wp-color-picker' );
365
366 $this->assets->enqueue( 'betterdocs-select2', 'vendor/js/select2.min.js', [] );
367 $this->assets->enqueue( 'betterdocs-sweetalert', 'vendor/js/sweetalert.min.js', [] );
368 $this->assets->enqueue( 'moment', 'vendor/js/moment.min.js', [] );
369 $this->assets->enqueue( 'betterdocs-daterangepicker', 'vendor/js/daterangepicker.min.js', [] );
370 wp_enqueue_script( 'betterdocs-admin' );
371 }
372
373 /**
374 * All admin pages header
375 *
376 * @return void
377 * @since 1.0.0
378 */
379 public function header( $admin_tab_name ) {
380 $quick_links = [
381 'switch_view' => sprintf( '<a href="%s" class="betterdocs-button betterdocs-button-secondary">%s</a>', add_query_arg( [
382 'post_type' => 'docs',
383 'bdocs_view' => 'classic'
384 ], 'edit.php' ), __( 'Switch to Classic UI', 'betterdocs' ) ),
385 'add_new_doc' => sprintf( '<a href="%s" class="betterdocs-button betterdocs-button-primary">%s</a>', add_query_arg( [ 'post_type' => 'docs' ], 'post-new.php' ), __( 'Add New Doc', 'betterdocs' ) )
386 ];
387
388 $quick_links = apply_filters( 'betterdocs_quick_links', $quick_links );
389
390 betterdocs()->views->get( 'admin/header', [
391 'quick_links' => $quick_links,
392 'active_tab' => $admin_tab_name
393 ] );
394 }
395
396 /**
397 * Register all the menus for BetterDocs
398 *
399 * @return void
400 * @since 1.0.0
401 */
402 // public function menus() {
403 // add_menu_page(
404 // 'BetterDocs',
405 // 'BetterDocs',
406 // 'edit_posts',
407 // $this->slug,
408 // [$this, 'output'],
409 // betterdocs()->assets->icon( 'betterdocs-icon-white.svg', true ),
410 // 5 // Position on the menu (use a unique number)
411 // );
412 // }
413
414 public function menus() {
415 $default_args = [
416 'page_title' => 'BetterDocs',
417 'menu_title' => 'BetterDocs',
418 'capability' => 'edit_posts',
419 'menu_slug' => $this->slug,
420 'callback' => [ $this, 'output' ],
421 'icon_url' => betterdocs()->assets->icon( 'betterdocs-icon-white.svg', true ),
422 'position' => 5
423 ];
424
425 $_menu_position = 5;
426
427 foreach ( $this->menu_list() as $key => $value ) {
428 if ( $key === 'betterdocs' ) {
429 $callable = 'add_menu_page';
430 $value = wp_parse_args( $value, $default_args );
431 } else {
432 $callable = 'add_submenu_page';
433 $default_args['callback'] = '';
434 $default_args['position'] = $_menu_position;
435 unset( $default_args['icon_url'] );
436 $value = wp_parse_args( $value, array_merge( [ 'parent_slug' => $this->slug ], $default_args ) );
437 }
438
439 $_menu_position++;
440
441 call_user_func_array( $callable, $value );
442 }
443 }
444
445 /**
446 * BetterDocs Admin Page Output
447 *
448 * @return void
449 * @since 1.0.0
450 */
451 public function output() {
452 betterdocs()->views->get( 'admin/main', [
453 'admin_ui' => 'dnd'
454 ] );
455 }
456
457 /**
458 * Menu creator helper
459 *
460 * @param string $title
461 * @param string $slug
462 * @param string $cap
463 * @param array $callback
464 *
465 * @return array
466 * @since 2.5.0
467 *
468 */
469 private function normalize_menu( $title, $slug, $cap = 'edit_docs', $callback = null ) {
470 return Helper::normalize_menu( $title, $slug, $cap, $callback );
471 }
472
473 /**
474 * BetterDocs Menu List
475 *
476 * @return array
477 * @since 1.0.0
478 */
479 private function menu_list() {
480 $betterdocs_admin_pages = [
481 'betterdocs' => [
482 'menu_slug' => $this->slug,
483 'page_title' => 'BetterDocs',
484 'menu_title' => 'BetterDocs',
485 'capability' => 'edit_docs',
486 'callback' => [ $this, 'output' ],
487 'icon_url' => betterdocs()->assets->icon( 'betterdocs-icon-white.svg', true ),
488 'position' => 5
489 ],
490 'all_docs' => $this->normalize_menu( __( 'All Docs', 'betterdocs' ), $this->ui_slug() ),
491 'add_new' => $this->normalize_menu( __( 'Add New', 'betterdocs' ), 'post-new.php?post_type=docs' ),
492 'categories' => $this->normalize_menu(
493 __( 'Categories', 'betterdocs' ),
494 'edit-tags.php?taxonomy=doc_category&post_type=docs',
495 'manage_doc_terms'
496 ),
497 'tags' => $this->normalize_menu(
498 __( 'Tags', 'betterdocs' ),
499 'edit-tags.php?taxonomy=doc_tag&post_type=docs',
500 'manage_doc_terms'
501 ),
502 'settings' => $this->normalize_menu(
503 __( 'Settings', 'betterdocs' ),
504 'betterdocs-settings',
505 'edit_docs_settings',
506 [$this->container->get( Settings::class ), 'views']
507 ),
508 'analytics' => $this->normalize_menu(
509 __( 'Analytics', 'betterdocs' ),
510 'betterdocs-analytics',
511 'read_docs_analytics',
512 [$this->container->get( Analytics::class ), 'views']
513 ),
514 'faq' => $this->normalize_menu(
515 __( 'FAQ Builder', 'betterdocs' ),
516 'betterdocs-faq',
517 'read_docs_analytics',
518 [$this->faq_builder, 'output']
519 )
520 ];
521
522 return apply_filters( 'betterdocs_admin_menu', $betterdocs_admin_pages );
523 }
524
525 public function quick_setup_menu( $menus ) {
526 $betterdocs_settings = get_option( 'betterdocs_settings' );
527 if ( $betterdocs_settings ) {
528 return $menus;
529 } else {
530 $menus['quick_setup'] = $this->normalize_menu( __( 'Quick Setup', 'betterdocs' ), 'betterdocs-setup', 'delete_users', [
531 $this->container->get( SetupWizard::class ),
532 'views'
533 ] );
534 }
535
536 return $menus;
537 }
538
539 public function insert_plugin_links( $links ) {
540 $links[] = '<a href="admin.php?page=betterdocs-settings">' . __( 'Settings', 'betterdocs' ) . '</a>';
541
542 return $links;
543 }
544
545 public function toolbar_menu( $admin_bar ) {
546 if ( ! is_admin() || ! is_admin_bar_showing() ) {
547 return;
548 }
549
550 // Show only when the user is a member of this site, or they're a super admin.
551 if ( ! is_user_member_of_blog() && ! is_super_admin() ) {
552 return;
553 }
554
555 $docs_url = '';
556
557 if ( $this->settings->get( 'builtin_doc_page' ) ) {
558 $docs_url = get_post_type_archive_link( 'docs' );
559 } elseif ( intval( $docs_page = $this->settings->get( 'docs_page' ) ) ) {
560 $docs_url = ! empty( $docs_page ) ? get_page_link( $docs_page ) : false;
561 }
562
563 if ( ! $docs_url ) {
564 return;
565 }
566
567 $admin_bar->add_node( [
568 'parent' => 'site-name',
569 'id' => 'view-docs',
570 'title' => __( 'Visit Documentation', 'betterdocs' ),
571 'href' => $docs_url
572 ] );
573 }
574 /**
575 * Save last visited admin ui
576 *
577 * @since 3.0.1
578 *
579 */
580 public function save_admin_page() {
581 if (isset($_GET['post_type']) && $_GET['post_type'] === 'docs' && isset($_GET['bdocs_view']) && $_GET['bdocs_view'] === 'classic') {
582 update_user_meta( get_current_user_id(), 'last_visited_docs_admin_page', 'classic_ui' );
583 } elseif (isset($_GET['page']) && $_GET['page'] === 'betterdocs-admin') {
584 update_user_meta( get_current_user_id(), 'last_visited_docs_admin_page', 'modern_ui' );
585 }
586 }
587
588 /**
589 * Return last visited admin ui slug
590 *
591 * @since 3.0.1
592 * @return string
593 */
594 public function ui_slug() {
595 $last_visited = get_user_meta( get_current_user_id(), 'last_visited_docs_admin_page', true);
596 $docs = get_posts( ['post_type' => 'docs', 'post_status' => 'any', 'numberposts' => -1] );
597
598 if ($last_visited === 'modern_ui' || count($docs) == 0 ) {
599 $slug = 'betterdocs-admin';
600 } else {
601 $slug = admin_url('edit.php?post_type=docs&bdocs_view=classic');
602 }
603
604 return $slug;
605 }
606
607 /**
608 * Resets a duplicate submenu in WordPress if the parent main menu and the first submenu permalink are not the same.
609 *
610 * @since 3.0.1
611 * @return string
612 */
613 public function reset_submenu() {
614 global $submenu;
615
616 $docs = get_posts( ['post_type' => 'docs'] );
617 if ( count($docs) == 0 ) {
618 return;
619 }
620
621 $last_visited = get_user_meta( get_current_user_id(), 'last_visited_docs_admin_page', true);
622
623 if ( $last_visited === 'classic_ui' && in_array( "betterdocs-admin", $submenu['betterdocs-admin'][0] ) ) {
624 unset($submenu['betterdocs-admin'][0]);
625 $submenu['betterdocs-admin'] = array_values($submenu['betterdocs-admin']);
626 }
627 }
628 }
629