Fix theme activation functionality to work with new theme panel design
This commit is contained in:
@ -293,11 +293,11 @@ jQuery(document).ready(function($) {
|
|||||||
// Initialize theme handlers
|
// Initialize theme handlers
|
||||||
function initThemeHandlers() {
|
function initThemeHandlers() {
|
||||||
// Install theme
|
// Install theme
|
||||||
$('.theme-browser .theme-actions .install-now').on('click', function(e) {
|
$('.theme-actions .install-now').on('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var $button = $(this);
|
var $button = $(this);
|
||||||
var slug = $button.data('slug');
|
var slug = $button.data('slug');
|
||||||
var $themeCard = $button.closest('.theme');
|
var $themeCard = $button.closest('.theme-card');
|
||||||
|
|
||||||
$button.addClass('updating-message').text('Installing...');
|
$button.addClass('updating-message').text('Installing...');
|
||||||
|
|
||||||
@ -317,38 +317,43 @@ jQuery(document).ready(function($) {
|
|||||||
alert(response.errorMessage);
|
alert(response.errorMessage);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Activate theme
|
// Activate theme
|
||||||
$('.theme-browser .theme-actions .activate-now').on('click', function(e) {
|
$('.theme-actions .activate-now').on('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var $button = $(this);
|
var $button = $(this);
|
||||||
var url = $button.attr('href');
|
var slug = $button.data('slug');
|
||||||
|
|
||||||
$button.addClass('updating-message').text('Activating...');
|
$button.addClass('updating-message').text('Activating...');
|
||||||
|
|
||||||
|
// Use AJAX to activate the theme
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: url,
|
url: ajaxurl,
|
||||||
dataType: 'html',
|
type: 'POST',
|
||||||
success: function() {
|
data: {
|
||||||
|
action: 'wp_allstars_activate_theme',
|
||||||
|
theme: slug,
|
||||||
|
_wpnonce: wpAllstars.nonce
|
||||||
|
},
|
||||||
|
success: function(response) {
|
||||||
|
if (response.success) {
|
||||||
$button.removeClass('updating-message').addClass('updated-message').text('Activated!');
|
$button.removeClass('updating-message').addClass('updated-message').text('Activated!');
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$('.theme-browser .theme').removeClass('active');
|
|
||||||
$button.closest('.theme').addClass('active');
|
|
||||||
$button.removeClass('activate-now updated-message')
|
$button.removeClass('activate-now updated-message')
|
||||||
.addClass('button-disabled')
|
.addClass('button-disabled')
|
||||||
.text('Active');
|
.text('Active');
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
} else {
|
||||||
|
$button.removeClass('updating-message').text('Activate');
|
||||||
|
alert(response.data || 'Failed to activate theme');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
$button.removeClass('updating-message').text('Activate');
|
$button.removeClass('updating-message').text('Activate');
|
||||||
alert('Failed to activate theme. Please try again or activate from the Themes page.');
|
alert('Failed to activate theme. Please try again or activate from the Themes page.');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
Reference in New Issue
Block a user