Example #1
0
 /**
  * Creates empty table of fields as $field_type => FieldGroup pairs
  *
  * @return array
  */
 private function initFieldTable()
 {
     $table = array();
     $field_types = FieldType::getConstants();
     foreach ($field_types as $type) {
         $field_group = new FieldGroup();
         $field_group->setRelation($this->getFieldRelation($type));
         $table[$type] = $field_group;
     }
     return $table;
 }
Example #2
0
 /**
  * Takes an array of query arguments and adds a sub-query
  * (eg tax_query, meta_query, or date_query)
  *
  * @param array $query
  * @param FieldGroup $field_group
  * @param $field_type
  * @param HttpRequest $request
  * @return array
  */
 private function addSubQuery(array $query, FieldGroup $field_group, $field_type, HttpRequest $request)
 {
     $classnames = array('taxonomy' => 'TaxQuery', 'meta_key' => 'MetaQuery', 'date' => 'DateQuery');
     $fields = $field_group->getFields();
     if (empty($classnames[$field_type]) || empty($fields)) {
         return $query;
     }
     $s_query = $this->getSubQuery($classnames[$field_type], $fields, $field_group->getRelation(), $request);
     if (!empty($s_query)) {
         $query[RequestVar::wpQueryVar($field_type)] = $s_query;
     }
     return $query;
 }