| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace WPDeveloper\BetterDocs\Editors\Elementor; |
| 3 | 3 | |
| 4 | 4 | if ( ! defined( 'ABSPATH' ) ) { |
| 5 | - exit; // Exit if accessed directly | |
| 5 | + exit; // Exit if accessed directly | |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | use ElementorPro\Plugin; |
| 9 | 9 | use Elementor\Controls_Manager; |
| @@ -18,130 +18,132 @@ | ||
| 18 | 18 | * @subpackage BetterDocs/elementor |
| 19 | 19 | * @author WPDeveloper <[email protected]> |
| 20 | 20 | */ |
| 21 | 21 | class SingleDocs extends Single_Base { |
| 22 | - public static function get_properties() { | |
| 23 | - $properties = parent::get_properties(); | |
| 22 | + public static function get_properties() { | |
| 23 | + $properties = parent::get_properties(); | |
| 24 | 24 | |
| 25 | - $properties['location'] = 'single'; | |
| 26 | - $properties['condition_type'] = 'docs'; | |
| 25 | + $properties['location'] = 'single'; | |
| 26 | + $properties['condition_type'] = 'docs'; | |
| 27 | 27 | |
| 28 | - return $properties; | |
| 29 | - } | |
| 28 | + return $properties; | |
| 29 | + } | |
| 30 | 30 | |
| 31 | - protected static function get_site_editor_type() { | |
| 32 | - return 'docs'; | |
| 33 | - } | |
| 31 | + protected static function get_site_editor_type() { | |
| 32 | + return 'docs'; | |
| 33 | + } | |
| 34 | 34 | |
| 35 | - public static function get_type() { | |
| 36 | - return 'docs'; | |
| 37 | - } | |
| 35 | + public static function get_type() { | |
| 36 | + return 'docs'; | |
| 37 | + } | |
| 38 | 38 | |
| 39 | - public static function get_title() { | |
| 40 | - return __( 'Single Doc', 'betterdocs' ); | |
| 41 | - } | |
| 39 | + public static function get_title() { | |
| 40 | + return __( 'Single Doc', 'betterdocs' ); | |
| 41 | + } | |
| 42 | 42 | |
| 43 | - public static function get_editor_panel_config() { | |
| 44 | - $config = parent::get_editor_panel_config(); | |
| 43 | + public static function get_editor_panel_config() { | |
| 44 | + $config = parent::get_editor_panel_config(); | |
| 45 | 45 | |
| 46 | - $config['widgets_settings']['betterdocs-elements'] = [ | |
| 47 | - 'show_in_panel' => true | |
| 48 | - ]; | |
| 46 | + $config['widgets_settings']['betterdocs-elements'] = [ | |
| 47 | + 'show_in_panel' => true | |
| 48 | + ]; | |
| 49 | 49 | |
| 50 | - return $config; | |
| 51 | - } | |
| 50 | + return $config; | |
| 51 | + } | |
| 52 | 52 | |
| 53 | - public function get_depended_widget() { | |
| 54 | - return Plugin::elementor()->widgets_manager->get_widget_types( 'betterdocs-content' ); | |
| 55 | - } | |
| 53 | + public function get_depended_widget() { | |
| 54 | + return Plugin::elementor()->widgets_manager->get_widget_types( 'betterdocs-content' ); | |
| 55 | + } | |
| 56 | 56 | |
| 57 | - public function get_container_attributes() { | |
| 58 | - $attributes = parent::get_container_attributes(); | |
| 57 | + public function get_container_attributes() { | |
| 58 | + $attributes = parent::get_container_attributes(); | |
| 59 | 59 | |
| 60 | - $attributes['class'] .= ' betterdocs'; | |
| 60 | + $attributes['class'] .= ' betterdocs'; | |
| 61 | 61 | |
| 62 | - return $attributes; | |
| 63 | - } | |
| 62 | + return $attributes; | |
| 63 | + } | |
| 64 | 64 | |
| 65 | - public function filter_body_classes( $body_classes ) { | |
| 66 | - $body_classes = parent::filter_body_classes( $body_classes ); | |
| 65 | + public function filter_body_classes( $body_classes ) { | |
| 66 | + $body_classes = parent::filter_body_classes( $body_classes ); | |
| 67 | 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 | - } | |
| 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 | 71 | |
| 72 | - return $body_classes; | |
| 73 | - } | |
| 72 | + return $body_classes; | |
| 73 | + } | |
| 74 | 74 | |
| 75 | - public function before_get_content() { | |
| 76 | - parent::before_get_content(); | |
| 75 | + public function before_get_content() { | |
| 76 | + parent::before_get_content(); | |
| 77 | 77 | |
| 78 | - do_action( 'betterdocs_before_single_product' ); | |
| 79 | - } | |
| 78 | + do_action( 'betterdocs_before_single_product' ); | |
| 79 | + } | |
| 80 | 80 | |
| 81 | - public function after_get_content() { | |
| 82 | - parent::after_get_content(); | |
| 81 | + public function after_get_content() { | |
| 82 | + parent::after_get_content(); | |
| 83 | 83 | |
| 84 | - do_action( 'betterdocs_after_single_product' ); | |
| 85 | - } | |
| 84 | + do_action( 'betterdocs_after_single_product' ); | |
| 85 | + } | |
| 86 | 86 | |
| 87 | - public function print_content() { | |
| 88 | - if ( post_password_required() ) { | |
| 89 | - echo get_the_password_form(); | |
| 90 | - return; | |
| 91 | - } | |
| 87 | + public function print_content() { | |
| 88 | + if ( post_password_required() ) { | |
| 89 | + echo wp_kses_post( get_the_password_form() ); | |
| 90 | + return; | |
| 91 | + } | |
| 92 | 92 | |
| 93 | - parent::print_content(); | |
| 94 | - } | |
| 93 | + parent::print_content(); | |
| 94 | + } | |
| 95 | 95 | |
| 96 | - public function __construct( array $data = [] ) { | |
| 97 | - parent::__construct( $data ); | |
| 98 | - } | |
| 96 | + public function __construct( array $data = [] ) { | |
| 97 | + parent::__construct( $data ); | |
| 98 | + } | |
| 99 | 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 | - ]; | |
| 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 | 108 | |
| 109 | - $categories += parent::get_editor_panel_categories(); | |
| 110 | - unset( $categories['theme-elements-single'] ); | |
| 111 | - return $categories; | |
| 112 | - } | |
| 109 | + $categories += parent::get_editor_panel_categories(); | |
| 110 | + unset( $categories['theme-elements-single'] ); | |
| 111 | + return $categories; | |
| 112 | + } | |
| 113 | 113 | |
| 114 | - protected function register_controls() { | |
| 115 | - parent::register_controls(); | |
| 114 | + protected function register_controls() { | |
| 115 | + parent::register_controls(); | |
| 116 | 116 | |
| 117 | - $this->update_control( | |
| 118 | - 'preview_type', | |
| 119 | - [ | |
| 120 | - 'type' => Controls_Manager::HIDDEN, | |
| 121 | - 'default' => 'single/docs' | |
| 122 | - ] | |
| 123 | - ); | |
| 117 | + $this->update_control( | |
| 118 | + 'preview_type', | |
| 119 | + [ | |
| 120 | + 'type' => Controls_Manager::HIDDEN, | |
| 121 | + 'default' => 'single/docs' | |
| 122 | + ] | |
| 123 | + ); | |
| 124 | 124 | |
| 125 | - $latest_posts = get_posts( [ | |
| 126 | - 'posts_per_page' => 1, | |
| 127 | - 'post_type' => 'docs' | |
| 128 | - ] ); | |
| 125 | + $latest_posts = get_posts( | |
| 126 | + [ | |
| 127 | + 'posts_per_page' => 1, | |
| 128 | + 'post_type' => 'docs' | |
| 129 | + ] | |
| 130 | + ); | |
| 129 | 131 | |
| 130 | - if ( ! empty( $latest_posts ) ) { | |
| 131 | - $this->update_control( | |
| 132 | - 'preview_id', | |
| 133 | - [ | |
| 134 | - 'default' => $latest_posts[0]->ID | |
| 135 | - ] | |
| 136 | - ); | |
| 137 | - } | |
| 138 | - } | |
| 132 | + if ( ! empty( $latest_posts ) ) { | |
| 133 | + $this->update_control( | |
| 134 | + 'preview_id', | |
| 135 | + [ | |
| 136 | + 'default' => $latest_posts[0]->ID | |
| 137 | + ] | |
| 138 | + ); | |
| 139 | + } | |
| 140 | + } | |
| 139 | 141 | |
| 140 | - protected function get_remote_library_config() { | |
| 141 | - $config = parent::get_remote_library_config(); | |
| 142 | + protected function get_remote_library_config() { | |
| 143 | + $config = parent::get_remote_library_config(); | |
| 142 | 144 | |
| 143 | - $config['category'] = 'Single Docs'; | |
| 145 | + $config['category'] = 'Single Docs'; | |
| 144 | 146 | |
| 145 | - return $config; | |
| 146 | - } | |
| 147 | + return $config; | |
| 148 | + } | |
| 147 | 149 | } |