Edit File by line
/home/zeestwma/ajeebong.../wp-conte.../plugins/revslide.../includes
File: update.class.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* @author ThemePunch <info@themepunch.com>
[2] Fix | Delete
* @link https://www.themepunch.com/
[3] Fix | Delete
* @copyright 2024 ThemePunch
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
if(!defined('ABSPATH')) exit();
[7] Fix | Delete
[8] Fix | Delete
class RevSliderUpdate extends RevSliderFunctions {
[9] Fix | Delete
[10] Fix | Delete
private $plugin_url = 'https://www.sliderrevolution.com/';
[11] Fix | Delete
private $remote_url = 'check_for_updates.php';
[12] Fix | Delete
private $remote_url_info = 'revslider/revslider.php';
[13] Fix | Delete
private $plugin_slug = 'revslider';
[14] Fix | Delete
private $version;
[15] Fix | Delete
private $plugins;
[16] Fix | Delete
private $option;
[17] Fix | Delete
private $data;
[18] Fix | Delete
public $force = false;
[19] Fix | Delete
[20] Fix | Delete
[21] Fix | Delete
public function __construct($version){
[22] Fix | Delete
$this->option = $this->plugin_slug . '_update_info';
[23] Fix | Delete
$this->data = new stdClass;
[24] Fix | Delete
$this->_retrieve_version_info();
[25] Fix | Delete
$this->version = (empty($version)) ? RS_REVISION : $version;
[26] Fix | Delete
}
[27] Fix | Delete
[28] Fix | Delete
[29] Fix | Delete
public function add_update_checks(){
[30] Fix | Delete
if($this->force === true){
[31] Fix | Delete
ini_set('max_execution_time', 300); //an update can follow, so set the execution time high for the runtime
[32] Fix | Delete
$transient = get_site_transient('update_plugins');
[33] Fix | Delete
$rs_t = $this->set_update_transient($transient);
[34] Fix | Delete
[35] Fix | Delete
if(!empty($rs_t)){
[36] Fix | Delete
set_site_transient('update_plugins', $rs_t);
[37] Fix | Delete
}
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
add_filter('pre_set_site_transient_update_plugins', array(&$this, 'set_update_transient'));
[41] Fix | Delete
add_filter('plugins_api', array(&$this, 'set_updates_api_results'), 10, 3);
[42] Fix | Delete
}
[43] Fix | Delete
[44] Fix | Delete
[45] Fix | Delete
public function set_update_transient($transient){
[46] Fix | Delete
$this->_check_updates();
[47] Fix | Delete
[48] Fix | Delete
if(isset($transient) && !isset($transient->response)){
[49] Fix | Delete
if(!is_object($transient)) $transient = new stdClass();
[50] Fix | Delete
$transient->response = array();
[51] Fix | Delete
}
[52] Fix | Delete
if(!isset($this->data)) return $transient;
[53] Fix | Delete
if(!isset($this->data->basic)) return $transient;
[54] Fix | Delete
[55] Fix | Delete
if(!empty($this->data->basic) && is_object($this->data->basic)){
[56] Fix | Delete
$version = (isset($this->data->basic->version)) ? $this->data->basic->version : $this->data->basic->new_version;
[57] Fix | Delete
if(version_compare($this->version, $version, '<')){
[58] Fix | Delete
$this->data->basic->new_version = $version;
[59] Fix | Delete
if(isset($this->data->basic->version)){
[60] Fix | Delete
unset($this->data->basic->version);
[61] Fix | Delete
}
[62] Fix | Delete
$transient->response[RS_PLUGIN_SLUG_PATH] = $this->data->basic;
[63] Fix | Delete
}
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
return $transient;
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
[70] Fix | Delete
public function set_updates_api_results($result, $action, $args){
[71] Fix | Delete
$this->_check_updates();
[72] Fix | Delete
[73] Fix | Delete
if(isset($args->slug) && $args->slug == $this->plugin_slug && $action == 'plugin_information'){
[74] Fix | Delete
if(!isset($this->data)) return $result;
[75] Fix | Delete
if(!isset($this->data->full)) return $result;
[76] Fix | Delete
if(is_object($this->data->full) && !empty($this->data->full)){
[77] Fix | Delete
$result = $this->data->full;
[78] Fix | Delete
}
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
return $result;
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
[85] Fix | Delete
public function _check_updates(){
[86] Fix | Delete
// Get data
[87] Fix | Delete
if(empty($this->data) || !isset($this->data->basic)){
[88] Fix | Delete
$data = get_option($this->option, false);
[89] Fix | Delete
$data = $data ? $data : new stdClass;
[90] Fix | Delete
[91] Fix | Delete
$this->data = is_object($data) ? $data : maybe_unserialize($data);
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
$last_check = get_option('revslider-update-check');
[95] Fix | Delete
if($last_check == false){ //first time called
[96] Fix | Delete
$last_check = time() - 172802;
[97] Fix | Delete
update_option('revslider-update-check', $last_check);
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
// Check for updates
[101] Fix | Delete
if(time() - $last_check > 172800 || $this->force == true){
[102] Fix | Delete
$data = $this->_retrieve_update_info();
[103] Fix | Delete
[104] Fix | Delete
update_option('revslider-update-check', time());
[105] Fix | Delete
if(isset($data->basic)){
[106] Fix | Delete
$this->data->checked = time();
[107] Fix | Delete
$this->data->basic = $data->basic;
[108] Fix | Delete
$this->data->full = $data->full;
[109] Fix | Delete
[110] Fix | Delete
update_option('revslider-stable-version', $data->full->stable);
[111] Fix | Delete
update_option('revslider-latest-version', $data->full->version);
[112] Fix | Delete
}
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
// Save results
[116] Fix | Delete
update_option($this->option, $this->data);
[117] Fix | Delete
}
[118] Fix | Delete
[119] Fix | Delete
[120] Fix | Delete
public function _retrieve_update_info(){
[121] Fix | Delete
$rslb = RevSliderGlobals::instance()->get('RevSliderLoadBalancer');
[122] Fix | Delete
$data = new stdClass;
[123] Fix | Delete
[124] Fix | Delete
// Build request
[125] Fix | Delete
$rattr = array(
[126] Fix | Delete
'code' => urlencode(get_option('revslider-code', '')),
[127] Fix | Delete
'version' => urlencode(RS_REVISION)
[128] Fix | Delete
);
[129] Fix | Delete
[130] Fix | Delete
if($this->_truefalse(get_option('revslider-valid', 'false')) !== true && version_compare(RS_REVISION, get_option('revslider-stable-version', '4.2'), '<')){ //We'll get the last stable only now!
[131] Fix | Delete
$rattr['get_stable'] = 'true';
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
$request = $rslb->call_url($this->remote_url_info, $rattr, 'updates');
[135] Fix | Delete
[136] Fix | Delete
if(!is_wp_error($request)){
[137] Fix | Delete
if($response = maybe_unserialize($request['body'])){
[138] Fix | Delete
if(is_object($response)){
[139] Fix | Delete
$data = $response;
[140] Fix | Delete
$data->basic->url = $this->plugin_url;
[141] Fix | Delete
$data->full->url = $this->plugin_url;
[142] Fix | Delete
$data->full->external = 1;
[143] Fix | Delete
}
[144] Fix | Delete
}
[145] Fix | Delete
}
[146] Fix | Delete
[147] Fix | Delete
return $data;
[148] Fix | Delete
}
[149] Fix | Delete
[150] Fix | Delete
[151] Fix | Delete
public function _retrieve_version_info(){
[152] Fix | Delete
$rslb = RevSliderGlobals::instance()->get('RevSliderLoadBalancer');
[153] Fix | Delete
$last_check = get_option('revslider-update-check-short');
[154] Fix | Delete
[155] Fix | Delete
// Check for updates
[156] Fix | Delete
if($last_check == false || time() - $last_check > 172800 || $this->force == true){
[157] Fix | Delete
do_action('revslider-retrieve_version_info', $this);
[158] Fix | Delete
update_option('revslider-update-check-short', time());
[159] Fix | Delete
[160] Fix | Delete
$hash = ($this->force === true) ? '' : get_option('revslider-update-hash', '');
[161] Fix | Delete
$purchase = ($this->_truefalse(get_option('revslider-valid', 'false')) === true) ? get_option('revslider-code', '') : '';
[162] Fix | Delete
$data = array(
[163] Fix | Delete
'version' => urlencode(RS_REVISION),
[164] Fix | Delete
'item' => urlencode(RS_PLUGIN_SLUG),
[165] Fix | Delete
'hash' => urlencode($hash),
[166] Fix | Delete
'code' => urlencode($purchase),
[167] Fix | Delete
'addition' => apply_filters('revslider_retrieve_version_info_addition', array())
[168] Fix | Delete
);
[169] Fix | Delete
[170] Fix | Delete
$request = $rslb->call_url($this->remote_url, $data, 'updates');
[171] Fix | Delete
$version_info = wp_remote_retrieve_body($request);
[172] Fix | Delete
[173] Fix | Delete
if(wp_remote_retrieve_response_code($request) != 200 || is_wp_error($version_info)){
[174] Fix | Delete
update_option('revslider-connection', false);
[175] Fix | Delete
return false;
[176] Fix | Delete
}else{
[177] Fix | Delete
update_option('revslider-connection', true);
[178] Fix | Delete
}
[179] Fix | Delete
[180] Fix | Delete
if('actual' != $version_info){
[181] Fix | Delete
$version_info = json_decode($version_info);
[182] Fix | Delete
[183] Fix | Delete
if(isset($version_info->hash)) update_option('revslider-update-hash', $version_info->hash);
[184] Fix | Delete
if(isset($version_info->version)) update_option('revslider-latest-version', $version_info->version);
[185] Fix | Delete
if(isset($version_info->stable)) update_option('revslider-stable-version', $version_info->stable);
[186] Fix | Delete
if(isset($version_info->notices)) update_option('revslider-notices', $version_info->notices);
[187] Fix | Delete
if(isset($version_info->additions)) update_option('revslider-additions', $version_info->additions);
[188] Fix | Delete
if(isset($version_info->addons)){
[189] Fix | Delete
$addons = get_option('revslider-addons', array());
[190] Fix | Delete
$addons = (is_object($addons)) ? (array)$addons : $addons;
[191] Fix | Delete
$addons = (!is_array($addons)) ? json_decode($addons, true) : $addons;
[192] Fix | Delete
[193] Fix | Delete
$cur_addons_count = count($addons);
[194] Fix | Delete
$new_addons_count = count((array)$version_info->addons);
[195] Fix | Delete
if($cur_addons_count < $new_addons_count){
[196] Fix | Delete
$counter = $new_addons_count - $cur_addons_count;
[197] Fix | Delete
update_option('rs-addons-counter', $counter);
[198] Fix | Delete
}
[199] Fix | Delete
[200] Fix | Delete
update_option('revslider-addons', $version_info->addons);
[201] Fix | Delete
}
[202] Fix | Delete
[203] Fix | Delete
if(isset($version_info->deactivated) && $version_info->deactivated === true){
[204] Fix | Delete
if($this->_truefalse(get_option('revslider-valid', 'false')) === true){
[205] Fix | Delete
//remove validation, add notice
[206] Fix | Delete
update_option('revslider-valid', 'false');
[207] Fix | Delete
update_option('revslider-deregister-popup', true);
[208] Fix | Delete
if(isset($version_info->deactivated_msg) && !empty($version_info->deactivated_msg)){
[209] Fix | Delete
update_option('revslider-deregister-message', $version_info->deactivated_msg);
[210] Fix | Delete
}
[211] Fix | Delete
}
[212] Fix | Delete
}
[213] Fix | Delete
}
[214] Fix | Delete
}
[215] Fix | Delete
[216] Fix | Delete
//force that the update will be directly searched
[217] Fix | Delete
if($this->force == true) update_option('revslider-update-check', '');
[218] Fix | Delete
[219] Fix | Delete
return get_option('revslider-latest-version', RS_REVISION);
[220] Fix | Delete
}
[221] Fix | Delete
}
[222] Fix | Delete
[223] Fix | Delete
[224] Fix | Delete
/**
[225] Fix | Delete
* old classname extends new one (old classnames will be obsolete soon)
[226] Fix | Delete
* @since: 5.0
[227] Fix | Delete
**/
[228] Fix | Delete
class UniteUpdateClassRev extends RevSliderUpdate {}
[229] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function