Merge branch 'release/0.16' of https://github.com/tainacan/tainacan into release/0.16

This commit is contained in:
mateuswetah 2020-05-08 14:05:21 -03:00
commit 0ee6b31240
2 changed files with 11 additions and 35 deletions

View File

@ -71,7 +71,7 @@ class Item_Metadata extends Repository {
} else { } else {
if ( $unique ) { if ( $unique ) {
if( empty( $item_metadata->get_value() ) ) { if( empty( $item_metadata->get_value() ) ) {
delete_post_meta( $item_metadata->get_item()->get_id(), $item_metadata->get_metadatum()->get_id() ); delete_metadata_by_mid( 'post', $item_metadata->get_meta_id() );
} elseif ( is_int( $item_metadata->get_meta_id() ) ) { } elseif ( is_int( $item_metadata->get_meta_id() ) ) {
update_metadata_by_mid( 'post', $item_metadata->get_meta_id(), wp_slash( $item_metadata->get_value() ) ); update_metadata_by_mid( 'post', $item_metadata->get_meta_id(), wp_slash( $item_metadata->get_value() ) );
} else { } else {

View File

@ -175,54 +175,30 @@ class Compound extends Metadata_Type {
return $return; return $return;
if ( $item_metadata->is_multiple() ) { if ( $item_metadata->is_multiple() ) {
$elements = [];
if ( sizeof($value) > 0 ) {
$return .= '<div class="tainacan-compound-group">';
$count = 0;
foreach ( $value as $compound_element ) { foreach ( $value as $compound_element ) {
$count++; if ( !empty($compound_element) ) {
$metadata_value = '';
if ( sizeof($compound_element) > 0 ) {
$return .= '<div class="tainacan-compound-metadatum">';
foreach ( $compound_element as $meta ) { foreach ( $compound_element as $meta ) {
if ( $meta instanceof Item_Metadata_Entity && $meta->get_value_as_html() != '' ) { if ( $meta instanceof Item_Metadata_Entity && $meta->get_value_as_html() != '' ) {
$return .= '<label class="label">' . $meta->get_metadatum()->get_name() . "</label>\n"; $metadata_value .= '<label class="label">' . $meta->get_metadatum()->get_name() . '</label> <p>' . $meta->get_value_as_html() . "</p> \n";
$return .= '<p>' . $meta->get_value_as_html() . '</p>' . "\n\n";
} }
} }
$elements[] = '<div class="tainacan-compound-metadatum">' . $metadata_value . "</div> \n" ;
if ($count < sizeof($compound_element)) {
$return .= '</div>' . "\n" . $separator . "\n";
} else {
$return .= '</div>';
} }
} }
} $return .= '<div class="tainacan-compound-group">' . implode($separator, $elements) . '</div>';
$return .= '</div>' . "\n\n";
}
} else { } else {
$return .= '<div class="tainacan-compound-group">'; $return .= '<div class="tainacan-compound-group">';
foreach ( $value as $meta ) { foreach ( $value as $meta ) {
if ( $meta->get_value_as_html() != '' ) { if ( $meta->get_value_as_html() != '' ) {
$return .= '<div class="tainacan-metadatum">'; $return .= '<div class="tainacan-metadatum">';
if ( $meta instanceof Item_Metadata_Entity ) { if ( $meta instanceof Item_Metadata_Entity ) {
$return .= '<label class="label">' . $meta->get_metadatum()->get_name() . "</label>\n"; $return .= '<label class="label">' . $meta->get_metadatum()->get_name() . "</label>\n";
$return .= '<p>' . $meta->get_value_as_html() . '</p>'; $return .= '<p>' . $meta->get_value_as_html() . '</p>';
} }
$return .= '</div>' . "\n\n"; $return .= '</div>' . "\n\n";
} }
} }
$return .= '</div>' . "\n\n"; $return .= '</div>' . "\n\n";
} }