automattic/jetpack-my-jetpack
Composer 安装命令:
composer require automattic/jetpack-my-jetpack
包简介
WP Admin page with information and configuration shared among all Jetpack stand-alone plugins
README 文档
README
WP Admin page with information and configuration shared among all Jetpack stand-alone plugins
Overview
My Jetpack is a centralized WordPress admin page that provides a unified interface for managing all Jetpack products and services. It serves as the main dashboard where users can view, install, configure, and manage their Jetpack products.
Usage
Every Jetpack plugin must include the My Jetpack package.
Require this package and initialize it:
add_action( 'init', function() { Automattic\Jetpack\My_Jetpack\Initializer::init(); } );
Conditionally loading licensing UI behind a feature flag
To disable the licensing UI at /wp-admin/admin.php?page=my-jetpack#/add-license, add a filter on jetpack_my_jetpack_should_enable_add_license_screen and return false: add_filter( 'jetpack_my_jetpack_should_enable_add_license_screen', '__return_false' );
Architecture
Core Components
PHP Backend (src/)
- Initializer (
class-initializer.php): Main entry point that sets up admin menu, REST endpoints, and asset enqueuing - Products (
class-products.php): Core product management system with status constants and lifecycle handling - Product Classes (
src/products/): Individual product implementations inheriting from baseProductclass - REST API (
class-rest-*.php): API endpoints for product management, purchases, and AI functionality
React Frontend (_inc/)
- Main App (
admin.jsx): Entry point with React Router setup - Components (
components/): Reusable UI components for product cards, screens, and interstitials - Data Layer (
data/): Custom hooks and API integration using React Query (see Data Layer Documentation) - Context (
context/): Global state management for notices and values
Product System
- Products inherit from base
Productclass with standardized interface - Status constants define product lifecycle:
active,inactive,needs_plan,plugin_absent, etc. - Hybrid products can function as both standalone plugins and Jetpack modules
- Product cards dynamically display status, actions, and pricing information
Key Features
- Connection Management: Handles WordPress.com site and user connections
- Product Interstitials: Purchase/activation flows for each product
- Onboarding Flow: Guided setup for new users
- Licensing: License key management and validation
- Activity Log: Integration with Jetpack activity monitoring
- Speed Score: Boost performance metrics integration
Frontend Architecture
- React 18 with functional components and hooks
- React Router for client-side navigation
- CSS Modules for component styling
- TypeScript for type safety
- Custom data hooks using React Query for API state management
Build System
- Webpack with Jetpack-specific configuration
- Babel for JavaScript transpilation
- Sass for CSS preprocessing
- Asset optimization for production builds
- Textdomain replacement for internationalization
Development
Commands
Build Commands:
jetpack build packages/my-jetpack- Build from monorepo rootjetpack watch packages/my-jetpack- Watch mode from monorepo rootpnpm run build- Build from package directorypnpm run test- Run tests from package directory
Testing Strategy
Testing:
- PHP: PHPUnit with WordPress test environment and polyfills
- JavaScript: Jest with React Testing Library
- E2E: Integration with monorepo Playwright setup
Development Notes
Code Standards:
- Uses WordPress coding standards and Jetpack extensions
- Requires WordPress.com connection for full functionality
- Integrates with Jetpack licensing and purchase systems
- Supports feature flags for gradual rollouts
- Compatible with WordPress multisite (when enabled)
API Endpoints
REST API Patterns
- Base namespace:
jetpack/v4/my-jetpack - Products endpoint:
/products- main product data and actions - Purchases endpoint:
/purchases- user purchase information - Feature endpoints: Various feature-specific endpoints
Data Flow
- React components call API via
apiFetch - WordPress routes to appropriate REST controller
- Controller validates permissions and processes request
- Product classes handle business logic
- Response returned to frontend for UI updates
Key Files Reference
PHP Files
src/class-initializer.php- Main initialization, admin menu setupsrc/class-products.php- Core product management, status constantssrc/products/class-product.php- Base product classsrc/class-rest-products.php- Main products API endpointsrc/class-wpcom-products.php- WordPress.com product integration
React Files
_inc/admin.jsx- Main React application entry point_inc/providers.tsx- Context providers wrapper_inc/constants.ts- Route definitions and constants_inc/components/my-jetpack-screen/- Main dashboard screen_inc/components/product-interstitial/- Product setup flows_inc/data/- API hooks and data management using React Query
Configuration Files
package.json- Dependencies and scriptswebpack.config.js- Build configurationbabel.config.js- JavaScript transpilationtsconfig.json- TypeScript configuration
Using this package in your WordPress plugin
If you plan on using this package in your WordPress plugin, we would recommend that you use Jetpack Autoloader as your autoloader. This will allow for maximum interoperability with other plugins that use this package as well.
Security
Need to report a security vulnerability? Go to https://automattic.com/security/ or directly to our security bug bounty site https://hackerone.com/automattic.
License
my-jetpack is licensed under GNU General Public License v2 (or later)
automattic/jetpack-my-jetpack 适用场景与选型建议
automattic/jetpack-my-jetpack 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 39.87k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2021 年 11 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 automattic/jetpack-my-jetpack 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 automattic/jetpack-my-jetpack 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 automattic/jetpack-my-jetpack 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This module allows drag & drop grouping of items in a GridField
Adds text size controls and text-to-speech controls to Flarum discussion content.
Native Blade date, datetime, and date range pickers.
Symfony and Flysystem integration for the maintained KCFinder continuation.
Laravel integration for the maintained KCFinder continuation.
PHPStan rules shared across KnpLabs organization projects
统计信息
- 总下载量: 39.87k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 9
- 依赖项目数: 9
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2021-11-23