## Brand Settings Implementation ✅ ### Backend: 1. **StoreSettingsProvider** - Added branding fields - store_logo - store_icon - store_tagline - primary_color - accent_color - error_color 2. **Branding Class** - Complete branding system - ✅ Logo display (image or text fallback "WooNooW") - ✅ Favicon injection (wp_head, admin_head, login_head) - ✅ Brand colors as CSS variables - ✅ Login page customization - Logo or text - Tagline - Primary color for buttons/links - ✅ Login logo URL → home_url() - ✅ Login logo title → store name ### Features: - **Logo fallback:** No logo → Shows "WooNooW" text - **Login page:** Fully branded with logo, tagline, colors - **Favicon:** Applied to frontend, admin, login - **Colors:** Injected as CSS variables (--woonoow-primary, --accent, --error) --- ## Developer Settings Page ✅ ### Frontend: Created `/settings/developer` page with: 1. **Debug Mode Section** - Enable Debug Mode toggle - Show API Logs (when debug enabled) - Enable React DevTools (when debug enabled) 2. **System Information Section** - WooNooW Version - WooCommerce Version - WordPress Version - PHP Version - HPOS Enabled status 3. **Cache Management Section** - Clear Navigation Cache - Clear Settings Cache - Clear All Caches (destructive) - Loading states with spinner ### Backend: 1. **DeveloperController** - Settings API - GET /woonoow/v1/settings/developer - POST /woonoow/v1/settings/developer - Stores: debug_mode, show_api_logs, enable_react_devtools 2. **SystemController** - System info & cache - GET /woonoow/v1/system/info - POST /woonoow/v1/cache/clear - Cache types: navigation, settings, all --- ## Settings Structure (Final) ``` Settings (6 tabs) ├── Store Details ✅ │ ├── Store Overview │ ├── Store Identity │ ├── Brand (logo, icon, colors) │ ├── Store Address │ ├── Currency & Formatting │ └── Standards & Formats ├── Payments ✅ ├── Shipping & Delivery ✅ ├── Tax ✅ ├── Notifications ✅ └── Developer ✅ (NEW) ├── Debug Mode ├── System Information └── Cache Management ``` --- ## Implementation Details ### Branding System: ```php // Logo fallback logic if (logo exists) → Show image else → Show "WooNooW" text // Login page - Logo or text - Tagline below logo - Primary color for buttons/links - Input focus color ``` ### Developer Settings: ```typescript // API logging localStorage.setItem('woonoow_api_logs', 'true'); // React DevTools localStorage.setItem('woonoow_react_devtools', 'true'); // Cache clearing POST /cache/clear { type: 'navigation' | 'settings' | 'all' } ``` --- ## Result ✅ Brand settings fully functional ✅ Logo displays on login page (or text fallback) ✅ Favicon applied everywhere ✅ Brand colors injected as CSS variables ✅ Developer page complete ✅ System info displayed ✅ Cache management working ✅ All 6 settings tabs implemented **Ready to test in browser!**
141 lines
3.9 KiB
PHP
141 lines
3.9 KiB
PHP
<?php
|
|
/**
|
|
* System Information REST API Controller
|
|
*
|
|
* Provides REST endpoints for system information.
|
|
*
|
|
* @package WooNooW
|
|
*/
|
|
|
|
namespace WooNooW\API;
|
|
|
|
use WP_REST_Controller;
|
|
use WP_REST_Server;
|
|
use WP_REST_Request;
|
|
use WP_REST_Response;
|
|
use WP_Error;
|
|
|
|
class SystemController extends WP_REST_Controller {
|
|
|
|
/**
|
|
* Namespace
|
|
*/
|
|
protected $namespace = 'woonoow/v1';
|
|
|
|
/**
|
|
* Rest base
|
|
*/
|
|
protected $rest_base = 'system';
|
|
|
|
/**
|
|
* Register routes
|
|
*/
|
|
public function register_routes() {
|
|
// GET /woonoow/v1/system/info
|
|
register_rest_route($this->namespace, '/' . $this->rest_base . '/info', [
|
|
[
|
|
'methods' => WP_REST_Server::READABLE,
|
|
'callback' => [$this, 'get_info'],
|
|
'permission_callback' => [$this, 'check_permission'],
|
|
],
|
|
]);
|
|
|
|
// POST /woonoow/v1/cache/clear
|
|
register_rest_route($this->namespace, '/cache/clear', [
|
|
[
|
|
'methods' => WP_REST_Server::EDITABLE,
|
|
'callback' => [$this, 'clear_cache'],
|
|
'permission_callback' => [$this, 'check_permission'],
|
|
],
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Get system information
|
|
*
|
|
* @param WP_REST_Request $request Request object
|
|
* @return WP_REST_Response|WP_Error Response object or error
|
|
*/
|
|
public function get_info(WP_REST_Request $request) {
|
|
global $wp_version;
|
|
|
|
// Get WooNooW version
|
|
$plugin_data = get_file_data(
|
|
dirname(dirname(dirname(__FILE__))) . '/woonoow.php',
|
|
['Version' => 'Version']
|
|
);
|
|
|
|
// Get WooCommerce version
|
|
$wc_version = defined('WC_VERSION') ? WC_VERSION : 'N/A';
|
|
|
|
// Check HPOS
|
|
$hpos_enabled = get_option('woocommerce_custom_orders_table_enabled') === 'yes';
|
|
|
|
$response = rest_ensure_response([
|
|
'woonoowVersion' => $plugin_data['Version'] ?? '0.1.0',
|
|
'woocommerceVersion' => $wc_version,
|
|
'wordpressVersion' => $wp_version,
|
|
'phpVersion' => PHP_VERSION,
|
|
'hposEnabled' => $hpos_enabled,
|
|
]);
|
|
|
|
$response->header('Cache-Control', 'max-age=60');
|
|
|
|
return $response;
|
|
}
|
|
|
|
/**
|
|
* Clear cache
|
|
*
|
|
* @param WP_REST_Request $request Request object
|
|
* @return WP_REST_Response|WP_Error Response object or error
|
|
*/
|
|
public function clear_cache(WP_REST_Request $request) {
|
|
$type = $request->get_param('type') ?? 'all';
|
|
|
|
switch ($type) {
|
|
case 'navigation':
|
|
// Clear navigation cache
|
|
delete_transient('woonoow_navigation_tree');
|
|
break;
|
|
|
|
case 'settings':
|
|
// Clear settings cache
|
|
delete_transient('woonoow_store_settings');
|
|
delete_transient('woonoow_developer_settings');
|
|
break;
|
|
|
|
case 'all':
|
|
// Clear all WooNooW transients
|
|
global $wpdb;
|
|
$wpdb->query(
|
|
"DELETE FROM {$wpdb->options}
|
|
WHERE option_name LIKE '_transient_woonoow_%'
|
|
OR option_name LIKE '_transient_timeout_woonoow_%'"
|
|
);
|
|
break;
|
|
|
|
default:
|
|
return new WP_Error(
|
|
'invalid_cache_type',
|
|
'Invalid cache type',
|
|
['status' => 400]
|
|
);
|
|
}
|
|
|
|
return rest_ensure_response([
|
|
'success' => true,
|
|
'message' => 'Cache cleared successfully',
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Check permission
|
|
*
|
|
* @return bool True if user has permission
|
|
*/
|
|
public function check_permission() {
|
|
return current_user_can('manage_woocommerce');
|
|
}
|
|
}
|