| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package RSFirewall! |
| 4 |
* @copyright (c) 2018 RSJoomla! |
| 5 |
* @link https://www.rsjoomla.com |
| 6 |
* @license GNU General Public License http://www.gnu.org/licenses/gpl-3.0.en.html |
| 7 |
*/ |
| 8 |
|
| 9 |
if ( ! defined( 'WPINC' ) ) { |
| 10 |
die; |
| 11 |
} |
| 12 |
|
| 13 |
|
| 14 |
class RSFirewall_Version |
| 15 |
{ |
| 16 |
public $version = '1.1.48'; |
| 17 |
public $key = 'RSJFIREWALLWP'; |
| 18 |
|
| 19 |
public function __construct() {} |
| 20 |
|
| 21 |
public static function get_instance() { |
| 22 |
static $inst; |
| 23 |
if (is_null($inst)) { |
| 24 |
$inst = new RSFirewall_Version(); |
| 25 |
} |
| 26 |
|
| 27 |
return $inst; |
| 28 |
} |
| 29 |
|
| 30 |
public function activate_updates($return = false, $update_code = null) { |
| 31 |
require_once RSFIREWALL_BASE . 'libraries/autoupdate.php'; |
| 32 |
|
| 33 |
$args = array( |
| 34 |
'current_version' => $this->version, |
| 35 |
'slug' => 'rsfirewall', |
| 36 |
'update_code' => !is_null($update_code) ? $update_code : RSFirewall_Config::get('code'), |
| 37 |
'key' => $this->key, |
| 38 |
'type' => 'plugin' |
| 39 |
); |
| 40 |
|
| 41 |
// check if this is a lite version |
| 42 |
if (!file_exists(RSFIREWALL_BASE.'proversion/libraries/rsfirewall.php')) { |
| 43 |
$args['is_lite'] = true; |
| 44 |
} |
| 45 |
|
| 46 |
$autoupdate = new RSFirewall_Autoupdate ( $args ); |
| 47 |
|
| 48 |
if ($return) { |
| 49 |
return $autoupdate; |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
public function get_latest_version() { |
| 54 |
|
| 55 |
// the function may not be available |
| 56 |
if ( ! function_exists( 'plugins_api' ) ) { |
| 57 |
require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); |
| 58 |
} |
| 59 |
|
| 60 |
$args = array( |
| 61 |
'slug' => 'rsfirewall', |
| 62 |
'per_page' => 1, |
| 63 |
'fields' => array ( |
| 64 |
'version' => true, |
| 65 |
'versions' => true, |
| 66 |
'short_description' => false, |
| 67 |
'description' => false, |
| 68 |
'sections' => false, |
| 69 |
'tested' => false, |
| 70 |
'requires' => false, |
| 71 |
'rating' => false, |
| 72 |
'ratings' => false, |
| 73 |
'downloaded' => false, |
| 74 |
'downloadlink' => false, |
| 75 |
'last_updated' => false, |
| 76 |
'added' => false, |
| 77 |
'tags' => false, |
| 78 |
'compatibility' => false, |
| 79 |
'homepage' => false, |
| 80 |
'donate_link' => false, |
| 81 |
) |
| 82 |
); |
| 83 |
|
| 84 |
$call_api = plugins_api('plugin_information', $args); |
| 85 |
|
| 86 |
if ( !is_wp_error( $call_api )) { |
| 87 |
if (is_array($call_api)) { |
| 88 |
$call_api = (object) $call_api; |
| 89 |
} |
| 90 |
|
| 91 |
// compatibility format |
| 92 |
$version = new stdClass(); |
| 93 |
// check for new_version first |
| 94 |
$version->new_version = isset($call_api->new_version) ? $call_api->new_version : $call_api->version; |
| 95 |
|
| 96 |
return $version; |
| 97 |
} |
| 98 |
|
| 99 |
return false; |
| 100 |
} |
| 101 |
} |