From ae22572a729441810a83cbfd3e6d764cc7122605 Mon Sep 17 00:00:00 2001 From: "DESKTOP-JPPL11C\\chris" Date: Mon, 26 Feb 2024 16:44:37 +0200 Subject: [PATCH 1/7] table widget --- includes/managers/widgets.php | 1 + includes/widgets/testOne.php | 289 ++++++++++++++++++++++++++++++++++ 2 files changed, 290 insertions(+) create mode 100644 includes/widgets/testOne.php diff --git a/includes/managers/widgets.php b/includes/managers/widgets.php index b447f34c4f2b..43f48f4e3cc2 100644 --- a/includes/managers/widgets.php +++ b/includes/managers/widgets.php @@ -63,6 +63,7 @@ private function init_widgets() { 'common', 'inner-section', 'heading', + 'testOne', 'image', 'text-editor', 'video', diff --git a/includes/widgets/testOne.php b/includes/widgets/testOne.php new file mode 100644 index 000000000000..cdc24056e86d --- /dev/null +++ b/includes/widgets/testOne.php @@ -0,0 +1,289 @@ + ! Utils::has_pro(), + 'image' => esc_url( ELEMENTOR_ASSETS_URL . 'images/go-pro.svg' ), + 'image_alt' => esc_attr__( 'Upgrade', 'elementor' ), + 'description' => esc_html__( 'Create captivating testOnes that rotate with the Animated Headline Widget.', 'elementor' ), + 'upgrade_url' => esc_url( 'https://go.elementor.com/go-pro-testOne-widget/' ), + 'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ), + ]; + } + + /** + * Register testOne widget controls. + * + * Adds different input fields to allow the user to change and customize the widget settings. + * + * @since 3.1.0 + * @access protected + */ + protected function register_controls() { + + $this->start_controls_section( + 'content_section', + [ + 'label' => esc_html__( 'table content', 'textdomain' ), + 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, + ] + ); + + $this->add_control( + 'show_title', + [ + 'label' => esc_html__( 'Show Columns Titles', 'textdomain' ), + 'type' => \Elementor\Controls_Manager::SWITCHER, + 'label_on' => esc_html__( 'Show', 'textdomain' ), + 'label_off' => esc_html__( 'Hide', 'textdomain' ), + 'return_value' => 'yes', + 'default' => 'yes', + ] + ); + + $this->add_control( + 'columnOne', + [ + 'label' => esc_html__( 'Title column 1', 'elementor' ), + 'type' => Controls_Manager::TEXT, + 'label_block' => true, + 'placeholder' => esc_html__( 'Enter column title', 'elementor' ), + 'default' => esc_html__( 'Column title', 'elementor' ), + 'dynamic' => [ + 'active' => true, + ], + ] + ); + + $this->add_control( + 'columnTwo', + [ + 'label' => esc_html__( 'Title column 2', 'elementor' ), + 'type' => Controls_Manager::TEXT, + 'label_block' => true, + 'placeholder' => esc_html__( 'Enter column title', 'elementor' ), + 'default' => esc_html__( 'Column title', 'elementor' ), + 'dynamic' => [ + 'active' => true, + ], + ] + ); + $this->add_control( + 'columnThree', + [ + 'label' => esc_html__( 'Title column 3', 'elementor' ), + 'type' => Controls_Manager::TEXT, + 'label_block' => true, + 'placeholder' => esc_html__( 'enter column title', 'elementor' ), + 'default' => esc_html__( 'Column title', 'elementor' ), + 'dynamic' => [ + 'active' => true, + ], + ] + ); + + $repeater = new repeater(); + + $repeater->add_control( + 'text', + [ + 'label' => esc_html__( 'Text', 'elementor' ), + 'type' => Controls_Manager::TEXT, + 'label_block' => true, + 'placeholder' => esc_html__( 'List Item', 'elementor' ), + 'default' => esc_html__( 'List Item', 'elementor' ), + 'dynamic' => [ + 'active' => true, + ], + ] + ); + + $this->add_control( + 'list', + [ + 'label' => esc_html__( 'Columns contents', 'textdomain' ), + 'show_label' => esc_html__( true, 'textdomain' ), + 'type' => \Elementor\Controls_Manager::REPEATER, + 'fields' => $repeater->get_controls(), + 'default' => [ + [ + 'list_title' => esc_html__( 'Content column 1', 'textdomain' ), + 'list_content' => esc_html__( 'Item content. Click the edit button to change this text.', 'textdomain' ), + ], + [ + 'list_title' => esc_html__( 'Content column 2', 'textdomain' ), + 'list_content' => esc_html__( 'Item content. Click the edit button to change this text.', 'textdomain' ), + ], + [ + 'list_title' => esc_html__( 'Content column 3', 'textdomain' ), + 'list_content' => esc_html__( 'Item content. Click the edit button to change this text.', 'textdomain' ), + ], + ], + 'title_field' => '{{{ list_title }}}', + ] + ); + + + + $this->end_controls_section(); + } + + /** + * Render testOne 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(); + + echo ''; + if ( 'yes' === $settings['show_title'] ) { + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + if ( $settings['list'] ) { + echo ''; + foreach ( $settings['list'] as $item ) { + echo ''; + // echo '
' . $item['list_content'] . '
'; + } + echo ''; + } + echo '
' . $settings['columnOne'] . '' . $settings['columnTwo'] . '' . $settings['columnThree'] . '
' . $item['list_title'] . '
'; + } + + protected function content_template() { + ?> + + + <# if ( 'yes' === settings.show_title ) { #> + + + + + + + <# } #> + + <# if ( settings.list.length ) { #> + + <# _.each( settings.list, function( item ) { #> + + + <# }); #> + + <# } #> +
{{{ settings.columnOne }}}{{{ settings.columnTwo }}}{{{ settings.columnThree }}}
{{{ item.list_title }}}
+ Date: Thu, 4 Apr 2024 19:19:11 +0200 Subject: [PATCH 2/7] changing file and class name, fixing typos --- includes/managers/widgets.php | 2 +- includes/widgets/{testOne.php => table.php} | 122 ++++++++++---------- package-lock.json | 2 +- package.json | 2 +- 4 files changed, 64 insertions(+), 64 deletions(-) rename includes/widgets/{testOne.php => table.php} (60%) diff --git a/includes/managers/widgets.php b/includes/managers/widgets.php index 43f48f4e3cc2..7928b8bc14f5 100644 --- a/includes/managers/widgets.php +++ b/includes/managers/widgets.php @@ -63,7 +63,7 @@ private function init_widgets() { 'common', 'inner-section', 'heading', - 'testOne', + 'table', 'image', 'text-editor', 'video', diff --git a/includes/widgets/testOne.php b/includes/widgets/table.php similarity index 60% rename from includes/widgets/testOne.php rename to includes/widgets/table.php index cdc24056e86d..73a829d8da05 100644 --- a/includes/widgets/testOne.php +++ b/includes/widgets/table.php @@ -5,22 +5,21 @@ exit; // Exit if accessed directly. } -use Elementor\Core\Kits\Documents\Tabs\Global_Colors; + use Elementor\Core\Kits\Documents\Tabs\Global_Typography; /** - * Elementor testOne widget. + * Elementor table widget. * - * Elementor widget that displays an eye-catching headlines. * * @since 1.0.0 */ -class Widget_testOne extends Widget_Base { +class Widget_Table extends Widget_Base { /** * Get widget name. * - * Retrieve testOne widget name. + * Retrieve table widget name. * * @since 1.0.0 * @access public @@ -28,13 +27,13 @@ class Widget_testOne extends Widget_Base { * @return string Widget name. */ public function get_name() { - return 'testOne'; + return 'table'; } /** * Get widget title. * - * Retrieve testOne widget title. + * Retrieve table widget title. * * @since 1.0.0 * @access public @@ -42,13 +41,13 @@ public function get_name() { * @return string Widget title. */ public function get_title() { - return esc_html__( 'testOne', 'elementor' ); + return esc_html__( 'table', 'elementor' ); } /** * Get widget icon. * - * Retrieve testOne widget icon. + * Retrieve table widget icon. * * @since 1.0.0 * @access public @@ -56,13 +55,13 @@ public function get_title() { * @return string Widget icon. */ public function get_icon() { - return 'eicon-code'; + return 'eicon-table'; } /** * Get widget categories. * - * Retrieve the list of categories the testOne widget belongs to. + * Retrieve the list of categories the table widget belongs to. * * Used to determine where to display the widget in the editor. * @@ -86,7 +85,7 @@ public function get_categories() { * @return array Widget keywords. */ public function get_keywords() { - return [ 'testOne', 'title', 'text' ]; + return [ 'table', 'title', 'text' ]; } /** @@ -104,14 +103,14 @@ protected function get_upsale_data() { 'condition' => ! Utils::has_pro(), 'image' => esc_url( ELEMENTOR_ASSETS_URL . 'images/go-pro.svg' ), 'image_alt' => esc_attr__( 'Upgrade', 'elementor' ), - 'description' => esc_html__( 'Create captivating testOnes that rotate with the Animated Headline Widget.', 'elementor' ), - 'upgrade_url' => esc_url( 'https://go.elementor.com/go-pro-testOne-widget/' ), + 'description' => esc_html__( 'Create captivating tables that rotate with the Animated Headline Widget.', 'elementor' ), + 'upgrade_url' => esc_url( 'https://go.elementor.com/go-pro-table-widget/' ), 'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ), ]; } /** - * Register testOne widget controls. + * Register table widget controls. * * Adds different input fields to allow the user to change and customize the widget settings. * @@ -123,7 +122,7 @@ protected function register_controls() { $this->start_controls_section( 'content_section', [ - 'label' => esc_html__( 'table content', 'textdomain' ), + 'label' => esc_html__( 'Table content', 'elementor' ), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); @@ -131,23 +130,22 @@ protected function register_controls() { $this->add_control( 'show_title', [ - 'label' => esc_html__( 'Show Columns Titles', 'textdomain' ), + 'label' => esc_html__( 'Show Columns Titles', 'elementor' ), 'type' => \Elementor\Controls_Manager::SWITCHER, - 'label_on' => esc_html__( 'Show', 'textdomain' ), - 'label_off' => esc_html__( 'Hide', 'textdomain' ), + 'label_on' => esc_html__( 'Show', 'elementor' ), + 'label_off' => esc_html__( 'Hide', 'elementor' ), 'return_value' => 'yes', 'default' => 'yes', ] ); $this->add_control( - 'columnOne', + 'column_one', [ 'label' => esc_html__( 'Title column 1', 'elementor' ), 'type' => Controls_Manager::TEXT, 'label_block' => true, 'placeholder' => esc_html__( 'Enter column title', 'elementor' ), - 'default' => esc_html__( 'Column title', 'elementor' ), 'dynamic' => [ 'active' => true, ], @@ -155,26 +153,24 @@ protected function register_controls() { ); $this->add_control( - 'columnTwo', + 'column_two', [ 'label' => esc_html__( 'Title column 2', 'elementor' ), 'type' => Controls_Manager::TEXT, 'label_block' => true, 'placeholder' => esc_html__( 'Enter column title', 'elementor' ), - 'default' => esc_html__( 'Column title', 'elementor' ), 'dynamic' => [ 'active' => true, ], ] ); $this->add_control( - 'columnThree', + 'column_three', [ 'label' => esc_html__( 'Title column 3', 'elementor' ), 'type' => Controls_Manager::TEXT, 'label_block' => true, - 'placeholder' => esc_html__( 'enter column title', 'elementor' ), - 'default' => esc_html__( 'Column title', 'elementor' ), + 'placeholder' => esc_html__( 'Enter column title', 'elementor' ), 'dynamic' => [ 'active' => true, ], @@ -188,7 +184,7 @@ protected function register_controls() { [ 'label' => esc_html__( 'Text', 'elementor' ), 'type' => Controls_Manager::TEXT, - 'label_block' => true, + 'label_block' => false, 'placeholder' => esc_html__( 'List Item', 'elementor' ), 'default' => esc_html__( 'List Item', 'elementor' ), 'dynamic' => [ @@ -200,25 +196,25 @@ protected function register_controls() { $this->add_control( 'list', [ - 'label' => esc_html__( 'Columns contents', 'textdomain' ), - 'show_label' => esc_html__( true, 'textdomain' ), + 'label' => esc_html__( 'Columns contents', 'elementor' ), + 'show_label' => esc_html__( true, 'elementor' ), 'type' => \Elementor\Controls_Manager::REPEATER, 'fields' => $repeater->get_controls(), 'default' => [ [ - 'list_title' => esc_html__( 'Content column 1', 'textdomain' ), - 'list_content' => esc_html__( 'Item content. Click the edit button to change this text.', 'textdomain' ), + 'list_title' => esc_html__( 'Content column 1', 'elementor' ), + 'list_content' => esc_html__( 'Item content. Click the edit button to change this text.', 'elementor' ), ], [ - 'list_title' => esc_html__( 'Content column 2', 'textdomain' ), - 'list_content' => esc_html__( 'Item content. Click the edit button to change this text.', 'textdomain' ), + 'list_title' => esc_html__( 'Content column 2', 'elementor' ), + 'list_content' => esc_html__( 'Item content. Click the edit button to change this text.', 'elementor' ), ], [ - 'list_title' => esc_html__( 'Content column 3', 'textdomain' ), - 'list_content' => esc_html__( 'Item content. Click the edit button to change this text.', 'textdomain' ), + 'list_title' => esc_html__( 'Content column 3', 'elementor' ), + 'list_content' => esc_html__( 'Item content. Click the edit button to change this text.', 'elementor' ), ], ], - 'title_field' => '{{{ list_title }}}', + ] ); @@ -228,7 +224,7 @@ protected function register_controls() { } /** - * Render testOne widget output on the frontend. + * Render table widget output on the frontend. * * Written in PHP and used to generate the final HTML. * @@ -241,21 +237,23 @@ protected function render() { echo ''; if ( 'yes' === $settings['show_title'] ) { - - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; } if ( $settings['list'] ) { - echo ''; - foreach ( $settings['list'] as $item ) { - echo ''; - // echo '
' . $item['list_content'] . '
'; - } - echo ''; + echo ''; + echo ''; + foreach ( $settings['list'] as $item ) { + echo ''; + } + echo ''; + echo ''; } echo '
' . $settings['columnOne'] . '' . $settings['columnTwo'] . '' . $settings['columnThree'] . '
' . $settings['column_one'] . '' . $settings['column_two'] . '' . $settings['column_three'] . '
' . $item['list_title'] . '
' . $item['list_title'] . '
'; } @@ -265,21 +263,23 @@ protected function content_template() { <# if ( 'yes' === settings.show_title ) { #> - - - - - - + + + + + + + <# } #> <# if ( settings.list.length ) { #> - - <# _.each( settings.list, function( item ) { #> - - - <# }); #> - + + + <# _.each( settings.list, function( item ) { #> + + <# }); #> + + <# } #>
{{{ settings.columnOne }}}{{{ settings.columnTwo }}}{{{ settings.columnThree }}}
{{{ settings.column_one }}}{{{ settings.column_two }}}{{{ settings.column_three }}}
{{{ item.list_title }}}
{{{item.list_title}}}
Date: Tue, 9 Apr 2024 17:13:02 +0200 Subject: [PATCH 3/7] adding javascript,fixing row's creations issues --- includes/widgets/table.php | 181 ++++++++++++++++++++++++++----------- package-lock.json | 2 +- package.json | 2 +- 3 files changed, 130 insertions(+), 55 deletions(-) diff --git a/includes/widgets/table.php b/includes/widgets/table.php index 73a829d8da05..16636eb420d0 100644 --- a/includes/widgets/table.php +++ b/includes/widgets/table.php @@ -41,7 +41,7 @@ public function get_name() { * @return string Widget title. */ public function get_title() { - return esc_html__( 'table', 'elementor' ); + return esc_html__( 'Table', 'elementor' ); } /** @@ -85,7 +85,7 @@ public function get_categories() { * @return array Widget keywords. */ public function get_keywords() { - return [ 'table', 'title', 'text' ]; + return [ 'table']; } /** @@ -103,7 +103,7 @@ protected function get_upsale_data() { 'condition' => ! Utils::has_pro(), 'image' => esc_url( ELEMENTOR_ASSETS_URL . 'images/go-pro.svg' ), 'image_alt' => esc_attr__( 'Upgrade', 'elementor' ), - 'description' => esc_html__( 'Create captivating tables that rotate with the Animated Headline Widget.', 'elementor' ), + 'description' => esc_html__( 'Create captivating tables.', 'elementor' ), 'upgrade_url' => esc_url( 'https://go.elementor.com/go-pro-table-widget/' ), 'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ), ]; @@ -213,13 +213,10 @@ protected function register_controls() { 'list_title' => esc_html__( 'Content column 3', 'elementor' ), 'list_content' => esc_html__( 'Item content. Click the edit button to change this text.', 'elementor' ), ], - ], - + ] ] ); - - $this->end_controls_section(); } @@ -233,57 +230,135 @@ protected function register_controls() { */ protected function render() { - $settings = $this->get_settings_for_display(); + $settings = $this->get_settings_for_display(); - echo ''; - if ( 'yes' === $settings['show_title'] ) { - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - } + echo '
' . $settings['column_one'] . '' . $settings['column_two'] . '' . $settings['column_three'] . '
'; + if ( 'yes' === $settings['show_title'] ) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } if ( $settings['list'] ) { - echo ''; - echo ''; - foreach ( $settings['list'] as $item ) { - echo ''; - } - echo ''; - echo ''; - } + $list = $settings['list']; + echo ''; + $count; + if (count($list) % 3 == 0) { + for ($i = 0; $i < count($list)-1; $i += 3) { + $count=$i + 3; + + echo ''; + for ($j = $i; $j < $count; $j++) { + echo ''; + } + echo ''; + } + + } else { + if (count($list) % 3 == 1) { + for ($i = 0; $i < count($list) - 2; $i += 3){ + $count=$i + 3; + + echo ''; + for ($j = $i; $j < $count; $j++){ + echo ''; + } + echo ''; + } + echo ''; + echo ''; + echo ''; + + } else { + for ($i = 0; $i < count($list) - 3; $i += 3){ + $count=$i + 3; + + echo ''; + for ($j = $i; $j < $count; $j++){ + echo ''; + } + echo ''; + } + echo ''; + echo ''; + echo ''; + echo ''; + }; + }; + echo ''; + }; echo '
' . $settings['column_one'] . '' . $settings['column_two'] . '' . $settings['column_three'] . '
' . $item['list_title'] . '
' . $list[$j]['text'] . '
' . $list[$j]['text'] . '
' . $list[$count]['text'] . '
' . $list[$j]['text'] . '
' . $list[$count]['text'] . '' . $list[$count + 1]['text'] . '
'; - } + } + - protected function content_template() { - ?> - - - <# if ( 'yes' === settings.show_title ) { #> - - - - - - - - <# } #> + protected function content_template() { + ?> - <# if ( settings.list.length ) { #> - - - <# _.each( settings.list, function( item ) { #> - - <# }); #> - - - <# } #> -
{{{ settings.column_one }}}{{{ settings.column_two }}}{{{ settings.column_three }}}
{{{item.list_title}}}
- + <# if ( 'yes' === settings.show_title ) { #> + + + {{{ settings.column_one }}} + {{{ settings.column_two }}} + {{{ settings.column_three }}} + + + <# } #> + + <# if ( settings.list.length ) { #> + <# let list = settings.list #> + <# let count; #> + + <# if(list.length % 3 == 0){ #> + + <# for(let i = 0; i < list.length - 1; i+=3){ #> + <# count = i + 3 #> + + <# for(let j = i; j < count; j++){ #> + {{{list[j].text}}} + <# } #> + + <# } #> + + <# } else { #> + + <# if (list.length % 3 == 1){ #> + <# for(let i = 0; i < list.length - 2; i+= 3){ #> + <# count = i + 3 #> + + <# for(let j = i; j < count; j++){ #> + {{{list[j].text}}} + <# } #> + + <# } #> + + {{{list[count].text}}} + + <# } else { #> + <# for(let i = 0; i < list.length - 3; i+= 3){ #> + <# count = i + 3 #> + + <# for(let j = i; j < count; j++){ #> + {{{list[j].text}}} + <#}#> + + <# } #> + + {{{list[count].text}}} + {{{list[count + 1].text}}} + + <# } #> + <# } #> + + + + <# } #> + + Date: Tue, 9 Apr 2024 18:41:34 +0200 Subject: [PATCH 4/7] renaming the repeater from list to row, renaming the 'list' variables to row --- includes/widgets/table.php | 84 +++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/includes/widgets/table.php b/includes/widgets/table.php index 16636eb420d0..3b332a2f4ee7 100644 --- a/includes/widgets/table.php +++ b/includes/widgets/table.php @@ -182,11 +182,11 @@ protected function register_controls() { $repeater->add_control( 'text', [ - 'label' => esc_html__( 'Text', 'elementor' ), + 'label' => esc_html__( 'Row', 'elementor' ), 'type' => Controls_Manager::TEXT, 'label_block' => false, - 'placeholder' => esc_html__( 'List Item', 'elementor' ), - 'default' => esc_html__( 'List Item', 'elementor' ), + 'placeholder' => esc_html__( 'row content', 'elementor' ), + 'default' => esc_html__( 'column content', 'elementor' ), 'dynamic' => [ 'active' => true, ], @@ -194,7 +194,7 @@ protected function register_controls() { ); $this->add_control( - 'list', + 'row', [ 'label' => esc_html__( 'Columns contents', 'elementor' ), 'show_label' => esc_html__( true, 'elementor' ), @@ -202,16 +202,16 @@ protected function register_controls() { 'fields' => $repeater->get_controls(), 'default' => [ [ - 'list_title' => esc_html__( 'Content column 1', 'elementor' ), - 'list_content' => esc_html__( 'Item content. Click the edit button to change this text.', 'elementor' ), + 'row_title' => esc_html__( 'Content column 1', 'elementor' ), + 'row_content' => esc_html__( 'Item content. Click the edit button to change this text.', 'elementor' ), ], [ - 'list_title' => esc_html__( 'Content column 2', 'elementor' ), - 'list_content' => esc_html__( 'Item content. Click the edit button to change this text.', 'elementor' ), + 'row_title' => esc_html__( 'Content column 2', 'elementor' ), + 'row_content' => esc_html__( 'Item content. Click the edit button to change this text.', 'elementor' ), ], [ - 'list_title' => esc_html__( 'Content column 3', 'elementor' ), - 'list_content' => esc_html__( 'Item content. Click the edit button to change this text.', 'elementor' ), + 'row_title' => esc_html__( 'Content column 3', 'elementor' ), + 'row_content' => esc_html__( 'Item content. Click the edit button to change this text.', 'elementor' ), ], ] ] @@ -243,55 +243,55 @@ protected function render() { echo ''; } - if ( $settings['list'] ) { - $list = $settings['list']; + if ( $settings['row'] ) { + $row = $settings['row']; echo ''; $count; - if (count($list) % 3 == 0) { - for ($i = 0; $i < count($list)-1; $i += 3) { + if (count($row) % 3 == 0) { + for ($i = 0; $i < count($row)-1; $i += 3) { $count=$i + 3; echo ''; for ($j = $i; $j < $count; $j++) { - echo '' . $list[$j]['text'] . ''; + echo '' . $row[$j]['text'] . ''; } echo ''; } } else { - if (count($list) % 3 == 1) { - for ($i = 0; $i < count($list) - 2; $i += 3){ + if (count($row) % 3 == 1) { + for ($i = 0; $i < count($row) - 2; $i += 3){ $count=$i + 3; echo ''; for ($j = $i; $j < $count; $j++){ - echo '' . $list[$j]['text'] . ''; + echo '' . $row[$j]['text'] . ''; } echo ''; } - echo ''; - echo '' . $list[$count]['text'] . ''; - echo ''; + echo ''; + echo '' . $row[$count]['text'] . ''; + echo ''; } else { - for ($i = 0; $i < count($list) - 3; $i += 3){ + for ($i = 0; $i < count($row) - 3; $i += 3){ $count=$i + 3; echo ''; for ($j = $i; $j < $count; $j++){ - echo '' . $list[$j]['text'] . ''; + echo '' . $row[$j]['text'] . ''; } echo ''; } - echo ''; - echo '' . $list[$count]['text'] . ''; - echo '' . $list[$count + 1]['text'] . ''; - echo ''; + echo ''; + echo '' . $row[$count]['text'] . ''; + echo '' . $row[$count + 1]['text'] . ''; + echo ''; }; }; - echo ''; + echo ''; }; - echo ''; + echo ''; } @@ -309,47 +309,47 @@ protected function content_template() { <# } #> - <# if ( settings.list.length ) { #> - <# let list = settings.list #> + <# if ( settings.row.length ) { #> + <# let row = settings.row #> <# let count; #> - <# if(list.length % 3 == 0){ #> + <# if(row.length % 3 == 0){ #> - <# for(let i = 0; i < list.length - 1; i+=3){ #> + <# for(let i = 0; i < row.length - 1; i+= 3){ #> <# count = i + 3 #> <# for(let j = i; j < count; j++){ #> - {{{list[j].text}}} + {{{row[j].text}}} <# } #> <# } #> <# } else { #> - <# if (list.length % 3 == 1){ #> - <# for(let i = 0; i < list.length - 2; i+= 3){ #> + <# if (row.length % 3 == 1){ #> + <# for(let i = 0; i < row.length - 2; i+= 3){ #> <# count = i + 3 #> <# for(let j = i; j < count; j++){ #> - {{{list[j].text}}} + {{{row[j].text}}} <# } #> <# } #> - {{{list[count].text}}} + {{{row[count].text}}} <# } else { #> - <# for(let i = 0; i < list.length - 3; i+= 3){ #> + <# for(let i = 0; i < row.length - 3; i+= 3){ #> <# count = i + 3 #> <# for(let j = i; j < count; j++){ #> - {{{list[j].text}}} + {{{row[j].text}}} <#}#> <# } #> - {{{list[count].text}}} - {{{list[count + 1].text}}} + {{{row[count].text}}} + {{{row[count + 1].text}}} <# } #> <# } #> From ff5fd7fc555be5dbf94572362915eda634b70fab Mon Sep 17 00:00:00 2001 From: christian Date: Wed, 10 Apr 2024 22:05:05 +0200 Subject: [PATCH 5/7] restructuring the rows, adding javascript --- includes/widgets/table.php | 158 ++++++++++--------------------------- 1 file changed, 41 insertions(+), 117 deletions(-) diff --git a/includes/widgets/table.php b/includes/widgets/table.php index 3b332a2f4ee7..dc9a722fc525 100644 --- a/includes/widgets/table.php +++ b/includes/widgets/table.php @@ -177,43 +177,38 @@ protected function register_controls() { ] ); - $repeater = new repeater(); - - $repeater->add_control( - 'text', - [ - 'label' => esc_html__( 'Row', 'elementor' ), - 'type' => Controls_Manager::TEXT, - 'label_block' => false, - 'placeholder' => esc_html__( 'row content', 'elementor' ), - 'default' => esc_html__( 'column content', 'elementor' ), - 'dynamic' => [ - 'active' => true, - ], - ] - ); - + $this->add_control( - 'row', + 'rows', [ - 'label' => esc_html__( 'Columns contents', 'elementor' ), + 'label' => esc_html__( "Rows' contents", 'elementor' ), 'show_label' => esc_html__( true, 'elementor' ), 'type' => \Elementor\Controls_Manager::REPEATER, - 'fields' => $repeater->get_controls(), - 'default' => [ + 'fields' => [ [ - 'row_title' => esc_html__( 'Content column 1', 'elementor' ), - 'row_content' => esc_html__( 'Item content. Click the edit button to change this text.', 'elementor' ), + 'name' => 'column_content_one', + 'label' => esc_html__( 'Content column 1', 'elementor' ), + 'type' => \Elementor\Controls_Manager::TEXT, + 'default' => esc_html__( 'Content column 1' , 'elementor' ), + 'label_block' => false, ], [ - 'row_title' => esc_html__( 'Content column 2', 'elementor' ), - 'row_content' => esc_html__( 'Item content. Click the edit button to change this text.', 'elementor' ), + 'name' => 'column_content_two', + 'label' => esc_html__( 'column content 2', 'elementor' ), + 'type' => \Elementor\Controls_Manager::TEXT, + 'default' => esc_html__( 'Content column 2' , 'elementor' ), + 'label_block' => false, ], [ - 'row_title' => esc_html__( 'Content column 3', 'elementor' ), - 'row_content' => esc_html__( 'Item content. Click the edit button to change this text.', 'elementor' ), + 'name' => 'column_content_three', + 'label' => esc_html__( 'column content 3', 'elementor' ), + 'type' => \Elementor\Controls_Manager::TEXT, + 'default' => esc_html__( 'Content column 3' , 'elementor' ), + 'label_block' => false, ], - ] + ], + 'title_field' => esc_html__( 'row', 'elementor'), + ] ); @@ -243,52 +238,17 @@ protected function render() { echo ''; } - if ( $settings['row'] ) { - $row = $settings['row']; + if ( $settings['rows'] ) { echo ''; - $count; - if (count($row) % 3 == 0) { - for ($i = 0; $i < count($row)-1; $i += 3) { - $count=$i + 3; - - echo ''; - for ($j = $i; $j < $count; $j++) { - echo '' . $row[$j]['text'] . ''; - } - echo ''; - } - - } else { - if (count($row) % 3 == 1) { - for ($i = 0; $i < count($row) - 2; $i += 3){ - $count=$i + 3; - - echo ''; - for ($j = $i; $j < $count; $j++){ - echo '' . $row[$j]['text'] . ''; - } - echo ''; - } - echo ''; - echo '' . $row[$count]['text'] . ''; - echo ''; - - } else { - for ($i = 0; $i < count($row) - 3; $i += 3){ - $count=$i + 3; - - echo ''; - for ($j = $i; $j < $count; $j++){ - echo '' . $row[$j]['text'] . ''; - } - echo ''; - } - echo ''; - echo '' . $row[$count]['text'] . ''; - echo '' . $row[$count + 1]['text'] . ''; - echo ''; - }; - }; + $rows = $settings['rows']; + for ($i=0; $i < count($rows) - 1; $i++) { + echo ''; + echo '' .$rows[$i]['column_content_one'] . ''; + echo '' .$rows[$i]['column_content_two'] . ''; + echo '' .$rows[$i]['column_content_three'] . ''; + echo ''; + } + echo ''; }; echo ''; @@ -299,7 +259,7 @@ protected function content_template() { ?> - <# if ( 'yes' === settings.show_title ) { #> + <# if ( 'yes' === settings.show_title ) { #> @@ -309,52 +269,16 @@ protected function content_template() { <# } #> - <# if ( settings.row.length ) { #> - <# let row = settings.row #> - <# let count; #> + <# if ( settings.rows.length ) { #> - <# if(row.length % 3 == 0){ #> - - <# for(let i = 0; i < row.length - 1; i+= 3){ #> - <# count = i + 3 #> - - <# for(let j = i; j < count; j++){ #> - - <# } #> - - <# } #> - - <# } else { #> - - <# if (row.length % 3 == 1){ #> - <# for(let i = 0; i < row.length - 2; i+= 3){ #> - <# count = i + 3 #> - - <# for(let j = i; j < count; j++){ #> - - <# } #> - - <# } #> - - - - <# } else { #> - <# for(let i = 0; i < row.length - 3; i+= 3){ #> - <# count = i + 3 #> - - <# for(let j = i; j < count; j++){ #> - - <#}#> - - <# } #> - - - - - <# } #> + <# let rows = settings.rows #> + <# for(let i = 0; i <= rows.length - 1; i++){ #> + + + + + <# } #> - - <# } #>
{{{ settings.column_one }}}
{{{row[j].text}}}
{{{row[j].text}}}
{{{row[count].text}}}
{{{row[j].text}}}
{{{row[count].text}}}{{{row[count + 1].text}}}
{{{rows[i].column_content_one}}}{{{rows[i].column_content_two}}}{{{rows[i].column_content_three}}}
From 3d53eea36e63604d3c0e2afe7aae546aea1584a8 Mon Sep 17 00:00:00 2001 From: christian Date: Thu, 11 Apr 2024 12:57:44 +0200 Subject: [PATCH 6/7] removing defaults fields values, adding some spacing, deleting useless codes --- includes/widgets/table.php | 38 +++++++------------------------------- package-lock.json | 12 ++++++------ 2 files changed, 13 insertions(+), 37 deletions(-) diff --git a/includes/widgets/table.php b/includes/widgets/table.php index dc9a722fc525..2cd2d6e49bdc 100644 --- a/includes/widgets/table.php +++ b/includes/widgets/table.php @@ -88,27 +88,6 @@ public function get_keywords() { return [ 'table']; } - /** - * Get widget upsale data. - * - * Retrieve the widget promotion data. - * - * @since 3.18.0 - * @access protected - * - * @return array Widget promotion data. - */ - protected function get_upsale_data() { - return [ - 'condition' => ! Utils::has_pro(), - 'image' => esc_url( ELEMENTOR_ASSETS_URL . 'images/go-pro.svg' ), - 'image_alt' => esc_attr__( 'Upgrade', 'elementor' ), - 'description' => esc_html__( 'Create captivating tables.', 'elementor' ), - 'upgrade_url' => esc_url( 'https://go.elementor.com/go-pro-table-widget/' ), - 'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ), - ]; - } - /** * Register table widget controls. * @@ -181,29 +160,26 @@ protected function register_controls() { $this->add_control( 'rows', [ - 'label' => esc_html__( "Rows' contents", 'elementor' ), - 'show_label' => esc_html__( true, 'elementor' ), + 'label' => esc_html__( "Content rows", 'elementor' ), + 'show_label' => true, 'type' => \Elementor\Controls_Manager::REPEATER, 'fields' => [ [ 'name' => 'column_content_one', 'label' => esc_html__( 'Content column 1', 'elementor' ), 'type' => \Elementor\Controls_Manager::TEXT, - 'default' => esc_html__( 'Content column 1' , 'elementor' ), 'label_block' => false, ], [ 'name' => 'column_content_two', 'label' => esc_html__( 'column content 2', 'elementor' ), 'type' => \Elementor\Controls_Manager::TEXT, - 'default' => esc_html__( 'Content column 2' , 'elementor' ), 'label_block' => false, ], [ 'name' => 'column_content_three', 'label' => esc_html__( 'column content 3', 'elementor' ), 'type' => \Elementor\Controls_Manager::TEXT, - 'default' => esc_html__( 'Content column 3' , 'elementor' ), 'label_block' => false, ], ], @@ -241,7 +217,7 @@ protected function render() { if ( $settings['rows'] ) { echo ''; $rows = $settings['rows']; - for ($i=0; $i < count($rows) - 1; $i++) { + for ($i=0; $i <= count($rows)-1; $i++) { echo ''; echo '' .$rows[$i]['column_content_one'] . ''; echo '' .$rows[$i]['column_content_two'] . ''; @@ -272,11 +248,11 @@ protected function content_template() { <# if ( settings.rows.length ) { #> <# let rows = settings.rows #> - <# for(let i = 0; i <= rows.length - 1; i++){ #> + <# for( let i = 0; i <= rows.length - 1; i++ ){ #> - {{{rows[i].column_content_one}}} - {{{rows[i].column_content_two}}} - {{{rows[i].column_content_three}}} + {{{ rows[i].column_content_one }}} + {{{ rows[i].column_content_two }}} + {{{ rows[i].column_content_three }}} <# } #> diff --git a/package-lock.json b/package-lock.json index 3a7140c6effb..9ba9c438eb02 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7447,9 +7447,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001532", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001532.tgz", - "integrity": "sha512-FbDFnNat3nMnrROzqrsg314zhqN5LGQ1kyyMk2opcrwGbVGpHRhgCWtAgD5YJUqNAiQ+dklreil/c3Qf1dfCTw==", + "version": "1.0.30001608", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001608.tgz", + "integrity": "sha512-cjUJTQkk9fQlJR2s4HMuPMvTiRggl0rAVMtthQuyOlDWuqHXqN8azLq+pi8B2TjwKJ32diHjUqRIKeFX4z1FoA==", "funding": [ { "type": "opencollective", @@ -28833,9 +28833,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001532", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001532.tgz", - "integrity": "sha512-FbDFnNat3nMnrROzqrsg314zhqN5LGQ1kyyMk2opcrwGbVGpHRhgCWtAgD5YJUqNAiQ+dklreil/c3Qf1dfCTw==" + "version": "1.0.30001608", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001608.tgz", + "integrity": "sha512-cjUJTQkk9fQlJR2s4HMuPMvTiRggl0rAVMtthQuyOlDWuqHXqN8azLq+pi8B2TjwKJ32diHjUqRIKeFX4z1FoA==" }, "capital-case": { "version": "1.0.4", From f121449a48ef703099aa11b40845b8b894eca5a6 Mon Sep 17 00:00:00 2001 From: christian Date: Thu, 11 Apr 2024 21:31:32 +0200 Subject: [PATCH 7/7] adding the style tab and it controls --- includes/widgets/table.php | 72 ++++++++++++++++++++++++++++++++++---- 1 file changed, 66 insertions(+), 6 deletions(-) diff --git a/includes/widgets/table.php b/includes/widgets/table.php index 2cd2d6e49bdc..1a21549dae62 100644 --- a/includes/widgets/table.php +++ b/includes/widgets/table.php @@ -5,9 +5,10 @@ exit; // Exit if accessed directly. } - +use Elementor\Core\Kits\Documents\Tabs\Global_Colors; use Elementor\Core\Kits\Documents\Tabs\Global_Typography; + /** * Elementor table widget. * @@ -143,6 +144,7 @@ protected function register_controls() { ], ] ); + $this->add_control( 'column_three', [ @@ -156,7 +158,6 @@ protected function register_controls() { ] ); - $this->add_control( 'rows', [ @@ -188,7 +189,66 @@ protected function register_controls() { ] ); + + $this->end_controls_section(); + + $this->start_controls_section( + 'style_section', + [ + 'label' => esc_html__( 'Style', 'elementor' ), + 'tab' => \Elementor\Controls_Manager::TAB_STYLE, + ] + ); + + $this->add_control( + 'table_head_color', + [ + 'label' => esc_html__( 'Table head Color', 'elementor' ), + 'type' => \Elementor\Controls_Manager::COLOR, + 'global' => [ + 'default' => Global_Colors::COLOR_TEXT, + ], + 'selectors' => [ + '{{WRAPPER}} .table_head' => 'color: {{VALUE}};', + ], + ] + ); + + $this->add_control( + 'table_head_background_color', + [ + 'label' => esc_html__( 'Table head background Color', 'elementor' ), + 'type' => \Elementor\Controls_Manager::COLOR, + 'global' => [ + 'default' => Global_Colors::COLOR_ACCENT, + ], + 'selectors' => [ + '{{WRAPPER}} .table_head' => 'background-color: {{VALUE}};', + ], + ] + ); + + $this->add_group_control( + \Elementor\Group_Control_Typography::get_type(), + [ + 'name' => 'sub_heading_typography', + 'global' => [ + 'default' => \Elementor\Core\Kits\Documents\Tabs\Global_Typography::TYPOGRAPHY_SECONDARY, + ], + 'selector' => '{{WRAPPER}} .table_head', + ] + ); + + $this->add_group_control( + \Elementor\Group_Control_Border::get_type(), + [ + 'name' => 'border', + 'selector' => '{{WRAPPER}} .table_head', + ] + ); + $this->end_controls_section(); + } /** @@ -203,9 +263,9 @@ protected function register_controls() { protected function render() { $settings = $this->get_settings_for_display(); - echo ''; + echo '
'; if ( 'yes' === $settings['show_title'] ) { - echo ''; + echo ''; echo ''; echo ''; echo ''; @@ -217,7 +277,7 @@ protected function render() { if ( $settings['rows'] ) { echo ''; $rows = $settings['rows']; - for ($i=0; $i <= count($rows)-1; $i++) { + for ($i=0; $i <= count($rows) - 1; $i++) { echo ''; echo ''; echo ''; @@ -236,7 +296,7 @@ protected function content_template() {
' . $settings['column_one'] . '' . $settings['column_two'] . '
' .$rows[$i]['column_content_one'] . '' .$rows[$i]['column_content_two'] . '
<# if ( 'yes' === settings.show_title ) { #> - +
{{{ settings.column_one }}} {{{ settings.column_two }}}