C:\xampp\htdocs\landing\wp-content\updraft\plugins-old\imagify\inc\functions\api.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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
<?php
defined
'ABSPATH' ) || die( 'Cheatin’ uh?' );

/**
 * Returns the main instance of the Imagify class.
 *
 * @since  1.6.5
 * @author Grégory Viguier
 *
 * @return object The Imagify instance.
 */
function imagify() {
    return 
Imagify::get_instance();
}

/**
 * Create a new user on Imagify.
 *
 * @param  array $data All user data.
 * @return object
 */
function add_imagify_user$data ) {
    return 
imagify()->create_user$data );
}

/**
 * Update your Imagify account.
 *
 * @param  string $data All user data.
 * @return object
 */
function update_imagify_user$data ) {
    return 
imagify()->update_user$data );
}

/**
 * Get your Imagify account infos.
 *
 * @return object
 */
function get_imagify_user() {
    return 
imagify()->get_user();
}

/**
 * Get the Imagify API version.
 *
 * @return object
 */
function get_imagify_api_version() {
    return 
imagify()->get_api_version();
}

/**
 * Check your Imagify API key status.
 *
 * @param  string $data An API key.
 * @return bool
 */
function get_imagify_status$data ) {
    return 
imagify()->get_status$data );
}

/**
 * Optimize an image by uploading it on Imagify.
 *
 * @param  array $data All image data.
 * @return object
 */
function fetch_imagify_image$data ) {
    return 
imagify()->fetch_image$data );
}

/**
 * Optimize an image by sharing its URL on Imagify.
 *
 * @since 1.6.7 $data['image'] can contain the file path (prefered) or the result of `curl_file_create()`.
 *
 * @param  array $data All image data.
 * @return object
 */
function upload_imagify_image$data ) {
    return 
imagify()->upload_image$data );
}

/**
 * Get Imagify Plans Prices.
 *
 * @since  1.5
 * @author Geoffrey Crofte
 *
 * @return object
 */
function get_imagify_plans_prices() {
    return 
imagify()->get_plans_prices();
}

/**
 * Get Imagify Plans Prices.
 *
 * @since  1.5
 * @author Geoffrey Crofte
 *
 * @return object
 */
function get_imagify_packs_prices() {
    return 
imagify()->get_packs_prices();
}

/**
 * Get Imagify All Prices (plan & packs).
 *
 * @since  1.5.4
 * @author Geoffrey Crofte
 *
 * @return object
 */
function get_imagify_all_prices() {
    return 
imagify()->get_all_prices();
}

/**
 * Check if Coupon Code exists.
 *
 * @since  1.6
 * @author Geoffrey Crofte
 *
 * @param  string $coupon the coupon code to check.
 * @return object
 */
function check_imagify_coupon_code$coupon ) {
    return 
imagify()->check_coupon_code$coupon );
}

/**
 * Check if Discount/Promotion is available.
 *
 * @since  1.6.3
 * @author Geoffrey Crofte
 *
 * @return object
 */
function check_imagify_discount() {
    return 
imagify()->check_discount();
}

/**
 * Get Maximum image size for free plan.
 *
 * @since  1.5.6
 * @author Remy Perona
 *
 * @return string
 */
function get_imagify_max_image_size() {
    
$max_image_size get_transient'imagify_max_image_size' );

    if ( 
false === $max_image_size ) {
        
$max_image_size imagify()->get_public_info();

        if ( ! 
is_wp_error$max_image_size ) ) {
            
$max_image_size $max_image_size->max_image_size;
            
set_transient'imagify_max_image_size'$max_image_sizeHOUR_IN_SECONDS );
        }
    }

    return 
$max_image_size;
}

/**
 * Translate a message from our servers.
 *
 * @since  1.6.10
 * @author Grégory Viguier
 * @see    Imagify::curl_http_call()
 * @see    Imagify::handle_response()
 *
 * @param  string $message The message from the server (in English).
 * @return string          If in our list, the translated message. The original message otherwise.
 */
function imagify_translate_api_message$message ) {
    if ( ! 
$message ) {
        return 
imagify_translate_api_message'Unknown error occurred' );
    }

    if ( 
is_wp_error$message ) ) {
        if ( 
$message->errors ) {
            foreach ( (array) 
$message->errors as $code => $messages ) {
                if ( 
$messages ) {
                    
$message->errors$code ] = array_map'imagify_translate_api_message', (array) $messages );
                }
            }
        }

        return 
$message;
    }

    if ( 
is_object$message ) && ! empty( $message->detail ) ) {
        
$message->detail imagify_translate_api_message$message->detail );
    }

    if ( ! 
is_string$message ) ) {
        return 
$message;
    }

    
$trim_message trim$message'. ' );

    
$messages = array(
        
// Local messages from Imagify::curl_http_call() and Imagify::handle_response().
        
'Could not initialize a new cURL handle'                                                   => __'Could not initialize a new cURL handle.''imagify' ),
        
'Unknown error occurred'                                                                   => __'Unknown error occurred.''imagify' ),
        
'Your image is too big to be uploaded on our server'                                       => __'Your file is too big to be uploaded on our server.''imagify' ),
        
'Our server returned an invalid response'                                                  => __'Our server returned an invalid response.''imagify' ),
        
'cURL isn\'t installed on the server'                                                      => __'cURL is not available on the server.''imagify' ),
        
// API messages.
        
'Authentification not provided'                                                            => __'Authentication not provided.''imagify' ),
        
'Cannot create client token'                                                               => __'Cannot create client token.''imagify' ),
        
'Confirm your account to continue optimizing image'                                        => __'Confirm your account to continue optimizing files.''imagify' ),
        
'Coupon doesn\'t exist'                                                                    => __'Coupon does not exist.''imagify' ),
        
'Email field shouldn\'t be empty'                                                          => __'Email field should not be empty.''imagify' ),
        
'Email or Password field shouldn\'t be empty'                                              => __'This account already exists.''imagify' ),
        
'Error uploading to data Storage'                                                          => __'Error uploading to Data Storage.''imagify' ),
        
'Not able to connect to Data Storage API to get the token'                                 => __'Unable to connect to Data Storage API to get the token.''imagify' ),
        
'Not able to connect to Data Storage API'                                                  => __'Unable to connect to Data Storage API.''imagify' ),
        
'Not able to retrieve the token from DataStorage API'                                      => __'Unable to retrieve the token from Data Storage API.''imagify' ),
        
'This email is already registered, you should try another email'                           => __'This email is already registered, you should try another email.''imagify' ),
        
'This user doesn\'t exit'                                                                  => __'This user does not exist.''imagify' ),
        
'Too many request, be patient'                                                             => __'Too many requests, please be patient.''imagify' ),
        
'Unable to regenerate access token'                                                        => __'Unable to regenerate access token.''imagify' ),
        
'User not valid'                                                                           => __'User not valid.''imagify' ),
        
'WELL DONE. This image is already compressed, no further compression required'             => __'WELL DONE. This media file is already optimized, no further optimization is required.''imagify' ),
        
'You are not authorized to perform this action'                                            => __'You are not authorized to perform this action.''imagify' ),
        
'You\'ve consumed all your data. You have to upgrade your account to continue'             => __'You have consumed all your data. You have to upgrade your account to continue.''imagify' ),
        
'Invalid token'                                                                            => __'Invalid API key''imagify' ),
        
'Upload a valid image. The file you uploaded was either not an image or a corrupted image' => __'Invalid or corrupted file.''imagify' ),
    );

    if ( isset( 
$messages$trim_message ] ) ) {
        return 
$messages$trim_message ];
    }

    
// Local message.
    
if ( preg_match'@^(?:Unknown|An) error occurred \((.+)\)$@'$trim_message$matches ) ) {
        
/* translators: %s is an error message. */
        
return sprintf__'An error occurred (%s).''imagify' ), esc_htmlwp_strip_all_tags$matches[1] ) ) );
    }

    
// Local message.
    
if ( preg_match'@^Our server returned an error \((.+)\)$@'$trim_message$matches ) ) {
        
/* translators: %s is an error message. */
        
return sprintf__'Our server returned an error (%s).''imagify' ), esc_htmlwp_strip_all_tags$matches[1] ) ) );
    }

    
// API message.
    
if ( preg_match'@^Custom one time plan starts from (\d+) MB$@'$trim_message$matches ) ) {
        
/* translators: %s is a formatted number, dont use %d. */
        
return sprintf__'Custom One Time plan starts from %s MB.''imagify' ), number_format_i18n( (int) $matches[1] ) );
    }

    
// API message.
    
if ( preg_match'@^(.*) is not a valid extension$@'$trim_message$matches ) ) {
        
/* translators: %s is a file extension. */
        
return sprintf__'%s is not a valid extension.''imagify' ), sanitize_text_field$matches[1] ) );
    }

    
// API message.
    
if ( preg_match'@^Request was throttled\. Expected available in ([\d.]+) second$@'$trim_message$matches ) ) {
        
/* translators: %s is a float number. */
        
return sprintf_n'Request was throttled. Expected available in %s second.''Request was throttled. Expected available in %s seconds.', (int) $matches[1], 'imagify' ), sanitize_text_field$matches[1] ) );
    }

    return 
$message;
}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586