Passed
Branch master (51607c)
by Paul
05:13
created
views/addons/addon.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php defined( 'WPINC' ) || die; ?>
1
+<?php defined('WPINC') || die; ?>
2 2
 
3 3
 <div class="glsr-addon-wrap">
4 4
 	<div class="glsr-addon">
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 		</div>
9 9
 		<h3 class="glsr-addon-name">{{ title }}</h3>
10 10
 		<a href="{{ link }}" class="glsr-addon-link button button-secondary">
11
-			<?= __( 'More Info', 'site-reviews' ); ?>
11
+			<?= __('More Info', 'site-reviews'); ?>
12 12
 		</a>
13 13
 	</div>
14 14
 </div>
Please login to merge, or discard this patch.
views/index.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@
 block discarded – undo
1
-<?php defined( 'WPINC' ) || die;
1
+<?php defined('WPINC') || die;
2 2
 
3
-$file = sprintf( '%s/site-reviews/%s.php', get_stylesheet_directory(), $view );
4
-if( !file_exists( $file )) {
5
-	$file = trailingslashit( __DIR__ )."{$view}.php";
3
+$file = sprintf('%s/site-reviews/%s.php', get_stylesheet_directory(), $view);
4
+if (!file_exists($file)) {
5
+	$file = trailingslashit(__DIR__)."{$view}.php";
6 6
 }
7
-$file = apply_filters( 'site-reviews/addon/views/file', $file, $view, $data );
7
+$file = apply_filters('site-reviews/addon/views/file', $file, $view, $data);
8 8
 
9
-if( file_exists( $file )) {
9
+if (file_exists($file)) {
10 10
 	include $file;
11 11
 }
12 12
 else {
13
-	glsr_log()->error( 'File not found: '.$file );
13
+	glsr_log()->error('File not found: '.$file);
14 14
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,7 +8,6 @@
 block discarded – undo
8 8
 
9 9
 if( file_exists( $file )) {
10 10
 	include $file;
11
-}
12
-else {
11
+} else {
13 12
 	glsr_log()->error( 'File not found: '.$file );
14 13
 }
Please login to merge, or discard this patch.
plugin/Handlers/RegisterShortcodes.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,15 +10,15 @@
 block discarded – undo
10 10
 	/**
11 11
 	 * @return void
12 12
 	 */
13
-	public function handle( Command $command )
13
+	public function handle(Command $command)
14 14
 	{
15
-		foreach( $command->shortcodes as $shortcode ) {
16
-			$shortcodeClass = glsr( Helper::class )->buildClassName( $shortcode.'-shortcode', 'Shortcodes' );
17
-			if( !class_exists( $shortcodeClass )) {
18
-				glsr_log()->error( sprintf( 'Class missing (%s)', $shortcodeClass ));
15
+		foreach ($command->shortcodes as $shortcode) {
16
+			$shortcodeClass = glsr(Helper::class)->buildClassName($shortcode.'-shortcode', 'Shortcodes');
17
+			if (!class_exists($shortcodeClass)) {
18
+				glsr_log()->error(sprintf('Class missing (%s)', $shortcodeClass));
19 19
 				continue;
20 20
 			}
21
-			add_shortcode( $shortcode, [glsr( $shortcodeClass ), 'buildShortcode'] );
21
+			add_shortcode($shortcode, [glsr($shortcodeClass), 'buildShortcode']);
22 22
 		}
23 23
 	}
24 24
 }
Please login to merge, or discard this patch.
plugin/Handlers/RegisterShortcodeButtons.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,15 +10,15 @@
 block discarded – undo
10 10
 	/**
11 11
 	 * @return void
12 12
 	 */
13
-	public function handle( Command $command )
13
+	public function handle(Command $command)
14 14
 	{
15
-		foreach( $command->shortcodes as $slug => $label ) {
16
-			$buttonClass = glsr( Helper::class )->buildClassName( $slug.'-button', 'Shortcodes' );
17
-			if( !class_exists( $buttonClass )) {
18
-				glsr_log()->error( sprintf( 'Class missing (%s)', $buttonClass ));
15
+		foreach ($command->shortcodes as $slug => $label) {
16
+			$buttonClass = glsr(Helper::class)->buildClassName($slug.'-button', 'Shortcodes');
17
+			if (!class_exists($buttonClass)) {
18
+				glsr_log()->error(sprintf('Class missing (%s)', $buttonClass));
19 19
 				continue;
20 20
 			}
21
-			$shortcode = glsr( $buttonClass )->register( $slug, [
21
+			$shortcode = glsr($buttonClass)->register($slug, [
22 22
 				'label' => $label,
23 23
 				'title' => $label,
24 24
 			]);
Please login to merge, or discard this patch.
plugin/Handlers/RegisterWidgets.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,17 +11,17 @@
 block discarded – undo
11 11
 	/**
12 12
 	 * @return void
13 13
 	 */
14
-	public function handle( Command $command )
14
+	public function handle(Command $command)
15 15
 	{
16 16
 		global $wp_widget_factory;
17
-		foreach( $command->widgets as $key => $values ) {
18
-			$widgetClass = glsr( Helper::class )->buildClassName( $key.'-widget', 'Widgets' );
19
-			if( !class_exists( $widgetClass )) {
20
-				glsr_log()->error( sprintf( 'Class missing (%s)', $widgetClass ));
17
+		foreach ($command->widgets as $key => $values) {
18
+			$widgetClass = glsr(Helper::class)->buildClassName($key.'-widget', 'Widgets');
19
+			if (!class_exists($widgetClass)) {
20
+				glsr_log()->error(sprintf('Class missing (%s)', $widgetClass));
21 21
 				continue;
22 22
 			}
23 23
 			// Here we bypass register_widget() in order to pass our custom values to the widget
24
-			$widget = new $widgetClass( Application::ID.'_'.$key, $values['title'], $values );
24
+			$widget = new $widgetClass(Application::ID.'_'.$key, $values['title'], $values);
25 25
 			$wp_widget_factory->widgets[$widgetClass] = $widget;
26 26
 		}
27 27
 	}
Please login to merge, or discard this patch.
plugin/Handlers/EnqueueAdminAssets.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
 	{
24 24
 		wp_enqueue_style(
25 25
 			Application::ID,
26
-			glsr()->url( 'assets/styles/'.Application::ID.'-admin.css' ),
26
+			glsr()->url('assets/styles/'.Application::ID.'-admin.css'),
27 27
 			[],
28 28
 			glsr()->version
29 29
 		);
30
-		if( !$this->isCurrentScreen() )return;
30
+		if (!$this->isCurrentScreen())return;
31 31
 		wp_enqueue_script(
32 32
 			Application::ID,
33
-			glsr()->url( 'assets/scripts/'.Application::ID.'-admin.js' ),
33
+			glsr()->url('assets/scripts/'.Application::ID.'-admin.js'),
34 34
 			$this->getDependencies(),
35 35
 			glsr()->version,
36 36
 			true
@@ -44,14 +44,14 @@  discard block
 block discarded – undo
44 44
 	{
45 45
 		$variables = [
46 46
 			'action' => Application::PREFIX.'action',
47
-			'ajaxurl' => admin_url( 'admin-ajax.php' ),
47
+			'ajaxurl' => admin_url('admin-ajax.php'),
48 48
 			'shortcodes' => [],
49 49
 		];
50
-		if( user_can_richedit() ) {
50
+		if (user_can_richedit()) {
51 51
 			$variables['shortcodes'] = $this->localizeShortcodes();
52 52
 		}
53
-		$variables = apply_filters( 'site-reviews/enqueue/localize', $variables );
54
-		wp_localize_script( Application::ID, 'site_reviews', $variables );
53
+		$variables = apply_filters('site-reviews/enqueue/localize', $variables);
54
+		wp_localize_script(Application::ID, 'site_reviews', $variables);
55 55
 	}
56 56
 
57 57
 	/**
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	protected function getDependencies()
61 61
 	{
62 62
 		$dependencies = []; //glsr( Html::class )->getDependencies();
63
-		$dependencies = array_merge( $dependencies, [
63
+		$dependencies = array_merge($dependencies, [
64 64
 			'jquery', 'jquery-ui-sortable', 'underscore', 'wp-util',
65 65
 		]);
66 66
 		return $dependencies;
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	protected function isCurrentScreen()
73 73
 	{
74 74
 		$screen = glsr_current_screen();
75
-		return $screen && ( $screen->post_type == Application::POST_TYPE
75
+		return $screen && ($screen->post_type == Application::POST_TYPE
76 76
 			|| $screen->base == 'post'
77 77
 			|| $screen->id == 'dashboard'
78 78
 			|| $screen->id == 'widgets'
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 	protected function localizeShortcodes()
86 86
 	{
87 87
 		$variables = [];
88
-		foreach( glsr()->mceShortcodes as $tag => $args ) {
89
-			if( empty( $args['required'] ))continue;
88
+		foreach (glsr()->mceShortcodes as $tag => $args) {
89
+			if (empty($args['required']))continue;
90 90
 			$variables[$tag] = $args['required'];
91 91
 		}
92 92
 		return $variables;
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,7 +27,9 @@  discard block
 block discarded – undo
27 27
 			[],
28 28
 			glsr()->version
29 29
 		);
30
-		if( !$this->isCurrentScreen() )return;
30
+		if( !$this->isCurrentScreen() ) {
31
+			return;
32
+		}
31 33
 		wp_enqueue_script(
32 34
 			Application::ID,
33 35
 			glsr()->url( 'assets/scripts/'.Application::ID.'-admin.js' ),
@@ -86,7 +88,9 @@  discard block
 block discarded – undo
86 88
 	{
87 89
 		$variables = [];
88 90
 		foreach( glsr()->mceShortcodes as $tag => $args ) {
89
-			if( empty( $args['required'] ))continue;
91
+			if( empty( $args['required'] )) {
92
+				continue;
93
+			}
90 94
 			$variables[$tag] = $args['required'];
91 95
 		}
92 96
 		return $variables;
Please login to merge, or discard this patch.
plugin/Handlers/RegisterPostType.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@
 block discarded – undo
9 9
 	/**
10 10
 	 * @return void
11 11
 	 */
12
-	public function handle( Command $command )
12
+	public function handle(Command $command)
13 13
 	{
14
-		if( in_array( $command->postType, get_post_types( ['_builtin' => true] )))return;
15
-		register_post_type( $command->postType, $command->args );
16
-		glsr()->postTypeColumns = wp_parse_args( glsr()->postTypeColumns, [
14
+		if (in_array($command->postType, get_post_types(['_builtin' => true])))return;
15
+		register_post_type($command->postType, $command->args);
16
+		glsr()->postTypeColumns = wp_parse_args(glsr()->postTypeColumns, [
17 17
 			$command->postType => $command->columns,
18 18
 		]);
19 19
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,9 @@
 block discarded – undo
11 11
 	 */
12 12
 	public function handle( Command $command )
13 13
 	{
14
-		if( in_array( $command->postType, get_post_types( ['_builtin' => true] )))return;
14
+		if( in_array( $command->postType, get_post_types( ['_builtin' => true] ))) {
15
+			return;
16
+		}
15 17
 		register_post_type( $command->postType, $command->args );
16 18
 		glsr()->postTypeColumns = wp_parse_args( glsr()->postTypeColumns, [
17 19
 			$command->postType => $command->columns,
Please login to merge, or discard this patch.
plugin/Handlers/SubmitReview.php 2 patches
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -13,29 +13,29 @@  discard block
 block discarded – undo
13 13
 	/**
14 14
 	 * @return void|string
15 15
 	 */
16
-	public function handle( Command $command )
16
+	public function handle(Command $command)
17 17
 	{
18
-		$post_id = glsr_db()->createReview( $this->normalize( $command ), $command );
19
-		glsr_db()->setReviewMeta( $post_id, $command->category );
20
-		$this->sendNotification( $post_id, $command );
21
-		$successMessage = apply_filters( 'site-reviews/local/review/submitted/message',
22
-			__( 'Your review has been submitted!', 'site-reviews' ),
18
+		$post_id = glsr_db()->createReview($this->normalize($command), $command);
19
+		glsr_db()->setReviewMeta($post_id, $command->category);
20
+		$this->sendNotification($post_id, $command);
21
+		$successMessage = apply_filters('site-reviews/local/review/submitted/message',
22
+			__('Your review has been submitted!', 'site-reviews'),
23 23
 			$command
24 24
 		);
25
-		do_action( 'site-reviews/local/review/submitted', $successMessage, $command );
26
-		if( $command->ajaxRequest ) {
27
-			glsr( Session::class )->clear();
25
+		do_action('site-reviews/local/review/submitted', $successMessage, $command);
26
+		if ($command->ajaxRequest) {
27
+			glsr(Session::class)->clear();
28 28
 			return $successMessage;
29 29
 		}
30
-		glsr( Session::class )->set( $command->formId.'-message', $successMessage );
31
-		wp_safe_redirect( $command->referrer );
30
+		glsr(Session::class)->set($command->formId.'-message', $successMessage);
31
+		wp_safe_redirect($command->referrer);
32 32
 		exit;
33 33
 	}
34 34
 
35 35
 	/**
36 36
 	 * @return \GeminiLabs\SiteReviews\Email
37 37
 	 */
38
-	protected function createEmailNotification( Command $command, array $args = [] )
38
+	protected function createEmailNotification(Command $command, array $args = [])
39 39
 	{
40 40
 		$email = [
41 41
 			'to' => $args['recipient'],
@@ -46,41 +46,41 @@  discard block
 block discarded – undo
46 46
 				'review_content' => $command->content,
47 47
 				'review_email' => $command->email,
48 48
 				'review_ip' => $command->ipAddress,
49
-				'review_link' => sprintf( '<a href="%1$s">%1$s</a>', $args['notification_link'] ),
49
+				'review_link' => sprintf('<a href="%1$s">%1$s</a>', $args['notification_link']),
50 50
 				'review_rating' => $command->rating,
51 51
 				'review_title' => $command->title,
52 52
 			],
53 53
 		];
54
-		return glsr( Email::class )->compose( $email );
54
+		return glsr(Email::class)->compose($email);
55 55
 	}
56 56
 
57 57
 	/**
58 58
 	 * @return string
59 59
 	 */
60
-	protected function createWebhookNotification( Command $command, array $args )
60
+	protected function createWebhookNotification(Command $command, array $args)
61 61
 	{
62 62
 		$fields = [];
63
-		$fields[] = ['title' => str_repeat( ':star:', (int) $command->rating )];
64
-		if( $command->title ) {
63
+		$fields[] = ['title' => str_repeat(':star:', (int)$command->rating)];
64
+		if ($command->title) {
65 65
 			$fields[] = ['title' => $command->title];
66 66
 		}
67
-		if( $command->content ) {
67
+		if ($command->content) {
68 68
 			$fields[] = ['value' => $command->content];
69 69
 		}
70
-		if( $command->email ) {
70
+		if ($command->email) {
71 71
 			$command->email = ' <'.$command->email.'>';
72 72
 		}
73
-		if( $command->author ) {
74
-			$fields[] = ['value' => trim( $command->author.$command->email.' - '.$command->ipAddress )];
73
+		if ($command->author) {
74
+			$fields[] = ['value' => trim($command->author.$command->email.' - '.$command->ipAddress)];
75 75
 		}
76
-		$fields[] = ['value' => sprintf( '<%s|%s>', $args['notification_link'], __( 'View Review', 'site-reviews' ))];
76
+		$fields[] = ['value' => sprintf('<%s|%s>', $args['notification_link'], __('View Review', 'site-reviews'))];
77 77
 		return json_encode([
78 78
 			'icon_url' => glsr()->url.'assets/img/icon.png',
79 79
 			'username' => glsr()->name,
80 80
 			'attachments' => [[
81 81
 				'pretext' => $args['notification_title'],
82 82
 				'color' => '#665068',
83
-				'fallback' => $this->createEmailNotification( $command, $args )->read( 'plaintext' ),
83
+				'fallback' => $this->createEmailNotification($command, $args)->read('plaintext'),
84 84
 				'fields' => $fields,
85 85
 			]],
86 86
 		]);
@@ -89,12 +89,12 @@  discard block
 block discarded – undo
89 89
 	/**
90 90
 	 * @return array
91 91
 	 */
92
-	protected function normalize( Command $command )
92
+	protected function normalize(Command $command)
93 93
 	{
94 94
 		$review = [
95 95
 			'author' => $command->author,
96 96
 			'assigned_to' => $command->assignedTo,
97
-			'avatar' => get_avatar_url( $command->email ),
97
+			'avatar' => get_avatar_url($command->email),
98 98
 			'content' => $command->content,
99 99
 			'email' => $command->email,
100 100
 			'ip_address' => $command->ipAddress,
@@ -102,66 +102,66 @@  discard block
 block discarded – undo
102 102
 			'review_type' => 'local',
103 103
 			'title' => $command->title,
104 104
 		];
105
-		return apply_filters( 'site-reviews/local/review', $review, $command );
105
+		return apply_filters('site-reviews/local/review', $review, $command);
106 106
 	}
107 107
 
108 108
 	/**
109 109
 	 * @param int $post_id
110 110
 	 * @return void|bool|array|WP_Error
111 111
 	 */
112
-	protected function sendNotification( $post_id, Command $command )
112
+	protected function sendNotification($post_id, Command $command)
113 113
 	{
114
-		$notificationType = glsr_get_option( 'general.notification' );
115
-		if( !in_array( $notificationType, ['default','custom','webhook'] ))return;
116
-		$assignedToTitle = get_the_title( (int) $command->assignedTo );
114
+		$notificationType = glsr_get_option('general.notification');
115
+		if (!in_array($notificationType, ['default', 'custom', 'webhook']))return;
116
+		$assignedToTitle = get_the_title((int)$command->assignedTo);
117 117
 		$notificationSubject = _nx(
118 118
 			'New %s-star review',
119 119
 			'New %s-star review of: %s',
120
-			(int) empty( $assignedToTitle ),
120
+			(int)empty($assignedToTitle),
121 121
 			'The text is different depending on whether or not the review has been assigned to a post.',
122 122
 			'site-reviews'
123 123
 		);
124
-		$notificationTitle = sprintf( '[%s] %s',
125
-			wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ),
126
-			sprintf( $notificationSubject, $command->rating, $assignedToTitle )
124
+		$notificationTitle = sprintf('[%s] %s',
125
+			wp_specialchars_decode(get_option('blogname'), ENT_QUOTES),
126
+			sprintf($notificationSubject, $command->rating, $assignedToTitle)
127 127
 		);
128 128
 		$args = [
129
-			'notification_link' => esc_url( admin_url( sprintf( 'post.php?post=%s&action=edit', $post_id ))),
129
+			'notification_link' => esc_url(admin_url(sprintf('post.php?post=%s&action=edit', $post_id))),
130 130
 			'notification_title' => $notificationTitle,
131 131
 			'notification_type' => $notificationType,
132 132
 		];
133 133
 		return $args['notification_type'] == 'webhook'
134
-			? $this->sendWebhookNotification( $command, $args )
135
-			: $this->sendEmailNotification( $command, $args );
134
+			? $this->sendWebhookNotification($command, $args)
135
+			: $this->sendEmailNotification($command, $args);
136 136
 	}
137 137
 
138 138
 	/**
139 139
 	 * @return bool
140 140
 	 */
141
-	protected function sendEmailNotification( Command $command, array $args )
141
+	protected function sendEmailNotification(Command $command, array $args)
142 142
 	{
143 143
 		$args['recipient'] = $args['notification_type'] === 'default'
144
-			? get_option( 'admin_email' )
145
-			: glsr_get_option( 'general.notification_email' );
146
-		$result = !empty( $args['recipient'] )
147
-			? $this->createEmailNotification( $command, $args )->send()
144
+			? get_option('admin_email')
145
+			: glsr_get_option('general.notification_email');
146
+		$result = !empty($args['recipient'])
147
+			? $this->createEmailNotification($command, $args)->send()
148 148
 			: false;
149
-		if( $result === null ) {
150
-			glsr_log( __( 'Email notification was not sent: missing email, subject, or message.', 'site-reviews' ), 'error' );
149
+		if ($result === null) {
150
+			glsr_log(__('Email notification was not sent: missing email, subject, or message.', 'site-reviews'), 'error');
151 151
 		}
152
-		if( $result === false ) {
153
-			glsr_log( __( 'Email notification was not sent: wp_mail() failed.', 'site-reviews' ), 'error' );
152
+		if ($result === false) {
153
+			glsr_log(__('Email notification was not sent: wp_mail() failed.', 'site-reviews'), 'error');
154 154
 		}
155
-		return (bool) $result;
155
+		return (bool)$result;
156 156
 	}
157 157
 
158 158
 	/**
159 159
 	 * @return array|WP_Error
160 160
 	 */
161
-	protected function sendWebhookNotification( Command $command, array $args )
161
+	protected function sendWebhookNotification(Command $command, array $args)
162 162
 	{
163
-		$notification = $this->createWebhookNotification( $command, $args );
164
-		$result = wp_remote_post( $endpoint, [
163
+		$notification = $this->createWebhookNotification($command, $args);
164
+		$result = wp_remote_post($endpoint, [
165 165
 			'method' => 'POST',
166 166
 			'timeout' => 45,
167 167
 			'redirection' => 5,
@@ -169,10 +169,10 @@  discard block
 block discarded – undo
169 169
 			'blocking' => false,
170 170
 			'sslverify' => false,
171 171
 			'headers' => ['Content-Type' => 'application/json'],
172
-			'body' => apply_filters( 'site-reviews/webhook/notification', $notification, $command ),
172
+			'body' => apply_filters('site-reviews/webhook/notification', $notification, $command),
173 173
 		]);
174
-		if( is_wp_error( $result )) {
175
-			glsr_log( $result->get_error_message(), 'error' );
174
+		if (is_wp_error($result)) {
175
+			glsr_log($result->get_error_message(), 'error');
176 176
 		}
177 177
 		return $result;
178 178
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -112,7 +112,9 @@
 block discarded – undo
112 112
 	protected function sendNotification( $post_id, Command $command )
113 113
 	{
114 114
 		$notificationType = glsr_get_option( 'general.notification' );
115
-		if( !in_array( $notificationType, ['default','custom','webhook'] ))return;
115
+		if( !in_array( $notificationType, ['default','custom','webhook'] )) {
116
+			return;
117
+		}
116 118
 		$assignedToTitle = get_the_title( (int) $command->assignedTo );
117 119
 		$notificationSubject = _nx(
118 120
 			'New %s-star review',
Please login to merge, or discard this patch.
plugin/Handlers/TogglePinned.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -10,22 +10,22 @@
 block discarded – undo
10 10
 	/**
11 11
 	 * @return bool
12 12
 	 */
13
-	public function handle( Command $command )
13
+	public function handle(Command $command)
14 14
 	{
15
-		if( !get_post( $command->id )) {
15
+		if (!get_post($command->id)) {
16 16
 			return false;
17 17
 		}
18
-		if( is_null( $command->pinned )) {
19
-			$meta = get_post_meta( $command->id, 'pinned', true );
20
-			$command->pinned = !wp_validate_boolean( $meta );
18
+		if (is_null($command->pinned)) {
19
+			$meta = get_post_meta($command->id, 'pinned', true);
20
+			$command->pinned = !wp_validate_boolean($meta);
21 21
 		}
22 22
 		else {
23 23
 			$notice = $command->pinned
24
-				? __( 'The review is pinned.', 'site-reviews' )
25
-				: __( 'The review is unpinned.', 'site-reviews' );
26
-			glsr( Notice::class )->addSuccess( $notice );
24
+				? __('The review is pinned.', 'site-reviews')
25
+				: __('The review is unpinned.', 'site-reviews');
26
+			glsr(Notice::class)->addSuccess($notice);
27 27
 		}
28
-		update_post_meta( $command->id, 'pinned', $command->pinned );
28
+		update_post_meta($command->id, 'pinned', $command->pinned);
29 29
 		return $command->pinned;
30 30
 	}
31 31
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,8 +18,7 @@
 block discarded – undo
18 18
 		if( is_null( $command->pinned )) {
19 19
 			$meta = get_post_meta( $command->id, 'pinned', true );
20 20
 			$command->pinned = !wp_validate_boolean( $meta );
21
-		}
22
-		else {
21
+		} else {
23 22
 			$notice = $command->pinned
24 23
 				? __( 'The review is pinned.', 'site-reviews' )
25 24
 				: __( 'The review is unpinned.', 'site-reviews' );
Please login to merge, or discard this patch.