Add coexistence checks to all enqueue methods to prevent loading both React and Grid.js assets simultaneously. Changes: - ReactAdmin.php: Only enqueue React assets when ?react=1 - Init.php: Skip Grid.js when React active on admin pages - Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0 - Customer.php, Product.php, License.php: Add coexistence checks Now the toggle between Classic and React versions works correctly. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.createPost = exports.deleteAllPosts = void 0;
|
|
/**
|
|
* Delete all posts using REST API.
|
|
*
|
|
* @param this
|
|
*/
|
|
async function deleteAllPosts() {
|
|
// List all posts.
|
|
// https://developer.wordpress.org/rest-api/reference/posts/#list-posts
|
|
const posts = await this.rest({
|
|
path: '/wp/v2/posts',
|
|
params: {
|
|
per_page: 100,
|
|
// All possible statuses.
|
|
status: 'publish,future,draft,pending,private,trash',
|
|
},
|
|
});
|
|
// Delete all posts one by one.
|
|
// https://developer.wordpress.org/rest-api/reference/posts/#delete-a-post
|
|
// "/wp/v2/posts" not yet supports batch requests.
|
|
await Promise.all(posts.map((post) => this.rest({
|
|
method: 'DELETE',
|
|
path: `/wp/v2/posts/${post.id}`,
|
|
params: {
|
|
force: true,
|
|
},
|
|
})));
|
|
}
|
|
exports.deleteAllPosts = deleteAllPosts;
|
|
/**
|
|
* Creates a new post using the REST API.
|
|
*
|
|
* @param this
|
|
* @param payload Post attributes.
|
|
*/
|
|
async function createPost(payload) {
|
|
const post = await this.rest({
|
|
method: 'POST',
|
|
path: `/wp/v2/posts`,
|
|
data: { ...payload },
|
|
});
|
|
return post;
|
|
}
|
|
exports.createPost = createPost;
|
|
//# sourceMappingURL=posts.js.map
|