PluginProbe
Elementor Website Builder – more than just a page builder / 3.24.7
Elementor Website Builder – more than just a page builder v3.24.7
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.24.7, at core/base/providers/social-network-provider.php

285 lines 7.2 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_text_mapping( string $platform ): string {
70 static::init_social_networks_array_if_empty();
71
72 if ( isset( self::$social_networks[ $platform ]['text'] ) ) {
73 return self::$social_networks[ $platform ]['text'];
74 }
75
76 return '';
77 }
78
79 public static function get_social_networks_text( $providers = [] ): array {
80 static::init_social_networks_array_if_empty();
81
82 static $texts = [];
83
84 if ( empty( $texts ) ) {
85 foreach ( static::$social_networks as $network => $data ) {
86 $texts[ $network ] = $data['text'];
87 }
88 }
89
90 if ( $providers ) {
91 return array_intersect_key( $texts, array_flip( $providers ) );
92 }
93
94 return $texts;
95 }
96
97 private static function init_social_networks_array_if_empty(): void {
98 if ( ! empty( static::$social_networks ) ) {
99 return;
100 }
101
102 static::$social_networks[ static::VCF ] = [
103 'text' => esc_html__( 'Save contact (vCard)', 'elementor' ),
104 'icon' => 'fab fa-outlook',
105 'name' => 'vcf',
106 ];
107
108 static::$social_networks[ static::FACEBOOK ] = [
109 'text' => esc_html__( 'Facebook', 'elementor' ),
110 'icon' => 'fab fa-facebook',
111 'name' => 'facebook',
112 ];
113
114 static::$social_networks[ static::TWITTER ] = [
115 'text' => esc_html__( 'X (Twitter)', 'elementor' ),
116 'icon' => 'fab fa-x-twitter',
117 'name' => 'x-twitter',
118 ];
119
120 static::$social_networks[ static::INSTAGRAM ] = [
121 'text' => esc_html__( 'Instagram', 'elementor' ),
122 'icon' => 'fab fa-instagram',
123 'name' => 'instagram',
124 ];
125
126 static::$social_networks[ static::LINKEDIN ] = [
127 'text' => esc_html__( 'LinkedIn', 'elementor' ),
128 'icon' => 'fab fa-linkedin-in',
129 'name' => 'linkedin',
130 ];
131
132 static::$social_networks[ static::PINTEREST ] = [
133 'text' => esc_html__( 'Pinterest', 'elementor' ),
134 'icon' => 'fab fa-pinterest',
135 'name' => 'pinterest',
136 ];
137
138 static::$social_networks[ static::YOUTUBE ] = [
139 'text' => esc_html__( 'YouTube', 'elementor' ),
140 'icon' => 'fab fa-youtube',
141 'name' => 'youtube',
142 ];
143
144 static::$social_networks[ static::TIKTOK ] = [
145 'text' => esc_html__( 'TikTok', 'elementor' ),
146 'icon' => 'fab fa-tiktok',
147 'name' => 'tiktok',
148 ];
149
150 static::$social_networks[ static::WHATSAPP ] = [
151 'text' => esc_html__( 'WhatsApp', 'elementor' ),
152 'icon' => 'fab fa-whatsapp',
153 'name' => 'whatsapp',
154 ];
155
156 static::$social_networks[ static::APPLEMUSIC ] = [
157 'text' => esc_html__( 'Apple Music', 'elementor' ),
158 'icon' => 'fa fa-music',
159 'name' => 'apple-music',
160 ];
161
162 static::$social_networks[ static::SPOTIFY ] = [
163 'text' => esc_html__( 'Spotify', 'elementor' ),
164 'icon' => 'fab fa-spotify',
165 'name' => 'spotify',
166 ];
167
168 static::$social_networks[ static::SOUNDCLOUD ] = [
169 'text' => esc_html__( 'SoundCloud', 'elementor' ),
170 'icon' => 'fab fa-soundcloud',
171 'name' => 'soundcloud',
172 ];
173
174 static::$social_networks[ static::BEHANCE ] = [
175 'text' => esc_html__( 'Behance', 'elementor' ),
176 'icon' => 'fab fa-behance',
177 'name' => 'behance',
178 ];
179
180 static::$social_networks[ static::DRIBBBLE ] = [
181 'text' => esc_html__( 'Dribbble', 'elementor' ),
182 'icon' => 'fab fa-dribbble',
183 'name' => 'dribble',
184 ];
185
186 static::$social_networks[ static::VIMEO ] = [
187 'text' => esc_html__( 'Vimeo', 'elementor' ),
188 'icon' => 'fab fa-vimeo-v',
189 'name' => 'vimeo',
190 ];
191
192 static::$social_networks[ static::WAZE ] = [
193 'text' => esc_html__( 'Waze', 'elementor' ),
194 'icon' => 'fab fa-waze',
195 'name' => 'waze',
196 ];
197
198 static::$social_networks[ static::MESSENGER ] = [
199 'text' => esc_html__( 'Messenger', 'elementor' ),
200 'icon' => 'fab fa-facebook-messenger',
201 'name' => 'messenger',
202 ];
203
204 static::$social_networks[ static::TELEPHONE ] = [
205 'text' => esc_html__( 'Telephone', 'elementor' ),
206 'icon' => 'fas fa-phone-alt',
207 'name' => 'phone',
208 ];
209
210 static::$social_networks[ static::EMAIL ] = [
211 'text' => esc_html__( 'Email', 'elementor' ),
212 'icon' => 'fas fa-envelope',
213 'name' => 'email',
214 ];
215
216 static::$social_networks[ static::URL ] = [
217 'text' => esc_html__( 'URL', 'elementor' ),
218 'icon' => 'fas fa-globe',
219 'name' => 'url',
220 ];
221
222 static::$social_networks[ static::FILE_DOWNLOAD ] = [
223 'text' => esc_html__( 'File Download', 'elementor' ),
224 'icon' => 'fas fa-download',
225 'name' => 'download',
226 ];
227
228 static::$social_networks[ static::SMS ] = [
229 'text' => esc_html__( 'SMS', 'elementor' ),
230 'icon' => 'fas fa-sms',
231 'name' => 'sms',
232 ];
233
234 static::$social_networks[ static::VIBER ] = [
235 'text' => esc_html__( 'Viber', 'elementor' ),
236 'icon' => 'fab fa-viber',
237 'name' => 'viber',
238 ];
239
240 static::$social_networks[ static::SKYPE ] = [
241 'text' => esc_html__( 'Skype', 'elementor' ),
242 'icon' => 'fab fa-skype',
243 'name' => 'skype',
244 ];
245 }
246
247 public static function build_messenger_link( string $username ) {
248 return 'https://m.me/' . $username;
249 }
250
251 public static function build_email_link( array $data, string $prefix ) {
252 $email = $data[ $prefix . '_mail' ] ?? '';
253 $subject = $data[ $prefix . '_mail_subject' ] ?? '';
254 $body = $data[ $prefix . '_mail_body' ] ?? '';
255
256 if ( ! $email ) {
257 return '';
258 }
259
260 $link = 'mailto:' . $email;
261
262 if ( $subject ) {
263 $link .= '?subject=' . $subject;
264 }
265
266 if ( $body ) {
267 $link .= $subject ? '&' : '?';
268 $link .= 'body=' . $body;
269 }
270
271 return $link;
272 }
273
274
275 public static function build_viber_link( string $action, string $number ) {
276 if ( empty( $number ) ) {
277 return '';
278 }
279
280 return add_query_arg( [
281 'number' => urlencode( $number ),
282 ], 'viber://' . $action );
283 }
284 }
285