Add CSS minification, AJAX settings, and modern admin styling
This commit is contained in:
@ -2,11 +2,11 @@ jQuery(document).ready(function($) {
|
||||
$('.wpa-superstar-toggle input').on('change', function() {
|
||||
var option = $(this).attr('name');
|
||||
var value = $(this).is(':checked') ? 1 : 0;
|
||||
$.post(ajaxurl, {
|
||||
$.post(wpaSuperstar.ajaxurl, {
|
||||
action: 'wpa_superstar_update_option',
|
||||
option: option,
|
||||
value: value,
|
||||
nonce: '<?php echo wp_create_nonce( "wpa-superstar-nonce" ); ?>'
|
||||
nonce: wpaSuperstar.nonce
|
||||
}, function(response) {
|
||||
console.log(response);
|
||||
});
|
||||
|
@ -17,7 +17,6 @@ function wpa_superstar_lazy_load_images( $content ) {
|
||||
add_filter( 'the_content', 'wpa_superstar_lazy_load_images' );
|
||||
add_filter( 'wp_get_attachment_image', 'wpa_superstar_lazy_load_images' );
|
||||
|
||||
// After lazy load function
|
||||
function wpa_superstar_minify_css( $html ) {
|
||||
if ( is_admin() || ! get_option( 'wpa_superstar_minify_css', 0 ) ) {
|
||||
return $html;
|
||||
|
@ -36,6 +36,15 @@ 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() {
|
||||
wp_enqueue_style( 'wpa-superstar-admin', plugins_url( 'admin/css/wpa-superstar-admin.css', __FILE__ ), [], WPA_SUPERSTAR_VERSION );
|
||||
|
Reference in New Issue
Block a user