Add more attributes to object Collection
Autho Creation Date Modification Date Thumbnail URL Post URL
This commit is contained in:
parent
2f870e74d0
commit
888f924e84
|
@ -101,6 +101,49 @@ class Collection extends Entity {
|
|||
return register_post_type($cpt_slug, $args);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return mixed|null
|
||||
*/
|
||||
function get_featured_img(){
|
||||
return $this->get_mapped_property('featured_image');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*/
|
||||
function set_featured_img($value){
|
||||
$this->set_mapped_property('featured_image', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed|null
|
||||
*/
|
||||
function get_modification_date(){
|
||||
return $this->get_mapped_property('modification_date');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed|null
|
||||
*/
|
||||
function get_creation_date(){
|
||||
return $this->get_mapped_property('creation_date');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed|null
|
||||
*/
|
||||
function get_author(){
|
||||
return $this->get_mapped_property('author');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed|null
|
||||
*/
|
||||
function get_url(){
|
||||
return $this->get_mapped_property('url');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collection name
|
||||
*
|
||||
|
|
|
@ -25,8 +25,38 @@ class Collections extends Repository {
|
|||
'map' => 'post_title',
|
||||
'title' => __('Name', 'tainacan'),
|
||||
'type' => 'string',
|
||||
'description'=> __('Name of the collection', 'tainacan'),
|
||||
'description' => __('Name of the collection', 'tainacan'),
|
||||
'validation' => v::stringType(),
|
||||
],
|
||||
'author' => [
|
||||
'map' => 'post_author',
|
||||
'title' => __('Author', 'tainacan'),
|
||||
'type' => 'string',
|
||||
'description' => __('The collection author\'s user ID (numeric string)', 'tainacan')
|
||||
],
|
||||
'creation_date' => [
|
||||
'map' => 'post_date',
|
||||
'title' => __('Creation Date', 'tainacan'),
|
||||
'type' => 'string',
|
||||
'description' => __('The collection creation date', 'tainacan')
|
||||
],
|
||||
'modification_date' => [
|
||||
'map' => 'post_modified',
|
||||
'title' => __('Modification Date', 'tainacan'),
|
||||
'type' => 'string',
|
||||
'description' => __('The collection modification date', 'tainacan')
|
||||
],
|
||||
'url' => [
|
||||
'map' => 'guid',
|
||||
'title' => __('Collection URL', 'tainacan'),
|
||||
'type' => 'string',
|
||||
'description' => __('The collection URL', 'tainacan')
|
||||
],
|
||||
'featured_image' => [
|
||||
'map' => 'thumbnail',
|
||||
'title' => __('Featured Image', 'tainacan'),
|
||||
'type' => 'string',
|
||||
'description' => __('The collection thumbnail URL')
|
||||
],
|
||||
'order' => [
|
||||
'map' => 'menu_order',
|
||||
|
|
|
@ -281,7 +281,12 @@ abstract class Repository {
|
|||
} elseif ( $mapped == 'termmeta' ){
|
||||
$property = get_term_meta($entity->WP_Term->term_id, $prop, true);
|
||||
} elseif ( isset( $entity->WP_Post )) {
|
||||
if($mapped == 'thumbnail'){
|
||||
$property = get_the_post_thumbnail_url($entity->WP_Post->ID, 'full');
|
||||
}
|
||||
else {
|
||||
$property = isset($entity->WP_Post->$mapped) ? $entity->WP_Post->$mapped : null;
|
||||
}
|
||||
} elseif ( isset( $entity->WP_Term )) {
|
||||
$property = isset($entity->WP_Term->$mapped) ? $entity->WP_Term->$mapped : null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue