Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
CRAP | n/a |
0 / 0 |
|
| wpcomsh_extend_stats_menu_item_access | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Jetpack Stats. |
| 4 | * |
| 5 | * @package wpcomsh |
| 6 | */ |
| 7 | |
| 8 | /** |
| 9 | * Extends the default value for which roles can access the Stats menu item. |
| 10 | * |
| 11 | * This enables the `view_stats` capability to work with all roles that are available on Simple sites. |
| 12 | * |
| 13 | * @see https://github.com/Automattic/jetpack/pull/33255 |
| 14 | * @see Automattic\Jetpack\Stats\Options::get_defaults() |
| 15 | * |
| 16 | * @param array $default_value The default value for stats options. |
| 17 | * @return array |
| 18 | */ |
| 19 | function wpcomsh_extend_stats_menu_item_access( $default_value ) { |
| 20 | if ( is_array( $default_value ) ) { |
| 21 | $default_value['roles'] = array( 'administrator', 'editor', 'author', 'contributor' ); |
| 22 | } |
| 23 | |
| 24 | return $default_value; |
| 25 | } |
| 26 | add_filter( 'default_option_stats_options', 'wpcomsh_extend_stats_menu_item_access' ); |