if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
class Group_Control_Grid_Container extends Group_Control_Base {
protected static $fields;
public static function get_type() {
protected function init_fields() {
$icon_start = is_rtl() ? 'end' : 'start';
$icon_end = is_rtl() ? 'start' : 'end';
$fields['items_grid'] = [
'type' => Controls_Manager::HEADING,
'label' => esc_html__( 'Items', 'elementor' ),
'label' => esc_html__( 'Grid Outline', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Show', 'elementor' ),
'label_off' => esc_html__( 'Hide', 'elementor' ),
'editor_available' => true,
$responsive_unit_defaults = $this->get_responsive_unit_defaults();
$fields['columns_grid'] = [
'label' => esc_html__( 'Columns', 'elementor' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'fr', 'custom' ],
'unit_selectors_dictionary' => [
'custom' => '--e-con-grid-template-columns: {{SIZE}}',
'{{SELECTOR}}' => '--e-con-grid-template-columns: repeat({{SIZE}}, 1fr)',
'editor_available' => true,
] + $responsive_unit_defaults;
'label' => esc_html__( 'Rows', 'elementor' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'fr', 'custom' ],
'unit_selectors_dictionary' => [
'custom' => '--e-con-grid-template-rows: {{SIZE}}',
'{{SELECTOR}}' => '--e-con-grid-template-rows: repeat({{SIZE}}, 1fr)',
'editor_available' => true,
] + $responsive_unit_defaults;
'label' => esc_html__( 'Gaps', 'elementor' ),
'type' => Controls_Manager::GAPS,
'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
'{{SELECTOR}}' => '--gap: {{ROW}}{{UNIT}} {{COLUMN}}{{UNIT}};--row-gap: {{ROW}}{{UNIT}};--column-gap: {{COLUMN}}{{UNIT}};',
'label' => esc_html__( 'Auto Flow', 'elementor' ),
'type' => Controls_Manager::SELECT,
'row' => esc_html__( 'Row', 'elementor' ),
'column' => esc_html__( 'Column', 'elementor' ),
'{{SELECTOR}}' => '--grid-auto-flow: {{VALUE}}',
'editor_available' => true,
] + $this->get_responsive_autoflow_defaults();
$fields['justify_items'] = [
'label' => esc_html__( 'Justify Items', 'elementor' ),
'type' => Controls_Manager::CHOOSE,
'title' => esc_html__( 'Start', 'elementor' ),
'icon' => 'eicon-align-' . $icon_start . '-h',
'title' => esc_html__( 'Center', 'elementor' ),
'icon' => 'eicon-align-center-h',
'title' => esc_html__( 'End', 'elementor' ),
'icon' => 'eicon-align-' . $icon_end . '-h',
'title' => esc_html__( 'Stretch', 'elementor' ),
'icon' => 'eicon-align-stretch-h',
'{{SELECTOR}}' => '--justify-items: {{VALUE}};',
$fields['align_items'] = [
'label' => esc_html__( 'Align Items', 'elementor' ),
'type' => Controls_Manager::CHOOSE,
'title' => esc_html__( 'Start', 'elementor' ),
'icon' => 'eicon-align-start-v',
'title' => esc_html__( 'Center', 'elementor' ),
'icon' => 'eicon-align-center-v',
'title' => esc_html__( 'End', 'elementor' ),
'icon' => 'eicon-align-end-v',
'title' => esc_html__( 'Stretch', 'elementor' ),
'icon' => 'eicon-align-stretch-v',
'{{SELECTOR}}' => '--align-items: {{VALUE}};',
$fields['justify_content'] = [
'label' => esc_html__( 'Justify Content', 'elementor' ),
'type' => Controls_Manager::CHOOSE,
'title' => esc_html__( 'Start', 'elementor' ),
'icon' => 'eicon-justify-start-h',
'title' => esc_html__( 'Middle', 'elementor' ),
'icon' => 'eicon-justify-center-h',
'title' => esc_html__( 'End', 'elementor' ),
'icon' => 'eicon-justify-end-h',
'title' => esc_html__( 'Space Between', 'elementor' ),
'icon' => 'eicon-justify-space-between-h',
'title' => esc_html__( 'Space Around', 'elementor' ),
'icon' => 'eicon-justify-space-around-h',
'title' => esc_html__( 'Space Evenly', 'elementor' ),
'icon' => 'eicon-justify-space-evenly-h',
'{{SELECTOR}}' => '--grid-justify-content: {{VALUE}};',
'columns_grid[unit]' => 'custom',
$fields['align_content'] = [
'label' => esc_html__( 'Align Content', 'elementor' ),
'type' => Controls_Manager::CHOOSE,
'title' => esc_html__( 'Start', 'elementor' ),
'icon' => 'eicon-justify-start-v',
'title' => esc_html__( 'Middle', 'elementor' ),
'icon' => 'eicon-justify-center-v',
'title' => esc_html__( 'End', 'elementor' ),
'icon' => 'eicon-justify-end-v',
'title' => esc_html__( 'Space Between', 'elementor' ),
'icon' => 'eicon-justify-space-between-v',
'title' => esc_html__( 'Space Around', 'elementor' ),
'icon' => 'eicon-justify-space-around-v',
'title' => esc_html__( 'Space Evenly', 'elementor' ),
'icon' => 'eicon-justify-space-evenly-v',
'{{SELECTOR}}' => '--grid-align-content: {{VALUE}};',
'rows_grid[unit]' => 'custom',
// Only use the auto flow prefix class inside the editor.
$auto_flow_prefix_class = Plugin::$instance->editor->is_edit_mode() ? [ 'prefix_class' => 'e-con--' ] : [];
$fields['_is_row'] = array_merge( $auto_flow_prefix_class, [
'type' => Controls_Manager::HIDDEN,
$fields['_is_column'] = array_merge( $auto_flow_prefix_class, [
'type' => Controls_Manager::HIDDEN,
protected function get_responsive_unit_defaults() {
$responsive_unit_defaults = [];
$active_breakpoints = Plugin::$instance->breakpoints->get_active_breakpoints();
foreach ( $active_breakpoints as $breakpoint_name => $breakpoint ) {
$responsive_unit_defaults[ $breakpoint_name . '_default' ] = [
return $responsive_unit_defaults;
protected function get_responsive_autoflow_defaults() {
$responsive_autoflow_defaults = [];
$active_breakpoints = Plugin::$instance->breakpoints->get_active_breakpoints();
foreach ( $active_breakpoints as $breakpoint_name => $breakpoint ) {
$responsive_autoflow_defaults[ $breakpoint_name . '_default' ] = 'row';
return $responsive_autoflow_defaults;
protected function get_default_options() {