Merge branch 'develop' of https://github.com/tainacan/tainacan into develop
This commit is contained in:
commit
eced477d66
|
@ -347,13 +347,28 @@ class Item_Metadata extends Repository {
|
|||
return $value->meta_value;
|
||||
}
|
||||
} else {
|
||||
return get_post_meta( $item_metadata->get_item()->get_id(), $item_metadata->get_metadatum()->get_id(), $unique );
|
||||
if( !metadata_exists('post', $item_metadata->get_item()->get_id(), $item_metadata->get_metadatum()->get_id()) ) {
|
||||
return $this->get_default_value($item_metadata->get_metadatum());
|
||||
} else {
|
||||
return get_post_meta( $item_metadata->get_item()->get_id(), $item_metadata->get_metadatum()->get_id(), $unique );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function get_default_value($metadatum) {
|
||||
if ( $metadatum->get_metadata_type() == 'Tainacan\Metadata_Types\User' ) {
|
||||
$options = $metadatum->get_metadata_type_options();
|
||||
if ( isset($options['default_author']) && $options['default_author'] = 'yes') {
|
||||
return get_current_user_id();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
return $metadatum->get_default_value();
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms the array saved as meta_value with the IDs of post_meta saved as a value for compound metadata
|
||||
* and converts it into an array of Item Metadatada Entitites
|
||||
|
|
|
@ -80,6 +80,8 @@ class User extends Metadata_Type {
|
|||
}
|
||||
|
||||
function user_exists($user) {
|
||||
if ( empty($user) )
|
||||
return true;
|
||||
// if( !is_int($user) )
|
||||
// return username_exists($user) !== false;
|
||||
|
||||
|
@ -146,6 +148,8 @@ class User extends Metadata_Type {
|
|||
*/
|
||||
public function get_value_as_html(\Tainacan\Entities\Item_Metadata_Entity $item_metadata) {
|
||||
$value = $item_metadata->get_value();
|
||||
if (empty($value))
|
||||
return "";
|
||||
$name = get_the_author_meta( 'display_name', $value );
|
||||
return apply_filters("tainacan-item-get-author-name", $name, $this);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue