| 1 |
<?php |
| 2 |
/** |
| 3 |
* Elementor Content Fields Class. |
| 4 |
* |
| 5 |
* This class contains all the common fields for Content tab. |
| 6 |
* |
| 7 |
* @package RadiusTheme\SB |
| 8 |
*/ |
| 9 |
|
| 10 |
namespace RadiusTheme\SB\Elementor\Widgets\Controls; |
| 11 |
|
| 12 |
use RadiusTheme\SB\Helpers\Fns; |
| 13 |
use RadiusTheme\SB\Elementor\Helper\ControlHelper; |
| 14 |
use RadiusTheme\SB\Models\GeneralList; |
| 15 |
|
| 16 |
// Do not allow directly accessing this file. |
| 17 |
if ( ! defined( 'ABSPATH' ) ) { |
| 18 |
exit( 'This script cannot be accessed directly.' ); |
| 19 |
} |
| 20 |
|
| 21 |
/** |
| 22 |
* Elementor Content Fields Class. |
| 23 |
*/ |
| 24 |
class ContentFields { |
| 25 |
/** |
| 26 |
* Tab name. |
| 27 |
* |
| 28 |
* @access private |
| 29 |
* @static |
| 30 |
* |
| 31 |
* @var array |
| 32 |
*/ |
| 33 |
private static $tab = 'content'; |
| 34 |
|
| 35 |
/** |
| 36 |
* Social Share Layout section |
| 37 |
* |
| 38 |
* @param object $obj Reference object. |
| 39 |
* @return array |
| 40 |
*/ |
| 41 |
public static function share_presets( $obj ) { |
| 42 |
$fields['layout_section'] = $obj->start_section( |
| 43 |
esc_html__( 'Presets', 'shopbuilder' ), |
| 44 |
self::$tab |
| 45 |
); |
| 46 |
|
| 47 |
$fields['layout'] = [ |
| 48 |
'type' => 'rtsb-image-selector', |
| 49 |
'options' => ControlHelper::share_layouts(), |
| 50 |
'default' => 'share-layout1', |
| 51 |
'separator' => rtsb()->has_pro() ? 'default' : 'after', |
| 52 |
]; |
| 53 |
|
| 54 |
$fields['layout_direction'] = [ |
| 55 |
'type' => 'choose', |
| 56 |
'label' => esc_html__( 'Layout Direction', 'shopbuilder' ), |
| 57 |
'options' => [ |
| 58 |
'horizontal' => [ |
| 59 |
'title' => esc_html__( 'Horizontal', 'shopbuilder' ), |
| 60 |
'icon' => 'eicon-navigation-horizontal', |
| 61 |
], |
| 62 |
'vertical' => [ |
| 63 |
'title' => esc_html__( 'Vertical', 'shopbuilder' ), |
| 64 |
'icon' => 'eicon-navigation-vertical', |
| 65 |
], |
| 66 |
], |
| 67 |
'default' => 'horizontal', |
| 68 |
'toggle' => true, |
| 69 |
'classes' => $obj->pro_class(), |
| 70 |
'separator' => rtsb()->has_pro() ? 'before-short' : 'default', |
| 71 |
]; |
| 72 |
|
| 73 |
$fields['layout_section_end'] = $obj->end_section(); |
| 74 |
|
| 75 |
return apply_filters( 'rtsb/elements/elementor/share_preset_control', $fields, $obj ); |
| 76 |
} |
| 77 |
|
| 78 |
/** |
| 79 |
* Social Share Platforms section |
| 80 |
* |
| 81 |
* @param object $obj Reference object. |
| 82 |
* |
| 83 |
* @return mixed|null |
| 84 |
*/ |
| 85 |
public static function share_platforms( $obj ) { |
| 86 |
$sharing_list = []; |
| 87 |
$defaults = []; |
| 88 |
$share_platforms = ControlHelper::sharing_settings(); |
| 89 |
|
| 90 |
foreach ( $share_platforms as $share_platform ) { |
| 91 |
switch ( $share_platform ) { |
| 92 |
case 'facebook': |
| 93 |
$share_text = esc_html__( 'Share', 'shopbuilder' ); |
| 94 |
break; |
| 95 |
|
| 96 |
case 'twitter': |
| 97 |
$share_text = esc_html__( 'Tweet', 'shopbuilder' ); |
| 98 |
break; |
| 99 |
|
| 100 |
case 'pinterest': |
| 101 |
$share_text = esc_html__( 'Pin It', 'shopbuilder' ); |
| 102 |
break; |
| 103 |
|
| 104 |
default: |
| 105 |
$share_text = ucfirst( esc_html( $share_platform ) ); |
| 106 |
} |
| 107 |
|
| 108 |
$defaults[] = [ |
| 109 |
'share_items' => esc_html( $share_platform ), |
| 110 |
'share_text' => $share_text, |
| 111 |
]; |
| 112 |
$sharing_list[ $share_platform ] = ucfirst( esc_html( $share_platform ) ); |
| 113 |
} |
| 114 |
|
| 115 |
$fields['platforms_section'] = $obj->start_section( |
| 116 |
esc_html__( 'Social Share Platforms', 'shopbuilder' ), |
| 117 |
self::$tab |
| 118 |
); |
| 119 |
|
| 120 |
$fields['show_share_settings_note'] = $obj->el_heading( esc_html__( 'Sharing Settings', 'shopbuilder' ), 'default' ); |
| 121 |
|
| 122 |
$fields['show_share_pre_text'] = [ |
| 123 |
'type' => 'switch', |
| 124 |
'label' => esc_html__( 'Show Header Text?', 'shopbuilder' ), |
| 125 |
'description' => esc_html__( 'Switch on to show social sharing text before icons.', 'shopbuilder' ), |
| 126 |
'label_on' => esc_html__( 'On', 'shopbuilder' ), |
| 127 |
'label_off' => esc_html__( 'Off', 'shopbuilder' ), |
| 128 |
'separator' => 'default', |
| 129 |
]; |
| 130 |
|
| 131 |
$fields['share_pre_text'] = [ |
| 132 |
'type' => 'text', |
| 133 |
'label' => esc_html__( 'Header Text', 'shopbuilder' ), |
| 134 |
'description' => esc_html__( 'Enter the text to show before icons.', 'shopbuilder' ), |
| 135 |
'default' => esc_html__( 'Share:', 'shopbuilder' ), |
| 136 |
'label_block' => true, |
| 137 |
'condition' => [ 'show_share_pre_text' => [ 'yes' ] ], |
| 138 |
]; |
| 139 |
|
| 140 |
$fields['show_share_icon'] = [ |
| 141 |
'type' => 'switch', |
| 142 |
'label' => esc_html__( 'Show Sharing Icon?', 'shopbuilder' ), |
| 143 |
'description' => esc_html__( 'Switch on to show social sharing icon.', 'shopbuilder' ), |
| 144 |
'label_on' => esc_html__( 'On', 'shopbuilder' ), |
| 145 |
'label_off' => esc_html__( 'Off', 'shopbuilder' ), |
| 146 |
'default' => 'yes', |
| 147 |
]; |
| 148 |
|
| 149 |
$fields['show_share_text'] = [ |
| 150 |
'type' => 'switch', |
| 151 |
'label' => esc_html__( 'Show Sharing Text?', 'shopbuilder' ), |
| 152 |
'description' => esc_html__( 'Switch on to show social sharing icon.', 'shopbuilder' ), |
| 153 |
'label_on' => esc_html__( 'On', 'shopbuilder' ), |
| 154 |
'label_off' => esc_html__( 'Off', 'shopbuilder' ), |
| 155 |
'default' => 'yes', |
| 156 |
'separator' => rtsb()->has_pro() ? 'before-short' : 'after elementor-control-separator-before-short', |
| 157 |
]; |
| 158 |
|
| 159 |
$fields['share_toggle'] = [ |
| 160 |
'type' => 'switch', |
| 161 |
'label' => esc_html__( 'Enable Share Toggle Icon?', 'shopbuilder' ), |
| 162 |
'description' => esc_html__( 'Switch on to enable share toggle icon.', 'shopbuilder' ), |
| 163 |
'label_on' => esc_html__( 'On', 'shopbuilder' ), |
| 164 |
'label_off' => esc_html__( 'Off', 'shopbuilder' ), |
| 165 |
'classes' => $obj->pro_class(), |
| 166 |
'separator' => rtsb()->has_pro() ? 'before-short' : 'default', |
| 167 |
]; |
| 168 |
|
| 169 |
$fields['share_toggle_icon'] = [ |
| 170 |
'type' => 'icons', |
| 171 |
'label' => esc_html__( 'Choose Toggle Icon', 'shopbuilder' ), |
| 172 |
'description' => esc_html__( 'Please choose the share toggle icon.', 'shopbuilder' ), |
| 173 |
'default' => [ |
| 174 |
'value' => 'rtsb-icon rtsb-icon-share', |
| 175 |
'library' => 'rtsb-fonts', |
| 176 |
], |
| 177 |
'condition' => [ 'share_toggle' => [ 'yes' ] ], |
| 178 |
]; |
| 179 |
|
| 180 |
$fields['share_platforms_note'] = $obj->el_heading( esc_html__( 'Sharing Platforms', 'shopbuilder' ), 'before' ); |
| 181 |
|
| 182 |
$fields['share_platforms'] = [ |
| 183 |
'type' => 'repeater', |
| 184 |
'mode' => 'repeater', |
| 185 |
'label' => esc_html__( 'Add Sharing Platforms', 'shopbuilder' ), |
| 186 |
'separator' => 'default', |
| 187 |
'title_field' => '{{{ share_items }}}', |
| 188 |
'fields' => [ |
| 189 |
'share_items' => [ |
| 190 |
'label' => esc_html__( 'Platform Name', 'shopbuilder' ), |
| 191 |
'type' => 'select', |
| 192 |
'separator' => 'default', |
| 193 |
'options' => $sharing_list, |
| 194 |
], |
| 195 |
'share_text' => [ |
| 196 |
'label' => esc_html__( 'Sharing Text', 'shopbuilder' ), |
| 197 |
'type' => 'text', |
| 198 |
], |
| 199 |
], |
| 200 |
'default' => $defaults, |
| 201 |
]; |
| 202 |
|
| 203 |
$fields['platforms_section_end'] = $obj->end_section(); |
| 204 |
|
| 205 |
return apply_filters( 'rtsb/elements/elementor/platforms_control', $fields, $obj ); |
| 206 |
} |
| 207 |
} |
| 208 |
|