Server IP : 172.67.216.182 / Your IP : 172.69.176.130 Web Server : Apache System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /www/wwwroot/coircraft.com/wp-content/plugins/caldera-forms/classes/field/ |
Upload File : |
<?php /** * Class Caldera_Forms_Field_Utm */ class Caldera_Forms_Field_Utm { /** * Add hooks for UTM fields * * @since 1.5.2 */ public static function add_hooks(){ add_filter( 'caldera_forms_field_attributes-utm', array( 'Caldera_Forms_Field_Utm', 'handle_attrs'), 1 ); add_filter( 'caldera_forms_view_field_utm', array( 'Caldera_Forms_Field_Utm', 'view' ), 10, 3 ); } /** * Set the type HTML attribute to hidden for UTM fields * * @since 1.5.2 * * @uses "caldera_forms_field_attributes-utm" filter * * @param array $attrs Field attributes * * @return array */ public static function handle_attrs( $attrs ){ $count = self::get_count(); $attrs[ 'type' ] = 'hidden'; $attrs[ 'name' ] = str_replace( $count . '_', '', $attrs[ 'id' ] ); return $attrs; } /** * Format field view for utm fields * * @since 1.5.2 * * @uses "caldera_forms_view_field_utm" filter * * @param mixed $field_value Saved value * @param array $field Field config * @param array $form Form config * * @return string */ public static function view( $field_value, $field, $form ){ if( ! is_array( $field_value ) ){ return $field_value; } $out = array(); $pattern = '<li><strong>%s</strong>: %s</li>'; foreach ( self::tags() as $tag ){ if( ! empty( $field_value[ $tag ] ) ){ $out[] = sprintf( $pattern, ucwords( $tag ), esc_html( $field_value[ $tag ] ) ); } } if ( ! empty( $out ) ) { $field_value = '<ul class="caldera-forms-utm-field-view">' . implode( ' ', $out ) . '</ul>'; } return $field_value; } /** * Save handler for UTM tag field * * @since 1.5.2 * * @param mixed $value Saved value * @param array $field Field config * @param array $form Form config * * @return array */ public static function handler( $value, $field, $form ){ $_value = array(); foreach ( self::tags() as $tag ){ $utm_field = self::config( $field, $tag ); $__value = self::find_in_post( $utm_field ); if ( ! empty( $__value ) ) { $_value[ $tag ] = $__value; } } if( ! empty( $_value ) ){ $value = $_value; } return $value; } /** * Creates config for individual tag fields * * @since 1.5.2 * * @param array $field Field config * @param string $tag Which tag * * @return array */ public static function config( $field, $tag ){ $tag = 'utm_' . $tag; $utm_field_config = $field; $utm_field_config[ 'slug' ] = $field[ 'slug' ] . '_' . $tag; $utm_field_config[ 'ID' ] = $field[ 'ID' ] . '_' . $tag; $utm_field_config[ 'label' ] = $field[ 'label' ] . ': ' . $tag; $utm_field_config[ 'config' ][ 'default' ] = ( isset( $_GET[ $tag ] ) ? Caldera_Forms_Sanitize::sanitize( $_GET[ $tag ] ) : '' ); return $utm_field_config; } /** * Array of types of UTM tags * * @since 1.5.2 * * @return array */ public static function tags(){ return array( 'source', 'medium', 'campaign', 'term', 'content', ); } /** * Find in POST data * * @since 1.5.2 * * @param array $utm_field Field config * * @return string */ protected static function find_in_post( $utm_field ){ $_value = ''; $tag_key = $utm_field[ 'ID' ] . '_' . self::get_count(); if ( isset( $_POST[ $tag_key ] ) ) { $_value = Caldera_Forms_Sanitize::sanitize( $_POST[ $tag_key ] ); } if( ! is_string( $_value ) ){ return ''; } return $_value; } /** * Get current form count * * @since 1.5.2 * * @return int */ protected static function get_count(){ $count = Caldera_Forms_Render_Util::get_current_form_count(); if ( 1 > $count ) { $count = 1; return $count; } return $count; } }