uniqid(), 'type' => self::$type, 'name' => self::get_name( $amount ), 'icon' => self::get_icon( $amount ), 'group' => 'general', 'available' => true, 'position' => 150, 'children' => isset( $attributes['children'] ) ? $attributes['children'] : self::get_nested_columns( $amount ), 'data' => [ 'amount_of_columns' => [ 'value_path' => 'amount_of_columns', 'default_value' => $amount, ], 'column_width' => [ 'value_path' => 'column_width', 'component' => 1 == $amount ? '' : 'ColumnWidth', 'title' => __( 'Column width (%)', 'yaymail' ), 'default_value' => [], // Trick to bypass checking value_path ], 'column_spacing' => [ 'value_path' => 'column_spacing', 'component' => 'Dimension', 'title' => __( 'Column spacing', 'yaymail' ), 'default_value' => isset( $attributes['column_spacing'] ) ? $attributes['column_spacing'] : '0', 'min' => 0, 'max' => 100, 'type' => 'style', ], 'container_setting_breaker' => [ 'component' => 'LineBreaker', ], 'container_setting_group_definition' => [ 'component' => 'GroupDefinition', 'title' => __( 'Container layout settings', 'yaymail' ), 'description' => __( 'Handle container layout settings', 'yaymail' ), ], 'padding' => [ 'value_path' => 'padding', 'component' => 'Spacing', 'title' => __( 'Padding', 'yaymail' ), 'default_value' => isset( $attributes['padding'] ) ? $attributes['padding'] : [ 'top' => '15', 'right' => '0', 'bottom' => '15', 'left' => '0', ], 'type' => 'style', ], 'border_radius' => [ 'value_path' => 'border_radius', 'component' => 'BorderRadius', 'title' => __( 'Border radius', 'yaymail' ), 'default_value' => [ 'top_left' => isset( $attributes['border_radius']['top_left'] ) ? $attributes['border_radius']['top_left'] : '0', 'top_right' => isset( $attributes['border_radius']['top_right'] ) ? $attributes['border_radius']['top_right'] : '0', 'bottom_left' => isset( $attributes['border_radius']['bottom_left'] ) ? $attributes['border_radius']['bottom_left'] : '0', 'bottom_right' => isset( $attributes['border_radius']['bottom_right'] ) ? $attributes['border_radius']['bottom_right'] : '0', ], 'type' => 'style', ], 'background_color' => [ 'value_path' => 'background_color', 'component' => 'Color', 'title' => __( 'Background color', 'yaymail' ), 'default_value' => isset( $attributes['background_color'] ) ? $attributes['background_color'] : '#fff', 'type' => 'style', ], 'background_image' => [ 'value_path' => 'background_image', 'component' => 'BackgroundImage', 'title' => __( 'Background image', 'yaymail' ), 'default_value' => isset( $attributes['background_image'] ) ? $attributes['background_image'] : [ 'url' => '', 'position' => 'default', 'x_position' => 0, 'y_position' => 0, 'repeat' => 'default', 'size' => 'default', ], 'type' => 'style', ], 'inner_setting_breaker' => [ 'component' => 'LineBreaker', ], 'inner_setting_group_definition' => [ 'component' => 'GroupDefinition', 'title' => __( 'Inner layout settings', 'yaymail' ), 'description' => __( 'Handle inner layout settings', 'yaymail' ), ], 'inner_border_radius' => [ 'value_path' => 'inner_border_radius', 'component' => 'BorderRadius', 'title' => __( 'Inner border radius', 'yaymail' ), 'default_value' => [ 'top_left' => isset( $attributes['inner_border_radius']['top_left'] ) ? $attributes['inner_border_radius']['top_left'] : '0', 'top_right' => isset( $attributes['inner_border_radius']['top_right'] ) ? $attributes['inner_border_radius']['top_right'] : '0', 'bottom_left' => isset( $attributes['inner_border_radius']['bottom_left'] ) ? $attributes['inner_border_radius']['bottom_left'] : '0', 'bottom_right' => isset( $attributes['inner_border_radius']['bottom_right'] ) ? $attributes['inner_border_radius']['bottom_right'] : '0', ], 'type' => 'style', ], 'inner_background_color' => [ 'value_path' => 'inner_background_color', 'component' => 'Color', 'title' => __( 'Inner background color', 'yaymail' ), 'default_value' => isset( $attributes['inner_background_color'] ) ? $attributes['inner_background_color'] : '#ffffff00', 'type' => 'style', ], ], ]; } private static function get_nested_columns( $amount ) { if ( ! isset( $amount ) || $amount <= 0 ) { return []; } $width = 100 / $amount; $nested_columms = []; for ( $i = 0; $i < $amount; $i++ ) { array_push( $nested_columms, Column::get_data( $width ) ); } return $nested_columms; } private static function get_name( $amount ) { $column_names = [ 1 => __( 'One Column', 'yaymail' ), 2 => __( 'Two Columns', 'yaymail' ), 3 => __( 'Three Columns', 'yaymail' ), 4 => __( 'Four Columns', 'yaymail' ), ]; return isset( $column_names[ $amount ] ) ? $column_names[ $amount ] : 'Column'; } private static function get_icon( $amount ) { $icons = [ 1 => ' ', 2 => ' ', 3 => ' ', 4 => ' ', ]; return isset( $icons[ $amount ] ) ? $icons[ $amount ] : $icons[1]; } }