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.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/FrontEnd/FrontEnd.php +32 -52 4.5.23.8.9 View file →
@@ -2,12 +2,12 @@
2 2
3 3 namespace WPDeveloper\BetterDocs\FrontEnd;
4 4
5 5 use WPDeveloper\BetterDocs\Utils\Base;
6 -use WPDeveloper\BetterDocs\Utils\Helper;
7 6 use WPDeveloper\BetterDocs\Core\Settings;
8 7 use WPDeveloper\BetterDocs\Utils\Enqueue;
9 8 use WPDeveloper\BetterDocs\Utils\Database;
9 +use WPDeveloper\BetterDocs\Utils\Helper;
10 10 use WPDeveloper\BetterDocs\Dependencies\DI\Container;
11 11
12 12 class FrontEnd extends Base {
13 13 private $container;
@@ -34,14 +34,14 @@
34 34
35 35 add_action( 'init', [ $this, 'init' ] );
36 36 add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
37 37
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 - }
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 + }
44 44
45 45 add_filter( 'betterdocs_layout_filename', [ $this, 'layout_filename' ], 10, 2 );
46 46
47 47 add_action( 'betterdocs_docs_before_social', [ $this, 'article_reactions' ] );
@@ -54,47 +54,31 @@
54 54
55 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)
56 56 add_filter( 'se_load_search_widgets', [ $this, 'exclude_betterdocs_search' ], 10, 1 );
57 57
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 - }
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 + }
62 63
63 - //render authors template
64 - add_filter( 'template_include', [$this, 'render_authors_template'], 10, 1 );
65 - }
64 + public function fse_url_update( &$wp_admin_bar ) {
65 + $site_edit_node = $wp_admin_bar->get_node( 'site-editor' );
66 66
67 - public function render_authors_template( $template_path ) {
68 - $post_type = get_query_var( 'post_type' ) != null ? get_query_var( 'post_type' ) : '';
69 - $author_id = get_query_var( 'author' ) != null ? get_query_var( 'author' ) : 0;
70 - $author_docs_count = count_user_posts( $author_id, 'docs' );
67 + if ( empty( $site_edit_node ) ) {
68 + return;
69 + }
71 70
72 - if ( $post_type == 'docs' && $author_docs_count > 0 ) {
73 - wp_enqueue_style('betterdocs-breadcrumb');
74 - $template_path = BETTERDOCS_ABSPATH . 'views/templates/authors/author.php';
75 - }
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 + }
76 80
77 - return $template_path;
78 - }
79 -
80 - public function fse_url_update( &$wp_admin_bar ) {
81 - $site_edit_node = $wp_admin_bar->get_node( 'site-editor' );
82 -
83 - if ( empty( $site_edit_node ) ) {
84 - return;
85 - }
86 -
87 - if ( is_post_type_archive( 'docs' ) || is_tax( 'knowledge_base' ) || is_tax( 'doc_category' ) || is_tax( 'doc_tag' ) || is_singular( 'docs' ) ) {
88 - $href = isset( $site_edit_node->href ) ? $site_edit_node->href : '';
89 - if ( ! empty( $href ) ) {
90 - $href = $href . '&lang=' . ICL_LANGUAGE_CODE;
91 - $site_edit_node->href = $href;
92 - $wp_admin_bar->add_node( $site_edit_node );
93 - }
94 - }
95 - }
96 -
97 81 public function exclude_betterdocs_search( $options ) {
98 82 $options['search_input'] = $options['search_input'] . ':not(.betterdocs-search-field)';
99 83 return $options;
100 84 }
@@ -147,10 +131,10 @@
147 131 break;
148 132 case 'blocks':
149 133 if ( isset( $this->widget_attributes['orderBy'] ) ) {
150 134 if ( $this->widget_attributes['orderBy'] == 'doc_category_order' ) {
151 - // Use betterdocs_order which handles fallback logic automatically
152 - $args['orderby'] = 'betterdocs_order';
135 + $args['orderby'] = 'meta_value_num';
136 + $args['meta_key'] = $this->widget_attributes['orderBy'];
153 137 } else {
154 138 $args['orderby'] = $this->widget_attributes['orderBy'];
155 139 }
156 140 }
@@ -207,11 +191,8 @@
207 191 $args = [];
208 192 $single_layout = $this->database->get_theme_mod( 'betterdocs_single_layout_select', true );
209 193 $reactions = $this->database->get_theme_mod( 'betterdocs_post_reactions', true );
210 194
211 - // Get the title tag from customizer
212 - $text_tag = $this->database->get_theme_mod( 'betterdocs_reactions_title_tag', 'h5' );
213 -
214 195 // Collect reaction values and icons
215 196 $reactions_data = [
216 197 'happy' => 'betterdocs_post_reactions_happy',
217 198 'happy_icon' => 'betterdocs_post_reactions_happy_icon',
@@ -221,9 +202,9 @@
221 202 'sad_icon' => 'betterdocs_post_reactions_sad_icon'
222 203 ];
223 204
224 205 foreach ( $reactions_data as $key => $theme_mod ) {
225 - $value = betterdocs()->customizer->defaults->get( $theme_mod );
206 + $value = $this->database->get_theme_mod( $theme_mod, true );
226 207 if ( $value ) {
227 208 $args[ $key ] = $value;
228 209 } else {
229 210 $args[ $key ] = false;
@@ -236,14 +217,14 @@
236 217 $attr .= sprintf( ' %s="%s"', esc_attr( $key ), esc_attr( $value ) );
237 218 }
238 219
239 220 // Render the shortcode based on layout and reactions availability
240 - if ( ( $single_layout == 'layout-8' || $single_layout == 'layout-10' ) && $reactions ) {
241 - 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 . ']' );
242 223 } elseif ( $single_layout == 'layout-9' && $reactions ) {
243 224 echo '';
244 225 } elseif ( $reactions ) {
245 - echo do_shortcode( '[betterdocs_article_reactions text_tag="' . esc_attr( $text_tag ) . '"' . $attr . ']' );
226 + echo do_shortcode( '[betterdocs_article_reactions' . $attr . ']' );
246 227 }
247 228 }
248 229
249 230
@@ -249,9 +230,8 @@
249 230
250 231 public function enqueue_scripts() {
251 232 if ( is_singular( 'docs' ) ) {
252 233 wp_enqueue_style( 'betterdocs-single' );
253 - wp_enqueue_style( 'betterdocs-article-summary' );
254 234 wp_enqueue_style( 'betterdocs-encyclopedia' );
255 235 wp_enqueue_style( 'betterdocs-glossaries' );
256 236 wp_enqueue_script( 'clipboard' );
257 237 wp_enqueue_script( 'betterdocs-glossaries' );