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