diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 59232831970ac..e7307ff2d6a12 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3368,6 +3368,71 @@ importers: specifier: 6.0.1 version: 6.0.1(webpack@5.101.3) + projects/packages/newsletter: + dependencies: + '@wordpress/dataviews': + specifier: 10.2.0 + version: 10.2.0(patch_hash=2659f08edd4c0250f15fb428f013852a17e84da9c745e6dae6307de837e4d30b)(@types/react@18.3.26)(react@18.3.1) + '@wordpress/element': + specifier: 6.35.0 + version: 6.35.0(patch_hash=2659f08edd4c0250f15fb428f013852a17e84da9c745e6dae6307de837e4d30b) + '@wordpress/i18n': + specifier: 6.8.0 + version: 6.8.0(patch_hash=0c63a888feb97f2f1d416ca013ad85c31b6360b41cc0b6e2b0ae28f778fbdc5b) + debug: + specifier: 4.4.1 + version: 4.4.1 + devDependencies: + '@automattic/babel-plugin-replace-textdomain': + specifier: workspace:* + version: link:../../js-packages/babel-plugin-replace-textdomain + '@automattic/jetpack-webpack-config': + specifier: workspace:* + version: link:../../js-packages/webpack-config + '@babel/core': + specifier: 7.28.4 + version: 7.28.4 + '@babel/runtime': + specifier: 7.28.4 + version: 7.28.4 + '@types/react': + specifier: 18.3.26 + version: 18.3.26 + '@types/react-dom': + specifier: 18.3.7 + version: 18.3.7(@types/react@18.3.26) + '@wordpress/browserslist-config': + specifier: 6.35.0 + version: 6.35.0 + concurrently: + specifier: 9.2.1 + version: 9.2.1 + jest: + specifier: 30.2.0 + version: 30.2.0 + sass-embedded: + specifier: 1.87.0 + version: 1.87.0 + sass-loader: + specifier: 16.0.5 + version: 16.0.5(sass-embedded@1.87.0)(webpack@5.101.3) + typescript: + specifier: 5.9.3 + version: 5.9.3 + webpack: + specifier: 5.101.3 + version: 5.101.3(webpack-cli@6.0.1) + webpack-cli: + specifier: 6.0.1 + version: 6.0.1(webpack@5.101.3) + optionalDependencies: + react: + specifier: 18.3.1 + version: 18.3.1 + react-dom: + specifier: 18.3.1 + version: 18.3.1(react@18.3.1) + projects/packages/paypal-payments: dependencies: '@automattic/babel-plugin-replace-textdomain': @@ -4826,6 +4891,9 @@ importers: '@automattic/jetpack-my-jetpack': specifier: workspace:* version: link:../../packages/my-jetpack + '@automattic/jetpack-newsletter': + specifier: workspace:* + version: link:../../packages/newsletter '@automattic/jetpack-partner-coupon': specifier: workspace:* version: link:../../js-packages/partner-coupon diff --git a/projects/packages/newsletter/.babelrc b/projects/packages/newsletter/.babelrc new file mode 100644 index 0000000000000..cf088480ee9fb --- /dev/null +++ b/projects/packages/newsletter/.babelrc @@ -0,0 +1,9 @@ +{ + "presets": [ + ["@babel/preset-env", { + "targets": { + "node": "current" + } + }] + ] +} diff --git a/projects/packages/newsletter/.gitattributes b/projects/packages/newsletter/.gitattributes new file mode 100644 index 0000000000000..b1f8617a0aa94 --- /dev/null +++ b/projects/packages/newsletter/.gitattributes @@ -0,0 +1,20 @@ +# Files not needed to be distributed in the package. +.gitattributes export-ignore +.github/ export-ignore +package.json export-ignore + +# Files to include in the mirror repo, but excluded via gitignore +# Remember to end all directories with `/**` to properly tag every file. +/build/** production-include + +# Files to exclude from the mirror repo, but included in the monorepo. +# Remember to end all directories with `/**` to properly tag every file. +.gitignore production-exclude +changelog/** production-exclude +.phpcs.dir.xml production-exclude +tests/** production-exclude +.phpcsignore production-exclude +tsconfig.json production-exclude +global.d.ts production-exclude +src/**/*.scss production-exclude +src/**/*.tsx production-exclude diff --git a/projects/packages/newsletter/.gitignore b/projects/packages/newsletter/.gitignore new file mode 100644 index 0000000000000..fe707006150ce --- /dev/null +++ b/projects/packages/newsletter/.gitignore @@ -0,0 +1,4 @@ +vendor/ +node_modules/ +.cache/ +build/ diff --git a/projects/packages/newsletter/.phan/baseline.php b/projects/packages/newsletter/.phan/baseline.php new file mode 100644 index 0000000000000..3df50068147ad --- /dev/null +++ b/projects/packages/newsletter/.phan/baseline.php @@ -0,0 +1,17 @@ + [ + ], + // 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed. + // (directory_suppressions will currently be ignored by subsequent calls to --save-baseline, but may be preserved in future Phan releases) +]; diff --git a/projects/packages/newsletter/.phan/config.php b/projects/packages/newsletter/.phan/config.php new file mode 100644 index 0000000000000..00eb11c8f2c05 --- /dev/null +++ b/projects/packages/newsletter/.phan/config.php @@ -0,0 +1,13 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/projects/packages/newsletter/CHANGELOG.md b/projects/packages/newsletter/CHANGELOG.md new file mode 100644 index 0000000000000..721294abd00ad --- /dev/null +++ b/projects/packages/newsletter/CHANGELOG.md @@ -0,0 +1,7 @@ +# 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). + diff --git a/projects/packages/newsletter/README.md b/projects/packages/newsletter/README.md new file mode 100644 index 0000000000000..da065926f9102 --- /dev/null +++ b/projects/packages/newsletter/README.md @@ -0,0 +1,15 @@ +# Jetpack Newsletter + +This package will hold the implementation for Jetpack's newsletter functionality - dashboard, blocks and more. + +## 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](https://packagist.org/packages/automattic/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/](https://automattic.com/security/) or directly to our security bug bounty site [https://hackerone.com/automattic](https://hackerone.com/automattic). + +## License + +Jetpack Newsletter is licensed under [GNU General Public License v2 (or later)](./LICENSE.txt) diff --git a/projects/packages/newsletter/changelog/.gitkeep b/projects/packages/newsletter/changelog/.gitkeep new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/projects/packages/newsletter/changelog/initial-version b/projects/packages/newsletter/changelog/initial-version new file mode 100644 index 0000000000000..fb1837c901e51 --- /dev/null +++ b/projects/packages/newsletter/changelog/initial-version @@ -0,0 +1,4 @@ +Significance: patch +Type: added + +Initial version. diff --git a/projects/packages/newsletter/composer.json b/projects/packages/newsletter/composer.json new file mode 100644 index 0000000000000..2d086ab77557f --- /dev/null +++ b/projects/packages/newsletter/composer.json @@ -0,0 +1,67 @@ +{ + "name": "automattic/jetpack-newsletter", + "description": "Jetpack Newsletter functionality", + "type": "jetpack-library", + "license": "GPL-2.0-or-later", + "require": { + "php": ">=7.2", + "automattic/jetpack-admin-ui": "@dev", + "automattic/jetpack-assets": "@dev", + "automattic/jetpack-status": "@dev" + }, + "require-dev": { + "yoast/phpunit-polyfills": "^4.0.0", + "automattic/jetpack-changelogger": "@dev", + "automattic/phpunit-select-config": "@dev" + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "scripts": { + "build-development": "pnpm run build", + "build-production": "pnpm run build-production", + "watch": [ + "Composer\\Config::disableProcessTimeout", + "pnpm run watch" + ], + "phpunit": [ + "phpunit-select-config phpunit.#.xml.dist --colors=always" + ], + "test-coverage": "pnpm concurrently --names php,js 'php -dpcov.directory=. ./vendor/bin/phpunit-select-config phpunit.#.xml.dist --coverage-php \"$COVERAGE_DIR/php.cov\"' 'pnpm:test-coverage'", + "test-php": [ + "@composer phpunit" + ], + "typecheck": "pnpm run typecheck" + }, + "repositories": [ + { + "type": "path", + "url": "../../packages/*", + "options": { + "monorepo": true + } + } + ], + "minimum-stability": "dev", + "prefer-stable": true, + "extra": { + "autorelease": true, + "autotagger": true, + "mirror-repo": "Automattic/jetpack-newsletter", + "branch-alias": { + "dev-trunk": "0.1.x-dev" + }, + "textdomain": "jetpack-newsletter", + "version-constants": { + "::PACKAGE_VERSION": "src/class-settings.php" + }, + "changelogger": { + "link-template": "https://github.com/Automattic/jetpack-newsletter/compare/v${old}...v${new}" + } + }, + "suggest": { + "automattic/jetpack-autoloader": "Allow for better interoperability with other plugins that use this package." + } +} diff --git a/projects/packages/newsletter/package.json b/projects/packages/newsletter/package.json new file mode 100644 index 0000000000000..1b66077ab1ced --- /dev/null +++ b/projects/packages/newsletter/package.json @@ -0,0 +1,60 @@ +{ + "name": "@automattic/jetpack-newsletter", + "version": "0.1.0-alpha", + "private": true, + "description": "Jetpack Newsletter functionality", + "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/newsletter/#readme", + "bugs": { + "url": "https://github.com/Automattic/jetpack/labels/[Package] Newsletter" + }, + "repository": { + "type": "git", + "url": "https://github.com/Automattic/jetpack.git", + "directory": "projects/packages/newsletter" + }, + "license": "GPL-2.0-or-later", + "author": "Automattic", + "type": "module", + "scripts": { + "build": "pnpm run clean && pnpm run build-client", + "build-client": "pnpm webpack --config webpack.config.js", + "build-js": "webpack --config webpack.config.js", + "build-production": "pnpm run clean && pnpm run build-production-js && pnpm run validate", + "build-production-js": "NODE_ENV=production BABEL_ENV=production pnpm run build-js", + "clean": "rm -rf build/", + "test": "jest --config=tests/jest.config.js --passWithNoTests", + "test-coverage": "pnpm run test --coverage", + "typecheck": "tsc --noEmit", + "validate": "pnpm exec validate-es build/", + "watch": "pnpm run build && pnpm webpack watch" + }, + "browserslist": [ + "extends @wordpress/browserslist-config" + ], + "dependencies": { + "@wordpress/dataviews": "10.2.0", + "@wordpress/element": "6.35.0", + "@wordpress/i18n": "6.8.0", + "debug": "4.4.1" + }, + "devDependencies": { + "@automattic/babel-plugin-replace-textdomain": "workspace:*", + "@automattic/jetpack-webpack-config": "workspace:*", + "@babel/core": "7.28.4", + "@babel/runtime": "7.28.4", + "@types/react": "18.3.26", + "@types/react-dom": "18.3.7", + "@wordpress/browserslist-config": "6.35.0", + "concurrently": "9.2.1", + "jest": "30.2.0", + "sass-embedded": "1.87.0", + "sass-loader": "16.0.5", + "typescript": "5.9.3", + "webpack": "5.101.3", + "webpack-cli": "6.0.1" + }, + "optionalDependencies": { + "react": "18.3.1", + "react-dom": "18.3.1" + } +} diff --git a/projects/packages/newsletter/phpunit.11.xml.dist b/projects/packages/newsletter/phpunit.11.xml.dist new file mode 100644 index 0000000000000..44db84cadf141 --- /dev/null +++ b/projects/packages/newsletter/phpunit.11.xml.dist @@ -0,0 +1,36 @@ + + + + + tests/php + + + + + + + + src + + + + + diff --git a/projects/packages/newsletter/phpunit.12.xml.dist b/projects/packages/newsletter/phpunit.12.xml.dist new file mode 120000 index 0000000000000..9fdb7a2c745c9 --- /dev/null +++ b/projects/packages/newsletter/phpunit.12.xml.dist @@ -0,0 +1 @@ +phpunit.11.xml.dist \ No newline at end of file diff --git a/projects/packages/newsletter/phpunit.8.xml.dist b/projects/packages/newsletter/phpunit.8.xml.dist new file mode 120000 index 0000000000000..707bde67863cf --- /dev/null +++ b/projects/packages/newsletter/phpunit.8.xml.dist @@ -0,0 +1 @@ +phpunit.9.xml.dist \ No newline at end of file diff --git a/projects/packages/newsletter/phpunit.9.xml.dist b/projects/packages/newsletter/phpunit.9.xml.dist new file mode 100644 index 0000000000000..3965963c485e7 --- /dev/null +++ b/projects/packages/newsletter/phpunit.9.xml.dist @@ -0,0 +1,17 @@ + + + + + tests/php + + + diff --git a/projects/packages/newsletter/src/class-settings.php b/projects/packages/newsletter/src/class-settings.php new file mode 100644 index 0000000000000..34a7d3155564c --- /dev/null +++ b/projects/packages/newsletter/src/class-settings.php @@ -0,0 +1,136 @@ +init_hooks(); + } + } + + /** + * Determine whether to expose the new settings UI to users. + * + * @return bool + */ + private function expose_to_users() { + /** + * Enables the new in-development newsletter settings UI in wp-admin. + * + * @since 15.3.0 + * + * @param bool $enabled Whether to enable the new newsletter settings UI. Default false. + */ + return apply_filters( 'jetpack_wp_admin_newsletter_settings_enabled', false ); + } + + /** + * Subscribe to necessary hooks. + */ + public function init_hooks() { + if ( ! $this->expose_to_users() ) { + return; + } + // Add admin menu item. + add_action( 'admin_menu', array( $this, 'add_wp_admin_menu' ), 1000 ); + + // Hijack the config URLs to point to our settings page. + // Customize the configuration URL to lead to the Subscriptions settings. + add_filter( + 'jetpack_module_configuration_url_subscriptions', + function () { + return ( new Paths() )->admin_url( array( 'page' => 'jetpack-newsletter' ) ); + } + ); + } + + /** + * Add the newsletter settings menu to the Jetpack menu. + */ + public function add_wp_admin_menu() { + if ( ( new Host() )->is_wpcom_platform() ) { + $page_suffix = add_submenu_page( + 'jetpack', + /** "Newsletter" is a product name, do not translate. */ + 'Newsletter', + 'Newsletter', + 'manage_options', + 'jetpack-newsletter', + array( $this, 'render' ) + ); + } else { + $page_suffix = Admin_Menu::add_menu( + /** "Newsletter" is a product name, do not translate. */ + 'Newsletter', + 'Newsletter', + 'manage_options', + 'jetpack-newsletter', + array( $this, 'render' ), + 10 + ); + } + + if ( $page_suffix ) { + add_action( 'load-' . $page_suffix, array( $this, 'admin_init' ) ); + } + } + + /** + * Admin init actions. + */ + public function admin_init() { + add_action( 'admin_enqueue_scripts', array( $this, 'load_admin_scripts' ) ); + } + + /** + * Load the admin scripts. + */ + public function load_admin_scripts() { + Assets::register_script( + 'jetpack-newsletter', + '../build/newsletter.js', + __FILE__, + array( + 'in_footer' => true, + 'textdomain' => 'jetpack-newsletter', + 'enqueue' => true, + ) + ); + } + + /** + * Render the newsletter settings page. + */ + public function render() { + ?> +
+ +

Newsletter Settings

+

This is a proof of concept, I am rendered via React.

+ + ); +} + +// Initialize the app when DOM is ready +const container = document.getElementById( 'newsletter-settings-root' ); +if ( container ) { + const root = createRoot( container ); + root.render( ); +} diff --git a/projects/packages/newsletter/src/settings/style.scss b/projects/packages/newsletter/src/settings/style.scss new file mode 100644 index 0000000000000..91745bc2630fd --- /dev/null +++ b/projects/packages/newsletter/src/settings/style.scss @@ -0,0 +1,8 @@ +.newsletter-settings { + padding: 20px; + + h1 { + font-size: 24px; + margin-bottom: 16px; + } +} diff --git a/projects/packages/newsletter/tests/.phpcs.dir.xml b/projects/packages/newsletter/tests/.phpcs.dir.xml new file mode 100644 index 0000000000000..46951fe77b37e --- /dev/null +++ b/projects/packages/newsletter/tests/.phpcs.dir.xml @@ -0,0 +1,4 @@ + + + + diff --git a/projects/packages/newsletter/tests/jest.config.js b/projects/packages/newsletter/tests/jest.config.js new file mode 100644 index 0000000000000..8df108c6b907a --- /dev/null +++ b/projects/packages/newsletter/tests/jest.config.js @@ -0,0 +1,12 @@ +import path from 'path'; +import { fileURLToPath } from 'url'; +import baseConfig from 'jetpack-js-tools/jest/config.base.js'; + +const __filename = fileURLToPath( import.meta.url ); +const __dirname = path.dirname( __filename ); + +export default { + ...baseConfig, + rootDir: path.join( __dirname, '..' ), + setupFilesAfterEnv: [ ...baseConfig.setupFilesAfterEnv, '/tests/jest.setup.js' ], +}; diff --git a/projects/packages/newsletter/tests/jest.setup.js b/projects/packages/newsletter/tests/jest.setup.js new file mode 100644 index 0000000000000..04d70fb00b062 --- /dev/null +++ b/projects/packages/newsletter/tests/jest.setup.js @@ -0,0 +1,7 @@ +window.JP_CONNECTION_INITIAL_STATE = { + userConnectionData: { + currentUser: { + wpcomUser: { Id: 99999, login: 'bobsacrmaneto', display_name: 'Bob Sacrmaneto' }, + }, + }, +}; diff --git a/projects/packages/newsletter/tests/php/bootstrap.php b/projects/packages/newsletter/tests/php/bootstrap.php new file mode 100644 index 0000000000000..46763b04a2cdb --- /dev/null +++ b/projects/packages/newsletter/tests/php/bootstrap.php @@ -0,0 +1,11 @@ + + Object.fromEntries( + Array.from( { length: 100 }, ( _, i ) => [ + `${ baseFn }${ i || '' }`, // empty suffix for 0 + value, + ] ) + ); + +export default { + mode: jetpackWebpackConfig.mode, + entry: { + newsletter: path.join( __dirname, 'src/settings/index.tsx' ), + }, + output: { + ...jetpackWebpackConfig.output, + path: path.join( __dirname, 'build' ), + }, + optimization: { + ...jetpackWebpackConfig.optimization, + }, + resolve: { + ...jetpackWebpackConfig.resolve, + modules: [ 'node_modules' ], + alias: { + ...jetpackWebpackConfig.resolve.alias, + fs: false, + }, + }, + externals: { + ...jetpackWebpackConfig.externals, + jetpackConfig: JSON.stringify( { + consumer_slug: 'newsletter', + } ), + }, + module: { + rules: [ + // Gutenberg packages' ESM builds don't fully specify their imports. Sigh. + // https://github.com/WordPress/gutenberg/issues/73362 + { + test: /\/node_modules\/@wordpress\/.*\/build-module\/.*\.js$/, + resolve: { fullySpecified: false }, + }, + + // Transpile JavaScript and TypeScript + jetpackWebpackConfig.TranspileRule( { + exclude: /node_modules\//, + } ), + + // Transpile @automattic/* in node_modules too. + jetpackWebpackConfig.TranspileRule( { + includeNodeModules: [ '@automattic/', 'debug/' ], + } ), + + /** + * Transpile @wordpress/dataviews in node_modules too. + * + * @see https://github.com/Automattic/jetpack/issues/39907 + */ + jetpackWebpackConfig.TranspileRule( { + includeNodeModules: [ '@wordpress/dataviews/build-wp/' ], + babelOpts: { + configFile: false, + plugins: [ + [ + require.resolve( '@automattic/babel-plugin-replace-textdomain' ), + { + textdomain: 'jetpack-newsletter', + functions: { + ...generateI18nVariants( '__', 1 ), + ...generateI18nVariants( '_x', 2 ), + ...generateI18nVariants( '_n', 3 ), + }, + }, + ], + ], + }, + } ), + + // Handle CSS. + jetpackWebpackConfig.CssRule( { + extensions: [ 'css', 'sass', 'scss' ], + extraLoaders: [ { loader: 'sass-loader', options: { api: 'modern-compiler' } } ], + } ), + + // Handle images. + jetpackWebpackConfig.FileRule(), + ], + }, + plugins: [ + ...jetpackWebpackConfig.StandardPlugins( { + DependencyExtractionPlugin: { + requestMap: { + // Bundle the package with our assets until WP core exposes wp-admin-ui. + '@wordpress/admin-ui': { external: false }, + }, + }, + } ), + ], + watchOptions: { + ...jetpackWebpackConfig.watchOptions, + }, +}; diff --git a/projects/plugins/jetpack/changelog/skeleton-jetpack-newsletter b/projects/plugins/jetpack/changelog/skeleton-jetpack-newsletter new file mode 100644 index 0000000000000..aab136cc04b43 --- /dev/null +++ b/projects/plugins/jetpack/changelog/skeleton-jetpack-newsletter @@ -0,0 +1,4 @@ +Significance: minor +Type: other + +Newsletters: Add skeleton for new settings screen diff --git a/projects/plugins/jetpack/composer.json b/projects/plugins/jetpack/composer.json index 00e73f8f87b96..d514d0636ddc4 100644 --- a/projects/plugins/jetpack/composer.json +++ b/projects/plugins/jetpack/composer.json @@ -40,6 +40,7 @@ "automattic/jetpack-logo": "@dev", "automattic/jetpack-masterbar": "@dev", "automattic/jetpack-my-jetpack": "@dev", + "automattic/jetpack-newsletter": "@dev", "automattic/jetpack-paypal-payments": "@dev", "automattic/jetpack-plugins-installer": "@dev", "automattic/jetpack-post-list": "@dev", diff --git a/projects/plugins/jetpack/composer.lock b/projects/plugins/jetpack/composer.lock index cc93009ead209..60dc4ff4bd545 100644 --- a/projects/plugins/jetpack/composer.lock +++ b/projects/plugins/jetpack/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "708db098186de11f46e06a9f1d11e58a", + "content-hash": "513d4f057e5ac1783b24badcd64f982b", "packages": [ { "name": "automattic/block-delimiter", @@ -2181,6 +2181,81 @@ "relative": true } }, + { + "name": "automattic/jetpack-newsletter", + "version": "dev-trunk", + "dist": { + "type": "path", + "url": "../../packages/newsletter", + "reference": "70c4fd8f9ebed459812e69b15a21152a4a8e9a0d" + }, + "require": { + "automattic/jetpack-admin-ui": "@dev", + "automattic/jetpack-assets": "@dev", + "automattic/jetpack-status": "@dev", + "php": ">=7.2" + }, + "require-dev": { + "automattic/jetpack-changelogger": "@dev", + "automattic/phpunit-select-config": "@dev", + "yoast/phpunit-polyfills": "^4.0.0" + }, + "suggest": { + "automattic/jetpack-autoloader": "Allow for better interoperability with other plugins that use this package." + }, + "type": "jetpack-library", + "extra": { + "autorelease": true, + "autotagger": true, + "mirror-repo": "Automattic/jetpack-newsletter", + "branch-alias": { + "dev-trunk": "0.1.x-dev" + }, + "textdomain": "jetpack-newsletter", + "version-constants": { + "::PACKAGE_VERSION": "src/class-settings.php" + }, + "changelogger": { + "link-template": "https://github.com/Automattic/jetpack-newsletter/compare/v${old}...v${new}" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "scripts": { + "build-development": [ + "pnpm run build" + ], + "build-production": [ + "pnpm run build-production" + ], + "watch": [ + "Composer\\Config::disableProcessTimeout", + "pnpm run watch" + ], + "phpunit": [ + "phpunit-select-config phpunit.#.xml.dist --colors=always" + ], + "test-coverage": [ + "pnpm concurrently --names php,js 'php -dpcov.directory=. ./vendor/bin/phpunit-select-config phpunit.#.xml.dist --coverage-php \"$COVERAGE_DIR/php.cov\"' 'pnpm:test-coverage'" + ], + "test-php": [ + "@composer phpunit" + ], + "typecheck": [ + "pnpm run typecheck" + ] + }, + "license": [ + "GPL-2.0-or-later" + ], + "description": "Jetpack Newsletter functionality", + "transport-options": { + "relative": true + } + }, { "name": "automattic/jetpack-password-checker", "version": "dev-trunk", @@ -6358,6 +6433,7 @@ "automattic/jetpack-logo": 20, "automattic/jetpack-masterbar": 20, "automattic/jetpack-my-jetpack": 20, + "automattic/jetpack-newsletter": 20, "automattic/jetpack-paypal-payments": 20, "automattic/jetpack-plugins-installer": 20, "automattic/jetpack-post-list": 20, diff --git a/projects/plugins/jetpack/modules/subscriptions.php b/projects/plugins/jetpack/modules/subscriptions.php index 3a1876a626965..e8341a063918e 100644 --- a/projects/plugins/jetpack/modules/subscriptions.php +++ b/projects/plugins/jetpack/modules/subscriptions.php @@ -18,6 +18,7 @@ use Automattic\Jetpack\Admin_UI\Admin_Menu; use Automattic\Jetpack\Connection\Manager as Connection_Manager; use Automattic\Jetpack\Connection\XMLRPC_Async_Call; +use Automattic\Jetpack\Newsletter\Settings as Newsletter_Settings; use Automattic\Jetpack\Redirect; use Automattic\Jetpack\Status; use Automattic\Jetpack\Status\Host; @@ -157,6 +158,9 @@ function () { add_action( 'wp_ajax_add-tag', array( $this, 'track_newsletter_category_creation' ), 1 ); $subscribers_dashboard = new Subscribers_Dashboard(); $subscribers_dashboard::init(); + + $newsletter_settings = new Newsletter_Settings(); + $newsletter_settings::init(); } /** diff --git a/projects/plugins/jetpack/package.json b/projects/plugins/jetpack/package.json index 33a9f6657bed8..35508590a0fd5 100644 --- a/projects/plugins/jetpack/package.json +++ b/projects/plugins/jetpack/package.json @@ -52,6 +52,7 @@ "@automattic/jetpack-explat": "workspace:*", "@automattic/jetpack-licensing": "workspace:*", "@automattic/jetpack-my-jetpack": "workspace:*", + "@automattic/jetpack-newsletter": "workspace:*", "@automattic/jetpack-partner-coupon": "workspace:*", "@automattic/jetpack-script-data": "workspace:*", "@automattic/jetpack-shared-extension-utils": "workspace:*",