/** * Filters conditional. * * We'll just handle this as a custom conditional * * Custom conditional * Main properties: * [custom] - custom statement made by user, note that $xxxx should match * IDs of fields that passed this filter. * [values] - same as for regular conditional * * [conditional] => Array( [custom] => ($wpcf-my-date = DATE(01,02,2014)) OR ($wpcf-my-date > DATE(07,02,2014)) [values] => Array( [wpcf-my-date] => 32508691200 ) ) * * @param array|string $field settings array (as stored in DB) or field ID * @param int $post_id Post or user ID to fetch meta data to check against * @return array */ public static function filterConditional($if, $post_id) { $data = WPToolset_Types::getCustomConditional($if, '', WPToolset_Types::getConditionalValues($post_id)); return $data; }
public static function parse_conditional( $post, $condition, $debug = false, $attr, $id, $has_post ){ $logging_string = "####################\nwpv-conditional attributes\n####################\n" . print_r( $attr, true ) . "\n####################\nDebug information\n####################" . "\n--------------------\nOriginal expression: " . $condition . "\n--------------------"; if (!defined('WPTOOLSET_COMMON_PATH')) { define('WPTOOLSET_COMMON_PATH', WPV_PATH_EMBEDDED . '/common'); } require_once WPV_PATH_EMBEDDED . '/common/toolset-forms/classes/class.types.php'; require_once WPV_PATH_EMBEDDED . '/common/toolset-forms/classes/class.cred.php'; $data = WPToolset_Types::getCustomConditional($condition, '', WPToolset_Types::getConditionalValues($id)); $evaluate = $data['custom']; $values = $data['values']; if (strpos($evaluate, "REGEX") === false) { $evaluate = trim(stripslashes($evaluate)); // Check dates $evaluate = wpv_filter_parse_date($evaluate); $evaluate = self::handle_user_function($evaluate); } $fields = self::extractFields($evaluate); $evaluate = apply_filters( 'wpv-extra-condition-filters', $evaluate); $temp = self::extractVariables( $evaluate, $attr, $has_post, $id ); $evaluate = $temp[0]; $logging_string .= $temp[1]; $passed = self::evaluateCustom($evaluate); if ( $passed ){ return array ( 'debug' => $logging_string, 'passed'=>$passed ); } $evaluate = self::_update_values_in_expression($evaluate, $fields, $values); $logging_string .= "\n--------------------\nConverted expression: " . $evaluate . "\n--------------------"; $passed = self::evaluateCustom($evaluate); return array ( 'debug' => $logging_string, 'passed'=>$passed ); }