← All changes
|
jetpack_vendor/automattic/jetpack-sync/src/class-main.php
+27
-0
13.6.2
→
16.3-beta
View file →
| @@ -20,8 +20,11 @@ | ||
| 20 | 20 | * |
| 21 | 21 | * @action plugins_loaded |
| 22 | 22 | */ |
| 23 | 23 | public static function configure() { |
| 24 | + // Activity Log custom events must register even when Sync is disabled, e.g. on WordPress.com Simple sites. | |
| 25 | + Activity_Log_Event::init(); | |
| 26 | + | |
| 24 | 27 | if ( Actions::sync_allowed() ) { |
| 25 | 28 | add_action( 'plugins_loaded', array( __CLASS__, 'on_plugins_loaded_early' ), 5 ); |
| 26 | 29 | add_action( 'plugins_loaded', array( __CLASS__, 'on_plugins_loaded_late' ), 90 ); |
| 27 | 30 | } |
| @@ -39,8 +42,32 @@ | ||
| 39 | 42 | add_action( 'jetpack_site_disconnected', array( __CLASS__, 'on_jetpack_site_disconnected' ), 1000 ); |
| 40 | 43 | |
| 41 | 44 | // Set up package version hook. |
| 42 | 45 | add_filter( 'jetpack_package_versions', __NAMESPACE__ . '\Package_Version::send_package_version_to_tracker' ); |
| 46 | + | |
| 47 | + // Add the custom capabilities for managing modules | |
| 48 | + add_filter( 'map_meta_cap', array( __CLASS__, 'module_custom_caps' ), 10, 2 ); | |
| 49 | + } | |
| 50 | + | |
| 51 | + /** | |
| 52 | + * Sets the Module custom capabilities. | |
| 53 | + * | |
| 54 | + * @param string[] $caps Array of the user's capabilities. | |
| 55 | + * @param string $cap Capability name. | |
| 56 | + * @return string[] The user's capabilities, adjusted as necessary. | |
| 57 | + */ | |
| 58 | + public static function module_custom_caps( $caps, $cap ) { | |
| 59 | + switch ( $cap ) { | |
| 60 | + case 'jetpack_manage_modules': | |
| 61 | + case 'jetpack_activate_modules': | |
| 62 | + case 'jetpack_deactivate_modules': | |
| 63 | + $caps = array( 'manage_options' ); | |
| 64 | + break; | |
| 65 | + case 'jetpack_configure_modules': | |
| 66 | + $caps = array( 'manage_options' ); | |
| 67 | + break; | |
| 68 | + } | |
| 69 | + return $caps; | |
| 43 | 70 | } |
| 44 | 71 | |
| 45 | 72 | /** |
| 46 | 73 | * Delete all sync related data on Identity Crisis disconnect. |