C:\xampp\htdocs\landing\wp-content\plugins\imagify\classes\Context\AbstractContext.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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
<?php
namespace Imagify\Context;

defined'ABSPATH' ) || die( 'Cheatin’ uh?' );

/**
 * Abstract used for contexts.
 *
 * @since  1.9
 * @author Grégory Viguier
 */
abstract class AbstractContext implements ContextInterface {

    
/**
     * Context "short name".
     *
     * @var    string
     * @since  1.9
     * @access protected
     * @author Grégory Viguier
     */
    
protected $context;

    
/**
     * Tell if the media/context is network-wide.
     *
     * @var    bool
     * @since  1.9
     * @access protected
     * @author Grégory Viguier
     */
    
protected $is_network_wide false;

    
/**
     * Type of files this context allows.
     *
     * @var    string Possible values are:
     *     - 'all' to allow all types.
     *     - 'image' to allow only images.
     *     - 'not-image' to allow only pdf files.
     * @since  1.9
     * @access protected
     * @see    imagify_get_mime_types()
     * @author Grégory Viguier
     */
    
protected $allowed_mime_types 'all';

    
/**
     * The thumbnail sizes for this context, except the full size.
     *
     * @var    array {
     *     Data for the currently registered thumbnail sizes.
     *     Size names are used as array keys.
     *
     *     @type int    $width  The image width.
     *     @type int    $height The image height.
     *     @type bool   $crop   True to crop, false to resize.
     *     @type string $name   The size name.
     * }
     * @since  1.9
     * @access protected
     * @author Grégory Viguier
     */
    
protected $thumbnail_sizes;

    
/**
     * Tell if the optimization process is allowed to backup in this context.
     *
     * @var    bool
     * @since  1.9
     * @access protected
     * @author Grégory Viguier
     */
    
protected $can_backup;

    
/**
     * Tell if the optimization process is allowed to keep exif in this context.
     *
     * @var    bool
     * @since  1.9
     * @access protected
     * @author Grégory Viguier
     */
    
protected $can_keep_exif;

    
/**
     * Get the context "short name".
     *
     * @since  1.9
     * @access public
     * @author Grégory Viguier
     *
     * @return string
     */
    
public function get_name() {
        return 
$this->context;
    }

    
/**
     * Tell if the context is network-wide.
     *
     * @since  1.9
     * @access public
     * @author Grégory Viguier
     *
     * @return bool
     */
    
public function is_network_wide() {
        return 
$this->is_network_wide;
    }

    
/**
     * Get the type of files this context allows.
     *
     * @since  1.9
     * @access protected
     * @see    imagify_get_mime_types()
     * @author Grégory Viguier
     *
     * @return string Possible values are:
     *                - 'all' to allow all types.
     *                - 'image' to allow only images.
     *                - 'not-image' to allow only pdf files.
     */
    
public function get_allowed_mime_types() {
        return 
$this->allowed_mime_types;
    }

    
/**
     * Get the thumbnail sizes for this context, except the full size.
     *
     * @since  1.9
     * @access public
     * @author Grégory Viguier
     *
     * @return array {
     *     Data for the currently registered thumbnail sizes.
     *     Size names are used as array keys.
     *
     *     @type int    $width  The image width.
     *     @type int    $height The image height.
     *     @type bool   $crop   True to crop, false to resize.
     *     @type string $name   The size name.
     * }
     */
    
public function get_thumbnail_sizes() {
        return 
$this->thumbnail_sizes;
    }

    
/**
     * Tell if the optimization process is allowed resize in this context.
     *
     * @since  1.9
     * @access public
     * @author Grégory Viguier
     *
     * @return bool
     */
    
public function can_resize() {
        return 
$this->get_resizing_threshold() > 0;
    }

    
/**
     * Tell if the optimization process is allowed to backup in this context.
     *
     * @since  1.9
     * @access public
     * @author Grégory Viguier
     *
     * @return bool
     */
    
public function can_backup() {
        return 
$this->can_backup;
    }

    
/**
     * Tell if the optimization process is allowed to keep exif in this context.
     *
     * @since  1.9
     * @access public
     * @author Grégory Viguier
     *
     * @return bool
     */
    
public function can_keep_exif() {
        return 
$this->can_keep_exif;
    }

    
/**
     * Tell if the current user is allowed to operate Imagify in this context.
     *
     * @since  1.9
     * @access public
     * @author Grégory Viguier
     *
     * @param  string $describer Capacity describer. See $this->get_capacity() for possible values. Can also be a "real" user capacity.
     * @param  int    $media_id  A media ID.
     * @return bool
     */
    
public function current_user_can$describer$media_id null ) {
        return 
$this->user_cannull$describer$media_id );
    }

    
/**
     * Tell if a user is allowed to operate Imagify in this context.
     *
     * @since  1.9
     * @access public
     * @author Grégory Viguier
     *
     * @param  int|\WP_User $user_id   A user ID or \WP_User object. Fallback to the current user ID.
     * @param  string       $describer Capacity describer. See $this->get_capacity() for possible values. Can also be a "real" user capacity.
     * @param  int          $media_id  A media ID.
     * @return bool
     */
    
public function user_can$user_id$describer$media_id null ) {
        
$current_user_id get_current_user_id();

        if ( ! 
$user_id ) {
            
$user    $current_user_id;
            
$user_id $current_user_id;
        } elseif ( 
$user_id instanceof \WP_User ) {
            
$user    $user_id;
            
$user_id = (int) $user->ID;
        } elseif ( 
is_numeric$user_id ) ) {
            
$user    = (int) $user_id;
            
$user_id $user;
        } else {
            
$user_id 0;
        }

        if ( ! 
$user_id ) {
            return 
false;
        }

        
$media_id $media_id ? (int) $media_id null;
        
$capacity $this->get_capacity$describer );

        if ( 
$user_id === $current_user_id ) {
            
$user_can current_user_can$capacity$media_id );

            
/**
             * Tell if the current user is allowed to operate Imagify in this context.
             *
             * @since 1.6.11
             * @since 1.9 Added the context name as parameter.
             *
             * @param bool   $user_can  Tell if the current user is allowed to operate Imagify in this context.
             * @param string $capacity  The user capacity.
             * @param string $describer Capacity describer. See $this->get_capacity() for possible values. Can also be a "real" user capacity.
             * @param int    $media_id  A media ID.
             * @param string $context   The context name.
             */
            
$user_can = (bool) apply_filters'imagify_current_user_can'$user_can$capacity$describer$media_id$this->get_name() );
        } else {
            
$user_can user_can$user$capacity$media_id );
        }

        
/**
         * Tell if the given user is allowed to operate Imagify in this context.
         *
         * @since  1.9
         * @author Grégory Viguier
         *
         * @param bool   $user_can  Tell if the given user is allowed to operate Imagify in this context.
         * @param int    $user_id   The user ID.
         * @param string $capacity  The user capacity.
         * @param string $describer Capacity describer. See $this->get_capacity() for possible values. Can also be a "real" user capacity.
         * @param int    $media_id  A media ID.
         * @param string $context   The context name.
         */
        
return (bool) apply_filters'imagify_user_can'$user_can$user_id$capacity$describer$media_id$this->get_name() );
    }

    
/**
     * Filter a user capacity used to operate Imagify in this context.
     *
     * @since  1.9
     * @access protected
     * @author Grégory Viguier
     *
     * @param  string $capacity  The user capacity.
     * @param  string $describer Capacity describer. Possible values are like 'manage', 'bulk-optimize', 'manual-optimize', 'auto-optimize'.
     * @return string
     */
    
protected function filter_capacity$capacity$describer ) {
        
/**
         * Filter a user capacity used to operate Imagify in this context.
         *
         * @since 1.0
         * @since 1.6.5  Added $force_mono parameter.
         * @since 1.6.11 Replaced $force_mono by $describer.
         * @since 1.9    Added the context name as parameter.
         *
         * @param string $capacity  The user capacity.
         * @param string $describer Capacity describer. Possible values are like 'manage', 'bulk-optimize', 'manual-optimize', 'auto-optimize'.
         * @param string $context   The context name.
         */
        
return (string) apply_filters'imagify_capacity'$capacity$describer$this->get_name() );
    }
}
x

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