initial
This commit is contained in:
@@ -0,0 +1,375 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [0.9.6] - 2026-06-26
|
||||
### Changed
|
||||
- Update dependencies. [#48834]
|
||||
|
||||
## [0.9.5] - 2026-06-23
|
||||
### Changed
|
||||
- Update package dependencies. [#49831]
|
||||
|
||||
## [0.9.4] - 2026-06-22
|
||||
### Changed
|
||||
- Update package dependencies. [#49691]
|
||||
|
||||
## [0.9.3] - 2026-06-15
|
||||
### Changed
|
||||
- Update dependencies. [#48834]
|
||||
|
||||
## [0.9.2] - 2026-06-09
|
||||
### Changed
|
||||
- Update package dependencies. [#49273]
|
||||
|
||||
## [0.9.1] - 2026-06-08
|
||||
### Changed
|
||||
- Internal updates.
|
||||
|
||||
## [0.9.0] - 2026-06-05
|
||||
### Added
|
||||
- Add a shared, token-only WPDS design-tokens stylesheet and enqueue it on Jetpack admin pages so `var(--wpds-*)` values resolve at runtime. [#49345]
|
||||
|
||||
## [0.8.9] - 2026-06-03
|
||||
### Changed
|
||||
- Internal updates.
|
||||
|
||||
## [0.8.8] - 2026-06-02
|
||||
### Changed
|
||||
- Update dependencies. [#48834]
|
||||
|
||||
## [0.8.7] - 2026-06-01
|
||||
### Added
|
||||
- Hide WordPress core admin notices on Jetpack admin pages. [#49237]
|
||||
|
||||
## [0.8.6] - 2026-05-21
|
||||
### Changed
|
||||
- Update package dependencies. [#48405]
|
||||
|
||||
## [0.8.5] - 2026-05-19
|
||||
### Changed
|
||||
- Internal updates.
|
||||
|
||||
## [0.8.4] - 2026-05-14
|
||||
### Changed
|
||||
- Update dependencies. [#48778]
|
||||
|
||||
## [0.8.3] - 2026-05-11
|
||||
### Changed
|
||||
- Update dependencies.
|
||||
|
||||
## [0.8.2] - 2026-05-04
|
||||
### Changed
|
||||
- Internal: No longer require automattic/jetpack-changelogger as a per-project dev dependency. [#48225]
|
||||
|
||||
## [0.8.1] - 2026-04-20
|
||||
### Changed
|
||||
- Update package dependencies. [#48106]
|
||||
|
||||
## [0.8.0] - 2026-04-10
|
||||
### Changed
|
||||
- Hide the sidebar upsell when the site is not connected to Jetpack or is in offline mode. [#47967]
|
||||
|
||||
## [0.7.1] - 2026-04-09
|
||||
### Changed
|
||||
- Update package dependencies. [#47890]
|
||||
|
||||
## [0.7.0] - 2026-04-06
|
||||
### Added
|
||||
- Add "Upgrade Jetpack" menu item for free users in the Jetpack admin menu. [#47418]
|
||||
- Admin: Record Tracks when the Jetpack sidebar "Upgrade Jetpack" link is clicked. [#47937]
|
||||
|
||||
### Changed
|
||||
- Update design of the sidebar upsell. [#47909]
|
||||
|
||||
### Fixed
|
||||
- Fix upgrade menu item color on problematic admin color schemes and add build pipeline for CSS assets. [#47903]
|
||||
|
||||
## [0.6.0] - 2026-03-30
|
||||
### Changed
|
||||
- Sidebar: Change "Anti-spam" to "Akismet Anti-spam". [#47834]
|
||||
|
||||
## [0.5.12] - 2026-03-09
|
||||
### Changed
|
||||
- Simplify Akismet admin menu title from 'Akismet Anti-spam' to 'Anti-spam'. [#47417]
|
||||
|
||||
## [0.5.11] - 2025-08-04
|
||||
### Changed
|
||||
- Internal updates.
|
||||
|
||||
## [0.5.10] - 2025-06-06
|
||||
### Fixed
|
||||
- Fix the Jetpack submenu order for WordPress.com sites that use Nav Unification. [#43781]
|
||||
|
||||
## [0.5.9] - 2025-05-05
|
||||
### Fixed
|
||||
- Remove the Jetpack submenu only if My Jetpack is present. [#43282]
|
||||
|
||||
## [0.5.8] - 2025-04-28
|
||||
### Changed
|
||||
- Internal updates.
|
||||
|
||||
## [0.5.7] - 2025-03-21
|
||||
### Changed
|
||||
- Internal updates.
|
||||
|
||||
## [0.5.6] - 2025-03-17
|
||||
### Changed
|
||||
- Internal updates.
|
||||
|
||||
## [0.5.5] - 2025-03-12
|
||||
### Changed
|
||||
- Internal updates.
|
||||
|
||||
## [0.5.4] - 2025-03-05
|
||||
### Changed
|
||||
- Internal updates.
|
||||
|
||||
## [0.5.3] - 2025-02-24
|
||||
### Changed
|
||||
- Update dependencies.
|
||||
|
||||
## [0.5.2] - 2025-02-03
|
||||
### Added
|
||||
- Add `remove_menu` method to `Admin_Menu` class. [#41422]
|
||||
|
||||
## [0.5.1] - 2024-11-25
|
||||
### Changed
|
||||
- Update dependencies. [#40286]
|
||||
|
||||
## [0.5.0] - 2024-11-14
|
||||
### Removed
|
||||
- General: Update minimum PHP version to 7.2. [#40147]
|
||||
|
||||
## [0.4.6] - 2024-11-04
|
||||
### Added
|
||||
- Enable test coverage. [#39961]
|
||||
|
||||
## [0.4.5] - 2024-09-05
|
||||
### Changed
|
||||
- Jetpack menu: only register Jetpack admin page for contributor roles and above. [#39081]
|
||||
|
||||
## [0.4.4] - 2024-08-29
|
||||
### Changed
|
||||
- Admin menu: change order of Jetpack sub-menu items [#39095]
|
||||
|
||||
## [0.4.3] - 2024-08-23
|
||||
### Changed
|
||||
- Updated package dependencies. [#39004]
|
||||
|
||||
## [0.4.2] - 2024-04-22
|
||||
### Changed
|
||||
- Internal updates.
|
||||
|
||||
## [0.4.1] - 2024-03-12
|
||||
### Changed
|
||||
- Internal updates.
|
||||
|
||||
## [0.4.0] - 2024-03-01
|
||||
### Added
|
||||
- Register menus in network admin as well as regular admin. [#36058]
|
||||
|
||||
## [0.3.2] - 2024-01-29
|
||||
### Fixed
|
||||
- Wait until 'admin_menu' action to call `add_menu()`, to avoid triggering the l10n load too early. [#35279]
|
||||
|
||||
## [0.3.1] - 2023-11-24
|
||||
|
||||
## [0.3.0] - 2023-11-20
|
||||
### Changed
|
||||
- Updated required PHP version to >= 7.0. [#34192]
|
||||
|
||||
## [0.2.25] - 2023-11-14
|
||||
|
||||
## [0.2.24] - 2023-10-30
|
||||
### Fixed
|
||||
- Handle Akismet submenu even if Jetpack is present, as Jetpack now relies on this package to do so. [#33559]
|
||||
|
||||
## [0.2.23] - 2023-09-19
|
||||
### Changed
|
||||
- Updated Jetpack submenu sort order so individual features are alpha-sorted. [#32958]
|
||||
|
||||
## [0.2.22] - 2023-09-11
|
||||
### Fixed
|
||||
- Akismet: update naming to common form [#32908]
|
||||
|
||||
## [0.2.21] - 2023-08-23
|
||||
### Changed
|
||||
- Updated package dependencies. [#32605]
|
||||
|
||||
## [0.2.20] - 2023-04-25
|
||||
### Fixed
|
||||
- Avoid errors when used in combination with an older version of the Logo package. [#30136]
|
||||
|
||||
## [0.2.19] - 2023-04-10
|
||||
### Added
|
||||
- Add Jetpack Autoloader package suggestion. [#29988]
|
||||
|
||||
## [0.2.18] - 2023-04-04
|
||||
### Changed
|
||||
- Menu icon: update to latest version of the Jetpack logo [#29418]
|
||||
|
||||
## [0.2.17] - 2023-02-20
|
||||
### Changed
|
||||
- Minor internal updates.
|
||||
|
||||
## [0.2.16] - 2023-01-25
|
||||
### Changed
|
||||
- Minor internal updates.
|
||||
|
||||
## [0.2.15] - 2023-01-11
|
||||
### Changed
|
||||
- Updated package dependencies.
|
||||
|
||||
## [0.2.14] - 2022-12-02
|
||||
### Changed
|
||||
- Updated package dependencies. [#27688]
|
||||
|
||||
## [0.2.13] - 2022-11-22
|
||||
### Changed
|
||||
- Updated package dependencies. [#27043]
|
||||
|
||||
## [0.2.12] - 2022-09-20
|
||||
### Changed
|
||||
- Updated package dependencies.
|
||||
|
||||
## [0.2.11] - 2022-07-26
|
||||
### Changed
|
||||
- Updated package dependencies. [#25158]
|
||||
|
||||
## [0.2.10] - 2022-07-12
|
||||
### Changed
|
||||
- Updated package dependencies.
|
||||
|
||||
## [0.2.9] - 2022-06-21
|
||||
### Changed
|
||||
- Renaming master to trunk.
|
||||
|
||||
## [0.2.8] - 2022-06-14
|
||||
### Changed
|
||||
- Updated package dependencies.
|
||||
|
||||
## [0.2.7] - 2022-04-26
|
||||
### Changed
|
||||
- Update package.json metadata.
|
||||
|
||||
## [0.2.6] - 2022-04-05
|
||||
### Changed
|
||||
- Updated package dependencies.
|
||||
|
||||
## [0.2.5] - 2022-03-08
|
||||
### Fixed
|
||||
- Do not handle Akismet submenu if Jetpack plugin is present
|
||||
|
||||
## [0.2.4] - 2022-02-09
|
||||
### Added
|
||||
- Support for akismet menu with stand-alone plugins
|
||||
|
||||
### Fixed
|
||||
- Fixes menu order working around a bug in add_submenu_page
|
||||
|
||||
## [0.2.3] - 2022-01-25
|
||||
### Changed
|
||||
- Updated package dependencies.
|
||||
|
||||
## [0.2.2] - 2022-01-18
|
||||
### Changed
|
||||
- General: update required node version to v16.13.2
|
||||
|
||||
## [0.2.1] - 2022-01-04
|
||||
### Changed
|
||||
- Switch to pcov for code coverage.
|
||||
- Updated package dependencies
|
||||
|
||||
## [0.2.0] - 2021-12-14
|
||||
### Added
|
||||
- New method to get the top level menu item
|
||||
|
||||
## [0.1.1] - 2021-11-17
|
||||
### Changed
|
||||
- Set `convertDeprecationsToExceptions` true in PHPUnit config.
|
||||
- Update PHPUnit configs to include just what needs coverage rather than include everything then try to exclude stuff that doesn't.
|
||||
|
||||
## 0.1.0 - 2021-10-13
|
||||
### Added
|
||||
- Created the package.
|
||||
|
||||
### Changed
|
||||
- Updated package dependencies.
|
||||
|
||||
### Fixed
|
||||
- Fixing menu visibility issues.
|
||||
|
||||
[0.9.6]: https://github.com/Automattic/jetpack-admin-ui/compare/0.9.5...0.9.6
|
||||
[0.9.5]: https://github.com/Automattic/jetpack-admin-ui/compare/0.9.4...0.9.5
|
||||
[0.9.4]: https://github.com/Automattic/jetpack-admin-ui/compare/0.9.3...0.9.4
|
||||
[0.9.3]: https://github.com/Automattic/jetpack-admin-ui/compare/0.9.2...0.9.3
|
||||
[0.9.2]: https://github.com/Automattic/jetpack-admin-ui/compare/0.9.1...0.9.2
|
||||
[0.9.1]: https://github.com/Automattic/jetpack-admin-ui/compare/0.9.0...0.9.1
|
||||
[0.9.0]: https://github.com/Automattic/jetpack-admin-ui/compare/0.8.9...0.9.0
|
||||
[0.8.9]: https://github.com/Automattic/jetpack-admin-ui/compare/0.8.8...0.8.9
|
||||
[0.8.8]: https://github.com/Automattic/jetpack-admin-ui/compare/0.8.7...0.8.8
|
||||
[0.8.7]: https://github.com/Automattic/jetpack-admin-ui/compare/0.8.6...0.8.7
|
||||
[0.8.6]: https://github.com/Automattic/jetpack-admin-ui/compare/0.8.5...0.8.6
|
||||
[0.8.5]: https://github.com/Automattic/jetpack-admin-ui/compare/0.8.4...0.8.5
|
||||
[0.8.4]: https://github.com/Automattic/jetpack-admin-ui/compare/0.8.3...0.8.4
|
||||
[0.8.3]: https://github.com/Automattic/jetpack-admin-ui/compare/0.8.2...0.8.3
|
||||
[0.8.2]: https://github.com/Automattic/jetpack-admin-ui/compare/0.8.1...0.8.2
|
||||
[0.8.1]: https://github.com/Automattic/jetpack-admin-ui/compare/0.8.0...0.8.1
|
||||
[0.8.0]: https://github.com/Automattic/jetpack-admin-ui/compare/0.7.1...0.8.0
|
||||
[0.7.1]: https://github.com/Automattic/jetpack-admin-ui/compare/0.7.0...0.7.1
|
||||
[0.7.0]: https://github.com/Automattic/jetpack-admin-ui/compare/0.6.0...0.7.0
|
||||
[0.6.0]: https://github.com/Automattic/jetpack-admin-ui/compare/0.5.12...0.6.0
|
||||
[0.5.12]: https://github.com/Automattic/jetpack-admin-ui/compare/0.5.11...0.5.12
|
||||
[0.5.11]: https://github.com/Automattic/jetpack-admin-ui/compare/0.5.10...0.5.11
|
||||
[0.5.10]: https://github.com/Automattic/jetpack-admin-ui/compare/0.5.9...0.5.10
|
||||
[0.5.9]: https://github.com/Automattic/jetpack-admin-ui/compare/0.5.8...0.5.9
|
||||
[0.5.8]: https://github.com/Automattic/jetpack-admin-ui/compare/0.5.7...0.5.8
|
||||
[0.5.7]: https://github.com/Automattic/jetpack-admin-ui/compare/0.5.6...0.5.7
|
||||
[0.5.6]: https://github.com/Automattic/jetpack-admin-ui/compare/0.5.5...0.5.6
|
||||
[0.5.5]: https://github.com/Automattic/jetpack-admin-ui/compare/0.5.4...0.5.5
|
||||
[0.5.4]: https://github.com/Automattic/jetpack-admin-ui/compare/0.5.3...0.5.4
|
||||
[0.5.3]: https://github.com/Automattic/jetpack-admin-ui/compare/0.5.2...0.5.3
|
||||
[0.5.2]: https://github.com/Automattic/jetpack-admin-ui/compare/0.5.1...0.5.2
|
||||
[0.5.1]: https://github.com/Automattic/jetpack-admin-ui/compare/0.5.0...0.5.1
|
||||
[0.5.0]: https://github.com/Automattic/jetpack-admin-ui/compare/0.4.6...0.5.0
|
||||
[0.4.6]: https://github.com/Automattic/jetpack-admin-ui/compare/0.4.5...0.4.6
|
||||
[0.4.5]: https://github.com/Automattic/jetpack-admin-ui/compare/0.4.4...0.4.5
|
||||
[0.4.4]: https://github.com/Automattic/jetpack-admin-ui/compare/0.4.3...0.4.4
|
||||
[0.4.3]: https://github.com/Automattic/jetpack-admin-ui/compare/0.4.2...0.4.3
|
||||
[0.4.2]: https://github.com/Automattic/jetpack-admin-ui/compare/0.4.1...0.4.2
|
||||
[0.4.1]: https://github.com/Automattic/jetpack-admin-ui/compare/0.4.0...0.4.1
|
||||
[0.4.0]: https://github.com/Automattic/jetpack-admin-ui/compare/0.3.2...0.4.0
|
||||
[0.3.2]: https://github.com/Automattic/jetpack-admin-ui/compare/0.3.1...0.3.2
|
||||
[0.3.1]: https://github.com/Automattic/jetpack-admin-ui/compare/0.3.0...0.3.1
|
||||
[0.3.0]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.25...0.3.0
|
||||
[0.2.25]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.24...0.2.25
|
||||
[0.2.24]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.23...0.2.24
|
||||
[0.2.23]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.22...0.2.23
|
||||
[0.2.22]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.21...0.2.22
|
||||
[0.2.21]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.20...0.2.21
|
||||
[0.2.20]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.19...0.2.20
|
||||
[0.2.19]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.18...0.2.19
|
||||
[0.2.18]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.17...0.2.18
|
||||
[0.2.17]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.16...0.2.17
|
||||
[0.2.16]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.15...0.2.16
|
||||
[0.2.15]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.14...0.2.15
|
||||
[0.2.14]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.13...0.2.14
|
||||
[0.2.13]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.12...0.2.13
|
||||
[0.2.12]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.11...0.2.12
|
||||
[0.2.11]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.10...0.2.11
|
||||
[0.2.10]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.9...0.2.10
|
||||
[0.2.9]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.8...0.2.9
|
||||
[0.2.8]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.7...0.2.8
|
||||
[0.2.7]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.6...0.2.7
|
||||
[0.2.6]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.5...0.2.6
|
||||
[0.2.5]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.4...0.2.5
|
||||
[0.2.4]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.3...0.2.4
|
||||
[0.2.3]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.2...0.2.3
|
||||
[0.2.2]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.1...0.2.2
|
||||
[0.2.1]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.0...0.2.1
|
||||
[0.2.0]: https://github.com/Automattic/jetpack-admin-ui/compare/0.1.1...0.2.0
|
||||
[0.1.1]: https://github.com/Automattic/jetpack-admin-ui/compare/0.1.0...0.1.1
|
||||
+1
@@ -0,0 +1 @@
|
||||
<?php return array('dependencies' => array(), 'version' => '9928b439705112de9a6a');
|
||||
+1
@@ -0,0 +1 @@
|
||||
document.addEventListener("DOMContentLoaded",()=>{const e=window.jetpackAdminUiUpgradeMenu;if(void 0===e)return;const t=e.menuItemClass;if(!t)return;const a=document.querySelector(`li.${t} a`);a&&(void 0!==window?.analytics&&e.tracksUserData&&window.analytics.initialize(e.tracksUserData?.userid,e.tracksUserData?.username),a.addEventListener("click",function(){window.analytics?.tracks?.recordEvent("jetpack_sidebar_free_upgrade_click",e.tracksEventData)}))});
|
||||
+1
@@ -0,0 +1 @@
|
||||
<?php return array('dependencies' => array(), 'version' => '3c06881fce01e490b54a');
|
||||
+1
@@ -0,0 +1 @@
|
||||
:root{--font-title-large:36px;--font-title-small:24px;--font-body:16px;--font-label:12px;--jp-black:#000;--jp-black-80:#2c3338;--jp-white:#fff;--jp-white-off:#f9f9f6;--jp-gray:#dcdcde;--jp-gray-0:#f6f7f7;--jp-gray-5:#dcdcde;--jp-gray-10:#c3c4c7;--jp-gray-20:#a7aaad;--jp-gray-30:#8c8f94;--jp-gray-40:#787c82;--jp-gray-50:#646970;--jp-gray-60:#50575e;--jp-gray-70:#3c434a;--jp-gray-80:#2c3338;--jp-gray-90:#1d2327;--jp-gray-100:#101517;--jp-gray-off:#e2e2df;--jp-yellow-5:#f5e6b3;--jp-yellow-10:#f2cf75;--jp-yellow-40:#c08c00;--jp-orange-20:#faa754;--jp-blue-5:#ced9f2;--jp-red-0:#f7ebec;--jp-red-50:#d63638;--jp-red-60:#b32d2e;--jp-red-80:#8a2424;--jp-red:#d63639;--jp-pink:#c9356e;--jp-green-0:#f0f2eb;--jp-green-5:#d0e6b8;--jp-green-10:#9dd977;--jp-green-20:#64ca43;--jp-green-30:#2fb41f;--jp-green-40:#069e08;--jp-green-50:#008710;--jp-green-60:#007117;--jp-green-70:#005b18;--jp-green-80:#004515;--jp-green-90:#003010;--jp-green-100:#001c09;--jp-green:#069e08;--jp-green-mint:#d3f6d5;--jp-green-primary:var(--jp-green-40);--jp-green-secondary:var(--jp-green-30);--jp-border-radius:4px;--jp-border-radius-rna:8px;--jp-menu-border-height:1px;--jp-underline-thickness:2px;--jp-modal-padding-large:32px;--jp-modal-padding:24px;--jp-modal-padding-small:16px;--jp-modal-radius:8px;--jp-button-padding:8px;--jp-button-radius:4px;--jp-gap:16px}#adminmenu li.jetpack-wpadmin-sidebar-free-plan-upsell-menu-item>a,#adminmenu li.jetpack-wpadmin-sidebar-free-plan-upsell-menu-item>a:hover{background:var(--jp-green-40)!important;border-radius:var(--jp-border-radius)!important;box-shadow:none!important;color:var(--jp-white)!important;margin:2px 4px;text-align:center;text-wrap:balance}#adminmenu li.jetpack-wpadmin-sidebar-free-plan-upsell-menu-item>a:hover{background:var(--jp-green-30)!important}
|
||||
+1
@@ -0,0 +1 @@
|
||||
:root{--font-title-large:36px;--font-title-small:24px;--font-body:16px;--font-label:12px;--jp-black:#000;--jp-black-80:#2c3338;--jp-white:#fff;--jp-white-off:#f9f9f6;--jp-gray:#dcdcde;--jp-gray-0:#f6f7f7;--jp-gray-5:#dcdcde;--jp-gray-10:#c3c4c7;--jp-gray-20:#a7aaad;--jp-gray-30:#8c8f94;--jp-gray-40:#787c82;--jp-gray-50:#646970;--jp-gray-60:#50575e;--jp-gray-70:#3c434a;--jp-gray-80:#2c3338;--jp-gray-90:#1d2327;--jp-gray-100:#101517;--jp-gray-off:#e2e2df;--jp-yellow-5:#f5e6b3;--jp-yellow-10:#f2cf75;--jp-yellow-40:#c08c00;--jp-orange-20:#faa754;--jp-blue-5:#ced9f2;--jp-red-0:#f7ebec;--jp-red-50:#d63638;--jp-red-60:#b32d2e;--jp-red-80:#8a2424;--jp-red:#d63639;--jp-pink:#c9356e;--jp-green-0:#f0f2eb;--jp-green-5:#d0e6b8;--jp-green-10:#9dd977;--jp-green-20:#64ca43;--jp-green-30:#2fb41f;--jp-green-40:#069e08;--jp-green-50:#008710;--jp-green-60:#007117;--jp-green-70:#005b18;--jp-green-80:#004515;--jp-green-90:#003010;--jp-green-100:#001c09;--jp-green:#069e08;--jp-green-mint:#d3f6d5;--jp-green-primary:var(--jp-green-40);--jp-green-secondary:var(--jp-green-30);--jp-border-radius:4px;--jp-border-radius-rna:8px;--jp-menu-border-height:1px;--jp-underline-thickness:2px;--jp-modal-padding-large:32px;--jp-modal-padding:24px;--jp-modal-padding-small:16px;--jp-modal-radius:8px;--jp-button-padding:8px;--jp-button-radius:4px;--jp-gap:16px}#adminmenu li.jetpack-wpadmin-sidebar-free-plan-upsell-menu-item>a,#adminmenu li.jetpack-wpadmin-sidebar-free-plan-upsell-menu-item>a:hover{background:var(--jp-green-40)!important;border-radius:var(--jp-border-radius)!important;box-shadow:none!important;color:var(--jp-white)!important;margin:2px 4px;text-align:center;text-wrap:balance}#adminmenu li.jetpack-wpadmin-sidebar-free-plan-upsell-menu-item>a:hover{background:var(--jp-green-30)!important}
|
||||
+1
@@ -0,0 +1 @@
|
||||
<?php return array('dependencies' => array(), 'version' => '9909656c2d47702db3c4');
|
||||
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+32
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Marks the wp-admin Jetpack sidebar "Upgrade Jetpack" item for Tracks.
|
||||
*/
|
||||
document.addEventListener( 'DOMContentLoaded', () => {
|
||||
const config = window.jetpackAdminUiUpgradeMenu;
|
||||
if ( typeof config === 'undefined' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const className = config.menuItemClass;
|
||||
if ( ! className ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Class comes from PHP (UPGRADE_MENU_SLUG); safe for querySelector.
|
||||
const item = document.querySelector( `li.${ className } a` );
|
||||
if ( ! item ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize Tracks
|
||||
if ( 'undefined' !== typeof window?.analytics && config.tracksUserData ) {
|
||||
window.analytics.initialize( config.tracksUserData?.userid, config.tracksUserData?.username );
|
||||
}
|
||||
|
||||
item.addEventListener( 'click', function () {
|
||||
window.analytics?.tracks?.recordEvent(
|
||||
'jetpack_sidebar_free_upgrade_click',
|
||||
config.tracksEventData
|
||||
);
|
||||
} );
|
||||
} );
|
||||
+601
@@ -0,0 +1,601 @@
|
||||
<?php
|
||||
/**
|
||||
* Admin Menu Registration
|
||||
*
|
||||
* @package automattic/jetpack-admin-ui
|
||||
*/
|
||||
|
||||
namespace Automattic\Jetpack\Admin_UI;
|
||||
|
||||
use Automattic\Jetpack\Tracking;
|
||||
use Jetpack_Options;
|
||||
use Jetpack_Tracks_Client;
|
||||
|
||||
/**
|
||||
* This class offers a wrapper to add_submenu_page and makes sure stand-alone plugin's menu items are always added under the Jetpack top level menu.
|
||||
* If the Jetpack top level was not previously registered by other plugin, it will be registered here.
|
||||
*/
|
||||
class Admin_Menu {
|
||||
|
||||
const PACKAGE_VERSION = '0.9.6';
|
||||
|
||||
/**
|
||||
* Slug used for the upgrade menu item and redirect URL.
|
||||
*
|
||||
* Keep the slug in sync with `$upgrade-menu-slug` at admin-ui-upgrade-menu.scss
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const UPGRADE_MENU_SLUG = 'jetpack-wpadmin-sidebar-free-plan-upsell-menu-item';
|
||||
|
||||
/**
|
||||
* Fallback upgrade URL when the Redirect class is unavailable.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const UPGRADE_MENU_FALLBACK_URL = 'https://jetpack.com/upgrade/';
|
||||
|
||||
/**
|
||||
* Handle for the shared, token-only WPDS design-tokens stylesheet.
|
||||
*
|
||||
* Registered once and enqueued on every Jetpack admin page so that
|
||||
* `var(--wpds-*)` values resolve at runtime instead of falling back to
|
||||
* their hand-written hex defaults.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const DESIGN_TOKENS_HANDLE = 'jetpack-admin-ui-design-tokens';
|
||||
|
||||
/**
|
||||
* Whether this class has been initialized
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private static $initialized = false;
|
||||
|
||||
/**
|
||||
* List of menu items enqueued to be added
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $menu_items = array();
|
||||
|
||||
/**
|
||||
* Hook suffixes of the pages registered through this class.
|
||||
*
|
||||
* Used to scope the design-tokens stylesheet to Jetpack admin pages.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $page_hooks = array();
|
||||
|
||||
/**
|
||||
* Optional connection manager dependency.
|
||||
*
|
||||
* @var object|null
|
||||
*/
|
||||
private static $connection_manager = null;
|
||||
|
||||
/**
|
||||
* Initialize the class and set up the main hook
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function init() {
|
||||
if ( ! self::$initialized ) {
|
||||
self::$initialized = true;
|
||||
self::handle_akismet_menu();
|
||||
add_action( 'admin_menu', array( __CLASS__, 'admin_menu_hook_callback' ), 1000 ); // Jetpack uses 998.
|
||||
add_action( 'network_admin_menu', array( __CLASS__, 'admin_menu_hook_callback' ), 1000 ); // Jetpack uses 998.
|
||||
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'add_upgrade_menu_item_styles' ) );
|
||||
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'maybe_enqueue_design_tokens' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the Akismet menu item when used alongside other stand-alone plugins
|
||||
*
|
||||
* When Jetpack plugin is present, Akismet menu item is moved under the Jetpack top level menu, but if Akismet is active alongside other stand-alone plugins,
|
||||
* we use this method to move the menu item.
|
||||
*/
|
||||
private static function handle_akismet_menu() {
|
||||
if ( class_exists( 'Akismet_Admin' ) ) {
|
||||
add_action(
|
||||
'admin_menu',
|
||||
function () {
|
||||
// Prevent Akismet from adding a menu item.
|
||||
remove_action( 'admin_menu', array( 'Akismet_Admin', 'admin_menu' ), 5 );
|
||||
|
||||
// Add an Anti-spam menu item for Jetpack.
|
||||
self::add_menu( __( 'Akismet Anti-spam', 'jetpack-admin-ui' ), __( 'Akismet Anti-spam', 'jetpack-admin-ui' ), 'manage_options', 'akismet-key-config', array( 'Akismet_Admin', 'display_page' ), 6 );
|
||||
},
|
||||
4
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to the admin_menu and network_admin_menu hooks that will register the enqueued menu items
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function admin_menu_hook_callback() {
|
||||
$can_see_toplevel_menu = true;
|
||||
$jetpack_plugin_present = class_exists( 'Jetpack_React_Page' );
|
||||
$icon = method_exists( '\Automattic\Jetpack\Assets\Logo', 'get_base64_logo' )
|
||||
? ( new \Automattic\Jetpack\Assets\Logo() )->get_base64_logo()
|
||||
: 'dashicons-admin-plugins';
|
||||
|
||||
if ( ! $jetpack_plugin_present ) {
|
||||
add_menu_page(
|
||||
'Jetpack',
|
||||
'Jetpack',
|
||||
'edit_posts',
|
||||
'jetpack',
|
||||
'__return_null',
|
||||
$icon,
|
||||
3
|
||||
);
|
||||
|
||||
// If Jetpack plugin is not present, user will only be able to see this menu if they have enough capability to at least one of the sub menus being added.
|
||||
$can_see_toplevel_menu = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The add_sub_menu function has a bug and will not keep the right order of menu items.
|
||||
*
|
||||
* @see https://core.trac.wordpress.org/ticket/52035
|
||||
* Let's order the items before registering them.
|
||||
* Since this all happens after the Jetpack plugin menu items were added, all items will be added after Jetpack plugin items - unless position is very low number (smaller than the number of menu items present in Jetpack plugin).
|
||||
*/
|
||||
usort(
|
||||
self::$menu_items,
|
||||
function ( $a, $b ) {
|
||||
$position_a = empty( $a['position'] ) ? 0 : $a['position'];
|
||||
$position_b = empty( $b['position'] ) ? 0 : $b['position'];
|
||||
$result = $position_a <=> $position_b;
|
||||
|
||||
if ( 0 === $result ) {
|
||||
$result = strcmp( $a['menu_title'], $b['menu_title'] );
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
);
|
||||
|
||||
foreach ( self::$menu_items as $menu_item ) {
|
||||
if ( ! current_user_can( $menu_item['capability'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$can_see_toplevel_menu = true;
|
||||
|
||||
add_submenu_page(
|
||||
'jetpack',
|
||||
$menu_item['page_title'],
|
||||
$menu_item['menu_title'],
|
||||
$menu_item['capability'],
|
||||
$menu_item['menu_slug'],
|
||||
$menu_item['function'],
|
||||
$menu_item['position']
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! $jetpack_plugin_present ) {
|
||||
remove_submenu_page( 'jetpack', 'jetpack' );
|
||||
}
|
||||
|
||||
if ( ! $can_see_toplevel_menu ) {
|
||||
remove_menu_page( 'jetpack' );
|
||||
}
|
||||
|
||||
self::maybe_add_upgrade_menu_item();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new submenu to the Jetpack Top level menu
|
||||
*
|
||||
* The parameters this method accepts are the same as @see add_submenu_page. This class will
|
||||
* aggreagate all menu items registered by stand-alone plugins and make sure they all go under the same
|
||||
* Jetpack top level menu. It will also handle the top level menu registration in case the Jetpack plugin is not present.
|
||||
*
|
||||
* @param string $page_title The text to be displayed in the title tags of the page when the menu
|
||||
* is selected.
|
||||
* @param string $menu_title The text to be used for the menu.
|
||||
* @param string $capability The capability required for this menu to be displayed to the user.
|
||||
* @param string $menu_slug The slug name to refer to this menu by. Should be unique for this menu
|
||||
* and only include lowercase alphanumeric, dashes, and underscores characters
|
||||
* to be compatible with sanitize_key().
|
||||
* @param callable|null $function The function to be called to output the content for this page.
|
||||
* @param int $position The position in the menu order this item should appear. Leave empty typically.
|
||||
*
|
||||
* @return string The resulting page's hook_suffix
|
||||
*/
|
||||
public static function add_menu( $page_title, $menu_title, $capability, $menu_slug, $function, $position = null ) {
|
||||
self::init();
|
||||
self::$menu_items[] = compact( 'page_title', 'menu_title', 'capability', 'menu_slug', 'function', 'position' );
|
||||
|
||||
/**
|
||||
* Let's return the page hook so consumers can use.
|
||||
* We know all pages will be under Jetpack top level menu page, so we can hardcode the first part of the string.
|
||||
* Using get_plugin_page_hookname here won't work because the top level page is not registered yet.
|
||||
*/
|
||||
$hook = 'jetpack_page_' . $menu_slug;
|
||||
|
||||
// Track the page hook so the design-tokens stylesheet can be scoped to it.
|
||||
self::$page_hooks[] = $hook;
|
||||
|
||||
// Hide WordPress core admin notices on this Jetpack page. The load-<hook>
|
||||
// action only fires when the matching screen is being rendered, so this
|
||||
// stays scoped to Jetpack pages and reaches every page registered here.
|
||||
add_action( 'load-' . $hook, array( __CLASS__, 'hide_core_admin_notices' ) );
|
||||
add_action( 'load-' . $hook . '-network', array( __CLASS__, 'hide_core_admin_notices' ) );
|
||||
|
||||
return $hook;
|
||||
}
|
||||
|
||||
/**
|
||||
* Queues an inline style that hides WordPress core admin notices on the current Jetpack page.
|
||||
*
|
||||
* Hooked from the page's load-<hook> action so it only runs on Jetpack screens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function hide_core_admin_notices() {
|
||||
add_action( 'admin_print_styles', array( __CLASS__, 'print_hide_core_admin_notices_style' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the inline style that hides WordPress core admin notices.
|
||||
*
|
||||
* We only target direct children of #wpbody-content (where core renders notices via the
|
||||
* admin_notices / all_admin_notices hooks). This intentionally leaves JITMs untouched —
|
||||
* they output `.jetpack-jitm-message`, not `.notice` — and leaves in-app/React notices
|
||||
* untouched, since those render deeper inside `.wrap`. An inline style is used (rather than
|
||||
* an enqueued build asset) so it also works on older Jetpack pages that ship no stylesheet.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function print_hide_core_admin_notices_style() {
|
||||
?>
|
||||
<style id="jetpack-admin-ui-hide-core-notices">
|
||||
#wpbody-content > .notice,
|
||||
#wpbody-content > .update-nag,
|
||||
#wpbody-content > .updated,
|
||||
#wpbody-content > .error { display: none !important; }
|
||||
</style>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an already added submenu
|
||||
*
|
||||
* @param string $menu_slug The slug of the submenu to remove.
|
||||
*
|
||||
* @return array|false The removed submenu on success, false if not found.
|
||||
*/
|
||||
public static function remove_menu( $menu_slug ) {
|
||||
|
||||
foreach ( self::$menu_items as $index => $menu_item ) {
|
||||
if ( $menu_item['menu_slug'] === $menu_slug ) {
|
||||
unset( self::$menu_items[ $index ] );
|
||||
|
||||
return $menu_item;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the slug for the first item under the Jetpack top level menu
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public static function get_top_level_menu_item_slug() {
|
||||
global $submenu;
|
||||
if ( ! empty( $submenu['jetpack'] ) ) {
|
||||
$item = reset( $submenu['jetpack'] );
|
||||
if ( isset( $item[2] ) ) {
|
||||
return $item[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the URL for the first item under the Jetpack top level menu
|
||||
*
|
||||
* @param string $fallback If Jetpack menu is not there or no children is found, return this fallback instead. Default to admin_url().
|
||||
* @return string
|
||||
*/
|
||||
public static function get_top_level_menu_item_url( $fallback = false ) {
|
||||
$slug = self::get_top_level_menu_item_slug();
|
||||
|
||||
if ( $slug ) {
|
||||
$url = menu_page_url( $slug, false );
|
||||
return $url;
|
||||
}
|
||||
|
||||
$url = $fallback ? $fallback : admin_url();
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the current site should show the upgrade menu item.
|
||||
*
|
||||
* The upgrade menu is only shown to administrators on free-plan sites
|
||||
* that are not hosted on WordPress.com.
|
||||
*
|
||||
* @return bool True if the upgrade menu should be shown.
|
||||
*/
|
||||
private static function should_show_upgrade_menu() {
|
||||
|
||||
// Only show to administrators.
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Don't show upsells on WordPress.com platform.
|
||||
if ( class_exists( '\Automattic\Jetpack\Status\Host' ) ) {
|
||||
$host = new \Automattic\Jetpack\Status\Host();
|
||||
if ( $host->is_wpcom_platform() ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Don't show upsells in offline/development mode.
|
||||
if ( class_exists( '\Automattic\Jetpack\Status' ) ) {
|
||||
$status = new \Automattic\Jetpack\Status();
|
||||
if ( $status->is_offline_mode() ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Only show after the site and current user are connected.
|
||||
if ( ! self::is_site_and_user_connected() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only show to free-plan sites.
|
||||
return self::is_free_plan();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the site and current user are connected to WordPress.com.
|
||||
*
|
||||
* @return bool True if site and current user are connected.
|
||||
*/
|
||||
private static function is_site_and_user_connected() {
|
||||
$connection_manager = self::$connection_manager;
|
||||
if ( ! $connection_manager && class_exists( '\Automattic\Jetpack\Connection\Manager' ) ) {
|
||||
$connection_manager = new \Automattic\Jetpack\Connection\Manager();
|
||||
self::$connection_manager = $connection_manager;
|
||||
}
|
||||
|
||||
if (
|
||||
$connection_manager
|
||||
&& is_callable( array( $connection_manager, 'is_connected' ) )
|
||||
&& is_callable( array( $connection_manager, 'is_user_connected' ) )
|
||||
) {
|
||||
return (bool) $connection_manager->is_connected()
|
||||
&& (bool) $connection_manager->is_user_connected( get_current_user_id() );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the connection manager dependency; used by tests.
|
||||
*
|
||||
* @param object|null $connection_manager Connection manager object.
|
||||
* @return void
|
||||
*/
|
||||
public static function set_connection_manager( $connection_manager ) {
|
||||
self::$connection_manager = $connection_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the current site is on a free Jetpack plan with no active paid license.
|
||||
*
|
||||
* @return bool True if the site has no paid plan.
|
||||
*/
|
||||
private static function is_free_plan() {
|
||||
// Check the active plan - use the is_free field or product_slug.
|
||||
$plan = get_option( 'jetpack_active_plan', array() );
|
||||
|
||||
// Back-compat: older plan payloads use class to indicate paid plans.
|
||||
if ( isset( $plan['class'] ) && 'free' !== $plan['class'] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the plan explicitly says it's not free, trust that.
|
||||
if ( isset( $plan['is_free'] ) && false === $plan['is_free'] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the product slug indicates a paid plan.
|
||||
if ( isset( $plan['product_slug'] ) && 'jetpack_free' !== $plan['product_slug'] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Also check for site products (licenses can add products without changing plan).
|
||||
$products = get_option( 'jetpack_site_products', array() );
|
||||
if ( ! empty( $products ) && is_array( $products ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Conditionally adds an "Upgrade Jetpack" submenu item for free-plan sites.
|
||||
*
|
||||
* Only shown to users with manage_options capability on self-hosted sites without a paid Jetpack plan or license.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private static function maybe_add_upgrade_menu_item() {
|
||||
if ( ! self::should_show_upgrade_menu() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$upgrade_url = class_exists( '\Automattic\Jetpack\Redirect' )
|
||||
? \Automattic\Jetpack\Redirect::get_url( self::UPGRADE_MENU_SLUG )
|
||||
: self::UPGRADE_MENU_FALLBACK_URL;
|
||||
|
||||
$menu_title = esc_html__( 'Upgrade Jetpack', 'jetpack-admin-ui' );
|
||||
|
||||
add_submenu_page(
|
||||
'jetpack',
|
||||
$menu_title,
|
||||
$menu_title,
|
||||
'manage_options',
|
||||
esc_url( $upgrade_url ),
|
||||
null, // @phan-suppress-current-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
|
||||
999
|
||||
);
|
||||
|
||||
// Add a CSS class to the <li> element so styles can target it precisely.
|
||||
global $submenu;
|
||||
if ( ! empty( $submenu['jetpack'] ) ) {
|
||||
foreach ( $submenu['jetpack'] as $index => $item ) {
|
||||
if ( isset( $item[2] ) && false !== strpos( $item[2], self::UPGRADE_MENU_SLUG ) ) {
|
||||
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
|
||||
$submenu['jetpack'][ $index ][4] = ( ! empty( $item[4] ) ? $item[4] . ' ' : '' ) . self::UPGRADE_MENU_SLUG;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueues admin styles for the "Upgrade Jetpack" menu item.
|
||||
*
|
||||
* The sidebar menu is visible on every admin page, so styles load globally.
|
||||
* Only enqueues for free-plan sites on self-hosted installs.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function add_upgrade_menu_item_styles() {
|
||||
if ( ! self::should_show_upgrade_menu() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$asset_file = dirname( __DIR__ ) . '/build/admin-ui-upgrade-menu.asset.php';
|
||||
$asset = file_exists( $asset_file ) ? require $asset_file : array();
|
||||
|
||||
wp_enqueue_style(
|
||||
'jetpack-admin-ui-upgrade-menu',
|
||||
plugins_url( '../build/admin-ui-upgrade-menu.css', __FILE__ ),
|
||||
$asset['dependencies'] ?? array(),
|
||||
$asset['version'] ?? self::PACKAGE_VERSION
|
||||
);
|
||||
|
||||
self::enqueue_upgrade_menu_tracks_script( $asset );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueues the shared, token-only WPDS design-tokens stylesheet.
|
||||
*
|
||||
* Single entry point for any consumer that needs WPDS `var(--wpds-*)` values
|
||||
* to resolve at runtime on a Jetpack admin page. Registers the handle on
|
||||
* first use (idempotent) and enqueues it; the caller is responsible for
|
||||
* scoping the call to the right page(s). Since admin-ui is a dependency of
|
||||
* the Jetpack plugin and the modernized packages, both the plugin's
|
||||
* legacy/wrap_ui gate and this package's own dashboards call through here,
|
||||
* so the handle has a single owner and there is no duplicated enqueue logic.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function enqueue_design_tokens() {
|
||||
self::register_design_tokens_style();
|
||||
wp_enqueue_style( self::DESIGN_TOKENS_HANDLE );
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the shared, token-only WPDS design-tokens stylesheet.
|
||||
*
|
||||
* The stylesheet only defines `:root{--wpds-*}` custom properties (no
|
||||
* component or class styles), giving every Jetpack admin page a single
|
||||
* runtime source for design tokens. It is safe to call repeatedly:
|
||||
* wp_register_style() is a no-op once the handle is registered.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private static function register_design_tokens_style() {
|
||||
if ( wp_style_is( self::DESIGN_TOKENS_HANDLE, 'registered' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$asset_file = dirname( __DIR__ ) . '/build/design-tokens.asset.php';
|
||||
$asset = file_exists( $asset_file ) ? require $asset_file : array();
|
||||
|
||||
wp_register_style(
|
||||
self::DESIGN_TOKENS_HANDLE,
|
||||
plugins_url( '../build/design-tokens.css', __FILE__ ),
|
||||
$asset['dependencies'] ?? array(),
|
||||
$asset['version'] ?? self::PACKAGE_VERSION
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueues the design tokens on the pages registered through this class.
|
||||
*
|
||||
* This is the admin_enqueue_scripts callback for the modernized Jetpack
|
||||
* dashboards. Scoped to self::$page_hooks so the tokens load wherever a
|
||||
* modernized dashboard renders, regardless of plan or connection state; the
|
||||
* actual enqueue is delegated to the reusable enqueue_design_tokens() API.
|
||||
*
|
||||
* @param string $hook_suffix The current admin page's hook suffix.
|
||||
* @return void
|
||||
*/
|
||||
public static function maybe_enqueue_design_tokens( $hook_suffix ) {
|
||||
if ( ! in_array( $hook_suffix, self::$page_hooks, true ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
self::enqueue_design_tokens();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueues Tracks for the upgrade submenu item.
|
||||
*
|
||||
* @param array $asset Parsed contents of admin-ui-upgrade-menu.asset.php.
|
||||
* @return void
|
||||
*/
|
||||
private static function enqueue_upgrade_menu_tracks_script( $asset ) {
|
||||
if ( ! class_exists( '\Automattic\Jetpack\Tracking' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
Tracking::register_tracks_functions_scripts( true );
|
||||
|
||||
wp_enqueue_script(
|
||||
'jetpack-admin-ui-upgrade-menu-tracking',
|
||||
plugins_url( '../build/admin-ui-upgrade-menu-tracking.js', __FILE__ ),
|
||||
$asset['dependencies'] ?? array(),
|
||||
$asset['version'] ?? self::PACKAGE_VERSION,
|
||||
true
|
||||
);
|
||||
|
||||
$current_screen = get_current_screen();
|
||||
$is_admin = current_user_can( 'jetpack_disconnect' );
|
||||
$site_id = class_exists( 'Jetpack_Options' ) ? Jetpack_Options::get_option( 'id' ) : null;
|
||||
$tracks_user_data = class_exists( 'Jetpack_Tracks_Client' ) ? Jetpack_Tracks_Client::get_connected_user_tracks_identity() : null;
|
||||
|
||||
wp_localize_script(
|
||||
'jetpack-admin-ui-upgrade-menu-tracking',
|
||||
'jetpackAdminUiUpgradeMenu',
|
||||
array(
|
||||
'menuItemClass' => self::UPGRADE_MENU_SLUG,
|
||||
'tracksUserData' => $tracks_user_data,
|
||||
'tracksEventData' => array(
|
||||
'is_admin' => $is_admin,
|
||||
'current_screen' => $current_screen ? $current_screen->id : false,
|
||||
'blog_id' => $site_id,
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Token-only WPDS design-tokens stylesheet.
|
||||
*
|
||||
* Re-exports the `:root{--wpds-*}` custom-property definitions from
|
||||
* @wordpress/theme so they can be enqueued as a standalone WP style handle on
|
||||
* every Jetpack admin page. The import is resolved and inlined by css-loader at
|
||||
* build time (a local entry file is used rather than pointing the webpack entry
|
||||
* straight at the package, which would get externalized to a non-existent
|
||||
* `wp-theme/design-tokens.css` script handle).
|
||||
*
|
||||
* Keep this token-only: do not add component or class selectors here.
|
||||
*/
|
||||
@import "@wordpress/theme/design-tokens.css";
|
||||
Reference in New Issue
Block a user