PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.9.2
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.9.2
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/Admin/Customizer/Customizer.php +123 -97 3.3.44.9.2 View file →
@@ -2,9 +2,9 @@
2 2
3 3 namespace WPDeveloper\BetterDocs\Admin\Customizer;
4 4
5 5 if ( ! defined( 'ABSPATH' ) ) {
6 - exit;
6 + exit;
7 7 }
8 8
9 9 use WPDeveloper\BetterDocs\Utils\Base;
10 10 use WPDeveloper\BetterDocs\Admin\Customizer\Sections\Sidebar;
@@ -15,115 +15,141 @@
15 15 use WPDeveloper\BetterDocs\Admin\Customizer\Sections\LiveSearch;
16 16 use WPDeveloper\BetterDocs\Admin\Customizer\Sections\ArchivePage;
17 17
18 18 class Customizer extends Base {
19 - /**
20 - * Defaults
21 - *
22 - * @var Defaults
23 - */
24 - public $defaults;
19 + /**
20 + * Defaults
21 + *
22 + * @var Defaults
23 + */
24 + public $defaults;
25 25
26 - /**
27 - * Enqueue
28 - *
29 - * @var \WPDeveloper\BetterDocs\Utils\Enqueue
30 - */
31 - private $assets;
26 + /**
27 + * Enqueue
28 + *
29 + * @var \WPDeveloper\BetterDocs\Utils\Enqueue
30 + */
31 + private $assets;
32 32
33 - public function __construct( Defaults $defaults ) {
34 - $this->defaults = $defaults;
33 + public function __construct( Defaults $defaults ) {
34 + $this->defaults = $defaults;
35 35
36 - add_action( 'customize_register', [$this, 'register'] );
36 + add_action( 'customize_register', [ $this, 'register' ] );
37 37
38 - add_action( 'customize_controls_enqueue_scripts', [$this, 'enqueue'] );
39 - add_action( 'customize_preview_init', [$this, 'customize_preview_init'] );
38 + add_action( 'customize_controls_enqueue_scripts', [ $this, 'enqueue' ] );
39 + add_action( 'customize_preview_init', [ $this, 'customize_preview_init' ] );
40 40
41 - add_action( 'customize_controls_print_styles', [$this, 'controls_print_styles'], 999 );
42 - add_action( 'wp_head', [$this, 'dynamic_css'] );
43 - }
41 + add_action( 'customize_controls_print_styles', [ $this, 'controls_print_styles' ], 999 );
44 42
45 - /**
46 - * Register all customizer options here.
47 - * Devided into classes for better readability.
48 - *
49 - * This methods refers to old customizer.php in admin/customizer
50 - * @param mixed $wp_customize
51 - * @return void
52 - */
53 - public function register( $wp_customize ) {
54 - $this->assets = betterdocs()->assets;
55 - $defaults = $this->defaults->defaults();
43 + if ( function_exists( 'wp_is_block_theme' ) && ! wp_is_block_theme() ) {
44 + add_action( 'wp_head', [ $this, 'dynamic_css' ] );
45 + }
46 + }
56 47
57 - // Create custom panels
58 - $wp_customize->add_panel( 'betterdocs_customize_options', [
59 - 'priority' => 30,
60 - 'theme_supports' => '',
61 - 'title' => __( 'BetterDocs', 'betterdocs' ),
62 - 'description' => __( 'Controls the design settings for the theme.', 'betterdocs' )
63 - ] );
48 + /**
49 + * Register all customizer options here.
50 + * Devided into classes for better readability.
51 + *
52 + * This methods refers to old customizer.php in admin/customizer
53 + * @param mixed $wp_customize
54 + * @return void
55 + */
56 + public function register( $wp_customize ) {
57 + $this->assets = betterdocs()->assets;
58 + $defaults = $this->defaults->defaults();
64 59
65 - $_settings_sections = apply_filters( 'betterdocs_customizer_settings', [
66 - DocsPage::class,
67 - SingleDoc::class,
68 - Sidebar::class,
69 - ArchivePage::class,
70 - LiveSearch::class,
71 - FaqBuilder::class,
72 - BreadCrumb::class
73 - ] );
60 + // Create custom panels
61 + $wp_customize->add_panel(
62 + 'betterdocs_customize_options',
63 + [
64 + 'priority' => 30,
65 + 'theme_supports' => '',
66 + 'title' => __( 'BetterDocs', 'betterdocs' ),
67 + 'description' => __( 'Controls the design settings for the theme.', 'betterdocs' )
68 + ]
69 + );
74 70
75 - /**
76 - * Register All Settings
77 - */
78 - foreach ( $_settings_sections as $settings ) {
79 - betterdocs()->container->get( $settings )->register( $wp_customize, $defaults );
80 - }
81 - }
71 + $_settings_sections = apply_filters(
72 + 'betterdocs_customizer_settings',
73 + [
74 + DocsPage::class,
75 + SingleDoc::class,
76 + Sidebar::class,
77 + ArchivePage::class,
78 + LiveSearch::class,
79 + FaqBuilder::class,
80 + BreadCrumb::class,
81 + ]
82 + );
82 83
83 - /**
84 - * Enqueueing styles and scripts for controls and conditions.
85 - *
86 - * old functions :
87 - * * betterdocs_customizer_styles
88 - * * betterdocs_customizer_condition
89 - *
90 - * @return void
91 - */
92 - public function enqueue() {
93 - betterdocs()->assets->enqueue( 'betterdocs-cutomizer-styles', 'customizer/css/customizer-controls.css' );
94 - betterdocs()->assets->enqueue( 'betterdocs-customize-condition', 'customizer/js/customizer-condition.js' );
95 - }
84 + /**
85 + * Register All Settings
86 + */
87 + foreach ( $_settings_sections as $settings ) {
88 + betterdocs()->container->get( $settings )->register( $wp_customize, $defaults );
89 + }
90 + }
96 91
97 - public function customize_preview_init() {
98 - betterdocs()->assets->enqueue( 'betterdocs-customizer', 'customizer/js/customizer.js', ['customize-preview'] );
99 - }
92 + /**
93 + * Enqueueing styles and scripts for controls and conditions.
94 + *
95 + * old functions :
96 + * * betterdocs_customizer_styles
97 + * * betterdocs_customizer_condition
98 + *
99 + * @return void
100 + */
101 + public function enqueue() {
102 + betterdocs()->assets->enqueue( 'betterdocs-cutomizer-styles', 'customizer/css/customizer-controls.css' );
103 + betterdocs()->assets->enqueue( 'betterdocs-customize-condition', 'customizer/js/customizer-condition.js' );
104 + betterdocs()->assets->localize(
105 + 'betterdocs-customize-condition',
106 + 'betterdocsCustomizer',
107 + [
108 + 'isFSETheme' => betterdocs()->helper->current_theme_is_fse_theme(),
109 + 'betterdocsBlockThemeNotification' => sprintf(
110 + /* translators: 1: Link to your documentation, 2: Link to Site Editor */
111 + __( 'BetterDocs Customizer options are not compatible with block-based themes and will not function as expected. Please use the <a href="%2$s">Site Editor</a> to customize your site. <a href="%1$s">Learn more</a>', 'betterdocs' ),
112 + esc_url( 'https://betterdocs.co/docs/betterdocs-provides-full-site-editor-support/' ), // Learn more link
113 + esc_url( admin_url( 'site-editor.php' ) ) // Site Editor link
114 + )
115 + ]
116 + );
117 + }
100 118
101 - public function controls_print_styles() {
102 - ob_start();
103 - include_once __DIR__ . '/controls.css.php';
104 - echo ob_get_clean();
105 - }
119 + public function customize_preview_init() {
120 + betterdocs()->assets->enqueue( 'betterdocs-customizer', 'customizer/js/customizer.js', [ 'customize-preview' ] );
121 + }
106 122
107 - /**
108 - * Generates dynamic css from customizer options.
109 - * @return void
110 - */
111 - public function dynamic_css() {
112 - if ( ! betterdocs()->helper->is_templates() ) {
113 - return false;
114 - }
115 - /**
116 - * Don't remove this line, it's used in dynamic.css.php file.
117 - */
118 - $mods = $this->defaults->theme_mods();
119 - require __DIR__ . '/dynamic.css.php';
123 + public function controls_print_styles() {
124 + ob_start();
125 + include_once __DIR__ . '/controls.css.php';
126 + echo ob_get_clean(); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Because The Styles Are Needed, Nothing To Sanitize Here
127 + }
120 128
121 - ob_start();
122 - // echo '<-- betterdocs customizer css -->';
123 - echo '<style type="text/css">';
124 - echo $css->get_output( true );
125 - echo '</style>';
126 - // echo '<-- betterdocs customizer css end -->';
127 - echo ob_get_clean();
128 - }
129 + /**
130 + * Generates dynamic css from customizer options.
131 + * @return void
132 + */
133 + public function dynamic_css() {
134 + // Also emit on single WooCommerce product pages so the "Product FAQ for
135 + // WooCommerce" customizer controls (.betterdocs-woo-product-faq rules)
136 + // apply there — is_templates() only covers docs/KB templates.
137 + $is_woo_product = function_exists( 'is_product' ) && is_product();
138 + if ( ! betterdocs()->helper->is_templates() && ! $is_woo_product ) {
139 + return false;
140 + }
141 + /**
142 + * Don't remove this line, it's used in dynamic.css.php file.
143 + */
144 + $mods = $this->defaults->theme_mods();
145 + require __DIR__ . '/dynamic.css.php';
146 +
147 + ob_start();
148 + // echo '<-- betterdocs customizer css -->';
149 + echo '<style type="text/css">';
150 + echo $css->get_output( true ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Because The Styles Are Needed Rendered Here, Nothing To Sanitize. We need to sanitize datas which are dynamic only & Not in our control
151 + echo '</style>';
152 + // echo '<-- betterdocs customizer css end -->';
153 + echo ob_get_clean(); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Because The Styles Are Needed, Nothing To Sanitize Here
154 + }
129 155 }