PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 2.0
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v2.0
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / classes / Context / CustomFolders.php

CustomFolders.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 2.0, at classes/Context/CustomFolders.php

103 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Imagify\Context;
3
4 use \Imagify\Traits\InstanceGetterTrait;
5
6 /**
7 * Context class used for the custom folders.
8 *
9 * @since 1.9
10 * @author Grégory Viguier
11 */
12 class CustomFolders extends AbstractContext {
13 use InstanceGetterTrait;
14
15 /**
16 * Context "short name".
17 *
18 * @var string
19 * @since 1.9
20 * @author Grégory Viguier
21 */
22 protected $context = 'custom-folders';
23
24 /**
25 * The thumbnail sizes for this context, except the full size.
26 *
27 * @var array {
28 * Data for the currently registered thumbnail sizes.
29 * Size names are used as array keys.
30 *
31 * @type int $width The image width.
32 * @type int $height The image height.
33 * @type bool $crop True to crop, false to resize.
34 * @type string $name The size name.
35 * }
36 * @since 1.9
37 * @author Grégory Viguier
38 */
39 protected $thumbnail_sizes = [];
40
41 /**
42 * Get images max width for this context. This is used when resizing.
43 * 0 means to not resize.
44 *
45 * @since 1.9.8
46 * @author Grégory Viguier
47 *
48 * @return int
49 */
50 public function get_resizing_threshold() {
51 return 0;
52 }
53
54 /**
55 * Tell if the optimization process is allowed to backup in this context.
56 *
57 * @since 1.9
58 * @author Grégory Viguier
59 *
60 * @return bool
61 */
62 public function can_backup() {
63 if ( isset( $this->can_backup ) ) {
64 return $this->can_backup;
65 }
66
67 $this->can_backup = get_imagify_option( 'backup' );
68
69 return $this->can_backup;
70 }
71
72 /**
73 * Get user capacity to operate Imagify in this context.
74 *
75 * @since 1.9
76 * @author Grégory Viguier
77 *
78 * @param string $describer Capacity describer. Possible values are like 'manage', 'bulk-optimize', 'manual-optimize', 'auto-optimize'.
79 * @return string
80 */
81 public function get_capacity( $describer ) {
82 switch ( $describer ) {
83 case 'manage':
84 $capacity = imagify_is_active_for_network() ? 'manage_network_options' : 'manage_options';
85 break;
86
87 case 'bulk-optimize':
88 case 'optimize':
89 case 'restore':
90 case 'manual-optimize':
91 case 'manual-restore':
92 case 'auto-optimize':
93 $capacity = is_multisite() ? 'manage_network_options' : 'manage_options';
94 break;
95
96 default:
97 $capacity = $describer;
98 }
99
100 return $this->filter_capacity( $capacity, $describer );
101 }
102 }
103