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 +58 -7 12.0.3 → 16.3-beta View file →
@@ -3,8 +3,16 @@
3 3 * Jetpack comments admin menu file.
4 4 *
5 5 * @package automattic/jetpack
6 6 */
7 +
8 +use Automattic\Jetpack\Comments\Block_Editor;
9 +use Automattic\Jetpack\Comments\Comments;
10 +
11 +if ( ! defined( 'ABSPATH' ) ) {
12 + exit( 0 );
13 +}
14 +
7 15 /**
8 16 * Class Jetpack_Comments_Settings
9 17 * This class represents the comments settings functionality.
10 18 */
@@ -63,9 +71,9 @@
63 71
64 72 /**
65 73 * Set any global variables or class variables
66 74 *
67 - * @since JetpackComments (1.4)
75 + * @since 1.4
68 76 */
69 77 protected function setup_globals() {
70 78 // Default option values.
71 79 $this->default_greeting = __( 'Leave a Reply', 'jetpack' );
@@ -82,9 +90,9 @@
82 90
83 91 /**
84 92 * Add the Jetpack settings to WordPress's discussions page
85 93 *
86 - * @since JetpackComments (1.4)
94 + * @since 1.4
87 95 */
88 96 public function add_settings() {
89 97
90 98 // Create the section.
@@ -127,14 +135,57 @@
127 135 'discussion',
128 136 'jetpack_comment_form_color_scheme',
129 137 array( $this, 'comment_form_color_scheme_sanitize' )
130 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 + );
131 158 }
132 159
133 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';
182 + }
183 +
184 + /**
134 185 * Discussions setting section blurb
135 186 *
136 - * @since JetpackComments (1.4)
187 + * @since 1.4
137 188 */
138 189 public function comment_form_settings_section() {
139 190 ?>
140 191
@@ -145,9 +196,9 @@
145 196
146 197 /**
147 198 * Custom Comment Greeting Text
148 199 *
149 - * @since JetpackComments (1.4)
200 + * @since 1.4
150 201 */
151 202 public function comment_form_greeting_setting() {
152 203
153 204 // The greeting.
@@ -162,9 +213,9 @@
162 213
163 214 /**
164 215 * Sanitize the clever comment greeting
165 216 *
166 - * @since JetpackComments (1.4)
217 + * @since 1.4
167 218 * @param string $val The contact form greeting string.
168 219 * @return string
169 220 */
170 221 public function comment_form_greeting_sanitize( $val ) {
@@ -180,9 +231,9 @@
180 231
181 232 /**
182 233 * Comment Form Color Scheme Setting
183 234 *
184 - * @since JetpackComments (1.4)
235 + * @since 1.4
185 236 */
186 237 public function comment_form_color_scheme_setting() {
187 238
188 239 // The color scheme.
@@ -209,9 +260,9 @@
209 260
210 261 /**
211 262 * Sanitize the color scheme
212 263 *
213 - * @since JetpackComments (1.4)
264 + * @since 1.4
214 265 * @param string $val The color scheme string.
215 266 * @return string
216 267 */
217 268 public function comment_form_color_scheme_sanitize( $val ) {