public static function getCustomConditional($custom, $suffix = '', $cond_values = array()) { $c_fields = WPToolset_Forms_Conditional::extractFields($custom); $c_values = array(); // Loop over extracted fields and adjust custom statement foreach ($c_fields as $c_field_id) { // Get field settings $c_field = self::getConfig($c_field_id); // If it's Types field if (!empty($c_field)) { // Adjust custom statement $custom = preg_replace('/\\$\\(' . $c_field_id . '\\)/', "\$({$c_field['meta_key']}{$suffix})", $custom); $custom = preg_replace('/\\$' . $c_field_id . '[\\s\\)]/', "\${$c_field['meta_key']}{$suffix} ", $custom); // Apply filters from field (that is why we set 'type' property) wptoolset_form_field_add_filters($c_field['type']); $c_key = $c_field['meta_key']; if (isset($cond_values[$c_key])) { $c_values[$c_key . $suffix] = apply_filters('wptoolset_conditional_value_php', $cond_values[$c_key], $c_field['type']); } // Otherwise do nothing (leave statement as it is and just add [values]) // That allows checking for non-Types field } elseif (isset($cond_values[$c_field_id])) { $c_values[$c_field_id . $suffix] = $cond_values[$c_field_id]; } } // Set conditional setting $cond = array('custom' => $custom, 'values' => $c_values); return $cond; }