PluginProbe ʕ •ᴥ•ʔ
PixelYourSite – Your smart PIXEL (TAG) & API Manager / 11.2.0.6
PixelYourSite – Your smart PIXEL (TAG) & API Manager v11.2.0.6
11.2.0.6 trunk 1.0 1.01 1.02 1.03 1.04 1.05 1.05.1 10.0.0 10.0.1 10.0.1.1 10.0.1.2 10.0.2 10.0.3 10.0.3.1 10.0.4 10.1.0 10.1.1 10.1.1.1 10.1.1.2 10.1.2.1 10.1.3 10.2.0 10.2.0.1 10.2.0.2 10.2.1 11.0.0 11.0.0.1 11.0.0.2 11.0.0.3 11.0.0.4 11.0.1 11.0.1.1 11.0.1.2 11.0.2 11.1.0 11.1.1 11.1.2 11.1.3 11.1.4 11.1.4.1 11.1.4.2 11.1.5 11.1.5.1 11.1.5.2 11.2.0 11.2.0.1 11.2.0.2 11.2.0.3 11.2.0.4 11.2.0.5 2.0 2.1 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.7 2.8.10 2.8.9 3.0 3.0.1 3.0.2 3.0.3 3.1.0 4.0.0 4.0.1 4.0.2 4.0.3 5.0.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5.2 5.0.6 5.0.7 5.0.8 5.0.9 5.1.0 5.2.0 5.2.1 5.3.0 5.3.1 5.3.2 5.3.3 5.3.4 7.0.0 7.0.1 7.0.2 7.0.3 7.0.4 7.0.5 7.1.0 7.1.1 7.1.10 7.1.11 7.1.12 7.1.13 7.1.14 7.1.2 7.1.3 7.1.4 7.1.5 7.1.6 7.1.7 7.1.8 7.1.9 7.2.0 7.2.1 7.2.1.1 7.3.0 8.0.0 8.0.1 8.0.2 8.0.3 8.0.4 8.0.5 8.0.6 8.0.7 8.0.8 8.0.9 8.1.0 8.1.1 8.2.0 8.2.1 8.2.10 8.2.11 8.2.12 8.2.13 8.2.14 8.2.15 8.2.16 8.2.17 8.2.18 8.2.2 8.2.3 8.2.4 8.2.5 8.2.6 8.2.7 8.2.8 9.0.0 9.1.0 9.1.1 9.2.0 9.2.1 9.2.2 9.3.0 9.3.1 9.3.2 9.3.3 9.3.4 9.3.5 9.3.6 9.3.7 9.3.8 9.3.8.1 9.3.9 9.4.0 9.4.0.1 9.4.1 9.4.2 9.4.3 9.4.5 9.4.5.1 9.4.6 9.4.7 9.4.7.1 9.5.0 9.5.0.1 9.5.1 9.5.1.1 9.5.3 9.5.4 9.5.5 9.6.0 9.6.0.1 9.6.1 9.6.1.1 9.6.2 9.7.0 9.7.0.1 9.7.1 9.7.2
pixelyoursite / includes / functions-custom-event.php
pixelyoursite / includes Last commit date
enrich 3 weeks ago event-definitions 4 months ago events 1 week ago formEvents 1 year ago logger 4 months ago views 1 week ago class-consent.php 6 months ago class-custom-event-factory.php 1 year ago class-custom-event.php 3 weeks ago class-event-definitions.php 4 months ago class-event-id-generator.php 5 years ago class-events-manager-ajax_hook.php 3 weeks ago class-events-manager.php 3 weeks ago class-fixed-notices.php 1 year ago class-optin-notices.php 1 year ago class-pixel.php 7 years ago class-plugin-updater.php 9 months ago class-plugin.php 7 years ago class-pys.php 1 week ago class-settings.php 4 months ago functions-admin.php 3 weeks ago functions-buttons.php 1 year ago functions-common.php 3 weeks ago functions-custom-event.php 1 week ago functions-edd.php 2 years ago functions-gdpr.php 11 months ago functions-license.php 3 weeks ago functions-migrate.php 9 months ago functions-promo-notices.php 1 year ago functions-system-report.php 7 years ago functions-update-plugin.php 6 years ago functions-woo.php 3 weeks ago options_defaults.json 3 weeks ago options_fields.json 3 weeks ago
functions-custom-event.php
719 lines
1 <?php
2
3 namespace PixelYourSite\Events;
4
5 use PixelYourSite;
6 use PixelYourSite\CustomEvent;
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 /**
13 * @param CustomEvent $event
14 * @param string $key
15 */
16 function renderHiddenInput( &$event, $key ) {
17
18 $attr_name = "pys[event][$key]";
19 $attr_value = $event->$key;
20
21 ?>
22
23 <input type="hidden" name="<?php echo esc_attr( $attr_name ); ?>"
24 value="<?php echo esc_attr( $attr_value ); ?>">
25
26 <?php
27
28 }
29
30 /**
31 * @param CustomEvent $event
32 * @param string $key
33 * @param string $placeholder
34 */
35 function renderTextInput( &$event, $key, $placeholder = '' ) {
36
37 $attr_name = "pys[event][$key]";
38 $attr_id = 'pys_event_' . $key;
39 $attr_value = $event->$key;
40
41 ?>
42
43 <input type="text" name="<?php echo esc_attr( $attr_name ); ?>"
44 id="<?php echo esc_attr( $attr_id ); ?>"
45 value="<?php echo esc_attr( $attr_value ); ?>"
46 placeholder="<?php echo esc_attr( $placeholder ); ?>"
47 class="input-standard">
48 <?php
49
50 }
51 /**
52 * @param CustomEvent $event
53 * @param string $key
54 * @param array $options
55 */
56 function renderGroupSelectInput( &$event, $key, $groups, $full_width = false,$classes = '' ) {
57
58 $attr_name = "pys[event][$key]";
59 $attr_id = 'pys_event_' . $key;
60 $attr_value = $event->$key;
61 $group_key = $key . '_group';
62
63 $attr_width = $full_width ? 'width: 100%;' : '';
64
65 ?>
66
67 <input type="hidden" name="pys[event][<?php echo esc_attr( $group_key ); ?>]"
68 value="<?php echo esc_attr( $event->$group_key ?? '' ); ?>" id="<?php echo esc_attr( $group_key ); ?>">
69
70 <div class="select-standard-wrap">
71 <select class="select-standard <?= $classes ?>" id="<?php echo esc_attr( $attr_id ); ?>"
72 name="<?php echo esc_attr( $attr_name ); ?>" autocomplete="off"
73 style="<?php echo esc_attr( $attr_width ); ?>">
74
75 <?php foreach ( $groups as $group => $options ) : ?>
76 <optgroup label="<?= $group ?>">
77 <?php foreach ( $options as $option_key => $option_value ) :
78 $selected_group = $event->$group_key ?? $group;
79 ?>
80 <option group="<?= $group ?>"
81 value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $selected_group == $group && $option_key == $attr_value ); ?> <?php disabled( $option_key, 'disabled' ); ?>><?php echo esc_attr( $option_key ); ?></option>
82 <?php endforeach; ?>
83 </optgroup>
84 <?php endforeach; ?>
85 </select>
86 </div>
87
88 <?php
89 }
90 /**
91 * @param CustomEvent $event
92 * @param string $key
93 */
94 function renderGoogleAnalyticsMergedActionInput( &$event, $key ) {
95 $ga_events = PixelYourSite\PYS_Event_Definitions::get_ga_events();
96 renderGroupSelectInput( $event, $key, $ga_events, false,'action_merged_g4' );
97 }
98 function renderMergedGAParamInput( $key, $val ) {
99
100 $attr_name = "pys[event][ga_ads_params][$key]";
101 $attr_id = 'pys_event_ga_ads_' . $key;
102 $attr_value = $val['value'] ?? $val;
103
104 ?>
105
106 <input type="text" name="<?php echo esc_attr( $attr_name ); ?>"
107 id="<?php echo esc_attr( $attr_id ); ?>"
108 value="<?php echo esc_attr( $attr_value ); ?>"
109 class="input-standard">
110
111 <?php
112
113 }
114 /**
115 * @param CustomEvent $event
116 * @param string $key
117 * @param string $placeholder
118 */
119 function renderGAParamInput( $key, $val ) {
120
121 $attr_name = "pys[event][ga_params][$key]";
122 $attr_id = 'pys_event_ga_' . $key;
123 $attr_value = $val;
124
125 ?>
126
127 <input type="text" name="<?php echo esc_attr( $attr_name ); ?>"
128 id="<?php echo esc_attr( $attr_id ); ?>"
129 value="<?php echo esc_attr( $attr_value ); ?>"
130 class="form-control">
131
132 <?php
133
134 }
135
136 /**
137 * Output radio input
138 *
139 * @param $key
140 * @param $value
141 * @param $label
142 * @param bool $disabled
143 */
144 function render_radio_input( &$event, $key, $value, $label, $disabled = false, $with_pro_badge = false ) {
145
146 $id = $key . "_" . rand( 1, 1000000 );
147 $attr_name = "pys[event][$key]";
148 $attr_value = $event->$key;
149
150 ?>
151 <div class="radio-standard">
152 <input type="radio"
153 name="<?php echo esc_attr( $attr_name ); ?>"
154 <?php disabled( $disabled, true ); ?>
155 class="custom-control-input"
156 id="<?php echo esc_attr( $id ); ?>"
157 <?php checked( $attr_value, $value ); ?>
158 value="<?php echo esc_attr( $value ); ?>">
159 <label class="standard-control radio-checkbox-label" for="<?php echo esc_attr( $id ); ?>">
160 <span class="standard-control-indicator"></span>
161 <span class="standard-control-description"><?php echo wp_kses_post( $label ); ?></span>
162 <?php if ( $with_pro_badge ) {
163 renderCogBadge();
164 } ?>
165 </label>
166 </div>
167
168 <?php
169
170 }
171
172 /**
173 * Output checkbox input
174 *
175 * @param $key
176 * @param $label
177 * @param bool $disabled
178 */
179 function render_checkbox_input( &$event, $key, $label, $disabled = false ) {
180
181 $attr_name = "pys[event][$key]";
182 $attr_value = $event->$key;
183
184 $classes = array( 'custom-control', 'custom-checkbox' );
185
186 if ( $disabled ) {
187 $attr_value = false;
188 $classes[] = 'disabled';
189 }
190
191 $classes = implode( ' ', $classes );
192
193 ?>
194
195 <label class="<?php echo esc_attr( $classes ); ?>">
196 <input type="hidden" name="<?php echo esc_attr( $attr_name ); ?>" value="0">
197 <input type="checkbox" name="<?php echo esc_attr( $attr_name ); ?>" value="1"
198 class="custom-control-input" <?php disabled( $disabled, true ); ?> <?php checked( $attr_value,
199 true ); ?> >
200 <span class="custom-control-indicator"></span>
201 <span class="custom-control-description"><?php echo wp_kses_post( $label ); ?></span>
202 </label>
203
204 <?php
205
206 }
207
208 /**
209 * @param CustomEvent $event
210 * @param string $key
211 * @param string $placeholder
212 */
213 function renderNumberInput( &$event, $key, $placeholder = null, $default = null ) {
214
215 $attr_name = "pys[event][$key]";
216 $attr_id = 'pys_event_' . $key;
217 $attr_value = $event->$key;
218
219 ?>
220
221 <div class="input-number-wrapper">
222 <button class="decrease"><i class="icon-minus"></i></button>
223 <input type="number" name="<?php echo esc_attr( $attr_name ); ?>"
224 id="<?php echo esc_attr( $attr_id ); ?>"
225 value="<?php echo !empty( $attr_value ) ? esc_attr( $attr_value ) : esc_attr( $default ); ?>"
226 placeholder="<?php echo esc_attr( $placeholder ); ?>"
227 min="0"
228 >
229 <button class="increase"><i class="icon-plus"></i></button>
230 </div>
231
232 <?php
233
234 }
235 /**
236 * @param CustomEvent $event
237 * @param string $key
238 * @param string $placeholder
239 */
240 function renderTriggerNumberInput( $trigger, $key, $placeholder = null, $default = null ) {
241
242 $i = $trigger->getTriggerIndex();
243 $attr_name = "pys[event][triggers][0][$key]";
244 $attr_id = 'pys_event_0_' . $key;
245 $attr_value = $trigger->getParam( $key );
246
247 ?>
248
249 <div class="input-number-wrapper">
250 <button class="decrease"><i class="icon-minus"></i></button>
251 <input type="number" name="<?php echo esc_attr( $attr_name ); ?>"
252 id="<?php echo esc_attr( $attr_id ); ?>"
253 value="<?php echo !empty( $attr_value ) ? esc_attr( $attr_value ) : esc_attr( $default ); ?>"
254 placeholder="<?php echo esc_attr( $placeholder ); ?>"
255 min="0">
256 <button class="increase"><i class="icon-plus"></i></button>
257 </div>
258
259 <?php
260
261 }
262 /**
263 * @param $trigger
264 * @param $label
265 * @param $key
266 * @param $value
267 * @param null $placeholder
268 * @param null $default
269 * @return void
270 */
271 function renderTriggerNumberInputPercent( $trigger, $label, $key, $value, $placeholder = null, $default = null ) {
272
273 $i = $trigger->getTriggerIndex();
274 $attr_name = "pys[event][triggers][$i][$label][$key][value]";
275 $attr_id = 'pys_event_' . $i . '_' . $key;
276
277 ?>
278
279 <div class="input-number-wrapper input-number-wrapper-percent">
280 <button class="decrease"><i class="icon-minus"></i></button>
281 <input type="number" name="<?php echo esc_attr( $attr_name ); ?>"
282 id="<?php echo esc_attr( $attr_id ); ?>"
283 value="<?php echo (int) !empty( $value ) ? esc_attr( $value ) : esc_attr( $default ); ?>"
284 placeholder="<?php echo esc_attr( $placeholder ); ?>"
285 min="0"
286 max="100"
287 step="1"
288 >
289 <button class="increase"><i class="icon-plus"></i></button>
290 </div>
291
292 <?php
293 }
294 /**
295 * @param CustomEvent $event
296 * @param string $key
297 * @param bool $disabled
298 */
299 function renderSwitcherInput( &$event, $key, $disabled = false ) {
300
301 $attr_name = "pys[event][$key]";
302 $attr_id = 'pys_event_' . $key;
303 $attr_value = $event->$key;
304
305 $classes = array( 'secondary-switch' );
306
307 if ( $disabled ) {
308 $attr_value = false;
309 $classes[] = 'disabled';
310 }
311
312 $classes = implode( ' ', $classes );
313
314 ?>
315
316 <div class="<?php echo esc_attr( $classes ); ?>">
317
318 <?php if ( !$disabled ) : ?>
319 <input type="hidden" name="<?php echo esc_attr( $attr_name ); ?>" value="0">
320 <?php endif; ?>
321
322 <input type="checkbox" name="<?php echo esc_attr( $attr_name ); ?>"
323 value="1" <?php checked( $attr_value, true ); ?> <?php disabled( $disabled, true ); ?>
324 id="<?php echo esc_attr( $attr_id ); ?>" class="custom-switch-input">
325 <label class="custom-switch-btn" for="<?php echo esc_attr( $attr_id ); ?>"></label>
326 </div>
327
328 <?php
329
330 }
331
332 /**
333 * @param CustomEvent $event
334 * @param string $key
335 * @param array $options
336 */
337 function renderSelectInput( &$event, $key, $options, $full_width = false,$classes = '' ) {
338
339 if ( $key == 'currency' ) {
340
341 $attr_name = "pys[event][facebook_params][$key]";
342 $attr_id = 'pys_event_facebook_params_' . $key;
343 $attr_value = $event->getFacebookParam( $key );
344
345 } else {
346
347 $attr_name = "pys[event][$key]";
348 $attr_id = 'pys_event_' . $key;
349 $attr_value = $event->$key;
350
351 }
352
353 $attr_width = $full_width ? 'width: 100%;' : '';
354
355 ?>
356
357 <div class="select-standard-wrap">
358 <select class="select-standard <?=$classes?>" id="<?php echo esc_attr( $attr_id ); ?>"
359 name="<?php echo esc_attr( $attr_name ); ?>" autocomplete="off" style="<?php echo esc_attr( $attr_width ); ?>">
360 <?php foreach ( $options as $option_key => $option_value ) : ?>
361 <option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $option_key,
362 esc_attr( $attr_value ) ); ?> <?php disabled( $option_key,
363 'disabled' ); ?>><?php echo esc_attr( $option_value ); ?></option>
364 <?php endforeach; ?>
365 </select>
366 </div>
367
368 <?php
369 }
370
371
372 /**
373 * @param CustomEvent $event
374 * @param string $key
375 * @param array $options
376 */
377 function renderTriggerSelectInput( $trigger, $key, $options, $full_width = false , $classes = '', $select_type = 'standard') {
378 $i = $trigger->getTriggerIndex();
379 $attr_name = "pys[event][triggers][$i][$key]";
380 $attr_id = 'pys_event_'.$i.'_' . $key;
381 $attr_value = $trigger->getParam($key);
382
383 $attr_width = $full_width ? 'width: 100%;' : '';
384
385 ?>
386
387 <div class="select-<?php echo esc_attr( $select_type ); ?>-wrap">
388 <select class="select-<?php echo esc_attr( $select_type ); ?> <?= $classes ?>"
389 id="<?php echo esc_attr( $attr_id ); ?>"
390 name="<?php echo esc_attr( $attr_name ); ?>" autocomplete="off"
391 style="<?php echo esc_attr( $attr_width ); ?>">
392 <?php foreach ( $options as $option_key => $option_value ) : ?>
393 <option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $option_key, esc_attr( $attr_value ) ); ?> <?php disabled( $option_key, 'disabled' ); ?>><?php echo esc_attr( $option_value ); ?></option>
394 <?php endforeach; ?>
395 </select>
396 </div>
397
398 <?php
399 }
400 /**
401 * @param CustomEvent $event
402 * @param string $key
403 */
404 function renderTriggerTypeInput( $trigger, $key ) {
405
406 $options = array(
407 'page_visit' => 'Page visit',
408 'home_page' => 'Home page',
409 'scroll_pos' => 'Page Scroll',
410 'post_type' => 'Post type',
411 );
412 $pro_options = array(
413 'add_to_cart' => 'WooCommerce add to cart - PRO',
414 'purchase' => 'WooCommerce purchase - PRO',
415 'number_page_visit' => 'Number of Page Visits - PRO',
416 'url_click' => 'Click on HTML link - PRO',
417 'css_click' => 'Click on CSS selector - PRO',
418 'css_mouseover' => 'Mouse over CSS selector - PRO',
419 'video_view' => 'Embedded Video View - PRO',
420 'email_link' => 'Email Link - PRO',
421 'form_field' => 'Filling out a form field - PRO',
422 'copy_element' => 'Copy element (text copy) - PRO',
423 'video_speed' => 'Video speed increase - PRO',
424 );
425 $eventsFormFactory = apply_filters("pys_form_event_factory",[]);
426 foreach ($eventsFormFactory as $activeFormPlugin) :
427 $options[$activeFormPlugin->getSlug()] = $activeFormPlugin->getName().' - PRO';
428 endforeach;
429
430 asort( $pro_options );
431
432 $options = array_merge($options,$pro_options);
433
434 renderTriggerSelectInput( $trigger, $key, $options, false, 'pys_event_trigger_type' );
435
436 }
437 /**
438 * @param CustomEvent $event
439 * @param string $key
440 */
441
442 function renderPostTypeSelect($trigger, $key) {
443 $types = get_post_types(null,"objects ");
444
445 $options = array();
446 foreach ($types as $type) {
447 $options[$type->name]=$type->label;
448 }
449
450 renderTriggerSelectInput( $trigger, $key, $options );
451 }
452 /**
453 * @param CustomEvent $event
454 * @param string $key
455 */
456 function renderCurrencyParamInput( &$event, $key ) {
457
458 $currencies = array(
459 'AUD' => 'Australian Dollar',
460 'BRL' => 'Brazilian Real',
461 'CAD' => 'Canadian Dollar',
462 'CZK' => 'Czech Koruna',
463 'DKK' => 'Danish Krone',
464 'EUR' => 'Euro',
465 'HKD' => 'Hong Kong Dollar',
466 'HUF' => 'Hungarian Forint',
467 'IDR' => 'Indonesian Rupiah',
468 'ILS' => 'Israeli New Sheqel',
469 'JPY' => 'Japanese Yen',
470 'KRW' => 'Korean Won',
471 'MYR' => 'Malaysian Ringgit',
472 'MXN' => 'Mexican Peso',
473 'NOK' => 'Norwegian Krone',
474 'NZD' => 'New Zealand Dollar',
475 'PHP' => 'Philippine Peso',
476 'PLN' => 'Polish Zloty',
477 'RON' => 'Romanian Leu',
478 'GBP' => 'Pound Sterling',
479 'SGD' => 'Singapore Dollar',
480 'SEK' => 'Swedish Krona',
481 'CHF' => 'Swiss Franc',
482 'TWD' => 'Taiwan New Dollar',
483 'THB' => 'Thai Baht',
484 'TRY' => 'Turkish Lira',
485 'USD' => 'U.S. Dollar',
486 'ZAR' => 'South African Rands'
487 );
488
489 $currencies = apply_filters( 'pys_currencies_list', $currencies );
490
491 $options[''] = 'Please, select...';
492 $options = array_merge( $options, $currencies );
493 $options['disabled'] = '';
494 $options['custom'] = 'Custom currency';
495
496 renderSelectInput( $event, $key, $options, true );
497
498 }
499
500 /**
501 * Render Facebook event type input
502 * Uses Events Registry for event definitions
503 *
504 * @param CustomEvent $event
505 * @param string $key
506 */
507 function renderFacebookEventTypeInput( &$event, $key ) {
508 // Get Facebook events from centralized Event Definitions class
509 $facebook_events = PixelYourSite\PYS_Event_Definitions::get_facebook_events();
510
511 // Ensure CustomEvent is included for backward compatibility
512 if ( !isset( $facebook_events['CustomEvent'] ) ) {
513 $facebook_events['CustomEvent'] = [];
514 }
515
516 $attr_name = "pys[event][$key]";
517 $attr_id = 'pys_event_' . $key;
518 $attr_value = esc_attr( $event->$key );
519
520 ?>
521 <div class="select-standard-wrap">
522 <select id="<?php echo esc_attr( $attr_id ); ?>" name="<?php echo esc_attr( $attr_name ); ?>" autocomplete="off"
523 class="select-standard">
524 <?php foreach ( $facebook_events as $option_key => $option_value ) :
525 $value = esc_attr( $option_key ); ?>
526
527 <option data-fields='<?= json_encode( $option_value ) ?>'
528 value="<?= $value ?>" <?php selected( $value, $attr_value ); ?> >
529 <?= $value ?>
530 </option>
531
532 <?php endforeach; ?>
533 </select>
534 </div>
535 <?php
536 }
537
538 /**
539 * @param CustomEvent $event
540 * @param string $key
541 */
542 function renderFacebookParamInput( &$event, $key ) {
543
544 $attr_name = "pys[event][facebook_params][$key]";
545 $attr_id = 'pys_event_facebook_' . $key;
546 $attr_value = $event->getFacebookParam( $key );
547
548 ?>
549
550 <input type="text" name="<?php echo esc_attr( $attr_name ); ?>"
551 id="<?php echo esc_attr( $attr_id ); ?>"
552 value="<?php echo esc_attr( $attr_value ); ?>"
553 placeholder="Enter value"
554 class="input-standard">
555
556 <?php
557
558 }
559
560 /**
561 * @param CustomEvent $event
562 * @param string $key
563 */
564 function renderGoogleAnalyticsActionInput( &$event, $key ) {
565
566 $options = array(
567 '_custom' => 'Custom Action',
568 'disabled' => '',
569 'add_payment_info' => 'add_payment_info',
570 'add_to_cart' => 'add_to_cart',
571 'add_to_wishlist' => 'add_to_wishlist',
572 'begin_checkout' => 'begin_checkout',
573 'checkout_progress' => 'checkout_progress',
574 'generate_lead' => 'generate_lead',
575 'login' => 'login',
576 'purchase' => 'purchase',
577 'refund' => 'refund',
578 'remove_from_cart' => 'remove_from_cart',
579 'search' => 'search',
580 'select_content' => 'select_content',
581 'set_checkout_option' => 'set_checkout_option',
582 'share' => 'share',
583 'sign_up' => 'sign_up',
584 'view_item' => 'view_item',
585 'view_item_list' => 'view_item_list',
586 'view_promotion' => 'view_promotion',
587 'view_search_results' => 'view_search_results',
588 );
589
590 renderSelectInput( $event, $key, $options, true );
591
592 }
593 /**
594 * @param CustomEvent $event
595 * @param string $key
596 */
597 function renderGoogleAnalyticsV4ActionInput( &$event, $key ) {
598 $ga_events = PixelYourSite\PYS_Event_Definitions::get_ga_events();
599 renderGroupSelectInput( $event, $key, $ga_events, false );
600 }
601 /**
602 * Render Pinterest event type input
603 * Uses Events Registry for event definitions
604 *
605 * @param CustomEvent $event
606 * @param string $key
607 */
608 function renderPinterestEventTypeInput( &$event, $key ) {
609 $pinterest_events = PixelYourSite\PYS_Event_Definitions::get_pinterest_events();
610
611 // Ensure CustomEvent is included for backward compatibility
612 if ( !isset( $pinterest_events['custom'] ) ) {
613 $pinterest_events['Custom'] = [];
614 }
615
616 $attr_name = "pys[event][$key]";
617 $attr_id = 'pys_event_' . $key;
618 $attr_value = esc_attr( $event->$key );
619
620 ?>
621 <div class="select-standard-wrap">
622 <select id="<?php echo esc_attr( $attr_id ); ?>" name="<?php echo esc_attr( $attr_name ); ?>" autocomplete="off"
623 class="select-standard">
624 <?php foreach ( $pinterest_events as $option_key => $option_value ) :
625 $value = esc_attr( $option_key ); ?>
626
627 <option data-fields='<?= json_encode( $option_value ) ?>'
628 value="<?= $value ?>" <?php selected( $value, $attr_value ); ?> >
629 <?= $value ?>
630 </option>
631
632 <?php endforeach; ?>
633 </select>
634 </div>
635 <?php
636 }
637
638 /**
639 * Render Bing event type input
640 * Uses Events Registry for event definitions
641 *
642 * @param CustomEvent $event
643 * @param string $key
644 */
645 function renderBingEventTypeInput( &$event, $key ) {
646 // Get Bing events from centralized Event Definitions class
647 $bing_events = PixelYourSite\PYS_Event_Definitions::get_bing_events();
648
649 $attr_name = "pys[event][$key]";
650 $attr_id = 'pys_event_' . $key;
651 $attr_value = esc_attr( $event->$key );
652
653 ?>
654 <select class="input-standard" id="<?php echo esc_attr( $attr_id ); ?>" name="<?php echo esc_attr( $attr_name ); ?>" autocomplete="off">
655 <?php foreach ( $bing_events as $option_key => $option_value ) :
656 $value = esc_attr( $option_key ); ?>
657
658 <option data-fields='<?= json_encode( $option_value ) ?>'
659 value="<?= $value ?>" <?php selected( $value, $attr_value ); ?> >
660 <?= $value ?>
661 </option>
662
663 <?php endforeach; ?>
664 </select>
665 <?php
666 }
667
668 /**
669 * @param CustomEvent $event
670 * @param string $key
671 */
672 function renderGTMEventId( &$event, $key) {
673 $options = array();
674 $mainPixels = PixelYourSite\GTM()->getPixelIDs();
675 foreach ($mainPixels as $mainPixel) {
676 if (strpos($mainPixel, 'GTM-') === 0 && strpos($mainPixel, 'GTM-') !== false) {
677 $options[$mainPixel] = $mainPixel.' (global)';
678 }
679 else{
680 $options[$mainPixel] = $mainPixel.' (not supported)';
681 }
682
683 }
684
685 render_multi_select_input( $event, $key, $options );
686
687 }
688
689 /**
690 * @param CustomEvent $event
691 * @param string $key
692 * @param string $placeholder
693 */
694 function renderGTMParamInput( $key, $val ) {
695
696 $attr_name = "pys[event][gtm_params][$key]";
697 $attr_id = 'pys_event_gtm_' . $key;
698 $attr_value = $val['value'] ?? $val;
699
700 ?>
701
702 <input type="text" name="<?php echo esc_attr( $attr_name ); ?>"
703 id="<?php echo esc_attr( $attr_id ); ?>"
704 value="<?php echo esc_attr( $attr_value ); ?>"
705 class="form-control">
706
707 <?php
708
709 }
710
711 /**
712 * @param CustomEvent $event
713 * @param string $key
714 */
715 function renderGTMActionInput( &$event, $key ) {
716 $ga_events = PixelYourSite\PYS_Event_Definitions::get_ga_events();
717 renderGroupSelectInput( $event, $key, $ga_events, false,'action_gtm' );
718 }
719