PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / trunk
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF vtrunk
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
← All changes | inc/3rd-party/nextgen-gallery/classes/Context/NGG.php +24 -19 1.10 → trunk View file →
@@ -1,8 +1,9 @@
1 1 <?php
2 2 namespace Imagify\ThirdParty\NGG\Context;
3 3
4 -defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
4 +use Imagify\Context\AbstractContext;
5 +use Imagify\Traits\InstanceGetterTrait;
5 6
6 7 /**
7 8 * Context class used for the WP media library.
8 9 *
@@ -8,10 +9,10 @@
8 9 *
9 10 * @since 1.9
10 11 * @author Grégory Viguier
11 12 */
12 -class NGG extends \Imagify\Context\AbstractContext {
13 - use \Imagify\Traits\InstanceGetterTrait;
13 +class NGG extends AbstractContext {
14 + use InstanceGetterTrait;
14 15
15 16 /**
16 17 * Context "short name".
17 18 *
@@ -16,9 +17,8 @@
16 17 * Context "short name".
17 18 *
18 19 * @var string
19 20 * @since 1.9
20 - * @access protected
21 21 * @author Grégory Viguier
22 22 */
23 23 protected $context = 'ngg';
24 24
@@ -29,9 +29,8 @@
29 29 * - 'all' to allow all types.
30 30 * - 'image' to allow only images.
31 31 * - 'not-image' to allow only pdf files.
32 32 * @since 1.9
33 - * @access protected
34 33 * @see imagify_get_mime_types()
35 34 * @author Grégory Viguier
36 35 */
37 36 protected $allowed_mime_types = 'image';
@@ -48,9 +47,8 @@
48 47 * @type bool $crop True to crop, false to resize.
49 48 * @type string $name The size name.
50 49 * }
51 50 * @since 1.9
52 - * @access public
53 51 * @author Grégory Viguier
54 52 */
55 53 protected $thumbnail_sizes = [];
56 54
@@ -58,29 +56,17 @@
58 56 * Tell if the optimization process is allowed to backup in this context.
59 57 *
60 58 * @var bool
61 59 * @since 1.9
62 - * @access protected
63 60 * @author Grégory Viguier
64 61 */
65 62 protected $can_backup = true;
66 63
67 64 /**
68 - * Tell if the optimization process is allowed to keep exif in this context.
69 - *
70 - * @var bool
71 - * @since 1.9
72 - * @access protected
73 - * @author Grégory Viguier
74 - */
75 - protected $can_keep_exif = true;
76 -
77 - /**
78 65 * Get images max width for this context. This is used when resizing.
79 66 * 0 means to not resize.
80 67 *
81 68 * @since 1.9.8
82 - * @access public
83 69 * @author Grégory Viguier
84 70 *
85 71 * @return int
86 72 */
@@ -91,9 +77,8 @@
91 77 /**
92 78 * Get user capacity to operate Imagify in this context.
93 79 *
94 80 * @since 1.9
95 - * @access public
96 81 * @author Grégory Viguier
97 82 *
98 83 * @param string $describer Capacity describer. Possible values are like 'manage', 'bulk-optimize', 'manual-optimize', 'auto-optimize'.
99 84 * @return string
@@ -121,8 +106,28 @@
121 106
122 107 default:
123 108 $capacity = $describer;
124 109 }
110 +
111 + // NGG v4 may not register the v3 custom capabilities. Fall back to 'manage_options' so
112 + // the submenu and bulk page remain accessible to site administrators on v4.
113 + // @codeCoverageIgnoreStart — requires live NGG v4 class; not available in unit tests.
114 + if ( class_exists( 'Imagely\NGG\Admin\App' ) && ! get_role( $capacity ) && ! wp_roles()->is_role( $capacity ) ) {
115 + $wp_roles = wp_roles();
116 + $has_cap = false;
117 +
118 + foreach ( $wp_roles->roles as $role_data ) {
119 + if ( ! empty( $role_data['capabilities'][ $capacity ] ) ) {
120 + $has_cap = true;
121 + break;
122 + }
123 + }
124 +
125 + if ( ! $has_cap ) {
126 + $capacity = 'manage_options';
127 + }
128 + }
129 + // @codeCoverageIgnoreEnd
125 130
126 131 return $this->filter_capacity( $capacity, $describer );
127 132 }
128 133 }