← All changes
|
inc/3rd-party/nextgen-gallery/classes/Context/NGG.php
+20
-0
2.2.8
→
trunk
View file →
| @@ -107,7 +107,27 @@ | ||
| 107 | 107 | default: |
| 108 | 108 | $capacity = $describer; |
| 109 | 109 | } |
| 110 | 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 | |
| 130 | + | |
| 111 | 131 | return $this->filter_capacity( $capacity, $describer ); |
| 112 | 132 | } |
| 113 | 133 | } |