| 1 |
<?php |
| 2 |
/** |
| 3 |
* Controls class. |
| 4 |
* |
| 5 |
* @package RadiusTheme\SB |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace RadiusTheme\SB\Elementor\Widgets\General\DropCaps; |
| 9 |
|
| 10 |
use RadiusTheme\SB\Helpers\Fns; |
| 11 |
use RadiusTheme\SB\Elementor\Helper\ControlHelper; |
| 12 |
|
| 13 |
// Do not allow directly accessing this file. |
| 14 |
if ( ! defined( 'ABSPATH' ) ) { |
| 15 |
exit( 'This script cannot be accessed directly.' ); |
| 16 |
} |
| 17 |
|
| 18 |
/** |
| 19 |
* Settings class. |
| 20 |
* |
| 21 |
* @package RadiusTheme\SB |
| 22 |
*/ |
| 23 |
class Controls { |
| 24 |
/** |
| 25 |
* Content section |
| 26 |
* |
| 27 |
* @param object $obj Reference object. |
| 28 |
* |
| 29 |
* @return array |
| 30 |
*/ |
| 31 |
public static function content( $obj ) { |
| 32 |
return array_merge( |
| 33 |
self::preset( $obj ), |
| 34 |
self::dropcaps_content( $obj ), |
| 35 |
); |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Style section |
| 40 |
* |
| 41 |
* @param object $obj Reference object. |
| 42 |
* |
| 43 |
* @return array |
| 44 |
*/ |
| 45 |
public static function style( $obj ) { |
| 46 |
return array_merge( |
| 47 |
self::content_style( $obj ), |
| 48 |
self::dropcap_letter_style( $obj ), |
| 49 |
); |
| 50 |
} |
| 51 |
/** |
| 52 |
* Preset section |
| 53 |
* |
| 54 |
* @param object $obj Reference object. |
| 55 |
* |
| 56 |
* @return array |
| 57 |
*/ |
| 58 |
private static function preset( $obj ) { |
| 59 |
$fields['dropcaps_preset'] = $obj->start_section( |
| 60 |
esc_html__( 'Layout', 'shopbuilder' ), |
| 61 |
'content' |
| 62 |
); |
| 63 |
$fields['layout_note'] = $obj->el_heading( esc_html__( 'Predefined Layouts', 'shopbuilder' ) ); |
| 64 |
$fields['layout_style'] = [ |
| 65 |
'type' => 'rtsb-image-selector', |
| 66 |
'options' => ControlHelper::general_widgets_dropcaps_layouts(), |
| 67 |
'default' => 'rtsb-dropcaps-layout1', |
| 68 |
]; |
| 69 |
|
| 70 |
$fields['dropcaps_preset_end'] = $obj->end_section(); |
| 71 |
return $fields; |
| 72 |
} |
| 73 |
/** |
| 74 |
* Content section |
| 75 |
* |
| 76 |
* @param object $obj Reference object. |
| 77 |
* |
| 78 |
* @return array |
| 79 |
*/ |
| 80 |
private static function dropcaps_content( $obj ) { |
| 81 |
$fields['dc_description'] = $obj->start_section( |
| 82 |
esc_html__( 'General', 'shopbuilder' ), |
| 83 |
'content' |
| 84 |
); |
| 85 |
$fields['drop_content'] = [ |
| 86 |
'label' => esc_html__( 'Content', 'shopbuilder' ), |
| 87 |
'description' => esc_html__( 'Please enter the dropcaps text.', 'shopbuilder' ), |
| 88 |
'type' => 'wysiwyg', |
| 89 |
'label_block' => true, |
| 90 |
'default' => sprintf( '<p>%s</p>', esc_html( __( 'ShopBuilder is a versatile plugin designed for Elementor Page Builder. This plugin helps you design and customize your online store easily, letting you create attractive product pages and improve the shopping experience for your customers.', 'shopbuilder' ) ) ), |
| 91 |
]; |
| 92 |
$fields['enable_list_content_count'] = [ |
| 93 |
'label' => esc_html__( 'List Content Counter', 'shopbuilder' ), |
| 94 |
'label_on' => esc_html__( 'On', 'shopbuilder' ), |
| 95 |
'label_off' => esc_html__( 'Off', 'shopbuilder' ), |
| 96 |
'type' => 'switch', |
| 97 |
'render_type' => 'template', |
| 98 |
'separator' => 'before', |
| 99 |
]; |
| 100 |
$fields['enable_list_content_count_note'] = [ |
| 101 |
'type' => 'html', |
| 102 |
'raw' => sprintf( |
| 103 |
'<span style="display: block; background: #fffbf1; padding: 10px; font-weight: 500; line-height: 1.4; color: #bd3a3a;border: 1px solid #bd3a3a;">%s</span>', |
| 104 |
esc_html__( 'To use the List Counter feature, you need to provide the content as a list.', 'shopbuilder' ) |
| 105 |
), |
| 106 |
|
| 107 |
]; |
| 108 |
$fields['cols'] = [ |
| 109 |
'type' => 'select2', |
| 110 |
'mode' => 'responsive', |
| 111 |
'label' => esc_html__( 'Number of Columns', 'shopbuilder' ), |
| 112 |
'description' => esc_html__( 'Please select the number of columns to show per row.', 'shopbuilder' ), |
| 113 |
'options' => [ |
| 114 |
1 => esc_html__( '1 Column', 'shopbuilder' ), |
| 115 |
2 => esc_html__( '2 Columns', 'shopbuilder' ), |
| 116 |
3 => esc_html__( '3 Columns', 'shopbuilder' ), |
| 117 |
4 => esc_html__( '4 Columns', 'shopbuilder' ), |
| 118 |
5 => esc_html__( '5 Columns', 'shopbuilder' ), |
| 119 |
6 => esc_html__( '6 Columns', 'shopbuilder' ), |
| 120 |
], |
| 121 |
'label_block' => true, |
| 122 |
'default' => '3', |
| 123 |
'tablet_default' => '2', |
| 124 |
'mobile_default' => '1', |
| 125 |
'required' => true, |
| 126 |
'selectors' => [ |
| 127 |
$obj->selectors['columns']['cols'] => 'grid-template-columns: repeat({{VALUE}}, minmax(0, 1fr));', |
| 128 |
], |
| 129 |
'condition' => [ |
| 130 |
'enable_list_content_count' => [ 'yes' ], |
| 131 |
], |
| 132 |
]; |
| 133 |
|
| 134 |
$fields['dc_description_end'] = $obj->end_section(); |
| 135 |
|
| 136 |
return $fields; |
| 137 |
} |
| 138 |
/** |
| 139 |
* Description style section |
| 140 |
* |
| 141 |
* @param object $obj Reference object. |
| 142 |
* |
| 143 |
* @return array |
| 144 |
*/ |
| 145 |
private static function content_style( $obj ) { |
| 146 |
$css_selectors = $obj->selectors['content_style']; |
| 147 |
$title = esc_html__( 'Content Style', 'shopbuilder' ); |
| 148 |
$selectors = [ |
| 149 |
'typography' => $css_selectors['typography'], |
| 150 |
'color' => [ $css_selectors['color'] => 'color: {{VALUE}};' ], |
| 151 |
'bg_color' => [ $css_selectors['bg_color'] => 'background-color: {{VALUE}};' ], |
| 152 |
'border' => $css_selectors['border'], |
| 153 |
'box_shadow' => $css_selectors['box_shadow'], |
| 154 |
'padding' => [ $css_selectors['padding'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ], |
| 155 |
'margin' => [ $css_selectors['margin'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ], |
| 156 |
'border_radius' => [ $css_selectors['border_radius'] => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ], |
| 157 |
'list_gap' => [ $css_selectors['list_gap'] => 'grid-gap: {{SIZE}}{{UNIT}};' ], |
| 158 |
]; |
| 159 |
|
| 160 |
$fields = ControlHelper::general_elementor_style( 'dc_content_style', $title, $obj, [], $selectors ); |
| 161 |
|
| 162 |
unset( |
| 163 |
$fields['dc_content_style_alignment'], |
| 164 |
$fields['dc_content_style_color_tabs'], |
| 165 |
$fields['dc_content_style_color_tab'], |
| 166 |
$fields['dc_content_style_color_tab_end'], |
| 167 |
$fields['dc_content_style_hover_color_tab'], |
| 168 |
$fields['dc_content_style_hover_color'], |
| 169 |
$fields['dc_content_style_hover_bg_color'], |
| 170 |
$fields['dc_content_style_hover_color_tab_end'], |
| 171 |
$fields['dc_content_style_color_tabs_end'], |
| 172 |
$fields['dc_content_style_border_hover_color'] |
| 173 |
); |
| 174 |
$extra_controls['dc_content_style_border_radius'] = [ |
| 175 |
'label' => esc_html__( 'Border Radius', 'shopbuilder' ), |
| 176 |
'type' => 'dimensions', |
| 177 |
'mode' => 'responsive', |
| 178 |
'size_units' => [ 'px' ], |
| 179 |
'selectors' => $selectors['border_radius'], |
| 180 |
]; |
| 181 |
$extra_controls['dc_content_style_box_shadow'] = [ |
| 182 |
'type' => 'box-shadow', |
| 183 |
'mode' => 'group', |
| 184 |
'label' => esc_html__( 'Box Shadow', 'shopbuilder' ), |
| 185 |
'selector' => $selectors['box_shadow'], |
| 186 |
]; |
| 187 |
$fields = Fns::insert_controls( 'dc_content_style_spacing_note', $fields, $extra_controls ); |
| 188 |
$extra_controls2['dc_content_style_list_gap'] = [ |
| 189 |
'label' => esc_html__( 'List Item Gap', 'shopbuilder' ), |
| 190 |
'type' => 'slider', |
| 191 |
'mode' => 'responsive', |
| 192 |
'size_units' => [ 'px', '%', 'em' ], |
| 193 |
'range' => [ |
| 194 |
'px' => [ |
| 195 |
'min' => 10, |
| 196 |
'max' => 200, |
| 197 |
], |
| 198 |
], |
| 199 |
'selectors' => $selectors['list_gap'], |
| 200 |
'description' => esc_html__( 'If you are using list content then it will be working', 'shopbuilder' ), |
| 201 |
]; |
| 202 |
return Fns::insert_controls( 'dc_content_style_spacing_note', $fields, $extra_controls2, true ); |
| 203 |
} |
| 204 |
/** |
| 205 |
* Dropcap Letter style section |
| 206 |
* |
| 207 |
* @param object $obj Reference object. |
| 208 |
* |
| 209 |
* @return array |
| 210 |
*/ |
| 211 |
private static function dropcap_letter_style( $obj ) { |
| 212 |
$css_selectors = $obj->selectors['dropcap_letter_style']; |
| 213 |
$title = esc_html__( 'Dropcap Letter', 'shopbuilder' ); |
| 214 |
$selectors = [ |
| 215 |
'typography' => $css_selectors['typography'], |
| 216 |
'text_shadow' => $css_selectors['text_shadow'], |
| 217 |
'color' => [ $css_selectors['color'] => 'color: {{VALUE}};' ], |
| 218 |
'gradient_bg' => $css_selectors['gradient_bg'], |
| 219 |
'border' => $css_selectors['border'], |
| 220 |
'padding' => [ $css_selectors['padding'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;' ], |
| 221 |
'margin' => [ $css_selectors['margin'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;' ], |
| 222 |
'border_radius' => [ $css_selectors['border_radius'] => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;' ], |
| 223 |
]; |
| 224 |
|
| 225 |
$fields = ControlHelper::general_elementor_style( 'dc_dropcap_letter_style', $title, $obj, [], $selectors ); |
| 226 |
|
| 227 |
unset( |
| 228 |
$fields['dc_dropcap_letter_style_alignment'], |
| 229 |
$fields['dc_dropcap_letter_style_color_tabs'], |
| 230 |
$fields['dc_dropcap_letter_style_bg_color'], |
| 231 |
$fields['dc_dropcap_letter_style_color_tab'], |
| 232 |
$fields['dc_dropcap_letter_style_color_tab_end'], |
| 233 |
$fields['dc_dropcap_letter_style_hover_color_tab'], |
| 234 |
$fields['dc_dropcap_letter_style_hover_color'], |
| 235 |
$fields['dc_dropcap_letter_style_hover_bg_color'], |
| 236 |
$fields['dc_dropcap_letter_style_hover_color_tab_end'], |
| 237 |
$fields['dc_dropcap_letter_style_color_tabs_end'], |
| 238 |
$fields['dc_dropcap_letter_style_border_hover_color'] |
| 239 |
); |
| 240 |
$extra_controls['dc_dropcap_letter_style_text_shadow'] = [ |
| 241 |
'type' => 'text-shadow', |
| 242 |
'mode' => 'group', |
| 243 |
'label' => esc_html__( 'Letter Shadow', 'shopbuilder' ), |
| 244 |
'selector' => $selectors['text_shadow'], |
| 245 |
]; |
| 246 |
$fields = Fns::insert_controls( 'rtsb_el_dc_dropcap_letter_style_typography', $fields, $extra_controls, true ); |
| 247 |
$extra_controls2['dc_dropcap_letter_style_gradient_bg'] = [ |
| 248 |
'label' => esc_html__( 'Background', 'shopbuilder' ), |
| 249 |
'type' => 'background', |
| 250 |
'mode' => 'group', |
| 251 |
'selector' => $selectors['gradient_bg'], |
| 252 |
'condition' => [ |
| 253 |
'layout_style!' => [ 'rtsb-dropcaps-layout2' ], |
| 254 |
], |
| 255 |
]; |
| 256 |
$fields = Fns::insert_controls( 'dc_dropcap_letter_style_color', $fields, $extra_controls2, true ); |
| 257 |
$extra_controls3['dc_dropcap_letter_style_border_radius'] = [ |
| 258 |
'label' => esc_html__( 'Border Radius', 'shopbuilder' ), |
| 259 |
'type' => 'dimensions', |
| 260 |
'mode' => 'responsive', |
| 261 |
'size_units' => [ 'px' ], |
| 262 |
'selectors' => $selectors['border_radius'], |
| 263 |
'condition' => [ |
| 264 |
'layout_style!' => [ 'rtsb-dropcaps-layout2' ], |
| 265 |
], |
| 266 |
]; |
| 267 |
$fields = Fns::insert_controls( 'dc_dropcap_letter_style_spacing_note', $fields, $extra_controls3 ); |
| 268 |
$fields['dc_dropcap_letter_style_border_note']['condition'] = [ |
| 269 |
'layout_style!' => [ 'rtsb-dropcaps-layout2' ], |
| 270 |
]; |
| 271 |
$fields['rtsb_el_dc_dropcap_letter_style_border']['condition'] = [ |
| 272 |
'layout_style!' => [ 'rtsb-dropcaps-layout2' ], |
| 273 |
]; |
| 274 |
return $fields; |
| 275 |
} |
| 276 |
} |
| 277 |
|