| 1 |
import apiFetch from '@wordpress/api-fetch'; |
| 2 |
|
| 3 |
const postTypes = { page: 'pages', post: 'posts' }; |
| 4 |
|
| 5 |
// status should only be either "publish" or "draft" |
| 6 |
export default async ({ postId, postType, updatedStatus }) => { |
| 7 |
const type = postTypes[postType] || postType; |
| 8 |
return await apiFetch({ |
| 9 |
path: `/wp/v2/${type}/${postId}?context=edit`, |
| 10 |
method: 'POST', |
| 11 |
data: { status: updatedStatus }, |
| 12 |
}); |
| 13 |
}; |
| 14 |
|