feat: Add SPA page selection UI in admin
Complete WooCommerce-style page architecture implementation: Backend (already committed): - API endpoint to fetch WordPress pages - spa_pages field in appearance settings - is_spa_page() checks in TemplateOverride and Assets Frontend (this commit): - Added page selector UI in Appearance > General - Dropdowns for Shop, Cart, Checkout, Account pages - Loads available WordPress pages from API - Saves selected page IDs to settings - Info alert explaining full-body rendering UI Features: - Clean page selection interface - Shows all published WordPress pages - '— None —' option to disable - Integrated into existing General settings tab - Follows existing design patterns How it works: 1. Admin selects pages in Appearance > General 2. Page IDs saved to woonoow_appearance_settings 3. Frontend checks if current page matches selected pages 4. If match, renders full SPA to body (no theme interference) 5. Works with ANY theme consistently Next: Test page selection and verify clean SPA rendering
This commit is contained in:
@@ -56,6 +56,13 @@ class AppearanceController {
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
// Get all WordPress pages for page selector
|
||||
register_rest_route(self::API_NAMESPACE, '/pages/list', [
|
||||
'methods' => 'GET',
|
||||
'callback' => [__CLASS__, 'get_pages_list'],
|
||||
'permission_callback' => [__CLASS__, 'check_permission'],
|
||||
]);
|
||||
}
|
||||
|
||||
public static function check_permission() {
|
||||
@@ -377,6 +384,30 @@ class AppearanceController {
|
||||
return $sanitized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of WordPress pages for page selector
|
||||
*/
|
||||
public static function get_pages_list(WP_REST_Request $request) {
|
||||
$pages = get_pages([
|
||||
'post_status' => 'publish',
|
||||
'sort_column' => 'post_title',
|
||||
'sort_order' => 'ASC',
|
||||
]);
|
||||
|
||||
$pages_list = array_map(function($page) {
|
||||
return [
|
||||
'id' => $page->ID,
|
||||
'title' => $page->post_title,
|
||||
'slug' => $page->post_name,
|
||||
];
|
||||
}, $pages);
|
||||
|
||||
return new WP_REST_Response([
|
||||
'success' => true,
|
||||
'data' => $pages_list,
|
||||
], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default settings structure
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user