versioning and wp plugin updates
This commit is contained in:
@@ -49,12 +49,70 @@ class Igny8Admin {
|
||||
* Add admin menu pages
|
||||
*/
|
||||
public function add_menu_pages() {
|
||||
add_options_page(
|
||||
__('IGNY8 API Settings', 'igny8-bridge'),
|
||||
__('IGNY8 API', 'igny8-bridge'),
|
||||
// Add main menu page
|
||||
add_menu_page(
|
||||
__('IGNY8', 'igny8-bridge'),
|
||||
__('IGNY8', 'igny8-bridge'),
|
||||
'manage_options',
|
||||
'igny8-settings',
|
||||
array($this, 'render_settings_page')
|
||||
'igny8-dashboard',
|
||||
array($this, 'render_page'),
|
||||
plugins_url('admin/assets/images/logo-icon.png', IGNY8_BRIDGE_PLUGIN_FILE),
|
||||
58
|
||||
);
|
||||
|
||||
// Add submenu pages
|
||||
add_submenu_page(
|
||||
'igny8-dashboard',
|
||||
__('Dashboard', 'igny8-bridge'),
|
||||
__('Dashboard', 'igny8-bridge'),
|
||||
'manage_options',
|
||||
'igny8-dashboard',
|
||||
array($this, 'render_page')
|
||||
);
|
||||
|
||||
add_submenu_page(
|
||||
'igny8-dashboard',
|
||||
__('Connection', 'igny8-bridge'),
|
||||
__('Connection', 'igny8-bridge'),
|
||||
'manage_options',
|
||||
'igny8-connection',
|
||||
array($this, 'render_page')
|
||||
);
|
||||
|
||||
add_submenu_page(
|
||||
'igny8-dashboard',
|
||||
__('Controls', 'igny8-bridge'),
|
||||
__('Controls', 'igny8-bridge'),
|
||||
'manage_options',
|
||||
'igny8-controls',
|
||||
array($this, 'render_page')
|
||||
);
|
||||
|
||||
add_submenu_page(
|
||||
'igny8-dashboard',
|
||||
__('Sync', 'igny8-bridge'),
|
||||
__('Sync', 'igny8-bridge'),
|
||||
'manage_options',
|
||||
'igny8-sync',
|
||||
array($this, 'render_page')
|
||||
);
|
||||
|
||||
add_submenu_page(
|
||||
'igny8-dashboard',
|
||||
__('Data', 'igny8-bridge'),
|
||||
__('Data', 'igny8-bridge'),
|
||||
'manage_options',
|
||||
'igny8-data',
|
||||
array($this, 'render_page')
|
||||
);
|
||||
|
||||
add_submenu_page(
|
||||
'igny8-dashboard',
|
||||
__('Logs', 'igny8-bridge'),
|
||||
__('Logs', 'igny8-bridge'),
|
||||
'manage_options',
|
||||
'igny8-logs',
|
||||
array($this, 'render_page')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -120,8 +178,17 @@ class Igny8Admin {
|
||||
* @param string $hook Current admin page hook
|
||||
*/
|
||||
public function enqueue_scripts($hook) {
|
||||
// Enqueue on settings page
|
||||
if ($hook === 'settings_page_igny8-settings') {
|
||||
// Enqueue on IGNY8 pages
|
||||
if (strpos($hook, 'igny8-') !== false || strpos($hook, 'toplevel_page_igny8') !== false) {
|
||||
// Load modern design system CSS
|
||||
wp_enqueue_style(
|
||||
'igny8-modern-style',
|
||||
IGNY8_BRIDGE_PLUGIN_URL . 'admin/assets/css/igny8-modern.css',
|
||||
array(),
|
||||
IGNY8_BRIDGE_VERSION
|
||||
);
|
||||
|
||||
// Load legacy admin CSS for backwards compatibility
|
||||
wp_enqueue_style(
|
||||
'igny8-admin-style',
|
||||
IGNY8_BRIDGE_PLUGIN_URL . 'admin/assets/css/admin.css',
|
||||
@@ -171,10 +238,10 @@ class Igny8Admin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Render settings page
|
||||
* Render page based on current menu slug
|
||||
*/
|
||||
public function render_settings_page() {
|
||||
// Handle form submission (use wp_verify_nonce to avoid wp_die on failure)
|
||||
public function render_page() {
|
||||
// Handle form submissions for connection page
|
||||
if (isset($_POST['igny8_connect'])) {
|
||||
if (empty($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'igny8_settings_nonce')) {
|
||||
add_settings_error(
|
||||
@@ -188,7 +255,7 @@ class Igny8Admin {
|
||||
}
|
||||
}
|
||||
|
||||
// Handle revoke API key (use wp_verify_nonce)
|
||||
// Handle revoke API key
|
||||
if (isset($_POST['igny8_revoke_api_key'])) {
|
||||
if (empty($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'igny8_revoke_api_key')) {
|
||||
add_settings_error(
|
||||
@@ -207,11 +274,55 @@ class Igny8Admin {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Webhook secret regeneration removed - using API key only
|
||||
|
||||
// Include settings template
|
||||
include IGNY8_BRIDGE_PLUGIN_DIR . 'admin/settings.php';
|
||||
// Determine which page to render
|
||||
$page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : 'igny8-dashboard';
|
||||
|
||||
// Add wrapper class for modern design
|
||||
echo '<div class="igny8-admin-page">';
|
||||
|
||||
// Include the appropriate page template
|
||||
$template_file = '';
|
||||
switch ($page) {
|
||||
case 'igny8-dashboard':
|
||||
$template_file = IGNY8_BRIDGE_PLUGIN_DIR . 'admin/pages/dashboard.php';
|
||||
break;
|
||||
case 'igny8-connection':
|
||||
$template_file = IGNY8_BRIDGE_PLUGIN_DIR . 'admin/pages/connection.php';
|
||||
break;
|
||||
case 'igny8-controls':
|
||||
$template_file = IGNY8_BRIDGE_PLUGIN_DIR . 'admin/pages/controls.php';
|
||||
break;
|
||||
case 'igny8-sync':
|
||||
$template_file = IGNY8_BRIDGE_PLUGIN_DIR . 'admin/pages/sync.php';
|
||||
break;
|
||||
case 'igny8-data':
|
||||
$template_file = IGNY8_BRIDGE_PLUGIN_DIR . 'admin/pages/data.php';
|
||||
break;
|
||||
case 'igny8-logs':
|
||||
$template_file = IGNY8_BRIDGE_PLUGIN_DIR . 'admin/pages/logs.php';
|
||||
break;
|
||||
default:
|
||||
$template_file = IGNY8_BRIDGE_PLUGIN_DIR . 'admin/pages/dashboard.php';
|
||||
}
|
||||
|
||||
// If the template file doesn't exist, fall back to the old settings page
|
||||
if (file_exists($template_file)) {
|
||||
include $template_file;
|
||||
} else {
|
||||
// Fallback to old settings page during transition
|
||||
include IGNY8_BRIDGE_PLUGIN_DIR . 'admin/settings.php';
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Render settings page - DEPRECATED, keeping for backwards compatibility
|
||||
*/
|
||||
public function render_settings_page() {
|
||||
// Redirect to new render_page method
|
||||
$this->render_page();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user