PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 3.8.9
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v3.8.9
4.9.2 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 All 200 releases
← All changes | includes/FrontEnd/FrontEnd.php +33 -62 4.9.23.8.9 View file →
@@ -1,17 +1,13 @@
1 1 <?php
2 +
2 3 namespace WPDeveloper\BetterDocs\FrontEnd;
3 4
4 -if ( ! defined( 'ABSPATH' ) ) {
5 - exit;
6 -}
7 -
8 -
9 5 use WPDeveloper\BetterDocs\Utils\Base;
10 -use WPDeveloper\BetterDocs\Utils\Helper;
11 6 use WPDeveloper\BetterDocs\Core\Settings;
12 7 use WPDeveloper\BetterDocs\Utils\Enqueue;
13 8 use WPDeveloper\BetterDocs\Utils\Database;
9 +use WPDeveloper\BetterDocs\Utils\Helper;
14 10 use WPDeveloper\BetterDocs\Dependencies\DI\Container;
15 11
16 12 class FrontEnd extends Base {
17 13 private $container;
@@ -38,14 +34,14 @@
38 34
39 35 add_action( 'init', [ $this, 'init' ] );
40 36 add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
41 37
42 - /**
43 - * Update The 'Edit Site' Url In FSE Mode For Betterdocs Templates Only
44 - */
45 - if ( Helper::is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) && wp_is_block_theme() ) {
46 - add_action( 'admin_bar_menu', [$this, 'fse_url_update'], 41, 1 );
47 - }
38 + /**
39 + * Update The 'Edit Site' Url In FSE Mode For Betterdocs Templates Only
40 + */
41 + if ( Helper::is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) && wp_is_block_theme() ) {
42 + add_action( 'admin_bar_menu', [ $this, 'fse_url_update' ], 41, 1 );
43 + }
48 44
49 45 add_filter( 'betterdocs_layout_filename', [ $this, 'layout_filename' ], 10, 2 );
50 46
51 47 add_action( 'betterdocs_docs_before_social', [ $this, 'article_reactions' ] );
@@ -58,51 +54,31 @@
58 54
59 55 //Remove our search selector from from Searchanise plugin for woocommerce, conflicts with betterdocs search (Bug Fix Card -> https://trello.com/c/lXzrtv2f/1313-client-issue-betterdocs-is-conflicting-with-the-searchanise-plugin)
60 56 add_filter( 'se_load_search_widgets', [ $this, 'exclude_betterdocs_search' ], 10, 1 );
61 57
62 - //Fix Betterdocs Search Issue With HostCluster Theme
63 - if ( function_exists( 'hostcluster_search_filter' ) ) {
64 - remove_filter( 'pre_get_posts', 'hostcluster_search_filter' );
65 - }
58 + //Fix Betterdocs Search Issue With HostCluster Theme
59 + if ( function_exists( 'hostcluster_search_filter' ) ) {
60 + remove_filter( 'pre_get_posts', 'hostcluster_search_filter' );
61 + }
62 + }
66 63
67 - //render authors template
68 - add_filter( 'template_include', [$this, 'render_authors_template'], 10, 1 );
69 - }
64 + public function fse_url_update( &$wp_admin_bar ) {
65 + $site_edit_node = $wp_admin_bar->get_node( 'site-editor' );
70 66
71 - public function render_authors_template( $template_path ) {
72 - $post_type = get_query_var( 'post_type' ) != null ? get_query_var( 'post_type' ) : '';
73 - $author_id = get_query_var( 'author' ) != null ? get_query_var( 'author' ) : 0;
74 - $author_docs_count = count_user_posts( $author_id, 'docs' );
67 + if ( empty( $site_edit_node ) ) {
68 + return;
69 + }
75 70
76 - // Only override on an actual author archive — otherwise this also fires on
77 - // the main docs archive (where $author_id falls back to 0) whenever any doc
78 - // has post_author 0, hijacking the docs/MKB archive (and its FSE template)
79 - // with the author template.
80 - if ( is_author() && $post_type == 'docs' && $author_docs_count > 0 ) {
81 - wp_enqueue_style('betterdocs-breadcrumb');
82 - $template_path = BETTERDOCS_ABSPATH . 'views/templates/authors/author.php';
83 - }
71 + if ( is_post_type_archive( 'docs' ) || is_tax( 'knowledge_base' ) || is_tax( 'doc_category' ) || is_tax( 'doc_tag' ) || is_singular( 'docs' ) ) {
72 + $href = isset( $site_edit_node->href ) ? $site_edit_node->href : '';
73 + if ( ! empty( $href ) ) {
74 + $href = $href . '&lang=' . ICL_LANGUAGE_CODE;
75 + $site_edit_node->href = $href;
76 + $wp_admin_bar->add_node( $site_edit_node );
77 + }
78 + }
79 + }
84 80
85 - return $template_path;
86 - }
87 -
88 - public function fse_url_update( &$wp_admin_bar ) {
89 - $site_edit_node = $wp_admin_bar->get_node( 'site-editor' );
90 -
91 - if ( empty( $site_edit_node ) ) {
92 - return;
93 - }
94 -
95 - if ( is_post_type_archive( 'docs' ) || is_tax( 'knowledge_base' ) || is_tax( 'doc_category' ) || is_tax( 'doc_tag' ) || is_singular( 'docs' ) ) {
96 - $href = isset( $site_edit_node->href ) ? $site_edit_node->href : '';
97 - if ( ! empty( $href ) ) {
98 - $href = $href . '&lang=' . ICL_LANGUAGE_CODE;
99 - $site_edit_node->href = $href;
100 - $wp_admin_bar->add_node( $site_edit_node );
101 - }
102 - }
103 - }
104 -
105 81 public function exclude_betterdocs_search( $options ) {
106 82 $options['search_input'] = $options['search_input'] . ':not(.betterdocs-search-field)';
107 83 return $options;
108 84 }
@@ -155,10 +131,10 @@
155 131 break;
156 132 case 'blocks':
157 133 if ( isset( $this->widget_attributes['orderBy'] ) ) {
158 134 if ( $this->widget_attributes['orderBy'] == 'doc_category_order' ) {
159 - // Use betterdocs_order which handles fallback logic automatically
160 - $args['orderby'] = 'betterdocs_order';
135 + $args['orderby'] = 'meta_value_num';
136 + $args['meta_key'] = $this->widget_attributes['orderBy'];
161 137 } else {
162 138 $args['orderby'] = $this->widget_attributes['orderBy'];
163 139 }
164 140 }
@@ -215,11 +191,8 @@
215 191 $args = [];
216 192 $single_layout = $this->database->get_theme_mod( 'betterdocs_single_layout_select', true );
217 193 $reactions = $this->database->get_theme_mod( 'betterdocs_post_reactions', true );
218 194
219 - // Get the title tag from customizer
220 - $text_tag = $this->database->get_theme_mod( 'betterdocs_reactions_title_tag', 'h5' );
221 -
222 195 // Collect reaction values and icons
223 196 $reactions_data = [
224 197 'happy' => 'betterdocs_post_reactions_happy',
225 198 'happy_icon' => 'betterdocs_post_reactions_happy_icon',
@@ -229,9 +202,9 @@
229 202 'sad_icon' => 'betterdocs_post_reactions_sad_icon'
230 203 ];
231 204
232 205 foreach ( $reactions_data as $key => $theme_mod ) {
233 - $value = betterdocs()->customizer->defaults->get( $theme_mod );
206 + $value = $this->database->get_theme_mod( $theme_mod, true );
234 207 if ( $value ) {
235 208 $args[ $key ] = $value;
236 209 } else {
237 210 $args[ $key ] = false;
@@ -244,14 +217,14 @@
244 217 $attr .= sprintf( ' %s="%s"', esc_attr( $key ), esc_attr( $value ) );
245 218 }
246 219
247 220 // Render the shortcode based on layout and reactions availability
248 - if ( ( $single_layout == 'layout-8' || $single_layout == 'layout-10' ) && $reactions ) {
249 - echo do_shortcode( '[betterdocs_article_reactions text_tag="' . esc_attr( $text_tag ) . '" layout="layout-2"' . $attr . ']' );
221 + if ( $single_layout == 'layout-8' && $reactions ) {
222 + echo do_shortcode( '[betterdocs_article_reactions layout="layout-2"' . $attr . ']' );
250 223 } elseif ( $single_layout == 'layout-9' && $reactions ) {
251 224 echo '';
252 225 } elseif ( $reactions ) {
253 - echo do_shortcode( '[betterdocs_article_reactions text_tag="' . esc_attr( $text_tag ) . '"' . $attr . ']' );
226 + echo do_shortcode( '[betterdocs_article_reactions' . $attr . ']' );
254 227 }
255 228 }
256 229
257 230
@@ -257,9 +230,8 @@
257 230
258 231 public function enqueue_scripts() {
259 232 if ( is_singular( 'docs' ) ) {
260 233 wp_enqueue_style( 'betterdocs-single' );
261 - wp_enqueue_style( 'betterdocs-article-summary' );
262 234 wp_enqueue_style( 'betterdocs-encyclopedia' );
263 235 wp_enqueue_style( 'betterdocs-glossaries' );
264 236 wp_enqueue_script( 'clipboard' );
265 237 wp_enqueue_script( 'betterdocs-glossaries' );
@@ -322,9 +294,8 @@
322 294 'betterdocs-reactions',
323 295 'betterdocsReactionsConfig',
324 296 [
325 297 'post_id' => get_the_ID(),
326 - 'nonce' => wp_create_nonce( 'wp_rest' ),
327 298 'FEEDBACK' => [
328 299 'DISPLAY' => true,
329 300 'TEXT' => esc_html__( 'How did you feel?', 'betterdocs' ),
330 301 'SUCCESS' => betterdocs()->settings->get( 'reaction_feedback_text', __( 'Thanks for your feedback', 'betterdocs' ) ),