Fix theme installation button and remove image zoom effect
This commit is contained in:
@ -526,9 +526,7 @@ input:checked + .wp-toggle-slider:before {
|
|||||||
transition: transform 0.3s ease;
|
transition: transform 0.3s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-card:hover .theme-image img {
|
/* Removed hover zoom effect */
|
||||||
transform: scale(1.05);
|
|
||||||
}
|
|
||||||
|
|
||||||
.theme-info {
|
.theme-info {
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
|
@ -311,9 +311,19 @@ jQuery(document).ready(function($) {
|
|||||||
console.log('Installing theme via AJAX:', slug);
|
console.log('Installing theme via AJAX:', slug);
|
||||||
$button.addClass('updating-message').text('Installing...');
|
$button.addClass('updating-message').text('Installing...');
|
||||||
|
|
||||||
|
// Make sure wp.updates is available
|
||||||
|
if (typeof wp === 'undefined' || typeof wp.updates === 'undefined' || typeof wp.updates.installTheme === 'undefined') {
|
||||||
|
console.error('WordPress updates API not available');
|
||||||
|
$button.removeClass('updating-message').text('Install');
|
||||||
|
alert('WordPress updates API not available. Please try again or install the theme from the Themes page.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Use the WordPress core updates API for AJAX installation
|
// Use the WordPress core updates API for AJAX installation
|
||||||
wp.updates.installTheme({
|
wp.updates.installTheme({
|
||||||
slug: slug,
|
slug: slug,
|
||||||
|
// Make sure we pass the correct nonce
|
||||||
|
_ajax_nonce: $button.data('api-nonce') || wpAllstars.updateNonce,
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
console.log('Theme installed successfully:', response);
|
console.log('Theme installed successfully:', response);
|
||||||
$button.removeClass('updating-message').addClass('updated-message').text('Installed!');
|
$button.removeClass('updating-message').addClass('updated-message').text('Installed!');
|
||||||
@ -324,9 +334,13 @@ jQuery(document).ready(function($) {
|
|||||||
$button.remove();
|
$button.remove();
|
||||||
|
|
||||||
// Create a proper activation link
|
// Create a proper activation link
|
||||||
var activateUrl = response.activateUrl ||
|
var activateUrl = '';
|
||||||
'themes.php?action=activate&stylesheet=' + slug +
|
if (response.activateUrl) {
|
||||||
'&_wpnonce=' + wp.updates.data.activateNonce;
|
activateUrl = response.activateUrl;
|
||||||
|
} else {
|
||||||
|
var nonce = wp.updates.data.activateNonce || wpAllstars.nonce;
|
||||||
|
activateUrl = 'themes.php?action=activate&stylesheet=' + slug + '&_wpnonce=' + nonce;
|
||||||
|
}
|
||||||
|
|
||||||
var adminUrl = wpAllstars.adminUrl || ajaxurl.replace('/admin-ajax.php', '/');
|
var adminUrl = wpAllstars.adminUrl || ajaxurl.replace('/admin-ajax.php', '/');
|
||||||
var $activateButton = $('<a class="button button-primary activate-now" href="' + adminUrl + activateUrl + '">Activate</a>');
|
var $activateButton = $('<a class="button button-primary activate-now" href="' + adminUrl + activateUrl + '">Activate</a>');
|
||||||
|
@ -43,9 +43,17 @@ if (!defined('ABSPATH')) {
|
|||||||
class="button button-primary install-now"
|
class="button button-primary install-now"
|
||||||
data-slug="kadence"
|
data-slug="kadence"
|
||||||
data-name="Kadence"
|
data-name="Kadence"
|
||||||
|
data-api-nonce="<?php echo esc_attr(wp_create_nonce('updates')); ?>"
|
||||||
|
data-nonce="<?php echo esc_attr($nonce); ?>"
|
||||||
aria-label="<?php esc_attr_e('Install Kadence'); ?>">
|
aria-label="<?php esc_attr_e('Install Kadence'); ?>">
|
||||||
<?php esc_html_e('Install'); ?>
|
<?php esc_html_e('Install'); ?>
|
||||||
</button>
|
</button>
|
||||||
|
<script>
|
||||||
|
console.log('Theme installation button initialized with:', {
|
||||||
|
slug: 'kadence',
|
||||||
|
nonce: '<?php echo esc_js(wp_create_nonce("updates")); ?>'
|
||||||
|
});
|
||||||
|
</script>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<script>
|
<script>
|
||||||
jQuery(document).ready(function($) {
|
jQuery(document).ready(function($) {
|
||||||
|
@ -57,10 +57,13 @@ function wp_allstars_admin_assets() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Enqueue script
|
// Enqueue script
|
||||||
|
// Enqueue WordPress updates script for theme installation
|
||||||
|
wp_enqueue_script('updates');
|
||||||
|
|
||||||
wp_enqueue_script(
|
wp_enqueue_script(
|
||||||
'wp-allstars-admin',
|
'wp-allstars-admin',
|
||||||
plugins_url( 'admin/js/wp-allstars-admin.js', __FILE__ ),
|
plugins_url( 'admin/js/wp-allstars-admin.js', __FILE__ ),
|
||||||
array('jquery'),
|
array('jquery', 'updates'),
|
||||||
WP_ALLSTARS_VERSION,
|
WP_ALLSTARS_VERSION,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
@ -69,7 +72,8 @@ function wp_allstars_admin_assets() {
|
|||||||
$ajax_data = array(
|
$ajax_data = array(
|
||||||
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
||||||
'adminUrl' => admin_url(),
|
'adminUrl' => admin_url(),
|
||||||
'nonce' => wp_create_nonce( 'wp-allstars-nonce' )
|
'nonce' => wp_create_nonce( 'wp-allstars-nonce' ),
|
||||||
|
'updateNonce' => wp_create_nonce( 'updates' )
|
||||||
);
|
);
|
||||||
wp_localize_script( 'wp-allstars-admin', 'wpAllstars', $ajax_data );
|
wp_localize_script( 'wp-allstars-admin', 'wpAllstars', $ajax_data );
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user