theme-elements
6 months ago
accordion.php
6 months ago
audio.php
6 months ago
before-after.php
6 months ago
button.php
6 months ago
carousel-navigation.php
6 months ago
circle-chart.php
6 months ago
contact-box.php
6 months ago
contact-form.php
6 months ago
custom-list.php
6 months ago
divider.php
6 months ago
gallery.php
6 months ago
gmap.php
6 months ago
heading-modern.php
6 months ago
icon.php
6 months ago
image.php
6 months ago
mailchimp.php
6 months ago
modern-button.php
6 months ago
products-grid.php
6 months ago
quote.php
6 months ago
recent-comments.php
6 months ago
recent-posts-grid-carousel.php
6 months ago
recent-posts-land-style.php
6 months ago
recent-posts-masonry.php
6 months ago
recent-posts-tiles-carousel.php
6 months ago
recent-posts-tiles.php
6 months ago
recent-posts-timeline.php
6 months ago
recent-products.php
6 months ago
responsive-table.php
6 months ago
search.php
6 months ago
staff.php
6 months ago
svg.php
6 months ago
tabs.php
6 months ago
testimonial.php
6 months ago
text.php
6 months ago
touch-slider.php
6 months ago
video.php
6 months ago
responsive-table.php
367 lines
| 1 | <?php |
| 2 | namespace Auxin\Plugin\CoreElements\Elementor\Elements; |
| 3 | |
| 4 | use Elementor\Plugin; |
| 5 | use Elementor\Widget_Base; |
| 6 | use Elementor\Controls_Manager; |
| 7 | use Elementor\Group_Control_Typography; |
| 8 | use Elementor\Core\Kits\Documents\Tabs\Global_Typography; |
| 9 | use Elementor\Group_Control_Background; |
| 10 | |
| 11 | |
| 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 13 | exit; // Exit if accessed directly. |
| 14 | } |
| 15 | |
| 16 | /** |
| 17 | * Elementor 'Responsive Table' widget. |
| 18 | * |
| 19 | * Elementor widget that displays an 'Responsive Table' with lightbox. |
| 20 | * |
| 21 | * @since 1.0.0 |
| 22 | */ |
| 23 | class ResponsiveTable extends Widget_Base { |
| 24 | |
| 25 | /** |
| 26 | * Get widget name. |
| 27 | * |
| 28 | * Retrieve 'Responsive Table' widget name. |
| 29 | * |
| 30 | * @since 1.0.0 |
| 31 | * @access public |
| 32 | * |
| 33 | * @return string Widget name. |
| 34 | */ |
| 35 | public function get_name() { |
| 36 | return 'aux_responsive_table'; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Get widget title. |
| 41 | * |
| 42 | * Retrieve 'Responsive Table' widget title. |
| 43 | * |
| 44 | * @since 1.0.0 |
| 45 | * @access public |
| 46 | * |
| 47 | * @return string Widget title. |
| 48 | */ |
| 49 | public function get_title() { |
| 50 | return __('Responsive Table', 'auxin-elements' ); |
| 51 | } |
| 52 | |
| 53 | public function has_widget_inner_wrapper(): bool { |
| 54 | return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); |
| 55 | } |
| 56 | |
| 57 | |
| 58 | /** |
| 59 | * Get widget icon. |
| 60 | * |
| 61 | * Retrieve 'Responsive Table' widget icon. |
| 62 | * |
| 63 | * @since 1.0.0 |
| 64 | * @access public |
| 65 | * |
| 66 | * @return string Widget icon. |
| 67 | */ |
| 68 | public function get_icon() { |
| 69 | return 'eicon-table auxin-badge'; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Get widget categories. |
| 74 | * |
| 75 | * Retrieve 'Responsive Table' widget icon. |
| 76 | * |
| 77 | * @since 1.0.0 |
| 78 | * @access public |
| 79 | * |
| 80 | * @return string Widget icon. |
| 81 | */ |
| 82 | public function get_categories() { |
| 83 | return array( 'auxin-core' ); |
| 84 | } |
| 85 | |
| 86 | public function get_script_depends() { |
| 87 | return ['stacktable']; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Register 'Responsive Table' widget controls. |
| 92 | * |
| 93 | * Adds different input fields to allow the user to change and customize the widget settings. |
| 94 | * |
| 95 | * @since 1.0.0 |
| 96 | * @access protected |
| 97 | */ |
| 98 | protected function register_controls() { |
| 99 | |
| 100 | /*-----------------------------------------------------------------------------------*/ |
| 101 | /* Content TAB |
| 102 | /*-----------------------------------------------------------------------------------*/ |
| 103 | |
| 104 | $this->start_controls_section( |
| 105 | 'table_markup_section', |
| 106 | array( |
| 107 | 'label' => __('Table Markup', 'auxin-elements' ), |
| 108 | ) |
| 109 | ); |
| 110 | |
| 111 | $this->add_control( |
| 112 | 'table_markup', |
| 113 | array( |
| 114 | 'label' => '', |
| 115 | 'type' => Controls_Manager::CODE, |
| 116 | 'show_label' => false, |
| 117 | ) |
| 118 | ); |
| 119 | |
| 120 | $this->end_controls_section(); |
| 121 | |
| 122 | |
| 123 | /*-----------------------------------------------------------------------------------*/ |
| 124 | /* Style TAB |
| 125 | /*-----------------------------------------------------------------------------------*/ |
| 126 | |
| 127 | $this->start_controls_section( |
| 128 | 'table_body_section', |
| 129 | array( |
| 130 | 'label' => __( 'Table Body', 'auxin-elements' ), |
| 131 | 'tab' => Controls_Manager::TAB_STYLE |
| 132 | ) |
| 133 | ); |
| 134 | |
| 135 | $this->add_responsive_control( |
| 136 | 'table_body_alignment', |
| 137 | array( |
| 138 | 'label' => __('Alignment','auxin-elements' ), |
| 139 | 'type' => Controls_Manager::CHOOSE, |
| 140 | 'options' => array( |
| 141 | 'left' => array( |
| 142 | 'title' => __( 'Left', 'auxin-elements' ), |
| 143 | 'icon' => 'eicon-text-align-left', |
| 144 | ), |
| 145 | 'center' => array( |
| 146 | 'title' => __( 'Center', 'auxin-elements' ), |
| 147 | 'icon' => 'eicon-text-align-center', |
| 148 | ), |
| 149 | 'right' => array( |
| 150 | 'title' => __( 'Right', 'auxin-elements' ), |
| 151 | 'icon' => 'eicon-text-align-right', |
| 152 | ) |
| 153 | ), |
| 154 | 'default' => '', |
| 155 | 'toggle' => true, |
| 156 | 'selectors' => array( |
| 157 | '{{WRAPPER}} td' => 'text-align:{{VALUE}};', |
| 158 | ), |
| 159 | 'separator' => 'after' |
| 160 | ) |
| 161 | ); |
| 162 | |
| 163 | $this->add_group_control( |
| 164 | Group_Control_Background::get_type(), |
| 165 | array( |
| 166 | 'name' => 'table_body_background_normal', |
| 167 | 'selector' => '{{WRAPPER}} td', |
| 168 | 'separator' => 'none' |
| 169 | ) |
| 170 | ); |
| 171 | |
| 172 | $this->add_group_control( |
| 173 | Group_Control_Typography::get_type(), |
| 174 | array( |
| 175 | 'name' => 'table_body_typography', |
| 176 | 'global' => [ |
| 177 | 'default' => Global_Typography::TYPOGRAPHY_PRIMARY, |
| 178 | ], |
| 179 | 'selector' => '{{WRAPPER}} td' |
| 180 | ) |
| 181 | ); |
| 182 | |
| 183 | $this->add_control( |
| 184 | 'table_body_color', |
| 185 | array( |
| 186 | 'label' => __( 'Color', 'auxin-elements' ), |
| 187 | 'type' => Controls_Manager::COLOR, |
| 188 | 'selectors' => array( |
| 189 | '{{WRAPPER}} td' => 'color:{{VALUE}};' |
| 190 | ) |
| 191 | ) |
| 192 | ); |
| 193 | |
| 194 | $this->end_controls_section(); |
| 195 | |
| 196 | $this->start_controls_section( |
| 197 | 'table_head_section', |
| 198 | array( |
| 199 | 'label' => __( 'Table Heading', 'auxin-elements' ), |
| 200 | 'tab' => Controls_Manager::TAB_STYLE |
| 201 | ) |
| 202 | ); |
| 203 | |
| 204 | $this->add_responsive_control( |
| 205 | 'table_head_alignment', |
| 206 | array( |
| 207 | 'label' => __('Alignment','auxin-elements' ), |
| 208 | 'type' => Controls_Manager::CHOOSE, |
| 209 | 'options' => array( |
| 210 | 'left' => array( |
| 211 | 'title' => __( 'Left', 'auxin-elements' ), |
| 212 | 'icon' => 'eicon-text-align-left', |
| 213 | ), |
| 214 | 'center' => array( |
| 215 | 'title' => __( 'Center', 'auxin-elements' ), |
| 216 | 'icon' => 'eicon-text-align-center', |
| 217 | ), |
| 218 | 'right' => array( |
| 219 | 'title' => __( 'Right', 'auxin-elements' ), |
| 220 | 'icon' => 'eicon-text-align-right', |
| 221 | ) |
| 222 | ), |
| 223 | 'default' => '', |
| 224 | 'toggle' => true, |
| 225 | 'selectors' => array( |
| 226 | '{{WRAPPER}} th' => 'text-align:{{VALUE}};', |
| 227 | ), |
| 228 | 'separator' => 'after' |
| 229 | ) |
| 230 | ); |
| 231 | |
| 232 | $this->add_group_control( |
| 233 | Group_Control_Background::get_type(), |
| 234 | array( |
| 235 | 'name' => 'table_head_background_normal', |
| 236 | 'selector' => '{{WRAPPER}} th', |
| 237 | 'separator' => 'none' |
| 238 | ) |
| 239 | ); |
| 240 | |
| 241 | $this->add_group_control( |
| 242 | Group_Control_Typography::get_type(), |
| 243 | array( |
| 244 | 'name' => 'table_head_typography', |
| 245 | 'global' => [ |
| 246 | 'default' => Global_Typography::TYPOGRAPHY_PRIMARY, |
| 247 | ], |
| 248 | 'selector' => '{{WRAPPER}} th' |
| 249 | ) |
| 250 | ); |
| 251 | |
| 252 | $this->add_control( |
| 253 | 'table_head_color', |
| 254 | array( |
| 255 | 'label' => __( 'Color', 'auxin-elements' ), |
| 256 | 'type' => Controls_Manager::COLOR, |
| 257 | 'selectors' => array( |
| 258 | '{{WRAPPER}} th' => 'color:{{VALUE}};' |
| 259 | ) |
| 260 | ) |
| 261 | ); |
| 262 | |
| 263 | $this->end_controls_section(); |
| 264 | |
| 265 | $this->start_controls_section( |
| 266 | 'table_odd_row_section', |
| 267 | array( |
| 268 | 'label' => __( 'Table Odd Rows', 'auxin-elements' ), |
| 269 | 'tab' => Controls_Manager::TAB_STYLE |
| 270 | ) |
| 271 | ); |
| 272 | |
| 273 | $this->add_group_control( |
| 274 | Group_Control_Background::get_type(), |
| 275 | array( |
| 276 | 'name' => 'table_odd_background_normal', |
| 277 | 'selector' => '{{WRAPPER}} tr:nth-child(2n+1)', |
| 278 | 'separator' => 'none' |
| 279 | ) |
| 280 | ); |
| 281 | |
| 282 | $this->add_control( |
| 283 | 'table_odd_row_color', |
| 284 | array( |
| 285 | 'label' => __( 'Color', 'auxin-elements' ), |
| 286 | 'type' => Controls_Manager::COLOR, |
| 287 | 'selectors' => array( |
| 288 | '{{WRAPPER}} {{WRAPPER}} tr:nth-child(2n+1)' => 'color:{{VALUE}};' |
| 289 | ) |
| 290 | ) |
| 291 | ); |
| 292 | |
| 293 | $this->end_controls_section(); |
| 294 | |
| 295 | $this->start_controls_section( |
| 296 | 'table_even_row_section', |
| 297 | array( |
| 298 | 'label' => __( 'Table Even Rows', 'auxin-elements' ), |
| 299 | 'tab' => Controls_Manager::TAB_STYLE |
| 300 | ) |
| 301 | ); |
| 302 | |
| 303 | $this->add_group_control( |
| 304 | Group_Control_Background::get_type(), |
| 305 | array( |
| 306 | 'name' => 'table_even_row_background_normal', |
| 307 | 'selector' => '{{WRAPPER}} tr:nth-child(2n)', |
| 308 | 'separator' => 'none' |
| 309 | ) |
| 310 | ); |
| 311 | |
| 312 | $this->add_control( |
| 313 | 'table_even_row_color', |
| 314 | array( |
| 315 | 'label' => __( 'Color', 'auxin-elements' ), |
| 316 | 'type' => Controls_Manager::COLOR, |
| 317 | 'selectors' => array( |
| 318 | '{{WRAPPER}} {{WRAPPER}} tr:nth-child(2n)' => 'color:{{VALUE}};' |
| 319 | ) |
| 320 | ) |
| 321 | ); |
| 322 | |
| 323 | $this->end_controls_section(); |
| 324 | } |
| 325 | |
| 326 | /** |
| 327 | * Render 'Tabs' widget output on the frontend. |
| 328 | * |
| 329 | * Written in PHP and used to generate the final HTML. |
| 330 | * |
| 331 | * @since 1.0.0 |
| 332 | * @access protected |
| 333 | */ |
| 334 | protected function render() { |
| 335 | |
| 336 | $settings = $this->get_settings_for_display(); |
| 337 | |
| 338 | $this->add_render_attribute( 'wrapper', 'class', 'widget-container aux-widget-responsive-table' ); |
| 339 | $this->add_render_attribute( 'inner', 'class', 'widget-inner' ); |
| 340 | |
| 341 | ?> |
| 342 | <div <?php echo $this->get_render_attribute_string( 'wrapper' ); ?> > |
| 343 | <div <?php echo $this->get_render_attribute_string( 'inner' ); ?> > |
| 344 | <?php echo wp_kses_post( $settings['table_markup'] );?> |
| 345 | </div> |
| 346 | </div> |
| 347 | <?php |
| 348 | } |
| 349 | |
| 350 | |
| 351 | /** |
| 352 | * Render responsive table element in the editor. |
| 353 | * |
| 354 | * @access protected |
| 355 | */ |
| 356 | protected function content_template() { |
| 357 | ?> |
| 358 | <div class="widget-container widget-responsive-table"> |
| 359 | <div class="widget-inner"> |
| 360 | {{{ settings.table_markup }}} |
| 361 | </div> |
| 362 | </div> |
| 363 | <?php |
| 364 | } |
| 365 | |
| 366 | } |
| 367 |