PluginProbe ʕ •ᴥ•ʔ
Hustle – Email Marketing, Lead Generation, Optins, Popups / 7.8.9
Hustle – Email Marketing, Lead Generation, Optins, Popups v7.8.9
7.8.13 7.8.13.1 trunk 3.0 3.1 3.1.1 3.1.2 3.1.3 3.1.4 4.3.2 4.4.4 4.4.5 4.4.5.1 4.4.5.4 4.6 4.6.1.1 4.6.1.4 4.7.0.2 4.7.0.3 4.7.0.7 4.7.0.9 4.7.1.0 4.7.1.1 4.8.0.0 5.0.0 5.0.1 5.0.1.1 5.0.1.2 5.1 5.1.1 5.1.2 5.1.3 5.1.3.1 5.1.3.2 5.1.4 5.1.5 6.0 6.0.1 6.0.2 6.0.3 6.0.4.2 6.0.5 6.0.6.1 6.0.7 6.0.8.1 6.0.9 7.0.0.1 7.0.2 7.0.3 7.0.4 7.1.0 7.1.1 7.2.0 7.2.1 7.3.0 7.3.1 7.3.3 7.3.5 7.3.6 7.3.7 7.4.0 7.4.1 7.4.11 7.4.13 7.4.13.1 7.4.2 7.4.3 7.4.4 7.4.5 7.4.5.1 7.4.5.2 7.4.6 7.4.7 7.5.0 7.6.0 7.6.1 7.6.3 7.6.4 7.6.6 7.7.0 7.7.1 7.8.0 7.8.1 7.8.10 7.8.10.1 7.8.10.2 7.8.11 7.8.12 7.8.12.1 7.8.2 7.8.3 7.8.4 7.8.5 7.8.6 7.8.7 7.8.8 7.8.9 7.8.9.1 7.8.9.2 7.8.9.3
wordpress-popup / inc / front / hustle-renderer-sshare.php
wordpress-popup / inc / front Last commit date
non-sshare-styles 9 months ago class-hustle-decorator-non-sshare.php 3 years ago class-hustle-decorator-sshare.php 9 months ago class-hustle-decorator_abstract.php 3 years ago class-hustle-module-preview.php 1 year ago hustle-module-front-ajax.php 1 year ago hustle-module-front.php 2 years ago hustle-module-renderer.php 9 months ago hustle-renderer-abstract.php 3 years ago hustle-renderer-sshare.php 3 years ago
hustle-renderer-sshare.php
455 lines
1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 /**
3 * Hustle_Renderer_Sshare
4 *
5 * @package Hustle
6 */
7
8 /**
9 * Class Hustle_Renderer_Sshare
10 * Used to render Social sharing modules.
11 *
12 * @since 4.0
13 */
14 class Hustle_Renderer_Sshare extends Hustle_Renderer_Abstract {
15
16 /**
17 * Get the content container tag.
18 *
19 * @since 4.0
20 * @param string $subtype Sub type.
21 * @param string $custom_classes Custom classes.
22 * @return string
23 */
24 protected function get_wrapper_main( $subtype, $custom_classes ) {
25
26 $module_id = $this->module->module_id;
27 $display = $this->module->display;
28
29 // Tracking enabled data.
30 $tracking_enabled_data = $this->module->is_tracking_enabled( $subtype ) ? 'enabled' : 'disabled';
31
32 // Type of module
33 // Applies for all except "float" modules.
34 $module_type = 'inline';
35
36 // Main data attributes for module.
37 $module_data = sprintf(
38 '
39 data-id="%s"
40 data-render-id="%d"
41 data-tracking="%s"
42 data-sub-type="%s"
43 ',
44 esc_attr( $module_id ),
45 self::$render_ids[ $module_id ],
46 esc_attr( $tracking_enabled_data ),
47 esc_attr( $subtype )
48 );
49
50 // If this instance is a floating module.
51 // This happens when floating is enabled in either desktop or mobile.
52 if ( Hustle_SShare_Model::FLOAT_MODULE === $subtype ) {
53
54 $module_type = 'float';
55
56 // Check if the module has floating active for desktop.
57 if ( self::$is_preview ) {
58 $module_data .= 'data-desktop="true"';
59 } elseif ( $this->module->is_display_type_active( Hustle_SShare_Model::FLOAT_DESKTOP ) ) {
60
61 $offset = 'css_selector' === $display->float_desktop_offset ? 'selector' : $display->float_desktop_offset;
62 $selector = 'selector' === $offset ? trim( $display->float_desktop_css_selector ) : '';
63 $position_x = $display->float_desktop_position;
64 $position_y = $display->float_desktop_position_y;
65
66 $module_data .= sprintf(
67 '
68 data-desktop="true"
69 data-desktop-offset="%s"
70 data-desktop-selector="%s"
71 data-desktop-positionX="%s"
72 data-desktop-positionY="%s"
73 ',
74 esc_attr( $offset ),
75 esc_attr( $selector ),
76 esc_attr( $position_x ),
77 esc_attr( $position_y )
78 );
79 } else {
80 $module_data .= 'data-desktop="false"';
81 }
82
83 // Check if the module has floating active for mobile.
84 if ( $this->module->is_display_type_active( Hustle_SShare_Model::FLOAT_MOBILE ) ) {
85
86 $offset = 'css_selector' === $display->float_mobile_offset ? 'selector' : $display->float_mobile_offset;
87 $selector = 'selector' === $offset ? trim( $display->float_mobile_css_selector ) : '';
88 $position_x = $display->float_mobile_position;
89 $position_y = $display->float_mobile_position_y;
90
91 $module_data .= sprintf(
92 '
93 data-mobiles="true"
94 data-mobiles-offset="%s"
95 data-mobiles-selector="%s"
96 data-mobiles-positionX="%s"
97 data-mobiles-positionY="%s"
98 ',
99 esc_attr( $offset ),
100 esc_attr( $selector ),
101 esc_attr( $position_x ),
102 esc_attr( $position_y )
103 );
104 } else {
105 $module_data .= 'data-mobiles="false"';
106 }
107 } else {
108
109 $module_data .= sprintf(
110 '
111 data-delay="%s"
112 data-intro="%s"
113 ',
114 '0',
115 'no_animation'
116 );
117
118 if ( Hustle_SShare_Model::INLINE_MODULE === $subtype ) {
119
120 $module_data .= sprintf(
121 'data-alignment="%s"',
122 esc_attr( $display->inline_align )
123 );
124 }
125 }
126
127 $inline_style = ! self::$is_preview ? 'style="opacity:0;"' : 'style="opacity:1;"';
128
129 if ( self::$is_preview ) {
130 $custom_classes .= ' hustle-displaying-in-large';
131 }
132
133 $html = sprintf(
134 '<div class="hustle-ui hustle-%s hustle_module_id_%d %s" %s %s>',
135 esc_attr( $module_type ),
136 $this->module->module_id,
137 esc_attr( $custom_classes ),
138 $module_data,
139 $inline_style
140 );
141
142 return $html;
143
144 }
145
146 /**
147 * Get the wrapper content.
148 *
149 * @since 4.0
150 *
151 * @param string $subtype Sub type.
152 * @return string
153 */
154 protected function get_wrapper_content( $subtype ) {
155
156 $module_type = 'inline';
157
158 if ( Hustle_SShare_Model::FLOAT_MODULE === $subtype ) {
159 $module_type = 'float';
160 }
161
162 $html = sprintf(
163 '<div class="hustle-%s-content">',
164 $module_type
165 );
166
167 return $html;
168
169 }
170
171 /**
172 * Get the body content.
173 *
174 * @since 4.0
175 *
176 * @param string $subtype Sub type.
177 * @return string
178 */
179 protected function get_module_body( $subtype ) {
180
181 $html = '';
182
183 $module_id = $this->module->module_id;
184
185 // Prevent php error messages on wizard preview when no services are active.
186 $content = $this->module->content;
187 $display = $this->module->display;
188 $design = $this->module->design;
189
190 $icons_design = $design->icon_style;
191 $icons_custom_color = 'false';
192 $icons_grid_desktop = 'inline';
193 $icons_grid_mobiles = 'inline';
194 $icons_counter = 'none';
195 $icons_animated = false;
196 $icons_animation = 'zoom';
197
198 if ( 'flat' === $icons_design ) {
199 $icons_design = 'default';
200 } elseif ( 'outline' === $icons_design ) {
201 $icons_design = 'outlined';
202 }
203
204 if ( Hustle_SShare_Model::FLOAT_MODULE === $subtype ) {
205
206 // Check if icons custom color is enabled.
207 $icons_custom_color = ( '1' === $design->floating_customize_colors ) ? 'true' : 'false';
208
209 // Check if the module has floating active for desktop.
210 if ( $this->module->is_display_type_active( Hustle_SShare_Model::FLOAT_DESKTOP ) ) {
211
212 $position_x = $display->float_desktop_position;
213 $position_y = $display->float_desktop_position_y;
214
215 if ( 'center' !== $display->float_desktop_position ) {
216 $icons_grid_desktop = 'stacked';
217 }
218
219 if ( 'center' === $position_x ) {
220
221 if ( 'top' === $position_y ) {
222 $icons_animation = 'bounceDownUp';
223 } else {
224 $icons_animation = 'bounceUpDown';
225 }
226 }
227 }
228
229 // Check if the module has floating active for mobile.
230 if ( $this->module->is_display_type_active( Hustle_SShare_Model::FLOAT_MOBILE ) ) {
231
232 $position_x = $display->float_mobile_position;
233 $position_y = $display->float_mobile_position_y;
234
235 if ( 'center' !== $display->float_mobile_position ) {
236 $icons_grid_mobiles = 'stacked';
237 }
238
239 if ( 'center' === $position_x ) {
240
241 if ( 'top' === $position_y ) {
242 $icons_animation = 'bounceDownUp';
243 } else {
244 $icons_animation = 'bounceUpDown';
245 }
246 }
247 }
248
249 if ( self::$is_preview ) {
250 $icons_grid_desktop = 'stacked';
251 $icons_grid_mobiles = 'stacked';
252 }
253
254 // Check if counter is enabled.
255 if ( '1' === $content->counter_enabled ) {
256 $icons_counter = ( '1' === $design->floating_inline_count ) ? 'inline' : 'stacked';
257 }
258
259 // Check if icons are animated.
260 if ( '1' === $design->floating_animate_icons ) {
261 $icons_animated = true;
262 }
263 } else {
264
265 // Check if icons custom color is enabled.
266 $icons_custom_color = ( '1' === $design->widget_customize_colors ) ? 'true' : 'false';
267
268 // Check if counter is enabled.
269 if ( '1' === $content->counter_enabled ) {
270 $icons_counter = ( '1' === $design->widget_inline_count ) ? 'inline' : 'stacked';
271 }
272
273 // Check if icons are animated.
274 if ( '1' === $design->widget_animate_icons ) {
275 $icons_animated = true;
276 }
277 }
278
279 $html .= sprintf(
280 '<div class="hustle-social hustle-social--%s" data-custom="%s" data-grid-desktop="%s" data-grid-mobiles="%s">',
281 esc_attr( $icons_design ),
282 esc_attr( $icons_custom_color ),
283 esc_attr( $icons_grid_desktop ),
284 esc_attr( $icons_grid_mobiles )
285 );
286
287 $html .= sprintf(
288 '<ul class="hustle-counter--%s%s"%s>',
289 esc_attr( $icons_counter ),
290 ( true === $icons_animated ? ' hustle-animated' : '' ),
291 ( true === $icons_animated ? ' data-animation="' . esc_attr( $icons_animation ) . '"' : '' )
292 );
293
294 $social_icons = $content->social_icons;
295
296 /**
297 * Filters the icons to be shown.
298 * Here you can add custom icons to be printed. It only works for networks
299 * using custom links (non-native ones), and without counters.
300 * The icon and visual attributes must be handled via custom CSS.
301 *
302 * @since 4.1.2
303 *
304 * @param array $social_icons {
305 * Selected social networks for the module.
306 * Contains an array for each platform. The platform's slug is the key of its array.
307 * The array for each platform must contain:
308 *
309 * @type string 'platform' The network's slug. Same as the array key. Lowercase, no spaces nor special chars.
310 * @type string 'label' The network's display name.
311 * @type string 'type' click|native Whether the counter would be retrieved from clicks or an API. Use 'click'.
312 * @type string 'link' The URL to which the user will go when clicking the icon. Required if a sharing
313 * endpoint isn't especified in the filter @see hustle_native_share_enpoints.
314 * @type int 'counter' The default number for the counter. This will be static, it won't increase for now.
315 * }
316 */
317 $social_icons = apply_filters( 'hustle_social_sharing_get_selected_networks', $social_icons, $this->module );
318
319 // Extra indentation to mimic html tree.
320 if ( ! empty( $social_icons ) ) {
321
322 foreach ( $social_icons as $icon => $data ) {
323
324 $type = isset( $data['type'] ) ? $data['type'] : '';
325 $label = isset( $data['label'] ) ? $data['label'] : '';
326 $link = isset( $data['link'] ) ? $data['link'] : '';
327
328 if ( 'facebook' === $data['platform'] ) {
329 $type = 'click';
330 }
331
332 if ( '' === $link && 'email' !== $icon ) {
333
334 $href_value = 'href="#"';
335 $link_type = 'native';
336
337 } else {
338 // Check if is email to insert mailto.
339 if ( 'email' === $icon ) {
340
341 $query_args = array(
342 'subject' => rawurlencode( Opt_In_Utils::replace_global_placeholders( $data['title'] ) ),
343 'body' => rawurlencode( Opt_In_Utils::replace_global_placeholders( $data['message'] ) ),
344 );
345 $mail_url = add_query_arg( $query_args, 'mailto:' );
346 $href_value = 'href="' . esc_url( $mail_url ) . '"';
347 $title = apply_filters( 'hustle_social_share_platform_title', rawurlencode( html_entity_decode( esc_html( get_the_title() ) ) ) );
348
349 } else {
350 $link = apply_filters( 'hustle_social_share_custom_link', $link, $data, $this->module );
351 $href_value = 'href="' . esc_url( $link ) . '" target="_blank" rel="noopener"';
352 }
353
354 $link_type = 'custom';
355
356 }
357
358 if ( 'fivehundredpx' === $icon ) {
359 $icon = '500px';
360 $network = 'fivehundredpx';
361 } else {
362 $network = $icon;
363 }
364
365 $html .= '<li>';
366
367 $html .= sprintf(
368 '<a %1$s class="hustle-share-icon hustle-share--%2$s" data-network="%3$s" data-counter="%4$s" data-link="%5$s" data-count="%6$s">',
369 $href_value,
370 esc_attr( $icon ),
371 esc_attr( $network ),
372 '0' === $content->counter_enabled ? 'none' : esc_attr( $type ),
373 esc_attr( $link_type ),
374 esc_attr( $data['counter'] )
375 );
376
377 $html .= sprintf(
378 '<i class="hustle-icon-social-%s" aria-hidden="true"></i>',
379 esc_attr( $icon )
380 );
381
382 if ( '1' === $content->counter_enabled ) {
383
384 if ( 'native' === $type && ! self::$is_preview ) {
385 $counter_content = '<i class="hustle-icon-loader hustle-loading-icon" aria-hidden="true"></i>';
386
387 } else {
388 $counter_content = ( '' !== $data['counter'] ) ? esc_attr( $data['counter'] ) : '0';
389 }
390
391 $html .= sprintf(
392 '<span class="hustle-counter" aria-hidden="true">%s</span>',
393 $counter_content
394 );
395 }
396
397 $html .= sprintf(
398 '<span class="hustle-screen-reader">Share on %s</span>',
399 esc_html( $label )
400 );
401
402 $html .= '</a>';
403
404 $html .= '</li>';
405
406 }
407 }
408
409 $html .= '</ul>';
410
411 $html .= '</div>';
412
413 return $html;
414
415 }
416
417 /**
418 * Handle AJAX display
419 *
420 * @since 4.0
421 * @param Hustle_Sshare_Model $module Module.
422 * @param array $data Data.
423 * @param bool $is_preview Is preview.
424 * @return string
425 */
426 public function ajax_display( Hustle_Sshare_Model $module, $data = array(), $is_preview = true ) {
427
428 self::$is_preview = $is_preview;
429
430 if ( ! empty( $data ) ) {
431 $this->module = $module->load_preview( $data );
432 } else {
433 $this->module = $module->load();
434 }
435
436 $response = array(
437 'style' => array(),
438 'script' => array(),
439 'module' => $this->module,
440 );
441
442 $response['floatingHtml'] = $this->get_module( Hustle_SShare_Model::FLOAT_MODULE, 'hustle-show', $is_preview );
443 $response['widgetHtml'] = $this->get_module( Hustle_SShare_Model::WIDGET_MODULE, 'hustle-show', $is_preview );
444
445 // This might be used later for ajax loading.
446 ob_start();
447 $this->print_styles( $is_preview );
448 $styles = ob_get_clean();
449 $response['style'] = $styles;
450
451 return $response;
452 }
453
454 }
455