Switch to native WordPress plugin installer: - Use WP_Plugin_Install_List_Table for plugin browser - Filter plugins API results for curated lists - Remove custom plugin card styles - Keep category filter buttons
This commit is contained in:
@ -174,13 +174,7 @@
|
|||||||
box-shadow: 0 2px 4px rgba(0,0,0,0.3);
|
box-shadow: 0 2px 4px rgba(0,0,0,0.3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Settings content spacing */
|
/* Plugin filters */
|
||||||
.wpa-settings-content {
|
|
||||||
margin-top: 30px;
|
|
||||||
padding: 0 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Plugin Browser Styles */
|
|
||||||
.wpa-plugin-filters {
|
.wpa-plugin-filters {
|
||||||
margin: 0 0 20px;
|
margin: 0 0 20px;
|
||||||
padding: 0 0 12px;
|
padding: 0 0 12px;
|
||||||
@ -195,98 +189,7 @@
|
|||||||
min-height: 30px;
|
min-height: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.wpa-plugins-browser {
|
/* Settings content spacing */
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
|
|
||||||
gap: 20px;
|
|
||||||
margin-top: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.plugin-card {
|
|
||||||
background-color: #fff;
|
|
||||||
border: 1px solid #ddd;
|
|
||||||
border-radius: 4px;
|
|
||||||
box-shadow: 0 1px 4px rgba(0,0,0,0.02);
|
|
||||||
margin: 0;
|
|
||||||
width: 100%;
|
|
||||||
padding: 0;
|
|
||||||
transition: all .15s ease-in-out;
|
|
||||||
}
|
|
||||||
|
|
||||||
.plugin-card:hover {
|
|
||||||
border-color: #4caf50;
|
|
||||||
box-shadow: 0 2px 8px rgba(0,0,0,0.04);
|
|
||||||
}
|
|
||||||
|
|
||||||
.plugin-card-top {
|
|
||||||
padding: 20px;
|
|
||||||
min-height: 150px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
|
|
||||||
.plugin-card .name {
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.plugin-card .name h3 {
|
|
||||||
font-size: 16px;
|
|
||||||
line-height: 1.3;
|
|
||||||
margin: 0;
|
|
||||||
color: #1d2327;
|
|
||||||
}
|
|
||||||
|
|
||||||
.plugin-card .plugin-author {
|
|
||||||
font-size: 13px;
|
|
||||||
color: #646970;
|
|
||||||
font-weight: 400;
|
|
||||||
margin-left: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.plugin-card .desc {
|
|
||||||
margin: 8px 0;
|
|
||||||
color: #50575e;
|
|
||||||
}
|
|
||||||
|
|
||||||
.plugin-card .desc p {
|
|
||||||
margin: 0;
|
|
||||||
font-size: 13px;
|
|
||||||
line-height: 1.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.plugin-card .action-links {
|
|
||||||
margin-top: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.plugin-action-buttons {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.plugin-action-buttons li {
|
|
||||||
display: inline-block;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.plugin-action-buttons .button {
|
|
||||||
min-height: 30px;
|
|
||||||
line-height: 28px;
|
|
||||||
padding: 0 12px;
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.plugin-action-buttons .button-disabled {
|
|
||||||
color: #a7aaad !important;
|
|
||||||
border-color: #ddd !important;
|
|
||||||
background: #f6f7f7 !important;
|
|
||||||
box-shadow: none !important;
|
|
||||||
cursor: default;
|
|
||||||
transform: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Adjust settings content padding for plugin browser */
|
|
||||||
.wpa-settings-content {
|
.wpa-settings-content {
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
@ -23,7 +23,7 @@ function wpa_superstar_register_settings() {
|
|||||||
}
|
}
|
||||||
add_action('admin_init', 'wpa_superstar_register_settings');
|
add_action('admin_init', 'wpa_superstar_register_settings');
|
||||||
|
|
||||||
// AJAX handler
|
// AJAX handler for settings
|
||||||
function wpa_superstar_update_option() {
|
function wpa_superstar_update_option() {
|
||||||
check_ajax_referer('wpa-superstar-nonce', 'nonce');
|
check_ajax_referer('wpa-superstar-nonce', 'nonce');
|
||||||
$option = sanitize_text_field($_POST['option']);
|
$option = sanitize_text_field($_POST['option']);
|
||||||
@ -36,105 +36,74 @@ add_action( 'wp_ajax_wpa_superstar_update_option', 'wpa_superstar_update_option'
|
|||||||
// Define recommended plugins
|
// Define recommended plugins
|
||||||
function wpa_superstar_get_recommended_plugins() {
|
function wpa_superstar_get_recommended_plugins() {
|
||||||
return array(
|
return array(
|
||||||
'utilities' => array(
|
'recommended' => array(
|
||||||
'name' => 'Recommended',
|
'advanced-custom-fields',
|
||||||
'plugins' => array(
|
'admin-menu-editor',
|
||||||
array(
|
'antispam-bee',
|
||||||
'slug' => 'advanced-custom-fields',
|
'burst-statistics',
|
||||||
'name' => 'Advanced Custom Fields',
|
'freesoul-deactivate-plugins',
|
||||||
'description' => 'Customize WordPress with powerful, professional and intuitive fields.',
|
'plugin-toggle',
|
||||||
'author' => 'WP Engine',
|
'pretty-links',
|
||||||
'category' => 'recommended'
|
'seo-by-rank-math',
|
||||||
|
'turnstile'
|
||||||
),
|
),
|
||||||
array(
|
'advanced' => array(
|
||||||
'slug' => 'admin-menu-editor',
|
'fluent-crm',
|
||||||
'name' => 'Admin Menu Editor',
|
'fluentform',
|
||||||
'description' => 'Customize the WordPress admin menu.',
|
'fluent-smtp',
|
||||||
'author' => 'Janis Elsts',
|
'fluent-support'
|
||||||
'category' => 'recommended'
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'slug' => 'antispam-bee',
|
|
||||||
'name' => 'Antispam Bee',
|
|
||||||
'description' => 'Antispam plugin with a sophisticated toolset for effective spam protection.',
|
|
||||||
'author' => 'pluginkollektiv',
|
|
||||||
'category' => 'recommended'
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'slug' => 'burst-statistics',
|
|
||||||
'name' => 'Burst Statistics',
|
|
||||||
'description' => 'Privacy-friendly analytics tool.',
|
|
||||||
'author' => 'Really Simple Plugins',
|
|
||||||
'category' => 'recommended'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
'fluent' => array(
|
|
||||||
'name' => 'Advanced',
|
|
||||||
'plugins' => array(
|
|
||||||
array(
|
|
||||||
'slug' => 'fluent-crm',
|
|
||||||
'name' => 'Fluent CRM',
|
|
||||||
'description' => 'Marketing Automation for WordPress.',
|
|
||||||
'author' => 'WP Fluent',
|
|
||||||
'category' => 'advanced'
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'slug' => 'fluentform',
|
|
||||||
'name' => 'Fluent Forms',
|
|
||||||
'description' => 'Advanced Contact Form Plugin.',
|
|
||||||
'author' => 'WP Fluent',
|
|
||||||
'category' => 'advanced'
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'slug' => 'fluent-smtp',
|
|
||||||
'name' => 'Fluent SMTP',
|
|
||||||
'description' => 'The Most Advanced SMTP & Email Service Integration Plugin.',
|
|
||||||
'author' => 'WP Fluent',
|
|
||||||
'category' => 'advanced'
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'slug' => 'fluent-support',
|
|
||||||
'name' => 'Fluent Support',
|
|
||||||
'description' => 'Customer Support & Helpdesk Plugin.',
|
|
||||||
'author' => 'WP Fluent',
|
|
||||||
'category' => 'advanced'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
'ecommerce' => array(
|
'ecommerce' => array(
|
||||||
'name' => 'Ecommerce',
|
'woocommerce',
|
||||||
'plugins' => array(
|
'client-booking'
|
||||||
array(
|
|
||||||
'slug' => 'woocommerce',
|
|
||||||
'name' => 'WooCommerce',
|
|
||||||
'description' => 'An eCommerce toolkit that helps you sell anything.',
|
|
||||||
'author' => 'Automattic',
|
|
||||||
'category' => 'ecommerce'
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'slug' => 'client-booking',
|
|
||||||
'name' => 'Client Bookings',
|
|
||||||
'description' => 'Appointment Scheduling & Booking.',
|
|
||||||
'author' => 'WP Fluent',
|
|
||||||
'category' => 'ecommerce'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
'lms' => array(
|
'lms' => array(
|
||||||
'name' => 'LMS',
|
// Add LMS plugins when needed
|
||||||
'plugins' => array(
|
|
||||||
// Add LMS plugins here when needed
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Filter the plugins API results
|
||||||
|
function wpa_superstar_filter_plugins_api($result, $action, $args) {
|
||||||
|
if ($action !== 'query_plugins') {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only filter on our page
|
||||||
|
if (!isset($_GET['page']) || $_GET['page'] !== 'wpa-superstar') {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
$category = isset($_GET['category']) ? sanitize_key($_GET['category']) : 'recommended';
|
||||||
|
$recommended_plugins = wpa_superstar_get_recommended_plugins();
|
||||||
|
|
||||||
|
if (!isset($recommended_plugins[$category])) {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the full plugin data for our recommended plugins
|
||||||
|
$args = array(
|
||||||
|
'per_page' => 100,
|
||||||
|
'fields' => array(
|
||||||
|
'last_updated' => true,
|
||||||
|
'active_installs' => true,
|
||||||
|
'downloaded' => true,
|
||||||
|
'icons' => true,
|
||||||
|
),
|
||||||
|
'slug' => $recommended_plugins[$category]
|
||||||
|
);
|
||||||
|
|
||||||
|
$query = new WP_Plugin_Install_List_Table();
|
||||||
|
$query->prepare_items();
|
||||||
|
|
||||||
|
return plugins_api('query_plugins', $args);
|
||||||
|
}
|
||||||
|
add_filter('plugins_api_result', 'wpa_superstar_filter_plugins_api', 10, 3);
|
||||||
|
|
||||||
// Settings page HTML
|
// Settings page HTML
|
||||||
function wpa_superstar_settings_page() {
|
function wpa_superstar_settings_page() {
|
||||||
$active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'recommended';
|
$active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'recommended';
|
||||||
$active_category = isset($_GET['category']) ? $_GET['category'] : 'recommended';
|
$active_category = isset($_GET['category']) ? $_GET['category'] : 'recommended';
|
||||||
$recommended_plugins = wpa_superstar_get_recommended_plugins();
|
|
||||||
?>
|
?>
|
||||||
<div class="wrap wpa-superstar-wrap">
|
<div class="wrap wpa-superstar-wrap">
|
||||||
<div class="wpa-superstar-header">
|
<div class="wpa-superstar-header">
|
||||||
@ -183,56 +152,19 @@ function wpa_superstar_settings_page() {
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="wpa-plugins-browser">
|
|
||||||
<?php foreach ( $recommended_plugins as $section ) :
|
|
||||||
foreach ( $section['plugins'] as $plugin ) :
|
|
||||||
if ( $plugin['category'] === $active_category ) :
|
|
||||||
$installed = is_dir( WP_PLUGIN_DIR . '/' . $plugin['slug'] );
|
|
||||||
$install_url = wp_nonce_url(
|
|
||||||
add_query_arg(
|
|
||||||
array(
|
|
||||||
'action' => 'install-plugin',
|
|
||||||
'plugin' => $plugin['slug']
|
|
||||||
),
|
|
||||||
admin_url( 'update.php' )
|
|
||||||
),
|
|
||||||
'install-plugin_' . $plugin['slug']
|
|
||||||
);
|
|
||||||
?>
|
|
||||||
<div class="plugin-card">
|
|
||||||
<div class="plugin-card-top">
|
|
||||||
<div class="name column-name">
|
|
||||||
<h3>
|
|
||||||
<?php echo esc_html( $plugin['name'] ); ?>
|
|
||||||
<span class="plugin-author">
|
|
||||||
<?php printf( esc_html__( 'By %s', 'wpa-superstar' ), esc_html( $plugin['author'] ) ); ?>
|
|
||||||
</span>
|
|
||||||
</h3>
|
|
||||||
</div>
|
|
||||||
<div class="desc column-description">
|
|
||||||
<p><?php echo esc_html( $plugin['description'] ); ?></p>
|
|
||||||
</div>
|
|
||||||
<div class="action-links">
|
|
||||||
<ul class="plugin-action-buttons">
|
|
||||||
<li>
|
|
||||||
<?php if ( $installed ) : ?>
|
|
||||||
<button class="button button-disabled" disabled><?php esc_html_e( 'Installed', 'wpa-superstar' ); ?></button>
|
|
||||||
<?php else : ?>
|
|
||||||
<a href="<?php echo esc_url( $install_url ); ?>" class="button button-primary">
|
|
||||||
<?php esc_html_e( 'Install Now', 'wpa-superstar' ); ?>
|
|
||||||
</a>
|
|
||||||
<?php endif; ?>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php
|
<?php
|
||||||
endif;
|
require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
|
||||||
endforeach;
|
require_once ABSPATH . 'wp-admin/includes/class-wp-plugin-install-list-table.php';
|
||||||
endforeach;
|
|
||||||
|
// Set up the plugin install table
|
||||||
|
$plugin_table = new WP_Plugin_Install_List_Table();
|
||||||
|
$plugin_table->prepare_items();
|
||||||
|
|
||||||
|
// Display the plugin browser
|
||||||
|
echo '<div class="wrap">';
|
||||||
|
$plugin_table->display();
|
||||||
|
echo '</div>';
|
||||||
?>
|
?>
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php elseif ($active_tab == 'general'): ?>
|
<?php elseif ($active_tab == 'general'): ?>
|
||||||
<div class="wpa-superstar-toggle">
|
<div class="wpa-superstar-toggle">
|
||||||
@ -252,6 +184,7 @@ function wpa_superstar_settings_page() {
|
|||||||
<?php esc_html_e('Improves page load time by loading images only when they enter the viewport.', 'wpa-superstar'); ?>
|
<?php esc_html_e('Improves page load time by loading images only when they enter the viewport.', 'wpa-superstar'); ?>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php elseif ($active_tab == 'advanced'): ?>
|
<?php elseif ($active_tab == 'advanced'): ?>
|
||||||
<div class="wpa-superstar-toggle">
|
<div class="wpa-superstar-toggle">
|
||||||
<label for="wpa_superstar_minify_css">
|
<label for="wpa_superstar_minify_css">
|
||||||
|
Reference in New Issue
Block a user