PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 All 507 releases
← All changes | modules/comments/admin.php +46 -0 16.2 → 16.3-beta View file →
@@ -4,8 +4,11 @@
4 4 *
5 5 * @package automattic/jetpack
6 6 */
7 7
8 +use Automattic\Jetpack\Comments\Block_Editor;
9 +use Automattic\Jetpack\Comments\Comments;
10 +
8 11 if ( ! defined( 'ABSPATH' ) ) {
9 12 exit( 0 );
10 13 }
11 14
@@ -132,8 +135,51 @@
132 135 'discussion',
133 136 'jetpack_comment_form_color_scheme',
134 137 array( $this, 'comment_form_color_scheme_sanitize' )
135 138 );
139 +
140 + // The rebuilt comment form is what offers blocks; the package may lag this file on a staged deploy.
141 + if ( ! class_exists( Block_Editor::class ) || ! Comments::is_enabled() ) {
142 + return;
143 + }
144 +
145 + add_settings_field(
146 + 'enable_blocks_comments',
147 + __( 'Allow Blocks', 'jetpack' ),
148 + array( $this, 'allow_blocks_field' ),
149 + 'discussion',
150 + 'jetpack_comment_form'
151 + );
152 +
153 + register_setting(
154 + 'discussion',
155 + 'enable_blocks_comments',
156 + array( $this, 'allow_blocks_sanitize' )
157 + );
158 + }
159 +
160 + /**
161 + * Blocks in comments setting.
162 + */
163 + public function allow_blocks_field() {
164 + ?>
165 +
166 + <label>
167 + <input name="enable_blocks_comments" type="checkbox" value="1" <?php checked( (bool) get_option( 'enable_blocks_comments', true ) ); ?>>
168 + <?php esc_html_e( 'Enable blocks in comments', 'jetpack' ); ?>
169 + </label>
170 +
171 + <?php
172 + }
173 +
174 + /**
175 + * Sanitize the blocks in comments setting.
176 + *
177 + * @param mixed $val The submitted value.
178 + * @return string
179 + */
180 + public function allow_blocks_sanitize( $val ) {
181 + return $val ? '1' : '0';
136 182 }
137 183
138 184 /**
139 185 * Discussions setting section blurb