/var/www/html_us/wp-content/plugins/revslider/admin/includes/addons.class.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
<?php
/**
 * @author    ThemePunch <[email protected]>
 * @link      https://www.themepunch.com/
 * @copyright 2024 ThemePunch
 */

if(!defined('ABSPATH')) exit();

class 
RevSliderAddons extends RevSliderFunctions //before: Rev_addon_Admin
    //private $addon_version_required = '2.0.0'; //this holds the globally needed addon version for the current RS version
    
    
private $addon_version_required = array(
        
'revslider-404-addon'                => '2.0.0',
        
'revslider-backup-addon'            => '2.0.0',
        
'revslider-featured-addon'            => '2.0.0',
        
'revslider-gallery-addon'            => '2.0.0',
        
'revslider-login-addon'                => '2.0.0',
        
'revslider-prevnext-posts-addon'    => '2.0.0',
        
'revslider-rel-posts-addon'            => '2.0.0',
        
        
'revslider-beforeafter-addon'        => '6.7.0',
        
'revslider-bubblemorph-addon'        => '6.7.0',
        
'revslider-charts-addon'            => '6.7.0',
        
'revslider-duotonefilters-addon'    => '6.7.0',
        
'revslider-explodinglayers-addon'    => '6.7.0',
        
'revslider-filmstrip-addon'            => '6.7.0',
        
'revslider-fluiddynamics-addon'        => '6.7.0',
        
'revslider-liquideffect-addon'        => '6.7.0',
        
'revslider-lottie-addon'            => '6.7.0',
        
'revslider-maintenance-addon'        => '6.7.0',
        
'revslider-mousetrap-addon'            => '6.7.0',
        
'revslider-paintbrush-addon'        => '6.7.0',
        
'revslider-panorama-addon'            => '6.7.0',
        
'revslider-particles-addon'            => '6.7.0',
        
'revslider-particlewave-addon'        => '6.7.0',
        
'revslider-polyfold-addon'            => '6.7.0',
        
'revslider-refresh-addon'            => '6.7.0',
        
'revslider-revealer-addon'            => '6.7.0',
        
'revslider-scrollvideo-addon'        => '6.7.0',
        
'revslider-sharing-addon'            => '6.7.0',
        
'revslider-slicey-addon'            => '6.7.0',
        
'revslider-snow-addon'                => '6.7.0',
        
'revslider-thecluster-addon'        => '6.7.0',
        
'revslider-transitionpack-addon'    => '6.7.0',
        
'revslider-typewriter-addon'        => '6.7.0',
        
'revslider-weather-addon'            => '6.7.0',
        
'revslider-whiteboard-addon'        => '6.7.0',
    );
    
    public function 
__construct(){
        include_once(
ABSPATH 'wp-admin/includes/plugin.php');
    }
    
    
/**
     * get all the addons with information
     **/
    
public function get_addon_list(){

        
$addons    get_option('revslider-addons');
        
$addons    = (array)$addons;
        
$addons array_reverse($addonstrue);
        
$plugins get_plugins();
        
        if(!empty(
$addons)){
            foreach(
$addons as $k => $addon){
                if(!
is_object($addon)) continue;
                if(
array_key_exists($addon->slug.'/'.$addon->slug.'.php'$plugins)){
                    
$addons[$k]->full_title    $plugins[$addon->slug.'/'.$addon->slug.'.php']['Name'];
                    
$addons[$k]->active is_plugin_active($addon->slug.'/'.$addon->slug.'.php');
                    
$addons[$k]->installed    $plugins[$addon->slug.'/'.$addon->slug.'.php']['Version'];
                }else{
                    
$addons[$k]->active false;
                    
$addons[$k]->installed    false;
                }
            }
        }
        
        return 
$addons;
    }
    
    
/**
     * get a specific addon version
     **/
    
public function get_addon_version($handle){
        
$list $this->get_addon_list();
        return 
$this->get_val($list, array($handle'installed'), false);
    }

    
/**
     * check if any addon is below version x (for RS6.0 this is version 2.0)
     * if yes give a message that tells to update
     **/
    
public function check_addon_version(){
        
$rs_addons    $this->get_addon_list();
        
$update        = array();
        
        if(!empty(
$rs_addons)){
            foreach(
$rs_addons as $handle => $addon){
                
$installed $this->get_val($addon'installed');
                if(
trim($installed) === '') continue;
                if(
$this->get_val($addon'active'false) === false) continue;
                
                
$version $this->get_val($this->addon_version_required$handlefalse);
                if(
$version !== false && version_compare($installed$version'<')){
                    
$available = (version_compare($version$this->get_val($addon'available'), '>')) ? $version $this->get_val($addon'available');
                    
$update[$handle] = array(
                        
'title' => $this->get_val($addon'full_title'),
                        
'old'    => $installed,
                        
'new'    => $available,
                        
'status'=> '1' //1 is mandatory to use it
                    
);
                }
            }
        }
        
        return 
$update;
    }
    
    
/**
     * Install Add-On/Plugin
     *
     * @since 6.0
     */
    
public function install_addon($addon$force false){
        if(
$this->_truefalse(get_option('revslider-valid''false')) !== true) return __('Please activate Slider Revolution''revslider');
        
        
//check if downloaded already
        
$plugins    get_plugins();
        
$addon_path $addon.'/'.$addon.'.php';
        if(!
array_key_exists($addon_path$plugins) || $force == true || !file_exists(WP_PLUGIN_DIR.'/'.$addon_path)){
            
//download if nessecary
            
return $this->download_addon($addon);
        }
        
        
//activate 
        
$activate $this->activate_addon($addon_path);
        
        return 
$activate;
    }
    
    
/**
     * Download Add-On/Plugin
     *
     * @since    1.0.0
     */
    
public function download_addon($addon){
        global 
$rslb;
        
        if(
$this->_truefalse(get_option('revslider-valid''false')) !== true) return __('Please activate Slider Revolution''revslider');
        
        
$plugin_slug    basename($addon);
        if(
!== strpos($plugin_slug'revslider-')) die( '-1' );

        
$code get_option('revslider-code''');
        
        
$done    false;
        
$count    0;
        
$rattr    = array(
            
'code'        => urlencode($code),
            
'version'    => urlencode(RS_REVISION),
            
'product'    => urlencode(RS_PLUGIN_SLUG),
            
'type'        => urlencode($plugin_slug)
        );
        
        do{    
            
$url 'addons/'.$plugin_slug.'/download.php';
            
$get $rslb->call_url($url$rattr'updates');
            
            if(
wp_remote_retrieve_response_code($get) == 200){
                
$done true;
            }else{
                
$rslb->move_server_list();
            }
            
            
$count++;
        }while(
$done == false && $count 5);
        
        if(
$get && $get['body'] != 'invalid' && wp_remote_retrieve_response_code($get) == 200){
            
$upload_dir    wp_upload_dir();
            
$file        $upload_dir['basedir']. '/revslider/templates/' $plugin_slug '.zip';
            @
mkdir(dirname($file), 0777true);
            
$ret        = @file_put_contents($file$get['body']);
            
            require_once(
ABSPATH 'wp-admin/includes/class-wp-filesystem-base.php');
            require_once(
ABSPATH 'wp-admin/includes/class-wp-filesystem-direct.php');
            
$fsd = new WP_Filesystem_Direct(false);
            
WP_Filesystem();
            
            global 
$wp_filesystem;

            
$upload_dir    wp_upload_dir();
            
$d_path        WP_PLUGIN_DIR;
            
$fsd->rmdir($d_path '/' $plugin_slugtrue); //remove the addon folder if exists

            
$unzipfile    unzip_file($file$d_path);

            if(
is_wp_error($unzipfile)){
                
define('FS_METHOD''direct'); //lets try direct. 

                
WP_Filesystem();  //WP_Filesystem() needs to be called again since now we use direct !

                //@chmod($file, 0775);
                
$unzipfile unzip_file($file$d_path);
                if(
is_wp_error($unzipfile)){
                    
$d_path WP_PLUGIN_DIR;
                    
$unzipfile unzip_file($file$d_path);
                    
                    if(
is_wp_error($unzipfile)){
                        
$f        basename($file);
                        
$d_path str_replace($f''$file);

                        
$unzipfile unzip_file($file$d_path);
                    }
                }
            }
            
            @
unlink($file);
            return 
true;
        }
        
        
//$result = activate_plugin( $plugin_slug.'/'.$plugin_slug.'.php' );
        
return false;
    }
    
    
/**
     * Activates Installed Add-On/Plugin
     *
     * @since    1.0.0
     */
    
public function activate_addon($addon){
        
// Verify that the incoming request is coming with the security nonce
        
if(isset($addon)){
            
$result activate_plugin($addon);
            if(
is_wp_error($result)){
                
// Process Error
                
return false;
            }
        }else{
            return 
false;
        }
        
        return 
true;
    }

    
/**
     * Deactivates Installed Add-On/Plugin
     *
     * @since    1.0.0
     */
    
public function deactivate_addon($addon){
        
// Verify that the incoming request is coming with the security nonce
        
deactivate_plugins($addon);
        return 
true;
    }
}

class 
Rev_addon_Admin extends RevSliderAddons {}