Prevents excluded post types from being displayed in newsletter editor
This commit is contained in:
@ -20,13 +20,14 @@ class AutomatedLatestContent extends APIEndpoint {
|
|||||||
|
|
||||||
function getPostTypes() {
|
function getPostTypes() {
|
||||||
$post_types = array_map(function($post_type) {
|
$post_types = array_map(function($post_type) {
|
||||||
|
if(!empty($post_type->exclude_from_search)) return;
|
||||||
return array(
|
return array(
|
||||||
'name' => $post_type->name,
|
'name' => $post_type->name,
|
||||||
'label' => $post_type->label
|
'label' => $post_type->label
|
||||||
);
|
);
|
||||||
}, get_post_types(array(), 'objects'));
|
}, get_post_types(array(), 'objects'));
|
||||||
return $this->successResponse(
|
return $this->successResponse(
|
||||||
$post_types
|
array_filter($post_types)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,4 +15,14 @@ class AutomatedLatestContentTest extends \MailPoetTest {
|
|||||||
expect($post_type['label'])->notEmpty();
|
expect($post_type['label'])->notEmpty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testItDoesNotGetPostTypesExludedFromSearch() {
|
||||||
|
$router = new AutomatedLatestContent();
|
||||||
|
$response = $router->getPostTypes();
|
||||||
|
// WP's default post type 'revision' is excluded from search
|
||||||
|
// https://codex.wordpress.org/Post_Types
|
||||||
|
$revision_post_type = get_post_type_object('revision');
|
||||||
|
expect($revision_post_type->exclude_from_search)->true();
|
||||||
|
expect(isset($response->data['revision']))->false();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user