PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 2.0.14
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v2.0.14
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 / elementor / betterdocs-single-docs.php

betterdocs-single-docs.php in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 2.0.14, at includes/elementor/betterdocs-single-docs.php

161 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use Elementor\Controls_Manager;
4 use ElementorPro\Modules\ThemeBuilder\Documents\Single_Base;
5 use ElementorPro\Plugin;
6
7 if (!defined('ABSPATH')) {
8 exit; // Exit if accessed directly
9 }
10
11 /**
12 * Working with elementor plugin
13 *
14 *
15 * @since 1.3.0
16 * @package BetterDocs
17 * @subpackage BetterDocs/elementor
18 * @author WPDeveloper <support@wpdeveloper.com>
19 */
20 class BetterDocs_Single_Docs extends Single_Base
21 {
22 public static function get_properties()
23 {
24 $properties = parent::get_properties();
25
26 $properties['location'] = 'single';
27 $properties['condition_type'] = 'docs';
28
29 return $properties;
30 }
31
32 protected static function get_site_editor_type()
33 {
34 return 'docs';
35 }
36
37 public static function get_type() {
38 return 'docs';
39 }
40
41 public static function get_title()
42 {
43 return __('Single Doc', 'betterdocs');
44 }
45
46 public static function get_editor_panel_config()
47 {
48 $config = parent::get_editor_panel_config();
49 $config['widgets_settings']['betterdocs-elements'] = [
50 'show_in_panel' => true,
51 ];
52
53 return $config;
54 }
55
56 public function get_depended_widget()
57 {
58 return Plugin::elementor()->widgets_manager->get_widget_types('betterdocs-content');
59 }
60
61 public function get_container_attributes()
62 {
63 $attributes = parent::get_container_attributes();
64
65 $attributes['class'] .= ' betterdocs';
66
67 return $attributes;
68 }
69
70 public function filter_body_classes($body_classes)
71 {
72 $body_classes = parent::filter_body_classes($body_classes);
73
74 if (get_the_ID() === $this->get_main_id() || Plugin::elementor()->preview->is_preview_mode($this->get_main_id())) {
75 $body_classes[] = 'betterdocs-elementor-single';
76 }
77
78 return $body_classes;
79 }
80
81 public function before_get_content()
82 {
83 parent::before_get_content();
84
85 do_action('betterdocs_before_single_product');
86 }
87
88 public function after_get_content()
89 {
90 parent::after_get_content();
91
92 do_action('betterdocs_after_single_product');
93 }
94
95 public function print_content()
96 {
97 if (post_password_required()) {
98 echo get_the_password_form();
99 return;
100 }
101
102 parent::print_content();
103 }
104
105 public function __construct(array $data = [])
106 {
107 parent::__construct($data);
108 }
109
110 protected static function get_editor_panel_categories()
111 {
112 $categories = [
113 // Move to top as active.
114 'betterdocs-elements-single' => [
115 'title' => __('BetterDocs', 'betterdocs'),
116 'active' => true,
117 ],
118 ];
119
120 $categories += parent::get_editor_panel_categories();
121 unset($categories['theme-elements-single']);
122 return $categories;
123 }
124
125 protected function register_controls()
126 {
127 parent::register_controls();
128
129 $this->update_control(
130 'preview_type',
131 [
132 'type' => Controls_Manager::HIDDEN,
133 'default' => 'single/docs',
134 ]
135 );
136
137 $latest_posts = get_posts([
138 'posts_per_page' => 1,
139 'post_type' => 'docs',
140 ]);
141
142 if (!empty($latest_posts)) {
143 $this->update_control(
144 'preview_id',
145 [
146 'default' => $latest_posts[0]->ID,
147 ]
148 );
149 }
150 }
151
152 protected function get_remote_library_config()
153 {
154 $config = parent::get_remote_library_config();
155
156 $config['category'] = 'Single Docs';
157
158 return $config;
159 }
160 }
161