From ad489bddb57bb97114328a9326f75fab9dac490d Mon Sep 17 00:00:00 2001 From: Marcus Quinn Date: Mon, 24 Mar 2025 17:19:25 +0000 Subject: [PATCH] Refactor: Clean up settings.php by removing all HTML content and properly delegating to Admin Manager class --- admin/includes/class-admin-manager.php | 139 ++++++++++ admin/settings.php | 359 +++---------------------- 2 files changed, 170 insertions(+), 328 deletions(-) diff --git a/admin/includes/class-admin-manager.php b/admin/includes/class-admin-manager.php index 3f1f03a..dd7ea87 100644 --- a/admin/includes/class-admin-manager.php +++ b/admin/includes/class-admin-manager.php @@ -74,4 +74,143 @@ class WP_Allstars_Admin_Manager { 'wp_allstars_settings_page' ); } + + /** + * Render the settings page + */ + public static function render_settings_page() { + global $tabs; + + $active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'general'; + $active_category = isset($_GET['category']) ? $_GET['category'] : 'minimal'; + + // Clear cache and load required files + if ($active_tab === 'recommended') { + WP_Allstars_Plugin_Manager::clear_plugin_cache(); + require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; + wp_enqueue_script('plugin-install'); + wp_enqueue_script('updates'); + add_thickbox(); + wp_enqueue_style('wp-allstars-admin', plugins_url('css/wp-allstars-admin.css', dirname(__FILE__))); + wp_enqueue_style('wp-allstars-plugins', plugins_url('css/wp-allstars-plugins.css', dirname(__FILE__))); + + // Add inline script to load plugins on page load + wp_add_inline_script('wp-allstars-admin', ' + jQuery(document).ready(function($) { + if ($("#wpa-plugin-list").length && $("#wpa-plugin-list").is(":empty")) { + var category = "' . esc_js($active_category) . '"; + var $container = $("#wpa-plugin-list"); + var $loadingOverlay = $("
"); + + // Show loading overlay + $container.css("position", "relative").append($loadingOverlay); + + // AJAX request to get plugins + $.ajax({ + url: ajaxurl, + type: "POST", + data: { + action: "wp_allstars_get_plugins", + category: category, + _wpnonce: wpAllstars.nonce + }, + success: function(response) { + $loadingOverlay.remove(); + if (response.success) { + $container.html(response.data); + // Initialize plugin action buttons + if (typeof initPluginActions === "function") { + initPluginActions(); + } + + // Spinners have been removed from individual cards + } else { + $container.html("

" + response.data + "

"); + } + }, + error: function(xhr, status, error) { + $loadingOverlay.remove(); + $container.html("

Failed to load plugins. Please try again. Error: " + error + "

"); + console.error("AJAX Error:", xhr.responseText); + } + }); + } + }); + '); + } + ?> +
+
+

+
+ + + + +
+
+ + +
+ "); - - // Show loading overlay - $container.css("position", "relative").append($loadingOverlay); - - // AJAX request to get plugins - $.ajax({ - url: ajaxurl, - type: "POST", - data: { - action: "wp_allstars_get_plugins", - category: category, - _wpnonce: wpAllstars.nonce - }, - success: function(response) { - $loadingOverlay.remove(); - if (response.success) { - $container.html(response.data); - // Initialize plugin action buttons - if (typeof initPluginActions === "function") { - initPluginActions(); - } - - // Spinners have been removed from individual cards - } else { - $container.html("

" + response.data + "

"); - } - }, - error: function(xhr, status, error) { - $loadingOverlay.remove(); - $container.html("

Failed to load plugins. Please try again. Error: " + error + "

"); - console.error("AJAX Error:", xhr.responseText); - } - }); - } - }); - '); - // Theme-specific scripts and styles are now handled in WP_Allstars_Theme_Manager::enqueue_scripts - } - ?> -
-
-

-
- - - - -
-
- -
- - -
- -
-
- -
-
- - -

-
-
- - -

-
- -
- - -

-
- -
- - -

- %filename%, %post_id%, %postname%, %timestamp%, %date%, %year%, %month%, %day% -

-
- -
- - -

- %filename%, %post_title%, %post_id%, %postname%, %timestamp% -

-
-
-
-
-
- -
- -
-
- -
- -
- - - -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
-
- -