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

This commit is contained in:
mateuswetah 2022-08-22 16:26:16 -03:00
commit 4d2a2d687e
4 changed files with 25 additions and 12 deletions

View File

@ -42,6 +42,11 @@ class REST_Item_Metadata_Controller extends REST_Controller {
public function register_routes() {
register_rest_route($this->namespace, '/item/(?P<item_id>[\d]+)/' . $this->rest_base . '/(?P<metadatum_id>[\d]+)',
array(
array(
'methods' => \WP_REST_Server::READABLE,
'callback' => array($this, 'get_item_metadatum_value'),
'permission_callback' => array($this, 'get_items_permissions_check'),
),
array(
'methods' => \WP_REST_Server::EDITABLE,
'callback' => array($this, 'update_item'),
@ -55,7 +60,7 @@ class REST_Item_Metadata_Controller extends REST_Controller {
),
)
);
register_rest_route($this->namespace, '/item/(?P<item_id>[\d]+)/'. $this->rest_base,
register_rest_route($this->namespace, '/item/(?P<item_id>[\d]+)/' . $this->rest_base,
array(
array(
'methods' => \WP_REST_Server::READABLE,
@ -65,15 +70,6 @@ class REST_Item_Metadata_Controller extends REST_Controller {
)
)
);
register_rest_route($this->namespace, '/item/(?P<item_id>[\d]+)/'. $this->rest_base. '/(?P<metadatum_id>[\d]+)',
array(
array(
'methods' => \WP_REST_Server::READABLE,
'callback' => array($this, 'get_item_metadatum_value'),
'permission_callback' => array($this, 'get_items_permissions_check'),
)
)
);
}
/**

View File

@ -437,7 +437,7 @@ class Item_Metadata extends Repository {
if ( is_array( $ids ) ) {
foreach ( $ids as $id ) {
$post_meta_object = get_metadata_by_mid( 'post', $id );
if ( is_object( $post_meta_object ) && get_post($post_meta_object->meta_key) !== null ) {
if ( is_object( $post_meta_object ) && get_post($post_meta_object->meta_key) !== null && get_post_status($post_meta_object->meta_key) !== 'trash' ) {
$metadatum = new Entities\Metadatum( $post_meta_object->meta_key );
$return_value[ $metadatum->get_id() ] = new Entities\Item_Metadata_Entity( $item, $metadatum, $id, (int)$compound_meta_id );
}

View File

@ -480,6 +480,23 @@ class Migrations {
}
}
static function insert_meta_default_metadata_section() {
global $wpdb;
// create metadata
$wpdb->query(
$wpdb->prepare(
"INSERT INTO $wpdb->postmeta (post_id,meta_key,meta_value)
SELECT ID,'metadata_section_id', %s FROM $wpdb->posts
WHERE post_type = %s AND ID NOT IN (
SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s
)"
,\Tainacan\Entities\Metadata_Section::$default_section_slug
,\Tainacan\Entities\Metadatum::$post_type
,\Tainacan\Entities\Metadata_Section::$default_section_slug
)
);
}
}

View File

@ -442,7 +442,7 @@ class ImporterTests extends TAINACAN_UnitTestCase {
'https://www.codeproject.com/KB/GDI-plus/ImageProcessing2/img.jpg||https://cloud.netlifyusercontent.com/assets/344dbf88-fdf9-42bb-adb4-46f01eedd629/58f72418-b5ee-4765-8e80-e463623a921d/01-httparchive-opt-small.png',
'file:https://images.pexels.com/photos/248797/pexels-photo-248797.jpeg'),
array('Data 41', '459', 'Data 43||limbbo', 'photos/SamplePNGImage_100kbmb.png||audios/SampleAudio_0.4mb.mp3', 'url:http://www.pdf995.com/samples/pdf.pdf'),
array('Data 51', '500', 'Data 53', 'http://techslides.com/demos/samples/sample.mp4', '')
array('Data 51', '500', 'Data 53', 'https://upload.wikimedia.org/wikipedia/commons/7/7b/Space_station_Penyulap.ogv', '')
);
// save each row of the data