Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

table widget #2

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion includes/managers/widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private function init_widgets() {
'common',
'inner-section',
'heading',
'testOne',
'table',
'image',
'text-editor',
'video',
Expand Down
122 changes: 61 additions & 61 deletions includes/widgets/testOne.php → includes/widgets/table.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,64 +5,63 @@
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
*
* @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
*
* @return string Widget title.
*/
public function get_title() {
return esc_html__( 'testOne', 'elementor' );
return esc_html__( 'table', 'elementor' );
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we always use capital letters here:

return esc_html__( 'Table', 'elementor' );

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it

}

/**
* Get widget icon.
*
* Retrieve testOne widget icon.
* Retrieve table widget icon.
*
* @since 1.0.0
* @access public
*
* @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.
*
Expand All @@ -86,7 +85,7 @@ public function get_categories() {
* @return array Widget keywords.
*/
public function get_keywords() {
return [ 'testOne', 'title', 'text' ];
return [ 'table', 'title', 'text' ];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return [ 'table' ];

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the 'title' and the 'text'

}

/**
Expand All @@ -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' ),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'description' => esc_html__( 'Create captivating tables.', 'elementor' ),

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the description

'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.
*
Expand All @@ -123,58 +122,55 @@ 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,
]
);

$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,
],
]
);

$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,
],
Expand All @@ -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' => [
Expand All @@ -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' ),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'show_label' => esc_html__( true, 'elementor' ),
'show_label' => true,

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it

'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 }}}',
]
);

Expand All @@ -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.
*
Expand All @@ -241,21 +237,23 @@ protected function render() {

echo '<table>';
if ( 'yes' === $settings['show_title'] ) {

echo '<tr>';
echo '<th>' . $settings['columnOne'] . '</th>';
echo '<th>' . $settings['columnTwo'] . '</th>';
echo '<th>' . $settings['columnThree'] . '</th>';
echo '</tr>';
echo '<thead>';
echo '<tr>';
echo '<th>' . $settings['column_one'] . '</th>';
echo '<th>' . $settings['column_two'] . '</th>';
echo '<th>' . $settings['column_three'] . '</th>';
echo '</tr>';
echo '</thead>';
}

if ( $settings['list'] ) {
echo '<tr>';
foreach ( $settings['list'] as $item ) {
echo '<td class="elementor-repeater-item-' . esc_attr( $item['_id'] ) . '">' . $item['list_title'] . '</td>';
// echo '<dd>' . $item['list_content'] . '</dd>';
}
echo '</tr>';
echo '<tbody>';
echo '<tr>';
foreach ( $settings['list'] as $item ) {
echo '<td class="elementor-repeater-item-' . esc_attr( $item['_id'] ) . '">' . $item['list_title'] . '</td>';
}
echo '</tr>';
echo '</tbody>';
}
echo '</table>';
}
Expand All @@ -265,21 +263,23 @@ protected function content_template() {

<table>
<# if ( 'yes' === settings.show_title ) { #>
<tr>
<th>{{{ settings.columnOne }}}</th>
<th>{{{ settings.columnTwo }}}</th>
<th>{{{ settings.columnThree }}}</th>
</tr>

<thead>
<tr>
<th>{{{ settings.column_one }}}</th>
<th>{{{ settings.column_two }}}</th>
<th>{{{ settings.column_three }}}</th>
</tr>
</thead>
<# } #>

<# if ( settings.list.length ) { #>
<tr>
<# _.each( settings.list, function( item ) { #>
<td class="elementor-repeater-item-{{ item._id }}">{{{ item.list_title }}}</td>
<!-- <dd>{{{ item.list_content }}}</dd> -->
<# }); #>
</tr>
<tbody>
<tr>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<tr>

<# _.each( settings.list, function( item ) { #>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<# _.each( settings.list, function( item ) { #>
<# _.each( settings.list, function( item ) { #>
<tr>

<td class="elementor-repeater-item-{{ item._id }}">{{{item.list_title}}}</td>
<# }); #>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<# }); #>

</tr>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
</tr>
</tr>
<# }); #>

</tbody>
<# } #>
</table>
<?php
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"eslint-plugin-no-jquery": "^2.7.0",
"eslint-plugin-react": "^7.33.2",
"eslint-webpack-plugin": "^4.0.1",
"grunt": "^1.5.3",
"grunt": "^1.6.1",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert to the orginal value. We can't update packages on the whole repository.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert changes. We can't make updates here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i changed it

"grunt-banner": "~0.6.0",
"grunt-bumpup": "~0.6.3",
"grunt-checktextdomain": "~1.0.1",
Expand Down