PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 All 507 releases
jetpack / jetpack_vendor / automattic / jetpack-my-jetpack / src / class-feature-visibility.php

class-feature-visibility.php in Jetpack – WP Security, Backup, Speed, & Growth 16.3-beta, at jetpack_vendor/automattic/jetpack-my-jetpack/src/class-feature-visibility.php

61 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Resolves which items a host keeps off the My Jetpack Features page.
4 *
5 * @package automattic/my-jetpack
6 */
7
8 namespace Automattic\Jetpack\My_Jetpack;
9
10 use Automattic\Jetpack\Admin_UI\Admin_Menu;
11 use Automattic\Jetpack\Feature_Policy;
12
13 /**
14 * The Features page counterpart to the sidebar's `jetpack_admin_menu_visibility`.
15 *
16 * Display only: forcing a module on or off is `jetpack_active_modules`, which the page
17 * already honors by dropping the toggle. `jetpack_feature_policy` feeds that filter, this one,
18 * and the sidebar's alike, so one policy covers both surfaces.
19 */
20 class Feature_Visibility {
21
22 /**
23 * Slugs a host has hidden from the page.
24 *
25 * @return string[] Product card and module slugs, in the order the host named them.
26 */
27 public static function get_hidden() {
28 if ( method_exists( Feature_Policy::class, 'ensure_hooks' ) ) {
29 Feature_Policy::ensure_hooks();
30 }
31
32 /**
33 * Filters which items appear on the My Jetpack Features page.
34 *
35 * Keys are product or module slugs, and a Features grid entry also answers to its own
36 * slug. 'hidden' keeps the item off the page, search included; anything else lists it.
37 * The whole map is passed so that two mu-plugins setting different keys merge.
38 *
39 * @since 6.6.0
40 *
41 * @param array $states Map of slug to state, empty until a host adds to it.
42 */
43 $states = apply_filters( 'jetpack_my_jetpack_feature_visibility', array() );
44
45 if ( ! is_array( $states ) ) {
46 return array();
47 }
48
49 $hidden = defined( Admin_Menu::class . '::VISIBILITY_HIDDEN' ) ? Admin_Menu::VISIBILITY_HIDDEN : 'hidden';
50
51 return array_keys(
52 array_filter(
53 $states,
54 function ( $state ) use ( $hidden ) {
55 return $hidden === $state;
56 }
57 )
58 );
59 }
60 }
61