Esempio n. 1
0
 /**
  * Return field array from Object, a field's data, or a field option
  *
  * @param string|null $field Object Field name
  * @param string|null $option Field option
  *
  * @return array|mixed
  *
  * @since 2.3.10
  */
 public function fields($field = null, $option = null)
 {
     if (!isset($this->_object['fields'])) {
         if ($this->is_custom()) {
             if (isset($this->_object['_fields']) && !empty($this->_object['_fields'])) {
                 foreach ($this->_object['_fields'] as $field) {
                     $field = pods_object_field($field, 0, $this->_live, $this->_object['id']);
                     if ($field->is_valid()) {
                         $this->_object['fields'][$field['name']] = $field;
                     }
                 }
             }
         } else {
             $find_args = array('post_type' => '_pods_field', 'posts_per_page' => -1, 'nopaging' => true, 'post_parent' => $this->_object['parent_id'], 'orderby' => 'menu_order', 'order' => 'ASC');
             $fields = get_posts($find_args);
             $this->_object['fields'] = array();
             if (!empty($fields)) {
                 foreach ($fields as $field) {
                     $field = pods_object_field($field, 0, $this->_live, $this->_object['id']);
                     if ($field->is_valid()) {
                         $this->_object['fields'][$field['name']] = $field;
                     }
                 }
             }
         }
     }
     return $this->_fields('fields', $field, $option);
 }
Esempio n. 2
0
 /**
  * Return object field array from Object, a object field's data, or a object field option
  *
  * @param string|null $field Object Field name
  * @param string|null $option Field option
  *
  * @return array|mixed
  *
  * @since 2.3.10
  */
 public function object_fields($field = null, $option = null)
 {
     if (!isset($this->_object['fields'])) {
         $object_fields = array();
         if ($this->is_custom() && isset($this->_object['_object_fields']) && !empty($this->_object['_object_fields'])) {
             $object_fields = $this->_object['_object_fields'];
         }
         $this->_object['_object_fields'] = array();
         foreach ($object_fields as $object_field) {
             $object_field = pods_object_field($object_field, 0, $this->_live, $this->_object['id']);
             if ($object_field->is_valid()) {
                 $this->_object['object_fields'][$object_field['name']] = $object_field;
             }
         }
     }
     return $this->_fields('object_fields', $field, $option);
 }