Improve tab styling and refactor plugin architecture. Make Hosting tab class fully self-contained by internalizing data structures, fix CSS to match reference plugin, and remove duplicate function declarations.

This commit is contained in:
Marcus Quinn
2025-03-24 03:59:41 +00:00
parent a7537a000c
commit 4cf485041f
2 changed files with 261 additions and 11 deletions

View File

@ -48,6 +48,9 @@
position: sticky; position: sticky;
top: 32px; top: 32px;
z-index: 100; z-index: 100;
display: flex;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
} }
.nav-tab { .nav-tab {
@ -64,6 +67,9 @@
border-bottom: 2px solid transparent; border-bottom: 2px solid transparent;
display: inline-block; display: inline-block;
transition: all 0.2s ease; transition: all 0.2s ease;
position: relative;
outline: none;
box-shadow: none;
} }
.nav-tab:hover, .nav-tab:hover,
@ -83,6 +89,17 @@
font-weight: 600; font-weight: 600;
} }
/* Improve tab content container */
.tab-content {
padding: 20px 0;
animation: fadeIn 0.3s ease-in-out;
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
/* Base Toggle Switch Component */ /* Base Toggle Switch Component */
.seoprostack-toggle-switch { .seoprostack-toggle-switch {
position: relative; position: relative;
@ -871,6 +888,9 @@ input:checked + .seoprostack-toggle-slider:before {
position: sticky; position: sticky;
top: 32px; top: 32px;
z-index: 100; z-index: 100;
display: flex;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
} }
.nav-tab { .nav-tab {

View File

@ -28,8 +28,24 @@ class SEOProStack_Tab_Hosting {
* Initialize the class. * Initialize the class.
* Register any hooks or actions here. * Register any hooks or actions here.
*/ */
/**
* Hosting providers data
*
* @var array
*/
private $hosting_providers;
/**
* Server information
*
* @var array
*/
private $server_info;
public function __construct() { public function __construct() {
// If needed, register hooks or actions here // Initialize the hosting providers data
$this->hosting_providers = $this->get_hosting_providers();
$this->server_info = $this->get_server_info();
} }
/** /**
@ -49,6 +65,223 @@ class SEOProStack_Tab_Hosting {
public function get_title() { public function get_title() {
return __('Hosting', 'seoprostack'); return __('Hosting', 'seoprostack');
} }
/**
* Get server information
*
* @return array Server information
*/
private function get_server_info() {
global $wpdb;
$server_info = array();
// PHP Version
$server_info['php_version'] = array(
'label' => __('PHP Version', 'seoprostack'),
'value' => phpversion(),
'recommendation' => __('PHP 8.0 or higher recommended', 'seoprostack')
);
// MySQL Version
$server_info['mysql_version'] = array(
'label' => __('MySQL Version', 'seoprostack'),
'value' => $wpdb->db_version(),
'recommendation' => __('MySQL 8.0 or higher recommended', 'seoprostack')
);
// Server Software
$server_info['server_software'] = array(
'label' => __('Server Software', 'seoprostack'),
'value' => $_SERVER['SERVER_SOFTWARE'] ?? __('Unknown', 'seoprostack'),
'recommendation' => ''
);
// PHP Memory Limit
$memory_limit = ini_get('memory_limit');
$server_info['php_memory_limit'] = array(
'label' => __('PHP Memory Limit', 'seoprostack'),
'value' => $memory_limit,
'recommendation' => __('256M or higher recommended', 'seoprostack')
);
// Max Upload Size
$upload_max_filesize = ini_get('upload_max_filesize');
$server_info['upload_max_filesize'] = array(
'label' => __('Max Upload Size', 'seoprostack'),
'value' => $upload_max_filesize,
'recommendation' => __('64M or higher recommended', 'seoprostack')
);
return $server_info;
}
/**
* Get hosting providers
*
* @return array The hosting providers data
*/
private function get_hosting_providers() {
return array(
'kinsta' => array(
'name' => 'Kinsta',
'description' => 'Premium WordPress hosting with excellent performance, security, and customer support.',
'button_group' => array(
array(
'text' => 'Home Page',
'url' => 'https://kinsta.com/',
'primary' => true
),
array(
'text' => 'Pricing',
'url' => 'https://kinsta.com/plans/'
)
)
),
'wpengine' => array(
'name' => 'WP Engine',
'description' => 'Managed WordPress hosting provider with solid performance and security features.',
'button_group' => array(
array(
'text' => 'Home Page',
'url' => 'https://wpengine.com/',
'primary' => true
),
array(
'text' => 'Pricing',
'url' => 'https://wpengine.com/plans/'
)
)
),
'siteground' => array(
'name' => 'SiteGround',
'description' => 'Popular WordPress hosting with good performance and customer support.',
'button_group' => array(
array(
'text' => 'Home Page',
'url' => 'https://www.siteground.com/',
'primary' => true
),
array(
'text' => 'Pricing',
'url' => 'https://www.siteground.com/wordpress-hosting.htm'
)
)
),
'hostinger' => array(
'name' => 'Hostinger',
'description' => 'Affordable WordPress hosting with good performance and user-friendly management tools.',
'button_group' => array(
array(
'text' => 'Home Page',
'url' => 'https://www.hostinger.com/',
'primary' => true
),
array(
'text' => 'Pricing',
'url' => 'https://www.hostinger.com/wordpress-hosting'
)
)
),
'hetzner' => array(
'name' => 'Hetzner Cloud',
'description' => 'High-performance cloud servers with excellent price-to-performance ratio for self-managed WordPress hosting.',
'button_group' => array(
array(
'text' => 'Home Page',
'url' => 'https://www.hetzner.com/cloud/',
'primary' => true
),
array(
'text' => 'Pricing',
'url' => 'https://www.hetzner.com/cloud#pricing'
)
)
),
'simplehost' => array(
'name' => 'SimpleHost',
'description' => 'Streamlined WordPress hosting with a focus on simplicity and performance.',
'button_group' => array(
array(
'text' => 'Home Page',
'url' => 'https://simplehost.so/',
'primary' => true
),
array(
'text' => 'Pricing',
'url' => 'https://simplehost.so/#pricing'
)
)
),
'cloudflare' => array(
'name' => 'Cloudflare',
'description' => 'Global cloud platform that provides CDN, security, and performance optimization services.',
'button_group' => array(
array(
'text' => 'Home Page',
'url' => 'https://www.cloudflare.com/en-gb/',
'primary' => true
),
array(
'text' => 'Pricing',
'url' => 'https://www.cloudflare.com/en-gb/plans/'
)
)
),
'spaceship' => array(
'name' => 'Spaceship',
'description' => 'Modern hosting platform with advanced features for WordPress sites.',
'button_group' => array(
array(
'text' => 'Home Page',
'url' => 'https://www.spaceship.com/',
'primary' => true
)
)
),
'101domain' => array(
'name' => '101Domain',
'description' => 'Domain registration and management service with support for hundreds of TLDs.',
'button_group' => array(
array(
'text' => 'Home Page',
'url' => 'https://www.101domain.com/',
'primary' => true
)
)
),
'namecheap' => array(
'name' => 'Namecheap',
'description' => 'Domain registrar and web hosting provider with competitive pricing and good support.',
'button_group' => array(
array(
'text' => 'Home Page',
'url' => 'https://www.namecheap.com/',
'primary' => true
),
array(
'text' => 'Pricing',
'url' => 'https://www.namecheap.com/hosting/shared/'
)
)
),
'updownio' => array(
'name' => 'Updown.io',
'description' => 'Simple and affordable website monitoring service with uptime checks and performance metrics.',
'button_group' => array(
array(
'text' => 'Home Page',
'url' => 'https://updown.io/',
'primary' => true
),
array(
'text' => 'Pricing',
'url' => 'https://updown.io/pricing'
)
)
)
);
}
/** /**
* Get the tab description * Get the tab description
@ -60,12 +293,11 @@ class SEOProStack_Tab_Hosting {
} }
/** /**
* Get hosting providers * Get additional hosting providers for specialized cases
* This internalizes the data previously retrieved from wp_seoprostack_get_hosting_providers()
* *
* @return array Array of hosting providers with their details * @return array Array of additional hosting providers
*/ */
public function get_hosting_providers() { private function get_additional_hosting_providers() {
return array( return array(
'closte' => array( 'closte' => array(
'name' => 'Closte', 'name' => 'Closte',
@ -276,13 +508,11 @@ class SEOProStack_Tab_Hosting {
* Render the tab content. * Render the tab content.
*/ */
public function render() { public function render() {
// Get server information // Use the self-contained data
$server_info = $this->get_server_info(); $server_info = $this->server_info;
$hosting_providers = $this->hosting_providers;
// Get hosting providers from the internal method echo '<div class="tab-content" id="' . esc_attr($this->tab_id) . '">;
$hosting_providers = $this->get_hosting_providers();
// For backward compatibility, make hosting providers available through global function
if (function_exists('wp_seoprostack_get_hosting_providers') && empty($GLOBALS['_wp_seoprostack_hosting_loaded'])) { if (function_exists('wp_seoprostack_get_hosting_providers') && empty($GLOBALS['_wp_seoprostack_hosting_loaded'])) {
// Optional: merge with any providers from the external function to ensure none are lost // Optional: merge with any providers from the external function to ensure none are lost
$external_providers = wp_seoprostack_get_hosting_providers(); $external_providers = wp_seoprostack_get_hosting_providers();