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:
@ -28,8 +28,24 @@ class SEOProStack_Tab_Hosting {
|
||||
* Initialize the class.
|
||||
* Register any hooks or actions here.
|
||||
*/
|
||||
/**
|
||||
* Hosting providers data
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $hosting_providers;
|
||||
|
||||
/**
|
||||
* Server information
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $server_info;
|
||||
|
||||
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() {
|
||||
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
|
||||
@ -60,12 +293,11 @@ class SEOProStack_Tab_Hosting {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hosting providers
|
||||
* This internalizes the data previously retrieved from wp_seoprostack_get_hosting_providers()
|
||||
* Get additional hosting providers for specialized cases
|
||||
*
|
||||
* @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(
|
||||
'closte' => array(
|
||||
'name' => 'Closte',
|
||||
@ -276,13 +508,11 @@ class SEOProStack_Tab_Hosting {
|
||||
* Render the tab content.
|
||||
*/
|
||||
public function render() {
|
||||
// Get server information
|
||||
$server_info = $this->get_server_info();
|
||||
// Use the self-contained data
|
||||
$server_info = $this->server_info;
|
||||
$hosting_providers = $this->hosting_providers;
|
||||
|
||||
// Get hosting providers from the internal method
|
||||
$hosting_providers = $this->get_hosting_providers();
|
||||
|
||||
// For backward compatibility, make hosting providers available through global function
|
||||
echo '<div class="tab-content" id="' . esc_attr($this->tab_id) . '">;
|
||||
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
|
||||
$external_providers = wp_seoprostack_get_hosting_providers();
|
||||
|
Reference in New Issue
Block a user