diff --git a/projects/packages/comments/changelog/update-comments-settings-screen b/projects/packages/comments/changelog/update-comments-settings-screen new file mode 100644 index 000000000000..e915d8032ffe --- /dev/null +++ b/projects/packages/comments/changelog/update-comments-settings-screen @@ -0,0 +1,4 @@ +Significance: minor +Type: added + +Add site settings to turn images and embeds in comments on or off. Blocks in comments are always on. diff --git a/projects/packages/comments/src/editor/class-block-editor.php b/projects/packages/comments/src/editor/class-block-editor.php index a9e5eaee05e9..34a8d887250d 100644 --- a/projects/packages/comments/src/editor/class-block-editor.php +++ b/projects/packages/comments/src/editor/class-block-editor.php @@ -113,10 +113,9 @@ public static function is_enabled() { * * @since 0.4.0 * - * @param bool $enabled Whether to offer the block editor. Default true, unless WordPress.com's - * "blocks in comments" Discussion setting is off. + * @param bool $enabled Whether to offer the block editor. Default true. */ - return (bool) apply_filters( 'jetpack_comments_block_editor', (bool) get_option( 'enable_blocks_comments', true ) ); + return (bool) apply_filters( 'jetpack_comments_block_editor', true ); } /** diff --git a/projects/packages/comments/src/editor/class-embeds.php b/projects/packages/comments/src/editor/class-embeds.php index 3b836d20956d..4b6c4622db62 100644 --- a/projects/packages/comments/src/editor/class-embeds.php +++ b/projects/packages/comments/src/editor/class-embeds.php @@ -82,9 +82,9 @@ public static function is_enabled() { * * @since 0.5.0 * - * @param bool $enabled Whether to offer it. Default true, wherever the block editor is on. + * @param bool $enabled Whether to offer it. Default the site's setting, which starts on, wherever the block editor is on. */ - return Comments::is_enabled() && Block_Editor::is_enabled() && (bool) apply_filters( 'jetpack_comments_block_editor_embeds', true ); + return Comments::is_enabled() && Block_Editor::is_enabled() && (bool) apply_filters( 'jetpack_comments_block_editor_embeds', (bool) get_option( 'jetpack_comments_embeds', true ) ); } /** diff --git a/projects/packages/comments/src/editor/class-images.php b/projects/packages/comments/src/editor/class-images.php index cbd5ed849c2a..612bb937fe68 100644 --- a/projects/packages/comments/src/editor/class-images.php +++ b/projects/packages/comments/src/editor/class-images.php @@ -24,9 +24,9 @@ public static function is_enabled() { * * @since 0.6.0 * - * @param bool $enabled Whether to offer it. Default true, wherever the block editor is on. + * @param bool $enabled Whether to offer it. Default the site's setting, which starts on, wherever the block editor is on. */ - return Block_Editor::is_enabled() && (bool) apply_filters( 'jetpack_comments_block_editor_images', true ); + return Block_Editor::is_enabled() && (bool) apply_filters( 'jetpack_comments_block_editor_images', (bool) get_option( 'jetpack_comments_images', true ) ); } /** diff --git a/projects/packages/sync/changelog/update-comments-settings-screen b/projects/packages/sync/changelog/update-comments-settings-screen new file mode 100644 index 000000000000..f0979ef5167b --- /dev/null +++ b/projects/packages/sync/changelog/update-comments-settings-screen @@ -0,0 +1,4 @@ +Significance: patch +Type: added + +Add the Jetpack Comments image and embed settings to the synced options. diff --git a/projects/packages/sync/src/class-defaults.php b/projects/packages/sync/src/class-defaults.php index 633ed71c3062..d3653beec816 100644 --- a/projects/packages/sync/src/class-defaults.php +++ b/projects/packages/sync/src/class-defaults.php @@ -79,6 +79,8 @@ class Defaults { 'jetpack_available_modules', 'jetpack_comment_form_color_scheme', 'jetpack_comment_likes_enabled', + 'jetpack_comments_embeds', + 'jetpack_comments_images', 'jetpack_excluded_extensions', 'jetpack_holiday_snow_enabled', 'jetpack_mailchimp', diff --git a/projects/plugins/jetpack/_inc/client/discussion/comments.jsx b/projects/plugins/jetpack/_inc/client/discussion/comments.jsx index 69d073f89fcd..e6df00f14b8a 100644 --- a/projects/plugins/jetpack/_inc/client/discussion/comments.jsx +++ b/projects/plugins/jetpack/_inc/client/discussion/comments.jsx @@ -38,8 +38,12 @@ class CommentsComponent extends Component { this.props.updateFormStateModuleOption( 'markdown', 'wpcom_publish_comments_with_markdown' ); }; - handleBlocksToggle = () => { - this.props.updateFormStateModuleOption( 'comments', 'enable_blocks_comments' ); + handleImagesToggle = () => { + this.props.updateFormStateModuleOption( 'comments', 'jetpack_comments_images' ); + }; + + handleEmbedsToggle = () => { + this.props.updateFormStateModuleOption( 'comments', 'jetpack_comments_embeds' ); }; render() { @@ -69,7 +73,8 @@ class CommentsComponent extends Component { module="comments" saveDisabled={ this.props.isSavingAnyOption( [ 'highlander_comment_form_prompt', - 'enable_blocks_comments', + 'jetpack_comments_images', + 'jetpack_comments_embeds', ] ) } > { foundComments && ( @@ -98,23 +103,46 @@ class CommentsComponent extends Component { { comments.description } { this.props.hasBlockEditor && ( - - - { __( 'Enable blocks in comments.', 'jetpack' ) } - - } - __nextHasNoMarginBottom={ true } - /> - + <> + + + { __( 'Allow images from links.', 'jetpack' ) } + + } + __nextHasNoMarginBottom={ true } + /> + + + + { __( 'Allow embeds from YouTube, X, and other services.', 'jetpack' ) } + + } + __nextHasNoMarginBottom={ true } + /> + + ) } diff --git a/projects/plugins/jetpack/_inc/lib/class.core-rest-api-endpoints.php b/projects/plugins/jetpack/_inc/lib/class.core-rest-api-endpoints.php index f6217261bdf7..0ab95a127187 100644 --- a/projects/plugins/jetpack/_inc/lib/class.core-rest-api-endpoints.php +++ b/projects/plugins/jetpack/_inc/lib/class.core-rest-api-endpoints.php @@ -1752,6 +1752,20 @@ public static function get_updateable_data_list( $selector = '' ) { 'validate_callback' => __CLASS__ . '::validate_boolean', 'jp_group' => 'comments', ), + 'jetpack_comments_images' => array( + 'description' => esc_html__( 'Allow images in comments', 'jetpack' ), + 'type' => 'boolean', + 'default' => 1, + 'validate_callback' => __CLASS__ . '::validate_boolean', + 'jp_group' => 'comments', + ), + 'jetpack_comments_embeds' => array( + 'description' => esc_html__( 'Allow embeds in comments', 'jetpack' ), + 'type' => 'boolean', + 'default' => 1, + 'validate_callback' => __CLASS__ . '::validate_boolean', + 'jp_group' => 'comments', + ), // Custom Content Types. 'jetpack_portfolio' => array( diff --git a/projects/plugins/jetpack/changelog/update-comments-settings-screen b/projects/plugins/jetpack/changelog/update-comments-settings-screen new file mode 100644 index 000000000000..1404d2e0414a --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-comments-settings-screen @@ -0,0 +1,4 @@ +Significance: minor +Type: enhancement + +Discussion: Add settings for images and embeds in comments, and remove the setting to turn off blocks in comments. diff --git a/projects/plugins/jetpack/modules/comments/admin.php b/projects/plugins/jetpack/modules/comments/admin.php index 1f3b851dc823..aff46e80a339 100644 --- a/projects/plugins/jetpack/modules/comments/admin.php +++ b/projects/plugins/jetpack/modules/comments/admin.php @@ -5,8 +5,6 @@ * @package automattic/jetpack */ -use Automattic\Jetpack\Comments\Comments; - if ( ! defined( 'ABSPATH' ) ) { exit( 0 ); } @@ -104,48 +102,6 @@ public function add_settings() { 'highlander_comment_form_prompt', array( $this, 'comment_form_greeting_sanitize' ) ); - - if ( ! Comments::is_enabled() ) { - return; - } - - add_settings_field( - 'enable_blocks_comments', - __( 'Allow Blocks', 'jetpack' ), - array( $this, 'allow_blocks_field' ), - 'discussion', - 'jetpack_comment_form' - ); - - register_setting( - 'discussion', - 'enable_blocks_comments', - array( $this, 'allow_blocks_sanitize' ) - ); - } - - /** - * Blocks in comments setting. - */ - public function allow_blocks_field() { - ?> - - - - '', 'jetpack_verbum_subscription_modal' => true, 'enable_blocks_comments' => '1', + 'jetpack_comments_images' => true, + 'jetpack_comments_embeds' => true, 'jetpack_blocks_disabled' => false, 'wpcom_ai_site_prompt' => '', 'reader_chat' => false,