| 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 static |
| 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' => 'default', |
| 52 |
]; |
| 53 |
|
| 54 |
$fields['layout_section_end'] = $obj->end_section(); |
| 55 |
|
| 56 |
return apply_filters( 'rtsb/elements/elementor/share_preset_control', $fields, $obj ); |
| 57 |
} |
| 58 |
|
| 59 |
/** |
| 60 |
* Social Share Platforms section |
| 61 |
* |
| 62 |
* @param object $obj Reference object. |
| 63 |
* |
| 64 |
* @return mixed|null |
| 65 |
*/ |
| 66 |
public static function share_platforms( $obj ) { |
| 67 |
$sharing_list = []; |
| 68 |
$defaults = []; |
| 69 |
$share_platforms = ControlHelper::sharing_settings(); |
| 70 |
|
| 71 |
foreach ( $share_platforms as $share_platform ) { |
| 72 |
switch ( $share_platform ) { |
| 73 |
case 'facebook': |
| 74 |
$share_text = esc_html__( 'Share', 'shopbuilder' ); |
| 75 |
break; |
| 76 |
|
| 77 |
case 'twitter': |
| 78 |
$share_text = esc_html__( 'Tweet', 'shopbuilder' ); |
| 79 |
break; |
| 80 |
|
| 81 |
case 'pinterest': |
| 82 |
$share_text = esc_html__( 'Pin It', 'shopbuilder' ); |
| 83 |
break; |
| 84 |
|
| 85 |
default: |
| 86 |
$share_text = ucfirst( esc_html( $share_platform ) ); |
| 87 |
} |
| 88 |
|
| 89 |
$defaults[] = [ |
| 90 |
'share_items' => esc_html( $share_platform ), |
| 91 |
'share_text' => $share_text, |
| 92 |
]; |
| 93 |
$sharing_list[ $share_platform ] = ucfirst( esc_html( $share_platform ) ); |
| 94 |
} |
| 95 |
|
| 96 |
$fields['platforms_section'] = $obj->start_section( |
| 97 |
esc_html__( 'Social Share Platforms', 'shopbuilder' ), |
| 98 |
self::$tab |
| 99 |
); |
| 100 |
|
| 101 |
$fields['show_share_icon'] = [ |
| 102 |
'type' => 'switch', |
| 103 |
'label' => esc_html__( 'Show Sharing Icon?', 'shopbuilder' ), |
| 104 |
'description' => esc_html__( 'Switch on to show social sharing icon.', 'shopbuilder' ), |
| 105 |
'label_on' => esc_html__( 'On', 'shopbuilder' ), |
| 106 |
'label_off' => esc_html__( 'Off', 'shopbuilder' ), |
| 107 |
'separator' => 'default', |
| 108 |
'default' => 'yes', |
| 109 |
]; |
| 110 |
|
| 111 |
$fields['share_platforms'] = [ |
| 112 |
'type' => 'repeater', |
| 113 |
'mode' => 'repeater', |
| 114 |
'label' => esc_html__( 'Add Sharing Platforms', 'shopbuilder' ), |
| 115 |
'separator' => 'before', |
| 116 |
'title_field' => '{{{ share_items }}}', |
| 117 |
'fields' => [ |
| 118 |
'share_items' => [ |
| 119 |
'label' => esc_html__( 'Platform Name', 'shopbuilder' ), |
| 120 |
'type' => 'select', |
| 121 |
'separator' => 'default', |
| 122 |
'options' => $sharing_list, |
| 123 |
], |
| 124 |
'share_text' => [ |
| 125 |
'label' => esc_html__( 'Sharing Text', 'shopbuilder' ), |
| 126 |
'type' => 'text', |
| 127 |
], |
| 128 |
], |
| 129 |
'default' => $defaults, |
| 130 |
]; |
| 131 |
|
| 132 |
$fields['platforms_section_end'] = $obj->end_section(); |
| 133 |
|
| 134 |
return apply_filters( 'rtsb/elements/elementor/platforms_control', $fields, $obj ); |
| 135 |
} |
| 136 |
} |
| 137 |
|