PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.2.6
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.2.6
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/Core/Admin.php +110 -32 4.4.14.2.6 View file →
@@ -3,8 +3,9 @@
3 3 namespace WPDeveloper\BetterDocs\Core;
4 4
5 5 use Exception;
6 6 use PriyoMukul\WPNotice\Notices;
7 +use WPDeveloper\BetterDocs\Admin\NoticePointers;
7 8 use WPDeveloper\BetterDocs\Utils\Base;
8 9 use PriyoMukul\WPNotice\Utils\CacheBank;
9 10 use WPDeveloper\BetterDocs\Utils\Helper;
10 11 use WPDeveloper\BetterDocs\Utils\Enqueue;
@@ -126,10 +127,9 @@
126 127 add_action( 'admin_footer-plugins.php', array( $this, 'disable_deactivation' ) );
127 128 }
128 129
129 130 if ( $this->settings->get( 'enable_estimated_reading_time' ) ) {
130 - // Hook into unified metabox instead of creating separate metabox
131 - add_action( 'betterdocs_reading_time_tab_content', [ $this, 'render_estimated_time_markup' ] );
131 + add_action( 'add_meta_boxes', [ $this, 'reading_meta_box_' ], 10 );
132 132 }
133 133
134 134 self::$cache_bank = CacheBank::get_instance();
135 135
@@ -140,8 +140,14 @@
140 140 $this->notices();
141 141 } catch ( Exception $e ) {
142 142 unset( $e );
143 143 }
144 +
145 + // Initialize Black Friday Pointer
146 + $this->init_black_friday_pointer();
147 +
148 + // Register AJAX handler for pointer dismissal
149 + add_action( 'wp_ajax_betterdocs_dismiss_black_friday_pointer', [ $this, 'ajax_dismiss_black_friday_pointer' ] );
144 150 }
145 151
146 152 public function order_terms_in_wp_terms_admin_table() {
147 153 //order the terms correctly to be shown on the admin panel categories menu with betterdocs order
@@ -212,8 +218,20 @@
212 218 }
213 219 return $output;
214 220 }
215 221
222 + public function reading_meta_box_() {
223 + add_meta_box(
224 + 'betterdocs_estimated_time_metabox',
225 + __( 'Estimated Reading Time', 'betterdocs' ),
226 + [
227 + $this,
228 + 'render_estimated_time_markup'
229 + ],
230 + 'docs'
231 + );
232 + }
233 +
216 234 public function render_estimated_time_markup() {
217 235 betterdocs()->views->get( 'admin/metabox/estimated-reading-box' );
218 236 }
219 237
@@ -400,45 +418,67 @@
400 418 ]
401 419 );
402 420 }
403 421
404 - $spring_campaign_message = '<div class="betterdocs-spring-notice-body"><p style="margin-top: 0; margin-bottom: 0;">🌸 <strong>Spring Savings:</strong> Build AI-powered Knowledge Bases & FAQs to empower support and improve user experience – now <strong>Flat 25% OFF!</strong> ⚡️</p></div>';
405 - $_spring_campaign_notice = [
422 + $blackfriday_message = '<div class="betterdocs-blackfriday-notice-body"><p style="margin-top: 0; margin-bottom: 0;"><strong>Black Friday Mega Sale:</strong> Build <strong>AI-Powered Knowledge Base</strong> & FAQs to empower support and improve user experience – now <strong>up to $120 OFF!</strong> 🎁</p></div>';
423 + $_blackfriday_notice = [
406 424 'thumbnail' => $this->assets->icon( 'betterdocs-logo.svg', true ),
407 - 'html' => $spring_campaign_message,
425 + 'html' => $blackfriday_message,
408 426 'links' => [
409 - 'support' => [
410 - 'link' => 'https://betterdocs.co/spring2026-admin-notice',
427 + 'support' => [
428 + 'link' => 'https://betterdocs.co/bfcm2025-admin-notice',
411 429 'attributes' => [
412 430 'target' => '_blank',
413 - 'class' => 'offer-button',
431 + 'class' => 'offer-button'
414 432 ],
415 - 'label' => __( 'Upgrade To PRO Now', 'betterdocs' ),
433 + 'label' => __( 'Upgrade To PRO', 'betterdocs' )
416 434 ],
417 - 'maybe_later' => [
418 - 'label' => __( 'I\'ll Grab It Later', 'betterdocs' ),
435 + 'maybe_later' => [
436 + 'label' => __( 'I’ll Grab It Later', 'betterdocs' ),
419 437 'attributes' => [
420 - 'target' => '_blank',
438 + 'target' => '_blank',
421 439 'data-later' => true,
422 - 'class' => 'dismiss-btn',
423 - ],
440 + 'class' => 'dismiss-btn'
441 + ]
424 442 ],
425 - ],
443 + ]
426 444 ];
427 445
428 446 $notices->add(
429 - 'spring-campaign-26',
430 - $_spring_campaign_notice,
447 + 'blackfriday25',
448 + $_blackfriday_notice,
431 449 [
432 450 'start' => $notices->time(),
433 451 'recurrence' => false,
434 452 'dismissible' => true,
435 453 'refresh' => BETTERDOCS_VERSION,
436 - 'expire' => strtotime( '11:59:59pm May 31, 2026' ),
437 - 'display_if' => ! is_plugin_active( 'betterdocs-pro/betterdocs-pro.php' ),
454 + 'expire' => strtotime( '11:59:59pm December 4, 2025' ),
455 + 'display_if' => ! is_plugin_active( 'betterdocs-pro/betterdocs-pro.php' )
438 456 ]
439 457 );
440 458
459 + $offer_message = '<div class="betterdocs-notice-body betterdocs-holiday-notice-body"><p style="margin-top: 0; margin-bottom: 0;"><strong>🎉 BetterDocs Just Hit 40,000+ Users!</strong> Join the celebration with 20% OFF & unlock even more power with premium features today!</p><div class="betterdocs-notice-actions"><a class="button button-primary" href="https://betterdocs.co/40K-admin-notice" target="_blank"><svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
460 + <path d="M15.7431 10.9381L15.904 9.35966C15.9898 8.5175 16.0464 7.9614 16.002 7.61102L16.0175 7.61112C16.7442 7.61112 17.3333 6.98929 17.3333 6.22223C17.3333 5.45517 16.7442 4.83334 16.0175 4.83334C15.2908 4.83334 14.7017 5.45517 14.7017 6.22223C14.7017 6.56914 14.8222 6.88634 15.0214 7.12975C14.7354 7.31608 14.3615 7.70926 13.7987 8.30106L13.7986 8.30107L13.7986 8.30108C13.365 8.75699 13.1482 8.98495 12.9064 9.02025C12.7724 9.03981 12.6358 9.01971 12.5121 8.96219C12.2887 8.85838 12.1398 8.57656 11.842 8.01293L10.2723 5.04204C10.0886 4.69433 9.9348 4.40331 9.79616 4.16913C10.3649 3.86285 10.7543 3.23869 10.7543 2.51852C10.7543 1.49577 9.96888 0.666672 8.99996 0.666672C8.03104 0.666672 7.24557 1.49577 7.24557 2.51852C7.24557 3.23869 7.63503 3.86285 8.20376 4.16913C8.06511 4.40333 7.91137 4.6943 7.72763 5.04204L6.1579 8.01293C5.8601 8.57656 5.71119 8.85838 5.48786 8.96219C5.36411 9.01971 5.22757 9.03981 5.09355 9.02025C4.85169 8.98495 4.63488 8.75699 4.20127 8.30107C3.63844 7.70928 3.26449 7.31608 2.97849 7.12975C3.17771 6.88634 3.29821 6.56914 3.29821 6.22223C3.29821 5.45517 2.70911 4.83334 1.98242 4.83334C1.25572 4.83334 0.666626 5.45517 0.666626 6.22223C0.666626 6.98929 1.25572 7.61112 1.98242 7.61112L1.99795 7.61102C1.95348 7.96139 2.01015 8.51749 2.09596 9.35965L2.2568 10.938C2.34608 11.8142 2.42032 12.6478 2.51125 13.3982H15.4887C15.5796 12.6478 15.6538 11.8142 15.7431 10.9381Z" fill="white"/>
461 + <path d="M8.04563 17.3333H9.95429C12.4419 17.3333 13.6858 17.3333 14.5157 16.5492C14.8779 16.207 15.1073 15.59 15.2728 14.787H2.72711C2.89263 15.59 3.12201 16.207 3.48424 16.5492C4.31414 17.3333 5.55797 17.3333 8.04563 17.3333Z" fill="white"/>
462 + </svg>Upgrade To PRO</a></div></div>';
463 + $_offer_notice = [
464 + 'thumbnail' => $this->assets->icon( 'betterdocs-logo.svg', true ),
465 + 'html' => $offer_message
466 + ];
467 +
468 + $notices->add(
469 + '40k_offer',
470 + $_offer_notice,
471 + [
472 + 'start' => $notices->time(),
473 + 'recurrence' => false,
474 + 'dismissible' => true,
475 + 'refresh' => BETTERDOCS_VERSION,
476 + 'expire' => strtotime( '11:59:59pm April 30, 2025' ),
477 + 'display_if' => ! is_plugin_active( 'betterdocs-pro/betterdocs-pro.php' )
478 + ]
479 + );
480 +
441 481 self::$cache_bank->create_account( $notices );
442 482 self::$cache_bank->calculate_deposits( $notices );
443 483 if ( method_exists( self::$cache_bank, 'clear_notices_in_' ) ) {
444 484 self::$cache_bank->clear_notices_in_(
@@ -683,16 +723,9 @@
683 723 'betterdocs_pro_version' => betterdocs()->pro_version(),
684 724 'analytics_older' => version_compare( betterdocs()->pro_version(), '3.3.4', '<=' ),
685 725 'disabled_embed_model_option' => get_option('disabled_embed_model_option'),
686 726 'betterdocs_ChatBot_plugin' => is_plugin_active( 'betterdocs-ai-chatbot/betterdocs-ai-chatbot.php' ),
687 - 'total_doc_category_terms' => wp_count_terms( 'doc_category'),
688 - 'github_oauth_nonce' => wp_create_nonce( 'betterdocs_github_oauth_nonce' ),
689 - 'git_settings' => [
690 - 'git_repository_url' => betterdocs()->settings->get_raw_field( 'git_repository_url', '' ),
691 - 'git_branch' => betterdocs()->settings->get_raw_field( 'git_branch', '' ),
692 - 'git_docs_directory' => betterdocs()->settings->get_raw_field( 'git_docs_directory', '' ),
693 - 'git_provider' => betterdocs()->settings->get_raw_field( 'git_provider', 'github' ),
694 - ],
727 + 'total_doc_category_terms' => wp_count_terms( 'doc_category')
695 728 ]
696 729 );
697 730
698 731 // If wp-date (which includes moment.js) is not registered, enqueue your custom moment.js
@@ -1062,8 +1095,12 @@
1062 1095
1063 1096 public function insert_plugin_links( $links ) {
1064 1097 $links[] = '<a href="admin.php?page=betterdocs-settings">' . __( 'Settings', 'betterdocs' ) . '</a>';
1065 1098
1099 + if (! is_plugin_active( 'betterdocs-pro/betterdocs-pro.php' ) ) {
1100 + $links[] = '<a href="https://betterdocs.co/bfcm-2025-plugins-wp" target="_blank" style="color: #000; font-weight: bold;">' . __( 'Save 40% Today', 'betterdocs' ) . '</a>';
1101 + }
1102 +
1066 1103 return $links;
1067 1104 }
1068 1105
1069 1106 public function toolbar_menu( $admin_bar ) {
@@ -1090,13 +1127,8 @@
1090 1127 }
1091 1128
1092 1129 $slug = $this->settings->get( 'encyclopedia_root_slug' );
1093 1130
1094 - global $wp_rewrite;
1095 - if ( $wp_rewrite->using_index_permalinks() ) {
1096 - $slug = $wp_rewrite->index . '/' . $slug;
1097 - }
1098 -
1099 1131 $encyclopedia_url = home_url( $slug );
1100 1132
1101 1133 $admin_bar->add_node(
1102 1134 [
@@ -1173,6 +1205,52 @@
1173 1205 if ( $last_visited === 'classic_ui' && isset( $submenu['betterdocs-admin'] ) && in_array( 'betterdocs-admin', $submenu['betterdocs-admin'][0] ) ) {
1174 1206 unset( $submenu['betterdocs-admin'][0] );
1175 1207 $submenu['betterdocs-admin'] = array_values( $submenu['betterdocs-admin'] );
1176 1208 }
1209 + }
1210 +
1211 + /**
1212 + * Initialize Black Friday Pointer
1213 + *
1214 + * @return void
1215 + * @since 3.7.0
1216 + */
1217 + private function init_black_friday_pointer() {
1218 + // Only initialize if conditions are met
1219 + if ( NoticePointers::should_display_notice() ) {
1220 + new NoticePointers();
1221 + }
1222 + }
1223 +
1224 + /**
1225 + * AJAX handler for dismissing Black Friday pointer
1226 + *
1227 + * @return void
1228 + * @since 3.7.0
1229 + */
1230 + public function ajax_dismiss_black_friday_pointer() {
1231 + // Verify nonce
1232 + if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'betterdocs_dismiss_pointer' ) ) {
1233 + wp_send_json_error( [ 'message' => __( 'Invalid nonce', 'betterdocs' ) ] );
1234 + }
1235 +
1236 + // Check if user has permission
1237 + if ( ! current_user_can( 'manage_options' ) && ! current_user_can( 'edit_docs' ) ) {
1238 + wp_send_json_error( [ 'message' => __( 'Permission denied', 'betterdocs' ) ] );
1239 + }
1240 +
1241 + // Get the introduction key
1242 + $introduction_key = isset( $_POST['introduction_key'] ) ? sanitize_text_field( $_POST['introduction_key'] ) : '';
1243 +
1244 + if ( empty( $introduction_key ) ) {
1245 + wp_send_json_error( [ 'message' => __( 'Invalid introduction key', 'betterdocs' ) ] );
1246 + }
1247 +
1248 + // Set the introduction as viewed
1249 + NoticePointers::set_introduction_viewed( $introduction_key );
1250 +
1251 + // Clear the priority option so other plugins can set their priority
1252 + delete_option( '_wpdeveloper_plugin_pointer_priority' );
1253 +
1254 + wp_send_json_success( [ 'message' => __( 'Pointer dismissed successfully', 'betterdocs' ) ] );
1177 1255 }
1178 1256 }