/var/www/hkosl.com/aga/wp-content/plugins/smart-slider-3/nextend/wordpress/platform.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
<?php

class N2Platform {

    public static 
$isAdmin false;

    public static 
$hasPosts true$isJoomla false$isWordpress false$isMagento false$isNative false;

    public static 
$name;

    private static 
$needCredentials false;

    public static function 
init() {
        
self::$isWordpress get_bloginfo('version');
        if (
basename($_SERVER['PHP_SELF']) == 'admin.php') {
            
self::$isAdmin true;
        }
    }

    public static function 
getSiteUrl() {
        return 
str_replace(array(
            
'http://',
            
'https://'
        
), '//'site_url('/'));
    }

    public static function 
getPlatform() {
        return 
'wordpress';
    }

    public static function 
getPlatformName() {
        return 
'WordPress';
    }

    public static function 
getPlatformVersion() {
        global 
$wp_version;

        return 
$wp_version;
    }

    public static function 
getCharset() {
        return 
get_option('blog_charset');
    }

    public static function 
getDate() {
        return 
current_time('mysql');
    }

    public static function 
getTime() {
        return 
current_time('timestamp');
    }

    public static function 
getPublicDir() {
        
$upload_dir wp_upload_dir();

        return 
N2Filesystem::fixPathSeparator(str_replace('//''/'$upload_dir['basedir']));
    }

    public static function 
getUserEmail() {
        return 
wp_get_current_user()->user_email;
    }

    public static function 
needStrongerCSS() {
        static 
$need null;
        if (
$need === null) {
            if (!
N2Platform::$isAdmin && function_exists('et_is_builder_plugin_active') && et_is_builder_plugin_active()) {
                
$need true;
            }
            if (
$need === null) {
                
$need false;
            }
        }

        return 
$need;
    }

    public static function 
adminHideCSS() {
        echo 
'
            html {
                background: #ffffff;
            }

            html.wp-toolbar {
                padding: 0;
            }

            #wpadminbar,
            #adminmenuwrap,
            #adminmenuback,
            .update-nag{
                display: none !important;
            }

            #wpcontent {
                margin: 0 !important;
                padding-left: 0;
                padding-right: 0;
            }
        '
;
    }

    public static function 
updateFromZip($fileRaw$updateInfo) {

        
add_filter('fs_ftp_connection_types', array(
            
'N2Platform',
            
'isFTPCredentialsNeeded'
        
));

        
N2Loader::import('libraries.zip.reader');

        
$tmpHandle tmpfile();
        
fwrite($tmpHandle$fileRaw);
        
$metaData    stream_get_meta_data($tmpHandle);
        
$tmpFilename $metaData['uri'];

        
$_GET['plugins'] = $updateInfo['plugin'];
        include_once 
ABSPATH 'wp-admin/includes/class-wp-upgrader.php';
        
$upgrader = new Plugin_Upgrader(new Plugin_Upgrader_Skin(compact('title''nonce''url''plugin')));

        
$upgrader->init();
        
$upgrader->upgrade_strings();

        
add_filter('upgrader_pre_install', array(
            
$upgrader,
            
'deactivate_plugin_before_upgrade'
        
), 102);
        
add_filter('upgrader_clear_destination', array(
            
$upgrader,
            
'delete_old_plugin'
        
), 104);

        
$upgrader->run(array(
            
'package'           => $tmpFilename,
            
'destination'       => WP_PLUGIN_DIR,
            
'clear_destination' => true,
            
'clear_working'     => true,
            
'hook_extra'        => array(
                
'plugin' => $updateInfo['plugin'],
                
'type'   => 'plugin',
                
'action' => 'update',
            ),
        ));

        
// Cleanup our hooks, in case something else does a upgrade on this connection.
        
remove_filter('upgrader_pre_install', array(
            
$upgrader,
            
'deactivate_plugin_before_upgrade'
        
));
        
remove_filter('upgrader_clear_destination', array(
            
$upgrader,
            
'delete_old_plugin'
        
));

        if (
self::$needCredentials) {
            
fclose($tmpHandle);

            return 
'CREDENTIALS';
        }

        
// Force refresh of plugin update information
        
wp_clean_plugins_cache(true);
        
fclose($tmpHandle);

        include(
ABSPATH 'wp-admin/admin-footer.php');

        return 
true;
    }

    public static function 
isFTPCredentialsNeeded($types) {
        
self::$needCredentials true;

        return 
$types;
    }

    public static function 
getDebug() {
        
$debug = array('');


        
$debug[] = 'Path to uri:';
        
$uris    N2Uri::getUris();
        
$paths   N2Filesystem::getPaths();
        foreach (
$uris AS $i => $uri) {
            
$debug[] = $paths[$i] . ' => ' $uri;
        }

        
$debug[] = '';
        
$debug[] = 'wp_upload_dir() => ';
        foreach (
wp_upload_dir() AS $k => $v) {
            
$debug[] = $k ': ' $v;
        }
        
$debug[] = '<=';
        
$debug[] = '';

        
$theme       wp_get_theme();
        
$parentTheme $theme->parent();
        if (
$parentTheme) {
            
$debug[] = 'Parent theme: ' $theme->get('Name') . " is version " $theme->get('Version');
        }
        
$debug[] = 'Theme: ' $theme->get('Name') . " is version " $theme->get('Version');


        
$plugins   get_plugins();
        
$notActive = array();

        
$debug[] = '';
        
$debug[] = 'Activated Plugins:';
        foreach (
$plugins AS $plugin => $pluginData) {
            if (
is_plugin_active($plugin)) {
                
$debug[] = ' - ' $plugin ' - ' $pluginData['Version'] . ' - ' $pluginData['Name'];
            } else {
                
$notActive[$plugin] = $pluginData;
            }
        }

        
$debug[] = '';
        
$debug[] = '';
        
$debug[] = 'NOT Activated Plugins:';
        foreach (
$notActive AS $plugin => $pluginData) {
            
$debug[] = ' - ' $plugin ' - ' $pluginData['Version'] . ' - ' $pluginData['Name'];
        }

        return 
$debug;
    }

}

N2Platform::init();