Rename plugin to wp-seoprostack-plugin, update file structure
This commit is contained in:
462
admin/settings/tabs/class-seoprostack-tab-hosting.php
Normal file
462
admin/settings/tabs/class-seoprostack-tab-hosting.php
Normal file
@ -0,0 +1,462 @@
|
||||
<?php
|
||||
/**
|
||||
* The Hosting tab for plugin settings.
|
||||
*
|
||||
* @package SEO_Pro_Stack
|
||||
* @subpackage SEO_Pro_Stack/Admin/Settings/Tabs
|
||||
*/
|
||||
|
||||
// If this file is called directly, abort.
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Hosting tab for plugin settings.
|
||||
* Self-contained class with integrated data and functionality
|
||||
*/
|
||||
class SEOProStack_Tab_Hosting {
|
||||
|
||||
/**
|
||||
* Tab identifier
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $tab_id = 'hosting';
|
||||
|
||||
/**
|
||||
* Initialize the class.
|
||||
* Register any hooks or actions here.
|
||||
*/
|
||||
public function __construct() {
|
||||
// If needed, register hooks or actions here
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tab ID
|
||||
*
|
||||
* @return string The tab ID
|
||||
*/
|
||||
public function get_tab_id() {
|
||||
return $this->tab_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tab title
|
||||
*
|
||||
* @return string The tab title
|
||||
*/
|
||||
public function get_title() {
|
||||
return __('Hosting', 'seoprostack');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tab description
|
||||
*
|
||||
* @return string The tab description
|
||||
*/
|
||||
public function get_description() {
|
||||
return __('Details about your current hosting environment and recommendations for improvement.', 'seoprostack');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hosting providers
|
||||
* This internalizes the data previously retrieved from wp_seoprostack_get_hosting_providers()
|
||||
*
|
||||
* @return array Array of hosting providers with their details
|
||||
*/
|
||||
public function get_hosting_providers() {
|
||||
return array(
|
||||
'closte' => array(
|
||||
'name' => 'Closte',
|
||||
'description' => 'Managed WordPress hosting with advanced performance optimization and auto-scaling.',
|
||||
'features' => array(
|
||||
'Auto-scaling architecture',
|
||||
'Global CDN included',
|
||||
'Advanced caching',
|
||||
'Free SSL certificates'
|
||||
),
|
||||
'button_group' => array(
|
||||
array(
|
||||
'text' => 'Home Page',
|
||||
'url' => 'https://closte.com/',
|
||||
'primary' => true
|
||||
),
|
||||
array(
|
||||
'text' => 'Pricing',
|
||||
'url' => 'https://closte.com/pricing'
|
||||
)
|
||||
)
|
||||
),
|
||||
'cloudron' => array(
|
||||
'name' => 'Cloudron',
|
||||
'description' => 'Self-hosted platform that makes it easy to run web applications like WordPress on your server.',
|
||||
'features' => array(
|
||||
'One-click installation',
|
||||
'Automatic updates',
|
||||
'Built-in backups',
|
||||
'SSL certificate management'
|
||||
),
|
||||
'button_group' => array(
|
||||
array(
|
||||
'text' => 'Home Page',
|
||||
'url' => 'https://www.cloudron.io/',
|
||||
'primary' => true
|
||||
),
|
||||
array(
|
||||
'text' => 'Pricing',
|
||||
'url' => 'https://www.cloudron.io/pricing.html'
|
||||
)
|
||||
)
|
||||
),
|
||||
'hostinger' => array(
|
||||
'name' => 'Hostinger',
|
||||
'description' => 'Affordable WordPress hosting with good performance and user-friendly management tools.',
|
||||
'features' => array(
|
||||
'Free domain name',
|
||||
'Managed WordPress features',
|
||||
'LiteSpeed cache',
|
||||
'Weekly backups'
|
||||
),
|
||||
'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.',
|
||||
'features' => array(
|
||||
'Scalable cloud instances',
|
||||
'Per-minute billing',
|
||||
'Snapshots and backups',
|
||||
'Global data centers'
|
||||
),
|
||||
'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.',
|
||||
'features' => array(
|
||||
'Simplified hosting dashboard',
|
||||
'Pre-optimized WordPress',
|
||||
'Automated backups',
|
||||
'Email hosting included'
|
||||
),
|
||||
'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.',
|
||||
'features' => array(
|
||||
'Global CDN network',
|
||||
'DDoS protection',
|
||||
'Web application firewall',
|
||||
'Performance optimization'
|
||||
),
|
||||
'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.',
|
||||
'features' => array(
|
||||
'Advanced WordPress tools',
|
||||
'Optimized for speed',
|
||||
'Developer-friendly features',
|
||||
'Smart caching system'
|
||||
),
|
||||
'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.',
|
||||
'features' => array(
|
||||
'Extensive TLD selection',
|
||||
'Domain privacy protection',
|
||||
'Expert domain support',
|
||||
'Bulk domain management'
|
||||
),
|
||||
'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.',
|
||||
'features' => array(
|
||||
'Free WhoisGuard protection',
|
||||
'Competitive domain pricing',
|
||||
'Reliable hosting services',
|
||||
'Excellent 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.',
|
||||
'features' => array(
|
||||
'Real-time monitoring',
|
||||
'Performance metrics',
|
||||
'Notification alerts',
|
||||
'Detailed reports'
|
||||
),
|
||||
'button_group' => array(
|
||||
array(
|
||||
'text' => 'Home Page',
|
||||
'url' => 'https://updown.io/',
|
||||
'primary' => true
|
||||
),
|
||||
array(
|
||||
'text' => 'Pricing',
|
||||
'url' => 'https://updown.io/pricing'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the tab content.
|
||||
*/
|
||||
public function render() {
|
||||
// Get server information
|
||||
$server_info = $this->get_server_info();
|
||||
|
||||
// Get hosting providers from the internal method
|
||||
$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'])) {
|
||||
// Optional: merge with any providers from the external function to ensure none are lost
|
||||
$external_providers = wp_seoprostack_get_hosting_providers();
|
||||
$hosting_providers = array_merge($external_providers, $hosting_providers);
|
||||
$GLOBALS['_wp_seoprostack_hosting_loaded'] = true;
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="seoprostack-settings-content tab-content" id="<?php echo esc_attr($this->get_tab_id()); ?>">
|
||||
<div class="seoprostack-setting-section">
|
||||
<h2><?php esc_html_e('Hosting Information', 'seoprostack'); ?></h2>
|
||||
<p class="description"><?php echo esc_html($this->get_description()); ?></p>
|
||||
|
||||
<div class="seoprostack-server-info">
|
||||
<h3><?php esc_html_e('Server Environment', 'seoprostack'); ?></h3>
|
||||
<table class="seoprostack-info-table">
|
||||
<tr>
|
||||
<th><?php esc_html_e('PHP Version', 'seoprostack'); ?></th>
|
||||
<td>
|
||||
<?php echo esc_html($server_info['php_version']); ?>
|
||||
<?php echo $this->get_status_icon($server_info['php_status']); ?>
|
||||
</td>
|
||||
<td class="seoprostack-info-note">
|
||||
<?php echo esc_html($server_info['php_note']); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php esc_html_e('MySQL Version', 'seoprostack'); ?></th>
|
||||
<td>
|
||||
<?php echo esc_html($server_info['mysql_version']); ?>
|
||||
<?php echo $this->get_status_icon($server_info['mysql_status']); ?>
|
||||
</td>
|
||||
<td class="seoprostack-info-note">
|
||||
<?php echo esc_html($server_info['mysql_note']); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php esc_html_e('WordPress Version', 'seoprostack'); ?></th>
|
||||
<td>
|
||||
<?php echo esc_html($server_info['wp_version']); ?>
|
||||
<?php echo $this->get_status_icon($server_info['wp_status']); ?>
|
||||
</td>
|
||||
<td class="seoprostack-info-note">
|
||||
<?php echo esc_html($server_info['wp_note']); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php esc_html_e('Memory Limit', 'seoprostack'); ?></th>
|
||||
<td>
|
||||
<?php echo esc_html($server_info['memory_limit']); ?>
|
||||
<?php echo $this->get_status_icon($server_info['memory_status']); ?>
|
||||
</td>
|
||||
<td class="seoprostack-info-note">
|
||||
<?php echo esc_html($server_info['memory_note']); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php esc_html_e('Max Execution Time', 'seoprostack'); ?></th>
|
||||
<td>
|
||||
<?php echo esc_html($server_info['max_execution_time']); ?> seconds
|
||||
<?php echo $this->get_status_icon($server_info['execution_status']); ?>
|
||||
</td>
|
||||
<td class="seoprostack-info-note">
|
||||
<?php echo esc_html($server_info['execution_note']); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="seoprostack-hosting-recommendations">
|
||||
<h3><?php esc_html_e('Recommended Hosting Providers', 'seoprostack'); ?></h3>
|
||||
<p><?php esc_html_e('These hosting providers offer excellent performance for WordPress sites and are recommended for optimal SEO results.', 'seoprostack'); ?></p>
|
||||
|
||||
<div class="seoprostack-hosting-grid">
|
||||
<?php foreach ($hosting_providers as $key => $provider) : ?>
|
||||
<div class="seoprostack-hosting-card">
|
||||
<div class="seoprostack-hosting-card-header">
|
||||
<h4><?php echo esc_html($provider['name']); ?></h4>
|
||||
</div>
|
||||
<div class="seoprostack-hosting-card-content">
|
||||
<p><?php echo esc_html($provider['description']); ?></p>
|
||||
<?php if (!empty($provider['features'])) : ?>
|
||||
<ul class="seoprostack-hosting-features">
|
||||
<?php foreach ($provider['features'] as $feature) : ?>
|
||||
<li><?php echo esc_html($feature); ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="seoprostack-hosting-card-footer">
|
||||
<?php foreach ($provider['button_group'] as $button) : ?>
|
||||
<a href="<?php echo esc_url($button['url']); ?>" class="seoprostack-button<?php echo ($button['primary']) ? ' primary' : ''; ?>" target="_blank">
|
||||
<?php echo esc_html($button['text']); ?>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Get server information.
|
||||
*
|
||||
* @return array Server information.
|
||||
*/
|
||||
private function get_server_info() {
|
||||
global $wpdb;
|
||||
|
||||
// PHP version
|
||||
$php_version = phpversion();
|
||||
$php_status = version_compare($php_version, '7.4', '>=') ? 'good' : (version_compare($php_version, '7.0', '>=') ? 'warning' : 'bad');
|
||||
$php_note = version_compare($php_version, '7.4', '>=') ? __('Your PHP version is up to date.', 'seoprostack') : __('We recommend PHP 7.4 or higher for optimal performance and security.', 'seoprostack');
|
||||
|
||||
// MySQL version
|
||||
$mysql_version = $wpdb->db_version();
|
||||
$mysql_status = version_compare($mysql_version, '5.6', '>=') ? 'good' : 'warning';
|
||||
$mysql_note = version_compare($mysql_version, '5.6', '>=') ? __('Your MySQL version is sufficient.', 'seoprostack') : __('We recommend MySQL 5.6 or higher for better performance.', 'seoprostack');
|
||||
|
||||
// WordPress version
|
||||
$wp_version = get_bloginfo('version');
|
||||
$wp_status = version_compare($wp_version, '5.8', '>=') ? 'good' : (version_compare($wp_version, '5.5', '>=') ? 'warning' : 'bad');
|
||||
$wp_note = version_compare($wp_version, '5.8', '>=') ? __('Your WordPress version is up to date.', 'seoprostack') : __('We recommend updating to the latest version of WordPress.', 'seoprostack');
|
||||
|
||||
// Memory limit
|
||||
$memory_limit = ini_get('memory_limit');
|
||||
$memory_limit_bytes = wp_convert_hr_to_bytes($memory_limit);
|
||||
$memory_status = $memory_limit_bytes >= 256 * 1024 * 1024 ? 'good' : ($memory_limit_bytes >= 128 * 1024 * 1024 ? 'warning' : 'bad');
|
||||
$memory_note = $memory_limit_bytes >= 256 * 1024 * 1024 ? __('Your memory limit is sufficient.', 'seoprostack') : __('We recommend a memory limit of at least 256MB.', 'seoprostack');
|
||||
|
||||
// Max execution time
|
||||
$max_execution_time = ini_get('max_execution_time');
|
||||
$execution_status = $max_execution_time >= 180 || $max_execution_time == 0 ? 'good' : ($max_execution_time >= 60 ? 'warning' : 'bad');
|
||||
$execution_note = $max_execution_time >= 180 || $max_execution_time == 0 ? __('Your max execution time is sufficient.', 'seoprostack') : __('We recommend a max execution time of at least 180 seconds.', 'seoprostack');
|
||||
|
||||
return array(
|
||||
'php_version' => $php_version,
|
||||
'php_status' => $php_status,
|
||||
'php_note' => $php_note,
|
||||
'mysql_version' => $mysql_version,
|
||||
'mysql_status' => $mysql_status,
|
||||
'mysql_note' => $mysql_note,
|
||||
'wp_version' => $wp_version,
|
||||
'wp_status' => $wp_status,
|
||||
'wp_note' => $wp_note,
|
||||
'memory_limit' => $memory_limit,
|
||||
'memory_status' => $memory_status,
|
||||
'memory_note' => $memory_note,
|
||||
'max_execution_time' => $max_execution_time,
|
||||
'execution_status' => $execution_status,
|
||||
'execution_note' => $execution_note
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a status icon based on the status.
|
||||
*
|
||||
* @param string $status Status (good, warning, or bad).
|
||||
* @return string Status icon HTML.
|
||||
*/
|
||||
private function get_status_icon($status) {
|
||||
switch ($status) {
|
||||
case 'good':
|
||||
return '<span class="seoprostack-status-icon good dashicons dashicons-yes-alt"></span>';
|
||||
case 'warning':
|
||||
return '<span class="seoprostack-status-icon warning dashicons dashicons-warning"></span>';
|
||||
case 'bad':
|
||||
return '<span class="seoprostack-status-icon bad dashicons dashicons-dismiss"></span>';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user