Remove lazy loading and minification features
- Remove CSS minifier and speed functions\n- Remove lazy loading functionality\n- Update plugin description and README\n- Simplify plugin to focus on auto upload feature\n- Rename files from wpa-superstar to wp-allstars
This commit is contained in:
45
README.md
45
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+
|
||||
|
||||
<!-- Last Updated: March 13, 2025 -->
|
||||
|
125
admin/css/wp-allstars-admin.css
Normal file
125
admin/css/wp-allstars-admin.css
Normal file
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
@ -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 = $('<span class="wpa-status" style="position: fixed; top: 32px; left: 50%; transform: translateX(-50%); z-index: 99999; background: #00a32a; color: white; padding: 8px 16px; border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">Setting saved</span>');
|
||||
var $notification = $('<span class="wp-status" style="position: fixed; top: 32px; left: 50%; transform: translateX(-50%); z-index: 99999; background: #00a32a; color: white; padding: 8px 16px; border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">Setting saved</span>');
|
||||
$('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);
|
@ -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__));
|
||||
}
|
||||
?>
|
||||
<div class="wrap wpa-superstar-wrap">
|
||||
<div class="wpa-superstar-header">
|
||||
<div class="wrap wp-allstars-wrap">
|
||||
<div class="wp-allstars-header">
|
||||
<h1><?php echo esc_html(get_admin_page_title()); ?></h1>
|
||||
<div class="wpa-superstar-header-actions">
|
||||
<span class="wpa-superstar-version">Version <?php echo esc_html(WPA_SUPERSTAR_VERSION); ?></span>
|
||||
<div class="wp-allstars-header-actions">
|
||||
<span class="wp-allstars-version">Version <?php echo esc_html(WP_ALLSTARS_VERSION); ?></span>
|
||||
<a href="https://www.wpallstars.com/docs/superstar-plugin/" target="_blank" class="button button-secondary">
|
||||
<?php esc_html_e('Documentation', 'wpa-superstar'); ?>
|
||||
<?php esc_html_e('Documentation', 'wp-allstars'); ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wpa-settings-container">
|
||||
<div class="wpa-superstar-nav">
|
||||
<div class="wp-allstars-nav">
|
||||
<h2 class="nav-tab-wrapper">
|
||||
<a href="?page=wpa-superstar&tab=general" class="nav-tab <?php echo $active_tab == 'general' ? 'nav-tab-active' : ''; ?>">
|
||||
<?php esc_html_e('General', 'wpa-superstar'); ?>
|
||||
<a href="?page=wp-allstars&tab=general" class="nav-tab <?php echo $active_tab == 'general' ? 'nav-tab-active' : ''; ?>">
|
||||
<?php esc_html_e('General', 'wp-allstars'); ?>
|
||||
</a>
|
||||
<a href="?page=wpa-superstar&tab=workflow" class="nav-tab <?php echo $active_tab == 'workflow' ? 'nav-tab-active' : ''; ?>">
|
||||
<?php esc_html_e('Workflow', 'wpa-superstar'); ?>
|
||||
<a href="?page=wp-allstars&tab=workflow" class="nav-tab <?php echo $active_tab == 'workflow' ? 'nav-tab-active' : ''; ?>">
|
||||
<?php esc_html_e('Workflow', 'wp-allstars'); ?>
|
||||
</a>
|
||||
<a href="?page=wpa-superstar&tab=advanced" class="nav-tab <?php echo $active_tab == 'advanced' ? 'nav-tab-active' : ''; ?>">
|
||||
<?php esc_html_e('Advanced', 'wpa-superstar'); ?>
|
||||
<a href="?page=wp-allstars&tab=advanced" class="nav-tab <?php echo $active_tab == 'advanced' ? 'nav-tab-active' : ''; ?>">
|
||||
<?php esc_html_e('Advanced', 'wp-allstars'); ?>
|
||||
</a>
|
||||
<a href="?page=wpa-superstar&tab=recommended" class="nav-tab <?php echo $active_tab == 'recommended' ? 'nav-tab-active' : ''; ?>">
|
||||
<?php esc_html_e('Free Plugins', 'wpa-superstar'); ?>
|
||||
<a href="?page=wp-allstars&tab=recommended" class="nav-tab <?php echo $active_tab == 'recommended' ? 'nav-tab-active' : ''; ?>">
|
||||
<?php esc_html_e('Free Plugins', 'wp-allstars'); ?>
|
||||
</a>
|
||||
<a href="?page=wpa-superstar&tab=theme" class="nav-tab <?php echo $active_tab == 'theme' ? 'nav-tab-active' : ''; ?>">
|
||||
<?php esc_html_e('Theme', 'wpa-superstar'); ?>
|
||||
<a href="?page=wp-allstars&tab=theme" class="nav-tab <?php echo $active_tab == 'theme' ? 'nav-tab-active' : ''; ?>">
|
||||
<?php esc_html_e('Theme', 'wp-allstars'); ?>
|
||||
</a>
|
||||
</h2>
|
||||
</div>
|
||||
@ -506,20 +508,20 @@ function wpa_superstar_settings_page() {
|
||||
<div class="wpa-settings-content">
|
||||
<?php if ($active_tab == 'workflow'): ?>
|
||||
<form action="options.php" method="post">
|
||||
<?php settings_fields('wpa_superstar_workflow'); ?>
|
||||
<div class="wpa-superstar-toggle">
|
||||
<div class="wpa-toggle-header">
|
||||
<label for="wpa_superstar_auto_upload_images">
|
||||
<div class="wpa-toggle-switch">
|
||||
<?php settings_fields('wp_allstars_workflow'); ?>
|
||||
<div class="wp-allstars-toggle">
|
||||
<div class="wp-toggle-header">
|
||||
<label for="wp_allstars_auto_upload_images">
|
||||
<div class="wp-toggle-switch">
|
||||
<input type="checkbox"
|
||||
id="wpa_superstar_auto_upload_images"
|
||||
name="wpa_superstar_workflow_options[auto_upload_images]"
|
||||
id="wp_allstars_auto_upload_images"
|
||||
name="wp_allstars_workflow_options[auto_upload_images]"
|
||||
value="1"
|
||||
<?php
|
||||
$options = get_option('wpa_superstar_workflow_options', array(
|
||||
$options = get_option('wp_allstars_workflow_options', array(
|
||||
'auto_upload_images' => false,
|
||||
'max_width' => 1920,
|
||||
'max_height' => 1080,
|
||||
'max_width' => 2560,
|
||||
'max_height' => 2560,
|
||||
'exclude_urls' => '',
|
||||
'exclude_post_types' => array(),
|
||||
'image_name_pattern' => '%filename%',
|
||||
@ -528,71 +530,71 @@ function wpa_superstar_settings_page() {
|
||||
checked($options['auto_upload_images'], true);
|
||||
?>
|
||||
/>
|
||||
<span class="wpa-toggle-slider"></span>
|
||||
<span class="wp-toggle-slider"></span>
|
||||
</div>
|
||||
<?php esc_html_e('Enable Auto Upload Images', 'wpa-superstar'); ?>
|
||||
<?php esc_html_e('Enable Auto Upload Images', 'wp-allstars'); ?>
|
||||
</label>
|
||||
<button type="button" class="wpa-expand-settings" aria-expanded="false">
|
||||
<button type="button" class="wp-expand-settings" aria-expanded="false">
|
||||
<span class="dashicons dashicons-arrow-down-alt2"></span>
|
||||
</button>
|
||||
</div>
|
||||
<p class="description">
|
||||
<?php esc_html_e('Import images that have external URLs into your Media Library when saving. Consider disabling during large data imports with many external image URLs.', 'wpa-superstar'); ?>
|
||||
<?php esc_html_e('Import images that have external URLs into your Media Library when saving. Consider disabling during large data imports with many external image URLs.', 'wp-allstars'); ?>
|
||||
</p>
|
||||
<div class="wpa-toggle-settings" style="display: none;">
|
||||
<div class="wpa-setting-row">
|
||||
<label for="wpa_max_width"><?php esc_html_e('Max Width', 'wpa-superstar'); ?></label>
|
||||
<div class="wp-toggle-settings" style="display: none;">
|
||||
<div class="wp-setting-row">
|
||||
<label for="wp_max_width"><?php esc_html_e('Max Width', 'wp-allstars'); ?></label>
|
||||
<input type="number"
|
||||
id="wpa_max_width"
|
||||
name="wpa_superstar_workflow_options[max_width]"
|
||||
id="wp_max_width"
|
||||
name="wp_allstars_workflow_options[max_width]"
|
||||
value="<?php echo esc_attr($options['max_width']); ?>"
|
||||
min="0"
|
||||
/>
|
||||
<p class="description"><?php esc_html_e('Maximum width of uploaded images (px). Leave empty for no limit.', 'wpa-superstar'); ?></p>
|
||||
<p class="description"><?php esc_html_e('Maximum width of uploaded images (px). Leave empty for no limit.', 'wp-allstars'); ?></p>
|
||||
</div>
|
||||
|
||||
<div class="wpa-setting-row">
|
||||
<label for="wpa_max_height"><?php esc_html_e('Max Height', 'wpa-superstar'); ?></label>
|
||||
<div class="wp-setting-row">
|
||||
<label for="wp_max_height"><?php esc_html_e('Max Height', 'wp-allstars'); ?></label>
|
||||
<input type="number"
|
||||
id="wpa_max_height"
|
||||
name="wpa_superstar_workflow_options[max_height]"
|
||||
id="wp_max_height"
|
||||
name="wp_allstars_workflow_options[max_height]"
|
||||
value="<?php echo esc_attr($options['max_height']); ?>"
|
||||
min="0"
|
||||
/>
|
||||
<p class="description"><?php esc_html_e('Maximum height of uploaded images (px). Leave empty for no limit.', 'wpa-superstar'); ?></p>
|
||||
<p class="description"><?php esc_html_e('Maximum height of uploaded images (px). Leave empty for no limit.', 'wp-allstars'); ?></p>
|
||||
</div>
|
||||
|
||||
<div class="wpa-setting-row">
|
||||
<label for="wpa_exclude_urls"><?php esc_html_e('Exclude URLs', 'wpa-superstar'); ?></label>
|
||||
<textarea id="wpa_exclude_urls"
|
||||
name="wpa_superstar_workflow_options[exclude_urls]"
|
||||
<div class="wp-setting-row">
|
||||
<label for="wp_exclude_urls"><?php esc_html_e('Exclude URLs', 'wp-allstars'); ?></label>
|
||||
<textarea id="wp_exclude_urls"
|
||||
name="wp_allstars_workflow_options[exclude_urls]"
|
||||
rows="3"
|
||||
placeholder="example.com another-domain.com"
|
||||
><?php echo esc_textarea($options['exclude_urls']); ?></textarea>
|
||||
<p class="description"><?php esc_html_e('Enter domains to exclude (one per line). Images from these domains will not be imported.', 'wpa-superstar'); ?></p>
|
||||
<p class="description"><?php esc_html_e('Enter domains to exclude (one per line). Images from these domains will not be imported.', 'wp-allstars'); ?></p>
|
||||
</div>
|
||||
|
||||
<div class="wpa-setting-row">
|
||||
<label for="wpa_image_name"><?php esc_html_e('Image Name Pattern', 'wpa-superstar'); ?></label>
|
||||
<div class="wp-setting-row">
|
||||
<label for="wp_image_name"><?php esc_html_e('Image Name Pattern', 'wp-allstars'); ?></label>
|
||||
<input type="text"
|
||||
id="wpa_image_name"
|
||||
name="wpa_superstar_workflow_options[image_name_pattern]"
|
||||
id="wp_image_name"
|
||||
name="wp_allstars_workflow_options[image_name_pattern]"
|
||||
value="<?php echo esc_attr($options['image_name_pattern']); ?>"
|
||||
/>
|
||||
<p class="description">
|
||||
<?php esc_html_e('Available patterns:', 'wpa-superstar'); ?> %filename%, %post_id%, %postname%, %timestamp%, %date%, %year%, %month%, %day%
|
||||
<?php esc_html_e('Available patterns:', 'wp-allstars'); ?> %filename%, %post_id%, %postname%, %timestamp%, %date%, %year%, %month%, %day%
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="wpa-setting-row">
|
||||
<label for="wpa_image_alt"><?php esc_html_e('Image Alt Pattern', 'wpa-superstar'); ?></label>
|
||||
<div class="wp-setting-row">
|
||||
<label for="wp_image_alt"><?php esc_html_e('Image Alt Pattern', 'wp-allstars'); ?></label>
|
||||
<input type="text"
|
||||
id="wpa_image_alt"
|
||||
name="wpa_superstar_workflow_options[image_alt_pattern]"
|
||||
id="wp_image_alt"
|
||||
name="wp_allstars_workflow_options[image_alt_pattern]"
|
||||
value="<?php echo esc_attr($options['image_alt_pattern']); ?>"
|
||||
/>
|
||||
<p class="description">
|
||||
<?php esc_html_e('Available patterns:', 'wpa-superstar'); ?> %filename%, %post_title%, %post_id%, %postname%, %timestamp%
|
||||
<?php esc_html_e('Available patterns:', 'wp-allstars'); ?> %filename%, %post_title%, %post_id%, %postname%, %timestamp%
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@ -602,10 +604,10 @@ function wpa_superstar_settings_page() {
|
||||
|
||||
<script>
|
||||
jQuery(document).ready(function($) {
|
||||
$('.wpa-expand-settings').on('click', function(e) {
|
||||
$('.wp-expand-settings').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
var $button = $(this);
|
||||
var $settings = $button.closest('.wpa-superstar-toggle').find('.wpa-toggle-settings');
|
||||
var $settings = $button.closest('.wp-allstars-toggle').find('.wp-toggle-settings');
|
||||
var isExpanded = $button.attr('aria-expanded') === 'true';
|
||||
|
||||
$button.attr('aria-expanded', !isExpanded);
|
||||
@ -642,7 +644,7 @@ function wpa_superstar_settings_page() {
|
||||
currentRequest = $.ajax({
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
action: 'wpa_get_theme',
|
||||
action: 'wp_allstars_get_theme',
|
||||
_ajax_nonce: '<?php echo wp_create_nonce("updates"); ?>'
|
||||
},
|
||||
beforeSend: function() {
|
||||
@ -715,7 +717,7 @@ function wpa_superstar_settings_page() {
|
||||
url: ajaxurl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'wpa_activate_theme',
|
||||
action: 'wp_allstars_activate_theme',
|
||||
theme: slug,
|
||||
_ajax_nonce: '<?php echo wp_create_nonce("updates"); ?>'
|
||||
},
|
||||
@ -763,21 +765,21 @@ function wpa_superstar_settings_page() {
|
||||
|
||||
<?php elseif ($active_tab == 'recommended'): ?>
|
||||
<div class="wpa-plugin-filters">
|
||||
<a href="?page=wpa-superstar&tab=recommended&category=minimal"
|
||||
<a href="?page=wp-allstars&tab=recommended&category=minimal"
|
||||
class="button <?php echo $active_category == 'minimal' ? 'button-primary' : ''; ?>">
|
||||
<?php esc_html_e('Minimal', 'wpa-superstar'); ?>
|
||||
<?php esc_html_e('Minimal', 'wp-allstars'); ?>
|
||||
</a>
|
||||
<a href="?page=wpa-superstar&tab=recommended&category=advanced"
|
||||
<a href="?page=wp-allstars&tab=recommended&category=advanced"
|
||||
class="button <?php echo $active_category == 'advanced' ? 'button-primary' : ''; ?>">
|
||||
<?php esc_html_e('Advanced', 'wpa-superstar'); ?>
|
||||
<?php esc_html_e('Advanced', 'wp-allstars'); ?>
|
||||
</a>
|
||||
<a href="?page=wpa-superstar&tab=recommended&category=ecommerce"
|
||||
<a href="?page=wp-allstars&tab=recommended&category=ecommerce"
|
||||
class="button <?php echo $active_category == 'ecommerce' ? 'button-primary' : ''; ?>">
|
||||
<?php esc_html_e('Ecommerce', 'wpa-superstar'); ?>
|
||||
<?php esc_html_e('Ecommerce', 'wp-allstars'); ?>
|
||||
</a>
|
||||
<a href="?page=wpa-superstar&tab=recommended&category=lms"
|
||||
<a href="?page=wp-allstars&tab=recommended&category=lms"
|
||||
class="button <?php echo $active_category == 'lms' ? 'button-primary' : ''; ?>">
|
||||
<?php esc_html_e('LMS', 'wpa-superstar'); ?>
|
||||
<?php esc_html_e('LMS', 'wp-allstars'); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@ -807,7 +809,7 @@ function wpa_superstar_settings_page() {
|
||||
currentRequest = $.ajax({
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
action: 'wpa_get_plugins',
|
||||
action: 'wp_allstars_get_plugins',
|
||||
category: category || 'minimal',
|
||||
_ajax_nonce: '<?php echo wp_create_nonce("updates"); ?>'
|
||||
},
|
||||
@ -872,58 +874,58 @@ function wpa_superstar_settings_page() {
|
||||
</script>
|
||||
|
||||
<?php elseif ($active_tab == 'general'): ?>
|
||||
<div class="wpa-superstar-toggle">
|
||||
<label for="wpa_superstar_lazy_load">
|
||||
<div class="wpa-toggle-switch">
|
||||
<div class="wp-allstars-toggle">
|
||||
<label for="wp_allstars_lazy_load">
|
||||
<div class="wp-toggle-switch">
|
||||
<input type="checkbox"
|
||||
id="wpa_superstar_lazy_load"
|
||||
name="wpa_superstar_lazy_load"
|
||||
id="wp_allstars_lazy_load"
|
||||
name="wp_allstars_lazy_load"
|
||||
value="1"
|
||||
<?php checked(get_option('wpa_superstar_lazy_load', 1)); ?>
|
||||
<?php checked(get_option('wp_allstars_lazy_load', 1)); ?>
|
||||
/>
|
||||
<span class="wpa-toggle-slider"></span>
|
||||
<span class="wp-toggle-slider"></span>
|
||||
</div>
|
||||
<?php esc_html_e('Enable lazy loading for images', 'wpa-superstar'); ?>
|
||||
<?php esc_html_e('Enable lazy loading for images', 'wp-allstars'); ?>
|
||||
</label>
|
||||
<p class="description">
|
||||
<?php esc_html_e('Improves page load time by loading images only when they enter the viewport.', 'wpa-superstar'); ?>
|
||||
<?php esc_html_e('Improves page load time by loading images only when they enter the viewport.', 'wp-allstars'); ?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php elseif ($active_tab == 'advanced'): ?>
|
||||
<div class="wpa-superstar-toggle">
|
||||
<label for="wpa_superstar_minify_css">
|
||||
<div class="wpa-toggle-switch">
|
||||
<div class="wp-allstars-toggle">
|
||||
<label for="wp_allstars_minify_css">
|
||||
<div class="wp-toggle-switch">
|
||||
<input type="checkbox"
|
||||
id="wpa_superstar_minify_css"
|
||||
name="wpa_superstar_minify_css"
|
||||
id="wp_allstars_minify_css"
|
||||
name="wp_allstars_minify_css"
|
||||
value="1"
|
||||
<?php checked(get_option('wpa_superstar_minify_css', 0)); ?>
|
||||
<?php checked(get_option('wp_allstars_minify_css', 0)); ?>
|
||||
/>
|
||||
<span class="wpa-toggle-slider"></span>
|
||||
<span class="wp-toggle-slider"></span>
|
||||
</div>
|
||||
<?php esc_html_e('Enable CSS minification', 'wpa-superstar'); ?>
|
||||
<?php esc_html_e('Enable CSS minification', 'wp-allstars'); ?>
|
||||
</label>
|
||||
<p class="description">
|
||||
<?php esc_html_e('Minifies CSS files to reduce file size and improve load times.', 'wpa-superstar'); ?>
|
||||
<?php esc_html_e('Minifies CSS files to reduce file size and improve load times.', 'wp-allstars'); ?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="wpa-superstar-toggle">
|
||||
<label for="wpa_superstar_minify_js">
|
||||
<div class="wpa-toggle-switch">
|
||||
<div class="wp-allstars-toggle">
|
||||
<label for="wp_allstars_minify_js">
|
||||
<div class="wp-toggle-switch">
|
||||
<input type="checkbox"
|
||||
id="wpa_superstar_minify_js"
|
||||
name="wpa_superstar_minify_js"
|
||||
id="wp_allstars_minify_js"
|
||||
name="wp_allstars_minify_js"
|
||||
value="1"
|
||||
<?php checked(get_option('wpa_superstar_minify_js', 0)); ?>
|
||||
<?php checked(get_option('wp_allstars_minify_js', 0)); ?>
|
||||
/>
|
||||
<span class="wpa-toggle-slider"></span>
|
||||
<span class="wp-toggle-slider"></span>
|
||||
</div>
|
||||
<?php esc_html_e('Enable JS minification', 'wpa-superstar'); ?>
|
||||
<?php esc_html_e('Enable JS minification', 'wp-allstars'); ?>
|
||||
</label>
|
||||
<p class="description">
|
||||
<?php esc_html_e('Minifies JavaScript files to reduce file size and improve load times.', 'wpa-superstar'); ?>
|
||||
<?php esc_html_e('Minifies JavaScript files to reduce file size and improve load times.', 'wp-allstars'); ?>
|
||||
</p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
106
css-minifier.php
106
css-minifier.php
@ -1,106 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* CSS Minifier Function
|
||||
*
|
||||
* A standalone PHP function to minify CSS content by:
|
||||
* - Removing comments
|
||||
* - Removing whitespace and line breaks
|
||||
* - Removing unnecessary semicolons
|
||||
* - Optimizing colors
|
||||
* - Shortening zero values
|
||||
*
|
||||
* @author WPA Superstar Plugin
|
||||
* @version 1.0.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Minifies CSS content
|
||||
*
|
||||
* @param string $css The CSS content to minify
|
||||
* @return string The minified CSS content
|
||||
*/
|
||||
function minify_css($css) {
|
||||
if (empty($css)) {
|
||||
return $css;
|
||||
}
|
||||
|
||||
try {
|
||||
// Remove comments
|
||||
$css = preg_replace('/\/\*[\s\S]*?\*\//', '', $css);
|
||||
|
||||
// Remove whitespace around key characters
|
||||
$css = preg_replace('/\s*([{}:;,])\s*/', '$1', $css);
|
||||
|
||||
// Remove newlines, tabs, and extra spaces
|
||||
$css = preg_replace('/\s+/', ' ', $css);
|
||||
|
||||
// Remove unnecessary semicolons
|
||||
$css = str_replace(';}', '}', $css);
|
||||
|
||||
// Convert rgb to hex where shorter
|
||||
$css = preg_replace_callback(
|
||||
'/rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)/i',
|
||||
function($matches) {
|
||||
$r = intval($matches[1]);
|
||||
$g = intval($matches[2]);
|
||||
$b = intval($matches[3]);
|
||||
|
||||
// Only convert if the hex representation would be shorter
|
||||
if ($r < 256 && $g < 256 && $b < 256) {
|
||||
$hex = sprintf("#%02x%02x%02x", $r, $g, $b);
|
||||
// Check if it can be shortened to #XXX format
|
||||
if (preg_match('/#([0-9a-f])\1([0-9a-f])\2([0-9a-f])\3/i', $hex)) {
|
||||
$hex = preg_replace('/#([0-9a-f])\1([0-9a-f])\2([0-9a-f])\3/i', '#$1$2$3', $hex);
|
||||
}
|
||||
return $hex;
|
||||
}
|
||||
return $matches[0];
|
||||
},
|
||||
$css
|
||||
);
|
||||
|
||||
// Optimize zero values (remove units)
|
||||
$css = preg_replace('/([:\s])0(?:px|pt|em|rem|%|in|cm|mm|pc|ex|vw|vh|vmin|vmax)/', '$10', $css);
|
||||
|
||||
// Shorten multiple zeros
|
||||
$css = preg_replace('/\b0 0 0 0\b/', '0', $css);
|
||||
$css = preg_replace('/\b0 0 0\b/', '0', $css);
|
||||
$css = preg_replace('/\b0 0\b/', '0', $css);
|
||||
|
||||
// Shorten colors where possible (e.g., #ffffff to #fff)
|
||||
$css = preg_replace('/#([0-9a-f])\1([0-9a-f])\2([0-9a-f])\3/i', '#$1$2$3', $css);
|
||||
|
||||
} catch (Exception $e) {
|
||||
// If any error occurs, return original CSS
|
||||
return $css;
|
||||
}
|
||||
|
||||
return trim($css);
|
||||
}
|
||||
|
||||
// Example usage
|
||||
// -----------------
|
||||
// Input CSS:
|
||||
// .example {
|
||||
// color: #ffffff;
|
||||
// margin: 0px 0px 0px 0px;
|
||||
// padding: 20px;
|
||||
// background-color: rgb(51, 51, 51);
|
||||
// }
|
||||
//
|
||||
// Output (minified):
|
||||
// .example{color:#fff;margin:0;padding:20px;background-color:#333}
|
||||
|
||||
// Simple test case
|
||||
if (basename(__FILE__) == basename($_SERVER['SCRIPT_FILENAME'])) {
|
||||
$test_css = '
|
||||
.example {
|
||||
color: #ffffff;
|
||||
margin: 0px 0px 0px 0px;
|
||||
padding: 20px;
|
||||
background-color: rgb(51, 51, 51);
|
||||
}';
|
||||
|
||||
echo "Original:\n" . $test_css . "\n\n";
|
||||
echo "Minified:\n" . minify_css($test_css);
|
||||
}
|
@ -2,16 +2,16 @@
|
||||
/**
|
||||
* Auto Upload Images functionality
|
||||
*
|
||||
* @package WPA_Superstar
|
||||
* @package WP_Allstars
|
||||
*/
|
||||
|
||||
class WPA_Superstar_Auto_Upload {
|
||||
class WP_Allstars_Auto_Upload {
|
||||
/**
|
||||
* Initialize the class
|
||||
*/
|
||||
public function __construct() {
|
||||
add_filter('content_save_pre', array($this, 'process_content'), 10, 1);
|
||||
add_action('wpa_superstar_image_upload_error', array($this, 'log_error'), 10, 2);
|
||||
add_action('wp_allstars_image_upload_error', array($this, 'log_error'), 10, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -22,7 +22,7 @@ class WPA_Superstar_Auto_Upload {
|
||||
*/
|
||||
public function process_content($content) {
|
||||
// Check if auto upload is enabled
|
||||
$options = get_option('wpa_superstar_workflow_options', array('auto_upload_images' => false));
|
||||
$options = get_option('wp_allstars_workflow_options', array('auto_upload_images' => false));
|
||||
if (!$options['auto_upload_images']) {
|
||||
return $content;
|
||||
}
|
||||
@ -57,7 +57,7 @@ class WPA_Superstar_Auto_Upload {
|
||||
return str_replace($url, $local_url, $matches[0]);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
do_action('wpa_superstar_image_upload_error', $url, $e->getMessage());
|
||||
do_action('wp_allstars_image_upload_error', $url, $e->getMessage());
|
||||
}
|
||||
|
||||
return $matches[0];
|
||||
@ -118,7 +118,7 @@ class WPA_Superstar_Auto_Upload {
|
||||
*/
|
||||
public function log_error($url, $error) {
|
||||
error_log(sprintf(
|
||||
'[WPA Superstar] Auto Upload Images Error - URL: %s, Error: %s',
|
||||
'[WP ALLSTARS] Auto Upload Images Error - URL: %s, Error: %s',
|
||||
$url,
|
||||
$error
|
||||
));
|
@ -1,233 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Speed optimization functions for WPA Superstar plugin
|
||||
*
|
||||
* @package WPA_Superstar
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
// If this file is called directly, abort
|
||||
if ( ! defined( 'ABSPATH' ) && ! defined( 'WPINC' ) ) {
|
||||
// Still allow the file to be loaded for IDE analysis
|
||||
defined( 'WPINC' ) || define( 'WPINC', 'wp-includes' );
|
||||
defined( 'ABSPATH' ) || define( 'ABSPATH', dirname( dirname( __FILE__ ) ) . '/' );
|
||||
defined( 'WP_CONTENT_DIR' ) || define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Logging function for the plugin
|
||||
*
|
||||
* @param string $message The message to log
|
||||
* @return void
|
||||
*/
|
||||
function wpa_superstar_log( $message ) {
|
||||
// Safe check for WordPress constants
|
||||
if ( defined( 'WP_CONTENT_DIR' ) ) {
|
||||
$log_file = WP_CONTENT_DIR . '/wpa-superstar.log';
|
||||
$time = function_exists( 'current_time' ) ? current_time( 'mysql' ) : date( 'Y-m-d H:i:s' );
|
||||
@file_put_contents( $log_file, "[$time] $message\n", FILE_APPEND );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add lazy loading attribute to images to improve page load speed
|
||||
*
|
||||
* @param string $content The content to process
|
||||
* @return string The processed content with lazy loading
|
||||
*/
|
||||
function wpa_superstar_lazy_load_images( $content ) {
|
||||
// Early return if admin or option disabled
|
||||
if ( ! $content ||
|
||||
( function_exists( 'is_admin' ) && is_admin() ) ||
|
||||
( function_exists( 'get_option' ) && ! get_option( 'wpa_superstar_lazy_load', 1 ) )
|
||||
) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
try {
|
||||
$content = preg_replace(
|
||||
'/(<img[^>]+)\/?>/i',
|
||||
'$1 loading="lazy" />',
|
||||
$content
|
||||
);
|
||||
} catch ( Exception $e ) {
|
||||
wpa_superstar_log( "Lazy load error: " . $e->getMessage() );
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
// Register the lazy load filters if add_filter exists
|
||||
if ( function_exists( 'add_filter' ) ) {
|
||||
add_filter( 'the_content', 'wpa_superstar_lazy_load_images' );
|
||||
add_filter( 'wp_get_attachment_image', 'wpa_superstar_lazy_load_images' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Advanced CSS minification function
|
||||
*
|
||||
* This function takes CSS content and returns a minified version by:
|
||||
* - Removing comments
|
||||
* - Removing whitespace
|
||||
* - Removing unnecessary semicolons
|
||||
* - Shortening color values
|
||||
* - Optimizing zero values
|
||||
*
|
||||
* @param string $css The CSS content to minify
|
||||
* @return string The minified CSS content
|
||||
*/
|
||||
function wpa_superstar_minify_css_content( $css ) {
|
||||
if ( empty( $css ) ) {
|
||||
return $css;
|
||||
}
|
||||
|
||||
try {
|
||||
// Remove comments
|
||||
$css = preg_replace( '/\/\*[\s\S]*?\*\//', '', $css );
|
||||
|
||||
// Remove whitespace around key characters
|
||||
$css = preg_replace( '/\s*([{}:;,])\s*/', '$1', $css );
|
||||
|
||||
// Remove trailing whitespace
|
||||
$css = preg_replace( '/\s+/', ' ', $css );
|
||||
|
||||
// Remove unnecessary semicolons
|
||||
$css = str_replace( ';}', '}', $css );
|
||||
|
||||
// Convert rgb to hex where shorter
|
||||
$css = preg_replace_callback( '/rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)/i', function( $matches ) {
|
||||
$r = intval( $matches[1] );
|
||||
$g = intval( $matches[2] );
|
||||
$b = intval( $matches[3] );
|
||||
|
||||
// Only convert if the hex representation would be shorter
|
||||
if ( $r < 256 && $g < 256 && $b < 256 ) {
|
||||
$hex = sprintf( "#%02x%02x%02x", $r, $g, $b );
|
||||
// Check if it can be shortened to #XXX format
|
||||
if ( preg_match( '/#([0-9a-f])\1([0-9a-f])\2([0-9a-f])\3/i', $hex ) ) {
|
||||
$hex = preg_replace( '/#([0-9a-f])\1([0-9a-f])\2([0-9a-f])\3/i', '#$1$2$3', $hex );
|
||||
}
|
||||
return $hex;
|
||||
}
|
||||
return $matches[0];
|
||||
}, $css );
|
||||
|
||||
// Optimize zero values
|
||||
$css = preg_replace( '/([:\s])0(?:px|pt|em|rem|%|in|cm|mm|pc|ex|vw|vh|vmin|vmax)/', '$10', $css );
|
||||
|
||||
// Shorten multiple zeros
|
||||
$css = preg_replace( '/\b0 0 0 0\b/', '0', $css );
|
||||
$css = preg_replace( '/\b0 0 0\b/', '0', $css );
|
||||
$css = preg_replace( '/\b0 0\b/', '0', $css );
|
||||
|
||||
// Shorten colors where possible (e.g., #ffffff to #fff)
|
||||
$css = preg_replace( '/#([0-9a-f])\1([0-9a-f])\2([0-9a-f])\3/i', '#$1$2$3', $css );
|
||||
|
||||
} catch ( Exception $e ) {
|
||||
wpa_superstar_log( "CSS content minify error: " . $e->getMessage() );
|
||||
return $css; // Return original on error
|
||||
}
|
||||
|
||||
return trim( $css );
|
||||
}
|
||||
|
||||
/**
|
||||
* Minify CSS in HTML content to reduce file size
|
||||
*
|
||||
* @param string $html The HTML content to process
|
||||
* @return string The processed HTML with minified CSS
|
||||
*/
|
||||
function wpa_superstar_minify_css( $html ) {
|
||||
// Early return if admin or option disabled
|
||||
if ( ( function_exists( 'is_admin' ) && is_admin() ) ||
|
||||
( function_exists( 'get_option' ) && ! get_option( 'wpa_superstar_minify_css', 0 ) )
|
||||
) {
|
||||
return $html;
|
||||
}
|
||||
|
||||
try {
|
||||
$html = preg_replace(
|
||||
array( '/\s+/', '/\/\*.*?\*\//s', '/;}/' ),
|
||||
array( ' ', '', '}' ),
|
||||
$html
|
||||
);
|
||||
} catch ( Exception $e ) {
|
||||
wpa_superstar_log( "CSS minify error: " . $e->getMessage() );
|
||||
}
|
||||
|
||||
return trim( $html );
|
||||
}
|
||||
|
||||
// Register the CSS minify filter if add_filter exists
|
||||
if ( function_exists( 'add_filter' ) ) {
|
||||
add_filter( 'style_loader_tag', 'wpa_superstar_minify_css' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Minify JavaScript in HTML content to reduce file size
|
||||
*
|
||||
* @param string $html The HTML content to process
|
||||
* @return string The processed HTML with minified JavaScript
|
||||
*/
|
||||
function wpa_superstar_minify_js( $html ) {
|
||||
// Early return if admin or option disabled
|
||||
if ( ( function_exists( 'is_admin' ) && is_admin() ) ||
|
||||
( function_exists( 'get_option' ) && ! get_option( 'wpa_superstar_minify_js', 0 ) )
|
||||
) {
|
||||
return $html;
|
||||
}
|
||||
|
||||
try {
|
||||
$html = preg_replace(
|
||||
array( '/\s+/', '/\/\*.*?\*\//s', '//.*?\n/' ),
|
||||
array( ' ', '', '' ),
|
||||
$html
|
||||
);
|
||||
} catch ( Exception $e ) {
|
||||
wpa_superstar_log( "JS minify error: " . $e->getMessage() );
|
||||
}
|
||||
|
||||
return trim( $html );
|
||||
}
|
||||
|
||||
// Register the JS minify filter if add_filter exists
|
||||
if ( function_exists( 'add_filter' ) ) {
|
||||
add_filter( 'script_loader_tag', 'wpa_superstar_minify_js' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Minify inline CSS in HTML content
|
||||
*
|
||||
* @param string $html The HTML content containing style tags
|
||||
* @return string The HTML with minified inline CSS
|
||||
*/
|
||||
function wpa_superstar_minify_inline_css( $html ) {
|
||||
// Early return if admin or option disabled
|
||||
if ( ( function_exists( 'is_admin' ) && is_admin() ) ||
|
||||
( function_exists( 'get_option' ) && ! get_option( 'wpa_superstar_minify_inline_css', 0 ) )
|
||||
) {
|
||||
return $html;
|
||||
}
|
||||
|
||||
try {
|
||||
// Find and minify all inline style blocks
|
||||
$html = preg_replace_callback(
|
||||
'/<style[^>]*>(.*?)<\/style>/si',
|
||||
function( $matches ) {
|
||||
$minified_css = wpa_superstar_minify_css_content( $matches[1] );
|
||||
return '<style>' . $minified_css . '</style>';
|
||||
},
|
||||
$html
|
||||
);
|
||||
} catch ( Exception $e ) {
|
||||
wpa_superstar_log( "Inline CSS minify error: " . $e->getMessage() );
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
// Apply the inline CSS minify filters if add_filter exists
|
||||
if ( function_exists( 'add_filter' ) ) {
|
||||
add_filter( 'wp_head', 'wpa_superstar_minify_inline_css', 999 );
|
||||
add_filter( 'wp_footer', 'wpa_superstar_minify_inline_css', 999 );
|
||||
}
|
77
wp-allstars-plugin.php
Normal file
77
wp-allstars-plugin.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: WP ALLSTARS Plugin
|
||||
* Plugin URI: https://www.wpallstars.com
|
||||
* Description: WP ALLSTARS Plugin for WordPress. Speed Matters.
|
||||
* Version: 1.0.0
|
||||
* Author: WP ALLSTARS
|
||||
* Author URI: https://www.wpallstars.com
|
||||
* License: GPL-2.0+
|
||||
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
||||
* Text Domain: wp-allstars
|
||||
* Domain Path: /languages
|
||||
* Requires at least: 5.0
|
||||
* Requires PHP: 7.2
|
||||
*/
|
||||
|
||||
// If this file is called directly, abort.
|
||||
if ( ! defined( 'WPINC' ) ) {
|
||||
die;
|
||||
}
|
||||
|
||||
// Define plugin version
|
||||
define( 'WP_ALLSTARS_VERSION', '1.0.0' );
|
||||
|
||||
// Activation hook
|
||||
function wp_allstars_activate() {
|
||||
// Add activation logic later if needed
|
||||
}
|
||||
register_activation_hook( __FILE__, 'wp_allstars_activate' );
|
||||
|
||||
// Load core functionality
|
||||
require_once plugin_dir_path(__FILE__) . 'includes/class-wp-allstars-auto-upload.php';
|
||||
|
||||
// Load admin UI
|
||||
if ( is_admin() ) {
|
||||
require_once plugin_dir_path( __FILE__ ) . 'admin/settings.php';
|
||||
}
|
||||
|
||||
// Localize script for AJAX
|
||||
function wp_allstars_localize_script() {
|
||||
wp_localize_script( 'wp-allstars-admin', 'wpAllstars', [
|
||||
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
||||
'nonce' => wp_create_nonce( 'wp-allstars-nonce' )
|
||||
] );
|
||||
}
|
||||
add_action( 'admin_enqueue_scripts', 'wp_allstars_localize_script' );
|
||||
|
||||
// Admin assets
|
||||
function wp_allstars_admin_assets() {
|
||||
// Enqueue styles
|
||||
wp_enqueue_style(
|
||||
'wp-allstars-admin',
|
||||
plugins_url( 'admin/css/wp-allstars-admin.css', __FILE__ ),
|
||||
array(),
|
||||
WP_ALLSTARS_VERSION
|
||||
);
|
||||
|
||||
// Enqueue script
|
||||
wp_enqueue_script(
|
||||
'wp-allstars-admin',
|
||||
plugins_url( 'admin/js/wp-allstars-admin.js', __FILE__ ),
|
||||
array('jquery'),
|
||||
WP_ALLSTARS_VERSION,
|
||||
true
|
||||
);
|
||||
|
||||
// Localize script for AJAX
|
||||
$ajax_data = array(
|
||||
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
||||
'nonce' => wp_create_nonce( 'wp-allstars-nonce' )
|
||||
);
|
||||
wp_localize_script( 'wp-allstars-admin', 'wpAllstars', $ajax_data );
|
||||
}
|
||||
add_action( 'admin_enqueue_scripts', 'wp_allstars_admin_assets' );
|
||||
|
||||
// Initialize classes
|
||||
$wp_allstars_auto_upload = new WP_Allstars_Auto_Upload();
|
@ -1,93 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: WP ALLSTARS Superstar Plugin
|
||||
* Plugin URI: https://www.wpallstars.com/superstar-plugin
|
||||
* Description: WP ALLSTARS Superstar Plugin for WordPress. Speed Matters.
|
||||
* Version: 1.0.0
|
||||
* Author: WP ALLSTARS
|
||||
* Author URI: https://www.wpallstars.com
|
||||
* License: GPL-2.0+
|
||||
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
||||
* Text Domain: wpa-superstar
|
||||
* Domain Path: /languages
|
||||
* Requires at least: 5.0
|
||||
* Requires PHP: 7.2
|
||||
*/
|
||||
|
||||
// If this file is called directly, abort.
|
||||
if ( ! defined( 'WPINC' ) ) {
|
||||
die;
|
||||
}
|
||||
|
||||
// Define plugin version
|
||||
define( 'WPA_SUPERSTAR_VERSION', '1.0.0' );
|
||||
|
||||
// Activation hook
|
||||
function wpa_superstar_activate() {
|
||||
// Add activation logic later if needed
|
||||
}
|
||||
register_activation_hook( __FILE__, 'wpa_superstar_activate' );
|
||||
|
||||
// Load core functionality
|
||||
require_once plugin_dir_path( __FILE__ ) . 'includes/speed-functions.php';
|
||||
require_once plugin_dir_path(__FILE__) . 'includes/class-wpa-superstar-auto-upload.php';
|
||||
|
||||
// Load admin UI
|
||||
if ( is_admin() ) {
|
||||
require_once plugin_dir_path( __FILE__ ) . 'admin/settings.php';
|
||||
}
|
||||
|
||||
// Localize script for AJAX
|
||||
function wpa_superstar_localize_script() {
|
||||
wp_localize_script( 'wpa-superstar-admin', 'wpaSuperstar', [
|
||||
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
||||
'nonce' => wp_create_nonce( 'wpa-superstar-nonce' )
|
||||
] );
|
||||
}
|
||||
add_action( 'admin_enqueue_scripts', 'wpa_superstar_localize_script' );
|
||||
|
||||
// Admin assets
|
||||
function wpa_superstar_admin_assets() {
|
||||
// Enqueue styles
|
||||
wp_enqueue_style(
|
||||
'wpa-superstar-admin',
|
||||
plugins_url( 'admin/css/wpa-superstar-admin.css', __FILE__ ),
|
||||
array(),
|
||||
WPA_SUPERSTAR_VERSION
|
||||
);
|
||||
|
||||
// Enqueue script
|
||||
wp_enqueue_script(
|
||||
'wpa-superstar-admin',
|
||||
plugins_url( 'admin/js/wpa-superstar-admin.js', __FILE__ ),
|
||||
array('jquery'),
|
||||
WPA_SUPERSTAR_VERSION,
|
||||
true
|
||||
);
|
||||
|
||||
// Localize script for AJAX
|
||||
$ajax_data = array(
|
||||
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
||||
'nonce' => wp_create_nonce( 'wpa-superstar-nonce' )
|
||||
);
|
||||
wp_localize_script( 'wpa-superstar-admin', 'wpaSuperstar', $ajax_data );
|
||||
}
|
||||
add_action( 'admin_enqueue_scripts', 'wpa_superstar_admin_assets' );
|
||||
|
||||
/**
|
||||
* Register and enqueue lazy loading assets
|
||||
*/
|
||||
function wpa_superstar_lazy_load_assets() {
|
||||
// Enqueue styles for lazy loading
|
||||
wp_enqueue_style(
|
||||
'wpa-superstar-lazy-load',
|
||||
plugins_url( 'public/css/wpa-superstar-lazy-load.css', __FILE__ ),
|
||||
[],
|
||||
WPA_SUPERSTAR_VERSION
|
||||
);
|
||||
}
|
||||
// Hook the function to appropriate WordPress action
|
||||
add_action( 'wp_enqueue_scripts', 'wpa_superstar_lazy_load_assets' );
|
||||
|
||||
// Initialize classes
|
||||
$wpa_superstar_auto_upload = new WPA_Superstar_Auto_Upload();
|
Reference in New Issue
Block a user