Passed
Push — master ( b1f119...6c0127 )
by Paul
11:00 queued 04:12
created
plugin/Modules/Html/ReviewsHtml.php 2 patches
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -8,135 +8,135 @@
 block discarded – undo
8 8
 
9 9
 class ReviewsHtml extends ArrayObject
10 10
 {
11
-    /**
12
-     * @var array
13
-     */
14
-    public $args;
11
+	/**
12
+	 * @var array
13
+	 */
14
+	public $args;
15 15
 
16
-    /**
17
-     * @var int
18
-     */
19
-    public $max_num_pages;
16
+	/**
17
+	 * @var int
18
+	 */
19
+	public $max_num_pages;
20 20
 
21
-    /**
22
-     * @var string
23
-     */
24
-    public $pagination;
21
+	/**
22
+	 * @var string
23
+	 */
24
+	public $pagination;
25 25
 
26
-    /**
27
-     * @var array
28
-     */
29
-    public $reviews;
26
+	/**
27
+	 * @var array
28
+	 */
29
+	public $reviews;
30 30
 
31
-    public function __construct(array $renderedReviews, $maxPageCount, array $args)
32
-    {
33
-        $this->args = $args;
34
-        $this->max_num_pages = $maxPageCount;
35
-        $this->reviews = $renderedReviews;
36
-        $this->pagination = $this->buildPagination();
37
-        parent::__construct($renderedReviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
38
-    }
31
+	public function __construct(array $renderedReviews, $maxPageCount, array $args)
32
+	{
33
+		$this->args = $args;
34
+		$this->max_num_pages = $maxPageCount;
35
+		$this->reviews = $renderedReviews;
36
+		$this->pagination = $this->buildPagination();
37
+		parent::__construct($renderedReviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
38
+	}
39 39
 
40
-    /**
41
-     * @return string
42
-     */
43
-    public function __toString()
44
-    {
45
-        return glsr(Template::class)->build('templates/reviews', [
46
-            'args' => $this->args,
47
-            'context' => [
48
-                'assigned_to' => $this->args['assigned_to'],
49
-                'category' => $this->args['category'],
50
-                'class' => $this->getClass(),
51
-                'id' => $this->args['id'],
52
-                'pagination' => $this->getPagination(),
53
-                'reviews' => $this->getReviews(),
54
-            ],
55
-        ]);
56
-    }
40
+	/**
41
+	 * @return string
42
+	 */
43
+	public function __toString()
44
+	{
45
+		return glsr(Template::class)->build('templates/reviews', [
46
+			'args' => $this->args,
47
+			'context' => [
48
+				'assigned_to' => $this->args['assigned_to'],
49
+				'category' => $this->args['category'],
50
+				'class' => $this->getClass(),
51
+				'id' => $this->args['id'],
52
+				'pagination' => $this->getPagination(),
53
+				'reviews' => $this->getReviews(),
54
+			],
55
+		]);
56
+	}
57 57
 
58
-    /**
59
-     * @return string
60
-     */
61
-    public function getPagination()
62
-    {
63
-        return wp_validate_boolean($this->args['pagination'])
64
-            ? $this->pagination
65
-            : '';
66
-    }
58
+	/**
59
+	 * @return string
60
+	 */
61
+	public function getPagination()
62
+	{
63
+		return wp_validate_boolean($this->args['pagination'])
64
+			? $this->pagination
65
+			: '';
66
+	}
67 67
 
68
-    /**
69
-     * @return string
70
-     */
71
-    public function getReviews()
72
-    {
73
-        $html = empty($this->reviews)
74
-            ? $this->getReviewsFallback()
75
-            : implode(PHP_EOL, $this->reviews);
76
-        $wrapper = '<div class="glsr-reviews">%s</div>';
77
-        $wrapper = apply_filters('site-reviews/reviews/reviews-wrapper', $wrapper);
78
-        return sprintf($wrapper, $html);
79
-    }
68
+	/**
69
+	 * @return string
70
+	 */
71
+	public function getReviews()
72
+	{
73
+		$html = empty($this->reviews)
74
+			? $this->getReviewsFallback()
75
+			: implode(PHP_EOL, $this->reviews);
76
+		$wrapper = '<div class="glsr-reviews">%s</div>';
77
+		$wrapper = apply_filters('site-reviews/reviews/reviews-wrapper', $wrapper);
78
+		return sprintf($wrapper, $html);
79
+	}
80 80
 
81
-    /**
82
-     * @param mixed $key
83
-     * @return mixed
84
-     */
85
-    public function offsetGet($key)
86
-    {
87
-        if ('navigation' == $key) {
88
-            glsr()->deprecated[] = 'The $reviewsHtml->navigation property has been been deprecated. Please use the $reviewsHtml->pagination property instead.';
89
-            return $this->pagination;
90
-        }
91
-        if (property_exists($this, $key)) {
92
-            return $this->$key;
93
-        }
94
-        return array_key_exists($key, $this->reviews)
95
-            ? $this->reviews[$key]
96
-            : null;
97
-    }
81
+	/**
82
+	 * @param mixed $key
83
+	 * @return mixed
84
+	 */
85
+	public function offsetGet($key)
86
+	{
87
+		if ('navigation' == $key) {
88
+			glsr()->deprecated[] = 'The $reviewsHtml->navigation property has been been deprecated. Please use the $reviewsHtml->pagination property instead.';
89
+			return $this->pagination;
90
+		}
91
+		if (property_exists($this, $key)) {
92
+			return $this->$key;
93
+		}
94
+		return array_key_exists($key, $this->reviews)
95
+			? $this->reviews[$key]
96
+			: null;
97
+	}
98 98
 
99
-    /**
100
-     * @return string
101
-     */
102
-    protected function buildPagination()
103
-    {
104
-        $html = glsr(Partial::class)->build('pagination', [
105
-            'baseUrl' => Arr::get($this->args, 'pagedUrl'),
106
-            'current' => Arr::get($this->args, 'paged'),
107
-            'total' => $this->max_num_pages,
108
-        ]);
109
-        $html.= sprintf('<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json']);
110
-        $wrapper = '<div class="glsr-pagination">%s</div>';
111
-        $wrapper = apply_filters('site-reviews/reviews/pagination-wrapper', $wrapper);
112
-        return sprintf($wrapper, $html);
113
-    }
99
+	/**
100
+	 * @return string
101
+	 */
102
+	protected function buildPagination()
103
+	{
104
+		$html = glsr(Partial::class)->build('pagination', [
105
+			'baseUrl' => Arr::get($this->args, 'pagedUrl'),
106
+			'current' => Arr::get($this->args, 'paged'),
107
+			'total' => $this->max_num_pages,
108
+		]);
109
+		$html.= sprintf('<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json']);
110
+		$wrapper = '<div class="glsr-pagination">%s</div>';
111
+		$wrapper = apply_filters('site-reviews/reviews/pagination-wrapper', $wrapper);
112
+		return sprintf($wrapper, $html);
113
+	}
114 114
 
115
-    /**
116
-     * @return string
117
-     */
118
-    protected function getClass()
119
-    {
120
-        $defaults = [
121
-            'glsr-default',
122
-        ];
123
-        if ('ajax' == $this->args['pagination']) {
124
-            $defaults[] = 'glsr-ajax-pagination';
125
-        }
126
-        $classes = explode(' ', $this->args['class']);
127
-        $classes = array_unique(array_merge($defaults, array_filter($classes)));
128
-        return implode(' ', $classes);
129
-    }
115
+	/**
116
+	 * @return string
117
+	 */
118
+	protected function getClass()
119
+	{
120
+		$defaults = [
121
+			'glsr-default',
122
+		];
123
+		if ('ajax' == $this->args['pagination']) {
124
+			$defaults[] = 'glsr-ajax-pagination';
125
+		}
126
+		$classes = explode(' ', $this->args['class']);
127
+		$classes = array_unique(array_merge($defaults, array_filter($classes)));
128
+		return implode(' ', $classes);
129
+	}
130 130
 
131
-    /**
132
-     * @return string
133
-     */
134
-    protected function getReviewsFallback()
135
-    {
136
-        if (empty($this->args['fallback']) && glsr(OptionManager::class)->getBool('settings.reviews.fallback')) {
137
-            $this->args['fallback'] = __('There are no reviews yet. Be the first one to write one.', 'site-reviews');
138
-        }
139
-        $fallback = '<p class="glsr-no-margins">'.$this->args['fallback'].'</p>';
140
-        return apply_filters('site-reviews/reviews/fallback', $fallback, $this->args);
141
-    }
131
+	/**
132
+	 * @return string
133
+	 */
134
+	protected function getReviewsFallback()
135
+	{
136
+		if (empty($this->args['fallback']) && glsr(OptionManager::class)->getBool('settings.reviews.fallback')) {
137
+			$this->args['fallback'] = __('There are no reviews yet. Be the first one to write one.', 'site-reviews');
138
+		}
139
+		$fallback = '<p class="glsr-no-margins">'.$this->args['fallback'].'</p>';
140
+		return apply_filters('site-reviews/reviews/fallback', $fallback, $this->args);
141
+	}
142 142
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -28,13 +28,13 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public $reviews;
30 30
 
31
-    public function __construct(array $renderedReviews, $maxPageCount, array $args)
31
+    public function __construct( array $renderedReviews, $maxPageCount, array $args )
32 32
     {
33 33
         $this->args = $args;
34 34
         $this->max_num_pages = $maxPageCount;
35 35
         $this->reviews = $renderedReviews;
36 36
         $this->pagination = $this->buildPagination();
37
-        parent::__construct($renderedReviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
37
+        parent::__construct( $renderedReviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS );
38 38
     }
39 39
 
40 40
     /**
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function __toString()
44 44
     {
45
-        return glsr(Template::class)->build('templates/reviews', [
45
+        return glsr( Template::class )->build( 'templates/reviews', [
46 46
             'args' => $this->args,
47 47
             'context' => [
48 48
                 'assigned_to' => $this->args['assigned_to'],
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
                 'pagination' => $this->getPagination(),
53 53
                 'reviews' => $this->getReviews(),
54 54
             ],
55
-        ]);
55
+        ] );
56 56
     }
57 57
 
58 58
     /**
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      */
61 61
     public function getPagination()
62 62
     {
63
-        return wp_validate_boolean($this->args['pagination'])
63
+        return wp_validate_boolean( $this->args['pagination'] )
64 64
             ? $this->pagination
65 65
             : '';
66 66
     }
@@ -72,26 +72,26 @@  discard block
 block discarded – undo
72 72
     {
73 73
         $html = empty($this->reviews)
74 74
             ? $this->getReviewsFallback()
75
-            : implode(PHP_EOL, $this->reviews);
75
+            : implode( PHP_EOL, $this->reviews );
76 76
         $wrapper = '<div class="glsr-reviews">%s</div>';
77
-        $wrapper = apply_filters('site-reviews/reviews/reviews-wrapper', $wrapper);
78
-        return sprintf($wrapper, $html);
77
+        $wrapper = apply_filters( 'site-reviews/reviews/reviews-wrapper', $wrapper );
78
+        return sprintf( $wrapper, $html );
79 79
     }
80 80
 
81 81
     /**
82 82
      * @param mixed $key
83 83
      * @return mixed
84 84
      */
85
-    public function offsetGet($key)
85
+    public function offsetGet( $key )
86 86
     {
87
-        if ('navigation' == $key) {
87
+        if( 'navigation' == $key ) {
88 88
             glsr()->deprecated[] = 'The $reviewsHtml->navigation property has been been deprecated. Please use the $reviewsHtml->pagination property instead.';
89 89
             return $this->pagination;
90 90
         }
91
-        if (property_exists($this, $key)) {
91
+        if( property_exists( $this, $key ) ) {
92 92
             return $this->$key;
93 93
         }
94
-        return array_key_exists($key, $this->reviews)
94
+        return array_key_exists( $key, $this->reviews )
95 95
             ? $this->reviews[$key]
96 96
             : null;
97 97
     }
@@ -101,15 +101,15 @@  discard block
 block discarded – undo
101 101
      */
102 102
     protected function buildPagination()
103 103
     {
104
-        $html = glsr(Partial::class)->build('pagination', [
105
-            'baseUrl' => Arr::get($this->args, 'pagedUrl'),
106
-            'current' => Arr::get($this->args, 'paged'),
104
+        $html = glsr( Partial::class )->build( 'pagination', [
105
+            'baseUrl' => Arr::get( $this->args, 'pagedUrl' ),
106
+            'current' => Arr::get( $this->args, 'paged' ),
107 107
             'total' => $this->max_num_pages,
108
-        ]);
109
-        $html.= sprintf('<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json']);
108
+        ] );
109
+        $html .= sprintf( '<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json'] );
110 110
         $wrapper = '<div class="glsr-pagination">%s</div>';
111
-        $wrapper = apply_filters('site-reviews/reviews/pagination-wrapper', $wrapper);
112
-        return sprintf($wrapper, $html);
111
+        $wrapper = apply_filters( 'site-reviews/reviews/pagination-wrapper', $wrapper );
112
+        return sprintf( $wrapper, $html );
113 113
     }
114 114
 
115 115
     /**
@@ -120,12 +120,12 @@  discard block
 block discarded – undo
120 120
         $defaults = [
121 121
             'glsr-default',
122 122
         ];
123
-        if ('ajax' == $this->args['pagination']) {
123
+        if( 'ajax' == $this->args['pagination'] ) {
124 124
             $defaults[] = 'glsr-ajax-pagination';
125 125
         }
126
-        $classes = explode(' ', $this->args['class']);
127
-        $classes = array_unique(array_merge($defaults, array_filter($classes)));
128
-        return implode(' ', $classes);
126
+        $classes = explode( ' ', $this->args['class'] );
127
+        $classes = array_unique( array_merge( $defaults, array_filter( $classes ) ) );
128
+        return implode( ' ', $classes );
129 129
     }
130 130
 
131 131
     /**
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
      */
134 134
     protected function getReviewsFallback()
135 135
     {
136
-        if (empty($this->args['fallback']) && glsr(OptionManager::class)->getBool('settings.reviews.fallback')) {
137
-            $this->args['fallback'] = __('There are no reviews yet. Be the first one to write one.', 'site-reviews');
136
+        if( empty($this->args['fallback']) && glsr( OptionManager::class )->getBool( 'settings.reviews.fallback' ) ) {
137
+            $this->args['fallback'] = __( 'There are no reviews yet. Be the first one to write one.', 'site-reviews' );
138 138
         }
139 139
         $fallback = '<p class="glsr-no-margins">'.$this->args['fallback'].'</p>';
140
-        return apply_filters('site-reviews/reviews/fallback', $fallback, $this->args);
140
+        return apply_filters( 'site-reviews/reviews/fallback', $fallback, $this->args );
141 141
     }
142 142
 }
Please login to merge, or discard this patch.
plugin/Filters.php 2 patches
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -15,72 +15,72 @@
 block discarded – undo
15 15
 
16 16
 class Filters implements HooksContract
17 17
 {
18
-    protected $admin;
19
-    protected $app;
20
-    protected $basename;
21
-    protected $blocks;
22
-    protected $editor;
23
-    protected $listtable;
24
-    protected $public;
25
-    protected $rebusify;
26
-    protected $translator;
27
-    protected $welcome;
18
+	protected $admin;
19
+	protected $app;
20
+	protected $basename;
21
+	protected $blocks;
22
+	protected $editor;
23
+	protected $listtable;
24
+	protected $public;
25
+	protected $rebusify;
26
+	protected $translator;
27
+	protected $welcome;
28 28
 
29
-    public function __construct(Application $app)
30
-    {
31
-        $this->app = $app;
32
-        $this->admin = $app->make(AdminController::class);
33
-        $this->basename = plugin_basename($app->file);
34
-        $this->blocks = $app->make(BlocksController::class);
35
-        $this->editor = $app->make(EditorController::class);
36
-        $this->listtable = $app->make(ListTableController::class);
37
-        $this->public = $app->make(PublicController::class);
38
-        $this->rebusify = $app->make(RebusifyController::class);
39
-        $this->translator = $app->make(TranslationController::class);
40
-        $this->welcome = $app->make(WelcomeController::class);
41
-    }
29
+	public function __construct(Application $app)
30
+	{
31
+		$this->app = $app;
32
+		$this->admin = $app->make(AdminController::class);
33
+		$this->basename = plugin_basename($app->file);
34
+		$this->blocks = $app->make(BlocksController::class);
35
+		$this->editor = $app->make(EditorController::class);
36
+		$this->listtable = $app->make(ListTableController::class);
37
+		$this->public = $app->make(PublicController::class);
38
+		$this->rebusify = $app->make(RebusifyController::class);
39
+		$this->translator = $app->make(TranslationController::class);
40
+		$this->welcome = $app->make(WelcomeController::class);
41
+	}
42 42
 
43
-    /**
44
-     * @return void
45
-     */
46
-    public function run()
47
-    {
48
-        add_filter('map_meta_cap',                                              [$this->admin, 'filterCreateCapability'], 10, 2);
49
-        add_filter('mce_external_plugins',                                      [$this->admin, 'filterTinymcePlugins'], 15);
50
-        add_filter('plugin_action_links_'.$this->basename,                      [$this->admin, 'filterActionLinks']);
51
-        add_filter('dashboard_glance_items',                                    [$this->admin, 'filterDashboardGlanceItems']);
52
-        add_filter('block_categories',                                          [$this->blocks, 'filterBlockCategories']);
53
-        add_filter('classic_editor_enabled_editors_for_post_type',              [$this->blocks, 'filterEnabledEditors'], 10, 2);
54
-        add_filter('use_block_editor_for_post_type',                            [$this->blocks, 'filterUseBlockEditor'], 10, 2);
55
-        add_filter('wp_editor_settings',                                        [$this->editor, 'filterEditorSettings']);
56
-        add_filter('the_editor',                                                [$this->editor, 'filterEditorTextarea']);
57
-        add_filter('is_protected_meta',                                         [$this->editor, 'filterIsProtectedMeta'], 10, 3);
58
-        add_filter('post_updated_messages',                                     [$this->editor, 'filterUpdateMessages']);
59
-        add_filter('manage_'.Application::POST_TYPE.'_posts_columns',           [$this->listtable, 'filterColumnsForPostType']);
60
-        add_filter('post_date_column_status',                                   [$this->listtable, 'filterDateColumnStatus'], 10, 2);
61
-        add_filter('default_hidden_columns',                                    [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2);
62
-        add_filter('post_row_actions',                                          [$this->listtable, 'filterRowActions'], 10, 2);
63
-        add_filter('manage_edit-'.Application::POST_TYPE.'_sortable_columns',   [$this->listtable, 'filterSortableColumns']);
64
-        add_filter('script_loader_tag',                                         [$this->public, 'filterEnqueuedScripts'], 10, 2);
65
-        add_filter('site-reviews/config/forms/submission-form',                 [$this->public, 'filterFieldOrder'], 11);
66
-        add_filter('site-reviews/render/view',                                  [$this->public, 'filterRenderView']);
67
-        add_filter('site-reviews/settings/callback',                            [$this->rebusify, 'filterSettingsCallback']);
68
-        add_filter('site-reviews/interpolate/partials/form/table-row-multiple', [$this->rebusify, 'filterSettingsTableRow'], 10, 3);
69
-        add_filter('bulk_post_updated_messages',                                [$this->translator, 'filterBulkUpdateMessages'], 10, 2);
70
-        add_filter('gettext',                                                   [$this->translator, 'filterGettext'], 9, 3);
71
-        add_filter('site-reviews/gettext/site-reviews',                         [$this->translator, 'filterGettextSiteReviews'], 10, 2);
72
-        add_filter('gettext_with_context',                                      [$this->translator, 'filterGettextWithContext'], 9, 4);
73
-        add_filter('site-reviews/gettext_with_context/site-reviews',            [$this->translator, 'filterGettextWithContextSiteReviews'], 10, 3);
74
-        add_filter('ngettext',                                                  [$this->translator, 'filterNgettext'], 9, 5);
75
-        add_filter('site-reviews/ngettext/site-reviews',                        [$this->translator, 'filterNgettextSiteReviews'], 10, 4);
76
-        add_filter('ngettext_with_context',                                     [$this->translator, 'filterNgettextWithContext'], 9, 6);
77
-        add_filter('site-reviews/ngettext_with_context/site-reviews',           [$this->translator, 'filterNgettextWithContextSiteReviews'], 10, 5);
78
-        add_filter('display_post_states',                                       [$this->translator, 'filterPostStates'], 10, 2);
79
-        add_filter('site-reviews/gettext/default',                              [$this->translator, 'filterPostStatusLabels'], 10, 2);
80
-        add_filter('site-reviews/gettext_with_context/default',                 [$this->translator, 'filterPostStatusLabels'], 10, 2);
81
-        add_filter('site-reviews/ngettext/default',                             [$this->translator, 'filterPostStatusText'], 10, 4);
82
-        add_filter('plugin_action_links_'.$this->basename,                      [$this->welcome, 'filterActionLinks'], 9);
83
-        add_filter('admin_title',                                               [$this->welcome, 'filterAdminTitle']);
84
-        add_filter('admin_footer_text',                                         [$this->welcome, 'filterFooterText']);
85
-    }
43
+	/**
44
+	 * @return void
45
+	 */
46
+	public function run()
47
+	{
48
+		add_filter('map_meta_cap',                                              [$this->admin, 'filterCreateCapability'], 10, 2);
49
+		add_filter('mce_external_plugins',                                      [$this->admin, 'filterTinymcePlugins'], 15);
50
+		add_filter('plugin_action_links_'.$this->basename,                      [$this->admin, 'filterActionLinks']);
51
+		add_filter('dashboard_glance_items',                                    [$this->admin, 'filterDashboardGlanceItems']);
52
+		add_filter('block_categories',                                          [$this->blocks, 'filterBlockCategories']);
53
+		add_filter('classic_editor_enabled_editors_for_post_type',              [$this->blocks, 'filterEnabledEditors'], 10, 2);
54
+		add_filter('use_block_editor_for_post_type',                            [$this->blocks, 'filterUseBlockEditor'], 10, 2);
55
+		add_filter('wp_editor_settings',                                        [$this->editor, 'filterEditorSettings']);
56
+		add_filter('the_editor',                                                [$this->editor, 'filterEditorTextarea']);
57
+		add_filter('is_protected_meta',                                         [$this->editor, 'filterIsProtectedMeta'], 10, 3);
58
+		add_filter('post_updated_messages',                                     [$this->editor, 'filterUpdateMessages']);
59
+		add_filter('manage_'.Application::POST_TYPE.'_posts_columns',           [$this->listtable, 'filterColumnsForPostType']);
60
+		add_filter('post_date_column_status',                                   [$this->listtable, 'filterDateColumnStatus'], 10, 2);
61
+		add_filter('default_hidden_columns',                                    [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2);
62
+		add_filter('post_row_actions',                                          [$this->listtable, 'filterRowActions'], 10, 2);
63
+		add_filter('manage_edit-'.Application::POST_TYPE.'_sortable_columns',   [$this->listtable, 'filterSortableColumns']);
64
+		add_filter('script_loader_tag',                                         [$this->public, 'filterEnqueuedScripts'], 10, 2);
65
+		add_filter('site-reviews/config/forms/submission-form',                 [$this->public, 'filterFieldOrder'], 11);
66
+		add_filter('site-reviews/render/view',                                  [$this->public, 'filterRenderView']);
67
+		add_filter('site-reviews/settings/callback',                            [$this->rebusify, 'filterSettingsCallback']);
68
+		add_filter('site-reviews/interpolate/partials/form/table-row-multiple', [$this->rebusify, 'filterSettingsTableRow'], 10, 3);
69
+		add_filter('bulk_post_updated_messages',                                [$this->translator, 'filterBulkUpdateMessages'], 10, 2);
70
+		add_filter('gettext',                                                   [$this->translator, 'filterGettext'], 9, 3);
71
+		add_filter('site-reviews/gettext/site-reviews',                         [$this->translator, 'filterGettextSiteReviews'], 10, 2);
72
+		add_filter('gettext_with_context',                                      [$this->translator, 'filterGettextWithContext'], 9, 4);
73
+		add_filter('site-reviews/gettext_with_context/site-reviews',            [$this->translator, 'filterGettextWithContextSiteReviews'], 10, 3);
74
+		add_filter('ngettext',                                                  [$this->translator, 'filterNgettext'], 9, 5);
75
+		add_filter('site-reviews/ngettext/site-reviews',                        [$this->translator, 'filterNgettextSiteReviews'], 10, 4);
76
+		add_filter('ngettext_with_context',                                     [$this->translator, 'filterNgettextWithContext'], 9, 6);
77
+		add_filter('site-reviews/ngettext_with_context/site-reviews',           [$this->translator, 'filterNgettextWithContextSiteReviews'], 10, 5);
78
+		add_filter('display_post_states',                                       [$this->translator, 'filterPostStates'], 10, 2);
79
+		add_filter('site-reviews/gettext/default',                              [$this->translator, 'filterPostStatusLabels'], 10, 2);
80
+		add_filter('site-reviews/gettext_with_context/default',                 [$this->translator, 'filterPostStatusLabels'], 10, 2);
81
+		add_filter('site-reviews/ngettext/default',                             [$this->translator, 'filterPostStatusText'], 10, 4);
82
+		add_filter('plugin_action_links_'.$this->basename,                      [$this->welcome, 'filterActionLinks'], 9);
83
+		add_filter('admin_title',                                               [$this->welcome, 'filterAdminTitle']);
84
+		add_filter('admin_footer_text',                                         [$this->welcome, 'filterFooterText']);
85
+	}
86 86
 }
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -26,18 +26,18 @@  discard block
 block discarded – undo
26 26
     protected $translator;
27 27
     protected $welcome;
28 28
 
29
-    public function __construct(Application $app)
29
+    public function __construct( Application $app )
30 30
     {
31 31
         $this->app = $app;
32
-        $this->admin = $app->make(AdminController::class);
33
-        $this->basename = plugin_basename($app->file);
34
-        $this->blocks = $app->make(BlocksController::class);
35
-        $this->editor = $app->make(EditorController::class);
36
-        $this->listtable = $app->make(ListTableController::class);
37
-        $this->public = $app->make(PublicController::class);
38
-        $this->rebusify = $app->make(RebusifyController::class);
39
-        $this->translator = $app->make(TranslationController::class);
40
-        $this->welcome = $app->make(WelcomeController::class);
32
+        $this->admin = $app->make( AdminController::class );
33
+        $this->basename = plugin_basename( $app->file );
34
+        $this->blocks = $app->make( BlocksController::class );
35
+        $this->editor = $app->make( EditorController::class );
36
+        $this->listtable = $app->make( ListTableController::class );
37
+        $this->public = $app->make( PublicController::class );
38
+        $this->rebusify = $app->make( RebusifyController::class );
39
+        $this->translator = $app->make( TranslationController::class );
40
+        $this->welcome = $app->make( WelcomeController::class );
41 41
     }
42 42
 
43 43
     /**
@@ -45,42 +45,42 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function run()
47 47
     {
48
-        add_filter('map_meta_cap',                                              [$this->admin, 'filterCreateCapability'], 10, 2);
49
-        add_filter('mce_external_plugins',                                      [$this->admin, 'filterTinymcePlugins'], 15);
50
-        add_filter('plugin_action_links_'.$this->basename,                      [$this->admin, 'filterActionLinks']);
51
-        add_filter('dashboard_glance_items',                                    [$this->admin, 'filterDashboardGlanceItems']);
52
-        add_filter('block_categories',                                          [$this->blocks, 'filterBlockCategories']);
53
-        add_filter('classic_editor_enabled_editors_for_post_type',              [$this->blocks, 'filterEnabledEditors'], 10, 2);
54
-        add_filter('use_block_editor_for_post_type',                            [$this->blocks, 'filterUseBlockEditor'], 10, 2);
55
-        add_filter('wp_editor_settings',                                        [$this->editor, 'filterEditorSettings']);
56
-        add_filter('the_editor',                                                [$this->editor, 'filterEditorTextarea']);
57
-        add_filter('is_protected_meta',                                         [$this->editor, 'filterIsProtectedMeta'], 10, 3);
58
-        add_filter('post_updated_messages',                                     [$this->editor, 'filterUpdateMessages']);
59
-        add_filter('manage_'.Application::POST_TYPE.'_posts_columns',           [$this->listtable, 'filterColumnsForPostType']);
60
-        add_filter('post_date_column_status',                                   [$this->listtable, 'filterDateColumnStatus'], 10, 2);
61
-        add_filter('default_hidden_columns',                                    [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2);
62
-        add_filter('post_row_actions',                                          [$this->listtable, 'filterRowActions'], 10, 2);
63
-        add_filter('manage_edit-'.Application::POST_TYPE.'_sortable_columns',   [$this->listtable, 'filterSortableColumns']);
64
-        add_filter('script_loader_tag',                                         [$this->public, 'filterEnqueuedScripts'], 10, 2);
65
-        add_filter('site-reviews/config/forms/submission-form',                 [$this->public, 'filterFieldOrder'], 11);
66
-        add_filter('site-reviews/render/view',                                  [$this->public, 'filterRenderView']);
67
-        add_filter('site-reviews/settings/callback',                            [$this->rebusify, 'filterSettingsCallback']);
68
-        add_filter('site-reviews/interpolate/partials/form/table-row-multiple', [$this->rebusify, 'filterSettingsTableRow'], 10, 3);
69
-        add_filter('bulk_post_updated_messages',                                [$this->translator, 'filterBulkUpdateMessages'], 10, 2);
70
-        add_filter('gettext',                                                   [$this->translator, 'filterGettext'], 9, 3);
71
-        add_filter('site-reviews/gettext/site-reviews',                         [$this->translator, 'filterGettextSiteReviews'], 10, 2);
72
-        add_filter('gettext_with_context',                                      [$this->translator, 'filterGettextWithContext'], 9, 4);
73
-        add_filter('site-reviews/gettext_with_context/site-reviews',            [$this->translator, 'filterGettextWithContextSiteReviews'], 10, 3);
74
-        add_filter('ngettext',                                                  [$this->translator, 'filterNgettext'], 9, 5);
75
-        add_filter('site-reviews/ngettext/site-reviews',                        [$this->translator, 'filterNgettextSiteReviews'], 10, 4);
76
-        add_filter('ngettext_with_context',                                     [$this->translator, 'filterNgettextWithContext'], 9, 6);
77
-        add_filter('site-reviews/ngettext_with_context/site-reviews',           [$this->translator, 'filterNgettextWithContextSiteReviews'], 10, 5);
78
-        add_filter('display_post_states',                                       [$this->translator, 'filterPostStates'], 10, 2);
79
-        add_filter('site-reviews/gettext/default',                              [$this->translator, 'filterPostStatusLabels'], 10, 2);
80
-        add_filter('site-reviews/gettext_with_context/default',                 [$this->translator, 'filterPostStatusLabels'], 10, 2);
81
-        add_filter('site-reviews/ngettext/default',                             [$this->translator, 'filterPostStatusText'], 10, 4);
82
-        add_filter('plugin_action_links_'.$this->basename,                      [$this->welcome, 'filterActionLinks'], 9);
83
-        add_filter('admin_title',                                               [$this->welcome, 'filterAdminTitle']);
84
-        add_filter('admin_footer_text',                                         [$this->welcome, 'filterFooterText']);
48
+        add_filter( 'map_meta_cap', [$this->admin, 'filterCreateCapability'], 10, 2 );
49
+        add_filter( 'mce_external_plugins', [$this->admin, 'filterTinymcePlugins'], 15 );
50
+        add_filter( 'plugin_action_links_'.$this->basename, [$this->admin, 'filterActionLinks'] );
51
+        add_filter( 'dashboard_glance_items', [$this->admin, 'filterDashboardGlanceItems'] );
52
+        add_filter( 'block_categories', [$this->blocks, 'filterBlockCategories'] );
53
+        add_filter( 'classic_editor_enabled_editors_for_post_type', [$this->blocks, 'filterEnabledEditors'], 10, 2 );
54
+        add_filter( 'use_block_editor_for_post_type', [$this->blocks, 'filterUseBlockEditor'], 10, 2 );
55
+        add_filter( 'wp_editor_settings', [$this->editor, 'filterEditorSettings'] );
56
+        add_filter( 'the_editor', [$this->editor, 'filterEditorTextarea'] );
57
+        add_filter( 'is_protected_meta', [$this->editor, 'filterIsProtectedMeta'], 10, 3 );
58
+        add_filter( 'post_updated_messages', [$this->editor, 'filterUpdateMessages'] );
59
+        add_filter( 'manage_'.Application::POST_TYPE.'_posts_columns', [$this->listtable, 'filterColumnsForPostType'] );
60
+        add_filter( 'post_date_column_status', [$this->listtable, 'filterDateColumnStatus'], 10, 2 );
61
+        add_filter( 'default_hidden_columns', [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2 );
62
+        add_filter( 'post_row_actions', [$this->listtable, 'filterRowActions'], 10, 2 );
63
+        add_filter( 'manage_edit-'.Application::POST_TYPE.'_sortable_columns', [$this->listtable, 'filterSortableColumns'] );
64
+        add_filter( 'script_loader_tag', [$this->public, 'filterEnqueuedScripts'], 10, 2 );
65
+        add_filter( 'site-reviews/config/forms/submission-form', [$this->public, 'filterFieldOrder'], 11 );
66
+        add_filter( 'site-reviews/render/view', [$this->public, 'filterRenderView'] );
67
+        add_filter( 'site-reviews/settings/callback', [$this->rebusify, 'filterSettingsCallback'] );
68
+        add_filter( 'site-reviews/interpolate/partials/form/table-row-multiple', [$this->rebusify, 'filterSettingsTableRow'], 10, 3 );
69
+        add_filter( 'bulk_post_updated_messages', [$this->translator, 'filterBulkUpdateMessages'], 10, 2 );
70
+        add_filter( 'gettext', [$this->translator, 'filterGettext'], 9, 3 );
71
+        add_filter( 'site-reviews/gettext/site-reviews', [$this->translator, 'filterGettextSiteReviews'], 10, 2 );
72
+        add_filter( 'gettext_with_context', [$this->translator, 'filterGettextWithContext'], 9, 4 );
73
+        add_filter( 'site-reviews/gettext_with_context/site-reviews', [$this->translator, 'filterGettextWithContextSiteReviews'], 10, 3 );
74
+        add_filter( 'ngettext', [$this->translator, 'filterNgettext'], 9, 5 );
75
+        add_filter( 'site-reviews/ngettext/site-reviews', [$this->translator, 'filterNgettextSiteReviews'], 10, 4 );
76
+        add_filter( 'ngettext_with_context', [$this->translator, 'filterNgettextWithContext'], 9, 6 );
77
+        add_filter( 'site-reviews/ngettext_with_context/site-reviews', [$this->translator, 'filterNgettextWithContextSiteReviews'], 10, 5 );
78
+        add_filter( 'display_post_states', [$this->translator, 'filterPostStates'], 10, 2 );
79
+        add_filter( 'site-reviews/gettext/default', [$this->translator, 'filterPostStatusLabels'], 10, 2 );
80
+        add_filter( 'site-reviews/gettext_with_context/default', [$this->translator, 'filterPostStatusLabels'], 10, 2 );
81
+        add_filter( 'site-reviews/ngettext/default', [$this->translator, 'filterPostStatusText'], 10, 4 );
82
+        add_filter( 'plugin_action_links_'.$this->basename, [$this->welcome, 'filterActionLinks'], 9 );
83
+        add_filter( 'admin_title', [$this->welcome, 'filterAdminTitle'] );
84
+        add_filter( 'admin_footer_text', [$this->welcome, 'filterFooterText'] );
85 85
     }
86 86
 }
Please login to merge, or discard this patch.
plugin/Controllers/PublicController.php 2 patches
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -13,81 +13,81 @@
 block discarded – undo
13 13
 
14 14
 class PublicController extends Controller
15 15
 {
16
-    /**
17
-     * @return void
18
-     * @action wp_enqueue_scripts
19
-     */
20
-    public function enqueueAssets()
21
-    {
22
-        (new EnqueuePublicAssets())->handle();
23
-    }
16
+	/**
17
+	 * @return void
18
+	 * @action wp_enqueue_scripts
19
+	 */
20
+	public function enqueueAssets()
21
+	{
22
+		(new EnqueuePublicAssets())->handle();
23
+	}
24 24
 
25
-    /**
26
-     * @param string $tag
27
-     * @param string $handle
28
-     * @return string
29
-     * @filter script_loader_tag
30
-     */
31
-    public function filterEnqueuedScripts($tag, $handle)
32
-    {
33
-        $scripts = [Application::ID.'/google-recaptcha'];
34
-        if (in_array($handle, apply_filters('site-reviews/async-scripts', $scripts))) {
35
-            $tag = str_replace(' src=', ' async src=', $tag);
36
-        }
37
-        if (in_array($handle, apply_filters('site-reviews/defer-scripts', $scripts))) {
38
-            $tag = str_replace(' src=', ' defer src=', $tag);
39
-        }
40
-        return $tag;
41
-    }
25
+	/**
26
+	 * @param string $tag
27
+	 * @param string $handle
28
+	 * @return string
29
+	 * @filter script_loader_tag
30
+	 */
31
+	public function filterEnqueuedScripts($tag, $handle)
32
+	{
33
+		$scripts = [Application::ID.'/google-recaptcha'];
34
+		if (in_array($handle, apply_filters('site-reviews/async-scripts', $scripts))) {
35
+			$tag = str_replace(' src=', ' async src=', $tag);
36
+		}
37
+		if (in_array($handle, apply_filters('site-reviews/defer-scripts', $scripts))) {
38
+			$tag = str_replace(' src=', ' defer src=', $tag);
39
+		}
40
+		return $tag;
41
+	}
42 42
 
43
-    /**
44
-     * @return array
45
-     * @filter site-reviews/config/forms/submission-form
46
-     */
47
-    public function filterFieldOrder(array $config)
48
-    {
49
-        $order = (array) apply_filters('site-reviews/submission-form/order', array_keys($config));
50
-        return array_intersect_key(array_merge(array_flip($order), $config), $config);
51
-    }
43
+	/**
44
+	 * @return array
45
+	 * @filter site-reviews/config/forms/submission-form
46
+	 */
47
+	public function filterFieldOrder(array $config)
48
+	{
49
+		$order = (array) apply_filters('site-reviews/submission-form/order', array_keys($config));
50
+		return array_intersect_key(array_merge(array_flip($order), $config), $config);
51
+	}
52 52
 
53
-    /**
54
-     * @param string $view
55
-     * @return string
56
-     * @filter site-reviews/render/view
57
-     */
58
-    public function filterRenderView($view)
59
-    {
60
-        return glsr(Style::class)->filterView($view);
61
-    }
53
+	/**
54
+	 * @param string $view
55
+	 * @return string
56
+	 * @filter site-reviews/render/view
57
+	 */
58
+	public function filterRenderView($view)
59
+	{
60
+		return glsr(Style::class)->filterView($view);
61
+	}
62 62
 
63
-    /**
64
-     * @return void
65
-     * @action site-reviews/builder
66
-     */
67
-    public function modifyBuilder(Builder $instance)
68
-    {
69
-        call_user_func_array([glsr(Style::class), 'modifyField'], [$instance]);
70
-    }
63
+	/**
64
+	 * @return void
65
+	 * @action site-reviews/builder
66
+	 */
67
+	public function modifyBuilder(Builder $instance)
68
+	{
69
+		call_user_func_array([glsr(Style::class), 'modifyField'], [$instance]);
70
+	}
71 71
 
72
-    /**
73
-     * @return void
74
-     * @action wp_footer
75
-     */
76
-    public function renderSchema()
77
-    {
78
-        glsr(Schema::class)->render();
79
-    }
72
+	/**
73
+	 * @return void
74
+	 * @action wp_footer
75
+	 */
76
+	public function renderSchema()
77
+	{
78
+		glsr(Schema::class)->render();
79
+	}
80 80
 
81
-    /**
82
-     * @return CreateReview
83
-     */
84
-    public function routerSubmitReview(array $request)
85
-    {
86
-        $validated = glsr(ValidateReview::class)->validate($request);
87
-        $command = new CreateReview($validated->request);
88
-        if (empty($validated->error) && !$validated->recaptchaIsUnset) {
89
-            $this->execute($command);
90
-        }
91
-        return $command;
92
-    }
81
+	/**
82
+	 * @return CreateReview
83
+	 */
84
+	public function routerSubmitReview(array $request)
85
+	{
86
+		$validated = glsr(ValidateReview::class)->validate($request);
87
+		$command = new CreateReview($validated->request);
88
+		if (empty($validated->error) && !$validated->recaptchaIsUnset) {
89
+			$this->execute($command);
90
+		}
91
+		return $command;
92
+	}
93 93
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
      * @return string
29 29
      * @filter script_loader_tag
30 30
      */
31
-    public function filterEnqueuedScripts($tag, $handle)
31
+    public function filterEnqueuedScripts( $tag, $handle )
32 32
     {
33 33
         $scripts = [Application::ID.'/google-recaptcha'];
34
-        if (in_array($handle, apply_filters('site-reviews/async-scripts', $scripts))) {
35
-            $tag = str_replace(' src=', ' async src=', $tag);
34
+        if( in_array( $handle, apply_filters( 'site-reviews/async-scripts', $scripts ) ) ) {
35
+            $tag = str_replace( ' src=', ' async src=', $tag );
36 36
         }
37
-        if (in_array($handle, apply_filters('site-reviews/defer-scripts', $scripts))) {
38
-            $tag = str_replace(' src=', ' defer src=', $tag);
37
+        if( in_array( $handle, apply_filters( 'site-reviews/defer-scripts', $scripts ) ) ) {
38
+            $tag = str_replace( ' src=', ' defer src=', $tag );
39 39
         }
40 40
         return $tag;
41 41
     }
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
      * @return array
45 45
      * @filter site-reviews/config/forms/submission-form
46 46
      */
47
-    public function filterFieldOrder(array $config)
47
+    public function filterFieldOrder( array $config )
48 48
     {
49
-        $order = (array) apply_filters('site-reviews/submission-form/order', array_keys($config));
50
-        return array_intersect_key(array_merge(array_flip($order), $config), $config);
49
+        $order = (array)apply_filters( 'site-reviews/submission-form/order', array_keys( $config ) );
50
+        return array_intersect_key( array_merge( array_flip( $order ), $config ), $config );
51 51
     }
52 52
 
53 53
     /**
@@ -55,18 +55,18 @@  discard block
 block discarded – undo
55 55
      * @return string
56 56
      * @filter site-reviews/render/view
57 57
      */
58
-    public function filterRenderView($view)
58
+    public function filterRenderView( $view )
59 59
     {
60
-        return glsr(Style::class)->filterView($view);
60
+        return glsr( Style::class )->filterView( $view );
61 61
     }
62 62
 
63 63
     /**
64 64
      * @return void
65 65
      * @action site-reviews/builder
66 66
      */
67
-    public function modifyBuilder(Builder $instance)
67
+    public function modifyBuilder( Builder $instance )
68 68
     {
69
-        call_user_func_array([glsr(Style::class), 'modifyField'], [$instance]);
69
+        call_user_func_array( [glsr( Style::class ), 'modifyField'], [$instance] );
70 70
     }
71 71
 
72 72
     /**
@@ -75,18 +75,18 @@  discard block
 block discarded – undo
75 75
      */
76 76
     public function renderSchema()
77 77
     {
78
-        glsr(Schema::class)->render();
78
+        glsr( Schema::class )->render();
79 79
     }
80 80
 
81 81
     /**
82 82
      * @return CreateReview
83 83
      */
84
-    public function routerSubmitReview(array $request)
84
+    public function routerSubmitReview( array $request )
85 85
     {
86
-        $validated = glsr(ValidateReview::class)->validate($request);
87
-        $command = new CreateReview($validated->request);
88
-        if (empty($validated->error) && !$validated->recaptchaIsUnset) {
89
-            $this->execute($command);
86
+        $validated = glsr( ValidateReview::class )->validate( $request );
87
+        $command = new CreateReview( $validated->request );
88
+        if( empty($validated->error) && !$validated->recaptchaIsUnset ) {
89
+            $this->execute( $command );
90 90
         }
91 91
         return $command;
92 92
     }
Please login to merge, or discard this patch.
plugin/Controllers/AjaxController.php 2 patches
Indentation   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -14,164 +14,164 @@
 block discarded – undo
14 14
 
15 15
 class AjaxController extends Controller
16 16
 {
17
-    /**
18
-     * @return void
19
-     */
20
-    public function routerChangeStatus(array $request)
21
-    {
22
-        wp_send_json_success($this->execute(new ChangeStatus($request)));
23
-    }
17
+	/**
18
+	 * @return void
19
+	 */
20
+	public function routerChangeStatus(array $request)
21
+	{
22
+		wp_send_json_success($this->execute(new ChangeStatus($request)));
23
+	}
24 24
 
25
-    /**
26
-     * @return void
27
-     */
28
-    public function routerClearConsole()
29
-    {
30
-        glsr(AdminController::class)->routerClearConsole();
31
-        wp_send_json_success([
32
-            'console' => glsr(Console::class)->get(),
33
-            'notices' => glsr(Notice::class)->get(),
34
-        ]);
35
-    }
25
+	/**
26
+	 * @return void
27
+	 */
28
+	public function routerClearConsole()
29
+	{
30
+		glsr(AdminController::class)->routerClearConsole();
31
+		wp_send_json_success([
32
+			'console' => glsr(Console::class)->get(),
33
+			'notices' => glsr(Notice::class)->get(),
34
+		]);
35
+	}
36 36
 
37
-    /**
38
-     * @return void
39
-     */
40
-    public function routerCountReviews()
41
-    {
42
-        glsr(AdminController::class)->routerCountReviews();
43
-        wp_send_json_success([
44
-            'notices' => glsr(Notice::class)->get(),
45
-        ]);
46
-    }
37
+	/**
38
+	 * @return void
39
+	 */
40
+	public function routerCountReviews()
41
+	{
42
+		glsr(AdminController::class)->routerCountReviews();
43
+		wp_send_json_success([
44
+			'notices' => glsr(Notice::class)->get(),
45
+		]);
46
+	}
47 47
 
48
-    /**
49
-     * @return void
50
-     */
51
-    public function routerDismissNotice(array $request)
52
-    {
53
-        glsr(NoticeController::class)->routerDismissNotice($request);
54
-        wp_send_json_success();
55
-    }
48
+	/**
49
+	 * @return void
50
+	 */
51
+	public function routerDismissNotice(array $request)
52
+	{
53
+		glsr(NoticeController::class)->routerDismissNotice($request);
54
+		wp_send_json_success();
55
+	}
56 56
 
57
-    /**
58
-     * @return void
59
-     */
60
-    public function routerMceShortcode(array $request)
61
-    {
62
-        $shortcode = $request['shortcode'];
63
-        $response = false;
64
-        if (array_key_exists($shortcode, glsr()->mceShortcodes)) {
65
-            $data = glsr()->mceShortcodes[$shortcode];
66
-            if (!empty($data['errors'])) {
67
-                $data['btn_okay'] = [esc_html__('Okay', 'site-reviews')];
68
-            }
69
-            $response = [
70
-                'body' => $data['fields'],
71
-                'close' => $data['btn_close'],
72
-                'ok' => $data['btn_okay'],
73
-                'shortcode' => $shortcode,
74
-                'title' => $data['title'],
75
-            ];
76
-        }
77
-        wp_send_json_success($response);
78
-    }
57
+	/**
58
+	 * @return void
59
+	 */
60
+	public function routerMceShortcode(array $request)
61
+	{
62
+		$shortcode = $request['shortcode'];
63
+		$response = false;
64
+		if (array_key_exists($shortcode, glsr()->mceShortcodes)) {
65
+			$data = glsr()->mceShortcodes[$shortcode];
66
+			if (!empty($data['errors'])) {
67
+				$data['btn_okay'] = [esc_html__('Okay', 'site-reviews')];
68
+			}
69
+			$response = [
70
+				'body' => $data['fields'],
71
+				'close' => $data['btn_close'],
72
+				'ok' => $data['btn_okay'],
73
+				'shortcode' => $shortcode,
74
+				'title' => $data['title'],
75
+			];
76
+		}
77
+		wp_send_json_success($response);
78
+	}
79 79
 
80
-    /**
81
-     * @return void
82
-     */
83
-    public function routerFetchConsole()
84
-    {
85
-        glsr(AdminController::class)->routerFetchConsole();
86
-        wp_send_json_success([
87
-            'console' => glsr(Console::class)->get(),
88
-            'notices' => glsr(Notice::class)->get(),
89
-        ]);
90
-    }
80
+	/**
81
+	 * @return void
82
+	 */
83
+	public function routerFetchConsole()
84
+	{
85
+		glsr(AdminController::class)->routerFetchConsole();
86
+		wp_send_json_success([
87
+			'console' => glsr(Console::class)->get(),
88
+			'notices' => glsr(Notice::class)->get(),
89
+		]);
90
+	}
91 91
 
92
-    /**
93
-     * @return void
94
-     */
95
-    public function routerSearchPosts(array $request)
96
-    {
97
-        $results = glsr(Database::class)->searchPosts($request['search']);
98
-        wp_send_json_success([
99
-            'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>',
100
-            'items' => $results,
101
-        ]);
102
-    }
92
+	/**
93
+	 * @return void
94
+	 */
95
+	public function routerSearchPosts(array $request)
96
+	{
97
+		$results = glsr(Database::class)->searchPosts($request['search']);
98
+		wp_send_json_success([
99
+			'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>',
100
+			'items' => $results,
101
+		]);
102
+	}
103 103
 
104
-    /**
105
-     * @return void
106
-     */
107
-    public function routerSearchTranslations(array $request)
108
-    {
109
-        if (empty($request['exclude'])) {
110
-            $request['exclude'] = [];
111
-        }
112
-        $results = glsr(Translation::class)
113
-            ->search($request['search'])
114
-            ->exclude()
115
-            ->exclude($request['exclude'])
116
-            ->renderResults();
117
-        wp_send_json_success([
118
-            'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>',
119
-            'items' => $results,
120
-        ]);
121
-    }
104
+	/**
105
+	 * @return void
106
+	 */
107
+	public function routerSearchTranslations(array $request)
108
+	{
109
+		if (empty($request['exclude'])) {
110
+			$request['exclude'] = [];
111
+		}
112
+		$results = glsr(Translation::class)
113
+			->search($request['search'])
114
+			->exclude()
115
+			->exclude($request['exclude'])
116
+			->renderResults();
117
+		wp_send_json_success([
118
+			'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>',
119
+			'items' => $results,
120
+		]);
121
+	}
122 122
 
123
-    /**
124
-     * @return void
125
-     */
126
-    public function routerSubmitReview(array $request)
127
-    {
128
-        $command = glsr(PublicController::class)->routerSubmitReview($request);
129
-        $redirect = trim(strval(get_post_meta($command->post_id, 'redirect_to', true)));
130
-        $redirect = apply_filters('site-reviews/review/redirect', $redirect, $command);
131
-        $data = [
132
-            'errors' => glsr()->sessionGet($command->form_id.'errors', false),
133
-            'message' => glsr()->sessionGet($command->form_id.'message', ''),
134
-            'recaptcha' => glsr()->sessionGet($command->form_id.'recaptcha', false),
135
-            'redirect' => $redirect,
136
-        ];
137
-        if (false === $data['errors']) {
138
-            glsr()->sessionClear();
139
-            wp_send_json_success($data);
140
-        }
141
-        wp_send_json_error($data);
142
-    }
123
+	/**
124
+	 * @return void
125
+	 */
126
+	public function routerSubmitReview(array $request)
127
+	{
128
+		$command = glsr(PublicController::class)->routerSubmitReview($request);
129
+		$redirect = trim(strval(get_post_meta($command->post_id, 'redirect_to', true)));
130
+		$redirect = apply_filters('site-reviews/review/redirect', $redirect, $command);
131
+		$data = [
132
+			'errors' => glsr()->sessionGet($command->form_id.'errors', false),
133
+			'message' => glsr()->sessionGet($command->form_id.'message', ''),
134
+			'recaptcha' => glsr()->sessionGet($command->form_id.'recaptcha', false),
135
+			'redirect' => $redirect,
136
+		];
137
+		if (false === $data['errors']) {
138
+			glsr()->sessionClear();
139
+			wp_send_json_success($data);
140
+		}
141
+		wp_send_json_error($data);
142
+	}
143 143
 
144
-    /**
145
-     * @return void
146
-     */
147
-    public function routerFetchPagedReviews(array $request)
148
-    {
149
-        $urlQuery = [];
150
-        parse_str(parse_url(Arr::get($request, 'url'), PHP_URL_QUERY), $urlQuery);
151
-        $args = [
152
-            'paged' => Arr::get($urlQuery, glsr()->constant('PAGED_QUERY_VAR'), 1),
153
-            'pagedUrl' => home_url(parse_url(Arr::get($request, 'url'), PHP_URL_PATH)),
154
-            'pagination' => 'ajax',
155
-            'schema' => false,
156
-        ];
157
-        $atts = (array) json_decode(Arr::get($request, 'atts'));
158
-        $atts = glsr(SiteReviewsShortcode::class)->normalizeAtts($atts);
159
-        $html = glsr(SiteReviewsPartial::class)->build(wp_parse_args($args, $atts));
160
-        return wp_send_json_success([
161
-            'pagination' => $html->getPagination(),
162
-            'reviews' => $html->getReviews(),
163
-        ]);
164
-    }
144
+	/**
145
+	 * @return void
146
+	 */
147
+	public function routerFetchPagedReviews(array $request)
148
+	{
149
+		$urlQuery = [];
150
+		parse_str(parse_url(Arr::get($request, 'url'), PHP_URL_QUERY), $urlQuery);
151
+		$args = [
152
+			'paged' => Arr::get($urlQuery, glsr()->constant('PAGED_QUERY_VAR'), 1),
153
+			'pagedUrl' => home_url(parse_url(Arr::get($request, 'url'), PHP_URL_PATH)),
154
+			'pagination' => 'ajax',
155
+			'schema' => false,
156
+		];
157
+		$atts = (array) json_decode(Arr::get($request, 'atts'));
158
+		$atts = glsr(SiteReviewsShortcode::class)->normalizeAtts($atts);
159
+		$html = glsr(SiteReviewsPartial::class)->build(wp_parse_args($args, $atts));
160
+		return wp_send_json_success([
161
+			'pagination' => $html->getPagination(),
162
+			'reviews' => $html->getReviews(),
163
+		]);
164
+	}
165 165
 
166
-    /**
167
-     * @return void
168
-     */
169
-    public function routerTogglePinned(array $request)
170
-    {
171
-        $isPinned = $this->execute(new TogglePinned($request));
172
-        wp_send_json_success([
173
-            'notices' => glsr(Notice::class)->get(),
174
-            'pinned' => $isPinned,
175
-        ]);
176
-    }
166
+	/**
167
+	 * @return void
168
+	 */
169
+	public function routerTogglePinned(array $request)
170
+	{
171
+		$isPinned = $this->execute(new TogglePinned($request));
172
+		wp_send_json_success([
173
+			'notices' => glsr(Notice::class)->get(),
174
+			'pinned' => $isPinned,
175
+		]);
176
+	}
177 177
 }
Please login to merge, or discard this patch.
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -17,9 +17,9 @@  discard block
 block discarded – undo
17 17
     /**
18 18
      * @return void
19 19
      */
20
-    public function routerChangeStatus(array $request)
20
+    public function routerChangeStatus( array $request )
21 21
     {
22
-        wp_send_json_success($this->execute(new ChangeStatus($request)));
22
+        wp_send_json_success( $this->execute( new ChangeStatus( $request ) ) );
23 23
     }
24 24
 
25 25
     /**
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
      */
28 28
     public function routerClearConsole()
29 29
     {
30
-        glsr(AdminController::class)->routerClearConsole();
31
-        wp_send_json_success([
32
-            'console' => glsr(Console::class)->get(),
33
-            'notices' => glsr(Notice::class)->get(),
34
-        ]);
30
+        glsr( AdminController::class )->routerClearConsole();
31
+        wp_send_json_success( [
32
+            'console' => glsr( Console::class )->get(),
33
+            'notices' => glsr( Notice::class )->get(),
34
+        ] );
35 35
     }
36 36
 
37 37
     /**
@@ -39,32 +39,32 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public function routerCountReviews()
41 41
     {
42
-        glsr(AdminController::class)->routerCountReviews();
43
-        wp_send_json_success([
44
-            'notices' => glsr(Notice::class)->get(),
45
-        ]);
42
+        glsr( AdminController::class )->routerCountReviews();
43
+        wp_send_json_success( [
44
+            'notices' => glsr( Notice::class )->get(),
45
+        ] );
46 46
     }
47 47
 
48 48
     /**
49 49
      * @return void
50 50
      */
51
-    public function routerDismissNotice(array $request)
51
+    public function routerDismissNotice( array $request )
52 52
     {
53
-        glsr(NoticeController::class)->routerDismissNotice($request);
53
+        glsr( NoticeController::class )->routerDismissNotice( $request );
54 54
         wp_send_json_success();
55 55
     }
56 56
 
57 57
     /**
58 58
      * @return void
59 59
      */
60
-    public function routerMceShortcode(array $request)
60
+    public function routerMceShortcode( array $request )
61 61
     {
62 62
         $shortcode = $request['shortcode'];
63 63
         $response = false;
64
-        if (array_key_exists($shortcode, glsr()->mceShortcodes)) {
64
+        if( array_key_exists( $shortcode, glsr()->mceShortcodes ) ) {
65 65
             $data = glsr()->mceShortcodes[$shortcode];
66
-            if (!empty($data['errors'])) {
67
-                $data['btn_okay'] = [esc_html__('Okay', 'site-reviews')];
66
+            if( !empty($data['errors']) ) {
67
+                $data['btn_okay'] = [esc_html__( 'Okay', 'site-reviews' )];
68 68
             }
69 69
             $response = [
70 70
                 'body' => $data['fields'],
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
                 'title' => $data['title'],
75 75
             ];
76 76
         }
77
-        wp_send_json_success($response);
77
+        wp_send_json_success( $response );
78 78
     }
79 79
 
80 80
     /**
@@ -82,96 +82,96 @@  discard block
 block discarded – undo
82 82
      */
83 83
     public function routerFetchConsole()
84 84
     {
85
-        glsr(AdminController::class)->routerFetchConsole();
86
-        wp_send_json_success([
87
-            'console' => glsr(Console::class)->get(),
88
-            'notices' => glsr(Notice::class)->get(),
89
-        ]);
85
+        glsr( AdminController::class )->routerFetchConsole();
86
+        wp_send_json_success( [
87
+            'console' => glsr( Console::class )->get(),
88
+            'notices' => glsr( Notice::class )->get(),
89
+        ] );
90 90
     }
91 91
 
92 92
     /**
93 93
      * @return void
94 94
      */
95
-    public function routerSearchPosts(array $request)
95
+    public function routerSearchPosts( array $request )
96 96
     {
97
-        $results = glsr(Database::class)->searchPosts($request['search']);
98
-        wp_send_json_success([
99
-            'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>',
97
+        $results = glsr( Database::class )->searchPosts( $request['search'] );
98
+        wp_send_json_success( [
99
+            'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>',
100 100
             'items' => $results,
101
-        ]);
101
+        ] );
102 102
     }
103 103
 
104 104
     /**
105 105
      * @return void
106 106
      */
107
-    public function routerSearchTranslations(array $request)
107
+    public function routerSearchTranslations( array $request )
108 108
     {
109
-        if (empty($request['exclude'])) {
109
+        if( empty($request['exclude']) ) {
110 110
             $request['exclude'] = [];
111 111
         }
112
-        $results = glsr(Translation::class)
113
-            ->search($request['search'])
112
+        $results = glsr( Translation::class )
113
+            ->search( $request['search'] )
114 114
             ->exclude()
115
-            ->exclude($request['exclude'])
115
+            ->exclude( $request['exclude'] )
116 116
             ->renderResults();
117
-        wp_send_json_success([
118
-            'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>',
117
+        wp_send_json_success( [
118
+            'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>',
119 119
             'items' => $results,
120
-        ]);
120
+        ] );
121 121
     }
122 122
 
123 123
     /**
124 124
      * @return void
125 125
      */
126
-    public function routerSubmitReview(array $request)
126
+    public function routerSubmitReview( array $request )
127 127
     {
128
-        $command = glsr(PublicController::class)->routerSubmitReview($request);
129
-        $redirect = trim(strval(get_post_meta($command->post_id, 'redirect_to', true)));
130
-        $redirect = apply_filters('site-reviews/review/redirect', $redirect, $command);
128
+        $command = glsr( PublicController::class )->routerSubmitReview( $request );
129
+        $redirect = trim( strval( get_post_meta( $command->post_id, 'redirect_to', true ) ) );
130
+        $redirect = apply_filters( 'site-reviews/review/redirect', $redirect, $command );
131 131
         $data = [
132
-            'errors' => glsr()->sessionGet($command->form_id.'errors', false),
133
-            'message' => glsr()->sessionGet($command->form_id.'message', ''),
134
-            'recaptcha' => glsr()->sessionGet($command->form_id.'recaptcha', false),
132
+            'errors' => glsr()->sessionGet( $command->form_id.'errors', false ),
133
+            'message' => glsr()->sessionGet( $command->form_id.'message', '' ),
134
+            'recaptcha' => glsr()->sessionGet( $command->form_id.'recaptcha', false ),
135 135
             'redirect' => $redirect,
136 136
         ];
137
-        if (false === $data['errors']) {
137
+        if( false === $data['errors'] ) {
138 138
             glsr()->sessionClear();
139
-            wp_send_json_success($data);
139
+            wp_send_json_success( $data );
140 140
         }
141
-        wp_send_json_error($data);
141
+        wp_send_json_error( $data );
142 142
     }
143 143
 
144 144
     /**
145 145
      * @return void
146 146
      */
147
-    public function routerFetchPagedReviews(array $request)
147
+    public function routerFetchPagedReviews( array $request )
148 148
     {
149 149
         $urlQuery = [];
150
-        parse_str(parse_url(Arr::get($request, 'url'), PHP_URL_QUERY), $urlQuery);
150
+        parse_str( parse_url( Arr::get( $request, 'url' ), PHP_URL_QUERY ), $urlQuery );
151 151
         $args = [
152
-            'paged' => Arr::get($urlQuery, glsr()->constant('PAGED_QUERY_VAR'), 1),
153
-            'pagedUrl' => home_url(parse_url(Arr::get($request, 'url'), PHP_URL_PATH)),
152
+            'paged' => Arr::get( $urlQuery, glsr()->constant( 'PAGED_QUERY_VAR' ), 1 ),
153
+            'pagedUrl' => home_url( parse_url( Arr::get( $request, 'url' ), PHP_URL_PATH ) ),
154 154
             'pagination' => 'ajax',
155 155
             'schema' => false,
156 156
         ];
157
-        $atts = (array) json_decode(Arr::get($request, 'atts'));
158
-        $atts = glsr(SiteReviewsShortcode::class)->normalizeAtts($atts);
159
-        $html = glsr(SiteReviewsPartial::class)->build(wp_parse_args($args, $atts));
160
-        return wp_send_json_success([
157
+        $atts = (array)json_decode( Arr::get( $request, 'atts' ) );
158
+        $atts = glsr( SiteReviewsShortcode::class )->normalizeAtts( $atts );
159
+        $html = glsr( SiteReviewsPartial::class )->build( wp_parse_args( $args, $atts ) );
160
+        return wp_send_json_success( [
161 161
             'pagination' => $html->getPagination(),
162 162
             'reviews' => $html->getReviews(),
163
-        ]);
163
+        ] );
164 164
     }
165 165
 
166 166
     /**
167 167
      * @return void
168 168
      */
169
-    public function routerTogglePinned(array $request)
169
+    public function routerTogglePinned( array $request )
170 170
     {
171
-        $isPinned = $this->execute(new TogglePinned($request));
172
-        wp_send_json_success([
173
-            'notices' => glsr(Notice::class)->get(),
171
+        $isPinned = $this->execute( new TogglePinned( $request ) );
172
+        wp_send_json_success( [
173
+            'notices' => glsr( Notice::class )->get(),
174 174
             'pinned' => $isPinned,
175
-        ]);
175
+        ] );
176 176
     }
177 177
 }
Please login to merge, or discard this patch.
plugin/Database/QueryBuilder.php 2 patches
Indentation   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -12,162 +12,162 @@
 block discarded – undo
12 12
 
13 13
 class QueryBuilder
14 14
 {
15
-    /**
16
-     * Build a WP_Query meta_query/tax_query.
17
-     * @return array
18
-     */
19
-    public function buildQuery(array $keys = [], array $values = [])
20
-    {
21
-        $queries = [];
22
-        foreach ($keys as $key) {
23
-            if (!array_key_exists($key, $values)) {
24
-                continue;
25
-            }
26
-            $methodName = Helper::buildMethodName($key, __FUNCTION__);
27
-            if (!method_exists($this, $methodName)) {
28
-                continue;
29
-            }
30
-            $query = call_user_func([$this, $methodName], $values[$key]);
31
-            if (is_array($query)) {
32
-                $queries[] = $query;
33
-            }
34
-        }
35
-        return $queries;
36
-    }
15
+	/**
16
+	 * Build a WP_Query meta_query/tax_query.
17
+	 * @return array
18
+	 */
19
+	public function buildQuery(array $keys = [], array $values = [])
20
+	{
21
+		$queries = [];
22
+		foreach ($keys as $key) {
23
+			if (!array_key_exists($key, $values)) {
24
+				continue;
25
+			}
26
+			$methodName = Helper::buildMethodName($key, __FUNCTION__);
27
+			if (!method_exists($this, $methodName)) {
28
+				continue;
29
+			}
30
+			$query = call_user_func([$this, $methodName], $values[$key]);
31
+			if (is_array($query)) {
32
+				$queries[] = $query;
33
+			}
34
+		}
35
+		return $queries;
36
+	}
37 37
 
38
-    /**
39
-     * @return string
40
-     */
41
-    public function buildSqlLines(array $values, array $conditions)
42
-    {
43
-        $string = '';
44
-        $values = array_filter($values);
45
-        foreach ($conditions as $key => $value) {
46
-            if (!isset($values[$key])) {
47
-                continue;
48
-            }
49
-            $values[$key] = implode(',', (array) $values[$key]);
50
-            $string.= Str::contains($value, '%s')
51
-                ? sprintf($value, strval($values[$key]))
52
-                : $value;
53
-        }
54
-        return $string;
55
-    }
38
+	/**
39
+	 * @return string
40
+	 */
41
+	public function buildSqlLines(array $values, array $conditions)
42
+	{
43
+		$string = '';
44
+		$values = array_filter($values);
45
+		foreach ($conditions as $key => $value) {
46
+			if (!isset($values[$key])) {
47
+				continue;
48
+			}
49
+			$values[$key] = implode(',', (array) $values[$key]);
50
+			$string.= Str::contains($value, '%s')
51
+				? sprintf($value, strval($values[$key]))
52
+				: $value;
53
+		}
54
+		return $string;
55
+	}
56 56
 
57
-    /**
58
-     * Build a SQL 'OR' string from an array.
59
-     * @param string|array $values
60
-     * @param string $sprintfFormat
61
-     * @return string
62
-     */
63
-    public function buildSqlOr($values, $sprintfFormat)
64
-    {
65
-        if (!is_array($values)) {
66
-            $values = explode(',', $values);
67
-        }
68
-        $values = array_filter(array_map('trim', (array) $values));
69
-        $values = array_map(function ($value) use ($sprintfFormat) {
70
-            return sprintf($sprintfFormat, $value);
71
-        }, $values);
72
-        return implode(' OR ', $values);
73
-    }
57
+	/**
58
+	 * Build a SQL 'OR' string from an array.
59
+	 * @param string|array $values
60
+	 * @param string $sprintfFormat
61
+	 * @return string
62
+	 */
63
+	public function buildSqlOr($values, $sprintfFormat)
64
+	{
65
+		if (!is_array($values)) {
66
+			$values = explode(',', $values);
67
+		}
68
+		$values = array_filter(array_map('trim', (array) $values));
69
+		$values = array_map(function ($value) use ($sprintfFormat) {
70
+			return sprintf($sprintfFormat, $value);
71
+		}, $values);
72
+		return implode(' OR ', $values);
73
+	}
74 74
 
75
-    /**
76
-     * Search SQL filter for matching against post title only.
77
-     * @see http://wordpress.stackexchange.com/a/11826/1685
78
-     * @param string $search
79
-     * @return string
80
-     * @filter posts_search
81
-     */
82
-    public function filterSearchByTitle($search, WP_Query $query)
83
-    {
84
-        if (empty($search) || empty($query->get('search_terms'))) {
85
-            return $search;
86
-        }
87
-        global $wpdb;
88
-        $n = empty($query->get('exact'))
89
-            ? '%'
90
-            : '';
91
-        $search = [];
92
-        foreach ((array) $query->get('search_terms') as $term) {
93
-            $search[] = $wpdb->prepare("{$wpdb->posts}.post_title LIKE %s", $n.$wpdb->esc_like($term).$n);
94
-        }
95
-        if (!is_user_logged_in()) {
96
-            $search[] = "{$wpdb->posts}.post_password = ''";
97
-        }
98
-        return ' AND '.implode(' AND ', $search);
99
-    }
75
+	/**
76
+	 * Search SQL filter for matching against post title only.
77
+	 * @see http://wordpress.stackexchange.com/a/11826/1685
78
+	 * @param string $search
79
+	 * @return string
80
+	 * @filter posts_search
81
+	 */
82
+	public function filterSearchByTitle($search, WP_Query $query)
83
+	{
84
+		if (empty($search) || empty($query->get('search_terms'))) {
85
+			return $search;
86
+		}
87
+		global $wpdb;
88
+		$n = empty($query->get('exact'))
89
+			? '%'
90
+			: '';
91
+		$search = [];
92
+		foreach ((array) $query->get('search_terms') as $term) {
93
+			$search[] = $wpdb->prepare("{$wpdb->posts}.post_title LIKE %s", $n.$wpdb->esc_like($term).$n);
94
+		}
95
+		if (!is_user_logged_in()) {
96
+			$search[] = "{$wpdb->posts}.post_password = ''";
97
+		}
98
+		return ' AND '.implode(' AND ', $search);
99
+	}
100 100
 
101
-    /**
102
-     * Get the current page number from the global query.
103
-     * @param bool $isEnabled
104
-     * @return int
105
-     */
106
-    public function getPaged($isEnabled = true)
107
-    {
108
-        return $isEnabled
109
-            ? max(1, intval(filter_input(INPUT_GET, glsr()->constant('PAGED_QUERY_VAR'))))
110
-            : 1;
111
-    }
101
+	/**
102
+	 * Get the current page number from the global query.
103
+	 * @param bool $isEnabled
104
+	 * @return int
105
+	 */
106
+	public function getPaged($isEnabled = true)
107
+	{
108
+		return $isEnabled
109
+			? max(1, intval(filter_input(INPUT_GET, glsr()->constant('PAGED_QUERY_VAR'))))
110
+			: 1;
111
+	}
112 112
 
113
-    /**
114
-     * @param string $value
115
-     * @return void|array
116
-     */
117
-    protected function buildQueryAssignedTo($value)
118
-    {
119
-        if (!empty($value)) {
120
-            $postIds = Arr::convertStringToArray($value, 'is_numeric');
121
-            return [
122
-                'compare' => 'IN',
123
-                'key' => '_assigned_to',
124
-                'value' => glsr(Polylang::class)->getPostIds($postIds),
125
-            ];
126
-        }
127
-    }
113
+	/**
114
+	 * @param string $value
115
+	 * @return void|array
116
+	 */
117
+	protected function buildQueryAssignedTo($value)
118
+	{
119
+		if (!empty($value)) {
120
+			$postIds = Arr::convertStringToArray($value, 'is_numeric');
121
+			return [
122
+				'compare' => 'IN',
123
+				'key' => '_assigned_to',
124
+				'value' => glsr(Polylang::class)->getPostIds($postIds),
125
+			];
126
+		}
127
+	}
128 128
 
129
-    /**
130
-     * @param array $value
131
-     * @return void|array
132
-     */
133
-    protected function buildQueryCategory($value)
134
-    {
135
-        if (!empty($value)) {
136
-            return [
137
-                'field' => 'term_id',
138
-                'taxonomy' => Application::TAXONOMY,
139
-                'terms' => $value,
140
-            ];
141
-        }
142
-    }
129
+	/**
130
+	 * @param array $value
131
+	 * @return void|array
132
+	 */
133
+	protected function buildQueryCategory($value)
134
+	{
135
+		if (!empty($value)) {
136
+			return [
137
+				'field' => 'term_id',
138
+				'taxonomy' => Application::TAXONOMY,
139
+				'terms' => $value,
140
+			];
141
+		}
142
+	}
143 143
 
144
-    /**
145
-     * @param string $value
146
-     * @return void|array
147
-     */
148
-    protected function buildQueryRating($value)
149
-    {
150
-        if (is_numeric($value)
151
-            && in_array(intval($value), range(1, glsr()->constant('MAX_RATING', Rating::class)))) {
152
-            return [
153
-                'compare' => '>=',
154
-                'key' => '_rating',
155
-                'value' => $value,
156
-            ];
157
-        }
158
-    }
144
+	/**
145
+	 * @param string $value
146
+	 * @return void|array
147
+	 */
148
+	protected function buildQueryRating($value)
149
+	{
150
+		if (is_numeric($value)
151
+			&& in_array(intval($value), range(1, glsr()->constant('MAX_RATING', Rating::class)))) {
152
+			return [
153
+				'compare' => '>=',
154
+				'key' => '_rating',
155
+				'value' => $value,
156
+			];
157
+		}
158
+	}
159 159
 
160
-    /**
161
-     * @param string $value
162
-     * @return void|array
163
-     */
164
-    protected function buildQueryType($value)
165
-    {
166
-        if (!in_array($value, ['', 'all'])) {
167
-            return [
168
-                'key' => '_review_type',
169
-                'value' => $value,
170
-            ];
171
-        }
172
-    }
160
+	/**
161
+	 * @param string $value
162
+	 * @return void|array
163
+	 */
164
+	protected function buildQueryType($value)
165
+	{
166
+		if (!in_array($value, ['', 'all'])) {
167
+			return [
168
+				'key' => '_review_type',
169
+				'value' => $value,
170
+			];
171
+		}
172
+	}
173 173
 }
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -16,19 +16,19 @@  discard block
 block discarded – undo
16 16
      * Build a WP_Query meta_query/tax_query.
17 17
      * @return array
18 18
      */
19
-    public function buildQuery(array $keys = [], array $values = [])
19
+    public function buildQuery( array $keys = [], array $values = [] )
20 20
     {
21 21
         $queries = [];
22
-        foreach ($keys as $key) {
23
-            if (!array_key_exists($key, $values)) {
22
+        foreach( $keys as $key ) {
23
+            if( !array_key_exists( $key, $values ) ) {
24 24
                 continue;
25 25
             }
26
-            $methodName = Helper::buildMethodName($key, __FUNCTION__);
27
-            if (!method_exists($this, $methodName)) {
26
+            $methodName = Helper::buildMethodName( $key, __FUNCTION__ );
27
+            if( !method_exists( $this, $methodName ) ) {
28 28
                 continue;
29 29
             }
30
-            $query = call_user_func([$this, $methodName], $values[$key]);
31
-            if (is_array($query)) {
30
+            $query = call_user_func( [$this, $methodName], $values[$key] );
31
+            if( is_array( $query ) ) {
32 32
                 $queries[] = $query;
33 33
             }
34 34
         }
@@ -38,17 +38,17 @@  discard block
 block discarded – undo
38 38
     /**
39 39
      * @return string
40 40
      */
41
-    public function buildSqlLines(array $values, array $conditions)
41
+    public function buildSqlLines( array $values, array $conditions )
42 42
     {
43 43
         $string = '';
44
-        $values = array_filter($values);
45
-        foreach ($conditions as $key => $value) {
46
-            if (!isset($values[$key])) {
44
+        $values = array_filter( $values );
45
+        foreach( $conditions as $key => $value ) {
46
+            if( !isset($values[$key]) ) {
47 47
                 continue;
48 48
             }
49
-            $values[$key] = implode(',', (array) $values[$key]);
50
-            $string.= Str::contains($value, '%s')
51
-                ? sprintf($value, strval($values[$key]))
49
+            $values[$key] = implode( ',', (array)$values[$key] );
50
+            $string .= Str::contains( $value, '%s' )
51
+                ? sprintf( $value, strval( $values[$key] ) )
52 52
                 : $value;
53 53
         }
54 54
         return $string;
@@ -60,16 +60,16 @@  discard block
 block discarded – undo
60 60
      * @param string $sprintfFormat
61 61
      * @return string
62 62
      */
63
-    public function buildSqlOr($values, $sprintfFormat)
63
+    public function buildSqlOr( $values, $sprintfFormat )
64 64
     {
65
-        if (!is_array($values)) {
66
-            $values = explode(',', $values);
65
+        if( !is_array( $values ) ) {
66
+            $values = explode( ',', $values );
67 67
         }
68
-        $values = array_filter(array_map('trim', (array) $values));
69
-        $values = array_map(function ($value) use ($sprintfFormat) {
70
-            return sprintf($sprintfFormat, $value);
71
-        }, $values);
72
-        return implode(' OR ', $values);
68
+        $values = array_filter( array_map( 'trim', (array)$values ) );
69
+        $values = array_map( function( $value ) use ($sprintfFormat) {
70
+            return sprintf( $sprintfFormat, $value );
71
+        }, $values );
72
+        return implode( ' OR ', $values );
73 73
     }
74 74
 
75 75
     /**
@@ -79,23 +79,23 @@  discard block
 block discarded – undo
79 79
      * @return string
80 80
      * @filter posts_search
81 81
      */
82
-    public function filterSearchByTitle($search, WP_Query $query)
82
+    public function filterSearchByTitle( $search, WP_Query $query )
83 83
     {
84
-        if (empty($search) || empty($query->get('search_terms'))) {
84
+        if( empty($search) || empty($query->get( 'search_terms' )) ) {
85 85
             return $search;
86 86
         }
87 87
         global $wpdb;
88
-        $n = empty($query->get('exact'))
88
+        $n = empty($query->get( 'exact' ))
89 89
             ? '%'
90 90
             : '';
91 91
         $search = [];
92
-        foreach ((array) $query->get('search_terms') as $term) {
93
-            $search[] = $wpdb->prepare("{$wpdb->posts}.post_title LIKE %s", $n.$wpdb->esc_like($term).$n);
92
+        foreach( (array)$query->get( 'search_terms' ) as $term ) {
93
+            $search[] = $wpdb->prepare( "{$wpdb->posts}.post_title LIKE %s", $n.$wpdb->esc_like( $term ).$n );
94 94
         }
95
-        if (!is_user_logged_in()) {
95
+        if( !is_user_logged_in() ) {
96 96
             $search[] = "{$wpdb->posts}.post_password = ''";
97 97
         }
98
-        return ' AND '.implode(' AND ', $search);
98
+        return ' AND '.implode( ' AND ', $search );
99 99
     }
100 100
 
101 101
     /**
@@ -103,10 +103,10 @@  discard block
 block discarded – undo
103 103
      * @param bool $isEnabled
104 104
      * @return int
105 105
      */
106
-    public function getPaged($isEnabled = true)
106
+    public function getPaged( $isEnabled = true )
107 107
     {
108 108
         return $isEnabled
109
-            ? max(1, intval(filter_input(INPUT_GET, glsr()->constant('PAGED_QUERY_VAR'))))
109
+            ? max( 1, intval( filter_input( INPUT_GET, glsr()->constant( 'PAGED_QUERY_VAR' ) ) ) )
110 110
             : 1;
111 111
     }
112 112
 
@@ -114,14 +114,14 @@  discard block
 block discarded – undo
114 114
      * @param string $value
115 115
      * @return void|array
116 116
      */
117
-    protected function buildQueryAssignedTo($value)
117
+    protected function buildQueryAssignedTo( $value )
118 118
     {
119
-        if (!empty($value)) {
120
-            $postIds = Arr::convertStringToArray($value, 'is_numeric');
119
+        if( !empty($value) ) {
120
+            $postIds = Arr::convertStringToArray( $value, 'is_numeric' );
121 121
             return [
122 122
                 'compare' => 'IN',
123 123
                 'key' => '_assigned_to',
124
-                'value' => glsr(Polylang::class)->getPostIds($postIds),
124
+                'value' => glsr( Polylang::class )->getPostIds( $postIds ),
125 125
             ];
126 126
         }
127 127
     }
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
      * @param array $value
131 131
      * @return void|array
132 132
      */
133
-    protected function buildQueryCategory($value)
133
+    protected function buildQueryCategory( $value )
134 134
     {
135
-        if (!empty($value)) {
135
+        if( !empty($value) ) {
136 136
             return [
137 137
                 'field' => 'term_id',
138 138
                 'taxonomy' => Application::TAXONOMY,
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
      * @param string $value
146 146
      * @return void|array
147 147
      */
148
-    protected function buildQueryRating($value)
148
+    protected function buildQueryRating( $value )
149 149
     {
150
-        if (is_numeric($value)
151
-            && in_array(intval($value), range(1, glsr()->constant('MAX_RATING', Rating::class)))) {
150
+        if( is_numeric( $value )
151
+            && in_array( intval( $value ), range( 1, glsr()->constant( 'MAX_RATING', Rating::class ) ) ) ) {
152 152
             return [
153 153
                 'compare' => '>=',
154 154
                 'key' => '_rating',
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
      * @param string $value
162 162
      * @return void|array
163 163
      */
164
-    protected function buildQueryType($value)
164
+    protected function buildQueryType( $value )
165 165
     {
166
-        if (!in_array($value, ['', 'all'])) {
166
+        if( !in_array( $value, ['', 'all'] ) ) {
167 167
             return [
168 168
                 'key' => '_review_type',
169 169
                 'value' => $value,
Please login to merge, or discard this patch.
views/pages/settings/translations.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,20 +1,20 @@  discard block
 block discarded – undo
1
-<?php defined('WPINC') || die; ?>
1
+<?php defined( 'WPINC' ) || die; ?>
2 2
 
3 3
 <div class="glsr-strings-form">
4 4
     <div class="glsr-search-box" id="glsr-search-translations">
5
-        <span class="screen-reader-text"><?= __('Search for translatable text', 'site-reviews'); ?></span>
5
+        <span class="screen-reader-text"><?= __( 'Search for translatable text', 'site-reviews' ); ?></span>
6 6
         <div class="glsr-spinner">
7 7
             <span class="spinner"></span>
8 8
         </div>
9
-        <input type="search" class="glsr-search-input" autocomplete="off" placeholder="<?= __('Search here for text to translate...', 'site-reviews'); ?>">
10
-        <?php wp_nonce_field('search-translations', '_search_nonce', false); ?>
9
+        <input type="search" class="glsr-search-input" autocomplete="off" placeholder="<?= __( 'Search here for text to translate...', 'site-reviews' ); ?>">
10
+        <?php wp_nonce_field( 'search-translations', '_search_nonce', false ); ?>
11 11
         <div class="glsr-search-results" data-prefix="{{ database_key }}"></div>
12 12
     </div>
13 13
     <table class="glsr-strings-table wp-list-table widefat striped {{ class }}">
14 14
         <thead>
15 15
             <tr>
16
-                <th scope="col" class="manage-column column-primary"><?= __('Original Text', 'site-reviews'); ?></th>
17
-                <th scope="col" class="manage-column"><?= __('Custom Translation', 'site-reviews'); ?></th>
16
+                <th scope="col" class="manage-column column-primary"><?= __( 'Original Text', 'site-reviews' ); ?></th>
17
+                <th scope="col" class="manage-column"><?= __( 'Custom Translation', 'site-reviews' ); ?></th>
18 18
             </tr>
19 19
         </thead>
20 20
         <tbody>{{ translations }}</tbody>
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
 </div>
24 24
 
25 25
 <script type="text/html" id="tmpl-glsr-string-plural">
26
-<?php include glsr()->path('views/partials/translations/plural.php'); ?>
26
+<?php include glsr()->path( 'views/partials/translations/plural.php' ); ?>
27 27
 </script>
28 28
 <script type="text/html" id="tmpl-glsr-string-single">
29
-<?php include glsr()->path('views/partials/translations/single.php'); ?>
29
+<?php include glsr()->path( 'views/partials/translations/single.php' ); ?>
30 30
 </script>
Please login to merge, or discard this patch.
plugin/Database/Cache.php 2 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -6,63 +6,63 @@
 block discarded – undo
6 6
 
7 7
 class Cache
8 8
 {
9
-    /**
10
-     * @return array
11
-     */
12
-    public function getCloudflareIps()
13
-    {
14
-        if (false === ($ipAddresses = get_transient(Application::ID.'_cloudflare_ips'))) {
15
-            $ipAddresses = array_fill_keys(['v4', 'v6'], []);
16
-            foreach (array_keys($ipAddresses) as $version) {
17
-                $url = 'https://www.cloudflare.com/ips-'.$version;
18
-                $response = wp_remote_get($url, ['sslverify' => false]);
19
-                if (is_wp_error($response)) {
20
-                    glsr_log()->error($response->get_error_message());
21
-                    continue;
22
-                }
23
-                if ('200' != ($statusCode = wp_remote_retrieve_response_code($response))) {
24
-                    glsr_log()->error('Unable to connect to '.$url.' ['.$statusCode.']');
25
-                    continue;
26
-                }
27
-                $ipAddresses[$version] = array_filter(
28
-                    (array) preg_split('/\R/', wp_remote_retrieve_body($response))
29
-                );
30
-            }
31
-            set_transient(Application::ID.'_cloudflare_ips', $ipAddresses, WEEK_IN_SECONDS);
32
-        }
33
-        return $ipAddresses;
34
-    }
9
+	/**
10
+	 * @return array
11
+	 */
12
+	public function getCloudflareIps()
13
+	{
14
+		if (false === ($ipAddresses = get_transient(Application::ID.'_cloudflare_ips'))) {
15
+			$ipAddresses = array_fill_keys(['v4', 'v6'], []);
16
+			foreach (array_keys($ipAddresses) as $version) {
17
+				$url = 'https://www.cloudflare.com/ips-'.$version;
18
+				$response = wp_remote_get($url, ['sslverify' => false]);
19
+				if (is_wp_error($response)) {
20
+					glsr_log()->error($response->get_error_message());
21
+					continue;
22
+				}
23
+				if ('200' != ($statusCode = wp_remote_retrieve_response_code($response))) {
24
+					glsr_log()->error('Unable to connect to '.$url.' ['.$statusCode.']');
25
+					continue;
26
+				}
27
+				$ipAddresses[$version] = array_filter(
28
+					(array) preg_split('/\R/', wp_remote_retrieve_body($response))
29
+				);
30
+			}
31
+			set_transient(Application::ID.'_cloudflare_ips', $ipAddresses, WEEK_IN_SECONDS);
32
+		}
33
+		return $ipAddresses;
34
+	}
35 35
 
36
-    /**
37
-     * @param string $metaKey
38
-     * @return array
39
-     */
40
-    public function getReviewCountsFor($metaKey)
41
-    {
42
-        $counts = wp_cache_get(Application::ID, $metaKey.'_count');
43
-        if (false === $counts) {
44
-            $counts = [];
45
-            $results = glsr(SqlQueries::class)->getReviewCountsFor($metaKey);
46
-            foreach ($results as $result) {
47
-                $counts[$result->name] = $result->num_posts;
48
-            }
49
-            wp_cache_set(Application::ID, $counts, $metaKey.'_count');
50
-        }
51
-        return $counts;
52
-    }
36
+	/**
37
+	 * @param string $metaKey
38
+	 * @return array
39
+	 */
40
+	public function getReviewCountsFor($metaKey)
41
+	{
42
+		$counts = wp_cache_get(Application::ID, $metaKey.'_count');
43
+		if (false === $counts) {
44
+			$counts = [];
45
+			$results = glsr(SqlQueries::class)->getReviewCountsFor($metaKey);
46
+			foreach ($results as $result) {
47
+				$counts[$result->name] = $result->num_posts;
48
+			}
49
+			wp_cache_set(Application::ID, $counts, $metaKey.'_count');
50
+		}
51
+		return $counts;
52
+	}
53 53
 
54
-    /**
55
-     * @return string
56
-     */
57
-    public function getRemotePostTest()
58
-    {
59
-        if (false === ($test = get_transient(Application::ID.'_remote_post_test'))) {
60
-            $response = wp_remote_post('https://api.wordpress.org/stats/php/1.0/');
61
-            $test = !is_wp_error($response) && in_array($response['response']['code'], range(200, 299))
62
-                ? 'Works'
63
-                : 'Does not work';
64
-            set_transient(Application::ID.'_remote_post_test', $test, WEEK_IN_SECONDS);
65
-        }
66
-        return $test;
67
-    }
54
+	/**
55
+	 * @return string
56
+	 */
57
+	public function getRemotePostTest()
58
+	{
59
+		if (false === ($test = get_transient(Application::ID.'_remote_post_test'))) {
60
+			$response = wp_remote_post('https://api.wordpress.org/stats/php/1.0/');
61
+			$test = !is_wp_error($response) && in_array($response['response']['code'], range(200, 299))
62
+				? 'Works'
63
+				: 'Does not work';
64
+			set_transient(Application::ID.'_remote_post_test', $test, WEEK_IN_SECONDS);
65
+		}
66
+		return $test;
67
+	}
68 68
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -11,24 +11,24 @@  discard block
 block discarded – undo
11 11
      */
12 12
     public function getCloudflareIps()
13 13
     {
14
-        if (false === ($ipAddresses = get_transient(Application::ID.'_cloudflare_ips'))) {
15
-            $ipAddresses = array_fill_keys(['v4', 'v6'], []);
16
-            foreach (array_keys($ipAddresses) as $version) {
14
+        if( false === ($ipAddresses = get_transient( Application::ID.'_cloudflare_ips' )) ) {
15
+            $ipAddresses = array_fill_keys( ['v4', 'v6'], [] );
16
+            foreach( array_keys( $ipAddresses ) as $version ) {
17 17
                 $url = 'https://www.cloudflare.com/ips-'.$version;
18
-                $response = wp_remote_get($url, ['sslverify' => false]);
19
-                if (is_wp_error($response)) {
20
-                    glsr_log()->error($response->get_error_message());
18
+                $response = wp_remote_get( $url, ['sslverify' => false] );
19
+                if( is_wp_error( $response ) ) {
20
+                    glsr_log()->error( $response->get_error_message() );
21 21
                     continue;
22 22
                 }
23
-                if ('200' != ($statusCode = wp_remote_retrieve_response_code($response))) {
24
-                    glsr_log()->error('Unable to connect to '.$url.' ['.$statusCode.']');
23
+                if( '200' != ($statusCode = wp_remote_retrieve_response_code( $response )) ) {
24
+                    glsr_log()->error( 'Unable to connect to '.$url.' ['.$statusCode.']' );
25 25
                     continue;
26 26
                 }
27 27
                 $ipAddresses[$version] = array_filter(
28
-                    (array) preg_split('/\R/', wp_remote_retrieve_body($response))
28
+                    (array)preg_split( '/\R/', wp_remote_retrieve_body( $response ) )
29 29
                 );
30 30
             }
31
-            set_transient(Application::ID.'_cloudflare_ips', $ipAddresses, WEEK_IN_SECONDS);
31
+            set_transient( Application::ID.'_cloudflare_ips', $ipAddresses, WEEK_IN_SECONDS );
32 32
         }
33 33
         return $ipAddresses;
34 34
     }
@@ -37,16 +37,16 @@  discard block
 block discarded – undo
37 37
      * @param string $metaKey
38 38
      * @return array
39 39
      */
40
-    public function getReviewCountsFor($metaKey)
40
+    public function getReviewCountsFor( $metaKey )
41 41
     {
42
-        $counts = wp_cache_get(Application::ID, $metaKey.'_count');
43
-        if (false === $counts) {
42
+        $counts = wp_cache_get( Application::ID, $metaKey.'_count' );
43
+        if( false === $counts ) {
44 44
             $counts = [];
45
-            $results = glsr(SqlQueries::class)->getReviewCountsFor($metaKey);
46
-            foreach ($results as $result) {
45
+            $results = glsr( SqlQueries::class )->getReviewCountsFor( $metaKey );
46
+            foreach( $results as $result ) {
47 47
                 $counts[$result->name] = $result->num_posts;
48 48
             }
49
-            wp_cache_set(Application::ID, $counts, $metaKey.'_count');
49
+            wp_cache_set( Application::ID, $counts, $metaKey.'_count' );
50 50
         }
51 51
         return $counts;
52 52
     }
@@ -56,12 +56,12 @@  discard block
 block discarded – undo
56 56
      */
57 57
     public function getRemotePostTest()
58 58
     {
59
-        if (false === ($test = get_transient(Application::ID.'_remote_post_test'))) {
60
-            $response = wp_remote_post('https://api.wordpress.org/stats/php/1.0/');
61
-            $test = !is_wp_error($response) && in_array($response['response']['code'], range(200, 299))
59
+        if( false === ($test = get_transient( Application::ID.'_remote_post_test' )) ) {
60
+            $response = wp_remote_post( 'https://api.wordpress.org/stats/php/1.0/' );
61
+            $test = !is_wp_error( $response ) && in_array( $response['response']['code'], range( 200, 299 ) )
62 62
                 ? 'Works'
63 63
                 : 'Does not work';
64
-            set_transient(Application::ID.'_remote_post_test', $test, WEEK_IN_SECONDS);
64
+            set_transient( Application::ID.'_remote_post_test', $test, WEEK_IN_SECONDS );
65 65
         }
66 66
         return $test;
67 67
     }
Please login to merge, or discard this patch.
plugin/Defaults/CreateReviewDefaults.php 2 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -6,41 +6,41 @@
 block discarded – undo
6 6
 
7 7
 class CreateReviewDefaults extends Defaults
8 8
 {
9
-    /**
10
-     * @var array
11
-     */
12
-    protected $guarded = [
13
-        'assigned_to',
14
-        'content',
15
-        'date',
16
-        'pinned',
17
-        'response',
18
-        'review_id',
19
-        'review_type',
20
-        'title',
21
-    ];
9
+	/**
10
+	 * @var array
11
+	 */
12
+	protected $guarded = [
13
+		'assigned_to',
14
+		'content',
15
+		'date',
16
+		'pinned',
17
+		'response',
18
+		'review_id',
19
+		'review_type',
20
+		'title',
21
+	];
22 22
 
23
-    /**
24
-     * @return array
25
-     */
26
-    protected function defaults()
27
-    {
28
-        return [
29
-            'assigned_to' => '',
30
-            'author' => '',
31
-            'avatar' => '',
32
-            'content' => '',
33
-            'custom' => '',
34
-            'date' => '',
35
-            'email' => '',
36
-            'ip_address' => '',
37
-            'pinned' => false,
38
-            'rating' => '',
39
-            'response' => '',
40
-            'review_id' => md5(time().mt_rand()),
41
-            'review_type' => 'local',
42
-            'title' => '',
43
-            'url' => '',
44
-        ];
45
-    }
23
+	/**
24
+	 * @return array
25
+	 */
26
+	protected function defaults()
27
+	{
28
+		return [
29
+			'assigned_to' => '',
30
+			'author' => '',
31
+			'avatar' => '',
32
+			'content' => '',
33
+			'custom' => '',
34
+			'date' => '',
35
+			'email' => '',
36
+			'ip_address' => '',
37
+			'pinned' => false,
38
+			'rating' => '',
39
+			'response' => '',
40
+			'review_id' => md5(time().mt_rand()),
41
+			'review_type' => 'local',
42
+			'title' => '',
43
+			'url' => '',
44
+		];
45
+	}
46 46
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
             'pinned' => false,
38 38
             'rating' => '',
39 39
             'response' => '',
40
-            'review_id' => md5(time().mt_rand()),
40
+            'review_id' => md5( time().mt_rand() ),
41 41
             'review_type' => 'local',
42 42
             'title' => '',
43 43
             'url' => '',
Please login to merge, or discard this patch.
plugin/Modules/Validator/ValidateReview.php 2 patches
Indentation   +259 added lines, -259 removed lines patch added patch discarded remove patch
@@ -13,285 +13,285 @@
 block discarded – undo
13 13
 
14 14
 class ValidateReview
15 15
 {
16
-    const RECAPTCHA_ENDPOINT = 'https://www.google.com/recaptcha/api/siteverify';
16
+	const RECAPTCHA_ENDPOINT = 'https://www.google.com/recaptcha/api/siteverify';
17 17
 
18
-    const RECAPTCHA_DISABLED = 0;
19
-    const RECAPTCHA_EMPTY = 1;
20
-    const RECAPTCHA_FAILED = 2;
21
-    const RECAPTCHA_INVALID = 3;
22
-    const RECAPTCHA_VALID = 4;
18
+	const RECAPTCHA_DISABLED = 0;
19
+	const RECAPTCHA_EMPTY = 1;
20
+	const RECAPTCHA_FAILED = 2;
21
+	const RECAPTCHA_INVALID = 3;
22
+	const RECAPTCHA_VALID = 4;
23 23
 
24
-    const VALIDATION_RULES = [
25
-        'content' => 'required',
26
-        'email' => 'required|email',
27
-        'name' => 'required',
28
-        'rating' => 'required|number|between:1,5',
29
-        'terms' => 'accepted',
30
-        'title' => 'required',
31
-    ];
24
+	const VALIDATION_RULES = [
25
+		'content' => 'required',
26
+		'email' => 'required|email',
27
+		'name' => 'required',
28
+		'rating' => 'required|number|between:1,5',
29
+		'terms' => 'accepted',
30
+		'title' => 'required',
31
+	];
32 32
 
33
-    /**
34
-     * @var string|void
35
-     */
36
-    public $error;
33
+	/**
34
+	 * @var string|void
35
+	 */
36
+	public $error;
37 37
 
38
-    /**
39
-     * @var string
40
-     */
41
-    public $form_id;
38
+	/**
39
+	 * @var string
40
+	 */
41
+	public $form_id;
42 42
 
43
-    /**
44
-     * @var bool
45
-     */
46
-    public $recaptchaIsUnset = false;
43
+	/**
44
+	 * @var bool
45
+	 */
46
+	public $recaptchaIsUnset = false;
47 47
 
48
-    /**
49
-     * @var array
50
-     */
51
-    public $request;
48
+	/**
49
+	 * @var array
50
+	 */
51
+	public $request;
52 52
 
53
-    /**
54
-     * @var array
55
-     */
56
-    protected $options;
53
+	/**
54
+	 * @var array
55
+	 */
56
+	protected $options;
57 57
 
58
-    /**
59
-     * @return static
60
-     */
61
-    public function validate(array $request)
62
-    {
63
-        $request['ip_address'] = Helper::getIpAddress(); // required for Akismet and Blacklist validation
64
-        $this->form_id = $request['form_id'];
65
-        $this->options = glsr(OptionManager::class)->all();
66
-        $this->request = $this->validateRequest($request);
67
-        $this->validateCustom();
68
-        $this->validateHoneyPot();
69
-        $this->validateReviewLimits();
70
-        $this->validateBlacklist();
71
-        $this->validateAkismet();
72
-        $this->validateRecaptcha();
73
-        if (!empty($this->error)) {
74
-            $this->setSessionValues('message', $this->error);
75
-        }
76
-        return $this;
77
-    }
58
+	/**
59
+	 * @return static
60
+	 */
61
+	public function validate(array $request)
62
+	{
63
+		$request['ip_address'] = Helper::getIpAddress(); // required for Akismet and Blacklist validation
64
+		$this->form_id = $request['form_id'];
65
+		$this->options = glsr(OptionManager::class)->all();
66
+		$this->request = $this->validateRequest($request);
67
+		$this->validateCustom();
68
+		$this->validateHoneyPot();
69
+		$this->validateReviewLimits();
70
+		$this->validateBlacklist();
71
+		$this->validateAkismet();
72
+		$this->validateRecaptcha();
73
+		if (!empty($this->error)) {
74
+			$this->setSessionValues('message', $this->error);
75
+		}
76
+		return $this;
77
+	}
78 78
 
79
-    /**
80
-     * @param string $path
81
-     * @param mixed $fallback
82
-     * @return mixed
83
-     */
84
-    protected function getOption($path, $fallback = '')
85
-    {
86
-        return Arr::get($this->options, $path, $fallback);
87
-    }
79
+	/**
80
+	 * @param string $path
81
+	 * @param mixed $fallback
82
+	 * @return mixed
83
+	 */
84
+	protected function getOption($path, $fallback = '')
85
+	{
86
+		return Arr::get($this->options, $path, $fallback);
87
+	}
88 88
 
89
-    /**
90
-     * @return int
91
-     */
92
-    protected function getRecaptchaStatus()
93
-    {
94
-        if (!glsr(OptionManager::class)->isRecaptchaEnabled()) {
95
-            return static::RECAPTCHA_DISABLED;
96
-        }
97
-        if (empty($this->request['_recaptcha-token'])) {
98
-            return $this->request['_counter'] < intval(apply_filters('site-reviews/recaptcha/timeout', 5))
99
-                ? static::RECAPTCHA_EMPTY
100
-                : static::RECAPTCHA_FAILED;
101
-        }
102
-        return $this->getRecaptchaTokenStatus();
103
-    }
89
+	/**
90
+	 * @return int
91
+	 */
92
+	protected function getRecaptchaStatus()
93
+	{
94
+		if (!glsr(OptionManager::class)->isRecaptchaEnabled()) {
95
+			return static::RECAPTCHA_DISABLED;
96
+		}
97
+		if (empty($this->request['_recaptcha-token'])) {
98
+			return $this->request['_counter'] < intval(apply_filters('site-reviews/recaptcha/timeout', 5))
99
+				? static::RECAPTCHA_EMPTY
100
+				: static::RECAPTCHA_FAILED;
101
+		}
102
+		return $this->getRecaptchaTokenStatus();
103
+	}
104 104
 
105
-    /**
106
-     * @return int
107
-     */
108
-    protected function getRecaptchaTokenStatus()
109
-    {
110
-        $endpoint = add_query_arg([
111
-            'remoteip' => Helper::getIpAddress(),
112
-            'response' => $this->request['_recaptcha-token'],
113
-            'secret' => $this->getOption('settings.submissions.recaptcha.secret'),
114
-        ], static::RECAPTCHA_ENDPOINT);
115
-        if (is_wp_error($response = wp_remote_get($endpoint))) {
116
-            glsr_log()->error($response->get_error_message());
117
-            return static::RECAPTCHA_FAILED;
118
-        }
119
-        $response = json_decode(wp_remote_retrieve_body($response));
120
-        if (!empty($response->success)) {
121
-            return boolval($response->success)
122
-                ? static::RECAPTCHA_VALID
123
-                : static::RECAPTCHA_INVALID;
124
-        }
125
-        foreach ($response->{'error-codes'} as $error) {
126
-            glsr_log()->error('reCAPTCHA error: '.$error);
127
-        }
128
-        return static::RECAPTCHA_INVALID;
129
-    }
105
+	/**
106
+	 * @return int
107
+	 */
108
+	protected function getRecaptchaTokenStatus()
109
+	{
110
+		$endpoint = add_query_arg([
111
+			'remoteip' => Helper::getIpAddress(),
112
+			'response' => $this->request['_recaptcha-token'],
113
+			'secret' => $this->getOption('settings.submissions.recaptcha.secret'),
114
+		], static::RECAPTCHA_ENDPOINT);
115
+		if (is_wp_error($response = wp_remote_get($endpoint))) {
116
+			glsr_log()->error($response->get_error_message());
117
+			return static::RECAPTCHA_FAILED;
118
+		}
119
+		$response = json_decode(wp_remote_retrieve_body($response));
120
+		if (!empty($response->success)) {
121
+			return boolval($response->success)
122
+				? static::RECAPTCHA_VALID
123
+				: static::RECAPTCHA_INVALID;
124
+		}
125
+		foreach ($response->{'error-codes'} as $error) {
126
+			glsr_log()->error('reCAPTCHA error: '.$error);
127
+		}
128
+		return static::RECAPTCHA_INVALID;
129
+	}
130 130
 
131
-    /**
132
-     * @return array
133
-     */
134
-    protected function getValidationRules(array $request)
135
-    {
136
-        $rules = array_intersect_key(
137
-            apply_filters('site-reviews/validation/rules', static::VALIDATION_RULES, $request),
138
-            array_flip($this->getOption('settings.submissions.required', []))
139
-        );
140
-        $excluded = explode(',', Arr::get($request, 'excluded'));
141
-        return array_diff_key($rules, array_flip($excluded));
142
-    }
131
+	/**
132
+	 * @return array
133
+	 */
134
+	protected function getValidationRules(array $request)
135
+	{
136
+		$rules = array_intersect_key(
137
+			apply_filters('site-reviews/validation/rules', static::VALIDATION_RULES, $request),
138
+			array_flip($this->getOption('settings.submissions.required', []))
139
+		);
140
+		$excluded = explode(',', Arr::get($request, 'excluded'));
141
+		return array_diff_key($rules, array_flip($excluded));
142
+	}
143 143
 
144
-    /**
145
-     * @return bool
146
-     */
147
-    protected function isRequestValid(array $request)
148
-    {
149
-        $rules = $this->getValidationRules($request);
150
-        $errors = glsr(Validator::class)->validate($request, $rules);
151
-        if (empty($errors)) {
152
-            return true;
153
-        }
154
-        $this->error = __('Please fix the submission errors.', 'site-reviews');
155
-        $this->setSessionValues('errors', $errors);
156
-        $this->setSessionValues('values', $request);
157
-        return false;
158
-    }
144
+	/**
145
+	 * @return bool
146
+	 */
147
+	protected function isRequestValid(array $request)
148
+	{
149
+		$rules = $this->getValidationRules($request);
150
+		$errors = glsr(Validator::class)->validate($request, $rules);
151
+		if (empty($errors)) {
152
+			return true;
153
+		}
154
+		$this->error = __('Please fix the submission errors.', 'site-reviews');
155
+		$this->setSessionValues('errors', $errors);
156
+		$this->setSessionValues('values', $request);
157
+		return false;
158
+	}
159 159
 
160
-    protected function setError($message, $loggedMessage = '')
161
-    {
162
-        $this->setSessionValues('errors', [], $loggedMessage);
163
-        $this->error = $message;
164
-    }
160
+	protected function setError($message, $loggedMessage = '')
161
+	{
162
+		$this->setSessionValues('errors', [], $loggedMessage);
163
+		$this->error = $message;
164
+	}
165 165
 
166
-    /**
167
-     * @param string $type
168
-     * @param mixed $value
169
-     * @param string $loggedMessage
170
-     * @return void
171
-     */
172
-    protected function setSessionValues($type, $value, $loggedMessage = '')
173
-    {
174
-        glsr()->sessionSet($this->form_id.$type, $value);
175
-        if (!empty($loggedMessage)) {
176
-            glsr_log()->warning($loggedMessage)->debug($this->request);
177
-        }
178
-    }
166
+	/**
167
+	 * @param string $type
168
+	 * @param mixed $value
169
+	 * @param string $loggedMessage
170
+	 * @return void
171
+	 */
172
+	protected function setSessionValues($type, $value, $loggedMessage = '')
173
+	{
174
+		glsr()->sessionSet($this->form_id.$type, $value);
175
+		if (!empty($loggedMessage)) {
176
+			glsr_log()->warning($loggedMessage)->debug($this->request);
177
+		}
178
+	}
179 179
 
180
-    /**
181
-     * @return void
182
-     */
183
-    protected function validateAkismet()
184
-    {
185
-        if (!empty($this->error)) {
186
-            return;
187
-        }
188
-        if (glsr(Akismet::class)->isSpam($this->request)) {
189
-            $this->setError(__('This review has been flagged as possible spam and cannot be submitted.', 'site-reviews'),
190
-                'Akismet caught a spam submission (consider adding the IP address to the blacklist):'
191
-            );
192
-        }
193
-    }
180
+	/**
181
+	 * @return void
182
+	 */
183
+	protected function validateAkismet()
184
+	{
185
+		if (!empty($this->error)) {
186
+			return;
187
+		}
188
+		if (glsr(Akismet::class)->isSpam($this->request)) {
189
+			$this->setError(__('This review has been flagged as possible spam and cannot be submitted.', 'site-reviews'),
190
+				'Akismet caught a spam submission (consider adding the IP address to the blacklist):'
191
+			);
192
+		}
193
+	}
194 194
 
195
-    /**
196
-     * @return void
197
-     */
198
-    protected function validateBlacklist()
199
-    {
200
-        if (!empty($this->error)) {
201
-            return;
202
-        }
203
-        if (!glsr(Blacklist::class)->isBlacklisted($this->request)) {
204
-            return;
205
-        }
206
-        $blacklistAction = $this->getOption('settings.submissions.blacklist.action');
207
-        if ('reject' != $blacklistAction) {
208
-            $this->request['blacklisted'] = true;
209
-            return;
210
-        }
211
-        $this->setError(__('Your review cannot be submitted at this time.', 'site-reviews'),
212
-            'Blacklisted submission detected:'
213
-        );
214
-    }
195
+	/**
196
+	 * @return void
197
+	 */
198
+	protected function validateBlacklist()
199
+	{
200
+		if (!empty($this->error)) {
201
+			return;
202
+		}
203
+		if (!glsr(Blacklist::class)->isBlacklisted($this->request)) {
204
+			return;
205
+		}
206
+		$blacklistAction = $this->getOption('settings.submissions.blacklist.action');
207
+		if ('reject' != $blacklistAction) {
208
+			$this->request['blacklisted'] = true;
209
+			return;
210
+		}
211
+		$this->setError(__('Your review cannot be submitted at this time.', 'site-reviews'),
212
+			'Blacklisted submission detected:'
213
+		);
214
+	}
215 215
 
216
-    /**
217
-     * @return void
218
-     */
219
-    protected function validateCustom()
220
-    {
221
-        if (!empty($this->error)) {
222
-            return;
223
-        }
224
-        $validated = apply_filters('site-reviews/validate/custom', true, $this->request);
225
-        if (true === $validated) {
226
-            return;
227
-        }
228
-        $errorMessage = is_string($validated)
229
-            ? $validated
230
-            : __('The review submission failed. Please notify the site administrator.', 'site-reviews');
231
-        $this->setError($errorMessage);
232
-        $this->setSessionValues('values', $this->request);
233
-    }
216
+	/**
217
+	 * @return void
218
+	 */
219
+	protected function validateCustom()
220
+	{
221
+		if (!empty($this->error)) {
222
+			return;
223
+		}
224
+		$validated = apply_filters('site-reviews/validate/custom', true, $this->request);
225
+		if (true === $validated) {
226
+			return;
227
+		}
228
+		$errorMessage = is_string($validated)
229
+			? $validated
230
+			: __('The review submission failed. Please notify the site administrator.', 'site-reviews');
231
+		$this->setError($errorMessage);
232
+		$this->setSessionValues('values', $this->request);
233
+	}
234 234
 
235
-    /**
236
-     * @return void
237
-     */
238
-    protected function validateHoneyPot()
239
-    {
240
-        if (!empty($this->error)) {
241
-            return;
242
-        }
243
-        if (!empty($this->request['gotcha'])) {
244
-            $this->setError(__('The review submission failed. Please notify the site administrator.', 'site-reviews'),
245
-                'The Honeypot caught a bad submission:'
246
-            );
247
-        }
248
-    }
235
+	/**
236
+	 * @return void
237
+	 */
238
+	protected function validateHoneyPot()
239
+	{
240
+		if (!empty($this->error)) {
241
+			return;
242
+		}
243
+		if (!empty($this->request['gotcha'])) {
244
+			$this->setError(__('The review submission failed. Please notify the site administrator.', 'site-reviews'),
245
+				'The Honeypot caught a bad submission:'
246
+			);
247
+		}
248
+	}
249 249
 
250
-    /**
251
-     * @return void
252
-     */
253
-    protected function validateReviewLimits()
254
-    {
255
-        if (!empty($this->error)) {
256
-            return;
257
-        }
258
-        if (glsr(ReviewLimits::class)->hasReachedLimit($this->request)) {
259
-            $this->setError(__('You have already submitted a review.', 'site-reviews'));
260
-        }
261
-    }
250
+	/**
251
+	 * @return void
252
+	 */
253
+	protected function validateReviewLimits()
254
+	{
255
+		if (!empty($this->error)) {
256
+			return;
257
+		}
258
+		if (glsr(ReviewLimits::class)->hasReachedLimit($this->request)) {
259
+			$this->setError(__('You have already submitted a review.', 'site-reviews'));
260
+		}
261
+	}
262 262
 
263
-    /**
264
-     * @return void
265
-     */
266
-    protected function validateRecaptcha()
267
-    {
268
-        if (!empty($this->error)) {
269
-            return;
270
-        }
271
-        $status = $this->getRecaptchaStatus();
272
-        if (in_array($status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID])) {
273
-            return;
274
-        }
275
-        if (static::RECAPTCHA_EMPTY === $status) {
276
-            $this->setSessionValues('recaptcha', 'unset');
277
-            $this->recaptchaIsUnset = true;
278
-            return;
279
-        }
280
-        $this->setSessionValues('recaptcha', 'reset');
281
-        $errors = [
282
-            static::RECAPTCHA_FAILED => __('The reCAPTCHA failed to load, please refresh the page and try again.', 'site-reviews'),
283
-            static::RECAPTCHA_INVALID => __('The reCAPTCHA verification failed, please try again.', 'site-reviews'),
284
-        ];
285
-        $this->setError($errors[$status]);
286
-    }
263
+	/**
264
+	 * @return void
265
+	 */
266
+	protected function validateRecaptcha()
267
+	{
268
+		if (!empty($this->error)) {
269
+			return;
270
+		}
271
+		$status = $this->getRecaptchaStatus();
272
+		if (in_array($status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID])) {
273
+			return;
274
+		}
275
+		if (static::RECAPTCHA_EMPTY === $status) {
276
+			$this->setSessionValues('recaptcha', 'unset');
277
+			$this->recaptchaIsUnset = true;
278
+			return;
279
+		}
280
+		$this->setSessionValues('recaptcha', 'reset');
281
+		$errors = [
282
+			static::RECAPTCHA_FAILED => __('The reCAPTCHA failed to load, please refresh the page and try again.', 'site-reviews'),
283
+			static::RECAPTCHA_INVALID => __('The reCAPTCHA verification failed, please try again.', 'site-reviews'),
284
+		];
285
+		$this->setError($errors[$status]);
286
+	}
287 287
 
288
-    /**
289
-     * @return array
290
-     */
291
-    protected function validateRequest(array $request)
292
-    {
293
-        return $this->isRequestValid($request)
294
-            ? array_merge(glsr(ValidateReviewDefaults::class)->defaults(), $request)
295
-            : $request;
296
-    }
288
+	/**
289
+	 * @return array
290
+	 */
291
+	protected function validateRequest(array $request)
292
+	{
293
+		return $this->isRequestValid($request)
294
+			? array_merge(glsr(ValidateReviewDefaults::class)->defaults(), $request)
295
+			: $request;
296
+	}
297 297
 }
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -58,20 +58,20 @@  discard block
 block discarded – undo
58 58
     /**
59 59
      * @return static
60 60
      */
61
-    public function validate(array $request)
61
+    public function validate( array $request )
62 62
     {
63 63
         $request['ip_address'] = Helper::getIpAddress(); // required for Akismet and Blacklist validation
64 64
         $this->form_id = $request['form_id'];
65
-        $this->options = glsr(OptionManager::class)->all();
66
-        $this->request = $this->validateRequest($request);
65
+        $this->options = glsr( OptionManager::class )->all();
66
+        $this->request = $this->validateRequest( $request );
67 67
         $this->validateCustom();
68 68
         $this->validateHoneyPot();
69 69
         $this->validateReviewLimits();
70 70
         $this->validateBlacklist();
71 71
         $this->validateAkismet();
72 72
         $this->validateRecaptcha();
73
-        if (!empty($this->error)) {
74
-            $this->setSessionValues('message', $this->error);
73
+        if( !empty($this->error) ) {
74
+            $this->setSessionValues( 'message', $this->error );
75 75
         }
76 76
         return $this;
77 77
     }
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
      * @param mixed $fallback
82 82
      * @return mixed
83 83
      */
84
-    protected function getOption($path, $fallback = '')
84
+    protected function getOption( $path, $fallback = '' )
85 85
     {
86
-        return Arr::get($this->options, $path, $fallback);
86
+        return Arr::get( $this->options, $path, $fallback );
87 87
     }
88 88
 
89 89
     /**
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
      */
92 92
     protected function getRecaptchaStatus()
93 93
     {
94
-        if (!glsr(OptionManager::class)->isRecaptchaEnabled()) {
94
+        if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) {
95 95
             return static::RECAPTCHA_DISABLED;
96 96
         }
97
-        if (empty($this->request['_recaptcha-token'])) {
98
-            return $this->request['_counter'] < intval(apply_filters('site-reviews/recaptcha/timeout', 5))
97
+        if( empty($this->request['_recaptcha-token']) ) {
98
+            return $this->request['_counter'] < intval( apply_filters( 'site-reviews/recaptcha/timeout', 5 ) )
99 99
                 ? static::RECAPTCHA_EMPTY
100 100
                 : static::RECAPTCHA_FAILED;
101 101
         }
@@ -107,23 +107,23 @@  discard block
 block discarded – undo
107 107
      */
108 108
     protected function getRecaptchaTokenStatus()
109 109
     {
110
-        $endpoint = add_query_arg([
110
+        $endpoint = add_query_arg( [
111 111
             'remoteip' => Helper::getIpAddress(),
112 112
             'response' => $this->request['_recaptcha-token'],
113
-            'secret' => $this->getOption('settings.submissions.recaptcha.secret'),
114
-        ], static::RECAPTCHA_ENDPOINT);
115
-        if (is_wp_error($response = wp_remote_get($endpoint))) {
116
-            glsr_log()->error($response->get_error_message());
113
+            'secret' => $this->getOption( 'settings.submissions.recaptcha.secret' ),
114
+        ], static::RECAPTCHA_ENDPOINT );
115
+        if( is_wp_error( $response = wp_remote_get( $endpoint ) ) ) {
116
+            glsr_log()->error( $response->get_error_message() );
117 117
             return static::RECAPTCHA_FAILED;
118 118
         }
119
-        $response = json_decode(wp_remote_retrieve_body($response));
120
-        if (!empty($response->success)) {
121
-            return boolval($response->success)
119
+        $response = json_decode( wp_remote_retrieve_body( $response ) );
120
+        if( !empty($response->success) ) {
121
+            return boolval( $response->success )
122 122
                 ? static::RECAPTCHA_VALID
123 123
                 : static::RECAPTCHA_INVALID;
124 124
         }
125
-        foreach ($response->{'error-codes'} as $error) {
126
-            glsr_log()->error('reCAPTCHA error: '.$error);
125
+        foreach( $response->{'error-codes'} as $error ) {
126
+            glsr_log()->error( 'reCAPTCHA error: '.$error );
127 127
         }
128 128
         return static::RECAPTCHA_INVALID;
129 129
     }
@@ -131,35 +131,35 @@  discard block
 block discarded – undo
131 131
     /**
132 132
      * @return array
133 133
      */
134
-    protected function getValidationRules(array $request)
134
+    protected function getValidationRules( array $request )
135 135
     {
136 136
         $rules = array_intersect_key(
137
-            apply_filters('site-reviews/validation/rules', static::VALIDATION_RULES, $request),
138
-            array_flip($this->getOption('settings.submissions.required', []))
137
+            apply_filters( 'site-reviews/validation/rules', static::VALIDATION_RULES, $request ),
138
+            array_flip( $this->getOption( 'settings.submissions.required', [] ) )
139 139
         );
140
-        $excluded = explode(',', Arr::get($request, 'excluded'));
141
-        return array_diff_key($rules, array_flip($excluded));
140
+        $excluded = explode( ',', Arr::get( $request, 'excluded' ) );
141
+        return array_diff_key( $rules, array_flip( $excluded ) );
142 142
     }
143 143
 
144 144
     /**
145 145
      * @return bool
146 146
      */
147
-    protected function isRequestValid(array $request)
147
+    protected function isRequestValid( array $request )
148 148
     {
149
-        $rules = $this->getValidationRules($request);
150
-        $errors = glsr(Validator::class)->validate($request, $rules);
151
-        if (empty($errors)) {
149
+        $rules = $this->getValidationRules( $request );
150
+        $errors = glsr( Validator::class )->validate( $request, $rules );
151
+        if( empty($errors) ) {
152 152
             return true;
153 153
         }
154
-        $this->error = __('Please fix the submission errors.', 'site-reviews');
155
-        $this->setSessionValues('errors', $errors);
156
-        $this->setSessionValues('values', $request);
154
+        $this->error = __( 'Please fix the submission errors.', 'site-reviews' );
155
+        $this->setSessionValues( 'errors', $errors );
156
+        $this->setSessionValues( 'values', $request );
157 157
         return false;
158 158
     }
159 159
 
160
-    protected function setError($message, $loggedMessage = '')
160
+    protected function setError( $message, $loggedMessage = '' )
161 161
     {
162
-        $this->setSessionValues('errors', [], $loggedMessage);
162
+        $this->setSessionValues( 'errors', [], $loggedMessage );
163 163
         $this->error = $message;
164 164
     }
165 165
 
@@ -169,11 +169,11 @@  discard block
 block discarded – undo
169 169
      * @param string $loggedMessage
170 170
      * @return void
171 171
      */
172
-    protected function setSessionValues($type, $value, $loggedMessage = '')
172
+    protected function setSessionValues( $type, $value, $loggedMessage = '' )
173 173
     {
174
-        glsr()->sessionSet($this->form_id.$type, $value);
175
-        if (!empty($loggedMessage)) {
176
-            glsr_log()->warning($loggedMessage)->debug($this->request);
174
+        glsr()->sessionSet( $this->form_id.$type, $value );
175
+        if( !empty($loggedMessage) ) {
176
+            glsr_log()->warning( $loggedMessage )->debug( $this->request );
177 177
         }
178 178
     }
179 179
 
@@ -182,11 +182,11 @@  discard block
 block discarded – undo
182 182
      */
183 183
     protected function validateAkismet()
184 184
     {
185
-        if (!empty($this->error)) {
185
+        if( !empty($this->error) ) {
186 186
             return;
187 187
         }
188
-        if (glsr(Akismet::class)->isSpam($this->request)) {
189
-            $this->setError(__('This review has been flagged as possible spam and cannot be submitted.', 'site-reviews'),
188
+        if( glsr( Akismet::class )->isSpam( $this->request ) ) {
189
+            $this->setError( __( 'This review has been flagged as possible spam and cannot be submitted.', 'site-reviews' ),
190 190
                 'Akismet caught a spam submission (consider adding the IP address to the blacklist):'
191 191
             );
192 192
         }
@@ -197,18 +197,18 @@  discard block
 block discarded – undo
197 197
      */
198 198
     protected function validateBlacklist()
199 199
     {
200
-        if (!empty($this->error)) {
200
+        if( !empty($this->error) ) {
201 201
             return;
202 202
         }
203
-        if (!glsr(Blacklist::class)->isBlacklisted($this->request)) {
203
+        if( !glsr( Blacklist::class )->isBlacklisted( $this->request ) ) {
204 204
             return;
205 205
         }
206
-        $blacklistAction = $this->getOption('settings.submissions.blacklist.action');
207
-        if ('reject' != $blacklistAction) {
206
+        $blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' );
207
+        if( 'reject' != $blacklistAction ) {
208 208
             $this->request['blacklisted'] = true;
209 209
             return;
210 210
         }
211
-        $this->setError(__('Your review cannot be submitted at this time.', 'site-reviews'),
211
+        $this->setError( __( 'Your review cannot be submitted at this time.', 'site-reviews' ),
212 212
             'Blacklisted submission detected:'
213 213
         );
214 214
     }
@@ -218,18 +218,18 @@  discard block
 block discarded – undo
218 218
      */
219 219
     protected function validateCustom()
220 220
     {
221
-        if (!empty($this->error)) {
221
+        if( !empty($this->error) ) {
222 222
             return;
223 223
         }
224
-        $validated = apply_filters('site-reviews/validate/custom', true, $this->request);
225
-        if (true === $validated) {
224
+        $validated = apply_filters( 'site-reviews/validate/custom', true, $this->request );
225
+        if( true === $validated ) {
226 226
             return;
227 227
         }
228
-        $errorMessage = is_string($validated)
228
+        $errorMessage = is_string( $validated )
229 229
             ? $validated
230
-            : __('The review submission failed. Please notify the site administrator.', 'site-reviews');
231
-        $this->setError($errorMessage);
232
-        $this->setSessionValues('values', $this->request);
230
+            : __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' );
231
+        $this->setError( $errorMessage );
232
+        $this->setSessionValues( 'values', $this->request );
233 233
     }
234 234
 
235 235
     /**
@@ -237,11 +237,11 @@  discard block
 block discarded – undo
237 237
      */
238 238
     protected function validateHoneyPot()
239 239
     {
240
-        if (!empty($this->error)) {
240
+        if( !empty($this->error) ) {
241 241
             return;
242 242
         }
243
-        if (!empty($this->request['gotcha'])) {
244
-            $this->setError(__('The review submission failed. Please notify the site administrator.', 'site-reviews'),
243
+        if( !empty($this->request['gotcha']) ) {
244
+            $this->setError( __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ),
245 245
                 'The Honeypot caught a bad submission:'
246 246
             );
247 247
         }
@@ -252,11 +252,11 @@  discard block
 block discarded – undo
252 252
      */
253 253
     protected function validateReviewLimits()
254 254
     {
255
-        if (!empty($this->error)) {
255
+        if( !empty($this->error) ) {
256 256
             return;
257 257
         }
258
-        if (glsr(ReviewLimits::class)->hasReachedLimit($this->request)) {
259
-            $this->setError(__('You have already submitted a review.', 'site-reviews'));
258
+        if( glsr( ReviewLimits::class )->hasReachedLimit( $this->request ) ) {
259
+            $this->setError( __( 'You have already submitted a review.', 'site-reviews' ) );
260 260
         }
261 261
     }
262 262
 
@@ -265,33 +265,33 @@  discard block
 block discarded – undo
265 265
      */
266 266
     protected function validateRecaptcha()
267 267
     {
268
-        if (!empty($this->error)) {
268
+        if( !empty($this->error) ) {
269 269
             return;
270 270
         }
271 271
         $status = $this->getRecaptchaStatus();
272
-        if (in_array($status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID])) {
272
+        if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ) ) {
273 273
             return;
274 274
         }
275
-        if (static::RECAPTCHA_EMPTY === $status) {
276
-            $this->setSessionValues('recaptcha', 'unset');
275
+        if( static::RECAPTCHA_EMPTY === $status ) {
276
+            $this->setSessionValues( 'recaptcha', 'unset' );
277 277
             $this->recaptchaIsUnset = true;
278 278
             return;
279 279
         }
280
-        $this->setSessionValues('recaptcha', 'reset');
280
+        $this->setSessionValues( 'recaptcha', 'reset' );
281 281
         $errors = [
282
-            static::RECAPTCHA_FAILED => __('The reCAPTCHA failed to load, please refresh the page and try again.', 'site-reviews'),
283
-            static::RECAPTCHA_INVALID => __('The reCAPTCHA verification failed, please try again.', 'site-reviews'),
282
+            static::RECAPTCHA_FAILED => __( 'The reCAPTCHA failed to load, please refresh the page and try again.', 'site-reviews' ),
283
+            static::RECAPTCHA_INVALID => __( 'The reCAPTCHA verification failed, please try again.', 'site-reviews' ),
284 284
         ];
285
-        $this->setError($errors[$status]);
285
+        $this->setError( $errors[$status] );
286 286
     }
287 287
 
288 288
     /**
289 289
      * @return array
290 290
      */
291
-    protected function validateRequest(array $request)
291
+    protected function validateRequest( array $request )
292 292
     {
293
-        return $this->isRequestValid($request)
294
-            ? array_merge(glsr(ValidateReviewDefaults::class)->defaults(), $request)
293
+        return $this->isRequestValid( $request )
294
+            ? array_merge( glsr( ValidateReviewDefaults::class )->defaults(), $request )
295 295
             : $request;
296 296
     }
297 297
 }
Please login to merge, or discard this patch.