/** * Returns a boolean query param based on the current WP_Query * @param array $query_vars * @return string The resulting boolean query parameter */ public function wpToBooleanQuery($query_vars) { $meta_query = new WP_Meta_Query(); $meta_query->parse_query_vars($query_vars); if (count($meta_query->queries) > 0) { $expressionSet = new Lift_Expression_Set(strtolower($meta_query->relation)); foreach ($meta_query->queries as $subquery) { if ($subquery['key'] == $this->meta_key) { if ($subquery['compare'] === 'LIKE') { foreach ((array) $subquery['value'] as $value) { $expressionSet->addExpression(new Lift_Expression_Field($this->name, $value)); } } elseif ($subquery['compare'] === 'NOT LIKE') { $subExpression = new Lift_Expression_Set('NOT'); foreach ((array) $subquery['value'] as $value) { $subExpression->addExpression(new Lift_Expression_Field($this->name, $value)); } $expressionSet->addExpression($subExpression); } } } return $expressionSet; } return ''; }
protected function push() { if ($this->buffer_start !== null) { // extract string from buffer start to current position $buffer = substr($this->string, $this->buffer_start, $this->position - $this->buffer_start); // clean buffer $this->buffer_start = null; // throw token into current scope if (is_null($this->currentSet)) { if (in_array($buffer, array('and', 'or', 'not'))) { $this->currentSet = new Lift_Expression_Set($buffer); } else { list($name, $value) = explode(':', $buffer); $is_str = false; if ($value[0] === "'") { $is_str = true; $value = substr($value, 1, -1); } $this->currentSet = new Lift_Expression_Field($name, $value, $is_str); } } else { list($name, $value) = explode(':', $buffer); $is_str = false; if ($value[0] === "'") { $is_str = true; $value = substr($value, 1, -1); } $exp = new Lift_Expression_Field($name, $value, $is_str); $this->currentSet->addExpression($exp); } } }