location_rule_fields) return; ?>$key) { $value = $_POST['meta_location_rule_value'][$i]; $choices[$key." : ".$value] = ""; } } // whichever rules we previously had for this field group, are also valid of // course $rules = get_post_meta(get_the_ID(), 'rule'); if (!$rules) $rules = array(); foreach($rules as $rule) { if ($rule['param'] !== 'meta_field') continue; $choices[$rule['value']] = ''; } return $choices; } /** * When trying to find out whether this rule applies in the current scope. */ function filter_acf_location_rule_match_meta_field($match, $rules, $post) { $compareOperaor = $rules['operator']; $compareKeyValue = $rules['value']; list($compareKey,$compareValue) = explode(" : ", $compareKeyValue, 2); // also add the fields to look for, to the header $this->location_rule_fields[] = $compareKey; // fetch from db $postValue = get_post_meta($post['post_id'], $compareKey, true); // if from ajax, use the actual value from the form, instead of the // maybe-outdated db version if (isset($_POST['meta_location_rules']) && isset($_POST['meta_location_rules'][$compareKey])) { $postValue = $_POST['meta_location_rules'][$compareKey]; } switch($compareOperaor) { case '==': if ($postValue === $compareValue) $match = true; break; case '!=': if ($postValue !== $compareValue) $match = true; break; } return $match; } } $obj = new AcfMetaLocationRules();