本文整理汇总了PHP中GFCommon::get_selection_value方法的典型用法代码示例。如果您正苦于以下问题:PHP GFCommon::get_selection_value方法的具体用法?PHP GFCommon::get_selection_value怎么用?PHP GFCommon::get_selection_value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GFCommon
的用法示例。
在下文中一共展示了GFCommon::get_selection_value方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: is_value_match
public static function is_value_match($field_value, $target_value, $operation = "is", $source_field = null)
{
if ($source_field && $source_field["type"] == "post_category") {
$field_value = GFCommon::prepare_post_category_value($field_value, $source_field, "conditional_logic");
}
if (!empty($field_value) && !is_array($field_value) && $source_field["type"] == "multiselect") {
//convert the comma-delimited string into an array
$field_value = explode(",", $field_value);
}
if (is_array($field_value)) {
$field_value = array_values($field_value);
//returning array values, ignoring keys if array is associative
$match_count = 0;
foreach ($field_value as $val) {
if (self::matches_operation(GFCommon::get_selection_value($val), $target_value, $operation)) {
$match_count++;
}
}
//If operation is Is Not, none of the values in the array can match the target value.
return $operation == "isnot" ? $match_count == count($field_value) : $match_count > 0;
} else {
if (self::matches_operation(GFCommon::get_selection_value($field_value), $target_value, $operation)) {
return true;
}
}
return false;
}
示例2: is_value_match
public static function is_value_match($field_value, $target_value, $operation = 'is', $source_field = null, $rule = null, $form = null)
{
$is_match = false;
if ($source_field && is_subclass_of($source_field, 'GF_Field') && $source_field->type == 'post_category') {
$field_value = GFCommon::prepare_post_category_value($field_value, $source_field, 'conditional_logic');
}
if (!empty($field_value) && !is_array($field_value) && is_subclass_of($source_field, 'GF_Field') && $source_field->type == 'multiselect') {
$field_value = explode(',', $field_value);
}
// convert the comma-delimited string into an array
$form_id = $source_field instanceof GF_Field ? $source_field->formId : 0;
$target_value = GFFormsModel::maybe_trim_input($target_value, $form_id, $source_field);
if (is_array($field_value)) {
$field_value = array_values($field_value);
//returning array values, ignoring keys if array is associative
$match_count = 0;
foreach ($field_value as $val) {
$val = GFFormsModel::maybe_trim_input(GFCommon::get_selection_value($val), rgar($source_field, 'formId'), $source_field);
if (self::matches_operation($val, $target_value, $operation)) {
$match_count++;
}
}
// if operation is Is Not, none of the values in the array can match the target value.
$is_match = $operation == 'isnot' ? $match_count == count($field_value) : $match_count > 0;
} else {
if (self::matches_operation(GFFormsModel::maybe_trim_input(GFCommon::get_selection_value($field_value), $form_id, $source_field), $target_value, $operation)) {
$is_match = true;
}
}
return apply_filters('gform_is_value_match', $is_match, $field_value, $target_value, $operation, $source_field, $rule);
}
示例3: is_value_match
public static function is_value_match($field_value, $target_value, $operation = "is", $source_field = null, $rule = null)
{
$is_match = false;
if ($source_field && $source_field["type"] == "post_category") {
$field_value = GFCommon::prepare_post_category_value($field_value, $source_field, "conditional_logic");
}
if (!empty($field_value) && !is_array($field_value) && $source_field["type"] == "multiselect") {
$field_value = explode(",", $field_value);
}
// convert the comma-delimited string into an array
$target_value = GFFormsModel::maybe_trim_input($target_value, rgar($source_field, "formId"), $source_field);
if (is_array($field_value)) {
$field_value = array_values($field_value);
//returning array values, ignoring keys if array is associative
$match_count = 0;
foreach ($field_value as $val) {
$val = GFFormsModel::maybe_trim_input(GFCommon::get_selection_value($val), rgar($source_field, "formId"), $source_field);
if (self::matches_operation($val, $target_value, $operation)) {
$match_count++;
}
}
// if operation is Is Not, none of the values in the array can match the target value.
$is_match = $operation == "isnot" ? $match_count == count($field_value) : $match_count > 0;
} else {
if (self::matches_operation(GFFormsModel::maybe_trim_input(GFCommon::get_selection_value($field_value), rgar($source_field, "formId"), $source_field), $target_value, $operation)) {
$is_match = true;
}
}
return apply_filters('gform_is_value_match', $is_match, $field_value, $target_value, $operation, $source_field, $rule);
}
示例4: maybe_update_user_role
/**
* Maybe update user role of the specified lead and feed
*
* @param array $lead
* @param Feed $feed
*/
private function maybe_update_user_role($lead, $feed)
{
$user = false;
// Gravity Forms User Registration Add-On
if (class_exists('GFUserData')) {
$user = GFUserData::get_user_by_entry_id($lead['id']);
}
if (false === $user) {
$created_by = $lead[Pronamic_WP_Pay_Extensions_GravityForms_LeadProperties::CREATED_BY];
$user = new WP_User($created_by);
}
if ($user && !empty($feed->user_role_field_id) && isset($lead[$feed->user_role_field_id])) {
$value = $lead[$feed->user_role_field_id];
$value = GFCommon::get_selection_value($value);
$user->set_role($value);
}
}
示例5: is_value_match
public static function is_value_match($field_value, $target_value)
{
if (is_array($field_value)) {
foreach ($field_value as $val) {
if (GFCommon::get_selection_value($val) == $target_value) {
return true;
}
}
} else {
if (GFCommon::get_selection_value($field_value) == $target_value) {
return true;
}
}
return false;
}
示例6: is_value_match
public static function is_value_match($field_value, $target_value, $operation = "is", $source_field = null)
{
if ($source_field && $source_field["type"] == "post_category") {
$field_value = GFCommon::prepare_post_category_value($field_value, $source_field, "conditional_logic");
}
if (!empty($field_value) && !is_array($field_value) && $source_field["type"] == "multiselect") {
//convert the comma-delimited string into an array
$field_value = explode(",", $field_value);
}
if (is_array($field_value)) {
foreach ($field_value as $val) {
if (self::matches_operation(GFCommon::get_selection_value($val), $target_value, $operation)) {
return true;
}
}
} else {
if (self::matches_operation(GFCommon::get_selection_value($field_value), $target_value, $operation)) {
return true;
}
}
return false;
}
示例7: is_value_match
public static function is_value_match($field_value, $target_value, $operation = "is")
{
if (is_array($field_value)) {
foreach ($field_value as $val) {
if (self::matches_operation(GFCommon::get_selection_value($val), $target_value, $operation)) {
return true;
}
}
} else {
if (self::matches_operation(GFCommon::get_selection_value($field_value), $target_value, $operation)) {
return true;
}
}
return false;
}