Implement AJAX handler for admin bar pull button and remove REST API endpoint for pulling pages
This commit is contained in:
@@ -48,15 +48,6 @@ add_action( 'rest_api_init', function () {
|
||||
},
|
||||
] );
|
||||
|
||||
// ── Pull single page + theme ───────────────────────────────────────────
|
||||
register_rest_route( 'oribi-sync/v1', '/pull-page', [
|
||||
'methods' => 'POST',
|
||||
'callback' => 'oribi_sync_rest_pull_page',
|
||||
'permission_callback' => function () {
|
||||
return current_user_can( 'manage_options' );
|
||||
},
|
||||
] );
|
||||
|
||||
// ── Webhook (secret-based auth, no WP login required) ─────────────────
|
||||
register_rest_route( 'oribi-sync/v1', '/webhook', [
|
||||
'methods' => 'POST',
|
||||
@@ -95,20 +86,6 @@ function oribi_sync_rest_status(): WP_REST_Response {
|
||||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
* REST: Pull a single page and theme from the repo.
|
||||
*/
|
||||
function oribi_sync_rest_pull_page( WP_REST_Request $request ): WP_REST_Response {
|
||||
$post_id = (int) $request->get_param( 'post_id' );
|
||||
if ( $post_id < 1 ) {
|
||||
return new WP_REST_Response( [ 'ok' => false, 'message' => 'Missing or invalid post_id.' ], 400 );
|
||||
}
|
||||
|
||||
$result = oribi_sync_pull_page_from_repo( $post_id );
|
||||
|
||||
return new WP_REST_Response( $result, $result['ok'] ? 200 : 500 );
|
||||
}
|
||||
|
||||
/**
|
||||
* REST: Webhook trigger.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user