-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from A2-Hosting/full-plugin
2.0 GPL Full Plugin
- Loading branch information
Showing
32 changed files
with
12,123 additions
and
68 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,52 @@ | ||
<?php | ||
/* | ||
Plugin Name: A2 Optimized | ||
Plugin URI: www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-the-a2-optimized-plugin | ||
Version: 1.7.8 | ||
Author: a2hosting.com | ||
Description: A2 Optimized WordPress optimization plugin | ||
Text Domain: a2-optimized | ||
License: GPLv3 | ||
*/ | ||
Plugin Name: A2 Optimized WP | ||
Plugin URI: https://wordpress.org/plugins/a2-optimized/ | ||
Version: 2.0 | ||
Author: A2 Hosting | ||
Author URI: https://www.a2hosting.com/ | ||
Description: A2 Optimized - WordPress Optimization Plugin | ||
Text Domain: a2-optimized | ||
License: GPLv2 or Later | ||
*/ | ||
|
||
|
||
function files_not_found_notice(){ | ||
|
||
$ip = $_SERVER['SERVER_ADDR']; | ||
|
||
$ch = curl_init(); | ||
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json; charset=utf-8","Accept:application/json, text/javascript, */*; q=0.01")); | ||
curl_setopt($ch, CURLOPT_URL, "http://whois.arin.net/rest/ip/{$ip}"); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | ||
$whois = json_decode(str_replace(array('@name','@handle'),array('name','handle'),curl_exec($ch))); | ||
curl_close($ch); | ||
|
||
|
||
$a2 = false; | ||
|
||
if(isset($whois->net->orgRef->handle)){ | ||
if($whois->net->orgRef->handle == 'A2HOS' || preg_match('/^185\.62\.13[6789]/',$ip) === 1 || preg_match('/^103.227.17[6789]/',$ip) === 1 ){ | ||
$a2 = true; | ||
} | ||
} | ||
////////////////////////////////// | ||
// Run initialization | ||
///////////////////////////////// | ||
|
||
|
||
class A2_Optimized { | ||
function __construct() { | ||
|
||
if($a2){ | ||
$message = ' | ||
A2 Optimized for WordPress is only available on Web Hosting packages. | ||
<br><br> | ||
If your WordPress site is hosted on a VPS or Dedicated Server: please deactivate and delete this plugin <a href="plugins.php?plugin_status=active">here</a>. | ||
<br><br> | ||
If your WordPress site is hosted on a Web Hosting account: please submit a support ticket <a href="http://my.a2hosting.com" >here</a> | ||
<br> | ||
'; | ||
} | ||
else{ | ||
$message = ' | ||
A2 Optimized for WordPress is only available for sites hosted with <a href="http://a2hosting.com/wordpress-hosting" target="_blank" >A2 Hosting</a>. | ||
<br><br> | ||
If you are completely satisfied with the speed of your current host: please deactivate and delete this plugin <a href="plugins.php?plugin_status=active">here</a>. | ||
<br><br> | ||
If you would like to take advantage of the A2 Optimized plugin for WordPress and enjoy extremely fast page load times: please visit <a target="_blank" href="http://a2hosting.com/wordpress-hosting">A2Hosting.com</a> | ||
<br>'; | ||
$GLOBALS['A2_Plugin_Dir'] = dirname(__FILE__); | ||
|
||
} | ||
require_once('A2_Optimized_Plugin.php'); | ||
require_once ABSPATH.'wp-admin/includes/plugin.php'; | ||
|
||
echo "<div class='error'><br>{$message}<br></div>"; | ||
|
||
} | ||
$a2Plugin = new A2_Optimized_Plugin(); | ||
|
||
// Install the plugin | ||
if (!$a2Plugin->isInstalled()) { | ||
$a2Plugin->install(); | ||
} | ||
else { | ||
// Perform any version-upgrade activities prior to activation (e.g. database changes) | ||
$a2Plugin->upgrade(); | ||
} | ||
|
||
$A2_Optimized_minimalRequiredPhpVersion = '5.3'; | ||
// Add callbacks to hooks | ||
$a2Plugin->addActionsAndFilters(); | ||
|
||
function A2_Optimized_noticePhpVersionWrong() { | ||
global $A2_Optimized_minimalRequiredPhpVersion; | ||
echo '<div class="updated fade">' . | ||
__('Error: plugin "A2 Optimized" requires a newer version of PHP to be running.', 'a2-optimized'). | ||
'<br/>' . __('Minimal version of PHP required: ', 'a2-optimized') . '<strong>' . $A2_Optimized_minimalRequiredPhpVersion . '</strong>' . | ||
'<br/>' . __('Your site is running PHP version: ', 'a2-optimized') . '<strong>' . phpversion() . '</strong>' . | ||
'<br /> To learn how to change the version of php running on your site <a target="_blank" href="http://www.a2hosting.com/kb/cpanel/cpanel-software-and-services/php-version">read this Knowledge Base Article</a>.'. | ||
'</div>'; | ||
} | ||
// Register the Plugin Activation Hook | ||
register_activation_hook(__FILE__, array(&$a2Plugin, 'activate')); | ||
|
||
// Register the Plugin Deactivation Hook | ||
register_deactivation_hook(__FILE__, array(&$a2Plugin, 'deactivate')); | ||
|
||
if(version_compare(phpversion(), $A2_Optimized_minimalRequiredPhpVersion) < 0) { | ||
add_action('admin_notices', 'A2_Optimized_noticePhpVersionWrong'); | ||
} | ||
elseif(!file_exists('/opt/a2-optimized/wordpress_encoded/a2-optimized.php')){ | ||
add_action('admin_notices', 'files_not_found_notice'); | ||
} | ||
else{ | ||
$GLOBALS['A2_Plugin_Dir'] = dirname(__FILE__); | ||
require_once '/opt/a2-optimized/wordpress_encoded/a2-optimized.php'; | ||
} | ||
} | ||
} | ||
|
||
?> | ||
$a2opt_class = new A2_Optimized(); |
Oops, something went wrong.