| 1 |
<?php |
| 2 |
/** |
| 3 |
* Controls class. |
| 4 |
* |
| 5 |
* @package RadiusTheme\SB |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace RadiusTheme\SB\Elementor\Widgets\General\PostGrid; |
| 9 |
|
| 10 |
use RadiusTheme\SB\Elementor\Helper\PostHelpers; |
| 11 |
use RadiusTheme\SB\Helpers\Fns; |
| 12 |
use RadiusTheme\SB\Elementor\Helper\ControlHelper; |
| 13 |
|
| 14 |
|
| 15 |
// Do not allow directly accessing this file. |
| 16 |
if ( ! defined( 'ABSPATH' ) ) { |
| 17 |
exit( 'This script cannot be accessed directly.' ); |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* Settings class. |
| 22 |
* |
| 23 |
* @package RadiusTheme\SB |
| 24 |
*/ |
| 25 |
class Controls { |
| 26 |
/** |
| 27 |
* Content section |
| 28 |
* |
| 29 |
* @param object $obj Reference object. |
| 30 |
* |
| 31 |
* @return array |
| 32 |
*/ |
| 33 |
public static function content( $obj ) { |
| 34 |
return array_merge( |
| 35 |
self::preset( $obj ), |
| 36 |
PostHelpers::query( $obj ), |
| 37 |
PostHelpers::pagination( $obj ), |
| 38 |
PostHelpers::content_visibility( $obj ), |
| 39 |
PostHelpers::image( $obj ), |
| 40 |
PostHelpers::post_title( $obj ), |
| 41 |
PostHelpers::post_excerpt( $obj ), |
| 42 |
PostHelpers::links( $obj ), |
| 43 |
PostHelpers::meta_icon_settings( $obj ), |
| 44 |
PostHelpers::readmore_button( $obj ), |
| 45 |
); |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Style section |
| 50 |
* |
| 51 |
* @param object $obj Reference object. |
| 52 |
* |
| 53 |
* @return array |
| 54 |
*/ |
| 55 |
public static function style( $obj ) { |
| 56 |
return array_merge( |
| 57 |
PostHelpers::post_list_item_style( $obj ), |
| 58 |
PostHelpers::image_styles( $obj ), |
| 59 |
PostHelpers::title_style( $obj ), |
| 60 |
PostHelpers::content_style( $obj ), |
| 61 |
PostHelpers::meta_style( $obj ), |
| 62 |
PostHelpers::taxonomy_style( $obj ), |
| 63 |
PostHelpers::button_style( $obj ), |
| 64 |
PostHelpers::post_pagination_style_settings( $obj ), |
| 65 |
); |
| 66 |
} |
| 67 |
|
| 68 |
/** |
| 69 |
* Preset section |
| 70 |
* |
| 71 |
* @param object $obj Reference object. |
| 72 |
* |
| 73 |
* @return array |
| 74 |
*/ |
| 75 |
private static function preset( $obj ) { |
| 76 |
$fields['sb_post_preset'] = $obj->start_section( |
| 77 |
esc_html__( 'Layout', 'shopbuilder' ), |
| 78 |
'content' |
| 79 |
); |
| 80 |
$fields['layout_note'] = $obj->el_heading( esc_html__( 'Predefined Layouts', 'shopbuilder' ) ); |
| 81 |
$fields['layout_style'] = [ |
| 82 |
'type' => 'rtsb-image-selector', |
| 83 |
'options' => ControlHelper::general_widgets_post_grid(), |
| 84 |
'default' => 'rtsb-post-grid-layout1', |
| 85 |
]; |
| 86 |
$fields['cols'] = [ |
| 87 |
'type' => 'select2', |
| 88 |
'mode' => 'responsive', |
| 89 |
'label' => esc_html__( 'Number of Columns', 'shopbuilder' ), |
| 90 |
'description' => esc_html__( 'Please select the number of columns to show per row.', 'shopbuilder' ), |
| 91 |
'options' => ControlHelper::layout_columns(), |
| 92 |
'label_block' => true, |
| 93 |
'default' => '0', |
| 94 |
'tablet_default' => '1', |
| 95 |
'mobile_default' => '1', |
| 96 |
'required' => true, |
| 97 |
'render_type' => 'template', |
| 98 |
'selectors' => [ |
| 99 |
$obj->selectors['columns']['cols'] => 'grid-template-columns: repeat({{VALUE}}, minmax(0, 1fr));', |
| 100 |
], |
| 101 |
'separator' => 'before', |
| 102 |
]; |
| 103 |
$fields['rows'] = [ |
| 104 |
'type' => 'select2', |
| 105 |
'label' => esc_html__( 'Number of Product Rows', 'shopbuilder' ), |
| 106 |
'description' => esc_html__( 'Please select the number of slide rows. Slide Rows represents how many rows of slides will be displayed at once.', 'shopbuilder' ), |
| 107 |
'options' => [ |
| 108 |
1 => esc_html__( 'Layout Default (1 Row)', 'shopbuilder' ), |
| 109 |
2 => esc_html__( '2 Rows', 'shopbuilder' ), |
| 110 |
3 => esc_html__( '3 Rows', 'shopbuilder' ), |
| 111 |
4 => esc_html__( '4 Rows', 'shopbuilder' ), |
| 112 |
5 => esc_html__( '5 Rows', 'shopbuilder' ), |
| 113 |
], |
| 114 |
'label_block' => true, |
| 115 |
'default' => '1', |
| 116 |
'tablet_default' => '1', |
| 117 |
'mobile_default' => '1', |
| 118 |
'required' => true, |
| 119 |
'condition' => [ 'activate_slider_item' => 'yes' ], |
| 120 |
]; |
| 121 |
|
| 122 |
$fields['cols_group'] = [ |
| 123 |
'type' => 'select2', |
| 124 |
'mode' => 'responsive', |
| 125 |
'label' => esc_html__( 'Number of Slides Per Group', 'shopbuilder' ), |
| 126 |
'description' => esc_html__( 'Please select the number of slides to show per group. Slides Per Group indicates how many slides will be transitioned at a time.', 'shopbuilder' ), |
| 127 |
'options' => ControlHelper::layout_columns(), |
| 128 |
'label_block' => true, |
| 129 |
'default' => '0', |
| 130 |
'tablet_default' => '2', |
| 131 |
'mobile_default' => '1', |
| 132 |
'required' => true, |
| 133 |
'condition' => [ 'activate_slider_item' => 'yes' ], |
| 134 |
]; |
| 135 |
$fields['grid_gap'] = [ |
| 136 |
'type' => 'slider', |
| 137 |
'mode' => 'responsive', |
| 138 |
'label' => esc_html__( 'Grid Gap / Spacing (px)', 'shopbuilder' ), |
| 139 |
'size_units' => [ 'px' ], |
| 140 |
'range' => [ |
| 141 |
'px' => [ |
| 142 |
'min' => 0, |
| 143 |
'max' => 100, |
| 144 |
'step' => 1, |
| 145 |
], |
| 146 |
], |
| 147 |
'default' => [ |
| 148 |
'unit' => 'px', |
| 149 |
'size' => 30, |
| 150 |
], |
| 151 |
'description' => esc_html__( 'Please select the grid gap in px.', 'shopbuilder' ), |
| 152 |
'selectors' => [ |
| 153 |
$obj->selectors['columns']['grid_gap']['padding'] => 'padding-left: calc({{SIZE}}{{UNIT}} / 2); padding-right: calc({{SIZE}}{{UNIT}} / 2);', |
| 154 |
$obj->selectors['columns']['grid_gap']['margin'] => 'margin-left: calc(-{{SIZE}}{{UNIT}} / 2); margin-right: calc(-{{SIZE}}{{UNIT}} / 2);', |
| 155 |
$obj->selectors['columns']['grid_gap']['bottom'] => 'margin-bottom: {{SIZE}}{{UNIT}};', |
| 156 |
], |
| 157 |
]; |
| 158 |
$fields['sb_post_preset_end'] = $obj->end_section(); |
| 159 |
return $fields; |
| 160 |
} |
| 161 |
} |
| 162 |
|