PluginProbe
Elementor Website Builder – more than just a page builder / 3.23.0-dev3
Elementor Website Builder – more than just a page builder v3.23.0-dev3
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
elementor / core / base / providers / social-network-provider.php

social-network-provider.php in Elementor Website Builder – more than just a page builder 3.23.0-dev3, at core/base/providers/social-network-provider.php

271 lines 6.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Core\Base\Providers;
4
5 class Social_Network_Provider {
6
7 private static array $social_networks = [];
8
9 public const FACEBOOK = 'Facebook';
10 public const TWITTER = 'X (Twitter)';
11 public const INSTAGRAM = 'Instagram';
12 public const LINKEDIN = 'LinkedIn';
13 public const PINTEREST = 'Pinterest';
14 public const YOUTUBE = 'YouTube';
15 public const TIKTOK = 'TikTok';
16 public const WHATSAPP = 'WhatsApp';
17 public const APPLEMUSIC = 'Apple Music';
18 public const SPOTIFY = 'Spotify';
19 public const SOUNDCLOUD = 'SoundCloud';
20 public const BEHANCE = 'Behance';
21 public const DRIBBBLE = 'Dribbble';
22 public const VIMEO = 'Vimeo';
23 public const WAZE = 'Waze';
24 public const MESSENGER = 'Messenger';
25 public const TELEPHONE = 'Telephone';
26 public const EMAIL = 'Email';
27 public const URL = 'Url';
28 public const FILE_DOWNLOAD = 'File Download';
29 public const SMS = 'SMS';
30 public const VIBER = 'VIBER';
31 public const SKYPE = 'Skype';
32 public const VCF = 'Save contact (vCard)';
33
34 public static function get_social_networks_icons(): array {
35 static::init_social_networks_array_if_empty();
36
37 static $icons = [];
38
39 if ( empty( $icons ) ) {
40 foreach ( static::$social_networks as $network => $data ) {
41 $icons[ $network ] = $data['icon'];
42 }
43 }
44
45 return $icons;
46 }
47
48 public static function get_icon_mapping( string $platform ): string {
49 static::init_social_networks_array_if_empty();
50
51 if ( isset( self::$social_networks[ $platform ]['icon'] ) ) {
52 return self::$social_networks[ $platform ]['icon'];
53 }
54
55 return '';
56
57 }
58
59 public static function get_name_mapping( string $platform ): string {
60 static::init_social_networks_array_if_empty();
61
62 if ( isset( self::$social_networks[ $platform ]['name'] ) ) {
63 return self::$social_networks[ $platform ]['name'];
64 }
65
66 return '';
67 }
68
69 public static function get_social_networks_text( $providers = [] ): array {
70 static::init_social_networks_array_if_empty();
71
72 static $texts = [];
73
74 if ( empty( $texts ) ) {
75 foreach ( static::$social_networks as $network => $data ) {
76 $texts[ $network ] = $data['text'];
77 }
78 }
79
80 if ( $providers ) {
81 return array_intersect_key( $texts, array_flip( $providers ) );
82 }
83
84 return $texts;
85 }
86
87 private static function init_social_networks_array_if_empty(): void {
88 if ( ! empty( static::$social_networks ) ) {
89 return;
90 }
91
92 static::$social_networks[ static::VCF ] = [
93 'text' => esc_html__( 'Save contact (vCard)', 'elementor' ),
94 'icon' => 'fab fa-outlook',
95 'name' => 'vcf',
96 ];
97
98 static::$social_networks[ static::FACEBOOK ] = [
99 'text' => esc_html__( 'Facebook', 'elementor' ),
100 'icon' => 'fab fa-facebook',
101 'name' => 'facebook',
102 ];
103
104 static::$social_networks[ static::TWITTER ] = [
105 'text' => esc_html__( 'X (Twitter)', 'elementor' ),
106 'icon' => 'fab fa-x-twitter',
107 'name' => 'x-twitter',
108 ];
109
110 static::$social_networks[ static::INSTAGRAM ] = [
111 'text' => esc_html__( 'Instagram', 'elementor' ),
112 'icon' => 'fab fa-instagram',
113 'name' => 'instagram',
114 ];
115
116 static::$social_networks[ static::LINKEDIN ] = [
117 'text' => esc_html__( 'LinkedIn', 'elementor' ),
118 'icon' => 'fab fa-linkedin-in',
119 'name' => 'linkedin',
120 ];
121
122 static::$social_networks[ static::PINTEREST ] = [
123 'text' => esc_html__( 'Pinterest', 'elementor' ),
124 'icon' => 'fab fa-pinterest',
125 'name' => 'pinterest',
126 ];
127
128 static::$social_networks[ static::YOUTUBE ] = [
129 'text' => esc_html__( 'YouTube', 'elementor' ),
130 'icon' => 'fab fa-youtube',
131 'name' => 'youtube',
132 ];
133
134 static::$social_networks[ static::TIKTOK ] = [
135 'text' => esc_html__( 'TikTok', 'elementor' ),
136 'icon' => 'fab fa-tiktok',
137 'name' => 'tiktok',
138 ];
139
140 static::$social_networks[ static::WHATSAPP ] = [
141 'text' => esc_html__( 'WhatsApp', 'elementor' ),
142 'icon' => 'fab fa-whatsapp',
143 'name' => 'whatsapp',
144 ];
145
146 static::$social_networks[ static::APPLEMUSIC ] = [
147 'text' => esc_html__( 'Apple Music', 'elementor' ),
148 'icon' => 'fa fa-music',
149 'name' => 'apple-music',
150 ];
151
152 static::$social_networks[ static::SPOTIFY ] = [
153 'text' => esc_html__( 'Spotify', 'elementor' ),
154 'icon' => 'fab fa-spotify',
155 'name' => 'spotify',
156 ];
157
158 static::$social_networks[ static::SOUNDCLOUD ] = [
159 'text' => esc_html__( 'SoundCloud', 'elementor' ),
160 'icon' => 'fab fa-soundcloud',
161 'name' => 'soundcloud',
162 ];
163
164 static::$social_networks[ static::BEHANCE ] = [
165 'text' => esc_html__( 'Behance', 'elementor' ),
166 'icon' => 'fab fa-behance',
167 'name' => 'behance',
168 ];
169
170 static::$social_networks[ static::DRIBBBLE ] = [
171 'text' => esc_html__( 'Dribbble', 'elementor' ),
172 'icon' => 'fab fa-dribbble',
173 'name' => 'dribble',
174 ];
175
176 static::$social_networks[ static::VIMEO ] = [
177 'text' => esc_html__( 'Vimeo', 'elementor' ),
178 'icon' => 'fab fa-vimeo-v',
179 'name' => 'vimeo',
180 ];
181
182 static::$social_networks[ static::WAZE ] = [
183 'text' => esc_html__( 'Waze', 'elementor' ),
184 'icon' => 'fab fa-waze',
185 'name' => 'waze',
186 ];
187
188 static::$social_networks[ static::MESSENGER ] = [
189 'text' => esc_html__( 'Messenger', 'elementor' ),
190 'icon' => 'fab fa-facebook-messenger',
191 'name' => 'messenger',
192 ];
193
194 static::$social_networks[ static::TELEPHONE ] = [
195 'text' => esc_html__( 'Telephone', 'elementor' ),
196 'icon' => 'fas fa-phone-alt',
197 'name' => 'phone',
198 ];
199
200 static::$social_networks[ static::EMAIL ] = [
201 'text' => esc_html__( 'Email', 'elementor' ),
202 'icon' => 'fas fa-envelope',
203 'name' => 'email',
204 ];
205
206 static::$social_networks[ static::URL ] = [
207 'text' => esc_html__( 'URL', 'elementor' ),
208 'icon' => 'fas fa-globe',
209 'name' => 'url',
210 ];
211
212 static::$social_networks[ static::FILE_DOWNLOAD ] = [
213 'text' => esc_html__( 'File Download', 'elementor' ),
214 'icon' => 'fas fa-download',
215 'name' => 'download',
216 ];
217
218 static::$social_networks[ static::SMS ] = [
219 'text' => esc_html__( 'SMS', 'elementor' ),
220 'icon' => 'fas fa-sms',
221 'name' => 'sms',
222 ];
223
224 static::$social_networks[ static::VIBER ] = [
225 'text' => esc_html__( 'Viber', 'elementor' ),
226 'icon' => 'fab fa-viber',
227 'name' => 'viber',
228 ];
229
230 static::$social_networks[ static::SKYPE ] = [
231 'text' => esc_html__( 'Skype', 'elementor' ),
232 'icon' => 'fab fa-skype',
233 'name' => 'skype',
234 ];
235 }
236
237 public static function build_email_link( array $data, string $prefix ) {
238 $email = $data[ $prefix . '_mail' ] ?? '';
239 $subject = $data[ $prefix . '_mail_subject' ] ?? '';
240 $body = $data[ $prefix . '_mail_body' ] ?? '';
241
242 if ( ! $email ) {
243 return '';
244 }
245
246 $link = 'mailto:' . $email;
247
248 if ( $subject ) {
249 $link .= '?subject=' . $subject;
250 }
251
252 if ( $body ) {
253 $link .= $subject ? '&' : '?';
254 $link .= 'body=' . $body;
255 }
256
257 return $link;
258 }
259
260
261 public static function build_viber_link( string $action, string $number ) {
262 if ( empty( $number ) ) {
263 return '';
264 }
265
266 return add_query_arg( [
267 'number' => urlencode( $number ),
268 ], 'viber://' . $action );
269 }
270 }
271