Passed
Branch main (b8e7f1)
by vishal
07:41
created
Category
wp-comment-preview.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@
 block discarded – undo
12 12
  * @package         WP_Comment_Preview
13 13
  */
14 14
 
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit; // Exit if accessed directly
17 17
 }
18 18
 
19
-define( 'WP_COMMENT_PREVIEW_URL', plugin_dir_url( __FILE__ ) );
20
-define( 'WP_COMMENT_PREVIEW_PATH', plugin_dir_path( __FILE__ ) );
19
+define('WP_COMMENT_PREVIEW_URL', plugin_dir_url(__FILE__));
20
+define('WP_COMMENT_PREVIEW_PATH', plugin_dir_path(__FILE__));
21 21
 
22 22
 require_once __DIR__ . '/inc/classes/class-comment-preview.php';
23 23
 
Please login to merge, or discard this patch.
inc/classes/class-comment-preview.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -27,15 +27,15 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	protected function _setup_hooks() {
29 29
 
30
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
30
+		add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
31 31
 
32
-		add_filter( 'comment_form_fields', array( $this, 'comment_form_fields' ), 20 );
32
+		add_filter('comment_form_fields', array($this, 'comment_form_fields'), 20);
33 33
 
34
-		add_filter( 'comment_form_field_comment', array( $this, 'append_markdown_option' ), 20 );
34
+		add_filter('comment_form_field_comment', array($this, 'append_markdown_option'), 20);
35 35
 
36
-		add_filter( 'comment_form_submit_button', array( $this, 'append_preview_button' ), 20 );
36
+		add_filter('comment_form_submit_button', array($this, 'append_preview_button'), 20);
37 37
 
38
-		add_action( 'rest_api_init', array( $this, 'register_rest_route' ) );
38
+		add_action('rest_api_init', array($this, 'register_rest_route'));
39 39
 	}
40 40
 
41 41
 	/**
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public function enqueue_scripts() {
45 45
 
46
-		if ( is_singular( 'post' ) ) {
46
+		if (is_singular('post')) {
47 47
 
48 48
 			wp_register_script(
49 49
 				'wp-comment-preview',
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
 				'wp-comment-preview',
58 58
 				'commentPreviewData',
59 59
 				array(
60
-					'apiURL' => get_rest_url( null, 'wp_comment_preview/v1/' ),
61
-					'nonce'  => wp_create_nonce( 'wp_rest' ),
60
+					'apiURL' => get_rest_url(null, 'wp_comment_preview/v1/'),
61
+					'nonce'  => wp_create_nonce('wp_rest'),
62 62
 				)
63 63
 			);
64 64
 
65
-			wp_enqueue_script( 'wp-comment-preview' );
65
+			wp_enqueue_script('wp-comment-preview');
66 66
 		}
67 67
 	}
68 68
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 *
74 74
 	 * @return mixed
75 75
 	 */
76
-	public function comment_form_fields( array $comment_fields = array() ) {
76
+	public function comment_form_fields(array $comment_fields = array()) {
77 77
 
78 78
 		ob_start();
79 79
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 		// Save output and stop output buffering.
84 84
 		$field = ob_get_clean();
85 85
 
86
-		if ( ! empty( $field ) ) {
86
+		if ( ! empty($field)) {
87 87
 
88 88
 			$comment_fields['comment'] = '<div id="preview-wrapper"></div>' . $comment_fields['comment'];
89 89
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 *
102 102
 	 * @return string Modified HTML.
103 103
 	 */
104
-	public function append_markdown_option( $fields ) {
104
+	public function append_markdown_option($fields) {
105 105
 
106 106
 		ob_start();
107 107
 
@@ -121,11 +121,11 @@  discard block
 block discarded – undo
121 121
 	 *
122 122
 	 * @return string Modified HTML
123 123
 	 */
124
-	public function append_preview_button( $submit_button = '' ) {
124
+	public function append_preview_button($submit_button = '') {
125 125
 
126 126
 		$preview_button = sprintf(
127 127
 			'<input name="preview" type="button" id="preview" class="submit" value="%1$s">',
128
-			esc_html__( 'Preview', 'comment-preview' )
128
+			esc_html__('Preview', 'comment-preview')
129 129
 		);
130 130
 
131 131
 		return $submit_button . $preview_button;
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 			'preview',
142 142
 			array(
143 143
 				'methods'             => \WP_REST_Server::CREATABLE,
144
-				'callback'            => array( $this, 'generate_preview' ),
144
+				'callback'            => array($this, 'generate_preview'),
145 145
 				'permission_callback' => '__return_true',
146 146
 			)
147 147
 		);
@@ -154,35 +154,35 @@  discard block
 block discarded – undo
154 154
 	 *
155 155
 	 * @return array Response object.
156 156
 	 */
157
-	public function generate_preview( $request ) {
157
+	public function generate_preview($request) {
158 158
 
159 159
 		$response = array();
160 160
 
161
-		if ( ! empty( $request['author'] ) ) {
162
-			$response['author'] = esc_html( $request['author'] );
161
+		if ( ! empty($request['author'])) {
162
+			$response['author'] = esc_html($request['author']);
163 163
 		}
164 164
 
165
-		$user_id = ( ( is_user_logged_in() ) ? get_current_user_id() : 0 );
165
+		$user_id = ((is_user_logged_in()) ? get_current_user_id() : 0);
166 166
 
167
-		if ( ! empty( $user_id ) ) {
167
+		if ( ! empty($user_id)) {
168 168
 
169
-			$user = get_userdata( $user_id );
169
+			$user = get_userdata($user_id);
170 170
 
171
-			if ( $user ) {
171
+			if ($user) {
172 172
 
173 173
 				$response['author'] = $user->data->display_name;
174 174
 			}
175 175
 		}
176 176
 
177
-		$response['gravatar'] = get_avatar_url( $user_id, array( 'size' => 50 ) );
177
+		$response['gravatar'] = get_avatar_url($user_id, array('size' => 50));
178 178
 
179
-		$response['date'] = current_time( get_option( 'date_format' ) . ' \a\t ' . get_option( 'time_format' ) );
179
+		$response['date'] = current_time(get_option('date_format') . ' \a\t ' . get_option('time_format'));
180 180
 
181
-		if ( ! empty( $request['comment'] ) && isset( $request['format'] ) ) {
182
-			if ( 'text' === $request['format'] ) {
183
-				$comment = wp_kses_data( $request['comment'] );
181
+		if ( ! empty($request['comment']) && isset($request['format'])) {
182
+			if ('text' === $request['format']) {
183
+				$comment = wp_kses_data($request['comment']);
184 184
 			} else {
185
-				$comment = apply_filters( 'pre_comment_content', $request['comment'] );
185
+				$comment = apply_filters('pre_comment_content', $request['comment']);
186 186
 			}
187 187
 		} else {
188 188
 			$comment = '';
Please login to merge, or discard this patch.
templates/markdown-option.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,9 +10,9 @@
 block discarded – undo
10 10
 <div class="comment-form-markdown">
11 11
 
12 12
 	<input checked="checked" type="radio" id="format-markdown-radio" name="wp_comment_format" value="markdown">
13
-	<label for="format-markdown-radio"><?php esc_html_e( 'Use', 'comment-preview' ); ?> <a href="https://commonmark.org/help/"><?php esc_html_e( 'markdown', 'comment-preview' ); ?></a></label>
13
+	<label for="format-markdown-radio"><?php esc_html_e('Use', 'comment-preview'); ?> <a href="https://commonmark.org/help/"><?php esc_html_e('markdown', 'comment-preview'); ?></a></label>
14 14
 
15 15
 	<input type="radio" id="format-text-radio" name="wp_comment_format" value="text">
16
-	<label for="format-text-radio"><?php esc_html_e( 'Use plain text', 'comment-preview' ); ?></label>
16
+	<label for="format-text-radio"><?php esc_html_e('Use plain text', 'comment-preview'); ?></label>
17 17
 
18 18
 </div>
Please login to merge, or discard this patch.