From 65bb46db69adde6f442c36fbeb212589b1df7733 Mon Sep 17 00:00:00 2001 From: Saiful Islam Date: Wed, 3 Feb 2021 22:26:30 +0600 Subject: [PATCH] Control for color and Typography for table is added --- modules/elementor-widget.php | 225 +++++++++++++++++++++++++++++------ 1 file changed, 190 insertions(+), 35 deletions(-) diff --git a/modules/elementor-widget.php b/modules/elementor-widget.php index b98e9aa6..9440399f 100644 --- a/modules/elementor-widget.php +++ b/modules/elementor-widget.php @@ -1,4 +1,15 @@ start_controls_section( - 'content_section', + //For General/Content Tab + $this->content_general(); + + //For Typography Section Style Tab + $this->style_table_head(); + + //For Typography Section Style Tab + $this->style_table_body(); + + + } + + /** + * Render oEmbed widget output on the frontend. + * + * Written in PHP and used to generate the final HTML. + * + * @since 1.0.0 + * @access protected + */ + protected function render() { + $settings = $this->get_settings_for_display(); + $table_id = isset( $settings['table_id'] ) && !empty( $settings['table_id'] ) ? $settings['table_id'] : false; + if( $table_id && is_numeric( $table_id ) ){ + $name = get_the_title( $table_id ); + $shortcode = "[Product_Table id='{$table_id}' name='{$name}']"; + $shortcode = do_shortcode( shortcode_unautop( $shortcode ) ); + ?> +
+ +
+ '; + echo esc_html__( 'Please select a Table.', 'wpt_pro' ); + echo ''; + } + } + + protected function content_general() { + $this->start_controls_section( + 'general', [ - 'label' => __( 'Content', 'wpt_pro' ), - 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, + 'label' => __( 'General', 'wpt_pro' ), + 'tab' => Controls_Manager::TAB_CONTENT, ] ); @@ -94,7 +145,7 @@ protected function _register_controls() { //$table_options[''] = esc_html__( 'Please Choose a Table', 'wpt_pro' ); else: $table_options = false; - //\Elementor\Controls_Manager::HEADING + //Controls_Manager::HEADING endif; @@ -105,7 +156,7 @@ protected function _register_controls() { 'table_id', [ 'label' => __( 'Table List', 'wpt_pro' ), - 'type' => \Elementor\Controls_Manager::SELECT, + 'type' => Controls_Manager::SELECT, 'options' => $table_options, //'default' => '', ] @@ -115,7 +166,7 @@ protected function _register_controls() { 'table_edit', [ 'label' => __( 'Additional Info', 'wpt_pro' ), - 'type' => \Elementor\Controls_Manager::RAW_HTML, + 'type' => Controls_Manager::RAW_HTML, 'raw' => sprintf( __( 'Edit your %sTable%s.', 'wpt_pro' ), '', @@ -133,7 +184,7 @@ protected function _register_controls() { 'table_notification', [ 'label' => __( 'Additional Information', 'wpt_pro' ), - 'type' => \Elementor\Controls_Manager::RAW_HTML, + 'type' => Controls_Manager::RAW_HTML, 'raw' => $wpt_extra_msg . sprintf( __( 'Create %sa new table%s.', 'wpt_pro' ), '', @@ -145,33 +196,137 @@ protected function _register_controls() { $this->end_controls_section(); - } + } + + /** + * Typography Section for Style Tab + * + * @since 1.0.0.9 + */ + protected function style_table_head() { + $this->start_controls_section( + 'thead', + [ + 'label' => esc_html__( 'Table Head', 'medilac' ), + 'tab' => Controls_Manager::TAB_STYLE, + ] + ); - /** - * Render oEmbed widget output on the frontend. - * - * Written in PHP and used to generate the final HTML. - * - * @since 1.0.0 - * @access protected - */ - protected function render() { - $settings = $this->get_settings_for_display(); - $table_id = isset( $settings['table_id'] ) && !empty( $settings['table_id'] ) ? $settings['table_id'] : false; - if( $table_id && is_numeric( $table_id ) ){ - $name = get_the_title( $table_id ); - $shortcode = "[Product_Table id='{$table_id}' name='{$name}']"; - $shortcode = do_shortcode( shortcode_unautop( $shortcode ) ); - ?> -
- -
- '; - echo esc_html__( 'Please select a Table.', 'wpt_pro' ); - echo ''; - } - } + $this->add_group_control( + Group_Control_Typography::get_type(), + [ + 'name' => 'thead_typography', + 'global' => [ + 'default' => Global_Typography::TYPOGRAPHY_PRIMARY, + ], + 'selector' => '{{WRAPPER}} table.wpt_product_table thead tr th', + ] + ); + + $this->add_control( + 'thead-color', + [ + 'label' => __( 'Color', 'medilac' ), + 'type' => Controls_Manager::COLOR, + 'selectors' => [ + '{{WRAPPER}} table.wpt_product_table thead tr th' => 'color: {{VALUE}}', + ], + 'default' => '#ffffff', + ] + ); + + $this->add_control( + 'thead-bg-color', + [ + 'label' => __( 'Background Color', 'medilac' ), + 'type' => Controls_Manager::COLOR, + 'selectors' => [ + '{{WRAPPER}} table.wpt_product_table thead tr th' => 'background-color: {{VALUE}}', + ], + 'default' => '#0a7f9c', + ] + ); + + + + $this->end_controls_section(); + } + + + + /** + * Typography Section for Style Tab + * + * @since 1.0.0.9 + */ + protected function style_table_body() { + + + $this->start_controls_section( + 'tbody', + [ + 'label' => esc_html__( 'Table Body', 'medilac' ), + 'tab' => Controls_Manager::TAB_STYLE, + ] + ); + + $this->add_group_control( + Group_Control_Typography::get_type(), + [ + 'name' => 'tbody_typography', + 'global' => [ + 'default' => Global_Typography::TYPOGRAPHY_PRIMARY, + ], + 'selectors' => [ + '{{WRAPPER}} table.wpt_product_table tbody tr td', + '{{WRAPPER}} table.wpt_product_table tbody tr td a', + '{{WRAPPER}} table.wpt_product_table tbody tr td p', + '{{WRAPPER}} table.wpt_product_table tbody tr td div', + ], + ] + ); + + $this->add_control( + 'tbody-text-color', + [ + 'label' => __( 'Text Color', 'medilac' ), + 'type' => Controls_Manager::COLOR, + 'selectors' => [ + '{{WRAPPER}} table.wpt_product_table tbody tr td' => 'color: {{VALUE}}', + '{{WRAPPER}} table.wpt_product_table tbody tr td p' => 'color: {{VALUE}}', + '{{WRAPPER}} table.wpt_product_table tbody tr td div' => 'color: {{VALUE}}', + ], + 'default' => '#535353', + ] + ); + + $this->add_control( + 'tbody-title-color', + [ + 'label' => __( 'Product Title Color', 'medilac' ), + 'type' => Controls_Manager::COLOR, + 'selectors' => [ + '{{WRAPPER}} table.wpt_product_table tbody tr td .product_title a' => 'color: {{VALUE}}', + ], + 'default' => '#000', + ] + ); + + + $this->add_control( + 'tbody-bg-color', + [ + 'label' => __( 'Background Color', 'medilac' ), + 'type' => Controls_Manager::COLOR, + 'selectors' => [ + '{{WRAPPER}} table.wpt_product_table tbody tr td' => 'background-color: {{VALUE}}', + ], + //'default' => '#fff', + ] + ); + + $this->end_controls_section(); + } + } \ No newline at end of file