Passed
Push — master ( 9b46a7...ed8579 )
by Paul
03:56
created
helpers.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  */
7 7
 function glsr( $alias = null ) {
8 8
 	$app = \GeminiLabs\SiteReviews\Application::load();
9
-	return !empty( $alias )
9
+	return !empty($alias)
10 10
 		? $app->make( $alias )
11 11
 		: $app;
12 12
 }
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
  * @return false|\GeminiLabs\SiteReviews\Review
16 16
  */
17 17
 function glsr_create_review( array $reviewValues = [] ) {
18
-	if( empty( $reviewValues )) {
18
+	if( empty($reviewValues) ) {
19 19
 		return false;
20 20
 	}
21 21
 	$review = new \GeminiLabs\SiteReviews\Commands\CreateReview( $reviewValues );
@@ -26,10 +26,10 @@  discard block
 block discarded – undo
26 26
  * @return \WP_Screen|object
27 27
  */
28 28
 function glsr_current_screen() {
29
-	if( function_exists( 'get_current_screen' )) {
29
+	if( function_exists( 'get_current_screen' ) ) {
30 30
 		$screen = get_current_screen();
31 31
 	}
32
-	return empty( $screen )
32
+	return empty($screen)
33 33
 		? (object)array_fill_keys( ['base', 'id', 'post_type'], null )
34 34
 		: $screen;
35 35
 }
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
  */
93 93
 function glsr_log() {
94 94
 	$args = func_get_args();
95
-	$context = isset( $args[1] )
95
+	$context = isset($args[1])
96 96
 		? $args[1]
97 97
 		: [];
98 98
 	$console = glsr( 'Modules\Console' );
99
-	return !empty( $args )
99
+	return !empty($args)
100 100
 		? $console->log( 'debug', $args[0], $context )
101 101
 		: $console;
102 102
 }
Please login to merge, or discard this patch.
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -4,7 +4,8 @@  discard block
 block discarded – undo
4 4
 /**
5 5
  * @return mixed
6 6
  */
7
-function glsr( $alias = null ) {
7
+function glsr( $alias = null )
8
+{
8 9
 	$app = \GeminiLabs\SiteReviews\Application::load();
9 10
 	return !empty( $alias )
10 11
 		? $app->make( $alias )
@@ -14,7 +15,8 @@  discard block
 block discarded – undo
14 15
 /**
15 16
  * @return false|\GeminiLabs\SiteReviews\Review
16 17
  */
17
-function glsr_create_review( array $reviewValues = [] ) {
18
+function glsr_create_review( array $reviewValues = [] )
19
+{
18 20
 	if( empty( $reviewValues )) {
19 21
 		return false;
20 22
 	}
@@ -25,7 +27,8 @@  discard block
 block discarded – undo
25 27
 /**
26 28
  * @return \WP_Screen|object
27 29
  */
28
-function glsr_current_screen() {
30
+function glsr_current_screen()
31
+{
29 32
 	if( function_exists( 'get_current_screen' )) {
30 33
 		$screen = get_current_screen();
31 34
 	}
@@ -38,7 +41,8 @@  discard block
 block discarded – undo
38 41
  * @param mixed ...$vars
39 42
  * @return void
40 43
  */
41
-function glsr_debug( ...$vars ) {
44
+function glsr_debug( ...$vars )
45
+{
42 46
 	if( count( $vars ) == 1 ) {
43 47
 		$value = htmlspecialchars( print_r( $vars[0], true ), ENT_QUOTES, 'UTF-8' );
44 48
 		printf( '<div class="glsr-debug"><pre>%s</pre></div>', $value );
@@ -57,14 +61,16 @@  discard block
 block discarded – undo
57 61
  * @param mixed $fallback
58 62
  * @return string|array
59 63
  */
60
-function glsr_get_option( $path = '', $fallback = '' ) {
64
+function glsr_get_option( $path = '', $fallback = '' )
65
+{
61 66
 	return glsr( 'Database\OptionManager' )->get( 'settings.'.$path, $fallback );
62 67
 }
63 68
 
64 69
 /**
65 70
  * @return array
66 71
  */
67
-function glsr_get_options() {
72
+function glsr_get_options()
73
+{
68 74
 	return glsr( 'Database\OptionManager' )->get( 'settings' );
69 75
 }
70 76
 
@@ -72,7 +78,8 @@  discard block
 block discarded – undo
72 78
  * @param int $post_id
73 79
  * @return void|\GeminiLabs\SiteReviews\Review
74 80
  */
75
-function glsr_get_review( $post_id ) {
81
+function glsr_get_review( $post_id )
82
+{
76 83
 	$post = get_post( $post_id );
77 84
 	if( $post instanceof WP_Post ) {
78 85
 		return glsr( 'Database\ReviewManager' )->single( $post );
@@ -83,14 +90,16 @@  discard block
 block discarded – undo
83 90
  * @return array
84 91
  * @todo document change of $reviews->reviews to $reviews->results
85 92
  */
86
-function glsr_get_reviews( array $args = array() ) {
93
+function glsr_get_reviews( array $args = array() )
94
+{
87 95
 	return glsr( 'Database\ReviewManager' )->get( $args );
88 96
 }
89 97
 
90 98
 /**
91 99
  * @return \GeminiLabs\SiteReviews\Modules\Console
92 100
  */
93
-function glsr_log() {
101
+function glsr_log()
102
+{
94 103
 	$args = func_get_args();
95 104
 	$context = isset( $args[1] )
96 105
 		? $args[1]
Please login to merge, or discard this patch.
plugin/Actions.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -51,55 +51,55 @@
 block discarded – undo
51 51
 	 */
52 52
 	public function run()
53 53
 	{
54
-		add_action( 'admin_enqueue_scripts',                        [$this->admin, 'enqueueAssets'] );
55
-		add_action( 'admin_init',                                   [$this->admin, 'registerTinymcePopups'] );
56
-		add_action( 'edit_form_after_title',                        [$this->admin, 'renderReviewEditor'] );
57
-		add_action( 'edit_form_top',                                [$this->admin, 'renderReviewNotice'] );
58
-		add_action( 'media_buttons',                                [$this->admin, 'renderTinymceButton'], 11 );
59
-		add_action( 'plugins_loaded',                               [$this->app, 'getDefaults'], 11 );
60
-		add_action( 'plugins_loaded',                               [$this->app, 'registerAddons'] );
61
-		add_action( 'plugins_loaded',                               [$this->app, 'registerLanguages'] );
62
-		add_action( 'plugins_loaded',                               [$this->app, 'registerReviewTypes'] );
63
-		add_action( 'upgrader_process_complete',                    [$this->app, 'upgraded'], 10, 2 );
64
-		add_action( 'admin_enqueue_scripts',                        [$this->editor, 'customizePostStatusLabels'] );
65
-		add_action( 'add_meta_boxes',                               [$this->editor, 'registerMetaBoxes'] );
66
-		add_action( 'admin_print_scripts',                          [$this->editor, 'removeAutosave'], 999 );
67
-		add_action( 'admin_menu',                                   [$this->editor, 'removeMetaBoxes'] );
68
-		add_action( 'post_submitbox_misc_actions',                  [$this->editor, 'renderPinnedInPublishMetaBox'] );
69
-		add_action( 'admin_action_revert',                          [$this->editor, 'revertReview'] );
70
-		add_action( 'save_post_'.Application::POST_TYPE,            [$this->editor, 'saveMetaboxes'] );
71
-		add_action( 'admin_action_approve',                         [$this->listtable, 'approve'] );
72
-		add_action( 'bulk_edit_custom_box',                         [$this->listtable, 'renderBulkEditFields'], 10, 2 );
73
-		add_action( 'restrict_manage_posts',                        [$this->listtable, 'renderColumnFilters'] );
74
-		add_action( 'manage_posts_custom_column',                   [$this->listtable, 'renderColumnValues'], 10, 2 );
75
-		add_action( 'save_post_'.Application::POST_TYPE,            [$this->listtable, 'saveBulkEditFields'] );
76
-		add_action( 'pre_get_posts',                                [$this->listtable, 'setQueryForColumn'] );
77
-		add_action( 'admin_action_unapprove',                       [$this->listtable, 'unapprove'] );
78
-		add_action( 'init',                                         [$this->main, 'registerPostType'], 8 );
79
-		add_action( 'init',                                         [$this->main, 'registerShortcodes'] );
80
-		add_action( 'init',                                         [$this->main, 'registerTaxonomy'] );
81
-		add_action( 'widgets_init',                                 [$this->main, 'registerWidgets'] );
82
-		add_action( 'admin_menu',                                   [$this->menu, 'registerMenuCount'] );
83
-		add_action( 'admin_menu',                                   [$this->menu, 'registerSubMenus'] );
84
-		add_action( 'admin_init',                                   [$this->menu, 'setCustomPermissions'], 999 );
85
-		add_action( 'wp_enqueue_scripts',                           [$this->public, 'enqueueAssets'], 999 );
86
-		add_filter( 'site-reviews/builder',                         [$this->public, 'modifyBuilder'] );
87
-		add_action( 'wp_footer',                                    [$this->public, 'renderSchema'] );
88
-		add_action( 'set_object_terms',                             [$this->review, 'onAfterChangeCategory'], 10, 6 );
89
-		add_action( 'site-reviews/create/review',                   [$this->review, 'onAfterCreate'], 10, 3 );
90
-		add_action( 'before_delete_post',                           [$this->review, 'onBeforeDelete'] );
91
-		add_action( 'update_postmeta',                              [$this->review, 'onBeforeUpdate'], 10, 4 );
92
-		add_action( 'transition_post_status',                       [$this->review, 'onChangeStatus'], 10, 3 );
93
-		add_action( 'admin_init',                                   [$this->router, 'routeAdminPostRequest'] );
94
-		add_action( 'wp_ajax_'.Application::PREFIX.'action',        [$this->router, 'routeAjaxRequest'] );
54
+		add_action( 'admin_enqueue_scripts', [$this->admin, 'enqueueAssets'] );
55
+		add_action( 'admin_init', [$this->admin, 'registerTinymcePopups'] );
56
+		add_action( 'edit_form_after_title', [$this->admin, 'renderReviewEditor'] );
57
+		add_action( 'edit_form_top', [$this->admin, 'renderReviewNotice'] );
58
+		add_action( 'media_buttons', [$this->admin, 'renderTinymceButton'], 11 );
59
+		add_action( 'plugins_loaded', [$this->app, 'getDefaults'], 11 );
60
+		add_action( 'plugins_loaded', [$this->app, 'registerAddons'] );
61
+		add_action( 'plugins_loaded', [$this->app, 'registerLanguages'] );
62
+		add_action( 'plugins_loaded', [$this->app, 'registerReviewTypes'] );
63
+		add_action( 'upgrader_process_complete', [$this->app, 'upgraded'], 10, 2 );
64
+		add_action( 'admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels'] );
65
+		add_action( 'add_meta_boxes', [$this->editor, 'registerMetaBoxes'] );
66
+		add_action( 'admin_print_scripts', [$this->editor, 'removeAutosave'], 999 );
67
+		add_action( 'admin_menu', [$this->editor, 'removeMetaBoxes'] );
68
+		add_action( 'post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox'] );
69
+		add_action( 'admin_action_revert', [$this->editor, 'revertReview'] );
70
+		add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'] );
71
+		add_action( 'admin_action_approve', [$this->listtable, 'approve'] );
72
+		add_action( 'bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2 );
73
+		add_action( 'restrict_manage_posts', [$this->listtable, 'renderColumnFilters'] );
74
+		add_action( 'manage_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2 );
75
+		add_action( 'save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields'] );
76
+		add_action( 'pre_get_posts', [$this->listtable, 'setQueryForColumn'] );
77
+		add_action( 'admin_action_unapprove', [$this->listtable, 'unapprove'] );
78
+		add_action( 'init', [$this->main, 'registerPostType'], 8 );
79
+		add_action( 'init', [$this->main, 'registerShortcodes'] );
80
+		add_action( 'init', [$this->main, 'registerTaxonomy'] );
81
+		add_action( 'widgets_init', [$this->main, 'registerWidgets'] );
82
+		add_action( 'admin_menu', [$this->menu, 'registerMenuCount'] );
83
+		add_action( 'admin_menu', [$this->menu, 'registerSubMenus'] );
84
+		add_action( 'admin_init', [$this->menu, 'setCustomPermissions'], 999 );
85
+		add_action( 'wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999 );
86
+		add_filter( 'site-reviews/builder', [$this->public, 'modifyBuilder'] );
87
+		add_action( 'wp_footer', [$this->public, 'renderSchema'] );
88
+		add_action( 'set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6 );
89
+		add_action( 'site-reviews/create/review', [$this->review, 'onAfterCreate'], 10, 3 );
90
+		add_action( 'before_delete_post', [$this->review, 'onBeforeDelete'] );
91
+		add_action( 'update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4 );
92
+		add_action( 'transition_post_status', [$this->review, 'onChangeStatus'], 10, 3 );
93
+		add_action( 'admin_init', [$this->router, 'routeAdminPostRequest'] );
94
+		add_action( 'wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] );
95 95
 		add_action( 'wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] );
96
-		add_action( 'init',                                         [$this->router, 'routePublicPostRequest'] );
97
-		add_action( 'site-reviews/schedule/session/purge',          [$this->session, 'deleteExpiredSessions'] );
98
-		add_action( 'admin_init',                                   [$this->settings, 'registerSettings'] );
99
-		add_action( Application::TAXONOMY.'_term_edit_form_top',    [$this->taxonomy, 'disableParents'] );
100
-		add_action( Application::TAXONOMY.'_term_new_form_tag',     [$this->taxonomy, 'disableParents'] );
101
-		add_action( Application::TAXONOMY.'_add_form_fields',       [$this->taxonomy, 'enableParents'] );
102
-		add_action( Application::TAXONOMY.'_edit_form',             [$this->taxonomy, 'enableParents'] );
103
-		add_action( 'restrict_manage_posts',                        [$this->taxonomy, 'renderTaxonomyFilter'], 9 );
96
+		add_action( 'init', [$this->router, 'routePublicPostRequest'] );
97
+		add_action( 'site-reviews/schedule/session/purge', [$this->session, 'deleteExpiredSessions'] );
98
+		add_action( 'admin_init', [$this->settings, 'registerSettings'] );
99
+		add_action( Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents'] );
100
+		add_action( Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents'] );
101
+		add_action( Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents'] );
102
+		add_action( Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents'] );
103
+		add_action( 'restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9 );
104 104
 	}
105 105
 }
Please login to merge, or discard this patch.
plugin/Controllers/AdminController.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 */
26 26
 	public function enqueueAssets()
27 27
 	{
28
-		$command = new EnqueueAdminAssets([
28
+		$command = new EnqueueAdminAssets( [
29 29
 			'pointers' => [[
30 30
 				'content' => __( 'You can pin exceptional reviews so that they are always shown first.', 'site-reviews' ),
31 31
 				'id' => 'glsr-pointer-pinned',
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 				'target' => '#misc-pub-pinned',
38 38
 				'title' => __( 'Pin Your Reviews', 'site-reviews' ),
39 39
 			]],
40
-		]);
40
+		] );
41 41
 		$this->execute( $command );
42 42
 	}
43 43
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	{
50 50
 		$links['settings'] = glsr( Builder::class )->a( __( 'Settings', 'site-reviews' ), [
51 51
 			'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=settings' ),
52
-		]);
52
+		] );
53 53
 		return $links;
54 54
 	}
55 55
 
@@ -60,19 +60,19 @@  discard block
 block discarded – undo
60 60
 	public function filterDashboardGlanceItems( array $items )
61 61
 	{
62 62
 		$postCount = wp_count_posts( Application::POST_TYPE );
63
-		if( empty( $postCount->publish )) {
63
+		if( empty($postCount->publish) ) {
64 64
 			return $items;
65 65
 		}
66 66
 		$text = _n( '%s Review', '%s Reviews', $postCount->publish, 'site-reviews' );
67
-		$text = sprintf( $text, number_format_i18n( $postCount->publish ));
67
+		$text = sprintf( $text, number_format_i18n( $postCount->publish ) );
68 68
 		$items[] = current_user_can( get_post_type_object( Application::POST_TYPE )->cap->edit_posts )
69 69
 			? glsr( Builder::class )->a( $text, [
70 70
 				'class' => 'glsr-review-count',
71 71
 				'href' => 'edit.php?post_type='.Application::POST_TYPE,
72
-			])
72
+			] )
73 73
 			: glsr( Builder::class )->span( $text, [
74 74
 				'class' => 'glsr-review-count',
75
-			]);
75
+			] );
76 76
 		return $items;
77 77
 	}
78 78
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	 */
83 83
 	public function filterTinymcePlugins( array $plugins )
84 84
 	{
85
-		if( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' )) {
85
+		if( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) {
86 86
 			$plugins['glsr_shortcode'] = glsr()->url( 'assets/scripts/mce-plugin.js' );
87 87
 		}
88 88
 		return $plugins;
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
 	 */
95 95
 	public function registerTinymcePopups()
96 96
 	{
97
-		$command = new RegisterTinymcePopups([
97
+		$command = new RegisterTinymcePopups( [
98 98
 			'site_reviews' => esc_html__( 'Recent Reviews', 'site-reviews' ),
99 99
 			'site_reviews_form' => esc_html__( 'Submit a Review', 'site-reviews' ),
100 100
 			'site_reviews_summary' => esc_html__( 'Summary of Reviews', 'site-reviews' ),
101
-		]);
101
+		] );
102 102
 		$this->execute( $command );
103 103
 	}
104 104
 
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
 	 */
109 109
 	public function renderReviewEditor( WP_Post $post )
110 110
 	{
111
-		if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return;
111
+		if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return;
112 112
 		glsr()->render( 'partials/editor/review', [
113 113
 			'post' => $post,
114
-		]);
114
+		] );
115 115
 	}
116 116
 
117 117
 	/**
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
 	 */
121 121
 	public function renderReviewNotice( WP_Post $post )
122 122
 	{
123
-		if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return;
124
-		glsr( Notice::class )->addWarning( __( 'This review is read-only.', 'site-reviews' ));
123
+		if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return;
124
+		glsr( Notice::class )->addWarning( __( 'This review is read-only.', 'site-reviews' ) );
125 125
 		glsr( Template::class )->render( 'partials/editor/notice', [
126 126
 			'context' => [
127 127
 				'notices' => glsr( Notice::class )->get(),
128 128
 			],
129
-		]);
129
+		] );
130 130
 	}
131 131
 
132 132
 	/**
@@ -140,10 +140,10 @@  discard block
 block discarded – undo
140 140
 		foreach( glsr()->mceShortcodes as $shortcode => $values ) {
141 141
 			$shortcodes[$shortcode] = $values;
142 142
 		}
143
-		if( empty( $shortcodes ))return;
143
+		if( empty($shortcodes) )return;
144 144
 		glsr()->render( 'partials/editor/tinymce', [
145 145
 			'shortcodes' => $shortcodes,
146
-		]);
146
+		] );
147 147
 	}
148 148
 
149 149
 	/**
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	public function routerClearConsole()
153 153
 	{
154 154
 		glsr( Console::class )->clear();
155
-		glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ));
155
+		glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ) );
156 156
 	}
157 157
 
158 158
 	/**
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	public function routerFetchConsole()
162 162
 	{
163
-		glsr( Notice::class )->addSuccess( __( 'Console reloaded.', 'site-reviews' ));
163
+		glsr( Notice::class )->addSuccess( __( 'Console reloaded.', 'site-reviews' ) );
164 164
 	}
165 165
 
166 166
 	/**
@@ -170,20 +170,20 @@  discard block
 block discarded – undo
170 170
 	public function routerCountReviews( $showNotice = true )
171 171
 	{
172 172
 		$countManager = glsr( CountsManager::class );
173
-		$terms = get_terms([
173
+		$terms = get_terms( [
174 174
 			'hide_empty' => true,
175 175
 			'taxonomy' => Application::TAXONOMY,
176
-		]);
176
+		] );
177 177
 		foreach( $terms as $term ) {
178
-			$countManager->setTermCounts( $term->term_id, $countManager->buildTermCounts( $term->term_id ));
178
+			$countManager->setTermCounts( $term->term_id, $countManager->buildTermCounts( $term->term_id ) );
179 179
 		}
180 180
 		$postIds = glsr( SqlQueries::class )->getReviewsMeta( 'assigned_to' );
181 181
 		foreach( $postIds as $postId ) {
182
-			$countManager->setPostCounts( $postId, $countManager->buildPostCounts( $postId ));
182
+			$countManager->setPostCounts( $postId, $countManager->buildPostCounts( $postId ) );
183 183
 		}
184 184
 		$countManager->setCounts( $countManager->buildCounts() );
185 185
 		if( $showNotice ) {
186
-			glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' ));
186
+			glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' ) );
187 187
 		}
188 188
 	}
189 189
 
@@ -218,17 +218,17 @@  discard block
 block discarded – undo
218 218
 	{
219 219
 		$file = $_FILES['import-file'];
220 220
 		if( $file['error'] !== UPLOAD_ERR_OK ) {
221
-			return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ));
221
+			return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ) );
222 222
 		}
223
-		if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] )) {
224
-			return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ));
223
+		if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] ) ) {
224
+			return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ) );
225 225
 		}
226 226
 		$settings = json_decode( file_get_contents( $file['tmp_name'] ), true );
227
-		if( empty( $settings )) {
228
-			return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ));
227
+		if( empty($settings) ) {
228
+			return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ) );
229 229
 		}
230
-		glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ));
231
-		glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ));
230
+		glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ) );
231
+		glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ) );
232 232
 	}
233 233
 
234 234
 	/**
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 			UPLOAD_ERR_CANT_WRITE => __( 'Failed to write file to disk.', 'site-reviews' ),
247 247
 			UPLOAD_ERR_EXTENSION => __( 'A PHP extension stopped the file upload.', 'site-reviews' ),
248 248
 		];
249
-		return !isset( $errors[$errorCode] )
249
+		return !isset($errors[$errorCode])
250 250
 			? __( 'Unknown upload error.', 'site-reviews' )
251 251
 			: $errors[$errorCode];
252 252
 	}
Please login to merge, or discard this patch.
plugin/Shortcodes/SiteReviewsPopup.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -13,15 +13,15 @@  discard block
 block discarded – undo
13 13
 	public function fields()
14 14
 	{
15 15
 		return [[
16
-			'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' )),
16
+			'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' ) ),
17 17
 			'minWidth' => 320,
18 18
 			'type' => 'container',
19
-		],[
19
+		], [
20 20
 			'label' => esc_html__( 'Title', 'site-reviews' ),
21 21
 			'name' => 'title',
22 22
 			'tooltip' => __( 'Enter a custom shortcode heading.', 'site-reviews' ),
23 23
 			'type' => 'textbox',
24
-		],[
24
+		], [
25 25
 			'label' => esc_html__( 'Count', 'site-reviews' ),
26 26
 			'maxLength' => 5,
27 27
 			'name' => 'count',
@@ -29,20 +29,20 @@  discard block
 block discarded – undo
29 29
 			'text' => '10',
30 30
 			'tooltip' => __( 'How many reviews would you like to display (default: 10)?', 'site-reviews' ),
31 31
 			'type' => 'textbox',
32
-		],[
32
+		], [
33 33
 			'label' => esc_html__( 'Rating', 'site-reviews' ),
34 34
 			'name' => 'rating',
35 35
 			'options' => [
36
-				'5' => esc_html( sprintf( _n( '%s star', '%s stars', 5, 'site-reviews' ), 5 )),
37
-				'4' => esc_html( sprintf( _n( '%s star', '%s stars', 4, 'site-reviews' ), 4 )),
38
-				'3' => esc_html( sprintf( _n( '%s star', '%s stars', 3, 'site-reviews' ), 3 )),
39
-				'2' => esc_html( sprintf( _n( '%s star', '%s stars', 2, 'site-reviews' ), 2 )),
40
-				'1' => esc_html( sprintf( _n( '%s star', '%s stars', 1, 'site-reviews' ), 1 )),
41
-				'0' => esc_html( __( 'Unrated', 'site-reviews' )),
36
+				'5' => esc_html( sprintf( _n( '%s star', '%s stars', 5, 'site-reviews' ), 5 ) ),
37
+				'4' => esc_html( sprintf( _n( '%s star', '%s stars', 4, 'site-reviews' ), 4 ) ),
38
+				'3' => esc_html( sprintf( _n( '%s star', '%s stars', 3, 'site-reviews' ), 3 ) ),
39
+				'2' => esc_html( sprintf( _n( '%s star', '%s stars', 2, 'site-reviews' ), 2 ) ),
40
+				'1' => esc_html( sprintf( _n( '%s star', '%s stars', 1, 'site-reviews' ), 1 ) ),
41
+				'0' => esc_html( __( 'Unrated', 'site-reviews' ) ),
42 42
 			],
43 43
 			'tooltip' => __( 'What is the minimum rating to display (default: 1 star)?', 'site-reviews' ),
44 44
 			'type' => 'listbox',
45
-		],[
45
+		], [
46 46
 			'label' => esc_html__( 'Pagination', 'site-reviews' ),
47 47
 			'name' => 'pagination',
48 48
 			'options' => [
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 			'name' => 'assigned_to',
61 61
 			'tooltip' => __( 'Limit reviews to those assigned to this post ID (separate multiple IDs with a comma). You can also enter "post_id" to use the ID of the current page.', 'site-reviews' ),
62 62
 			'type' => 'textbox',
63
-		],[
63
+		], [
64 64
 			'label' => esc_html__( 'Schema', 'site-reviews' ),
65 65
 			'name' => 'schema',
66 66
 			'options' => [
@@ -69,49 +69,49 @@  discard block
 block discarded – undo
69 69
 			],
70 70
 			'tooltip' => __( 'Rich snippets are disabled by default.', 'site-reviews' ),
71 71
 			'type' => 'listbox',
72
-		],[
72
+		], [
73 73
 			'label' => esc_html__( 'Classes', 'site-reviews' ),
74 74
 			'name' => 'class',
75 75
 			'tooltip' => __( 'Add custom CSS classes to the shortcode.', 'site-reviews' ),
76 76
 			'type' => 'textbox',
77
-		],[
77
+		], [
78 78
 			'columns' => 2,
79 79
 			'items' => [[
80 80
 				'name' => 'hide_assigned_to',
81 81
 				'text' => esc_html__( 'Assigned To', 'site-reviews' ),
82 82
 				'tooltip' => __( 'Hide the assigned to link?', 'site-reviews' ),
83 83
 				'type' => 'checkbox',
84
-			],[
84
+			], [
85 85
 				'name' => 'hide_author',
86 86
 				'text' => esc_html__( 'Author', 'site-reviews' ),
87 87
 				'tooltip' => __( 'Hide the review author?', 'site-reviews' ),
88 88
 				'type' => 'checkbox',
89
-			],[
89
+			], [
90 90
 				'name' => 'hide_avatar',
91 91
 				'text' => esc_html__( 'Avatar', 'site-reviews' ),
92 92
 				'tooltip' => __( 'Hide the reviewer avatar if shown?', 'site-reviews' ),
93 93
 				'type' => 'checkbox',
94
-			],[
94
+			], [
95 95
 				'name' => 'hide_content',
96 96
 				'text' => esc_html__( 'Content', 'site-reviews' ),
97 97
 				'tooltip' => __( 'Hide the review content?', 'site-reviews' ),
98 98
 				'type' => 'checkbox',
99
-			],[
99
+			], [
100 100
 				'name' => 'hide_date',
101 101
 				'text' => esc_html__( 'Date', 'site-reviews' ),
102 102
 				'tooltip' => __( 'Hide the review date?', 'site-reviews' ),
103 103
 				'type' => 'checkbox',
104
-			],[
104
+			], [
105 105
 				'name' => 'hide_rating',
106 106
 				'text' => esc_html__( 'Rating', 'site-reviews' ),
107 107
 				'tooltip' => __( 'Hide the review rating?', 'site-reviews' ),
108 108
 				'type' => 'checkbox',
109
-			],[
109
+			], [
110 110
 				'name' => 'hide_response',
111 111
 				'text' => esc_html__( 'Response', 'site-reviews' ),
112 112
 				'tooltip' => __( 'Hide the review response?', 'site-reviews' ),
113 113
 				'type' => 'checkbox',
114
-			],[
114
+			], [
115 115
 				'name' => 'hide_title',
116 116
 				'text' => esc_html__( 'Title', 'site-reviews' ),
117 117
 				'tooltip' => __( 'Hide the review title?', 'site-reviews' ),
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 			'label' => esc_html__( 'Hide', 'site-reviews' ),
122 122
 			'spacing' => 5,
123 123
 			'type' => 'container',
124
-		],[
124
+		], [
125 125
 			'hidden' => true,
126 126
 			'name' => 'id',
127 127
 			'type' => 'textbox',
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	public function getTerms()
135 135
 	{
136 136
 		$terms = glsr( Database::class )->getTerms();
137
-		if( empty( $terms )) {
137
+		if( empty($terms) ) {
138 138
 			return [];
139 139
 		}
140 140
 		return [
Please login to merge, or discard this patch.
plugin/Shortcodes/SiteReviewsFormPopup.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -15,12 +15,12 @@  discard block
 block discarded – undo
15 15
 		return [[
16 16
 			'type' => 'container',
17 17
 			'html' => '<p class="strong">'.esc_html__( 'All settings are optional.', 'site-reviews' ).'</p>',
18
-		],[
18
+		], [
19 19
 			'label' => esc_html__( 'Title', 'site-reviews' ),
20 20
 			'name' => 'title',
21 21
 			'tooltip' => __( 'Enter a custom shortcode heading.', 'site-reviews' ),
22 22
 			'type' => 'textbox',
23
-		],[
23
+		], [
24 24
 			'label' => esc_html__( 'Description', 'site-reviews' ),
25 25
 			'minHeight' => 60,
26 26
 			'minWidth' => 240,
@@ -35,39 +35,39 @@  discard block
 block discarded – undo
35 35
 			'name' => 'assign_to',
36 36
 			'tooltip' => __( 'Assign submitted reviews to a custom page/post ID. You can also enter "post_id" to assign reviews to the ID of the current page.', 'site-reviews' ),
37 37
 			'type' => 'textbox',
38
-		],[
38
+		], [
39 39
 			'label' => esc_html__( 'Classes', 'site-reviews' ),
40 40
 			'name' => 'class',
41 41
 			'tooltip' => __( 'Add custom CSS classes to the shortcode.', 'site-reviews' ),
42 42
 			'type' => 'textbox',
43
-		],[
43
+		], [
44 44
 			'columns' => 2,
45 45
 			'items' => [[
46 46
 				'name' => 'hide_content',
47 47
 				'text' => esc_html__( 'Content', 'site-reviews' ),
48 48
 				'tooltip' => __( 'Hide the content field?', 'site-reviews' ),
49 49
 				'type' => 'checkbox',
50
-			],[
50
+			], [
51 51
 				'name' => 'hide_email',
52 52
 				'text' => esc_html__( 'Email', 'site-reviews' ),
53 53
 				'tooltip' => __( 'Hide the email field?', 'site-reviews' ),
54 54
 				'type' => 'checkbox',
55
-			],[
55
+			], [
56 56
 				'name' => 'hide_name',
57 57
 				'text' => esc_html__( 'Name', 'site-reviews' ),
58 58
 				'tooltip' => __( 'Hide the name field?', 'site-reviews' ),
59 59
 				'type' => 'checkbox',
60
-			],[
60
+			], [
61 61
 				'name' => 'hide_rating',
62 62
 				'text' => esc_html__( 'Rating', 'site-reviews' ),
63 63
 				'tooltip' => __( 'Hide the rating field?', 'site-reviews' ),
64 64
 				'type' => 'checkbox',
65
-			],[
65
+			], [
66 66
 				'name' => 'hide_terms',
67 67
 				'text' => esc_html__( 'Terms', 'site-reviews' ),
68 68
 				'tooltip' => __( 'Hide the terms field?', 'site-reviews' ),
69 69
 				'type' => 'checkbox',
70
-			],[
70
+			], [
71 71
 				'name' => 'hide_title',
72 72
 				'text' => esc_html__( 'Title', 'site-reviews' ),
73 73
 				'tooltip' => __( 'Hide the title field?', 'site-reviews' ),
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 			'layout' => 'grid',
78 78
 			'spacing' => 5,
79 79
 			'type' => 'container',
80
-		],[
80
+		], [
81 81
 			'hidden' => true,
82 82
 			'name' => 'id',
83 83
 			'type' => 'textbox',
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	public function getTerms()
91 91
 	{
92 92
 		$terms = glsr( Database::class )->getTerms();
93
-		if( empty( $terms )) {
93
+		if( empty($terms) ) {
94 94
 			return [];
95 95
 		}
96 96
 		return [
Please login to merge, or discard this patch.
plugin/Shortcodes/SiteReviewsSummaryPopup.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 	public function fields()
13 13
 	{
14 14
 		return [[
15
-			'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' )),
15
+			'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' ) ),
16 16
 			'minWidth' => 320,
17 17
 			'type' => 'container',
18
-		],[
18
+		], [
19 19
 			'label' => esc_html__( 'Title', 'site-reviews' ),
20 20
 			'name' => 'title',
21 21
 			'tooltip' => __( 'Enter a custom shortcode heading.', 'site-reviews' ),
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 			'name' => 'assigned_to',
29 29
 			'tooltip' => __( 'Limit reviews to those assigned to this post ID (separate multiple IDs with a comma). You can also enter "post_id" to use the ID of the current page.', 'site-reviews' ),
30 30
 			'type' => 'textbox',
31
-		],[
31
+		], [
32 32
 			'label' => esc_html__( 'Schema', 'site-reviews' ),
33 33
 			'name' => 'schema',
34 34
 			'options' => [
@@ -37,34 +37,34 @@  discard block
 block discarded – undo
37 37
 			],
38 38
 			'tooltip' => __( 'Rich snippets are disabled by default.', 'site-reviews' ),
39 39
 			'type' => 'listbox',
40
-		],[
40
+		], [
41 41
 			'label' => esc_html__( 'Classes', 'site-reviews' ),
42 42
 			'name' => 'class',
43 43
 			'tooltip' => __( 'Add custom CSS classes to the shortcode.', 'site-reviews' ),
44 44
 			'type' => 'textbox',
45
-		],[
45
+		], [
46 46
 			'columns' => 2,
47 47
 			'items' => [[
48 48
 				'type' => 'checkbox',
49 49
 				'name' => 'hide_bars',
50 50
 				'text' => esc_html__( 'Bars', 'site-reviews' ),
51 51
 				'tooltip' => __( 'Hide the percentage bars?', 'site-reviews' ),
52
-			],[
52
+			], [
53 53
 				'type' => 'checkbox',
54 54
 				'name' => 'hide_if_empty',
55 55
 				'text' => esc_html__( 'If Empty', 'site-reviews' ),
56 56
 				'tooltip' => __( 'Hide the summary if no reviews are found?', 'site-reviews' ),
57
-			],[
57
+			], [
58 58
 				'type' => 'checkbox',
59 59
 				'name' => 'hide_rating',
60 60
 				'text' => esc_html__( 'Rating', 'site-reviews' ),
61 61
 				'tooltip' => __( 'Hide the rating?', 'site-reviews' ),
62
-			],[
62
+			], [
63 63
 				'type' => 'checkbox',
64 64
 				'name' => 'hide_stars',
65 65
 				'text' => esc_html__( 'Stars', 'site-reviews' ),
66 66
 				'tooltip' => __( 'Hide the stars?', 'site-reviews' ),
67
-			],[
67
+			], [
68 68
 				'type' => 'checkbox',
69 69
 				'name' => 'hide_summary',
70 70
 				'text' => esc_html__( 'Summary', 'site-reviews' ),
Please login to merge, or discard this patch.
plugin/Modules/Validator/ValidateReview.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		$this->validateBlacklist();
68 68
 		$this->validateAkismet();
69 69
 		$this->validateRecaptcha();
70
-		if( !empty( $this->error )) {
70
+		if( !empty($this->error) ) {
71 71
 			$this->setSessionValues( 'message', $this->error );
72 72
 		}
73 73
 		return $this;
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
 		if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) {
92 92
 			return static::RECAPTCHA_DISABLED;
93 93
 		}
94
-		if( empty( $this->request['recaptcha-token'] )) {
95
-			return $this->request['counter'] < intval( apply_filters( 'site-reviews/recaptcha/timeout', 5 ))
94
+		if( empty($this->request['recaptcha-token']) ) {
95
+			return $this->request['counter'] < intval( apply_filters( 'site-reviews/recaptcha/timeout', 5 ) )
96 96
 				? static::RECAPTCHA_EMPTY
97 97
 				: static::RECAPTCHA_FAILED;
98 98
 		}
@@ -104,17 +104,17 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
 	protected function getRecaptchaTokenStatus()
106 106
 	{
107
-		$endpoint = add_query_arg([
107
+		$endpoint = add_query_arg( [
108 108
 			'remoteip' => glsr( Helper::class )->getIpAddress(),
109 109
 			'response' => $this->request['recaptcha-token'],
110 110
 			'secret' => $this->getOption( 'settings.submissions.recaptcha.secret' ),
111 111
 		], static::RECAPTCHA_ENDPOINT );
112
-		if( is_wp_error( $response = wp_remote_get( $endpoint ))) {
112
+		if( is_wp_error( $response = wp_remote_get( $endpoint ) ) ) {
113 113
 			glsr_log()->error( $response->get_error_message() );
114 114
 			return static::RECAPTCHA_FAILED;
115 115
 		}
116
-		$response = json_decode( wp_remote_retrieve_body( $response ));
117
-		if( !empty( $response->success )) {
116
+		$response = json_decode( wp_remote_retrieve_body( $response ) );
117
+		if( !empty($response->success) ) {
118 118
 			return boolval( $response->success )
119 119
 				? static::RECAPTCHA_VALID
120 120
 				: static::RECAPTCHA_INVALID;
@@ -132,12 +132,12 @@  discard block
 block discarded – undo
132 132
 	{
133 133
 		$rules = array_intersect_key(
134 134
 			apply_filters( 'site-reviews/validation/rules', static::VALIDATION_RULES, $request ),
135
-			array_flip( $this->getOption( 'settings.submissions.required', [] ))
135
+			array_flip( $this->getOption( 'settings.submissions.required', [] ) )
136 136
 		);
137
-		$excluded = isset( $request['excluded'] )
137
+		$excluded = isset($request['excluded'])
138 138
 			? explode( ',', $request['excluded'] )
139 139
 			: [];
140
-		return array_diff_key( $rules, array_flip( $excluded ));
140
+		return array_diff_key( $rules, array_flip( $excluded ) );
141 141
 	}
142 142
 
143 143
 	/**
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	{
148 148
 		$rules = $this->getValidationRules( $request );
149 149
 		$errors = glsr( Validator::class )->validate( $request, $rules );
150
-		if( empty( $errors )) {
150
+		if( empty($errors) ) {
151 151
 			return true;
152 152
 		}
153 153
 		$this->setSessionValues( 'errors', $errors );
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	protected function setSessionValues( $type, $value, $loggedMessage = '' )
165 165
 	{
166 166
 		glsr( Session::class )->set( $this->form_id.$type, $value );
167
-		if( !empty( $loggedMessage )) {
167
+		if( !empty($loggedMessage) ) {
168 168
 			glsr_log()->warning( $loggedMessage );
169 169
 			glsr_log()->warning( $this->request );
170 170
 		}
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 	 */
176 176
 	protected function validateAkismet()
177 177
 	{
178
-		if( !empty( $this->error ))return;
179
-		if( !glsr( Akismet::class )->isSpam( $this->request ))return;
178
+		if( !empty($this->error) )return;
179
+		if( !glsr( Akismet::class )->isSpam( $this->request ) )return;
180 180
 		$this->setSessionValues( 'errors', [], 'Akismet caught a spam submission:' );
181 181
 		$this->error = __( 'Your review cannot be submitted at this time. Please try again later.', 'site-reviews' );
182 182
 	}
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
 	 */
187 187
 	protected function validateBlacklist()
188 188
 	{
189
-		if( !empty( $this->error ))return;
190
-		if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return;
189
+		if( !empty($this->error) )return;
190
+		if( !glsr( Blacklist::class )->isBlacklisted( $this->request ) )return;
191 191
 		$blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' );
192 192
 		if( $blacklistAction == 'reject' ) {
193 193
 			$this->setSessionValues( 'errors', [], 'Blacklisted submission detected:' );
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 	 */
203 203
 	protected function validateCustom()
204 204
 	{
205
-		if( !empty( $this->error ))return;
205
+		if( !empty($this->error) )return;
206 206
 		$validated = apply_filters( 'site-reviews/validate/custom', true, $this->request );
207 207
 		if( $validated === true )return;
208 208
 		$this->setSessionValues( 'errors', [] );
@@ -217,8 +217,8 @@  discard block
 block discarded – undo
217 217
 	 */
218 218
 	protected function validateHoneyPot()
219 219
 	{
220
-		if( !empty( $this->error ))return;
221
-		if( empty( $this->request['gotcha'] ))return;
220
+		if( !empty($this->error) )return;
221
+		if( empty($this->request['gotcha']) )return;
222 222
 		$this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' );
223 223
 		$this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' );
224 224
 	}
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
 	 */
229 229
 	protected function validateRecaptcha()
230 230
 	{
231
-		if( !empty( $this->error ))return;
231
+		if( !empty($this->error) )return;
232 232
 		$status = $this->getRecaptchaStatus();
233
-		if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ))return;
233
+		if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ) )return;
234 234
 		if( $status == static::RECAPTCHA_EMPTY ) {
235 235
 			$this->setSessionValues( 'recaptcha', 'unset' );
236 236
 			$this->recaptchaIsUnset = true;
@@ -250,11 +250,11 @@  discard block
 block discarded – undo
250 250
 	 */
251 251
 	protected function validateRequest( array $request )
252 252
 	{
253
-		if( !$this->isRequestValid( $request )) {
253
+		if( !$this->isRequestValid( $request ) ) {
254 254
 			$this->error = __( 'Please fix the submission errors.', 'site-reviews' );
255 255
 			return $request;
256 256
 		}
257
-		if( empty( $request['title'] )) {
257
+		if( empty($request['title']) ) {
258 258
 			$request['title'] = __( 'No Title', 'site-reviews' );
259 259
 		}
260 260
 		return array_merge( glsr( ValidateReviewDefaults::class )->defaults(), $request );
Please login to merge, or discard this patch.
Braces   +30 added lines, -10 removed lines patch added patch discarded remove patch
@@ -175,8 +175,12 @@  discard block
 block discarded – undo
175 175
 	 */
176 176
 	protected function validateAkismet()
177 177
 	{
178
-		if( !empty( $this->error ))return;
179
-		if( !glsr( Akismet::class )->isSpam( $this->request ))return;
178
+		if( !empty( $this->error )) {
179
+			return;
180
+		}
181
+		if( !glsr( Akismet::class )->isSpam( $this->request )) {
182
+			return;
183
+		}
180 184
 		$this->setSessionValues( 'errors', [], 'Akismet caught a spam submission:' );
181 185
 		$this->error = __( 'Your review cannot be submitted at this time. Please try again later.', 'site-reviews' );
182 186
 	}
@@ -186,8 +190,12 @@  discard block
 block discarded – undo
186 190
 	 */
187 191
 	protected function validateBlacklist()
188 192
 	{
189
-		if( !empty( $this->error ))return;
190
-		if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return;
193
+		if( !empty( $this->error )) {
194
+			return;
195
+		}
196
+		if( !glsr( Blacklist::class )->isBlacklisted( $this->request )) {
197
+			return;
198
+		}
191 199
 		$blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' );
192 200
 		if( $blacklistAction == 'reject' ) {
193 201
 			$this->setSessionValues( 'errors', [], 'Blacklisted submission detected:' );
@@ -202,9 +210,13 @@  discard block
 block discarded – undo
202 210
 	 */
203 211
 	protected function validateCustom()
204 212
 	{
205
-		if( !empty( $this->error ))return;
213
+		if( !empty( $this->error )) {
214
+			return;
215
+		}
206 216
 		$validated = apply_filters( 'site-reviews/validate/custom', true, $this->request );
207
-		if( $validated === true )return;
217
+		if( $validated === true ) {
218
+			return;
219
+		}
208 220
 		$this->setSessionValues( 'errors', [] );
209 221
 		$this->setSessionValues( 'values', $this->request );
210 222
 		$this->error = is_string( $validated )
@@ -217,8 +229,12 @@  discard block
 block discarded – undo
217 229
 	 */
218 230
 	protected function validateHoneyPot()
219 231
 	{
220
-		if( !empty( $this->error ))return;
221
-		if( empty( $this->request['gotcha'] ))return;
232
+		if( !empty( $this->error )) {
233
+			return;
234
+		}
235
+		if( empty( $this->request['gotcha'] )) {
236
+			return;
237
+		}
222 238
 		$this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' );
223 239
 		$this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' );
224 240
 	}
@@ -228,9 +244,13 @@  discard block
 block discarded – undo
228 244
 	 */
229 245
 	protected function validateRecaptcha()
230 246
 	{
231
-		if( !empty( $this->error ))return;
247
+		if( !empty( $this->error )) {
248
+			return;
249
+		}
232 250
 		$status = $this->getRecaptchaStatus();
233
-		if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ))return;
251
+		if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] )) {
252
+			return;
253
+		}
234 254
 		if( $status == static::RECAPTCHA_EMPTY ) {
235 255
 			$this->setSessionValues( 'recaptcha', 'unset' );
236 256
 			$this->recaptchaIsUnset = true;
Please login to merge, or discard this patch.
plugin/Modules/Html/Partials/SiteReviewsForm.php 2 patches
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 				'response' => $this->buildResponse(),
66 66
 				'submit_button' => $this->buildSubmitButton().$this->buildRecaptcha(),
67 67
 			],
68
-		]);
68
+		] );
69 69
 	}
70 70
 
71 71
 	/**
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 			'context' => [
78 78
 				'text' => trim( $this->getLoginText().' '.$this->getRegisterText() ),
79 79
 			],
80
-		]);
80
+		] );
81 81
 	}
82 82
 
83 83
 	/**
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
 	protected function buildRecaptcha()
87 87
 	{
88 88
 		if( !glsr( OptionManager::class )->isRecaptchaEnabled() )return;
89
-		return glsr( Builder::class )->div([
89
+		return glsr( Builder::class )->div( [
90 90
 			'class' => 'glsr-recaptcha-holder',
91 91
 			'data-badge' => glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.position' ),
92
-			'data-sitekey' => sanitize_text_field( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.key' )),
92
+			'data-sitekey' => sanitize_text_field( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.key' ) ),
93 93
 			'data-size' => 'invisible',
94
-		]);
94
+		] );
95 95
 	}
96 96
 
97 97
 	/**
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 */
100 100
 	protected function buildResponse()
101 101
 	{
102
-		$classes = !empty( $this->errors )
102
+		$classes = !empty($this->errors)
103 103
 			? glsr( StyleValidationDefaults::class )->defaults()['message_error_class']
104 104
 			: '';
105 105
 		return glsr( Template::class )->build( 'templates/form/response', [
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
 				'class' => $classes,
108 108
 				'message' => wpautop( $this->message ),
109 109
 			],
110
-			'has_errors' => !empty( $this->errors ),
111
-		]);
110
+			'has_errors' => !empty($this->errors),
111
+		] );
112 112
 	}
113 113
 
114 114
 	/**
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 			'context' => [
121 121
 				'text' => __( 'Submit your review', 'site-reviews' ),
122 122
 			],
123
-		]);
123
+		] );
124 124
 	}
125 125
 
126 126
 	/**
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 		$fields = array_merge(
140 140
 			$this->getHiddenFields(),
141 141
 			[$this->getHoneypotField()],
142
-			$this->normalizeFields( glsr( Form::class )->getFields( 'submission-form' ))
142
+			$this->normalizeFields( glsr( Form::class )->getFields( 'submission-form' ) )
143 143
 		);
144 144
 		return $fields;
145 145
 	}
@@ -149,10 +149,10 @@  discard block
 block discarded – undo
149 149
 	 */
150 150
 	protected function getLoginText()
151 151
 	{
152
-		$loginLink = glsr( Builder::class )->a([
153
-			'href' => wp_login_url( strval( get_permalink() )),
152
+		$loginLink = glsr( Builder::class )->a( [
153
+			'href' => wp_login_url( strval( get_permalink() ) ),
154 154
 			'text' => __( 'logged in', 'site-reviews' ),
155
-		]);
155
+		] );
156 156
 		return sprintf( __( 'You must be %s to submit a review.', 'site-reviews' ), $loginLink );
157 157
 	}
158 158
 
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
 	protected function getRegisterText()
163 163
 	{
164 164
 		if( !get_option( 'users_can_register' ) || glsr( OptionManager::class )->get( 'settings.general.require.login' ) != 'yes' )return;
165
-		$registerLink = glsr( Builder::class )->a([
165
+		$registerLink = glsr( Builder::class )->a( [
166 166
 			'href' => wp_registration_url(),
167 167
 			'text' => __( 'register', 'site-reviews' ),
168
-		]);
168
+		] );
169 169
 		return sprintf( __( 'You may also %s for an account.', 'site-reviews' ), $registerLink );
170 170
 	}
171 171
 
@@ -177,32 +177,32 @@  discard block
 block discarded – undo
177 177
 		$fields = [[
178 178
 			'name' => 'action',
179 179
 			'value' => 'submit-review',
180
-		],[
180
+		], [
181 181
 			'name' => 'assign_to',
182 182
 			'value' => $this->args['assign_to'],
183
-		],[
183
+		], [
184 184
 			'name' => 'category',
185 185
 			'value' => $this->args['category'],
186
-		],[
186
+		], [
187 187
 			'name' => 'counter',
188
-		],[
188
+		], [
189 189
 			'name' => 'excluded',
190 190
 			'value' => $this->args['hide'],
191
-		],[
191
+		], [
192 192
 			'name' => 'form_id',
193 193
 			'value' => $this->args['id'],
194
-		],[
194
+		], [
195 195
 			'name' => 'nonce',
196 196
 			'value' => wp_create_nonce( 'submit-review' ),
197
-		],[
197
+		], [
198 198
 			'name' => 'post_id',
199 199
 			'value' => get_the_ID(),
200
-		],[
200
+		], [
201 201
 			'name' => 'referer',
202
-			'value' => wp_unslash( filter_input( INPUT_SERVER, 'REQUEST_URI' )),
202
+			'value' => wp_unslash( filter_input( INPUT_SERVER, 'REQUEST_URI' ) ),
203 203
 		]];
204 204
 		return array_map( function( $field ) {
205
-			return new Field( wp_parse_args( $field, ['type' => 'hidden'] ));
205
+			return new Field( wp_parse_args( $field, ['type' => 'hidden'] ) );
206 206
 		}, $fields );
207 207
 	}
208 208
 
@@ -211,10 +211,10 @@  discard block
 block discarded – undo
211 211
 	 */
212 212
 	protected function getHoneypotField()
213 213
 	{
214
-		return new Field([
214
+		return new Field( [
215 215
 			'name' => 'gotcha',
216 216
 			'type' => 'honeypot',
217
-		]);
217
+		] );
218 218
 	}
219 219
 
220 220
 	/**
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	 */
223 223
 	protected function normalizeFieldClass( Field &$field )
224 224
 	{
225
-		if( !isset( $field->field['class'] )) {
225
+		if( !isset($field->field['class']) ) {
226 226
 			$field->field['class'] = '';
227 227
 		}
228 228
 		$field->field['class'] = trim( $field->field['class'].' glsr-field-control' );
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	 */
234 234
 	protected function normalizeFieldErrors( Field &$field )
235 235
 	{
236
-		if( !array_key_exists( $field->field['path'], $this->errors ))return;
236
+		if( !array_key_exists( $field->field['path'], $this->errors ) )return;
237 237
 		$field->field['errors'] = $this->errors[$field->field['path']];
238 238
 	}
239 239
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	 */
243 243
 	protected function normalizeFieldRequired( Field &$field )
244 244
 	{
245
-		if( !in_array( $field->field['path'], $this->required ))return;
245
+		if( !in_array( $field->field['path'], $this->required ) )return;
246 246
 		$field->field['required'] = true;
247 247
 	}
248 248
 
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 	{
254 254
 		$normalizedFields = [];
255 255
 		foreach( $fields as $field ) {
256
-			if( in_array( $field->field['path'], $this->args['hide'] ))continue;
256
+			if( in_array( $field->field['path'], $this->args['hide'] ) )continue;
257 257
 			$field->field['is_public'] = true;
258 258
 			$this->normalizeFieldClass( $field );
259 259
 			$this->normalizeFieldErrors( $field );
@@ -269,8 +269,8 @@  discard block
 block discarded – undo
269 269
 	 */
270 270
 	protected function normalizeFieldValue( Field &$field )
271 271
 	{
272
-		if( !array_key_exists( $field->field['path'], $this->values ))return;
273
-		if( in_array( $field->field['type'], ['radio', 'checkbox'] )) {
272
+		if( !array_key_exists( $field->field['path'], $this->values ) )return;
273
+		if( in_array( $field->field['type'], ['radio', 'checkbox'] ) ) {
274 274
 			$field->field['checked'] = $field->field['value'] == $this->values[$field->field['path']];
275 275
 		}
276 276
 		else {
Please login to merge, or discard this patch.
Braces   +18 added lines, -6 removed lines patch added patch discarded remove patch
@@ -85,7 +85,9 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	protected function buildRecaptcha()
87 87
 	{
88
-		if( !glsr( OptionManager::class )->isRecaptchaEnabled() )return;
88
+		if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) {
89
+			return;
90
+		}
89 91
 		return glsr( Builder::class )->div([
90 92
 			'class' => 'glsr-recaptcha-holder',
91 93
 			'data-badge' => glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.position' ),
@@ -161,7 +163,9 @@  discard block
 block discarded – undo
161 163
 	 */
162 164
 	protected function getRegisterText()
163 165
 	{
164
-		if( !get_option( 'users_can_register' ) || glsr( OptionManager::class )->get( 'settings.general.require.login' ) != 'yes' )return;
166
+		if( !get_option( 'users_can_register' ) || glsr( OptionManager::class )->get( 'settings.general.require.login' ) != 'yes' ) {
167
+			return;
168
+		}
165 169
 		$registerLink = glsr( Builder::class )->a([
166 170
 			'href' => wp_registration_url(),
167 171
 			'text' => __( 'register', 'site-reviews' ),
@@ -233,7 +237,9 @@  discard block
 block discarded – undo
233 237
 	 */
234 238
 	protected function normalizeFieldErrors( Field &$field )
235 239
 	{
236
-		if( !array_key_exists( $field->field['path'], $this->errors ))return;
240
+		if( !array_key_exists( $field->field['path'], $this->errors )) {
241
+			return;
242
+		}
237 243
 		$field->field['errors'] = $this->errors[$field->field['path']];
238 244
 	}
239 245
 
@@ -242,7 +248,9 @@  discard block
 block discarded – undo
242 248
 	 */
243 249
 	protected function normalizeFieldRequired( Field &$field )
244 250
 	{
245
-		if( !in_array( $field->field['path'], $this->required ))return;
251
+		if( !in_array( $field->field['path'], $this->required )) {
252
+			return;
253
+		}
246 254
 		$field->field['required'] = true;
247 255
 	}
248 256
 
@@ -253,7 +261,9 @@  discard block
 block discarded – undo
253 261
 	{
254 262
 		$normalizedFields = [];
255 263
 		foreach( $fields as $field ) {
256
-			if( in_array( $field->field['path'], $this->args['hide'] ))continue;
264
+			if( in_array( $field->field['path'], $this->args['hide'] )) {
265
+				continue;
266
+			}
257 267
 			$field->field['is_public'] = true;
258 268
 			$this->normalizeFieldClass( $field );
259 269
 			$this->normalizeFieldErrors( $field );
@@ -269,7 +279,9 @@  discard block
 block discarded – undo
269 279
 	 */
270 280
 	protected function normalizeFieldValue( Field &$field )
271 281
 	{
272
-		if( !array_key_exists( $field->field['path'], $this->values ))return;
282
+		if( !array_key_exists( $field->field['path'], $this->values )) {
283
+			return;
284
+		}
273 285
 		if( in_array( $field->field['type'], ['radio', 'checkbox'] )) {
274 286
 			$field->field['checked'] = $field->field['value'] == $this->values[$field->field['path']];
275 287
 		}
Please login to merge, or discard this patch.
plugin/Modules/Html/Settings.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 */
36 36
 	protected function getFieldDefault( array $field )
37 37
 	{
38
-		return isset( $field['default'] )
38
+		return isset($field['default'])
39 39
 			? $field['default']
40 40
 			: '';
41 41
 	}
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 */
46 46
 	protected function getSettingFields( $path )
47 47
 	{
48
-		return array_filter( $this->settings, function( $key ) use( $path ) {
48
+		return array_filter( $this->settings, function( $key ) use($path) {
49 49
 			return glsr( Helper::class )->startsWith( $path, $key );
50 50
 		}, ARRAY_FILTER_USE_KEY );
51 51
 	}
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 			$field = wp_parse_args( $field, [
61 61
 				'is_setting' => true,
62 62
 				'name' => $name,
63
-			]);
64
-			$rows.= new Field( $this->normalize( $field ));
63
+			] );
64
+			$rows .= new Field( $this->normalize( $field ) );
65 65
 		}
66 66
 		return $rows;
67 67
 	}
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 */
73 73
 	protected function getTemplateData( $id )
74 74
 	{
75
-		$fields = $this->getSettingFields( $this->normalizeSettingPath( $id ));
75
+		$fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) );
76 76
 		return [
77 77
 			'context' => [
78 78
 				'rows' => $this->getSettingRows( $fields ),
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
 	 */
87 87
 	protected function getTemplateDataForAddons( $id )
88 88
 	{
89
-		$fields = $this->getSettingFields( $this->normalizeSettingPath( $id ));
89
+		$fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) );
90 90
 		$settings = glsr( Helper::class )->convertDotNotationArray( $fields );
91 91
 		$settingKeys = array_keys( $settings['settings']['addons'] );
92 92
 		$results = [];
93 93
 		foreach( $settingKeys as $key ) {
94
-			$addonFields = array_filter( $fields, function( $path ) use( $key ) {
94
+			$addonFields = array_filter( $fields, function( $path ) use($key) {
95 95
 				return glsr( Helper::class )->startsWith( 'settings.addons.'.$key, $path );
96 96
 			}, ARRAY_FILTER_USE_KEY );
97 97
 			$results[$key] = $this->getSettingRows( $addonFields );
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	protected function getTemplateDataForTranslations()
108 108
 	{
109 109
 		$translations = glsr( Translation::class )->renderAll();
110
-		$class = empty( $translations )
110
+		$class = empty($translations)
111 111
 			? 'glsr-hidden'
112 112
 			: '';
113 113
 		return [
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
 			$path,
131 131
 			glsr( Helper::class )->getPathValue( $path, glsr()->defaults )
132 132
 		);
133
-		if( is_array( $expectedValue )) {
133
+		if( is_array( $expectedValue ) ) {
134 134
 			return is_array( $optionValue )
135
-				? count( array_intersect( $optionValue, $expectedValue )) === 0
135
+				? count( array_intersect( $optionValue, $expectedValue ) ) === 0
136 136
 				: !in_array( $optionValue, $expectedValue );
137 137
 		}
138 138
 		return $optionValue != $expectedValue;
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
 	 */
144 144
 	protected function isMultiDependency( $path )
145 145
 	{
146
-		if( isset( $this->settings[$path] )) {
146
+		if( isset($this->settings[$path]) ) {
147 147
 			$field = $this->settings[$path];
148
-			return ( $field['type'] == 'checkbox' && !empty( $field['options'] ))
149
-				|| !empty( $field['multiple'] );
148
+			return ($field['type'] == 'checkbox' && !empty($field['options']))
149
+				|| !empty($field['multiple']);
150 150
 		}
151 151
 		return false;
152 152
 	}
@@ -167,17 +167,17 @@  discard block
 block discarded – undo
167 167
 	 */
168 168
 	protected function normalizeDependsOn( array $field )
169 169
 	{
170
-		if( !empty( $field['depends_on'] ) && is_array( $field['depends_on'] )) {
170
+		if( !empty($field['depends_on']) && is_array( $field['depends_on'] ) ) {
171 171
 			$path = key( $field['depends_on'] );
172 172
 			$expectedValue = $field['depends_on'][$path];
173 173
 			$fieldName = glsr( Helper::class )->convertPathToName( $path, OptionManager::databaseKey() );
174
-			if( $this->isMultiDependency( $path )) {
175
-				$fieldName.= '[]';
174
+			if( $this->isMultiDependency( $path ) ) {
175
+				$fieldName .= '[]';
176 176
 			}
177
-			$field['data-depends'] = json_encode([
177
+			$field['data-depends'] = json_encode( [
178 178
 				'name' => $fieldName,
179 179
 				'value' => $expectedValue,
180
-			], JSON_HEX_APOS|JSON_HEX_QUOT );
180
+			], JSON_HEX_APOS | JSON_HEX_QUOT );
181 181
 			$field['is_hidden'] = $this->isFieldHidden( $path, $expectedValue );
182 182
 		}
183 183
 		return $field;
@@ -188,9 +188,9 @@  discard block
 block discarded – undo
188 188
 	 */
189 189
 	protected function normalizeLabelAndLegend( array $field )
190 190
 	{
191
-		if( !empty( $field['label'] )) {
191
+		if( !empty($field['label']) ) {
192 192
 			$field['legend'] = $field['label'];
193
-			unset( $field['label'] );
193
+			unset($field['label']);
194 194
 		}
195 195
 		else {
196 196
 			$field['is_valid'] = false;
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	 */
205 205
 	protected function normalizeValue( array $field )
206 206
 	{
207
-		if( !isset( $field['value'] )) {
207
+		if( !isset($field['value']) ) {
208 208
 			$field['value'] = glsr( OptionManager::class )->get(
209 209
 				$field['name'],
210 210
 				$this->getFieldDefault( $field )
Please login to merge, or discard this patch.