Skip to content

Commit 418f760

Browse files
pablinosmatticbot
authored andcommitted
Social: Update the admin page for use by Editors and Authors (#41859)
* Add the user permissions to script data. * Allow Editors and Authors to manage Social in Jetpack * Only register the admin page if the user has permissions * Only render the module toggle if the user has permission * Move the module capabilities to the sync package The Sync package holds the Modules class that handles the actions to manage the modules. We need the custom capibility to turn the module on and off on the Social admin page, but it's likely to be generally useful for other standalone plugins. * Add changelogs * Refine the permissions type * Update the user capabilities script-data utilities * Implement UserCapabilities interface * Implement the hideToggle logic for the description * Remove unused import Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/13496936847 Upstream-Ref: Automattic/jetpack@e3e42e3
1 parent a0c38aa commit 418f760

File tree

16 files changed

+174
-135
lines changed

16 files changed

+174
-135
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type": "wordpress-plugin",
55
"license": "GPL-2.0-or-later",
66
"require": {
7-
"automattic/jetpack-assets": "^4.0.7",
7+
"automattic/jetpack-assets": "^4.0.8-alpha",
88
"automattic/jetpack-autoloader": "^5.0.1",
99
"automattic/jetpack-composer-plugin": "^4.0.0",
1010
"automattic/jetpack-config": "^3.0.0",

jetpack_vendor/automattic/jetpack-assets/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [4.0.8-alpha] - unreleased
9+
10+
This is an alpha version! The changes listed here are not final.
11+
12+
### Added
13+
- User data: Added permissions to the current user object
14+
815
## [4.0.7] - 2025-02-17
916
### Changed
1017
- Update dependencies.
@@ -564,6 +571,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
564571

565572
- Statically access asset tools
566573

574+
[4.0.8-alpha]: https://github.com/Automattic/jetpack-assets/compare/v4.0.7...v4.0.8-alpha
567575
[4.0.7]: https://github.com/Automattic/jetpack-assets/compare/v4.0.6...v4.0.7
568576
[4.0.6]: https://github.com/Automattic/jetpack-assets/compare/v4.0.5...v4.0.6
569577
[4.0.5]: https://github.com/Automattic/jetpack-assets/compare/v4.0.4...v4.0.5
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array(), 'version' => 'ef2f2e5166a54321a227');
1+
<?php return array('dependencies' => array(), 'version' => '71e696cb91a018077b9d');

jetpack_vendor/automattic/jetpack-assets/build/jetpack-script-data.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jetpack_vendor/automattic/jetpack-assets/src/class-script-data.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,10 @@ protected static function get_current_user_data() {
215215
return array(
216216
'display_name' => $current_user->display_name,
217217
'id' => $current_user->ID,
218+
'capabilities' => array(
219+
'manage_options' => current_user_can( 'manage_options' ),
220+
'manage_modules' => current_user_can( 'jetpack_manage_modules' ),
221+
),
218222
);
219223
}
220224
}

jetpack_vendor/automattic/jetpack-connection/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"php": ">=7.2",
88
"automattic/jetpack-a8c-mc-stats": "^3.0.0",
99
"automattic/jetpack-admin-ui": "^0.5.2",
10-
"automattic/jetpack-assets": "^4.0.7",
10+
"automattic/jetpack-assets": "^4.0.8-alpha",
1111
"automattic/jetpack-constants": "^3.0.1",
1212
"automattic/jetpack-roles": "^3.0.1",
1313
"automattic/jetpack-status": "^5.0.4-alpha",

jetpack_vendor/automattic/jetpack-jitm/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"require": {
77
"php": ">=7.2",
88
"automattic/jetpack-a8c-mc-stats": "^3.0.0",
9-
"automattic/jetpack-assets": "^4.0.7",
9+
"automattic/jetpack-assets": "^4.0.8-alpha",
1010
"automattic/jetpack-connection": "^6.6.0-alpha",
1111
"automattic/jetpack-device-detection": "^3.0.0",
1212
"automattic/jetpack-logo": "^3.0.0",

jetpack_vendor/automattic/jetpack-my-jetpack/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"require": {
77
"php": ">=7.2",
88
"automattic/jetpack-admin-ui": "^0.5.2",
9-
"automattic/jetpack-assets": "^4.0.7",
9+
"automattic/jetpack-assets": "^4.0.8-alpha",
1010
"automattic/jetpack-boost-speed-score": "^0.4.1",
1111
"automattic/jetpack-connection": "^6.6.0-alpha",
1212
"automattic/jetpack-explat": "^0.2.7",

jetpack_vendor/automattic/jetpack-sync/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
This is an alpha version! The changes listed here are not final.
1111

12+
### Added
13+
- Modules: Moved the custom capibilities from the Jetpack plugin
14+
1215
### Fixed
1316
- Code: Prevent dynamic class properties.
1417

jetpack_vendor/automattic/jetpack-sync/src/class-main.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,30 @@ public static function configure() {
4040

4141
// Set up package version hook.
4242
add_filter( 'jetpack_package_versions', __NAMESPACE__ . '\Package_Version::send_package_version_to_tracker' );
43+
44+
// Add the custom capabilities for managing modules
45+
add_filter( 'map_meta_cap', array( __CLASS__, 'module_custom_caps' ), 10, 2 );
46+
}
47+
48+
/**
49+
* Sets the Module custom capabilities.
50+
*
51+
* @param string[] $caps Array of the user's capabilities.
52+
* @param string $cap Capability name.
53+
* @return string[] The user's capabilities, adjusted as necessary.
54+
*/
55+
public static function module_custom_caps( $caps, $cap ) {
56+
switch ( $cap ) {
57+
case 'jetpack_manage_modules':
58+
case 'jetpack_activate_modules':
59+
case 'jetpack_deactivate_modules':
60+
$caps = array( 'manage_options' );
61+
break;
62+
case 'jetpack_configure_modules':
63+
$caps = array( 'manage_options' );
64+
break;
65+
}
66+
return $caps;
4367
}
4468

4569
/**

jetpack_vendor/automattic/jetpack-videopress/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"require": {
77
"php": ">=7.2",
88
"automattic/jetpack-admin-ui": "^0.5.2",
9-
"automattic/jetpack-assets": "^4.0.7",
9+
"automattic/jetpack-assets": "^4.0.8-alpha",
1010
"automattic/jetpack-connection": "^6.6.0-alpha",
1111
"automattic/jetpack-my-jetpack": "^5.5.0-alpha",
1212
"automattic/jetpack-plans": "^0.5.2"

jetpack_vendor/i18n-map.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
),
1111
'jetpack-assets' => array(
1212
'path' => 'jetpack_vendor/automattic/jetpack-assets',
13-
'ver' => '4.0.7',
13+
'ver' => '4.0.8-alpha1740396408',
1414
),
1515
'jetpack-boost-core' => array(
1616
'path' => 'jetpack_vendor/automattic/jetpack-boost-core',
@@ -66,7 +66,7 @@
6666
),
6767
'jetpack-sync' => array(
6868
'path' => 'jetpack_vendor/automattic/jetpack-sync',
69-
'ver' => '4.8.2-alpha1740070348',
69+
'ver' => '4.8.2-alpha1740396408',
7070
),
7171
'jetpack-videopress-pkg' => array(
7272
'path' => 'jetpack_vendor/automattic/jetpack-videopress',

0 commit comments

Comments
 (0)