| 1 |
<?php |
| 2 |
namespace WPDeveloper\BetterDocs\Editors\Elementor\Widget; |
| 3 |
|
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; // Exit if accessed directly |
| 6 |
} |
| 7 |
|
| 8 |
use Elementor\Core\Schemes; |
| 9 |
use Elementor\Controls_Manager; |
| 10 |
use Elementor\Group_Control_Typography; |
| 11 |
use WPDeveloper\BetterDocs\Editors\Elementor\ContentBaseWidget; |
| 12 |
|
| 13 |
class Content extends ContentBaseWidget { |
| 14 |
public function get_name() { |
| 15 |
return 'betterdocs-content'; |
| 16 |
} |
| 17 |
|
| 18 |
public function get_title() { |
| 19 |
return __( 'Doc Content', 'betterdocs' ); |
| 20 |
} |
| 21 |
|
| 22 |
public function has_widget_inner_wrapper():bool { |
| 23 |
return false; |
| 24 |
} |
| 25 |
|
| 26 |
public function get_icon() { |
| 27 |
return 'betterdocs-icon-Content'; |
| 28 |
} |
| 29 |
|
| 30 |
public function get_categories() { |
| 31 |
return [ 'betterdocs-elements-single' ]; |
| 32 |
} |
| 33 |
|
| 34 |
public function get_keywords() { |
| 35 |
return [ 'betterdocs-elements', 'content', 'description', 'docs', 'betterdocs' ]; |
| 36 |
} |
| 37 |
|
| 38 |
public function get_custom_help_url() { |
| 39 |
return 'https://betterdocs.co/docs/single-doc-in-elementor'; |
| 40 |
} |
| 41 |
|
| 42 |
protected function register_controls() { |
| 43 |
$this->start_controls_section( |
| 44 |
'section_style', |
| 45 |
[ |
| 46 |
'label' => __( 'Style', 'betterdocs' ), |
| 47 |
'tab' => Controls_Manager::TAB_STYLE |
| 48 |
] |
| 49 |
); |
| 50 |
|
| 51 |
$this->add_control( |
| 52 |
'print_btn', |
| 53 |
[ |
| 54 |
'label' => __( 'Print Button', 'betterdocs' ), |
| 55 |
'type' => Controls_Manager::SWITCHER, |
| 56 |
'label_on' => __( 'Show', 'betterdocs' ), |
| 57 |
'label_off' => __( 'Hide', 'betterdocs' ), |
| 58 |
'return_value' => '1', |
| 59 |
'default' => '1' |
| 60 |
] |
| 61 |
); |
| 62 |
|
| 63 |
$this->add_responsive_control( |
| 64 |
'align', |
| 65 |
[ |
| 66 |
'label' => __( 'Alignment', 'betterdocs' ), |
| 67 |
'type' => Controls_Manager::CHOOSE, |
| 68 |
'options' => [ |
| 69 |
'left' => [ |
| 70 |
'title' => __( 'Left', 'betterdocs' ), |
| 71 |
'icon' => 'eicon-text-align-left' |
| 72 |
], |
| 73 |
'center' => [ |
| 74 |
'title' => __( 'Center', 'betterdocs' ), |
| 75 |
'icon' => 'eicon-text-align-center' |
| 76 |
], |
| 77 |
'right' => [ |
| 78 |
'title' => __( 'Right', 'betterdocs' ), |
| 79 |
'icon' => 'eicon-text-align-right' |
| 80 |
], |
| 81 |
'justify' => [ |
| 82 |
'title' => __( 'Justified', 'betterdocs' ), |
| 83 |
'icon' => 'eicon-text-align-justify' |
| 84 |
] |
| 85 |
], |
| 86 |
'selectors' => [ |
| 87 |
'{{WRAPPER}}' => 'text-align: {{VALUE}};' |
| 88 |
] |
| 89 |
] |
| 90 |
); |
| 91 |
|
| 92 |
$this->add_group_control( |
| 93 |
Group_Control_Typography::get_type(), |
| 94 |
[ |
| 95 |
'name' => 'betterdocs_content_typography', |
| 96 |
'selector' => '{{WRAPPER}} .betterdocs-content' |
| 97 |
] |
| 98 |
); |
| 99 |
|
| 100 |
$this->add_control( |
| 101 |
'doc_content_color', |
| 102 |
[ |
| 103 |
'label' => __( 'Doc Content Color', 'betterdocs' ), |
| 104 |
'type' => Controls_Manager::COLOR, |
| 105 |
'selectors' => [ |
| 106 |
'{{WRAPPER}} .betterdocs-content' => 'color: {{VALUE}}', |
| 107 |
'{{WRAPPER}} .betterdocs-content p' => 'color: {{VALUE}}', |
| 108 |
] |
| 109 |
] |
| 110 |
); |
| 111 |
|
| 112 |
$this->add_control( |
| 113 |
'doc_content_title_color', |
| 114 |
[ |
| 115 |
'label' => __( 'Content Title Color', 'betterdocs' ), |
| 116 |
'type' => Controls_Manager::COLOR, |
| 117 |
'selectors' => [ |
| 118 |
'{{WRAPPER}} .betterdocs-content .betterdocs-content-heading' => 'color: {{VALUE}}' |
| 119 |
] |
| 120 |
] |
| 121 |
); |
| 122 |
|
| 123 |
$this->add_group_control( |
| 124 |
Group_Control_Typography::get_type(), |
| 125 |
[ |
| 126 |
'name' => 'betterdocs_content_title_typography', |
| 127 |
'selector' => '{{WRAPPER}} .betterdocs-content .betterdocs-content-heading' |
| 128 |
] |
| 129 |
); |
| 130 |
$this->end_controls_section(); |
| 131 |
} |
| 132 |
|
| 133 |
protected function render_callback() { |
| 134 |
$this->views( 'widgets/content' ); |
| 135 |
} |
| 136 |
|
| 137 |
public function view_params() { |
| 138 |
$toc_setting = get_transient( 'betterdocs_toc_setting' ); |
| 139 |
$htags = ( $toc_setting ) ? implode( ',', $toc_setting['htags'] ) : ''; |
| 140 |
$enable_toc = ( $htags ) ? 1 : ''; |
| 141 |
|
| 142 |
return [ |
| 143 |
'enable' => (bool) $this->attributes['print_btn'], |
| 144 |
'htags' => $htags, |
| 145 |
'enable_toc' => $enable_toc, |
| 146 |
'wrapper_attr' => [ |
| 147 |
'class' => [ 'betterdocs-entry-content' ] |
| 148 |
] |
| 149 |
]; |
| 150 |
} |
| 151 |
|
| 152 |
public function show_in_panel() { |
| 153 |
return true; |
| 154 |
} |
| 155 |
} |
| 156 |
|