PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 6.4.4
Jetpack – WP Security, Backup, Speed, & Growth v6.4.4
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 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 14.4.2 All 500 releases
← All changes | modules/comments/admin.php +44 -69 12.3.26.4.4 View file →
@@ -1,46 +1,31 @@
1 -<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 -/**
3 - * Jetpack comments admin menu file.
4 - *
5 - * @package automattic/jetpack
6 - */
7 -/**
8 - * Class Jetpack_Comments_Settings
9 - * This class represents the comments settings functionality.
10 - */
1 +<?php
2 +
11 3 class Jetpack_Comments_Settings {
12 4
13 5 /** Variables *************************************************************/
14 6
15 7 /**
16 - * The Jetpack Comments singleton
17 - *
18 - * @var Highlander_Comments_Base
8 + * The Jetpack Coments singleton
19 9 */
20 10 public $jetpack_comments;
21 11
22 12 /**
23 - * The default comment form greeting - blank to start with
24 - *
13 + * The default comment form greeting
25 14 * @var string
26 15 */
27 - public $default_greeting = ''; // Set in constructor.
16 + public $default_greeting = ''; // Set in constructor
28 17
29 18 /**
30 - * The default comment form color scheme - an empty array to start with
31 - *
32 - * @var array
19 + * The default comment form color scheme
20 + * @var string
33 21 */
34 22 public $color_schemes = array();
35 23
36 - /**
37 - * Initialize class
38 - */
39 24 public static function init() {
40 25 static $instance = false;
41 26
42 - if ( ! $instance ) {
27 + if ( !$instance ) {
43 28 $instance = new Jetpack_Comments_Settings( Jetpack_Comments::init() );
44 29 }
45 30
46 31 return $instance;
@@ -45,41 +30,35 @@
45 30
46 31 return $instance;
47 32 }
48 33
49 - /**
50 - * Constructor
51 - *
52 - * @param Highlander_Comments_Base $jetpack_comments The Jetpack Comments singleton.
53 - */
54 34 public function __construct( Highlander_Comments_Base $jetpack_comments ) {
55 35 $this->jetpack_comments = $jetpack_comments;
56 36
57 - // Setup settings.
37 + // Setup settings
58 38 add_action( 'admin_init', array( $this, 'add_settings' ) );
59 39 $this->setup_globals();
60 40 }
61 41
62 - /** Private Methods ****************************************************** */
42 + /** Private Methods *******************************************************/
63 43
64 44 /**
65 45 * Set any global variables or class variables
66 - *
67 46 * @since JetpackComments (1.4)
68 47 */
69 48 protected function setup_globals() {
70 - // Default option values.
49 + // Default option values
71 50 $this->default_greeting = __( 'Leave a Reply', 'jetpack' );
72 51
73 - // Possible color schemes.
52 + // Possible color schemes
74 53 $this->color_schemes = array(
75 - 'light' => __( 'Light', 'jetpack' ),
76 - 'dark' => __( 'Dark', 'jetpack' ),
77 - 'transparent' => __( 'Transparent', 'jetpack' ),
54 + 'light' => __( 'Light', 'jetpack' ),
55 + 'dark' => __( 'Dark', 'jetpack' ),
56 + 'transparent' => __( 'Transparent', 'jetpack' ),
78 57 );
79 58 }
80 59
81 - /** Settings ************************************************************* */
60 + /** Settings **************************************************************/
82 61
83 62 /**
84 63 * Add the Jetpack settings to WordPress's discussions page
85 64 *
@@ -86,9 +65,9 @@
86 65 * @since JetpackComments (1.4)
87 66 */
88 67 public function add_settings() {
89 68
90 - // Create the section.
69 + // Create the section
91 70 add_settings_section(
92 71 'jetpack_comment_form',
93 72 __( 'Comments', 'jetpack' ),
94 73 array( $this, 'comment_form_settings_section' ),
@@ -94,11 +73,10 @@
94 73 array( $this, 'comment_form_settings_section' ),
95 74 'discussion'
96 75 );
97 76
98 - /**
99 - * Clever Greeting
100 - */
77 + /** Clever Greeting ***************************************************/
78 +
101 79 add_settings_field(
102 80 'highlander_comment_form_prompt',
103 81 __( 'Greeting Text', 'jetpack' ),
104 82 array( $this, 'comment_form_greeting_setting' ),
@@ -111,11 +89,10 @@
111 89 'highlander_comment_form_prompt',
112 90 array( $this, 'comment_form_greeting_sanitize' )
113 91 );
114 92
115 - /**
116 - * Color Scheme
117 - */
93 + /** Color Scheme ******************************************************/
94 +
118 95 add_settings_field(
119 96 'jetpack_comment_form_color_scheme',
120 97 __( 'Color Scheme', 'jetpack' ),
121 98 array( $this, 'comment_form_color_scheme_setting' ),
@@ -135,13 +112,13 @@
135 112 *
136 113 * @since JetpackComments (1.4)
137 114 */
138 115 public function comment_form_settings_section() {
139 - ?>
116 + ?>
140 117
141 - <p id="jetpack-comments-settings"><?php esc_html_e( 'Adjust your Comments form with a clever greeting and color-scheme.', 'jetpack' ); ?></p>
118 + <p id="jetpack-comments-settings"><?php _e( 'Adjust your Comments form with a clever greeting and color-scheme.', 'jetpack' ); ?></p>
142 119
143 - <?php
120 + <?php
144 121 }
145 122
146 123 /**
147 124 * Custom Comment Greeting Text
@@ -149,16 +126,15 @@
149 126 * @since JetpackComments (1.4)
150 127 */
151 128 public function comment_form_greeting_setting() {
152 129
153 - // The greeting.
154 - $greeting = get_option( 'highlander_comment_form_prompt', $this->default_greeting );
155 - ?>
130 + // The greeting
131 + $greeting = get_option( 'highlander_comment_form_prompt', $this->default_greeting ); ?>
156 132
157 133 <input type="text" name="highlander_comment_form_prompt" id="jetpack-comment-form-greeting" value="<?php echo esc_attr( $greeting ); ?>" class="regular-text">
158 - <p class="description"><?php esc_html_e( 'A few catchy words to motivate your readers to comment', 'jetpack' ); ?></p>
134 + <p class="description"><?php _e( 'A few catchy words to motivate your readers to comment', 'jetpack' ); ?></p>
159 135
160 - <?php
136 + <?php
161 137 }
162 138
163 139 /**
164 140 * Sanitize the clever comment greeting
@@ -163,15 +139,15 @@
163 139 /**
164 140 * Sanitize the clever comment greeting
165 141 *
166 142 * @since JetpackComments (1.4)
167 - * @param string $val The contact form greeting string.
143 + * @param type $val
168 144 * @return string
169 145 */
170 - public function comment_form_greeting_sanitize( $val ) {
146 + function comment_form_greeting_sanitize( $val ) {
171 147
172 - // Delete if empty or the default.
173 - if ( empty( $val ) || ( $this->default_greeting === $val ) ) {
148 + // Delete if empty or the default
149 + if ( empty( $val ) || ( $this->default_greeting == $val ) ) {
174 150 delete_option( 'highlander_comment_form_prompt' );
175 151 return false;
176 152 }
177 153
@@ -178,26 +154,25 @@
178 154 return wp_kses( $val, array() );
179 155 }
180 156
181 157 /**
182 - * Comment Form Color Scheme Setting
158 + * Color Scheme Setting
183 159 *
184 160 * @since JetpackComments (1.4)
185 161 */
186 162 public function comment_form_color_scheme_setting() {
187 163
188 - // The color scheme.
189 - $scheme = get_option( 'jetpack_comment_form_color_scheme', $this->jetpack_comments->default_color_scheme );
190 - ?>
164 + // The color scheme
165 + $scheme = get_option( 'jetpack_comment_form_color_scheme', $this->jetpack_comments->default_color_scheme ); ?>
191 166
192 167 <fieldset>
193 - <legend class="screen-reader-text"><?php esc_html_e( 'Color Scheme', 'jetpack' ); ?></legend>
168 + <legend class="screen-reader-text"><?php _e( 'Color Scheme', 'jetpack' ); ?></legend>
194 169
195 - <?php foreach ( $this->color_schemes as $key => $label ) : ?>
170 + <?php foreach( $this->color_schemes as $key => $label ) : ?>
196 171
197 172 <label>
198 - <input type="radio" name="jetpack_comment_form_color_scheme" id="jetpack-comment-form-color-scheme" value="<?php echo esc_attr( $key ); ?>" <?php checked( $scheme, $key ); ?>>
199 - <?php echo esc_attr( $label ); ?>
173 + <input type="radio" name="jetpack_comment_form_color_scheme" id="jetpack-comment-form-color-scheme" value="<?php echo $key; ?>" <?php checked( $scheme, $key ); ?>>
174 + <?php echo $label; ?>
200 175 </label>
201 176 <br />
202 177
203 178 <?php endforeach; ?>
@@ -203,9 +178,9 @@
203 178 <?php endforeach; ?>
204 179
205 180 </fieldset>
206 181
207 - <?php
182 + <?php
208 183 }
209 184
210 185 /**
211 186 * Sanitize the color scheme
@@ -210,18 +185,18 @@
210 185 /**
211 186 * Sanitize the color scheme
212 187 *
213 188 * @since JetpackComments (1.4)
214 - * @param string $val The color scheme string.
189 + * @param type $val
215 190 * @return string
216 191 */
217 192 public function comment_form_color_scheme_sanitize( $val ) {
218 193
219 - // Delete the option if it's unknown, or the default.
194 + // Delete the option if it's...
220 195 if (
221 - empty( $val ) || ! array_key_exists( $val, $this->color_schemes )
196 + empty( $val ) || !in_array( $val, array_keys( $this->color_schemes ) ) // ... unknown
222 197 ||
223 - $val === $this->jetpack_comments->default_color_scheme
198 + $val == $this->jetpack_comments->default_color_scheme // ... or the default
224 199 ) {
225 200 delete_option( 'jetpack_comment_form_color_scheme' );
226 201 return false;
227 202 }