diff --git a/README.md b/README.md index 59c72ad..3b83722 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,36 @@ -# WP ALLSTARS Superstar Plugin -A lean speed optimization plugin for WordPress. Speed Matters. +# WP ALLSTARS Plugin + +A WordPress plugin for optimizing website performance. ## Features -- Lazy loading of images -- CSS minification -- JS minification -- Modern, tabbed Admin UI with AJAX settings + +- Auto upload of external images +- More features coming soon... ## Installation -1. Download or clone this repo. -2. Upload to `/wp-content/plugins/`. -3. Activate in WordPress Admin. -4. Clean LocalWP sync -## Configuration -- Go to Settings → WPA Superstar. -- Toggle features in General and Advanced tabs. -- No Aider files synced +1. Download the plugin +2. Upload to your WordPress site +3. Activate the plugin +4. Configure settings -## Logs -- Errors are logged to `wp-content/wpa-superstar.log`. -- Sync logging enabled +## Usage + +1. Go to Settings → WP ALLSTARS +2. Configure auto upload settings +3. Save changes + +## Debugging + +- Debug mode can be enabled in wp-config.php +- Errors are logged to `wp-content/wp-allstars.log` + +## Support + +For support, please visit [wpallstars.com](https://www.wpallstars.com) + +## License + +GPL-2.0+ diff --git a/admin/css/wp-allstars-admin.css b/admin/css/wp-allstars-admin.css new file mode 100644 index 0000000..fc504e1 --- /dev/null +++ b/admin/css/wp-allstars-admin.css @@ -0,0 +1,125 @@ +.wp-allstars-wrap { + max-width: none; + margin: 0; + padding-right: 20px; +} + +.wp-allstars-header { + background: #fff; + border-bottom: 1px solid #c3c4c7; + box-shadow: 0 1px 0 rgba(0,0,0,.04); + margin: 0 -20px 20px -20px; + padding: 20px; + display: flex; + align-items: center; + justify-content: space-between; + width: auto; +} + +.wp-allstars-header h1 { + font-size: 23px; + font-weight: 400; + margin: 0; + padding: 0; + line-height: 1.3; + color: #1d2327; +} + +.wp-allstars-header-actions { + display: flex; + align-items: center; + gap: 10px; +} + +.wp-allstars-version { + color: #646970; + font-size: 13px; + font-weight: 400; +} + +.wp-allstars-toggle { + margin: 15px 0; + padding: 16px 20px; + background: #fff; + border: 1px solid #ddd; + border-radius: 4px; + box-shadow: 0 1px 4px rgba(0,0,0,0.02); + transition: all .15s ease-in-out; +} + +.wp-allstars-toggle:hover { + border-color: #4caf50; + box-shadow: 0 2px 6px rgba(0,0,0,0.04); +} + +.wp-allstars-toggle label { + display: flex; + align-items: center; + font-size: 14px; + line-height: 1.4; + font-weight: 500; + color: #1d2327; + cursor: pointer; +} + +.wp-allstars-toggle .description { + margin: 6px 0 0 52px; + color: #666; + font-size: 13px; + line-height: 1.5; +} + +.wp-allstars-loading-overlay { + position: fixed; + top: 32px; + left: 160px; + right: 0; + bottom: 0; + background: rgba(255, 255, 255, 0.9); + z-index: 100000; + display: flex; + align-items: center; + justify-content: center; +} + +.wp-allstars-plugin-filters { + margin: 0 0 20px; + padding: 0 0 12px; + border-bottom: 1px solid #ddd; +} + +.wp-allstars-settings-container { + padding: 0 20px; + max-width: 1100px; +} + +.wp-allstars-settings-content { + margin-top: 20px; + padding: 0; +} + +.wp-allstars-toggle-header { + display: flex; + justify-content: space-between; + align-items: center; + width: 100%; +} + +.wp-allstars-toggle-settings { + margin-top: 15px; + padding-top: 15px; + border-top: 1px solid #ddd; +} + +.wp-allstars-setting-row { + margin-bottom: 20px; +} + +.wp-allstars-expand-settings { + background: none; + border: none; + padding: 4px; + cursor: pointer; + color: #787c82; + transition: color .15s ease-in-out; +} \ No newline at end of file diff --git a/admin/css/wpa-superstar-admin.css b/admin/css/wpa-superstar-admin.css deleted file mode 100644 index 11c2c32..0000000 --- a/admin/css/wpa-superstar-admin.css +++ /dev/null @@ -1,328 +0,0 @@ -.wpa-superstar-wrap { - max-width: none; - margin: 0; - padding-right: 20px; -} - -.wpa-superstar-header { - background: #fff; - border-bottom: 1px solid #c3c4c7; - box-shadow: 0 1px 0 rgba(0,0,0,.04); - margin: 0 -20px 20px -20px; - padding: 20px; - display: flex; - align-items: center; - justify-content: space-between; - width: auto; -} - -.wpa-superstar-header h1 { - font-size: 23px; - font-weight: 400; - margin: 0; - padding: 0; - line-height: 1.3; - color: #1d2327; -} - -.wpa-superstar-header-actions { - display: flex; - align-items: center; - gap: 10px; -} - -.wpa-superstar-version { - color: #646970; - font-size: 13px; - font-weight: 400; -} - -.wpa-settings-container { - padding: 0 20px; - max-width: 1100px; -} - -/* RankMath-style Tabs */ -.nav-tab-wrapper { - margin: 0; - padding-top: 0; - border-bottom: 1px solid #ddd; - line-height: inherit; - position: relative; - z-index: 1; -} - -.nav-tab { - margin: 0 6px 0 0; - padding: 12px 20px; - font-size: 14px; - line-height: 1.4; - font-weight: 500; - background: transparent; - border: 0; - border-bottom: 2px solid transparent; - color: #646970; - transition: all .2s ease; -} - -.nav-tab:hover, -.nav-tab:focus { - background: transparent; - color: #2271b1; - border-bottom-color: rgba(34, 113, 177, 0.4); -} - -.nav-tab-active, -.nav-tab-active:focus, -.nav-tab-active:focus:active, -.nav-tab-active:hover { - background: transparent; - color: #2271b1; - border: 0; - border-bottom: 2px solid #2271b1; - font-weight: 600; -} - -/* RankMath-style toggle switches */ -.wpa-superstar-toggle { - margin: 15px 0; - padding: 16px 20px; - background: #fff; - border: 1px solid #ddd; - border-radius: 4px; - box-shadow: 0 1px 4px rgba(0,0,0,0.02); - transition: all .15s ease-in-out; -} - -.wpa-superstar-toggle:hover { - border-color: #4caf50; - box-shadow: 0 2px 6px rgba(0,0,0,0.04); -} - -.wpa-superstar-toggle label { - display: flex; - align-items: center; - font-size: 14px; - line-height: 1.4; - font-weight: 500; - color: #1d2327; - cursor: pointer; -} - -.wpa-superstar-toggle .description { - margin: 6px 0 0 52px; - color: #666; - font-size: 13px; - line-height: 1.5; -} - -/* RankMath-style Toggle Switch */ -.wpa-toggle-switch { - position: relative; - display: inline-block; - width: 40px; - height: 20px; - margin-right: 12px; -} - -.wpa-toggle-switch input { - opacity: 0; - width: 0; - height: 0; - margin: 0; -} - -.wpa-toggle-slider { - position: absolute; - cursor: pointer; - top: 0; - left: 0; - right: 0; - bottom: 0; - background-color: #b5bfc9; - transition: .15s ease-in-out; - border-radius: 100px; - border: 0; -} - -.wpa-toggle-slider:before { - position: absolute; - content: ""; - height: 16px; - width: 16px; - left: 2px; - bottom: 2px; - background-color: white; - transition: .15s ease-in-out; - border-radius: 50%; - box-shadow: 0 2px 4px rgba(0,0,0,0.2); -} - -.wpa-toggle-switch input:checked + .wpa-toggle-slider { - background-color: #4caf50; -} - -.wpa-toggle-switch input:checked + .wpa-toggle-slider:before { - transform: translateX(20px); -} - -.wpa-toggle-switch input:focus + .wpa-toggle-slider { - box-shadow: 0 0 0 1px #fff, 0 0 0 3px rgba(76, 175, 80, 0.25); -} - -.wpa-toggle-switch:hover .wpa-toggle-slider:before { - box-shadow: 0 2px 4px rgba(0,0,0,0.3); -} - -/* Plugin filters */ -.wpa-plugin-filters { - margin: 0 0 20px; - padding: 0 0 12px; - border-bottom: 1px solid #ddd; -} - -.wpa-plugin-filters .button { - margin: 0 8px 8px 0; - padding: 4px 10px; - font-size: 13px; - line-height: 1.5; - min-height: 30px; -} - -/* Settings content spacing */ -.wpa-settings-content { - margin-top: 20px; - padding: 0; -} - -/* Loading overlay */ -.wpa-loading-overlay { - position: fixed; - top: 32px; - left: 160px; - right: 0; - bottom: 0; - background: rgba(255, 255, 255, 0.9); - z-index: 100000; - display: flex; - align-items: center; - justify-content: center; -} - -.wp-list-table-container { - position: relative; - min-height: 400px; -} - -.wp-list-table-container .spinner { - float: none; - margin: 0; -} - -.wpa-superstar-workflow-toggle { - /* Remove these style blocks entirely */ -} - -.wpa-superstar-workflow-toggle label { - /* Remove these style blocks entirely */ -} - -.wpa-superstar-workflow-toggle .description { - /* Remove these style blocks entirely */ -} - -/* Toggle switch styles */ -.switch { - /* Remove these style blocks entirely */ -} - -.switch input { - /* Remove these style blocks entirely */ -} - -.slider { - /* Remove these style blocks entirely */ -} - -.slider:before { - /* Remove these style blocks entirely */ -} - -input:checked + .slider { - /* Remove these style blocks entirely */ -} - -input:checked + .slider:before { - /* Remove these style blocks entirely */ -} - -/* Active tab styles */ -.nav-tab-active { - background: #fff; - border-bottom: 1px solid #fff; -} - -.wpa-toggle-header { - display: flex; - justify-content: space-between; - align-items: center; - width: 100%; -} - -.wpa-expand-settings { - background: none; - border: none; - padding: 4px; - cursor: pointer; - color: #787c82; - transition: color .15s ease-in-out; -} - -.wpa-expand-settings:hover { - color: #2271b1; -} - -.wpa-expand-settings .dashicons { - width: 20px; - height: 20px; - font-size: 20px; -} - -.wpa-toggle-settings { - margin-top: 15px; - padding-top: 15px; - border-top: 1px solid #ddd; -} - -.wpa-setting-row { - margin-bottom: 20px; -} - -.wpa-setting-row:last-child { - margin-bottom: 0; -} - -.wpa-setting-row label { - display: block; - font-weight: 600; - margin-bottom: 5px; -} - -.wpa-setting-row input[type="text"], -.wpa-setting-row input[type="number"], -.wpa-setting-row textarea { - width: 100%; - max-width: 400px; - margin-top: 5px; -} - -.wpa-setting-row textarea { - min-height: 80px; -} - -.wpa-setting-row .description { - margin-top: 5px; - margin-left: 0; - color: #666; - font-size: 13px; -} \ No newline at end of file diff --git a/admin/js/wpa-superstar-admin.js b/admin/js/wp-allstars-admin.js similarity index 63% rename from admin/js/wpa-superstar-admin.js rename to admin/js/wp-allstars-admin.js index a0c44f4..eefa38e 100644 --- a/admin/js/wpa-superstar-admin.js +++ b/admin/js/wp-allstars-admin.js @@ -1,21 +1,21 @@ jQuery(document).ready(function($) { - $('.wpa-superstar-toggle input').on('change', function() { + $('.wp-allstars-toggle input').on('change', function() { var $input = $(this); var option = $input.attr('name'); var value = $input.is(':checked') ? 1 : 0; // Remove any existing status messages - $('.wpa-status').remove(); + $('.wp-status').remove(); // Add a small notification that fades out - var $notification = $('Setting saved'); + var $notification = $('Setting saved'); $('body').append($notification); - $.post(wpaSuperstar.ajaxurl, { - action: 'wpa_superstar_update_option', + $.post(wpAllstars.ajaxurl, { + action: 'wp_allstars_update_option', option: option, value: value, - nonce: wpaSuperstar.nonce + nonce: wpAllstars.nonce }, function(response) { if (!response.success) { console.error('Error:', response); diff --git a/admin/settings.php b/admin/settings.php index 664329a..a2fbfdd 100644 --- a/admin/settings.php +++ b/admin/settings.php @@ -4,37 +4,37 @@ */ // Add menu item -function wpa_superstar_admin_menu() { +function wp_allstars_admin_menu() { add_options_page( - 'WPA Superstar Settings', - 'WPA Superstar', + 'WP ALLSTARS Settings', + 'WP ALLSTARS', 'manage_options', - 'wpa-superstar', - 'wpa_superstar_settings_page' + 'wp-allstars', + 'wp_allstars_settings_page' ); } -add_action('admin_menu', 'wpa_superstar_admin_menu'); +add_action('admin_menu', 'wp_allstars_admin_menu'); // Register settings -function wpa_superstar_register_settings() { - register_setting('wpa-superstar-settings', 'wpa_superstar_lazy_load'); - register_setting('wpa-superstar-settings', 'wpa_superstar_minify_css'); - register_setting('wpa-superstar-settings', 'wpa_superstar_minify_js'); +function wp_allstars_register_settings() { + register_setting('wp-allstars-settings', 'wp_allstars_lazy_load'); + register_setting('wp-allstars-settings', 'wp_allstars_minify_css'); + register_setting('wp-allstars-settings', 'wp_allstars_minify_js'); } -add_action('admin_init', 'wpa_superstar_register_settings'); +add_action('admin_init', 'wp_allstars_register_settings'); // AJAX handler for settings -function wpa_superstar_update_option() { - check_ajax_referer('wpa-superstar-nonce', 'nonce'); +function wp_allstars_update_option() { + check_ajax_referer('wp-allstars-nonce', 'nonce'); $option = sanitize_text_field($_POST['option']); $value = intval($_POST['value']); update_option($option, $value); wp_send_json_success('Option updated'); } -add_action('wp_ajax_wpa_superstar_update_option', 'wpa_superstar_update_option'); +add_action('wp_ajax_wp_allstars_update_option', 'wp_allstars_update_option'); // Define recommended plugins -function wpa_superstar_get_recommended_plugins() { +function wp_allstars_get_recommended_plugins() { return array( 'minimal' => array( 'antispam-bee', @@ -64,8 +64,8 @@ function wpa_superstar_get_recommended_plugins() { } // Add transient caching for plugin data -function wpa_superstar_get_cached_plugins($category) { - $cache_key = 'wpa_superstar_plugins_' . $category; +function wp_allstars_get_cached_plugins($category) { + $cache_key = 'wp_allstars_plugins_' . $category; $cached_data = get_transient($cache_key); if ($cached_data !== false) { @@ -75,13 +75,13 @@ function wpa_superstar_get_cached_plugins($category) { return false; } -function wpa_superstar_set_cached_plugins($category, $data) { - $cache_key = 'wpa_superstar_plugins_' . $category; +function wp_allstars_set_cached_plugins($category, $data) { + $cache_key = 'wp_allstars_plugins_' . $category; set_transient($cache_key, $data, 12 * HOUR_IN_SECONDS); } // Add AJAX endpoint for plugin list -function wpa_superstar_ajax_get_plugins() { +function wp_allstars_ajax_get_plugins() { check_ajax_referer('updates'); if (!current_user_can('install_plugins')) { @@ -93,13 +93,13 @@ function wpa_superstar_ajax_get_plugins() { require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; // Get our recommended plugins for this category - $recommended_plugins = wpa_superstar_get_recommended_plugins(); + $recommended_plugins = wp_allstars_get_recommended_plugins(); if (!isset($recommended_plugins[$category])) { wp_send_json_error('Invalid category: ' . $category); } // Try to get cached data first - $cached_data = wpa_superstar_get_cached_plugins($category); + $cached_data = wp_allstars_get_cached_plugins($category); if ($cached_data !== false) { error_log('Using cached data for category: ' . $category); // Setup the list table with cached data @@ -188,7 +188,7 @@ function wpa_superstar_ajax_get_plugins() { ); // Cache the results - wpa_superstar_set_cached_plugins($category, $res); + wp_allstars_set_cached_plugins($category, $res); // Setup the list table $GLOBALS['tab'] = 'plugin-install'; @@ -218,49 +218,49 @@ function wpa_superstar_ajax_get_plugins() { wp_send_json_error('Failed to fetch plugin data: ' . $e->getMessage()); } } -add_action('wp_ajax_wpa_get_plugins', 'wpa_superstar_ajax_get_plugins'); +add_action('wp_ajax_wp_allstars_get_plugins', 'wp_allstars_ajax_get_plugins'); // Remove the old plugins API filter since we're handling everything in the AJAX endpoint -remove_filter('plugins_api_result', 'wpa_superstar_plugins_api_result'); +remove_filter('plugins_api_result', 'wp_allstars_plugins_api_result'); // Clear plugin cache when plugins are updated, activated, or deactivated -function wpa_superstar_clear_plugin_cache() { - $recommended_plugins = wpa_superstar_get_recommended_plugins(); +function wp_allstars_clear_plugin_cache() { + $recommended_plugins = wp_allstars_get_recommended_plugins(); foreach (array_keys($recommended_plugins) as $category) { - delete_transient('wpa_superstar_plugins_' . $category); + delete_transient('wp_allstars_plugins_' . $category); } } -add_action('upgrader_process_complete', 'wpa_superstar_clear_plugin_cache', 10, 0); -add_action('activated_plugin', 'wpa_superstar_clear_plugin_cache'); -add_action('deactivated_plugin', 'wpa_superstar_clear_plugin_cache'); -add_action('deleted_plugin', 'wpa_superstar_clear_plugin_cache'); -add_action('update_option_active_plugins', 'wpa_superstar_clear_plugin_cache'); +add_action('upgrader_process_complete', 'wp_allstars_clear_plugin_cache', 10, 0); +add_action('activated_plugin', 'wp_allstars_clear_plugin_cache'); +add_action('deactivated_plugin', 'wp_allstars_clear_plugin_cache'); +add_action('deleted_plugin', 'wp_allstars_clear_plugin_cache'); +add_action('update_option_active_plugins', 'wp_allstars_clear_plugin_cache'); // Add transient caching for theme data -function wpa_superstar_get_cached_theme() { - $cache_key = 'wpa_superstar_theme_kadence'; +function wp_allstars_get_cached_theme() { + $cache_key = 'wp_allstars_theme_kadence'; return get_transient($cache_key); } -function wpa_superstar_set_cached_theme($data) { - $cache_key = 'wpa_superstar_theme_kadence'; +function wp_allstars_set_cached_theme($data) { + $cache_key = 'wp_allstars_theme_kadence'; set_transient($cache_key, $data, 12 * HOUR_IN_SECONDS); } // Add AJAX endpoint for theme -function wpa_superstar_ajax_get_theme() { +function wp_allstars_ajax_get_theme() { check_ajax_referer('updates'); if (!current_user_can('install_themes')) { - error_log('WPA Superstar: User does not have permission to install themes'); + error_log('WP ALLSTARS: User does not have permission to install themes'); wp_send_json_error('Permission denied'); return; } - error_log('WPA Superstar: Starting theme fetch process'); + error_log('WP ALLSTARS: Starting theme fetch process'); try { - error_log('WPA Superstar: Fetching theme data for kadence'); + error_log('WP ALLSTARS: Fetching theme data for kadence'); // Get theme data with minimal fields $theme_data = themes_api('theme_information', array( @@ -286,12 +286,12 @@ function wpa_superstar_ajax_get_theme() { )); if (is_wp_error($theme_data)) { - error_log('WPA Superstar Theme API Error: ' . $theme_data->get_error_message()); + error_log('WP ALLSTARS Theme API Error: ' . $theme_data->get_error_message()); wp_send_json_error('Theme API Error: ' . $theme_data->get_error_message()); return; } - error_log('WPA Superstar: Successfully fetched theme data'); + error_log('WP ALLSTARS: Successfully fetched theme data'); // Format author data $author = ''; @@ -391,35 +391,35 @@ function wpa_superstar_ajax_get_theme() { $html = ob_get_clean(); if (empty($html)) { - error_log('WPA Superstar: Empty HTML generated'); + error_log('WP ALLSTARS: Empty HTML generated'); wp_send_json_error('Failed to generate theme display'); return; } - error_log('WPA Superstar: Successfully generated theme display'); + error_log('WP ALLSTARS: Successfully generated theme display'); wp_send_json_success($html); } catch (Exception $e) { - error_log('WPA Superstar Theme loading exception: ' . $e->getMessage()); - error_log('WPA Superstar Theme loading exception trace: ' . $e->getTraceAsString()); + error_log('WP ALLSTARS Theme loading exception: ' . $e->getMessage()); + error_log('WP ALLSTARS Theme loading exception trace: ' . $e->getTraceAsString()); wp_send_json_error('Theme loading error: ' . $e->getMessage()); } catch (Error $e) { - error_log('WPA Superstar Theme loading error: ' . $e->getMessage()); - error_log('WPA Superstar Theme loading error trace: ' . $e->getTraceAsString()); + error_log('WP ALLSTARS Theme loading error: ' . $e->getMessage()); + error_log('WP ALLSTARS Theme loading error trace: ' . $e->getTraceAsString()); wp_send_json_error('Theme loading error: ' . $e->getMessage()); } } -add_action('wp_ajax_wpa_get_theme', 'wpa_superstar_ajax_get_theme'); +add_action('wp_ajax_wp_allstars_get_theme', 'wp_allstars_ajax_get_theme'); // Clear theme cache when themes are updated -function wpa_superstar_clear_theme_cache() { - delete_transient('wpa_superstar_theme_kadence'); +function wp_allstars_clear_theme_cache() { + delete_transient('wp_allstars_theme_kadence'); } -add_action('upgrader_process_complete', 'wpa_superstar_clear_theme_cache', 10, 0); -add_action('switch_theme', 'wpa_superstar_clear_theme_cache'); +add_action('upgrader_process_complete', 'wp_allstars_clear_theme_cache', 10, 0); +add_action('switch_theme', 'wp_allstars_clear_theme_cache'); // Add AJAX handler for theme activation -function wpa_superstar_activate_theme() { +function wp_allstars_activate_theme() { check_ajax_referer('updates'); if (!current_user_can('switch_themes')) { @@ -447,10 +447,10 @@ function wpa_superstar_activate_theme() { wp_send_json_error('Failed to activate theme'); } } -add_action('wp_ajax_wpa_activate_theme', 'wpa_superstar_activate_theme'); +add_action('wp_ajax_wp_allstars_activate_theme', 'wp_allstars_activate_theme'); // Settings page HTML -function wpa_superstar_settings_page() { +function wp_allstars_settings_page() { global $tabs; $active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'general'; @@ -458,47 +458,49 @@ function wpa_superstar_settings_page() { // Clear cache and load required files if ($active_tab === 'recommended') { - wpa_superstar_clear_plugin_cache(); + wp_allstars_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', __FILE__)); } elseif ($active_tab === 'theme') { - wpa_superstar_clear_theme_cache(); + wp_allstars_clear_theme_cache(); require_once ABSPATH . 'wp-admin/includes/theme.php'; wp_enqueue_script('theme-install'); wp_enqueue_script('updates'); add_thickbox(); + wp_enqueue_style('wp-allstars-admin', plugins_url('css/wp-allstars-admin.css', __FILE__)); } ?> -