Revert to Load More button for plugin loading
This commit is contained in:
@ -46,7 +46,6 @@ function wp_allstars_get_recommended_plugins() {
|
|||||||
'advanced' => array(
|
'advanced' => array(
|
||||||
'acf-better-search',
|
'acf-better-search',
|
||||||
'admin-bar-dashboard-control',
|
'admin-bar-dashboard-control',
|
||||||
'admin-columns',
|
|
||||||
'advanced-custom-fields',
|
'advanced-custom-fields',
|
||||||
'admin-menu-editor',
|
'admin-menu-editor',
|
||||||
'ai-engine',
|
'ai-engine',
|
||||||
@ -55,6 +54,8 @@ function wp_allstars_get_recommended_plugins() {
|
|||||||
'bookmark-card',
|
'bookmark-card',
|
||||||
'browser-shots',
|
'browser-shots',
|
||||||
'bulk-actions-select-all',
|
'bulk-actions-select-all',
|
||||||
|
'bulk-edit-categories-tags',
|
||||||
|
'bulk-edit-user-profiles-in-spreadsheet',
|
||||||
'burst-statistics',
|
'burst-statistics',
|
||||||
'carbon-copy',
|
'carbon-copy',
|
||||||
'code-snippets',
|
'code-snippets',
|
||||||
@ -71,21 +72,19 @@ function wp_allstars_get_recommended_plugins() {
|
|||||||
'fluent-crm',
|
'fluent-crm',
|
||||||
'fluentform',
|
'fluentform',
|
||||||
'fluentforms-pdf',
|
'fluentforms-pdf',
|
||||||
'signature-addon-for-wp-fluent-form',
|
|
||||||
'fluent-support',
|
'fluent-support',
|
||||||
'flying-analytics',
|
'flying-analytics',
|
||||||
'flying-pages',
|
'flying-pages',
|
||||||
'flying-scripts',
|
'flying-scripts',
|
||||||
'freesoul-deactivate-plugins',
|
'freesoul-deactivate-plugins',
|
||||||
'hide-admin-notices',
|
'hide-admin-notices',
|
||||||
'hreflang-manager',
|
'hreflang-manager-lite',
|
||||||
'ics-calandar',
|
'ics-calendar',
|
||||||
'iframe-block',
|
'iframe-block',
|
||||||
'image-copytrack',
|
'image-copytrack',
|
||||||
'imsanity',
|
'imsanity',
|
||||||
'index-wp-mysql-for-speed',
|
'index-wp-mysql-for-speed',
|
||||||
'kadence-blocks',
|
'kadence-blocks',
|
||||||
'kadence-simple-share',
|
|
||||||
'litespeed-cache',
|
'litespeed-cache',
|
||||||
'magic-login',
|
'magic-login',
|
||||||
'mainwp-child',
|
'mainwp-child',
|
||||||
@ -96,16 +95,13 @@ function wp_allstars_get_recommended_plugins() {
|
|||||||
'nav-menu-roles',
|
'nav-menu-roles',
|
||||||
'ninja-tables',
|
'ninja-tables',
|
||||||
'performant-translations',
|
'performant-translations',
|
||||||
'plugin-groups',
|
|
||||||
'simple-icons',
|
'simple-icons',
|
||||||
'post-draft-preview',
|
'post-draft-preview',
|
||||||
'post-meta-data-manager',
|
|
||||||
'post-type-switcher',
|
'post-type-switcher',
|
||||||
'pretty-link',
|
'pretty-link',
|
||||||
'seo-by-rank-math',
|
'seo-by-rank-math',
|
||||||
'really-simple-ssl',
|
'really-simple-ssl',
|
||||||
'remove-cpt-base',
|
'remove-cpt-base',
|
||||||
'richtext-extension',
|
|
||||||
'safe-svg',
|
'safe-svg',
|
||||||
'simple-custom-post-order',
|
'simple-custom-post-order',
|
||||||
'remove-old-slugspermalinks',
|
'remove-old-slugspermalinks',
|
||||||
@ -114,7 +110,6 @@ function wp_allstars_get_recommended_plugins() {
|
|||||||
'ultimate-addons-for-gutenberg',
|
'ultimate-addons-for-gutenberg',
|
||||||
'sticky-posts-switch',
|
'sticky-posts-switch',
|
||||||
'syndication-links',
|
'syndication-links',
|
||||||
'taxopress',
|
|
||||||
'term-management-tools',
|
'term-management-tools',
|
||||||
'the-paste',
|
'the-paste',
|
||||||
'ultimate-410',
|
'ultimate-410',
|
||||||
@ -124,11 +119,13 @@ function wp_allstars_get_recommended_plugins() {
|
|||||||
'wordpress-importer',
|
'wordpress-importer',
|
||||||
'wp-social-reviews',
|
'wp-social-reviews',
|
||||||
'wp-optimize',
|
'wp-optimize',
|
||||||
'wp-sheet-editor',
|
'wp-sheet-editor-bulk-spreadsheet-editor-for-posts-and-pages',
|
||||||
'yellow-pencil-visual-theme-customizer'
|
'yellow-pencil-visual-theme-customizer'
|
||||||
),
|
),
|
||||||
'ecommerce' => array(
|
'ecommerce' => array(
|
||||||
'woocommerce',
|
'woocommerce',
|
||||||
|
'woo-bulk-edit-products',
|
||||||
|
'woo-coupons-bulk-editor',
|
||||||
'woocommerce-gateway-gocardless',
|
'woocommerce-gateway-gocardless',
|
||||||
'kadence-woocommerce-email-designer',
|
'kadence-woocommerce-email-designer',
|
||||||
'pymntpl-paypal-woocommerce',
|
'pymntpl-paypal-woocommerce',
|
||||||
@ -140,6 +137,7 @@ function wp_allstars_get_recommended_plugins() {
|
|||||||
'debug' => array(
|
'debug' => array(
|
||||||
'debug-log-manager',
|
'debug-log-manager',
|
||||||
'gotmls',
|
'gotmls',
|
||||||
|
'plugin-groups',
|
||||||
'query-monitor',
|
'query-monitor',
|
||||||
'string-locator',
|
'string-locator',
|
||||||
'user-switching',
|
'user-switching',
|
||||||
@ -823,8 +821,11 @@ function wp_allstars_settings_page() {
|
|||||||
|
|
||||||
<div class="wp-list-table-container">
|
<div class="wp-list-table-container">
|
||||||
<div id="wpa-plugin-list"></div>
|
<div id="wpa-plugin-list"></div>
|
||||||
<div class="wpa-loading-indicator" style="display: none; text-align: center; margin: 20px 0;">
|
<div class="wpa-load-more" style="display: none; text-align: center; margin: 20px 0;">
|
||||||
<span class="spinner is-active"></span>
|
<button class="button button-secondary">
|
||||||
|
<?php esc_html_e('Load More Plugins', 'wp-allstars'); ?>
|
||||||
|
<span class="spinner" style="float: none; margin-top: 4px;"></span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -840,9 +841,9 @@ function wp_allstars_settings_page() {
|
|||||||
transform: translateY(0);
|
transform: translateY(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.wpa-loading-indicator .spinner {
|
.wpa-load-more .spinner.is-active {
|
||||||
float: none;
|
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
|
display: inline-block;
|
||||||
}
|
}
|
||||||
/* Hide duplicate plugin counts */
|
/* Hide duplicate plugin counts */
|
||||||
.plugin-install-php .subsubsub {
|
.plugin-install-php .subsubsub {
|
||||||
@ -857,15 +858,16 @@ function wp_allstars_settings_page() {
|
|||||||
var currentCategory = '<?php echo esc_js($active_category); ?>';
|
var currentCategory = '<?php echo esc_js($active_category); ?>';
|
||||||
var currentOffset = 0;
|
var currentOffset = 0;
|
||||||
var batchSize = 10;
|
var batchSize = 10;
|
||||||
var hasMorePlugins = true;
|
|
||||||
var loadingObserver;
|
|
||||||
|
|
||||||
function loadPlugins(category, offset = 0, append = false) {
|
function loadPlugins(category, offset = 0, append = false) {
|
||||||
if (isLoading || !hasMorePlugins) return;
|
if (isLoading) return;
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
|
|
||||||
// Show loading indicator
|
// Show loading indicator in load more button if appending
|
||||||
$('.wpa-loading-indicator').show();
|
if (append) {
|
||||||
|
$('.wpa-load-more .spinner').addClass('is-active');
|
||||||
|
$('.wpa-load-more button').prop('disabled', true);
|
||||||
|
}
|
||||||
|
|
||||||
// Cancel previous request if it exists
|
// Cancel previous request if it exists
|
||||||
if (currentRequest) {
|
if (currentRequest) {
|
||||||
@ -903,13 +905,13 @@ function wp_allstars_settings_page() {
|
|||||||
|
|
||||||
$('#wpa-plugin-list').append($content);
|
$('#wpa-plugin-list').append($content);
|
||||||
|
|
||||||
// Update offset and check if we have more plugins
|
// Update offset and check if we need to show load more button
|
||||||
currentOffset = response.data.offset;
|
currentOffset = response.data.offset;
|
||||||
hasMorePlugins = response.data.remaining > 0;
|
|
||||||
|
|
||||||
// Hide loading indicator if no more plugins
|
if (response.data.remaining > 0) {
|
||||||
if (!hasMorePlugins) {
|
$('.wpa-load-more').show();
|
||||||
$('.wpa-loading-indicator').hide();
|
} else {
|
||||||
|
$('.wpa-load-more').hide();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.error('Server returned error:', response);
|
console.error('Server returned error:', response);
|
||||||
@ -920,36 +922,12 @@ function wp_allstars_settings_page() {
|
|||||||
},
|
},
|
||||||
complete: function() {
|
complete: function() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
if (hasMorePlugins) {
|
$('.wpa-load-more .spinner').removeClass('is-active');
|
||||||
setupIntersectionObserver();
|
$('.wpa-load-more button').prop('disabled', false);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupIntersectionObserver() {
|
|
||||||
// Disconnect previous observer if it exists
|
|
||||||
if (loadingObserver) {
|
|
||||||
loadingObserver.disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create new observer
|
|
||||||
loadingObserver = new IntersectionObserver((entries) => {
|
|
||||||
entries.forEach(entry => {
|
|
||||||
if (entry.isIntersecting && !isLoading && hasMorePlugins) {
|
|
||||||
loadPlugins(currentCategory, currentOffset, true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}, {
|
|
||||||
root: null,
|
|
||||||
rootMargin: '100px',
|
|
||||||
threshold: 0.1
|
|
||||||
});
|
|
||||||
|
|
||||||
// Observe the loading indicator
|
|
||||||
loadingObserver.observe($('.wpa-loading-indicator')[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load initial batch of plugins
|
// Load initial batch of plugins
|
||||||
loadPlugins(currentCategory);
|
loadPlugins(currentCategory);
|
||||||
|
|
||||||
@ -958,7 +936,6 @@ function wp_allstars_settings_page() {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var category = new URLSearchParams($(this).attr('href').split('?')[1]).get('category');
|
var category = new URLSearchParams($(this).attr('href').split('?')[1]).get('category');
|
||||||
currentCategory = category;
|
currentCategory = category;
|
||||||
hasMorePlugins = true;
|
|
||||||
|
|
||||||
// Update URL without page reload
|
// Update URL without page reload
|
||||||
var newUrl = $(this).attr('href');
|
var newUrl = $(this).attr('href');
|
||||||
@ -971,6 +948,11 @@ function wp_allstars_settings_page() {
|
|||||||
// Load new category
|
// Load new category
|
||||||
loadPlugins(category);
|
loadPlugins(category);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Handle load more button clicks
|
||||||
|
$('.wpa-load-more button').on('click', function() {
|
||||||
|
loadPlugins(currentCategory, currentOffset, true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user