| 1 |
<?php |
| 2 |
/** |
| 3 |
* SocialShare class. |
| 4 |
* |
| 5 |
* @package RadiusTheme\SB |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace RadiusTheme\SB\Elementor\Widgets\General; |
| 9 |
|
| 10 |
use RadiusTheme\SB\Helpers\Fns; |
| 11 |
use RadiusTheme\SB\Elementor\Render\Render; |
| 12 |
use RadiusTheme\SB\Elementor\Widgets\Controls; |
| 13 |
use RadiusTheme\SB\Abstracts\ElementorWidgetBase; |
| 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 |
* SocialShare class. |
| 22 |
*/ |
| 23 |
class SocialShare extends ElementorWidgetBase { |
| 24 |
/** |
| 25 |
* Control Fields |
| 26 |
* |
| 27 |
* @var array |
| 28 |
*/ |
| 29 |
private $control_fields = []; |
| 30 |
|
| 31 |
/** |
| 32 |
* Construct function |
| 33 |
* |
| 34 |
* @param array $data default array. |
| 35 |
* @param mixed $args default arg. |
| 36 |
*/ |
| 37 |
public function __construct( $data = [], $args = null ) { |
| 38 |
$this->rtsb_name = esc_html__( 'Social Share', 'shopbuilder' ); |
| 39 |
$this->rtsb_base = 'rtsb-social-share'; |
| 40 |
|
| 41 |
parent::__construct( $data, $args ); |
| 42 |
|
| 43 |
$this->pro_tab = 'content'; |
| 44 |
$this->rtsb_category = 'rtsb-shopbuilder-general'; |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Controls for layout tab |
| 49 |
* |
| 50 |
* @return SocialShare |
| 51 |
*/ |
| 52 |
protected function layout_tab() { |
| 53 |
$sections = apply_filters( |
| 54 |
'rtsb/elements/elementor/share_layout_tab', |
| 55 |
array_merge( |
| 56 |
Controls\ContentFields::share_presets( $this ), |
| 57 |
Controls\ContentFields::share_platforms( $this ), |
| 58 |
) |
| 59 |
); |
| 60 |
|
| 61 |
$this->control_fields = array_merge( $this->control_fields, $sections ); |
| 62 |
|
| 63 |
return $this; |
| 64 |
} |
| 65 |
|
| 66 |
/** |
| 67 |
* Controls for style tab |
| 68 |
* |
| 69 |
* @return SocialShare |
| 70 |
*/ |
| 71 |
protected function style_tab() { |
| 72 |
$sections = apply_filters( |
| 73 |
'rtsb/elements/elementor/share_style_tab', |
| 74 |
array_merge( |
| 75 |
Controls\StyleFields::share_items( $this ), |
| 76 |
Controls\StyleFields::share_icons( $this ), |
| 77 |
Controls\StyleFields::share_text( $this ), |
| 78 |
) |
| 79 |
); |
| 80 |
|
| 81 |
$this->control_fields = array_merge( $this->control_fields, $sections ); |
| 82 |
|
| 83 |
return $this; |
| 84 |
} |
| 85 |
|
| 86 |
/** |
| 87 |
* Widget Field |
| 88 |
* |
| 89 |
* @return void|array |
| 90 |
*/ |
| 91 |
public function widget_fields() { |
| 92 |
$this->layout_tab()->style_tab(); |
| 93 |
|
| 94 |
if ( empty( $this->control_fields ) ) { |
| 95 |
return []; |
| 96 |
} |
| 97 |
|
| 98 |
return apply_filters( 'rtsb/elements/elementor/general/' . $this->rtsb_base, $this->control_fields, $this ); |
| 99 |
} |
| 100 |
|
| 101 |
/** |
| 102 |
* Render Function |
| 103 |
* |
| 104 |
* @return void |
| 105 |
*/ |
| 106 |
protected function render() { |
| 107 |
$settings = $this->get_settings_for_display(); |
| 108 |
$this->theme_support(); |
| 109 |
$template = 'elementor/general/social-share'; |
| 110 |
|
| 111 |
Fns::print_html( Render::instance()->social_share_view( $template, $settings ), true ); |
| 112 |
$this->theme_support( 'render_reset' ); |
| 113 |
} |
| 114 |
|
| 115 |
} |
| 116 |
|