From 20c2cc831f67cc36804dbf9e90ac69abd15b0fda Mon Sep 17 00:00:00 2001 From: Christian Gastrell Date: Thu, 12 Nov 2026 17:52:03 -0300 Subject: [PATCH 1/4] Settings: Move the Comments settings into the settings panel Behind the my-jetpack-settings-consolidation flag. The My Jetpack panel holds the Comments module switch, the blocks-in-comments option and the comment form introduction, which saves on blur. The Jetpack plugin prints comment block availability to My Jetpack script data; without it, the panel hides the blocks option. With the flag on, admins get search pointers instead of the Comments card, the Discussion tab hides, and #/discussion opens the panel. Co-Authored-By: Claude Opus 5.5 --- .../components/settings-panel/comments.tsx | 94 ++++++++++++ .../components/settings-panel/registry.ts | 2 + .../settings-panel/test/comments.test.tsx | 135 ++++++++++++++++++ .../settings-panel/use-module-text-setting.ts | 64 +++++++++ .../changelog/change-settings-comments-panel | 5 + .../my-jetpack/src/class-initializer.php | 2 +- .../components/settings-nav-tabs/index.jsx | 6 +- .../settings-nav-tabs/test/component.jsx | 3 + .../_inc/client/discussion/comments-moved.jsx | 19 +++ .../jetpack/_inc/client/discussion/index.jsx | 51 ++++--- .../discussion/test/discussion.test.jsx | 86 +++++++++++ projects/plugins/jetpack/_inc/client/main.jsx | 9 +- .../_inc/client/test/security-route.test.jsx | 3 +- .../admin-pages/settings-redirect-map.json | 20 ++- .../changelog/change-settings-comments-panel | 5 + .../jetpack/src/class-jetpack-script-data.php | 6 +- 16 files changed, 485 insertions(+), 25 deletions(-) create mode 100644 projects/packages/my-jetpack/_inc/components/settings-panel/comments.tsx create mode 100644 projects/packages/my-jetpack/_inc/components/settings-panel/test/comments.test.tsx create mode 100644 projects/packages/my-jetpack/_inc/components/settings-panel/use-module-text-setting.ts create mode 100644 projects/packages/my-jetpack/changelog/change-settings-comments-panel create mode 100644 projects/plugins/jetpack/_inc/client/discussion/comments-moved.jsx create mode 100644 projects/plugins/jetpack/_inc/client/discussion/test/discussion.test.jsx create mode 100644 projects/plugins/jetpack/changelog/change-settings-comments-panel diff --git a/projects/packages/my-jetpack/_inc/components/settings-panel/comments.tsx b/projects/packages/my-jetpack/_inc/components/settings-panel/comments.tsx new file mode 100644 index 000000000000..f38fe454ace3 --- /dev/null +++ b/projects/packages/my-jetpack/_inc/components/settings-panel/comments.tsx @@ -0,0 +1,94 @@ +import { getRedirectUrl } from '@automattic/jetpack-components'; +import { getScriptData } from '@automattic/jetpack-script-data'; +import { __ } from '@wordpress/i18n'; +import { InputControl, Link, Stack, SwitchControl, Text } from '@wordpress/ui'; +import { useCallback, useId, useState } from 'react'; +import { PanelModuleToggle } from './panel-module-toggle'; +import styles from './styles.module.scss'; +import { useModuleOption } from './use-module-option'; +import { useModuleTextSetting } from './use-module-text-setting'; +import type { ModuleSettingsProps } from './registry'; + +// Printed by the Jetpack plugin. Older plugins leave it out, so only `true` shows the blocks option. +type JetpackPluginScriptData = { jetpack?: { isCommentBlocksAvailable?: boolean } }; + +/** + * The Comments options. + * + * @param props - Component props. + * @param props.module - The module. + * @param props.disabled - Whether the site cannot use the module. + * @return The settings. + */ +export function CommentsSettings( { module: $module, disabled }: ModuleSettingsProps ) { + const blocks = useModuleOption( $module, 'enable_blocks_comments' ); + const prompt = useModuleTextSetting( $module, 'highlander_comment_form_prompt' ); + // The introduction as typed, until it is saved; null shows the stored one. + const [ draft, setDraft ] = useState< string | null >( null ); + const optionsDisabled = ! $module.activated || disabled; + const labelId = useId(); + const blocksAvailable = + ( getScriptData() as JetpackPluginScriptData | undefined )?.jetpack + ?.isCommentBlocksAvailable === true; + + const { value: storedPrompt, save: savePrompt } = prompt; + // Saved on blur. + const onBlur = useCallback( async () => { + if ( draft === null || draft === storedPrompt ) { + return; + } + if ( await savePrompt( draft ) ) { + setDraft( null ); + } + }, [ draft, storedPrompt, savePrompt ] ); + + return ( + + + { __( + 'Replace the standard WordPress comment form with one that lets readers comment with their social media accounts.', + 'jetpack-my-jetpack' + ) } + + + { __( 'Learn more about Comments', 'jetpack-my-jetpack' ) } + + + + + { __( 'Use the Jetpack comment form', 'jetpack-my-jetpack' ) } + + + + + { blocksAvailable && ( + + ) } + + + ); +} diff --git a/projects/packages/my-jetpack/_inc/components/settings-panel/registry.ts b/projects/packages/my-jetpack/_inc/components/settings-panel/registry.ts index 74eac871c66a..ac404b4d3cba 100644 --- a/projects/packages/my-jetpack/_inc/components/settings-panel/registry.ts +++ b/projects/packages/my-jetpack/_inc/components/settings-panel/registry.ts @@ -1,4 +1,5 @@ import { CarouselSettings } from './carousel'; +import { CommentsSettings } from './comments'; import { GoogleAnalyticsSettings } from './google-analytics'; import { InfiniteScrollSettings } from './infinite-scroll'; import { MarkdownSettings } from './markdown'; @@ -23,6 +24,7 @@ export type ModuleSettingsProps = { */ export const moduleSettings: Record< string, ComponentType< ModuleSettingsProps > > = { carousel: CarouselSettings, + comments: CommentsSettings, 'infinite-scroll': InfiniteScrollSettings, markdown: MarkdownSettings, 'post-by-email': PostByEmailSettings, diff --git a/projects/packages/my-jetpack/_inc/components/settings-panel/test/comments.test.tsx b/projects/packages/my-jetpack/_inc/components/settings-panel/test/comments.test.tsx new file mode 100644 index 000000000000..7ac61bdb421f --- /dev/null +++ b/projects/packages/my-jetpack/_inc/components/settings-panel/test/comments.test.tsx @@ -0,0 +1,135 @@ +import { render, screen, waitFor } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; +import apiFetch from '@wordpress/api-fetch'; +import { CommentsSettings } from '../comments'; +import type { MyJetpackModule } from '../../../types'; + +jest.mock( '@wordpress/api-fetch', () => jest.fn() ); +jest.mock( '@automattic/jetpack-shared-stores', () => ( { store: {} } ) ); +jest.mock( '@wordpress/notices', () => ( { store: 'core/notices' } ) ); +jest.mock( '@wordpress/data', () => ( { + useDispatch: () => ( { + fetchModules: jest.fn(), + createErrorNotice: jest.fn(), + createSuccessNotice: jest.fn(), + } ), +} ) ); +jest.mock( '../../../hooks/use-analytics', () => ( { + __esModule: true, + default: () => ( { recordEvent: jest.fn() } ), +} ) ); +jest.mock( '../../module-toggle', () => ( { + ModuleToggle: ( { labelledby, disabled }: { labelledby?: string; disabled?: boolean } ) => ( + + ), +} ) ); + +const mockFetch = apiFetch as unknown as jest.Mock; + +const build = ( overrides: Partial< MyJetpackModule > = {} ) => + ( { + module: 'comments', + name: 'Comments', + activated: true, + override: false, + options: { + enable_blocks_comments: { current_value: true }, + highlander_comment_form_prompt: { current_value: 'Leave a Reply' }, + }, + ...overrides, + } ) as unknown as MyJetpackModule; + +const setBlocksAvailable = ( isCommentBlocksAvailable?: boolean ) => { + window.JetpackScriptData = { + jetpack: { isCommentBlocksAvailable }, + } as unknown as typeof window.JetpackScriptData; +}; + +const blocksSwitch = () => screen.queryByRole( 'switch', { name: 'Enable blocks in comments' } ); +const introField = () => screen.getByRole( 'textbox', { name: 'Comment form introduction' } ); +const posts = () => mockFetch.mock.calls.map( ( [ options ] ) => options.data ); + +beforeEach( () => { + jest.clearAllMocks(); + mockFetch.mockResolvedValue( {} ); + setBlocksAvailable( true ); +} ); + +afterEach( () => { + delete window.JetpackScriptData; +} ); + +describe( 'CommentsSettings', () => { + it.each( [ + [ 'offers', 'the plugin says they work', true, true ], + [ 'hides', 'the plugin says they do not', false, false ], + [ 'hides', 'an older plugin says nothing', undefined, false ], + ] )( '%s the blocks option when %s', ( _verb, _when, available, shown ) => { + setBlocksAvailable( available ); + render( ); + + expect( blocksSwitch() !== null ).toBe( shown ); + } ); + + it( 'saves the blocks option on its own', async () => { + render( ); + await userEvent.click( blocksSwitch()! ); + + expect( posts() ).toEqual( [ { enable_blocks_comments: false } ] ); + } ); + + it( 'saves the introduction on blur, and only when it changed', async () => { + render( ); + + await userEvent.click( introField() ); + await userEvent.tab(); + expect( posts() ).toHaveLength( 0 ); + + await userEvent.clear( introField() ); + await userEvent.type( introField(), 'Say hello' ); + expect( posts() ).toHaveLength( 0 ); + await userEvent.tab(); + + await waitFor( () => + expect( posts() ).toEqual( [ { highlander_comment_form_prompt: 'Say hello' } ] ) + ); + } ); + + it( 'locks the introduction while it saves, and keeps the typed text when the save fails', async () => { + let failSave: () => void = () => undefined; + mockFetch.mockImplementation( + () => + new Promise( ( _resolve, reject ) => { + failSave = () => reject( new Error( 'nope' ) ); + } ) + ); + render( ); + + await userEvent.clear( introField() ); + await userEvent.type( introField(), 'Say hello' ); + await userEvent.tab(); + expect( introField() ).toBeDisabled(); + + failSave(); + await waitFor( () => expect( introField() ).toBeEnabled() ); + expect( introField() ).toHaveValue( 'Say hello' ); + } ); + + it.each( [ + [ 'the module is off', { activated: false }, false ], + [ 'the site cannot use it', {}, true ], + ] )( 'locks the options when %s', ( _name, overrides, disabled ) => { + render( ); + + expect( blocksSwitch() ).toHaveAttribute( 'aria-disabled', 'true' ); + expect( introField() ).toBeDisabled(); + } ); + + it( 'locks the module switch when the site cannot use it', () => { + render( ); + + expect( + screen.getByRole( 'checkbox', { name: 'Use the Jetpack comment form' } ) + ).toBeDisabled(); + } ); +} ); diff --git a/projects/packages/my-jetpack/_inc/components/settings-panel/use-module-text-setting.ts b/projects/packages/my-jetpack/_inc/components/settings-panel/use-module-text-setting.ts new file mode 100644 index 000000000000..26cf1a6bdd0e --- /dev/null +++ b/projects/packages/my-jetpack/_inc/components/settings-panel/use-module-text-setting.ts @@ -0,0 +1,64 @@ +import { store as modulesStore } from '@automattic/jetpack-shared-stores'; +import apiFetch from '@wordpress/api-fetch'; +import { useDispatch } from '@wordpress/data'; +import { __ } from '@wordpress/i18n'; +import { store as noticesStore } from '@wordpress/notices'; +import { useCallback, useRef, useState } from 'react'; +import type { MyJetpackModule } from '../../types'; + +/** + * A module's text option, saved through `jetpack/v4/settings` one save at a time. + * + * @param $module - The module that owns the option. + * @param name - The option name, such as `highlander_comment_form_prompt`. + * @return The value to show (the asked-for one until its save settles), whether a save is running, and the saver, which resolves to whether the save worked. + */ +export function useModuleTextSetting( $module: MyJetpackModule, name: string ) { + const { fetchModules } = useDispatch( modulesStore ); + const { createErrorNotice, createSuccessNotice } = useDispatch( noticesStore ); + const [ pending, setPending ] = useState< string | null >( null ); + const queue = useRef< Promise< unknown > >( Promise.resolve() ); + + const option = Array.isArray( $module.options ) ? undefined : $module.options?.[ name ]; + const stored = String( + ( option as { current_value?: unknown } | undefined )?.current_value ?? '' + ); + + const send = useCallback( + async ( value: string ) => { + try { + await apiFetch( { + path: '/jetpack/v4/settings', + method: 'POST', + data: { [ name ]: value }, + } ); + await fetchModules(); + createSuccessNotice( __( 'Updated settings.', 'jetpack-my-jetpack' ), { + type: 'snackbar', + } ); + return true; + } catch { + createErrorNotice( __( 'Failed to save the setting.', 'jetpack-my-jetpack' ), { + type: 'snackbar', + } ); + return false; + } finally { + // A later save keeps its own pending value. + setPending( current => ( current === value ? null : current ) ); + } + }, + [ name, fetchModules, createErrorNotice, createSuccessNotice ] + ); + + const save = useCallback( + ( value: string ) => { + setPending( value ); + const result = queue.current.then( () => send( value ) ); + queue.current = result; + return result; + }, + [ send ] + ); + + return { value: pending ?? stored, isSaving: pending !== null, save }; +} diff --git a/projects/packages/my-jetpack/changelog/change-settings-comments-panel b/projects/packages/my-jetpack/changelog/change-settings-comments-panel new file mode 100644 index 000000000000..32ab11f6d7b0 --- /dev/null +++ b/projects/packages/my-jetpack/changelog/change-settings-comments-panel @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Settings panel: Add the Comments settings, behind the settings consolidation flag. + + diff --git a/projects/packages/my-jetpack/src/class-initializer.php b/projects/packages/my-jetpack/src/class-initializer.php index 2d726b8b241b..2046cc1fba75 100644 --- a/projects/packages/my-jetpack/src/class-initializer.php +++ b/projects/packages/my-jetpack/src/class-initializer.php @@ -155,7 +155,7 @@ class Initializer { /** * Modules whose Jetpack settings link opens in the Features panel. A subset of `moduleSettings` in `settings-panel/registry.ts`; see there for which modules stay out. */ - public const SETTINGS_PANEL_MODULES = array( 'carousel', 'infinite-scroll', 'markdown', 'post-by-email', 'related-posts' ); + public const SETTINGS_PANEL_MODULES = array( 'carousel', 'comments', 'infinite-scroll', 'markdown', 'post-by-email', 'related-posts' ); /** * Holds info/data about the site (from the /sites/%d endpoint) diff --git a/projects/plugins/jetpack/_inc/client/components/settings-nav-tabs/index.jsx b/projects/plugins/jetpack/_inc/client/components/settings-nav-tabs/index.jsx index 6dd249ae3984..3d12196e6c74 100644 --- a/projects/plugins/jetpack/_inc/client/components/settings-nav-tabs/index.jsx +++ b/projects/plugins/jetpack/_inc/client/components/settings-nav-tabs/index.jsx @@ -123,7 +123,11 @@ const SettingsNavTabs = props => { ) { visibleTabs.push( '/sharing' ); } - if ( hasModules( [ 'comments', 'gravatar-hovercards', 'markdown' ] ) ) { + // Once settings move out, admins find every Discussion setting in Features. + if ( + ! isSettingsConsolidationEnabled() && + hasModules( [ 'comments', 'gravatar-hovercards', 'markdown' ] ) + ) { visibleTabs.push( '/discussion' ); } if ( diff --git a/projects/plugins/jetpack/_inc/client/components/settings-nav-tabs/test/component.jsx b/projects/plugins/jetpack/_inc/client/components/settings-nav-tabs/test/component.jsx index 7b0afc4d66e8..a777887a02cc 100644 --- a/projects/plugins/jetpack/_inc/client/components/settings-nav-tabs/test/component.jsx +++ b/projects/plugins/jetpack/_inc/client/components/settings-nav-tabs/test/component.jsx @@ -101,6 +101,9 @@ describe( 'SettingsNavTabs', () => { [ 'hides', 'Writing', 'Infinite Scroll', 'infinite-scroll', true, 0 ], [ 'shows', 'Writing', 'custom content types', null, false, 1 ], [ 'hides', 'Writing', 'custom content types', null, true, 0 ], + [ 'shows', 'Discussion', 'Comments', 'comments', false, 1 ], + [ 'hides', 'Discussion', 'Comments', 'comments', true, 0 ], + [ 'hides', 'Discussion', 'Gravatar Hovercards', 'gravatar-hovercards', true, 0 ], [ 'shows', 'Reader', 'the Reader', 'wpcom-reader', false, 1 ], [ 'hides', 'Reader', 'the Reader', 'wpcom-reader', true, 0 ], ] )( diff --git a/projects/plugins/jetpack/_inc/client/discussion/comments-moved.jsx b/projects/plugins/jetpack/_inc/client/discussion/comments-moved.jsx new file mode 100644 index 000000000000..172196897e1d --- /dev/null +++ b/projects/plugins/jetpack/_inc/client/discussion/comments-moved.jsx @@ -0,0 +1,19 @@ +import { __ } from '@wordpress/i18n'; +import PointerCard from 'components/pointer-card'; + +/** + * Search result that sends the Comments settings to the panel in Features. + * + * @param {object} props - Component props. + * @param {Function} props.getModule - Reads a module by slug. + * @return {import('react').ReactNode} The card. + */ +export const CommentsMoved = ( { getModule } ) => ( + +

{ __( 'The Comments settings are now in Features, in My Jetpack.', 'jetpack' ) }

+
+); diff --git a/projects/plugins/jetpack/_inc/client/discussion/index.jsx b/projects/plugins/jetpack/_inc/client/discussion/index.jsx index e4b6eab67867..d5dbe39a9cf4 100644 --- a/projects/plugins/jetpack/_inc/client/discussion/index.jsx +++ b/projects/plugins/jetpack/_inc/client/discussion/index.jsx @@ -2,6 +2,7 @@ import { __ } from '@wordpress/i18n'; import { Component } from 'react'; import { connect } from 'react-redux'; import QuerySite from 'components/data/query-site'; +import { FeaturesPointer } from 'components/pointer-card'; import { isSettingsConsolidationEnabled } from 'lib/settings-consolidation'; import { isOfflineMode, @@ -19,6 +20,7 @@ import { getModule, getModuleOverride } from 'state/modules'; import { isModuleFound as _isModuleFound } from 'state/search'; import { getSettings } from 'state/settings'; import { Comments } from './comments'; +import { CommentsMoved } from './comments-moved'; export class Discussion extends Component { static displayName = 'DiscussionSettings'; @@ -37,28 +39,49 @@ export class Discussion extends Component { return null; } - const foundComments = this.props.isModuleFound( 'comments' ), + const { isMovedToFeatures, searchTerm } = this.props, + foundComments = this.props.isModuleFound( 'comments' ), foundMarkdown = this.props.isModuleFound( 'markdown' ), foundGravatar = this.props.isModuleFound( 'gravatar-hovercards' ), foundCommentLikes = this.props.isModuleFound( 'comment-likes' ); - if ( ! foundComments && ! foundMarkdown && ! foundGravatar && ! foundCommentLikes ) { + // Once settings move out, admins find this tab's settings in Features, and only a search points there. + // Markdown's pointer is on the Writing tab. + const shown = isMovedToFeatures + ? !! searchTerm && ( foundComments || foundGravatar || foundCommentLikes ) + : foundComments || foundMarkdown || foundGravatar || foundCommentLikes; + if ( ! shown ) { return null; } + const pointTo = module => { + const { name } = this.props.module( module ); + return ( + + ); + }; + return (

{ __( 'Jetpack Discussion Settings', 'jetpack' ) }

- { this.props.searchTerm && ( + { searchTerm && (

{ __( 'Discussion', 'jetpack' ) }

) } - + { isMovedToFeatures ? ( + <> + { foundComments && } + { foundGravatar && pointTo( 'gravatar-hovercards' ) } + { foundCommentLikes && pointTo( 'comment-likes' ) } + + ) : ( + + ) }
); } @@ -70,13 +93,9 @@ export default connect( state => { settings: getSettings( state ), isOfflineMode: isOfflineMode( state ), isUnavailableInOfflineMode: module_name => isUnavailableInOfflineMode( state, module_name ), - // Markdown's settings live in its My Jetpack panel, as in the Writing tab. - isModuleFound: module_name => - ! ( - 'markdown' === module_name && - isSettingsConsolidationEnabled() && - userCanManageModules( state ) - ) && _isModuleFound( state, module_name ), + isModuleFound: module_name => _isModuleFound( state, module_name ), + // The panel and Features need manage_options, so users who cannot manage modules keep the card. + isMovedToFeatures: isSettingsConsolidationEnabled() && userCanManageModules( state ), connectUrl: getConnectUrl( state ), isLinked: isCurrentUserLinked( state ), getModuleOverride: module_name => getModuleOverride( state, module_name ), diff --git a/projects/plugins/jetpack/_inc/client/discussion/test/discussion.test.jsx b/projects/plugins/jetpack/_inc/client/discussion/test/discussion.test.jsx new file mode 100644 index 000000000000..77e63895fd24 --- /dev/null +++ b/projects/plugins/jetpack/_inc/client/discussion/test/discussion.test.jsx @@ -0,0 +1,86 @@ +import { render, screen } from 'test/test-utils'; +import Discussion from '../index'; + +jest.mock( 'components/data/query-site', () => () => null ); +jest.mock( '../comments', () => ( { Comments: () =>

Comments card

} ) ); +jest.mock( '../comments-moved', () => ( { CommentsMoved: () =>

Comments pointer

} ) ); +jest.mock( 'components/pointer-card', () => ( { + FeaturesPointer: ( { search } ) =>

{ `Features pointer: ${ search }` }

, +} ) ); + +const MODULES = { + comments: { module: 'comments', name: 'Comments' }, + 'gravatar-hovercards': { module: 'gravatar-hovercards', name: 'Gravatar Hovercards' }, + 'comment-likes': { module: 'comment-likes', name: 'Comment Likes' }, + markdown: { module: 'markdown', name: 'Markdown' }, +}; + +const renderDiscussion = ( { flag, searchTerm = '', canManageModules = true } ) => { + window.JetpackScriptData = { myJetpack: { settingsConsolidation: flag } }; + return render( , { + initialState: { + jetpack: { + connection: { + status: { siteConnected: { isActive: true, offlineMode: { isActive: false } } }, + user: { currentUser: { isConnected: true } }, + }, + initialState: { + siteData: {}, + userData: { currentUser: { permissions: { manage_modules: canManageModules } } }, + }, + modules: { items: MODULES }, + search: { searchTerm }, + settings: { items: {} }, + }, + }, + } ); +}; + +describe( 'Discussion settings', () => { + afterEach( () => { + delete window.JetpackScriptData; + } ); + + it.each( [ + [ 'the card on the tab with the settings flag off', false, '', true, [ 'Comments card' ] ], + [ 'nothing on the tab once the flag is on', true, '', true, [] ], + [ 'the panel pointer for a Comments search', true, 'comments', true, [ 'Comments pointer' ] ], + [ + 'the Features row for a Gravatar search', + true, + 'gravatar', + true, + [ 'Features pointer: Gravatar Hovercards' ], + ], + [ + 'the Features row for a Comment Likes search', + true, + 'comment likes', + true, + [ 'Features pointer: Comment Likes' ], + ], + [ + 'the card to a user who cannot manage modules', + true, + 'comments', + false, + [ 'Comments card' ], + ], + ] )( 'shows %s', ( _name, flag, searchTerm, canManageModules, expected ) => { + renderDiscussion( { flag, searchTerm, canManageModules } ); + + const shown = [ + 'Comments card', + 'Comments pointer', + 'Features pointer: Gravatar Hovercards', + 'Features pointer: Comment Likes', + ].filter( text => screen.queryByText( text ) ); + expect( shown ).toEqual( expected ); + } ); + + it( 'renders nothing for a Markdown search once the flag is on, since Writing points to it', () => { + const { container } = renderDiscussion( { flag: true, searchTerm: 'markdown' } ); + + expect( container ).toBeEmptyDOMElement(); + } ); +} ); diff --git a/projects/plugins/jetpack/_inc/client/main.jsx b/projects/plugins/jetpack/_inc/client/main.jsx index 2a0ea075c45b..c8418cc6bdf5 100644 --- a/projects/plugins/jetpack/_inc/client/main.jsx +++ b/projects/plugins/jetpack/_inc/client/main.jsx @@ -291,8 +291,15 @@ export class Main extends Component { break; } // Falls through. - case '/settings': case '/discussion': + if ( '/discussion' === route && isSettingsConsolidationEnabled() ) { + window.location.replace( + getAdminUrl( 'admin.php?page=my-jetpack&p=%2Ffeatures%3Fconfigure%3Dcomments' ) + ); + break; + } + // Falls through. + case '/settings': case '/traffic': case '/privacy': pageComponent = ( diff --git a/projects/plugins/jetpack/_inc/client/test/security-route.test.jsx b/projects/plugins/jetpack/_inc/client/test/security-route.test.jsx index bf175d0078cd..a5b950b5872b 100644 --- a/projects/plugins/jetpack/_inc/client/test/security-route.test.jsx +++ b/projects/plugins/jetpack/_inc/client/test/security-route.test.jsx @@ -79,6 +79,7 @@ describe( 'Main routes that leave Settings once settings move out', () => { [ '/sharing', 'admin.php?page=my-jetpack#/features?search=sharing' ], [ '/reader', 'admin.php?page=my-jetpack#/features?search=reader' ], [ '/writing', 'admin.php?page=my-jetpack#/features' ], + [ '/discussion', 'admin.php?page=my-jetpack&p=%2Ffeatures%3Fconfigure%3Dcomments' ], ] )( 'sends %s to %s with the settings flag on', ( route, destination ) => { isSettingsConsolidationEnabled.mockReturnValue( true ); renderAt( route, false ); @@ -88,7 +89,7 @@ describe( 'Main routes that leave Settings once settings move out', () => { expect( screen.queryByTestId( 'searchable-settings' ) ).not.toBeInTheDocument(); } ); - it.each( [ '/performance', '/sharing', '/reader', '/writing' ] )( + it.each( [ '/performance', '/sharing', '/reader', '/writing', '/discussion' ] )( 'keeps %s on Settings with the settings flag off', route => { renderAt( route, false ); diff --git a/projects/plugins/jetpack/_inc/lib/admin-pages/settings-redirect-map.json b/projects/plugins/jetpack/_inc/lib/admin-pages/settings-redirect-map.json index f7d69f5a5fff..ecaac746355d 100644 --- a/projects/plugins/jetpack/_inc/lib/admin-pages/settings-redirect-map.json +++ b/projects/plugins/jetpack/_inc/lib/admin-pages/settings-redirect-map.json @@ -133,7 +133,9 @@ }, { "source": "/discussion", - "rules": [ { "pending": [ "JETPACK-3720" ] } ], + "rules": [ + { "destination": "admin.php?page=my-jetpack&p=%2Ffeatures%3Fconfigure%3Dcomments" } + ], "outsideRepo": [ "wpcom: help search key" ] }, { @@ -302,14 +304,26 @@ { "destination": "admin.php?page=my-jetpack&p=%2Ffeatures%3Fconfigure%3Dpost-by-email" } ] }, - { "source": "comments", "rules": [ { "pending": [ "JETPACK-3720" ] } ] }, + { + "source": "comments", + "rules": [ + { "destination": "admin.php?page=my-jetpack&p=%2Ffeatures%3Fconfigure%3Dcomments" } + ] + }, { "source": "markdown", "rules": [ { "destination": "admin.php?page=my-jetpack&p=%2Ffeatures%3Fconfigure%3Dmarkdown" } ] }, - { "source": "gravatar-hovercards", "rules": [ { "pending": [ "JETPACK-3720" ] } ] }, + { + "source": "gravatar-hovercards", + "rules": [ { "destination": "admin.php?page=my-jetpack#/features?search=gravatar" } ] + }, + { + "source": "comment-likes", + "rules": [ { "destination": "admin.php?page=my-jetpack#/features?search=comment%20likes" } ] + }, { "source": "custom-content-types", "rules": [ { "destination": "options-writing.php#cpt-options" } ] diff --git a/projects/plugins/jetpack/changelog/change-settings-comments-panel b/projects/plugins/jetpack/changelog/change-settings-comments-panel new file mode 100644 index 000000000000..3306d5bc6183 --- /dev/null +++ b/projects/plugins/jetpack/changelog/change-settings-comments-panel @@ -0,0 +1,5 @@ +Significance: patch +Type: enhancement +Comment: Settings: Point the Comments settings to their panel in My Jetpack, behind the settings consolidation flag. + + diff --git a/projects/plugins/jetpack/src/class-jetpack-script-data.php b/projects/plugins/jetpack/src/class-jetpack-script-data.php index 3361627f6995..b19c0081f0e9 100644 --- a/projects/plugins/jetpack/src/class-jetpack-script-data.php +++ b/projects/plugins/jetpack/src/class-jetpack-script-data.php @@ -9,6 +9,7 @@ namespace Automattic\Jetpack\Plugin; +use Automattic\Jetpack\Comments\Comments; use Automattic\Jetpack\Current_Plan as Jetpack_Plan; use Automattic\Jetpack\My_Jetpack\Initializer as My_Jetpack_Initializer; @@ -47,12 +48,13 @@ public static function set_admin_script_data( $data ) { ), ); - // Only the settings panel in My Jetpack reads it, so skip the theme folder scan elsewhere. + // Only the settings panel in My Jetpack reads these, so skip the theme folder scan elsewhere. // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Only selects which data to print. if ( 'my-jetpack' === sanitize_key( wp_unslash( $_GET['page'] ?? '' ) ) && self::is_settings_consolidation_enabled() ) { - $data['jetpack']['themeSupports'] = array( + $data['jetpack']['themeSupports'] = array( 'infiniteScroll' => self::theme_supports_infinite_scroll(), ); + $data['jetpack']['isCommentBlocksAvailable'] = Comments::is_enabled(); } return $data; From 493c8ea2bf0bd0439300b491d3a93d09dfec498c Mon Sep 17 00:00:00 2001 From: Christian Gastrell Date: Thu, 12 Nov 2026 18:29:06 -0300 Subject: [PATCH 2/4] Settings: Share the settings panel gate in one helper isInSettingsPanel() holds the flag + manage_modules check that Composing, Discussion and Post by Email each wrote inline. Co-Authored-By: Claude Opus 5.5 --- .../jetpack/_inc/client/discussion/index.jsx | 6 ++---- .../lib/settings-consolidation/index.js | 11 ++++++++++ .../lib/settings-consolidation/test/index.js | 20 ++++++++++++++++++- .../jetpack/_inc/client/writing/composing.jsx | 7 +++---- .../jetpack/_inc/client/writing/index.jsx | 4 +++- 5 files changed, 38 insertions(+), 10 deletions(-) diff --git a/projects/plugins/jetpack/_inc/client/discussion/index.jsx b/projects/plugins/jetpack/_inc/client/discussion/index.jsx index d5dbe39a9cf4..60c761e00fd8 100644 --- a/projects/plugins/jetpack/_inc/client/discussion/index.jsx +++ b/projects/plugins/jetpack/_inc/client/discussion/index.jsx @@ -3,7 +3,7 @@ import { Component } from 'react'; import { connect } from 'react-redux'; import QuerySite from 'components/data/query-site'; import { FeaturesPointer } from 'components/pointer-card'; -import { isSettingsConsolidationEnabled } from 'lib/settings-consolidation'; +import { isInSettingsPanel } from 'lib/settings-consolidation'; import { isOfflineMode, isUnavailableInOfflineMode, @@ -14,7 +14,6 @@ import { isOdysseyStatsEnabled, getSiteAdminUrl, isCommentBlocksAvailable, - userCanManageModules, } from 'state/initial-state'; import { getModule, getModuleOverride } from 'state/modules'; import { isModuleFound as _isModuleFound } from 'state/search'; @@ -94,8 +93,7 @@ export default connect( state => { isOfflineMode: isOfflineMode( state ), isUnavailableInOfflineMode: module_name => isUnavailableInOfflineMode( state, module_name ), isModuleFound: module_name => _isModuleFound( state, module_name ), - // The panel and Features need manage_options, so users who cannot manage modules keep the card. - isMovedToFeatures: isSettingsConsolidationEnabled() && userCanManageModules( state ), + isMovedToFeatures: isInSettingsPanel( state ), connectUrl: getConnectUrl( state ), isLinked: isCurrentUserLinked( state ), getModuleOverride: module_name => getModuleOverride( state, module_name ), diff --git a/projects/plugins/jetpack/_inc/client/lib/settings-consolidation/index.js b/projects/plugins/jetpack/_inc/client/lib/settings-consolidation/index.js index c326a400465e..6cb043492011 100644 --- a/projects/plugins/jetpack/_inc/client/lib/settings-consolidation/index.js +++ b/projects/plugins/jetpack/_inc/client/lib/settings-consolidation/index.js @@ -58,6 +58,17 @@ export function getMovedOutModules( state ) { */ export const isMovedOut = ( module, state ) => getMovedOutModules( state ).includes( module ); +/** + * Whether settings that moved to a My Jetpack settings panel leave only a pointer here. + * + * The panel lives in Features, which needs manage_options, so users who cannot manage modules keep the card. + * + * @param {object} state - Global state tree. + * @return {boolean} True when the card gives way to a pointer. + */ +export const isInSettingsPanel = state => + isSettingsConsolidationEnabled() && userCanManageModules( state ); + /** * Whether a module's Settings toggle gives way to its switch in My Jetpack › Features, leaving only a search result that points there. * diff --git a/projects/plugins/jetpack/_inc/client/lib/settings-consolidation/test/index.js b/projects/plugins/jetpack/_inc/client/lib/settings-consolidation/test/index.js index 33b65ebe26cb..4fc2ca75b787 100644 --- a/projects/plugins/jetpack/_inc/client/lib/settings-consolidation/test/index.js +++ b/projects/plugins/jetpack/_inc/client/lib/settings-consolidation/test/index.js @@ -1,10 +1,15 @@ import { getScriptData, isWoASite } from '@automattic/jetpack-script-data'; -import { getMovedOutModules, isSettingsConsolidationEnabled } from '../index'; +import { userCanManageModules } from 'state/initial-state'; +import { getMovedOutModules, isInSettingsPanel, isSettingsConsolidationEnabled } from '../index'; jest.mock( '@automattic/jetpack-script-data', () => ( { getScriptData: jest.fn(), isWoASite: jest.fn(), } ) ); +jest.mock( 'state/initial-state', () => ( { + ...jest.requireActual( 'state/initial-state' ), + userCanManageModules: jest.fn(), +} ) ); describe( 'isSettingsConsolidationEnabled', () => { it.each( [ @@ -30,3 +35,16 @@ describe( 'getMovedOutModules', () => { expect( getMovedOutModules() ).toEqual( expected ); } ); } ); + +describe( 'isInSettingsPanel', () => { + it.each( [ + [ 'moves', 'admins with the flag on', true, true, true ], + [ 'keeps', 'users who cannot manage modules', true, false, false ], + [ 'keeps', 'admins with the flag off', false, true, false ], + ] )( '%s the card for %s', ( _verb, _who, flag, canManage, expected ) => { + getScriptData.mockReturnValue( { myJetpack: { settingsConsolidation: flag } } ); + userCanManageModules.mockReturnValue( canManage ); + + expect( isInSettingsPanel( {} ) ).toBe( expected ); + } ); +} ); diff --git a/projects/plugins/jetpack/_inc/client/writing/composing.jsx b/projects/plugins/jetpack/_inc/client/writing/composing.jsx index 6af51f13f479..3ad4118bea5f 100644 --- a/projects/plugins/jetpack/_inc/client/writing/composing.jsx +++ b/projects/plugins/jetpack/_inc/client/writing/composing.jsx @@ -12,10 +12,10 @@ import { FeaturesPointer } from 'components/pointer-card'; import SettingsCard from 'components/settings-card'; import SettingsGroup from 'components/settings-group'; import { - isSettingsConsolidationEnabled, + isInSettingsPanel, isSwitchedInFeatures as _isSwitchedInFeatures, } from 'lib/settings-consolidation'; -import { showMyJetpack, userCanManageModules } from 'state/initial-state'; +import { showMyJetpack } from 'state/initial-state'; import { getModule } from 'state/modules'; import { isModuleFound as _isModuleFound, getSearchTerm } from 'state/search'; import { MarkdownMoved } from './markdown-moved'; @@ -278,8 +278,7 @@ export default connect( state => { module: module_name => getModule( state, module_name ), isModuleFound: module_name => _isModuleFound( state, module_name ), isSwitchedInFeatures: module_name => _isSwitchedInFeatures( state, module_name ), - // The panel needs Features, which users who cannot manage modules lack. - isMarkdownMoved: isSettingsConsolidationEnabled() && userCanManageModules( state ), + isMarkdownMoved: isInSettingsPanel( state ), isMyJetpackReachable: showMyJetpack( state ), searchTerm: getSearchTerm( state ), }; diff --git a/projects/plugins/jetpack/_inc/client/writing/index.jsx b/projects/plugins/jetpack/_inc/client/writing/index.jsx index 65af747e1e92..14963b4d9cc9 100644 --- a/projects/plugins/jetpack/_inc/client/writing/index.jsx +++ b/projects/plugins/jetpack/_inc/client/writing/index.jsx @@ -4,6 +4,7 @@ import { connect } from 'react-redux'; import Card from 'components/card'; import QuerySite from 'components/data/query-site'; import { + isInSettingsPanel, isMovedOut, isSettingsConsolidationEnabled, isSwitchedInFeatures, @@ -172,7 +173,7 @@ export class Writing extends Component { { this.props.isModuleFound( 'post-by-email' ) && showPostByEmail && - ( isSettingsConsolidationEnabled() && this.props.userCanManageModules ? ( + ( this.props.isPostByEmailMoved ? ( this.props.searchTerm && ) : ( isModuleActivated( state, module_name ), isLinked: isCurrentUserLinked( state ), userCanManageModules: userCanManageModules( state ), + isPostByEmailMoved: isInSettingsPanel( state ), isModuleFound: module_name => isModuleFound( state, module_name ) && ! isMovedOut( module_name, state ) && From a7596929f570f7b54447f27fffbcdd9e031618dd Mon Sep 17 00:00:00 2001 From: Christian Gastrell Date: Thu, 12 Nov 2026 18:53:19 -0300 Subject: [PATCH 3/4] Settings: Pass the Post by Email gate to the Writing test The gate now comes from connect(), which the unconnected render skips. Co-Authored-By: Claude Opus 5.5 --- .../plugins/jetpack/_inc/client/writing/test/writing.test.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/plugins/jetpack/_inc/client/writing/test/writing.test.jsx b/projects/plugins/jetpack/_inc/client/writing/test/writing.test.jsx index 28ec98309774..709685a2d4c4 100644 --- a/projects/plugins/jetpack/_inc/client/writing/test/writing.test.jsx +++ b/projects/plugins/jetpack/_inc/client/writing/test/writing.test.jsx @@ -159,6 +159,7 @@ describe( 'Writing settings', () => { Date: Thu, 12 Nov 2026 19:40:24 -0300 Subject: [PATCH 4/4] Settings: Simplify the Comments panel data and saves The panel shows the blocks option when the module sends it, so the Jetpack plugin no longer prints isCommentBlocksAvailable. The introduction saves through useModuleSetting(), which now resolves to whether the save worked. Users who cannot manage modules keep /discussion until D9. Co-Authored-By: Claude Opus 5.5 --- .../components/settings-panel/comments.tsx | 17 ++--- .../settings-panel/test/comments.test.tsx | 32 +++++----- .../settings-panel/use-module-option.ts | 4 +- .../settings-panel/use-module-text-setting.ts | 64 ------------------- .../admin-pages/settings-redirect-map.json | 6 +- .../jetpack/src/class-jetpack-script-data.php | 6 +- 6 files changed, 32 insertions(+), 97 deletions(-) delete mode 100644 projects/packages/my-jetpack/_inc/components/settings-panel/use-module-text-setting.ts diff --git a/projects/packages/my-jetpack/_inc/components/settings-panel/comments.tsx b/projects/packages/my-jetpack/_inc/components/settings-panel/comments.tsx index f38fe454ace3..a703640dfdb1 100644 --- a/projects/packages/my-jetpack/_inc/components/settings-panel/comments.tsx +++ b/projects/packages/my-jetpack/_inc/components/settings-panel/comments.tsx @@ -1,17 +1,12 @@ import { getRedirectUrl } from '@automattic/jetpack-components'; -import { getScriptData } from '@automattic/jetpack-script-data'; import { __ } from '@wordpress/i18n'; import { InputControl, Link, Stack, SwitchControl, Text } from '@wordpress/ui'; import { useCallback, useId, useState } from 'react'; import { PanelModuleToggle } from './panel-module-toggle'; import styles from './styles.module.scss'; -import { useModuleOption } from './use-module-option'; -import { useModuleTextSetting } from './use-module-text-setting'; +import { useModuleOption, useModuleSetting } from './use-module-option'; import type { ModuleSettingsProps } from './registry'; -// Printed by the Jetpack plugin. Older plugins leave it out, so only `true` shows the blocks option. -type JetpackPluginScriptData = { jetpack?: { isCommentBlocksAvailable?: boolean } }; - /** * The Comments options. * @@ -22,16 +17,18 @@ type JetpackPluginScriptData = { jetpack?: { isCommentBlocksAvailable?: boolean */ export function CommentsSettings( { module: $module, disabled }: ModuleSettingsProps ) { const blocks = useModuleOption( $module, 'enable_blocks_comments' ); - const prompt = useModuleTextSetting( $module, 'highlander_comment_form_prompt' ); + const prompt = useModuleSetting( $module, 'highlander_comment_form_prompt', v => + String( v ?? '' ) + ); // The introduction as typed, until it is saved; null shows the stored one. const [ draft, setDraft ] = useState< string | null >( null ); const optionsDisabled = ! $module.activated || disabled; const labelId = useId(); + // Jetpack versions without block comments do not send the option. const blocksAvailable = - ( getScriptData() as JetpackPluginScriptData | undefined )?.jetpack - ?.isCommentBlocksAvailable === true; + ! Array.isArray( $module.options ) && undefined !== $module.options?.enable_blocks_comments; - const { value: storedPrompt, save: savePrompt } = prompt; + const { value: storedPrompt, setValue: savePrompt } = prompt; // Saved on blur. const onBlur = useCallback( async () => { if ( draft === null || draft === storedPrompt ) { diff --git a/projects/packages/my-jetpack/_inc/components/settings-panel/test/comments.test.tsx b/projects/packages/my-jetpack/_inc/components/settings-panel/test/comments.test.tsx index 7ac61bdb421f..113e1adb1728 100644 --- a/projects/packages/my-jetpack/_inc/components/settings-panel/test/comments.test.tsx +++ b/projects/packages/my-jetpack/_inc/components/settings-panel/test/comments.test.tsx @@ -39,12 +39,6 @@ const build = ( overrides: Partial< MyJetpackModule > = {} ) => ...overrides, } ) as unknown as MyJetpackModule; -const setBlocksAvailable = ( isCommentBlocksAvailable?: boolean ) => { - window.JetpackScriptData = { - jetpack: { isCommentBlocksAvailable }, - } as unknown as typeof window.JetpackScriptData; -}; - const blocksSwitch = () => screen.queryByRole( 'switch', { name: 'Enable blocks in comments' } ); const introField = () => screen.getByRole( 'textbox', { name: 'Comment form introduction' } ); const posts = () => mockFetch.mock.calls.map( ( [ options ] ) => options.data ); @@ -52,21 +46,25 @@ const posts = () => mockFetch.mock.calls.map( ( [ options ] ) => options.data ); beforeEach( () => { jest.clearAllMocks(); mockFetch.mockResolvedValue( {} ); - setBlocksAvailable( true ); -} ); - -afterEach( () => { - delete window.JetpackScriptData; } ); describe( 'CommentsSettings', () => { it.each( [ - [ 'offers', 'the plugin says they work', true, true ], - [ 'hides', 'the plugin says they do not', false, false ], - [ 'hides', 'an older plugin says nothing', undefined, false ], - ] )( '%s the blocks option when %s', ( _verb, _when, available, shown ) => { - setBlocksAvailable( available ); - render( ); + [ 'offers', 'Jetpack sends it', {}, true ], + [ + 'hides', + 'an older Jetpack leaves it out', + { options: { highlander_comment_form_prompt: { current_value: '' } } }, + false, + ], + [ 'hides', 'Jetpack sends no options', { options: [] }, false ], + ] )( '%s the blocks option when %s', ( _verb, _when, overrides, shown ) => { + render( + ) } + disabled={ false } + /> + ); expect( blocksSwitch() !== null ).toBe( shown ); } ); diff --git a/projects/packages/my-jetpack/_inc/components/settings-panel/use-module-option.ts b/projects/packages/my-jetpack/_inc/components/settings-panel/use-module-option.ts index c5dfde6634a2..1263b7362e58 100644 --- a/projects/packages/my-jetpack/_inc/components/settings-panel/use-module-option.ts +++ b/projects/packages/my-jetpack/_inc/components/settings-panel/use-module-option.ts @@ -17,7 +17,7 @@ type ModuleOptionValue = boolean | string; * @param $module - The module that owns the option. * @param name - The option name, such as `carousel_background_color`. * @param parse - Turns the stored `current_value` into the value to show. - * @return The value to show, whether a save is running, and the setter. + * @return The value to show, whether a save is running, and the setter, which resolves to whether the save worked. */ export function useModuleSetting< T extends ModuleOptionValue >( $module: MyJetpackModule, @@ -44,10 +44,12 @@ export function useModuleSetting< T extends ModuleOptionValue >( createSuccessNotice( __( 'Updated settings.', 'jetpack-my-jetpack' ), { type: 'snackbar', } ); + return true; } catch { createErrorNotice( __( 'Failed to save the setting.', 'jetpack-my-jetpack' ), { type: 'snackbar', } ); + return false; } finally { setRequested( null ); } diff --git a/projects/packages/my-jetpack/_inc/components/settings-panel/use-module-text-setting.ts b/projects/packages/my-jetpack/_inc/components/settings-panel/use-module-text-setting.ts deleted file mode 100644 index 26cf1a6bdd0e..000000000000 --- a/projects/packages/my-jetpack/_inc/components/settings-panel/use-module-text-setting.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { store as modulesStore } from '@automattic/jetpack-shared-stores'; -import apiFetch from '@wordpress/api-fetch'; -import { useDispatch } from '@wordpress/data'; -import { __ } from '@wordpress/i18n'; -import { store as noticesStore } from '@wordpress/notices'; -import { useCallback, useRef, useState } from 'react'; -import type { MyJetpackModule } from '../../types'; - -/** - * A module's text option, saved through `jetpack/v4/settings` one save at a time. - * - * @param $module - The module that owns the option. - * @param name - The option name, such as `highlander_comment_form_prompt`. - * @return The value to show (the asked-for one until its save settles), whether a save is running, and the saver, which resolves to whether the save worked. - */ -export function useModuleTextSetting( $module: MyJetpackModule, name: string ) { - const { fetchModules } = useDispatch( modulesStore ); - const { createErrorNotice, createSuccessNotice } = useDispatch( noticesStore ); - const [ pending, setPending ] = useState< string | null >( null ); - const queue = useRef< Promise< unknown > >( Promise.resolve() ); - - const option = Array.isArray( $module.options ) ? undefined : $module.options?.[ name ]; - const stored = String( - ( option as { current_value?: unknown } | undefined )?.current_value ?? '' - ); - - const send = useCallback( - async ( value: string ) => { - try { - await apiFetch( { - path: '/jetpack/v4/settings', - method: 'POST', - data: { [ name ]: value }, - } ); - await fetchModules(); - createSuccessNotice( __( 'Updated settings.', 'jetpack-my-jetpack' ), { - type: 'snackbar', - } ); - return true; - } catch { - createErrorNotice( __( 'Failed to save the setting.', 'jetpack-my-jetpack' ), { - type: 'snackbar', - } ); - return false; - } finally { - // A later save keeps its own pending value. - setPending( current => ( current === value ? null : current ) ); - } - }, - [ name, fetchModules, createErrorNotice, createSuccessNotice ] - ); - - const save = useCallback( - ( value: string ) => { - setPending( value ); - const result = queue.current.then( () => send( value ) ); - queue.current = result; - return result; - }, - [ send ] - ); - - return { value: pending ?? stored, isSaving: pending !== null, save }; -} diff --git a/projects/plugins/jetpack/_inc/lib/admin-pages/settings-redirect-map.json b/projects/plugins/jetpack/_inc/lib/admin-pages/settings-redirect-map.json index ecaac746355d..609bac59869f 100644 --- a/projects/plugins/jetpack/_inc/lib/admin-pages/settings-redirect-map.json +++ b/projects/plugins/jetpack/_inc/lib/admin-pages/settings-redirect-map.json @@ -134,7 +134,11 @@ { "source": "/discussion", "rules": [ - { "destination": "admin.php?page=my-jetpack&p=%2Ffeatures%3Fconfigure%3Dcomments" } + { "when": { "canManageModules": false }, "pending": [ "D9" ] }, + { + "destination": "admin.php?page=my-jetpack&p=%2Ffeatures%3Fconfigure%3Dcomments", + "alreadyRedirects": true + } ], "outsideRepo": [ "wpcom: help search key" ] }, diff --git a/projects/plugins/jetpack/src/class-jetpack-script-data.php b/projects/plugins/jetpack/src/class-jetpack-script-data.php index b19c0081f0e9..3361627f6995 100644 --- a/projects/plugins/jetpack/src/class-jetpack-script-data.php +++ b/projects/plugins/jetpack/src/class-jetpack-script-data.php @@ -9,7 +9,6 @@ namespace Automattic\Jetpack\Plugin; -use Automattic\Jetpack\Comments\Comments; use Automattic\Jetpack\Current_Plan as Jetpack_Plan; use Automattic\Jetpack\My_Jetpack\Initializer as My_Jetpack_Initializer; @@ -48,13 +47,12 @@ public static function set_admin_script_data( $data ) { ), ); - // Only the settings panel in My Jetpack reads these, so skip the theme folder scan elsewhere. + // Only the settings panel in My Jetpack reads it, so skip the theme folder scan elsewhere. // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Only selects which data to print. if ( 'my-jetpack' === sanitize_key( wp_unslash( $_GET['page'] ?? '' ) ) && self::is_settings_consolidation_enabled() ) { - $data['jetpack']['themeSupports'] = array( + $data['jetpack']['themeSupports'] = array( 'infiniteScroll' => self::theme_supports_infinite_scroll(), ); - $data['jetpack']['isCommentBlocksAvailable'] = Comments::is_enabled(); } return $data;