RWMB_Field::get_value PHP Метод

get_value() публичный статический Метод

Each field can extend this function and add more data to the returned value. See specific field classes for details.
public static get_value ( array $field, array $args = [], integer | null $post_id = null ) : mixed
$field array Field parameters
$args array Additional arguments. Rarely used. See specific fields for details
$post_id integer | null Post ID. null for current post. Optional.
Результат mixed Field value
	public static function get_value( $field, $args = array(), $post_id = null ) {
		// Some fields does not have ID like heading, custom HTML, etc.
		if ( empty( $field['id'] ) ) {
			return '';
		}

		if ( ! $post_id ) {
			$post_id = get_the_ID();
		}

		// Get raw meta value in the database, no escape
		$value  = self::call( $field, 'raw_meta', $post_id );

		// Make sure meta value is an array for cloneable and multiple fields
		if ( $field['clone'] || $field['multiple'] ) {
			$value = is_array( $value ) && $value ? $value : array();
		}

		return $value;
	}

Usage Example

Пример #1
0
 /**
  * Get the field value. Return meaningful info of the files.
  *
  * @param  array    $field   Field parameters
  * @param  array    $args    Not used for this field
  * @param  int|null $post_id Post ID. null for current post. Optional.
  *
  * @return mixed Full info of uploaded files
  */
 public static function get_value($field, $args = array(), $post_id = null)
 {
     $value = parent::get_value($field, $args, $post_id);
     if (!$field['clone']) {
         $value = self::call('files_info', $field, $value, $args);
     } else {
         $return = array();
         foreach ($value as $subvalue) {
             $return[] = self::call('files_info', $field, $subvalue, $args);
         }
         $value = $return;
     }
     if (isset($args['limit'])) {
         $value = array_slice($value, 0, intval($args['limit']));
     }
     return $value;
 }
All Usage Examples Of RWMB_Field::get_value