Fix auto-upload settings panel, pro plugin buttons, and free plugins loading
This commit is contained in:
@ -117,4 +117,55 @@ jQuery(document).ready(function($) {
|
|||||||
$('form').on('submit', function() {
|
$('form').on('submit', function() {
|
||||||
showNotification('Saved');
|
showNotification('Saved');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Load plugins on page load
|
||||||
|
if ($('#wpa-plugin-list').length) {
|
||||||
|
var urlParams = new URLSearchParams(window.location.search);
|
||||||
|
var currentCategory = urlParams.get('category') || 'minimal';
|
||||||
|
loadPlugins(currentCategory);
|
||||||
|
|
||||||
|
// Handle category filter clicks
|
||||||
|
$('.wpa-plugin-filters a').on('click', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var category = new URLSearchParams($(this).attr('href').split('?')[1]).get('category');
|
||||||
|
loadPlugins(category);
|
||||||
|
|
||||||
|
// Update URL without page reload
|
||||||
|
var newUrl = $(this).attr('href');
|
||||||
|
history.pushState({}, '', newUrl);
|
||||||
|
|
||||||
|
// Update active state
|
||||||
|
$('.wpa-plugin-filters a').removeClass('button-primary');
|
||||||
|
$(this).addClass('button-primary');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to load plugins
|
||||||
|
function loadPlugins(category) {
|
||||||
|
// Show loading overlay
|
||||||
|
$('.wpa-loading-overlay').fadeIn();
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: ajaxurl,
|
||||||
|
data: {
|
||||||
|
action: 'wp_allstars_get_plugins',
|
||||||
|
category: category || 'minimal',
|
||||||
|
_ajax_nonce: wpAllstarsData.nonce
|
||||||
|
},
|
||||||
|
success: function(response) {
|
||||||
|
if (response.success) {
|
||||||
|
$('#wpa-plugin-list').html(response.data);
|
||||||
|
} else {
|
||||||
|
console.error('Server returned error:', response);
|
||||||
|
$('#wpa-plugin-list').html('<div class="notice notice-error"><p>Failed to load plugins: ' + (response.data || 'Unknown error') + '</p></div>');
|
||||||
|
}
|
||||||
|
$('.wpa-loading-overlay').fadeOut();
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
console.error('Failed to load plugins:', {xhr: xhr, status: status, error: error});
|
||||||
|
$('#wpa-plugin-list').html('<div class="notice notice-error"><p>Failed to load plugins. Please try again. Error: ' + error + '</p></div>');
|
||||||
|
$('.wpa-loading-overlay').fadeOut();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
@ -685,11 +685,55 @@ function wp_allstars_settings_page() {
|
|||||||
<label for="wp_max_width"><?php esc_html_e('Max Width', 'wp-allstars'); ?></label>
|
<label for="wp_max_width"><?php esc_html_e('Max Width', 'wp-allstars'); ?></label>
|
||||||
<input type="number"
|
<input type="number"
|
||||||
id="wp_max_width"
|
id="wp_max_width"
|
||||||
name="wp_allstars_max_width"
|
name="wp_max_width"
|
||||||
value="<?php echo esc_attr(get_option('wp_allstars_max_width', '1920')); ?>"
|
value="<?php echo esc_attr(get_option('wp_allstars_max_width', 1920)); ?>"
|
||||||
|
min="0"
|
||||||
|
/>
|
||||||
|
<p class="description"><?php esc_html_e('Maximum width of uploaded images (px). Leave empty for no limit.', 'wp-allstars'); ?></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="wp-allstars-setting-row">
|
||||||
|
<label for="wp_max_height"><?php esc_html_e('Max Height', 'wp-allstars'); ?></label>
|
||||||
|
<input type="number"
|
||||||
|
id="wp_max_height"
|
||||||
|
name="wp_max_height"
|
||||||
|
value="<?php echo esc_attr(get_option('wp_allstars_max_height', 1080)); ?>"
|
||||||
|
min="0"
|
||||||
|
/>
|
||||||
|
<p class="description"><?php esc_html_e('Maximum height of uploaded images (px). Leave empty for no limit.', 'wp-allstars'); ?></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="wp-allstars-setting-row">
|
||||||
|
<label for="wp_exclude_urls"><?php esc_html_e('Exclude URLs', 'wp-allstars'); ?></label>
|
||||||
|
<textarea id="wp_exclude_urls"
|
||||||
|
name="wp_exclude_urls"
|
||||||
|
rows="3"
|
||||||
|
placeholder="example.com another-domain.com"
|
||||||
|
><?php echo esc_textarea(get_option('wp_allstars_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.', 'wp-allstars'); ?></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="wp-allstars-setting-row">
|
||||||
|
<label for="wp_image_name"><?php esc_html_e('Image Name Pattern', 'wp-allstars'); ?></label>
|
||||||
|
<input type="text"
|
||||||
|
id="wp_image_name"
|
||||||
|
name="wp_image_name"
|
||||||
|
value="<?php echo esc_attr(get_option('wp_allstars_image_name_pattern', '%filename%')); ?>"
|
||||||
/>
|
/>
|
||||||
<p class="description">
|
<p class="description">
|
||||||
<?php esc_html_e('Maximum width for uploaded images. Images larger than this will be resized.', 'wp-allstars'); ?>
|
<?php esc_html_e('Available patterns:', 'wp-allstars'); ?> %filename%, %post_id%, %postname%, %timestamp%, %date%, %year%, %month%, %day%
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="wp-allstars-setting-row">
|
||||||
|
<label for="wp_image_alt"><?php esc_html_e('Image Alt Pattern', 'wp-allstars'); ?></label>
|
||||||
|
<input type="text"
|
||||||
|
id="wp_image_alt"
|
||||||
|
name="wp_image_alt"
|
||||||
|
value="<?php echo esc_attr(get_option('wp_allstars_image_alt_pattern', '%filename%')); ?>"
|
||||||
|
/>
|
||||||
|
<p class="description">
|
||||||
|
<?php esc_html_e('Available patterns:', 'wp-allstars'); ?> %filename%, %post_title%, %post_id%, %postname%, %timestamp%
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -785,6 +829,15 @@ function wp_allstars_settings_page() {
|
|||||||
<div class="wpa-pro-plugin">
|
<div class="wpa-pro-plugin">
|
||||||
<h3><?php echo esc_html($plugin['name']); ?></h3>
|
<h3><?php echo esc_html($plugin['name']); ?></h3>
|
||||||
<p><?php echo esc_html($plugin['description']); ?></p>
|
<p><?php echo esc_html($plugin['description']); ?></p>
|
||||||
|
<?php if (isset($plugin['button_group'])): ?>
|
||||||
|
<div class="button-group">
|
||||||
|
<?php foreach ($plugin['button_group'] as $button): ?>
|
||||||
|
<a href="<?php echo esc_url($button['url']); ?>" target="_blank" class="button <?php echo isset($button['primary']) && $button['primary'] ? 'button-primary' : ''; ?>">
|
||||||
|
<?php echo esc_html($button['text']); ?>
|
||||||
|
</a>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<?php else: ?>
|
||||||
<div class="button-group">
|
<div class="button-group">
|
||||||
<?php if (!empty($plugin['demo_url'])): ?>
|
<?php if (!empty($plugin['demo_url'])): ?>
|
||||||
<a href="<?php echo esc_url($plugin['demo_url']); ?>" class="button" target="_blank">
|
<a href="<?php echo esc_url($plugin['demo_url']); ?>" class="button" target="_blank">
|
||||||
@ -795,6 +848,7 @@ function wp_allstars_settings_page() {
|
|||||||
<?php esc_html_e('Learn More', 'wp-allstars'); ?>
|
<?php esc_html_e('Learn More', 'wp-allstars'); ?>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user