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
betterdocs / includes / Editors / Elementor / SingleDocs.php

SingleDocs.php in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 3.8.9, at includes/Editors/Elementor/SingleDocs.php

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