Passed
Push — master ( 04b043...334ee0 )
by Paul
04:11
created
plugin/Blocks/SiteReviewsFormBlock.php 2 patches
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -7,115 +7,115 @@
 block discarded – undo
7 7
 
8 8
 class SiteReviewsFormBlock extends BlockGenerator
9 9
 {
10
-    /**
11
-     * @return array
12
-     */
13
-    public function attributes()
14
-    {
15
-        return [
16
-            'assign_to' => [
17
-                'default' => '',
18
-                'type' => 'string',
19
-            ],
20
-            'category' => [
21
-                'default' => '',
22
-                'type' => 'string',
23
-            ],
24
-            'className' => [
25
-                'default' => '',
26
-                'type' => 'string',
27
-            ],
28
-            'hide' => [
29
-                'default' => '',
30
-                'type' => 'string',
31
-            ],
32
-            'id' => [
33
-                'default' => '',
34
-                'type' => 'string',
35
-            ],
36
-        ];
37
-    }
10
+	/**
11
+	 * @return array
12
+	 */
13
+	public function attributes()
14
+	{
15
+		return [
16
+			'assign_to' => [
17
+				'default' => '',
18
+				'type' => 'string',
19
+			],
20
+			'category' => [
21
+				'default' => '',
22
+				'type' => 'string',
23
+			],
24
+			'className' => [
25
+				'default' => '',
26
+				'type' => 'string',
27
+			],
28
+			'hide' => [
29
+				'default' => '',
30
+				'type' => 'string',
31
+			],
32
+			'id' => [
33
+				'default' => '',
34
+				'type' => 'string',
35
+			],
36
+		];
37
+	}
38 38
 
39
-    /**
40
-     * @return string
41
-     */
42
-    public function render(array $attributes)
43
-    {
44
-        $attributes['class'] = $attributes['className'];
45
-        $shortcode = glsr(Shortcode::class);
46
-        if ('edit' == filter_input(INPUT_GET, 'context')) {
47
-            $this->filterFormFields();
48
-            $this->filterRatingField();
49
-            $this->filterShortcodeClass();
50
-            $this->filterSubmitButton();
51
-            if (!$this->hasVisibleFields($shortcode, $attributes)) {
52
-                $this->filterInterpolation();
53
-            }
54
-        }
55
-        return $shortcode->buildShortcode($attributes);
56
-    }
39
+	/**
40
+	 * @return string
41
+	 */
42
+	public function render(array $attributes)
43
+	{
44
+		$attributes['class'] = $attributes['className'];
45
+		$shortcode = glsr(Shortcode::class);
46
+		if ('edit' == filter_input(INPUT_GET, 'context')) {
47
+			$this->filterFormFields();
48
+			$this->filterRatingField();
49
+			$this->filterShortcodeClass();
50
+			$this->filterSubmitButton();
51
+			if (!$this->hasVisibleFields($shortcode, $attributes)) {
52
+				$this->filterInterpolation();
53
+			}
54
+		}
55
+		return $shortcode->buildShortcode($attributes);
56
+	}
57 57
 
58
-    /**
59
-     * @return void
60
-     */
61
-    protected function filterFormFields()
62
-    {
63
-        add_filter('site-reviews/config/forms/submission-form', function (array $config) {
64
-            array_walk($config, function (&$field) {
65
-                $field['disabled'] = true;
66
-                $field['tabindex'] = '-1';
67
-            });
68
-            return $config;
69
-        });
70
-    }
58
+	/**
59
+	 * @return void
60
+	 */
61
+	protected function filterFormFields()
62
+	{
63
+		add_filter('site-reviews/config/forms/submission-form', function (array $config) {
64
+			array_walk($config, function (&$field) {
65
+				$field['disabled'] = true;
66
+				$field['tabindex'] = '-1';
67
+			});
68
+			return $config;
69
+		});
70
+	}
71 71
 
72
-    /**
73
-     * @return void
74
-     */
75
-    protected function filterInterpolation()
76
-    {
77
-        add_filter('site-reviews/interpolate/reviews-form', function ($context) {
78
-            $context['class'] = 'glsr-default glsr-block-disabled';
79
-            $context['fields'] = __('You have hidden all of the fields for this block.', 'site-reviews');
80
-            $context['response'] = '';
81
-            $context['submit_button'] = '';
82
-            return $context;
83
-        });
84
-    }
72
+	/**
73
+	 * @return void
74
+	 */
75
+	protected function filterInterpolation()
76
+	{
77
+		add_filter('site-reviews/interpolate/reviews-form', function ($context) {
78
+			$context['class'] = 'glsr-default glsr-block-disabled';
79
+			$context['fields'] = __('You have hidden all of the fields for this block.', 'site-reviews');
80
+			$context['response'] = '';
81
+			$context['submit_button'] = '';
82
+			return $context;
83
+		});
84
+	}
85 85
 
86
-    /**
87
-     * @return void
88
-     */
89
-    protected function filterRatingField()
90
-    {
91
-        add_filter('site-reviews/rendered/field', function ($html, $type, $args) {
92
-            if ('rating' == $args['path']) {
93
-                $stars = '<span class="glsr-stars">';
94
-                $stars.= str_repeat('<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int) glsr()->constant('MAX_RATING', Rating::class));
95
-                $stars.= '</span>';
96
-                $html = preg_replace('/(.*)(<select.*)(<\/select>)(.*)/u', '$1'.$stars.'$4', $html);
97
-            }
98
-            return $html;
99
-        }, 10, 3);
100
-    }
86
+	/**
87
+	 * @return void
88
+	 */
89
+	protected function filterRatingField()
90
+	{
91
+		add_filter('site-reviews/rendered/field', function ($html, $type, $args) {
92
+			if ('rating' == $args['path']) {
93
+				$stars = '<span class="glsr-stars">';
94
+				$stars.= str_repeat('<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int) glsr()->constant('MAX_RATING', Rating::class));
95
+				$stars.= '</span>';
96
+				$html = preg_replace('/(.*)(<select.*)(<\/select>)(.*)/u', '$1'.$stars.'$4', $html);
97
+			}
98
+			return $html;
99
+		}, 10, 3);
100
+	}
101 101
 
102
-    /**
103
-     * @return void
104
-     */
105
-    protected function filterShortcodeClass()
106
-    {
107
-        add_filter('site-reviews/style', function () {
108
-            return 'default';
109
-        });
110
-    }
102
+	/**
103
+	 * @return void
104
+	 */
105
+	protected function filterShortcodeClass()
106
+	{
107
+		add_filter('site-reviews/style', function () {
108
+			return 'default';
109
+		});
110
+	}
111 111
 
112
-    /**
113
-     * @return void
114
-     */
115
-    protected function filterSubmitButton()
116
-    {
117
-        add_filter('site-reviews/rendered/template/form/submit-button', function ($template) {
118
-            return str_replace('type="submit"', 'tabindex="-1"', $template);
119
-        });
120
-    }
112
+	/**
113
+	 * @return void
114
+	 */
115
+	protected function filterSubmitButton()
116
+	{
117
+		add_filter('site-reviews/rendered/template/form/submit-button', function ($template) {
118
+			return str_replace('type="submit"', 'tabindex="-1"', $template);
119
+		});
120
+	}
121 121
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -39,20 +39,20 @@  discard block
 block discarded – undo
39 39
     /**
40 40
      * @return string
41 41
      */
42
-    public function render(array $attributes)
42
+    public function render( array $attributes )
43 43
     {
44 44
         $attributes['class'] = $attributes['className'];
45
-        $shortcode = glsr(Shortcode::class);
46
-        if ('edit' == filter_input(INPUT_GET, 'context')) {
45
+        $shortcode = glsr( Shortcode::class );
46
+        if( 'edit' == filter_input( INPUT_GET, 'context' ) ) {
47 47
             $this->filterFormFields();
48 48
             $this->filterRatingField();
49 49
             $this->filterShortcodeClass();
50 50
             $this->filterSubmitButton();
51
-            if (!$this->hasVisibleFields($shortcode, $attributes)) {
51
+            if( !$this->hasVisibleFields( $shortcode, $attributes ) ) {
52 52
                 $this->filterInterpolation();
53 53
             }
54 54
         }
55
-        return $shortcode->buildShortcode($attributes);
55
+        return $shortcode->buildShortcode( $attributes );
56 56
     }
57 57
 
58 58
     /**
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
      */
61 61
     protected function filterFormFields()
62 62
     {
63
-        add_filter('site-reviews/config/forms/submission-form', function (array $config) {
64
-            array_walk($config, function (&$field) {
63
+        add_filter( 'site-reviews/config/forms/submission-form', function( array $config ) {
64
+            array_walk( $config, function( &$field ) {
65 65
                 $field['disabled'] = true;
66 66
                 $field['tabindex'] = '-1';
67 67
             });
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
      */
75 75
     protected function filterInterpolation()
76 76
     {
77
-        add_filter('site-reviews/interpolate/reviews-form', function ($context) {
77
+        add_filter( 'site-reviews/interpolate/reviews-form', function( $context ) {
78 78
             $context['class'] = 'glsr-default glsr-block-disabled';
79
-            $context['fields'] = __('You have hidden all of the fields for this block.', 'site-reviews');
79
+            $context['fields'] = __( 'You have hidden all of the fields for this block.', 'site-reviews' );
80 80
             $context['response'] = '';
81 81
             $context['submit_button'] = '';
82 82
             return $context;
@@ -88,15 +88,15 @@  discard block
 block discarded – undo
88 88
      */
89 89
     protected function filterRatingField()
90 90
     {
91
-        add_filter('site-reviews/rendered/field', function ($html, $type, $args) {
92
-            if ('rating' == $args['path']) {
91
+        add_filter( 'site-reviews/rendered/field', function( $html, $type, $args ) {
92
+            if( 'rating' == $args['path'] ) {
93 93
                 $stars = '<span class="glsr-stars">';
94
-                $stars.= str_repeat('<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int) glsr()->constant('MAX_RATING', Rating::class));
95
-                $stars.= '</span>';
96
-                $html = preg_replace('/(.*)(<select.*)(<\/select>)(.*)/u', '$1'.$stars.'$4', $html);
94
+                $stars .= str_repeat( '<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int)glsr()->constant( 'MAX_RATING', Rating::class ) );
95
+                $stars .= '</span>';
96
+                $html = preg_replace( '/(.*)(<select.*)(<\/select>)(.*)/u', '$1'.$stars.'$4', $html );
97 97
             }
98 98
             return $html;
99
-        }, 10, 3);
99
+        }, 10, 3 );
100 100
     }
101 101
 
102 102
     /**
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
      */
105 105
     protected function filterShortcodeClass()
106 106
     {
107
-        add_filter('site-reviews/style', function () {
107
+        add_filter( 'site-reviews/style', function() {
108 108
             return 'default';
109 109
         });
110 110
     }
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
      */
115 115
     protected function filterSubmitButton()
116 116
     {
117
-        add_filter('site-reviews/rendered/template/form/submit-button', function ($template) {
118
-            return str_replace('type="submit"', 'tabindex="-1"', $template);
117
+        add_filter( 'site-reviews/rendered/template/form/submit-button', function( $template ) {
118
+            return str_replace( 'type="submit"', 'tabindex="-1"', $template );
119 119
         });
120 120
     }
121 121
 }
Please login to merge, or discard this patch.
plugin/Blocks/SiteReviewsBlock.php 2 patches
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -6,124 +6,124 @@
 block discarded – undo
6 6
 
7 7
 class SiteReviewsBlock extends BlockGenerator
8 8
 {
9
-    /**
10
-     * @return array
11
-     */
12
-    public function attributes()
13
-    {
14
-        return [
15
-            'assigned_to' => [
16
-                'default' => '',
17
-                'type' => 'string',
18
-            ],
19
-            'category' => [
20
-                'default' => '',
21
-                'type' => 'string',
22
-            ],
23
-            'className' => [
24
-                'default' => '',
25
-                'type' => 'string',
26
-            ],
27
-            'display' => [
28
-                'default' => 5,
29
-                'type' => 'number',
30
-            ],
31
-            'hide' => [
32
-                'default' => '',
33
-                'type' => 'string',
34
-            ],
35
-            'id' => [
36
-                'default' => '',
37
-                'type' => 'string',
38
-            ],
39
-            'pagination' => [
40
-                'default' => '',
41
-                'type' => 'string',
42
-            ],
43
-            'post_id' => [
44
-                'default' => '',
45
-                'type' => 'string',
46
-            ],
47
-            'rating' => [
48
-                'default' => 0,
49
-                'type' => 'number',
50
-            ],
51
-            'schema' => [
52
-                'default' => false,
53
-                'type' => 'boolean',
54
-            ],
55
-            'type' => [
56
-                'default' => 'local',
57
-                'type' => 'string',
58
-            ],
59
-        ];
60
-    }
9
+	/**
10
+	 * @return array
11
+	 */
12
+	public function attributes()
13
+	{
14
+		return [
15
+			'assigned_to' => [
16
+				'default' => '',
17
+				'type' => 'string',
18
+			],
19
+			'category' => [
20
+				'default' => '',
21
+				'type' => 'string',
22
+			],
23
+			'className' => [
24
+				'default' => '',
25
+				'type' => 'string',
26
+			],
27
+			'display' => [
28
+				'default' => 5,
29
+				'type' => 'number',
30
+			],
31
+			'hide' => [
32
+				'default' => '',
33
+				'type' => 'string',
34
+			],
35
+			'id' => [
36
+				'default' => '',
37
+				'type' => 'string',
38
+			],
39
+			'pagination' => [
40
+				'default' => '',
41
+				'type' => 'string',
42
+			],
43
+			'post_id' => [
44
+				'default' => '',
45
+				'type' => 'string',
46
+			],
47
+			'rating' => [
48
+				'default' => 0,
49
+				'type' => 'number',
50
+			],
51
+			'schema' => [
52
+				'default' => false,
53
+				'type' => 'boolean',
54
+			],
55
+			'type' => [
56
+				'default' => 'local',
57
+				'type' => 'string',
58
+			],
59
+		];
60
+	}
61 61
 
62
-    /**
63
-     * @return string
64
-     */
65
-    public function render(array $attributes)
66
-    {
67
-        $attributes['class'] = $attributes['className'];
68
-        $shortcode = glsr(Shortcode::class);
69
-        if ('edit' == filter_input(INPUT_GET, 'context')) {
70
-            $attributes = $this->normalize($attributes);
71
-            $this->filterReviewLinks();
72
-            $this->filterShortcodeClass();
73
-            $this->filterShowMoreLinks('content');
74
-            $this->filterShowMoreLinks('response');
75
-            if (!$this->hasVisibleFields($shortcode, $attributes)) {
76
-                $this->filterInterpolation();
77
-            }
78
-        }
79
-        return $shortcode->buildShortcode($attributes);
80
-    }
62
+	/**
63
+	 * @return string
64
+	 */
65
+	public function render(array $attributes)
66
+	{
67
+		$attributes['class'] = $attributes['className'];
68
+		$shortcode = glsr(Shortcode::class);
69
+		if ('edit' == filter_input(INPUT_GET, 'context')) {
70
+			$attributes = $this->normalize($attributes);
71
+			$this->filterReviewLinks();
72
+			$this->filterShortcodeClass();
73
+			$this->filterShowMoreLinks('content');
74
+			$this->filterShowMoreLinks('response');
75
+			if (!$this->hasVisibleFields($shortcode, $attributes)) {
76
+				$this->filterInterpolation();
77
+			}
78
+		}
79
+		return $shortcode->buildShortcode($attributes);
80
+	}
81 81
 
82
-    /**
83
-     * @return void
84
-     */
85
-    protected function filterInterpolation()
86
-    {
87
-        add_filter('site-reviews/interpolate/reviews', function ($context) {
88
-            $context['class'] = 'glsr-default glsr-block-disabled';
89
-            $context['reviews'] = __('You have hidden all of the fields for this block.', 'site-reviews');
90
-            return $context;
91
-        });
92
-    }
82
+	/**
83
+	 * @return void
84
+	 */
85
+	protected function filterInterpolation()
86
+	{
87
+		add_filter('site-reviews/interpolate/reviews', function ($context) {
88
+			$context['class'] = 'glsr-default glsr-block-disabled';
89
+			$context['reviews'] = __('You have hidden all of the fields for this block.', 'site-reviews');
90
+			return $context;
91
+		});
92
+	}
93 93
 
94
-    /**
95
-     * @return void
96
-     */
97
-    protected function filterReviewLinks()
98
-    {
99
-        add_filter('site-reviews/rendered/template/reviews', function ($template) {
100
-            return str_replace('<a', '<a tabindex="-1"', $template);
101
-        });
102
-    }
94
+	/**
95
+	 * @return void
96
+	 */
97
+	protected function filterReviewLinks()
98
+	{
99
+		add_filter('site-reviews/rendered/template/reviews', function ($template) {
100
+			return str_replace('<a', '<a tabindex="-1"', $template);
101
+		});
102
+	}
103 103
 
104
-    /**
105
-     * @return void
106
-     */
107
-    protected function filterShortcodeClass()
108
-    {
109
-        add_filter('site-reviews/style', function () {
110
-            return 'default';
111
-        });
112
-    }
104
+	/**
105
+	 * @return void
106
+	 */
107
+	protected function filterShortcodeClass()
108
+	{
109
+		add_filter('site-reviews/style', function () {
110
+			return 'default';
111
+		});
112
+	}
113 113
 
114
-    /**
115
-     * @param string $field
116
-     * @return void
117
-     */
118
-    protected function filterShowMoreLinks($field)
119
-    {
120
-        add_filter('site-reviews/review/wrap/'.$field, function ($value) {
121
-            $value = preg_replace(
122
-                '/(.*)(<span class="glsr-hidden)(.*)(<\/span>)(.*)/us',
123
-                '$1... <a href="#" class="glsr-read-more" tabindex="-1">'.__('Show more', 'site-reviews').'</a>$5',
124
-                $value
125
-            );
126
-            return $value;
127
-        });
128
-    }
114
+	/**
115
+	 * @param string $field
116
+	 * @return void
117
+	 */
118
+	protected function filterShowMoreLinks($field)
119
+	{
120
+		add_filter('site-reviews/review/wrap/'.$field, function ($value) {
121
+			$value = preg_replace(
122
+				'/(.*)(<span class="glsr-hidden)(.*)(<\/span>)(.*)/us',
123
+				'$1... <a href="#" class="glsr-read-more" tabindex="-1">'.__('Show more', 'site-reviews').'</a>$5',
124
+				$value
125
+			);
126
+			return $value;
127
+		});
128
+	}
129 129
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -62,21 +62,21 @@  discard block
 block discarded – undo
62 62
     /**
63 63
      * @return string
64 64
      */
65
-    public function render(array $attributes)
65
+    public function render( array $attributes )
66 66
     {
67 67
         $attributes['class'] = $attributes['className'];
68
-        $shortcode = glsr(Shortcode::class);
69
-        if ('edit' == filter_input(INPUT_GET, 'context')) {
70
-            $attributes = $this->normalize($attributes);
68
+        $shortcode = glsr( Shortcode::class );
69
+        if( 'edit' == filter_input( INPUT_GET, 'context' ) ) {
70
+            $attributes = $this->normalize( $attributes );
71 71
             $this->filterReviewLinks();
72 72
             $this->filterShortcodeClass();
73
-            $this->filterShowMoreLinks('content');
74
-            $this->filterShowMoreLinks('response');
75
-            if (!$this->hasVisibleFields($shortcode, $attributes)) {
73
+            $this->filterShowMoreLinks( 'content' );
74
+            $this->filterShowMoreLinks( 'response' );
75
+            if( !$this->hasVisibleFields( $shortcode, $attributes ) ) {
76 76
                 $this->filterInterpolation();
77 77
             }
78 78
         }
79
-        return $shortcode->buildShortcode($attributes);
79
+        return $shortcode->buildShortcode( $attributes );
80 80
     }
81 81
 
82 82
     /**
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
      */
85 85
     protected function filterInterpolation()
86 86
     {
87
-        add_filter('site-reviews/interpolate/reviews', function ($context) {
87
+        add_filter( 'site-reviews/interpolate/reviews', function( $context ) {
88 88
             $context['class'] = 'glsr-default glsr-block-disabled';
89
-            $context['reviews'] = __('You have hidden all of the fields for this block.', 'site-reviews');
89
+            $context['reviews'] = __( 'You have hidden all of the fields for this block.', 'site-reviews' );
90 90
             return $context;
91 91
         });
92 92
     }
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
      */
97 97
     protected function filterReviewLinks()
98 98
     {
99
-        add_filter('site-reviews/rendered/template/reviews', function ($template) {
100
-            return str_replace('<a', '<a tabindex="-1"', $template);
99
+        add_filter( 'site-reviews/rendered/template/reviews', function( $template ) {
100
+            return str_replace( '<a', '<a tabindex="-1"', $template );
101 101
         });
102 102
     }
103 103
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
      */
107 107
     protected function filterShortcodeClass()
108 108
     {
109
-        add_filter('site-reviews/style', function () {
109
+        add_filter( 'site-reviews/style', function() {
110 110
             return 'default';
111 111
         });
112 112
     }
@@ -115,12 +115,12 @@  discard block
 block discarded – undo
115 115
      * @param string $field
116 116
      * @return void
117 117
      */
118
-    protected function filterShowMoreLinks($field)
118
+    protected function filterShowMoreLinks( $field )
119 119
     {
120
-        add_filter('site-reviews/review/wrap/'.$field, function ($value) {
120
+        add_filter( 'site-reviews/review/wrap/'.$field, function( $value ) {
121 121
             $value = preg_replace(
122 122
                 '/(.*)(<span class="glsr-hidden)(.*)(<\/span>)(.*)/us',
123
-                '$1... <a href="#" class="glsr-read-more" tabindex="-1">'.__('Show more', 'site-reviews').'</a>$5',
123
+                '$1... <a href="#" class="glsr-read-more" tabindex="-1">'.__( 'Show more', 'site-reviews' ).'</a>$5',
124 124
                 $value
125 125
             );
126 126
             return $value;
Please login to merge, or discard this patch.
views/partials/notices/trustalyze.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <div class="notice is-dismissible glsr-notice" data-dismiss="trustalyze">
2 2
     <div class="glsr-notice-icon">
3
-        <img width="96" height="96" src="<?= glsr()->url('assets/images/trustalyze-badge.png'); ?>">
3
+        <img width="96" height="96" src="<?= glsr()->url( 'assets/images/trustalyze-badge.png' ); ?>">
4 4
     </div>
5 5
     <div class="glsr-notice-content">
6 6
         <h3>Validate Your Reviews on the Blockchain With the Trustalyze Confidence System</h3>
7 7
         <p>Site Reviews integrates with the <a href="https://trustalyze.com/plans?ref=105">Trustalyze Confidence System</a>, a service which uses blockchain technology to verify to your visitors and customers that your reviews are authentic.</p>
8
-        <a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general'); ?>" class="button">Enable the integration</a>
8
+        <a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general' ); ?>" class="button">Enable the integration</a>
9 9
     </div>
10 10
 </div>
Please login to merge, or discard this patch.
plugin/Controllers/TrustalyzeController.php 3 patches
Indentation   +206 added lines, -206 removed lines patch added patch discarded remove patch
@@ -12,210 +12,210 @@
 block discarded – undo
12 12
 
13 13
 class TrustalyzeController extends Controller
14 14
 {
15
-    protected $apiKey = 'settings.general.trustalyze_serial';
16
-    protected $emailKey = 'settings.general.trustalyze_email';
17
-    protected $enabledKey = 'settings.general.trustalyze';
18
-    protected $trustalyzeKey = '_glsr_trustalyze';
19
-
20
-    /**
21
-     * @return array
22
-     * @filter site-reviews/settings/callback
23
-     */
24
-    public function filterSettingsCallback(array $settings)
25
-    {
26
-        if ('yes' !== Arr::get($settings, $this->enabledKey)) {
27
-            return $settings;
28
-        }
29
-        $isApiKeyModified = $this->isEmptyOrModified($this->apiKey, $settings);
30
-        $isEmailModified = $this->isEmptyOrModified($this->emailKey, $settings);
31
-        $isAccountVerified = glsr(OptionManager::class)->getWP($this->trustalyzeKey, false);
32
-        if (!$isAccountVerified || $isApiKeyModified || $isEmailModified) {
33
-            $settings = $this->sanitizeTrustalyzeSettings($settings);
34
-        }
35
-        return $settings;
36
-    }
37
-
38
-    /**
39
-     * @param string $template
40
-     * @return array
41
-     * @filter site-reviews/interpolate/partials/form/table-row-multiple
42
-     */
43
-    public function filterSettingsTableRow(array $context, $template, array $data)
44
-    {
45
-        if ($this->enabledKey !== Arr::get($data, 'field.path')) {
46
-            return $context;
47
-        }
48
-        $isAccountValidated = !empty(glsr(OptionManager::class)->getWP($this->trustalyzeKey));
49
-        $isIntegrationEnabled = glsr(OptionManager::class)->getBool('settings.general.trustalyze');
50
-        if ($isAccountValidated && $isIntegrationEnabled) {
51
-            return $context;
52
-        }
53
-        $context['field'].= $this->buildCreateButton();
54
-        return $context;
55
-    }
56
-
57
-    /**
58
-     * Triggered when a review is created.
59
-     * @return void
60
-     * @action site-reviews/review/created
61
-     */
62
-    public function onCreated(Review $review)
63
-    {
64
-        if (!$this->canPostReview($review)) {
65
-            return;
66
-        }
67
-        $trustalyze = glsr(Trustalyze::class)->sendReview($review);
68
-        if ($trustalyze->success) {
69
-            glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id);
70
-        }
71
-    }
72
-
73
-    /**
74
-     * Triggered when a review is reverted to its original title/content/date_timestamp.
75
-     * @return void
76
-     * @action site-reviews/review/reverted
77
-     */
78
-    public function onReverted(Review $review)
79
-    {
80
-        if (!$this->canPostReview($review)) {
81
-            return;
82
-        }
83
-        $trustalyze = glsr(Trustalyze::class)->sendReview($review);
84
-        if ($trustalyze->success) {
85
-            glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id);
86
-        }
87
-    }
88
-
89
-    /**
90
-     * Triggered when an existing review is updated.
91
-     * @return void
92
-     * @action site-reviews/review/saved
93
-     */
94
-    public function onSaved(Review $review)
95
-    {
96
-        if (!$this->canPostReview($review)) {
97
-            return;
98
-        }
99
-        $trustalyze = glsr(Trustalyze::class)->sendReview($review);
100
-        if ($trustalyze->success) {
101
-            glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id);
102
-        }
103
-    }
104
-
105
-    /**
106
-     * Triggered when a review's response is added or updated.
107
-     * @param int $metaId
108
-     * @param int $postId
109
-     * @param string $metaKey
110
-     * @return void
111
-     * @action updated_postmeta
112
-     */
113
-    public function onUpdatedMeta($metaId, $postId, $metaKey)
114
-    {
115
-        $review = glsr_get_review($postId);
116
-        if (!$this->canPostResponse($review) || '_response' !== $metaKey) {
117
-            return;
118
-        }
119
-        $trustalyze = glsr(Trustalyze::class)->sendReviewResponse($review);
120
-        if ($trustalyze->success) {
121
-            glsr(Database::class)->set($review->ID, 'trustalyze_response', true);
122
-        }
123
-    }
124
-
125
-    /**
126
-     * @return string
127
-     */
128
-    protected function buildCreateButton()
129
-    {
130
-        return glsr(Builder::class)->a(__('Create Your Trustalyze Account', 'site-reviews'), [
131
-            'class' => 'button',
132
-            'href' => Trustalyze::WEB_URL,
133
-            'target' => '_blank',
134
-        ]);
135
-    }
136
-
137
-    /**
138
-     * @return bool
139
-     */
140
-    protected function canPostResponse(Review $review)
141
-    {
142
-        $requiredValues = [
143
-            glsr(Database::class)->get($review->ID, 'trustalyze'),
144
-            $review->response,
145
-            $review->review_id,
146
-        ];
147
-        return $this->canProceed($review, 'trustalyze_response')
148
-            && 'publish' === $review->status
149
-            && 3 === count(array_filter($requiredValues));
150
-    }
151
-
152
-    /**
153
-     * @return bool
154
-     */
155
-    protected function canPostReview(Review $review)
156
-    {
157
-        $requiredValues = [
158
-            $review->author,
159
-            $review->content,
160
-            $review->rating,
161
-            $review->review_id,
162
-            $review->title,
163
-        ];
164
-        return $this->canProceed($review)
165
-            && 'publish' === $review->status
166
-            && 5 === count(array_filter($requiredValues));
167
-    }
168
-
169
-    /**
170
-     * @param string $metaKey
171
-     * @return bool
172
-     */
173
-    protected function canProceed(Review $review, $metaKey = 'trustalyze')
174
-    {
175
-        return glsr(OptionManager::class)->getBool($this->enabledKey)
176
-            && $this->isReviewPostId($review->ID)
177
-            && !$this->hasMetaKey($review, $metaKey);
178
-    }
179
-
180
-    /**
181
-     * @param string $metaKey
182
-     * @return bool
183
-     */
184
-    protected function hasMetaKey(Review $review, $metaKey = 'trustalyze')
185
-    {
186
-        return '' !== glsr(Database::class)->get($review->ID, $metaKey);
187
-    }
188
-
189
-    /**
190
-     * @param string $key
191
-     * @return bool
192
-     */
193
-    protected function isEmptyOrModified($key, array $settings)
194
-    {
195
-        $oldValue = glsr_get_option($key);
196
-        $newValue = Arr::get($settings, $key);
197
-        return empty($newValue) || $newValue !== $oldValue;
198
-    }
199
-
200
-    /**
201
-     * @return array
202
-     */
203
-    protected function sanitizeTrustalyzeSettings(array $settings)
204
-    {
205
-        $trustalyze = glsr(Trustalyze::class)->activateKey(
206
-            Arr::get($settings, $this->apiKey),
207
-            Arr::get($settings, $this->emailKey)
208
-        );
209
-        if ($trustalyze->success) {
210
-            update_option($this->trustalyzeKey, Arr::get($trustalyze->response, 'producttype'));
211
-        } else {
212
-            delete_option($this->trustalyzeKey);
213
-            $settings = Arr::set($settings, $this->enabledKey, 'no');
214
-            glsr(Notice::class)->addError(sprintf(
215
-                __('Your Trustalyze account details could not be verified, please try again. %s', 'site-reviews'),
216
-                '('.$trustalyze->message.')'
217
-            ));
218
-        }
219
-        return $settings;
220
-    }
15
+	protected $apiKey = 'settings.general.trustalyze_serial';
16
+	protected $emailKey = 'settings.general.trustalyze_email';
17
+	protected $enabledKey = 'settings.general.trustalyze';
18
+	protected $trustalyzeKey = '_glsr_trustalyze';
19
+
20
+	/**
21
+	 * @return array
22
+	 * @filter site-reviews/settings/callback
23
+	 */
24
+	public function filterSettingsCallback(array $settings)
25
+	{
26
+		if ('yes' !== Arr::get($settings, $this->enabledKey)) {
27
+			return $settings;
28
+		}
29
+		$isApiKeyModified = $this->isEmptyOrModified($this->apiKey, $settings);
30
+		$isEmailModified = $this->isEmptyOrModified($this->emailKey, $settings);
31
+		$isAccountVerified = glsr(OptionManager::class)->getWP($this->trustalyzeKey, false);
32
+		if (!$isAccountVerified || $isApiKeyModified || $isEmailModified) {
33
+			$settings = $this->sanitizeTrustalyzeSettings($settings);
34
+		}
35
+		return $settings;
36
+	}
37
+
38
+	/**
39
+	 * @param string $template
40
+	 * @return array
41
+	 * @filter site-reviews/interpolate/partials/form/table-row-multiple
42
+	 */
43
+	public function filterSettingsTableRow(array $context, $template, array $data)
44
+	{
45
+		if ($this->enabledKey !== Arr::get($data, 'field.path')) {
46
+			return $context;
47
+		}
48
+		$isAccountValidated = !empty(glsr(OptionManager::class)->getWP($this->trustalyzeKey));
49
+		$isIntegrationEnabled = glsr(OptionManager::class)->getBool('settings.general.trustalyze');
50
+		if ($isAccountValidated && $isIntegrationEnabled) {
51
+			return $context;
52
+		}
53
+		$context['field'].= $this->buildCreateButton();
54
+		return $context;
55
+	}
56
+
57
+	/**
58
+	 * Triggered when a review is created.
59
+	 * @return void
60
+	 * @action site-reviews/review/created
61
+	 */
62
+	public function onCreated(Review $review)
63
+	{
64
+		if (!$this->canPostReview($review)) {
65
+			return;
66
+		}
67
+		$trustalyze = glsr(Trustalyze::class)->sendReview($review);
68
+		if ($trustalyze->success) {
69
+			glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id);
70
+		}
71
+	}
72
+
73
+	/**
74
+	 * Triggered when a review is reverted to its original title/content/date_timestamp.
75
+	 * @return void
76
+	 * @action site-reviews/review/reverted
77
+	 */
78
+	public function onReverted(Review $review)
79
+	{
80
+		if (!$this->canPostReview($review)) {
81
+			return;
82
+		}
83
+		$trustalyze = glsr(Trustalyze::class)->sendReview($review);
84
+		if ($trustalyze->success) {
85
+			glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id);
86
+		}
87
+	}
88
+
89
+	/**
90
+	 * Triggered when an existing review is updated.
91
+	 * @return void
92
+	 * @action site-reviews/review/saved
93
+	 */
94
+	public function onSaved(Review $review)
95
+	{
96
+		if (!$this->canPostReview($review)) {
97
+			return;
98
+		}
99
+		$trustalyze = glsr(Trustalyze::class)->sendReview($review);
100
+		if ($trustalyze->success) {
101
+			glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id);
102
+		}
103
+	}
104
+
105
+	/**
106
+	 * Triggered when a review's response is added or updated.
107
+	 * @param int $metaId
108
+	 * @param int $postId
109
+	 * @param string $metaKey
110
+	 * @return void
111
+	 * @action updated_postmeta
112
+	 */
113
+	public function onUpdatedMeta($metaId, $postId, $metaKey)
114
+	{
115
+		$review = glsr_get_review($postId);
116
+		if (!$this->canPostResponse($review) || '_response' !== $metaKey) {
117
+			return;
118
+		}
119
+		$trustalyze = glsr(Trustalyze::class)->sendReviewResponse($review);
120
+		if ($trustalyze->success) {
121
+			glsr(Database::class)->set($review->ID, 'trustalyze_response', true);
122
+		}
123
+	}
124
+
125
+	/**
126
+	 * @return string
127
+	 */
128
+	protected function buildCreateButton()
129
+	{
130
+		return glsr(Builder::class)->a(__('Create Your Trustalyze Account', 'site-reviews'), [
131
+			'class' => 'button',
132
+			'href' => Trustalyze::WEB_URL,
133
+			'target' => '_blank',
134
+		]);
135
+	}
136
+
137
+	/**
138
+	 * @return bool
139
+	 */
140
+	protected function canPostResponse(Review $review)
141
+	{
142
+		$requiredValues = [
143
+			glsr(Database::class)->get($review->ID, 'trustalyze'),
144
+			$review->response,
145
+			$review->review_id,
146
+		];
147
+		return $this->canProceed($review, 'trustalyze_response')
148
+			&& 'publish' === $review->status
149
+			&& 3 === count(array_filter($requiredValues));
150
+	}
151
+
152
+	/**
153
+	 * @return bool
154
+	 */
155
+	protected function canPostReview(Review $review)
156
+	{
157
+		$requiredValues = [
158
+			$review->author,
159
+			$review->content,
160
+			$review->rating,
161
+			$review->review_id,
162
+			$review->title,
163
+		];
164
+		return $this->canProceed($review)
165
+			&& 'publish' === $review->status
166
+			&& 5 === count(array_filter($requiredValues));
167
+	}
168
+
169
+	/**
170
+	 * @param string $metaKey
171
+	 * @return bool
172
+	 */
173
+	protected function canProceed(Review $review, $metaKey = 'trustalyze')
174
+	{
175
+		return glsr(OptionManager::class)->getBool($this->enabledKey)
176
+			&& $this->isReviewPostId($review->ID)
177
+			&& !$this->hasMetaKey($review, $metaKey);
178
+	}
179
+
180
+	/**
181
+	 * @param string $metaKey
182
+	 * @return bool
183
+	 */
184
+	protected function hasMetaKey(Review $review, $metaKey = 'trustalyze')
185
+	{
186
+		return '' !== glsr(Database::class)->get($review->ID, $metaKey);
187
+	}
188
+
189
+	/**
190
+	 * @param string $key
191
+	 * @return bool
192
+	 */
193
+	protected function isEmptyOrModified($key, array $settings)
194
+	{
195
+		$oldValue = glsr_get_option($key);
196
+		$newValue = Arr::get($settings, $key);
197
+		return empty($newValue) || $newValue !== $oldValue;
198
+	}
199
+
200
+	/**
201
+	 * @return array
202
+	 */
203
+	protected function sanitizeTrustalyzeSettings(array $settings)
204
+	{
205
+		$trustalyze = glsr(Trustalyze::class)->activateKey(
206
+			Arr::get($settings, $this->apiKey),
207
+			Arr::get($settings, $this->emailKey)
208
+		);
209
+		if ($trustalyze->success) {
210
+			update_option($this->trustalyzeKey, Arr::get($trustalyze->response, 'producttype'));
211
+		} else {
212
+			delete_option($this->trustalyzeKey);
213
+			$settings = Arr::set($settings, $this->enabledKey, 'no');
214
+			glsr(Notice::class)->addError(sprintf(
215
+				__('Your Trustalyze account details could not be verified, please try again. %s', 'site-reviews'),
216
+				'('.$trustalyze->message.')'
217
+			));
218
+		}
219
+		return $settings;
220
+	}
221 221
 }
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -21,16 +21,16 @@  discard block
 block discarded – undo
21 21
      * @return array
22 22
      * @filter site-reviews/settings/callback
23 23
      */
24
-    public function filterSettingsCallback(array $settings)
24
+    public function filterSettingsCallback( array $settings )
25 25
     {
26
-        if ('yes' !== Arr::get($settings, $this->enabledKey)) {
26
+        if( 'yes' !== Arr::get( $settings, $this->enabledKey ) ) {
27 27
             return $settings;
28 28
         }
29
-        $isApiKeyModified = $this->isEmptyOrModified($this->apiKey, $settings);
30
-        $isEmailModified = $this->isEmptyOrModified($this->emailKey, $settings);
31
-        $isAccountVerified = glsr(OptionManager::class)->getWP($this->trustalyzeKey, false);
32
-        if (!$isAccountVerified || $isApiKeyModified || $isEmailModified) {
33
-            $settings = $this->sanitizeTrustalyzeSettings($settings);
29
+        $isApiKeyModified = $this->isEmptyOrModified( $this->apiKey, $settings );
30
+        $isEmailModified = $this->isEmptyOrModified( $this->emailKey, $settings );
31
+        $isAccountVerified = glsr( OptionManager::class )->getWP( $this->trustalyzeKey, false );
32
+        if( !$isAccountVerified || $isApiKeyModified || $isEmailModified ) {
33
+            $settings = $this->sanitizeTrustalyzeSettings( $settings );
34 34
         }
35 35
         return $settings;
36 36
     }
@@ -40,17 +40,17 @@  discard block
 block discarded – undo
40 40
      * @return array
41 41
      * @filter site-reviews/interpolate/partials/form/table-row-multiple
42 42
      */
43
-    public function filterSettingsTableRow(array $context, $template, array $data)
43
+    public function filterSettingsTableRow( array $context, $template, array $data )
44 44
     {
45
-        if ($this->enabledKey !== Arr::get($data, 'field.path')) {
45
+        if( $this->enabledKey !== Arr::get( $data, 'field.path' ) ) {
46 46
             return $context;
47 47
         }
48
-        $isAccountValidated = !empty(glsr(OptionManager::class)->getWP($this->trustalyzeKey));
49
-        $isIntegrationEnabled = glsr(OptionManager::class)->getBool('settings.general.trustalyze');
50
-        if ($isAccountValidated && $isIntegrationEnabled) {
48
+        $isAccountValidated = !empty(glsr( OptionManager::class )->getWP( $this->trustalyzeKey ));
49
+        $isIntegrationEnabled = glsr( OptionManager::class )->getBool( 'settings.general.trustalyze' );
50
+        if( $isAccountValidated && $isIntegrationEnabled ) {
51 51
             return $context;
52 52
         }
53
-        $context['field'].= $this->buildCreateButton();
53
+        $context['field'] .= $this->buildCreateButton();
54 54
         return $context;
55 55
     }
56 56
 
@@ -59,14 +59,14 @@  discard block
 block discarded – undo
59 59
      * @return void
60 60
      * @action site-reviews/review/created
61 61
      */
62
-    public function onCreated(Review $review)
62
+    public function onCreated( Review $review )
63 63
     {
64
-        if (!$this->canPostReview($review)) {
64
+        if( !$this->canPostReview( $review ) ) {
65 65
             return;
66 66
         }
67
-        $trustalyze = glsr(Trustalyze::class)->sendReview($review);
68
-        if ($trustalyze->success) {
69
-            glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id);
67
+        $trustalyze = glsr( Trustalyze::class )->sendReview( $review );
68
+        if( $trustalyze->success ) {
69
+            glsr( Database::class )->set( $review->ID, 'trustalyze', $trustalyze->review_id );
70 70
         }
71 71
     }
72 72
 
@@ -75,14 +75,14 @@  discard block
 block discarded – undo
75 75
      * @return void
76 76
      * @action site-reviews/review/reverted
77 77
      */
78
-    public function onReverted(Review $review)
78
+    public function onReverted( Review $review )
79 79
     {
80
-        if (!$this->canPostReview($review)) {
80
+        if( !$this->canPostReview( $review ) ) {
81 81
             return;
82 82
         }
83
-        $trustalyze = glsr(Trustalyze::class)->sendReview($review);
84
-        if ($trustalyze->success) {
85
-            glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id);
83
+        $trustalyze = glsr( Trustalyze::class )->sendReview( $review );
84
+        if( $trustalyze->success ) {
85
+            glsr( Database::class )->set( $review->ID, 'trustalyze', $trustalyze->review_id );
86 86
         }
87 87
     }
88 88
 
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
      * @return void
92 92
      * @action site-reviews/review/saved
93 93
      */
94
-    public function onSaved(Review $review)
94
+    public function onSaved( Review $review )
95 95
     {
96
-        if (!$this->canPostReview($review)) {
96
+        if( !$this->canPostReview( $review ) ) {
97 97
             return;
98 98
         }
99
-        $trustalyze = glsr(Trustalyze::class)->sendReview($review);
100
-        if ($trustalyze->success) {
101
-            glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id);
99
+        $trustalyze = glsr( Trustalyze::class )->sendReview( $review );
100
+        if( $trustalyze->success ) {
101
+            glsr( Database::class )->set( $review->ID, 'trustalyze', $trustalyze->review_id );
102 102
         }
103 103
     }
104 104
 
@@ -110,15 +110,15 @@  discard block
 block discarded – undo
110 110
      * @return void
111 111
      * @action updated_postmeta
112 112
      */
113
-    public function onUpdatedMeta($metaId, $postId, $metaKey)
113
+    public function onUpdatedMeta( $metaId, $postId, $metaKey )
114 114
     {
115
-        $review = glsr_get_review($postId);
116
-        if (!$this->canPostResponse($review) || '_response' !== $metaKey) {
115
+        $review = glsr_get_review( $postId );
116
+        if( !$this->canPostResponse( $review ) || '_response' !== $metaKey ) {
117 117
             return;
118 118
         }
119
-        $trustalyze = glsr(Trustalyze::class)->sendReviewResponse($review);
120
-        if ($trustalyze->success) {
121
-            glsr(Database::class)->set($review->ID, 'trustalyze_response', true);
119
+        $trustalyze = glsr( Trustalyze::class )->sendReviewResponse( $review );
120
+        if( $trustalyze->success ) {
121
+            glsr( Database::class )->set( $review->ID, 'trustalyze_response', true );
122 122
         }
123 123
     }
124 124
 
@@ -127,32 +127,32 @@  discard block
 block discarded – undo
127 127
      */
128 128
     protected function buildCreateButton()
129 129
     {
130
-        return glsr(Builder::class)->a(__('Create Your Trustalyze Account', 'site-reviews'), [
130
+        return glsr( Builder::class )->a( __( 'Create Your Trustalyze Account', 'site-reviews' ), [
131 131
             'class' => 'button',
132 132
             'href' => Trustalyze::WEB_URL,
133 133
             'target' => '_blank',
134
-        ]);
134
+        ] );
135 135
     }
136 136
 
137 137
     /**
138 138
      * @return bool
139 139
      */
140
-    protected function canPostResponse(Review $review)
140
+    protected function canPostResponse( Review $review )
141 141
     {
142 142
         $requiredValues = [
143
-            glsr(Database::class)->get($review->ID, 'trustalyze'),
143
+            glsr( Database::class )->get( $review->ID, 'trustalyze' ),
144 144
             $review->response,
145 145
             $review->review_id,
146 146
         ];
147
-        return $this->canProceed($review, 'trustalyze_response')
147
+        return $this->canProceed( $review, 'trustalyze_response' )
148 148
             && 'publish' === $review->status
149
-            && 3 === count(array_filter($requiredValues));
149
+            && 3 === count( array_filter( $requiredValues ) );
150 150
     }
151 151
 
152 152
     /**
153 153
      * @return bool
154 154
      */
155
-    protected function canPostReview(Review $review)
155
+    protected function canPostReview( Review $review )
156 156
     {
157 157
         $requiredValues = [
158 158
             $review->author,
@@ -161,60 +161,60 @@  discard block
 block discarded – undo
161 161
             $review->review_id,
162 162
             $review->title,
163 163
         ];
164
-        return $this->canProceed($review)
164
+        return $this->canProceed( $review )
165 165
             && 'publish' === $review->status
166
-            && 5 === count(array_filter($requiredValues));
166
+            && 5 === count( array_filter( $requiredValues ) );
167 167
     }
168 168
 
169 169
     /**
170 170
      * @param string $metaKey
171 171
      * @return bool
172 172
      */
173
-    protected function canProceed(Review $review, $metaKey = 'trustalyze')
173
+    protected function canProceed( Review $review, $metaKey = 'trustalyze' )
174 174
     {
175
-        return glsr(OptionManager::class)->getBool($this->enabledKey)
176
-            && $this->isReviewPostId($review->ID)
177
-            && !$this->hasMetaKey($review, $metaKey);
175
+        return glsr( OptionManager::class )->getBool( $this->enabledKey )
176
+            && $this->isReviewPostId( $review->ID )
177
+            && !$this->hasMetaKey( $review, $metaKey );
178 178
     }
179 179
 
180 180
     /**
181 181
      * @param string $metaKey
182 182
      * @return bool
183 183
      */
184
-    protected function hasMetaKey(Review $review, $metaKey = 'trustalyze')
184
+    protected function hasMetaKey( Review $review, $metaKey = 'trustalyze' )
185 185
     {
186
-        return '' !== glsr(Database::class)->get($review->ID, $metaKey);
186
+        return '' !== glsr( Database::class )->get( $review->ID, $metaKey );
187 187
     }
188 188
 
189 189
     /**
190 190
      * @param string $key
191 191
      * @return bool
192 192
      */
193
-    protected function isEmptyOrModified($key, array $settings)
193
+    protected function isEmptyOrModified( $key, array $settings )
194 194
     {
195
-        $oldValue = glsr_get_option($key);
196
-        $newValue = Arr::get($settings, $key);
195
+        $oldValue = glsr_get_option( $key );
196
+        $newValue = Arr::get( $settings, $key );
197 197
         return empty($newValue) || $newValue !== $oldValue;
198 198
     }
199 199
 
200 200
     /**
201 201
      * @return array
202 202
      */
203
-    protected function sanitizeTrustalyzeSettings(array $settings)
203
+    protected function sanitizeTrustalyzeSettings( array $settings )
204 204
     {
205
-        $trustalyze = glsr(Trustalyze::class)->activateKey(
206
-            Arr::get($settings, $this->apiKey),
207
-            Arr::get($settings, $this->emailKey)
205
+        $trustalyze = glsr( Trustalyze::class )->activateKey(
206
+            Arr::get( $settings, $this->apiKey ),
207
+            Arr::get( $settings, $this->emailKey )
208 208
         );
209
-        if ($trustalyze->success) {
210
-            update_option($this->trustalyzeKey, Arr::get($trustalyze->response, 'producttype'));
209
+        if( $trustalyze->success ) {
210
+            update_option( $this->trustalyzeKey, Arr::get( $trustalyze->response, 'producttype' ) );
211 211
         } else {
212
-            delete_option($this->trustalyzeKey);
213
-            $settings = Arr::set($settings, $this->enabledKey, 'no');
214
-            glsr(Notice::class)->addError(sprintf(
215
-                __('Your Trustalyze account details could not be verified, please try again. %s', 'site-reviews'),
212
+            delete_option( $this->trustalyzeKey );
213
+            $settings = Arr::set( $settings, $this->enabledKey, 'no' );
214
+            glsr( Notice::class )->addError( sprintf(
215
+                __( 'Your Trustalyze account details could not be verified, please try again. %s', 'site-reviews' ),
216 216
                 '('.$trustalyze->message.')'
217
-            ));
217
+            ) );
218 218
         }
219 219
         return $settings;
220 220
     }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -208,7 +208,8 @@
 block discarded – undo
208 208
         );
209 209
         if ($trustalyze->success) {
210 210
             update_option($this->trustalyzeKey, Arr::get($trustalyze->response, 'producttype'));
211
-        } else {
211
+        }
212
+        else {
212 213
             delete_option($this->trustalyzeKey);
213 214
             $settings = Arr::set($settings, $this->enabledKey, 'no');
214 215
             glsr(Notice::class)->addError(sprintf(
Please login to merge, or discard this patch.
plugin/Controllers/TranslationController.php 2 patches
Indentation   +227 added lines, -227 removed lines patch added patch discarded remove patch
@@ -11,247 +11,247 @@
 block discarded – undo
11 11
 
12 12
 class TranslationController
13 13
 {
14
-    /**
15
-     * @var Translator
16
-     */
17
-    public $translator;
14
+	/**
15
+	 * @var Translator
16
+	 */
17
+	public $translator;
18 18
 
19
-    public function __construct(Translator $translator)
20
-    {
21
-        $this->translator = $translator;
22
-    }
19
+	public function __construct(Translator $translator)
20
+	{
21
+		$this->translator = $translator;
22
+	}
23 23
 
24
-    /**
25
-     * @return void
26
-     * @action plugins_loaded
27
-     */
28
-    public function addTranslationFilters()
29
-    {
30
-        if (empty(glsr(Translation::class)->translations())) {
31
-            return;
32
-        }
33
-        add_filter('gettext',                                         [$this, 'filterGettext'], 9, 3);
34
-        add_filter('site-reviews/gettext/site-reviews',               [$this, 'filterGettextSiteReviews'], 10, 2);
35
-        add_filter('gettext_with_context',                            [$this, 'filterGettextWithContext'], 9, 4);
36
-        add_filter('site-reviews/gettext_with_context/site-reviews',  [$this, 'filterGettextWithContextSiteReviews'], 10, 3);
37
-        add_filter('ngettext',                                        [$this, 'filterNgettext'], 9, 5);
38
-        add_filter('site-reviews/ngettext/site-reviews',              [$this, 'filterNgettextSiteReviews'], 10, 4);
39
-        add_filter('ngettext_with_context',                           [$this, 'filterNgettextWithContext'], 9, 6);
40
-        add_filter('site-reviews/ngettext_with_context/site-reviews', [$this, 'filterNgettextWithContextSiteReviews'], 10, 5);
41
-    }
24
+	/**
25
+	 * @return void
26
+	 * @action plugins_loaded
27
+	 */
28
+	public function addTranslationFilters()
29
+	{
30
+		if (empty(glsr(Translation::class)->translations())) {
31
+			return;
32
+		}
33
+		add_filter('gettext',                                         [$this, 'filterGettext'], 9, 3);
34
+		add_filter('site-reviews/gettext/site-reviews',               [$this, 'filterGettextSiteReviews'], 10, 2);
35
+		add_filter('gettext_with_context',                            [$this, 'filterGettextWithContext'], 9, 4);
36
+		add_filter('site-reviews/gettext_with_context/site-reviews',  [$this, 'filterGettextWithContextSiteReviews'], 10, 3);
37
+		add_filter('ngettext',                                        [$this, 'filterNgettext'], 9, 5);
38
+		add_filter('site-reviews/ngettext/site-reviews',              [$this, 'filterNgettextSiteReviews'], 10, 4);
39
+		add_filter('ngettext_with_context',                           [$this, 'filterNgettextWithContext'], 9, 6);
40
+		add_filter('site-reviews/ngettext_with_context/site-reviews', [$this, 'filterNgettextWithContextSiteReviews'], 10, 5);
41
+	}
42 42
 
43
-    /**
44
-     * @param array $messages
45
-     * @return array
46
-     * @filter bulk_post_updated_messages
47
-     */
48
-    public function filterBulkUpdateMessages($messages, array $counts)
49
-    {
50
-        $messages = Arr::consolidateArray($messages);
51
-        $messages[Application::POST_TYPE] = [
52
-            'updated' => _n('%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews'),
53
-            'locked' => _n('%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews'),
54
-            'deleted' => _n('%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews'),
55
-            'trashed' => _n('%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews'),
56
-            'untrashed' => _n('%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews'),
57
-        ];
58
-        return $messages;
59
-    }
43
+	/**
44
+	 * @param array $messages
45
+	 * @return array
46
+	 * @filter bulk_post_updated_messages
47
+	 */
48
+	public function filterBulkUpdateMessages($messages, array $counts)
49
+	{
50
+		$messages = Arr::consolidateArray($messages);
51
+		$messages[Application::POST_TYPE] = [
52
+			'updated' => _n('%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews'),
53
+			'locked' => _n('%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews'),
54
+			'deleted' => _n('%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews'),
55
+			'trashed' => _n('%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews'),
56
+			'untrashed' => _n('%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews'),
57
+		];
58
+		return $messages;
59
+	}
60 60
 
61
-    /**
62
-     * @param string $translation
63
-     * @param string $text
64
-     * @param string $domain
65
-     * @return string
66
-     * @filter gettext
67
-     */
68
-    public function filterGettext($translation, $text, $domain)
69
-    {
70
-        return apply_filters('site-reviews/gettext/'.$domain, $translation, $text);
71
-    }
61
+	/**
62
+	 * @param string $translation
63
+	 * @param string $text
64
+	 * @param string $domain
65
+	 * @return string
66
+	 * @filter gettext
67
+	 */
68
+	public function filterGettext($translation, $text, $domain)
69
+	{
70
+		return apply_filters('site-reviews/gettext/'.$domain, $translation, $text);
71
+	}
72 72
 
73
-    /**
74
-     * @param string $translation
75
-     * @param string $text
76
-     * @return string
77
-     * @filter site-reviews/gettext/site-reviews
78
-     */
79
-    public function filterGettextSiteReviews($translation, $text)
80
-    {
81
-        return $this->translator->translate($translation, Application::ID, [
82
-            'single' => $text,
83
-        ]);
84
-    }
73
+	/**
74
+	 * @param string $translation
75
+	 * @param string $text
76
+	 * @return string
77
+	 * @filter site-reviews/gettext/site-reviews
78
+	 */
79
+	public function filterGettextSiteReviews($translation, $text)
80
+	{
81
+		return $this->translator->translate($translation, Application::ID, [
82
+			'single' => $text,
83
+		]);
84
+	}
85 85
 
86
-    /**
87
-     * @param string $translation
88
-     * @param string $text
89
-     * @param string $context
90
-     * @param string $domain
91
-     * @return string
92
-     * @filter gettext_with_context
93
-     */
94
-    public function filterGettextWithContext($translation, $text, $context, $domain)
95
-    {
96
-        return apply_filters('site-reviews/gettext_with_context/'.$domain, $translation, $text, $context);
97
-    }
86
+	/**
87
+	 * @param string $translation
88
+	 * @param string $text
89
+	 * @param string $context
90
+	 * @param string $domain
91
+	 * @return string
92
+	 * @filter gettext_with_context
93
+	 */
94
+	public function filterGettextWithContext($translation, $text, $context, $domain)
95
+	{
96
+		return apply_filters('site-reviews/gettext_with_context/'.$domain, $translation, $text, $context);
97
+	}
98 98
 
99
-    /**
100
-     * @param string $translation
101
-     * @param string $text
102
-     * @param string $context
103
-     * @return string
104
-     * @filter site-reviews/gettext_with_context/site-reviews
105
-     */
106
-    public function filterGettextWithContextSiteReviews($translation, $text, $context)
107
-    {
108
-        return $this->translator->translate($translation, Application::ID, [
109
-            'context' => $context,
110
-            'single' => $text,
111
-        ]);
112
-    }
99
+	/**
100
+	 * @param string $translation
101
+	 * @param string $text
102
+	 * @param string $context
103
+	 * @return string
104
+	 * @filter site-reviews/gettext_with_context/site-reviews
105
+	 */
106
+	public function filterGettextWithContextSiteReviews($translation, $text, $context)
107
+	{
108
+		return $this->translator->translate($translation, Application::ID, [
109
+			'context' => $context,
110
+			'single' => $text,
111
+		]);
112
+	}
113 113
 
114
-    /**
115
-     * @param string $translation
116
-     * @param string $single
117
-     * @param string $plural
118
-     * @param int $number
119
-     * @param string $domain
120
-     * @return string
121
-     * @filter ngettext
122
-     */
123
-    public function filterNgettext($translation, $single, $plural, $number, $domain)
124
-    {
125
-        return apply_filters('site-reviews/ngettext/'.$domain, $translation, $single, $plural, $number);
126
-    }
114
+	/**
115
+	 * @param string $translation
116
+	 * @param string $single
117
+	 * @param string $plural
118
+	 * @param int $number
119
+	 * @param string $domain
120
+	 * @return string
121
+	 * @filter ngettext
122
+	 */
123
+	public function filterNgettext($translation, $single, $plural, $number, $domain)
124
+	{
125
+		return apply_filters('site-reviews/ngettext/'.$domain, $translation, $single, $plural, $number);
126
+	}
127 127
 
128
-    /**
129
-     * @param string $translation
130
-     * @param string $single
131
-     * @param string $plural
132
-     * @param int $number
133
-     * @return string
134
-     * @filter site-reviews/ngettext/site-reviews
135
-     */
136
-    public function filterNgettextSiteReviews($translation, $single, $plural, $number)
137
-    {
138
-        return $this->translator->translate($translation, Application::ID, [
139
-            'number' => $number,
140
-            'plural' => $plural,
141
-            'single' => $single,
142
-        ]);
143
-    }
128
+	/**
129
+	 * @param string $translation
130
+	 * @param string $single
131
+	 * @param string $plural
132
+	 * @param int $number
133
+	 * @return string
134
+	 * @filter site-reviews/ngettext/site-reviews
135
+	 */
136
+	public function filterNgettextSiteReviews($translation, $single, $plural, $number)
137
+	{
138
+		return $this->translator->translate($translation, Application::ID, [
139
+			'number' => $number,
140
+			'plural' => $plural,
141
+			'single' => $single,
142
+		]);
143
+	}
144 144
 
145
-    /**
146
-     * @param string $translation
147
-     * @param string $single
148
-     * @param string $plural
149
-     * @param int $number
150
-     * @param string $context
151
-     * @param string $domain
152
-     * @return string
153
-     * @filter ngettext_with_context
154
-     */
155
-    public function filterNgettextWithContext($translation, $single, $plural, $number, $context, $domain)
156
-    {
157
-        return apply_filters('site-reviews/ngettext_with_context/'.$domain, $translation, $single, $plural, $number, $context);
158
-    }
145
+	/**
146
+	 * @param string $translation
147
+	 * @param string $single
148
+	 * @param string $plural
149
+	 * @param int $number
150
+	 * @param string $context
151
+	 * @param string $domain
152
+	 * @return string
153
+	 * @filter ngettext_with_context
154
+	 */
155
+	public function filterNgettextWithContext($translation, $single, $plural, $number, $context, $domain)
156
+	{
157
+		return apply_filters('site-reviews/ngettext_with_context/'.$domain, $translation, $single, $plural, $number, $context);
158
+	}
159 159
 
160
-    /**
161
-     * @param string $translation
162
-     * @param string $single
163
-     * @param string $plural
164
-     * @param int $number
165
-     * @param string $context
166
-     * @return string
167
-     * @filter site-reviews/ngettext_with_context/site-reviews
168
-     */
169
-    public function filterNgettextWithContextSiteReviews($translation, $single, $plural, $number, $context)
170
-    {
171
-        return $this->translator->translate($translation, Application::ID, [
172
-            'context' => $context,
173
-            'number' => $number,
174
-            'plural' => $plural,
175
-            'single' => $single,
176
-        ]);
177
-    }
160
+	/**
161
+	 * @param string $translation
162
+	 * @param string $single
163
+	 * @param string $plural
164
+	 * @param int $number
165
+	 * @param string $context
166
+	 * @return string
167
+	 * @filter site-reviews/ngettext_with_context/site-reviews
168
+	 */
169
+	public function filterNgettextWithContextSiteReviews($translation, $single, $plural, $number, $context)
170
+	{
171
+		return $this->translator->translate($translation, Application::ID, [
172
+			'context' => $context,
173
+			'number' => $number,
174
+			'plural' => $plural,
175
+			'single' => $single,
176
+		]);
177
+	}
178 178
 
179
-    /**
180
-     * @param array $postStates
181
-     * @param \WP_Post $post
182
-     * @return array
183
-     * @filter display_post_states
184
-     */
185
-    public function filterPostStates($postStates, $post)
186
-    {
187
-        $postStates = Arr::consolidateArray($postStates);
188
-        if (Application::POST_TYPE == Arr::get($post, 'post_type') && array_key_exists('pending', $postStates)) {
189
-            $postStates['pending'] = __('Unapproved', 'site-reviews');
190
-        }
191
-        return $postStates;
192
-    }
179
+	/**
180
+	 * @param array $postStates
181
+	 * @param \WP_Post $post
182
+	 * @return array
183
+	 * @filter display_post_states
184
+	 */
185
+	public function filterPostStates($postStates, $post)
186
+	{
187
+		$postStates = Arr::consolidateArray($postStates);
188
+		if (Application::POST_TYPE == Arr::get($post, 'post_type') && array_key_exists('pending', $postStates)) {
189
+			$postStates['pending'] = __('Unapproved', 'site-reviews');
190
+		}
191
+		return $postStates;
192
+	}
193 193
 
194
-    /**
195
-     * @param string $translation
196
-     * @param string $text
197
-     * @return string
198
-     * @filter site-reviews/gettext/default
199
-     * @filter site-reviews/gettext_with_context/default
200
-     */
201
-    public function filterPostStatusLabels($translation, $text)
202
-    {
203
-        return $this->canModifyTranslation()
204
-            ? glsr(Labels::class)->filterPostStatusLabels($translation, $text)
205
-            : $translation;
206
-    }
194
+	/**
195
+	 * @param string $translation
196
+	 * @param string $text
197
+	 * @return string
198
+	 * @filter site-reviews/gettext/default
199
+	 * @filter site-reviews/gettext_with_context/default
200
+	 */
201
+	public function filterPostStatusLabels($translation, $text)
202
+	{
203
+		return $this->canModifyTranslation()
204
+			? glsr(Labels::class)->filterPostStatusLabels($translation, $text)
205
+			: $translation;
206
+	}
207 207
 
208
-    /**
209
-     * @param string $translation
210
-     * @param string $single
211
-     * @param string $plural
212
-     * @param int $number
213
-     * @return string
214
-     * @filter site-reviews/ngettext/default
215
-     */
216
-    public function filterPostStatusText($translation, $single, $plural, $number)
217
-    {
218
-        if ($this->canModifyTranslation()) {
219
-            $strings = [
220
-                'Published' => __('Approved', 'site-reviews'),
221
-                'Pending' => __('Unapproved', 'site-reviews'),
222
-            ];
223
-            foreach ($strings as $search => $replace) {
224
-                if (!Str::contains($single, $search)) {
225
-                    continue;
226
-                }
227
-                return $this->translator->getTranslation([
228
-                    'number' => $number,
229
-                    'plural' => str_replace($search, $replace, $plural),
230
-                    'single' => str_replace($search, $replace, $single),
231
-                ]);
232
-            }
233
-        }
234
-        return $translation;
235
-    }
208
+	/**
209
+	 * @param string $translation
210
+	 * @param string $single
211
+	 * @param string $plural
212
+	 * @param int $number
213
+	 * @return string
214
+	 * @filter site-reviews/ngettext/default
215
+	 */
216
+	public function filterPostStatusText($translation, $single, $plural, $number)
217
+	{
218
+		if ($this->canModifyTranslation()) {
219
+			$strings = [
220
+				'Published' => __('Approved', 'site-reviews'),
221
+				'Pending' => __('Unapproved', 'site-reviews'),
222
+			];
223
+			foreach ($strings as $search => $replace) {
224
+				if (!Str::contains($single, $search)) {
225
+					continue;
226
+				}
227
+				return $this->translator->getTranslation([
228
+					'number' => $number,
229
+					'plural' => str_replace($search, $replace, $plural),
230
+					'single' => str_replace($search, $replace, $single),
231
+				]);
232
+			}
233
+		}
234
+		return $translation;
235
+	}
236 236
 
237
-    /**
238
-     * @return void
239
-     * @action admin_enqueue_scripts
240
-     */
241
-    public function translatePostStatusLabels()
242
-    {
243
-        if ($this->canModifyTranslation()) {
244
-            glsr(Labels::class)->translatePostStatusLabels();
245
-        }
246
-    }
237
+	/**
238
+	 * @return void
239
+	 * @action admin_enqueue_scripts
240
+	 */
241
+	public function translatePostStatusLabels()
242
+	{
243
+		if ($this->canModifyTranslation()) {
244
+			glsr(Labels::class)->translatePostStatusLabels();
245
+		}
246
+	}
247 247
 
248
-    /**
249
-     * @return bool
250
-     */
251
-    protected function canModifyTranslation()
252
-    {
253
-        $screen = glsr_current_screen();
254
-        return Application::POST_TYPE == $screen->post_type 
255
-            && in_array($screen->base, ['edit', 'post']);
256
-    }
248
+	/**
249
+	 * @return bool
250
+	 */
251
+	protected function canModifyTranslation()
252
+	{
253
+		$screen = glsr_current_screen();
254
+		return Application::POST_TYPE == $screen->post_type 
255
+			&& in_array($screen->base, ['edit', 'post']);
256
+	}
257 257
 }
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
      */
17 17
     public $translator;
18 18
 
19
-    public function __construct(Translator $translator)
19
+    public function __construct( Translator $translator )
20 20
     {
21 21
         $this->translator = $translator;
22 22
     }
@@ -27,17 +27,17 @@  discard block
 block discarded – undo
27 27
      */
28 28
     public function addTranslationFilters()
29 29
     {
30
-        if (empty(glsr(Translation::class)->translations())) {
30
+        if( empty(glsr( Translation::class )->translations()) ) {
31 31
             return;
32 32
         }
33
-        add_filter('gettext',                                         [$this, 'filterGettext'], 9, 3);
34
-        add_filter('site-reviews/gettext/site-reviews',               [$this, 'filterGettextSiteReviews'], 10, 2);
35
-        add_filter('gettext_with_context',                            [$this, 'filterGettextWithContext'], 9, 4);
36
-        add_filter('site-reviews/gettext_with_context/site-reviews',  [$this, 'filterGettextWithContextSiteReviews'], 10, 3);
37
-        add_filter('ngettext',                                        [$this, 'filterNgettext'], 9, 5);
38
-        add_filter('site-reviews/ngettext/site-reviews',              [$this, 'filterNgettextSiteReviews'], 10, 4);
39
-        add_filter('ngettext_with_context',                           [$this, 'filterNgettextWithContext'], 9, 6);
40
-        add_filter('site-reviews/ngettext_with_context/site-reviews', [$this, 'filterNgettextWithContextSiteReviews'], 10, 5);
33
+        add_filter( 'gettext', [$this, 'filterGettext'], 9, 3 );
34
+        add_filter( 'site-reviews/gettext/site-reviews', [$this, 'filterGettextSiteReviews'], 10, 2 );
35
+        add_filter( 'gettext_with_context', [$this, 'filterGettextWithContext'], 9, 4 );
36
+        add_filter( 'site-reviews/gettext_with_context/site-reviews', [$this, 'filterGettextWithContextSiteReviews'], 10, 3 );
37
+        add_filter( 'ngettext', [$this, 'filterNgettext'], 9, 5 );
38
+        add_filter( 'site-reviews/ngettext/site-reviews', [$this, 'filterNgettextSiteReviews'], 10, 4 );
39
+        add_filter( 'ngettext_with_context', [$this, 'filterNgettextWithContext'], 9, 6 );
40
+        add_filter( 'site-reviews/ngettext_with_context/site-reviews', [$this, 'filterNgettextWithContextSiteReviews'], 10, 5 );
41 41
     }
42 42
 
43 43
     /**
@@ -45,15 +45,15 @@  discard block
 block discarded – undo
45 45
      * @return array
46 46
      * @filter bulk_post_updated_messages
47 47
      */
48
-    public function filterBulkUpdateMessages($messages, array $counts)
48
+    public function filterBulkUpdateMessages( $messages, array $counts )
49 49
     {
50
-        $messages = Arr::consolidateArray($messages);
50
+        $messages = Arr::consolidateArray( $messages );
51 51
         $messages[Application::POST_TYPE] = [
52
-            'updated' => _n('%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews'),
53
-            'locked' => _n('%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews'),
54
-            'deleted' => _n('%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews'),
55
-            'trashed' => _n('%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews'),
56
-            'untrashed' => _n('%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews'),
52
+            'updated' => _n( '%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews' ),
53
+            'locked' => _n( '%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews' ),
54
+            'deleted' => _n( '%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews' ),
55
+            'trashed' => _n( '%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews' ),
56
+            'untrashed' => _n( '%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews' ),
57 57
         ];
58 58
         return $messages;
59 59
     }
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
      * @return string
66 66
      * @filter gettext
67 67
      */
68
-    public function filterGettext($translation, $text, $domain)
68
+    public function filterGettext( $translation, $text, $domain )
69 69
     {
70
-        return apply_filters('site-reviews/gettext/'.$domain, $translation, $text);
70
+        return apply_filters( 'site-reviews/gettext/'.$domain, $translation, $text );
71 71
     }
72 72
 
73 73
     /**
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
      * @return string
77 77
      * @filter site-reviews/gettext/site-reviews
78 78
      */
79
-    public function filterGettextSiteReviews($translation, $text)
79
+    public function filterGettextSiteReviews( $translation, $text )
80 80
     {
81
-        return $this->translator->translate($translation, Application::ID, [
81
+        return $this->translator->translate( $translation, Application::ID, [
82 82
             'single' => $text,
83
-        ]);
83
+        ] );
84 84
     }
85 85
 
86 86
     /**
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
      * @return string
92 92
      * @filter gettext_with_context
93 93
      */
94
-    public function filterGettextWithContext($translation, $text, $context, $domain)
94
+    public function filterGettextWithContext( $translation, $text, $context, $domain )
95 95
     {
96
-        return apply_filters('site-reviews/gettext_with_context/'.$domain, $translation, $text, $context);
96
+        return apply_filters( 'site-reviews/gettext_with_context/'.$domain, $translation, $text, $context );
97 97
     }
98 98
 
99 99
     /**
@@ -103,12 +103,12 @@  discard block
 block discarded – undo
103 103
      * @return string
104 104
      * @filter site-reviews/gettext_with_context/site-reviews
105 105
      */
106
-    public function filterGettextWithContextSiteReviews($translation, $text, $context)
106
+    public function filterGettextWithContextSiteReviews( $translation, $text, $context )
107 107
     {
108
-        return $this->translator->translate($translation, Application::ID, [
108
+        return $this->translator->translate( $translation, Application::ID, [
109 109
             'context' => $context,
110 110
             'single' => $text,
111
-        ]);
111
+        ] );
112 112
     }
113 113
 
114 114
     /**
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
      * @return string
121 121
      * @filter ngettext
122 122
      */
123
-    public function filterNgettext($translation, $single, $plural, $number, $domain)
123
+    public function filterNgettext( $translation, $single, $plural, $number, $domain )
124 124
     {
125
-        return apply_filters('site-reviews/ngettext/'.$domain, $translation, $single, $plural, $number);
125
+        return apply_filters( 'site-reviews/ngettext/'.$domain, $translation, $single, $plural, $number );
126 126
     }
127 127
 
128 128
     /**
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
      * @return string
134 134
      * @filter site-reviews/ngettext/site-reviews
135 135
      */
136
-    public function filterNgettextSiteReviews($translation, $single, $plural, $number)
136
+    public function filterNgettextSiteReviews( $translation, $single, $plural, $number )
137 137
     {
138
-        return $this->translator->translate($translation, Application::ID, [
138
+        return $this->translator->translate( $translation, Application::ID, [
139 139
             'number' => $number,
140 140
             'plural' => $plural,
141 141
             'single' => $single,
142
-        ]);
142
+        ] );
143 143
     }
144 144
 
145 145
     /**
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
      * @return string
153 153
      * @filter ngettext_with_context
154 154
      */
155
-    public function filterNgettextWithContext($translation, $single, $plural, $number, $context, $domain)
155
+    public function filterNgettextWithContext( $translation, $single, $plural, $number, $context, $domain )
156 156
     {
157
-        return apply_filters('site-reviews/ngettext_with_context/'.$domain, $translation, $single, $plural, $number, $context);
157
+        return apply_filters( 'site-reviews/ngettext_with_context/'.$domain, $translation, $single, $plural, $number, $context );
158 158
     }
159 159
 
160 160
     /**
@@ -166,14 +166,14 @@  discard block
 block discarded – undo
166 166
      * @return string
167 167
      * @filter site-reviews/ngettext_with_context/site-reviews
168 168
      */
169
-    public function filterNgettextWithContextSiteReviews($translation, $single, $plural, $number, $context)
169
+    public function filterNgettextWithContextSiteReviews( $translation, $single, $plural, $number, $context )
170 170
     {
171
-        return $this->translator->translate($translation, Application::ID, [
171
+        return $this->translator->translate( $translation, Application::ID, [
172 172
             'context' => $context,
173 173
             'number' => $number,
174 174
             'plural' => $plural,
175 175
             'single' => $single,
176
-        ]);
176
+        ] );
177 177
     }
178 178
 
179 179
     /**
@@ -182,11 +182,11 @@  discard block
 block discarded – undo
182 182
      * @return array
183 183
      * @filter display_post_states
184 184
      */
185
-    public function filterPostStates($postStates, $post)
185
+    public function filterPostStates( $postStates, $post )
186 186
     {
187
-        $postStates = Arr::consolidateArray($postStates);
188
-        if (Application::POST_TYPE == Arr::get($post, 'post_type') && array_key_exists('pending', $postStates)) {
189
-            $postStates['pending'] = __('Unapproved', 'site-reviews');
187
+        $postStates = Arr::consolidateArray( $postStates );
188
+        if( Application::POST_TYPE == Arr::get( $post, 'post_type' ) && array_key_exists( 'pending', $postStates ) ) {
189
+            $postStates['pending'] = __( 'Unapproved', 'site-reviews' );
190 190
         }
191 191
         return $postStates;
192 192
     }
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
      * @filter site-reviews/gettext/default
199 199
      * @filter site-reviews/gettext_with_context/default
200 200
      */
201
-    public function filterPostStatusLabels($translation, $text)
201
+    public function filterPostStatusLabels( $translation, $text )
202 202
     {
203 203
         return $this->canModifyTranslation()
204
-            ? glsr(Labels::class)->filterPostStatusLabels($translation, $text)
204
+            ? glsr( Labels::class )->filterPostStatusLabels( $translation, $text )
205 205
             : $translation;
206 206
     }
207 207
 
@@ -213,22 +213,22 @@  discard block
 block discarded – undo
213 213
      * @return string
214 214
      * @filter site-reviews/ngettext/default
215 215
      */
216
-    public function filterPostStatusText($translation, $single, $plural, $number)
216
+    public function filterPostStatusText( $translation, $single, $plural, $number )
217 217
     {
218
-        if ($this->canModifyTranslation()) {
218
+        if( $this->canModifyTranslation() ) {
219 219
             $strings = [
220
-                'Published' => __('Approved', 'site-reviews'),
221
-                'Pending' => __('Unapproved', 'site-reviews'),
220
+                'Published' => __( 'Approved', 'site-reviews' ),
221
+                'Pending' => __( 'Unapproved', 'site-reviews' ),
222 222
             ];
223
-            foreach ($strings as $search => $replace) {
224
-                if (!Str::contains($single, $search)) {
223
+            foreach( $strings as $search => $replace ) {
224
+                if( !Str::contains( $single, $search ) ) {
225 225
                     continue;
226 226
                 }
227
-                return $this->translator->getTranslation([
227
+                return $this->translator->getTranslation( [
228 228
                     'number' => $number,
229
-                    'plural' => str_replace($search, $replace, $plural),
230
-                    'single' => str_replace($search, $replace, $single),
231
-                ]);
229
+                    'plural' => str_replace( $search, $replace, $plural ),
230
+                    'single' => str_replace( $search, $replace, $single ),
231
+                ] );
232 232
             }
233 233
         }
234 234
         return $translation;
@@ -240,8 +240,8 @@  discard block
 block discarded – undo
240 240
      */
241 241
     public function translatePostStatusLabels()
242 242
     {
243
-        if ($this->canModifyTranslation()) {
244
-            glsr(Labels::class)->translatePostStatusLabels();
243
+        if( $this->canModifyTranslation() ) {
244
+            glsr( Labels::class )->translatePostStatusLabels();
245 245
         }
246 246
     }
247 247
 
@@ -252,6 +252,6 @@  discard block
 block discarded – undo
252 252
     {
253 253
         $screen = glsr_current_screen();
254 254
         return Application::POST_TYPE == $screen->post_type 
255
-            && in_array($screen->base, ['edit', 'post']);
255
+            && in_array( $screen->base, ['edit', 'post'] );
256 256
     }
257 257
 }
Please login to merge, or discard this patch.
plugin/Filters.php 2 patches
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -15,64 +15,64 @@
 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 $translator;
26
-    protected $trustalyze;
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 $translator;
26
+	protected $trustalyze;
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->translator = $app->make(TranslationController::class);
39
-        $this->trustalyze = $app->make(TrustalyzeController::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->translator = $app->make(TranslationController::class);
39
+		$this->trustalyze = $app->make(TrustalyzeController::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('bulk_post_updated_messages',                                [$this->translator, 'filterBulkUpdateMessages'], 10, 2);
68
-        add_filter('display_post_states',                                       [$this->translator, 'filterPostStates'], 10, 2);
69
-        add_filter('site-reviews/gettext/default',                              [$this->translator, 'filterPostStatusLabels'], 10, 2);
70
-        add_filter('site-reviews/gettext_with_context/default',                 [$this->translator, 'filterPostStatusLabels'], 10, 2);
71
-        add_filter('site-reviews/ngettext/default',                             [$this->translator, 'filterPostStatusText'], 10, 4);
72
-        add_filter('site-reviews/settings/callback',                            [$this->trustalyze, 'filterSettingsCallback']);
73
-        add_filter('site-reviews/interpolate/partials/form/table-row-multiple', [$this->trustalyze, 'filterSettingsTableRow'], 10, 3);
74
-        add_filter('plugin_action_links_'.$this->basename,                      [$this->welcome, 'filterActionLinks'], 9);
75
-        add_filter('admin_title',                                               [$this->welcome, 'filterAdminTitle']);
76
-        add_filter('admin_footer_text',                                         [$this->welcome, 'filterFooterText']);
77
-    }
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('bulk_post_updated_messages',                                [$this->translator, 'filterBulkUpdateMessages'], 10, 2);
68
+		add_filter('display_post_states',                                       [$this->translator, 'filterPostStates'], 10, 2);
69
+		add_filter('site-reviews/gettext/default',                              [$this->translator, 'filterPostStatusLabels'], 10, 2);
70
+		add_filter('site-reviews/gettext_with_context/default',                 [$this->translator, 'filterPostStatusLabels'], 10, 2);
71
+		add_filter('site-reviews/ngettext/default',                             [$this->translator, 'filterPostStatusText'], 10, 4);
72
+		add_filter('site-reviews/settings/callback',                            [$this->trustalyze, 'filterSettingsCallback']);
73
+		add_filter('site-reviews/interpolate/partials/form/table-row-multiple', [$this->trustalyze, 'filterSettingsTableRow'], 10, 3);
74
+		add_filter('plugin_action_links_'.$this->basename,                      [$this->welcome, 'filterActionLinks'], 9);
75
+		add_filter('admin_title',                                               [$this->welcome, 'filterAdminTitle']);
76
+		add_filter('admin_footer_text',                                         [$this->welcome, 'filterFooterText']);
77
+	}
78 78
 }
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -26,18 +26,18 @@  discard block
 block discarded – undo
26 26
     protected $trustalyze;
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->translator = $app->make(TranslationController::class);
39
-        $this->trustalyze = $app->make(TrustalyzeController::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->translator = $app->make( TranslationController::class );
39
+        $this->trustalyze = $app->make( TrustalyzeController::class );
40
+        $this->welcome = $app->make( WelcomeController::class );
41 41
     }
42 42
 
43 43
     /**
@@ -45,34 +45,34 @@  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('bulk_post_updated_messages',                                [$this->translator, 'filterBulkUpdateMessages'], 10, 2);
68
-        add_filter('display_post_states',                                       [$this->translator, 'filterPostStates'], 10, 2);
69
-        add_filter('site-reviews/gettext/default',                              [$this->translator, 'filterPostStatusLabels'], 10, 2);
70
-        add_filter('site-reviews/gettext_with_context/default',                 [$this->translator, 'filterPostStatusLabels'], 10, 2);
71
-        add_filter('site-reviews/ngettext/default',                             [$this->translator, 'filterPostStatusText'], 10, 4);
72
-        add_filter('site-reviews/settings/callback',                            [$this->trustalyze, 'filterSettingsCallback']);
73
-        add_filter('site-reviews/interpolate/partials/form/table-row-multiple', [$this->trustalyze, 'filterSettingsTableRow'], 10, 3);
74
-        add_filter('plugin_action_links_'.$this->basename,                      [$this->welcome, 'filterActionLinks'], 9);
75
-        add_filter('admin_title',                                               [$this->welcome, 'filterAdminTitle']);
76
-        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( 'bulk_post_updated_messages', [$this->translator, 'filterBulkUpdateMessages'], 10, 2 );
68
+        add_filter( 'display_post_states', [$this->translator, 'filterPostStates'], 10, 2 );
69
+        add_filter( 'site-reviews/gettext/default', [$this->translator, 'filterPostStatusLabels'], 10, 2 );
70
+        add_filter( 'site-reviews/gettext_with_context/default', [$this->translator, 'filterPostStatusLabels'], 10, 2 );
71
+        add_filter( 'site-reviews/ngettext/default', [$this->translator, 'filterPostStatusText'], 10, 4 );
72
+        add_filter( 'site-reviews/settings/callback', [$this->trustalyze, 'filterSettingsCallback'] );
73
+        add_filter( 'site-reviews/interpolate/partials/form/table-row-multiple', [$this->trustalyze, 'filterSettingsTableRow'], 10, 3 );
74
+        add_filter( 'plugin_action_links_'.$this->basename, [$this->welcome, 'filterActionLinks'], 9 );
75
+        add_filter( 'admin_title', [$this->welcome, 'filterAdminTitle'] );
76
+        add_filter( 'admin_footer_text', [$this->welcome, 'filterFooterText'] );
77 77
     }
78 78
 }
Please login to merge, or discard this patch.
plugin/Controllers/ListTableController/Columns.php 2 patches
Indentation   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -10,184 +10,184 @@
 block discarded – undo
10 10
 
11 11
 class Columns
12 12
 {
13
-    /**
14
-     * @param int $postId
15
-     * @return void|string
16
-     */
17
-    public function buildColumnAssignedTo($postId)
18
-    {
19
-        $assignedPost = glsr(Database::class)->getAssignedToPost($postId);
20
-        if ($assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status) {
21
-            return glsr(Builder::class)->a(get_the_title($assignedPost->ID), [
22
-                'href' => (string) get_the_permalink($assignedPost->ID),
23
-            ]);
24
-        }
25
-    }
13
+	/**
14
+	 * @param int $postId
15
+	 * @return void|string
16
+	 */
17
+	public function buildColumnAssignedTo($postId)
18
+	{
19
+		$assignedPost = glsr(Database::class)->getAssignedToPost($postId);
20
+		if ($assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status) {
21
+			return glsr(Builder::class)->a(get_the_title($assignedPost->ID), [
22
+				'href' => (string) get_the_permalink($assignedPost->ID),
23
+			]);
24
+		}
25
+	}
26 26
 
27
-    /**
28
-     * @param int $postId
29
-     * @return void|string
30
-     */
31
-    public function buildColumnEmail($postId)
32
-    {
33
-        if ($email = glsr(Database::class)->get($postId, 'email')) {
34
-            return $email;
35
-        }
36
-    }
27
+	/**
28
+	 * @param int $postId
29
+	 * @return void|string
30
+	 */
31
+	public function buildColumnEmail($postId)
32
+	{
33
+		if ($email = glsr(Database::class)->get($postId, 'email')) {
34
+			return $email;
35
+		}
36
+	}
37 37
 
38
-    /**
39
-     * @param int $postId
40
-     * @return void|string
41
-     */
42
-    public function buildColumnIpAddress($postId)
43
-    {
44
-        if ($ipAddress = glsr(Database::class)->get($postId, 'ip_address')) {
45
-            return $ipAddress;
46
-        }
47
-    }
38
+	/**
39
+	 * @param int $postId
40
+	 * @return void|string
41
+	 */
42
+	public function buildColumnIpAddress($postId)
43
+	{
44
+		if ($ipAddress = glsr(Database::class)->get($postId, 'ip_address')) {
45
+			return $ipAddress;
46
+		}
47
+	}
48 48
 
49
-    /**
50
-     * @param int $postId
51
-     * @return string
52
-     */
53
-    public function buildColumnPinned($postId)
54
-    {
55
-        $pinned = glsr(Database::class)->get($postId, 'pinned')
56
-            ? 'pinned '
57
-            : '';
58
-        if (glsr()->can('edit_others_posts')) {
59
-            $pinned.= 'pin-review ';
60
-        }
61
-        return glsr(Builder::class)->i([
62
-            'class' => $pinned.'dashicons dashicons-sticky',
63
-            'data-id' => $postId,
64
-        ]);
65
-    }
49
+	/**
50
+	 * @param int $postId
51
+	 * @return string
52
+	 */
53
+	public function buildColumnPinned($postId)
54
+	{
55
+		$pinned = glsr(Database::class)->get($postId, 'pinned')
56
+			? 'pinned '
57
+			: '';
58
+		if (glsr()->can('edit_others_posts')) {
59
+			$pinned.= 'pin-review ';
60
+		}
61
+		return glsr(Builder::class)->i([
62
+			'class' => $pinned.'dashicons dashicons-sticky',
63
+			'data-id' => $postId,
64
+		]);
65
+	}
66 66
 
67
-    /**
68
-     * @param int $postId
69
-     * @return string
70
-     */
71
-    public function buildColumnResponse($postId)
72
-    {
73
-        return glsr(Database::class)->get($postId, 'response')
74
-            ? __('Yes', 'site-reviews')
75
-            : __('No', 'site-reviews');
76
-    }
67
+	/**
68
+	 * @param int $postId
69
+	 * @return string
70
+	 */
71
+	public function buildColumnResponse($postId)
72
+	{
73
+		return glsr(Database::class)->get($postId, 'response')
74
+			? __('Yes', 'site-reviews')
75
+			: __('No', 'site-reviews');
76
+	}
77 77
 
78
-    /**
79
-     * @param int $postId
80
-     * @return string
81
-     */
82
-    public function buildColumnReviewer($postId)
83
-    {
84
-        $author = strval(glsr(Database::class)->get($postId, 'author'));
85
-        $userId = Helper::castToInt(get_post($postId)->post_author);
86
-        return !empty($userId)
87
-            ? glsr(Builder::class)->a($author, ['href' => get_author_posts_url($userId)])
88
-            : $author;
89
-    }
78
+	/**
79
+	 * @param int $postId
80
+	 * @return string
81
+	 */
82
+	public function buildColumnReviewer($postId)
83
+	{
84
+		$author = strval(glsr(Database::class)->get($postId, 'author'));
85
+		$userId = Helper::castToInt(get_post($postId)->post_author);
86
+		return !empty($userId)
87
+			? glsr(Builder::class)->a($author, ['href' => get_author_posts_url($userId)])
88
+			: $author;
89
+	}
90 90
 
91
-    /**
92
-     * @param int $postId
93
-     * @param int|null $rating
94
-     * @return string
95
-     */
96
-    public function buildColumnRating($postId)
97
-    {
98
-        return glsr_star_rating(intval(glsr(Database::class)->get($postId, 'rating')));
99
-    }
91
+	/**
92
+	 * @param int $postId
93
+	 * @param int|null $rating
94
+	 * @return string
95
+	 */
96
+	public function buildColumnRating($postId)
97
+	{
98
+		return glsr_star_rating(intval(glsr(Database::class)->get($postId, 'rating')));
99
+	}
100 100
 
101
-    /**
102
-     * @param int $postId
103
-     * @return string
104
-     */
105
-    public function buildColumnReviewType($postId)
106
-    {
107
-        $type = glsr(Database::class)->get($postId, 'review_type');
108
-        return array_key_exists($type, glsr()->reviewTypes)
109
-            ? glsr()->reviewTypes[$type]
110
-            : __('Unsupported Type', 'site-reviews');
111
-    }
101
+	/**
102
+	 * @param int $postId
103
+	 * @return string
104
+	 */
105
+	public function buildColumnReviewType($postId)
106
+	{
107
+		$type = glsr(Database::class)->get($postId, 'review_type');
108
+		return array_key_exists($type, glsr()->reviewTypes)
109
+			? glsr()->reviewTypes[$type]
110
+			: __('Unsupported Type', 'site-reviews');
111
+	}
112 112
 
113
-    /**
114
-     * @param string $postType
115
-     * @return void
116
-     */
117
-    public function renderFilters($postType)
118
-    {
119
-        if (Application::POST_TYPE !== $postType) {
120
-            return;
121
-        }
122
-        if (!($status = filter_input(INPUT_GET, 'post_status'))) {
123
-            $status = 'publish';
124
-        }
125
-        $ratings = glsr(Database::class)->getReviewsMeta('rating', $status);
126
-        $types = glsr(Database::class)->getReviewsMeta('review_type', $status);
127
-        $this->renderFilterRatings($ratings);
128
-        $this->renderFilterTypes($types);
129
-    }
113
+	/**
114
+	 * @param string $postType
115
+	 * @return void
116
+	 */
117
+	public function renderFilters($postType)
118
+	{
119
+		if (Application::POST_TYPE !== $postType) {
120
+			return;
121
+		}
122
+		if (!($status = filter_input(INPUT_GET, 'post_status'))) {
123
+			$status = 'publish';
124
+		}
125
+		$ratings = glsr(Database::class)->getReviewsMeta('rating', $status);
126
+		$types = glsr(Database::class)->getReviewsMeta('review_type', $status);
127
+		$this->renderFilterRatings($ratings);
128
+		$this->renderFilterTypes($types);
129
+	}
130 130
 
131
-    /**
132
-     * @param string $column
133
-     * @param int $postId
134
-     * @return void
135
-     */
136
-    public function renderValues($column, $postId)
137
-    {
138
-        $method = Helper::buildMethodName($column, 'buildColumn');
139
-        $value = method_exists($this, $method)
140
-            ? call_user_func([$this, $method], $postId)
141
-            : '';
142
-        $value = apply_filters('site-reviews/columns/'.$column, $value, $postId);
143
-        if (0 !== $value && empty($value)) {
144
-            $value = '&mdash;';
145
-        }
146
-        echo $value;
147
-    }
131
+	/**
132
+	 * @param string $column
133
+	 * @param int $postId
134
+	 * @return void
135
+	 */
136
+	public function renderValues($column, $postId)
137
+	{
138
+		$method = Helper::buildMethodName($column, 'buildColumn');
139
+		$value = method_exists($this, $method)
140
+			? call_user_func([$this, $method], $postId)
141
+			: '';
142
+		$value = apply_filters('site-reviews/columns/'.$column, $value, $postId);
143
+		if (0 !== $value && empty($value)) {
144
+			$value = '&mdash;';
145
+		}
146
+		echo $value;
147
+	}
148 148
 
149
-    /**
150
-     * @param array $ratings
151
-     * @return void
152
-     */
153
-    protected function renderFilterRatings($ratings)
154
-    {
155
-        if (empty($ratings)) {
156
-            return;
157
-        }
158
-        $ratings = array_flip(array_reverse($ratings));
159
-        array_walk($ratings, function (&$value, $key) {
160
-            $label = _n('%s star', '%s stars', $key, 'site-reviews');
161
-            $value = sprintf($label, $key);
162
-        });
163
-        echo glsr(Builder::class)->label(__('Filter by rating', 'site-reviews'), [
164
-            'class' => 'screen-reader-text',
165
-            'for' => 'rating',
166
-        ]);
167
-        echo glsr(Builder::class)->select([
168
-            'name' => 'rating',
169
-            'options' => ['' => __('All ratings', 'site-reviews')] + $ratings,
170
-            'value' => filter_input(INPUT_GET, 'rating'),
171
-        ]);
172
-    }
149
+	/**
150
+	 * @param array $ratings
151
+	 * @return void
152
+	 */
153
+	protected function renderFilterRatings($ratings)
154
+	{
155
+		if (empty($ratings)) {
156
+			return;
157
+		}
158
+		$ratings = array_flip(array_reverse($ratings));
159
+		array_walk($ratings, function (&$value, $key) {
160
+			$label = _n('%s star', '%s stars', $key, 'site-reviews');
161
+			$value = sprintf($label, $key);
162
+		});
163
+		echo glsr(Builder::class)->label(__('Filter by rating', 'site-reviews'), [
164
+			'class' => 'screen-reader-text',
165
+			'for' => 'rating',
166
+		]);
167
+		echo glsr(Builder::class)->select([
168
+			'name' => 'rating',
169
+			'options' => ['' => __('All ratings', 'site-reviews')] + $ratings,
170
+			'value' => filter_input(INPUT_GET, 'rating'),
171
+		]);
172
+	}
173 173
 
174
-    /**
175
-     * @param array $types
176
-     * @return void
177
-     */
178
-    protected function renderFilterTypes($types)
179
-    {
180
-        if (count(glsr()->reviewTypes) < 2) {
181
-            return;
182
-        }
183
-        echo glsr(Builder::class)->label(__('Filter by type', 'site-reviews'), [
184
-            'class' => 'screen-reader-text',
185
-            'for' => 'review_type',
186
-        ]);
187
-        echo glsr(Builder::class)->select([
188
-            'name' => 'review_type',
189
-            'options' => ['' => __('All types', 'site-reviews')] + glsr()->reviewTypes,
190
-            'value' => filter_input(INPUT_GET, 'review_type'),
191
-        ]);
192
-    }
174
+	/**
175
+	 * @param array $types
176
+	 * @return void
177
+	 */
178
+	protected function renderFilterTypes($types)
179
+	{
180
+		if (count(glsr()->reviewTypes) < 2) {
181
+			return;
182
+		}
183
+		echo glsr(Builder::class)->label(__('Filter by type', 'site-reviews'), [
184
+			'class' => 'screen-reader-text',
185
+			'for' => 'review_type',
186
+		]);
187
+		echo glsr(Builder::class)->select([
188
+			'name' => 'review_type',
189
+			'options' => ['' => __('All types', 'site-reviews')] + glsr()->reviewTypes,
190
+			'value' => filter_input(INPUT_GET, 'review_type'),
191
+		]);
192
+	}
193 193
 }
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
      * @param int $postId
15 15
      * @return void|string
16 16
      */
17
-    public function buildColumnAssignedTo($postId)
17
+    public function buildColumnAssignedTo( $postId )
18 18
     {
19
-        $assignedPost = glsr(Database::class)->getAssignedToPost($postId);
20
-        if ($assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status) {
21
-            return glsr(Builder::class)->a(get_the_title($assignedPost->ID), [
22
-                'href' => (string) get_the_permalink($assignedPost->ID),
23
-            ]);
19
+        $assignedPost = glsr( Database::class )->getAssignedToPost( $postId );
20
+        if( $assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status ) {
21
+            return glsr( Builder::class )->a( get_the_title( $assignedPost->ID ), [
22
+                'href' => (string)get_the_permalink( $assignedPost->ID ),
23
+            ] );
24 24
         }
25 25
     }
26 26
 
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
      * @param int $postId
29 29
      * @return void|string
30 30
      */
31
-    public function buildColumnEmail($postId)
31
+    public function buildColumnEmail( $postId )
32 32
     {
33
-        if ($email = glsr(Database::class)->get($postId, 'email')) {
33
+        if( $email = glsr( Database::class )->get( $postId, 'email' ) ) {
34 34
             return $email;
35 35
         }
36 36
     }
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
      * @param int $postId
40 40
      * @return void|string
41 41
      */
42
-    public function buildColumnIpAddress($postId)
42
+    public function buildColumnIpAddress( $postId )
43 43
     {
44
-        if ($ipAddress = glsr(Database::class)->get($postId, 'ip_address')) {
44
+        if( $ipAddress = glsr( Database::class )->get( $postId, 'ip_address' ) ) {
45 45
             return $ipAddress;
46 46
         }
47 47
     }
@@ -50,41 +50,41 @@  discard block
 block discarded – undo
50 50
      * @param int $postId
51 51
      * @return string
52 52
      */
53
-    public function buildColumnPinned($postId)
53
+    public function buildColumnPinned( $postId )
54 54
     {
55
-        $pinned = glsr(Database::class)->get($postId, 'pinned')
55
+        $pinned = glsr( Database::class )->get( $postId, 'pinned' )
56 56
             ? 'pinned '
57 57
             : '';
58
-        if (glsr()->can('edit_others_posts')) {
59
-            $pinned.= 'pin-review ';
58
+        if( glsr()->can( 'edit_others_posts' ) ) {
59
+            $pinned .= 'pin-review ';
60 60
         }
61
-        return glsr(Builder::class)->i([
61
+        return glsr( Builder::class )->i( [
62 62
             'class' => $pinned.'dashicons dashicons-sticky',
63 63
             'data-id' => $postId,
64
-        ]);
64
+        ] );
65 65
     }
66 66
 
67 67
     /**
68 68
      * @param int $postId
69 69
      * @return string
70 70
      */
71
-    public function buildColumnResponse($postId)
71
+    public function buildColumnResponse( $postId )
72 72
     {
73
-        return glsr(Database::class)->get($postId, 'response')
74
-            ? __('Yes', 'site-reviews')
75
-            : __('No', 'site-reviews');
73
+        return glsr( Database::class )->get( $postId, 'response' )
74
+            ? __( 'Yes', 'site-reviews' )
75
+            : __( 'No', 'site-reviews' );
76 76
     }
77 77
 
78 78
     /**
79 79
      * @param int $postId
80 80
      * @return string
81 81
      */
82
-    public function buildColumnReviewer($postId)
82
+    public function buildColumnReviewer( $postId )
83 83
     {
84
-        $author = strval(glsr(Database::class)->get($postId, 'author'));
85
-        $userId = Helper::castToInt(get_post($postId)->post_author);
84
+        $author = strval( glsr( Database::class )->get( $postId, 'author' ) );
85
+        $userId = Helper::castToInt( get_post( $postId )->post_author );
86 86
         return !empty($userId)
87
-            ? glsr(Builder::class)->a($author, ['href' => get_author_posts_url($userId)])
87
+            ? glsr( Builder::class )->a( $author, ['href' => get_author_posts_url( $userId )] )
88 88
             : $author;
89 89
     }
90 90
 
@@ -93,39 +93,39 @@  discard block
 block discarded – undo
93 93
      * @param int|null $rating
94 94
      * @return string
95 95
      */
96
-    public function buildColumnRating($postId)
96
+    public function buildColumnRating( $postId )
97 97
     {
98
-        return glsr_star_rating(intval(glsr(Database::class)->get($postId, 'rating')));
98
+        return glsr_star_rating( intval( glsr( Database::class )->get( $postId, 'rating' ) ) );
99 99
     }
100 100
 
101 101
     /**
102 102
      * @param int $postId
103 103
      * @return string
104 104
      */
105
-    public function buildColumnReviewType($postId)
105
+    public function buildColumnReviewType( $postId )
106 106
     {
107
-        $type = glsr(Database::class)->get($postId, 'review_type');
108
-        return array_key_exists($type, glsr()->reviewTypes)
107
+        $type = glsr( Database::class )->get( $postId, 'review_type' );
108
+        return array_key_exists( $type, glsr()->reviewTypes )
109 109
             ? glsr()->reviewTypes[$type]
110
-            : __('Unsupported Type', 'site-reviews');
110
+            : __( 'Unsupported Type', 'site-reviews' );
111 111
     }
112 112
 
113 113
     /**
114 114
      * @param string $postType
115 115
      * @return void
116 116
      */
117
-    public function renderFilters($postType)
117
+    public function renderFilters( $postType )
118 118
     {
119
-        if (Application::POST_TYPE !== $postType) {
119
+        if( Application::POST_TYPE !== $postType ) {
120 120
             return;
121 121
         }
122
-        if (!($status = filter_input(INPUT_GET, 'post_status'))) {
122
+        if( !($status = filter_input( INPUT_GET, 'post_status' )) ) {
123 123
             $status = 'publish';
124 124
         }
125
-        $ratings = glsr(Database::class)->getReviewsMeta('rating', $status);
126
-        $types = glsr(Database::class)->getReviewsMeta('review_type', $status);
127
-        $this->renderFilterRatings($ratings);
128
-        $this->renderFilterTypes($types);
125
+        $ratings = glsr( Database::class )->getReviewsMeta( 'rating', $status );
126
+        $types = glsr( Database::class )->getReviewsMeta( 'review_type', $status );
127
+        $this->renderFilterRatings( $ratings );
128
+        $this->renderFilterTypes( $types );
129 129
     }
130 130
 
131 131
     /**
@@ -133,14 +133,14 @@  discard block
 block discarded – undo
133 133
      * @param int $postId
134 134
      * @return void
135 135
      */
136
-    public function renderValues($column, $postId)
136
+    public function renderValues( $column, $postId )
137 137
     {
138
-        $method = Helper::buildMethodName($column, 'buildColumn');
139
-        $value = method_exists($this, $method)
140
-            ? call_user_func([$this, $method], $postId)
138
+        $method = Helper::buildMethodName( $column, 'buildColumn' );
139
+        $value = method_exists( $this, $method )
140
+            ? call_user_func( [$this, $method], $postId )
141 141
             : '';
142
-        $value = apply_filters('site-reviews/columns/'.$column, $value, $postId);
143
-        if (0 !== $value && empty($value)) {
142
+        $value = apply_filters( 'site-reviews/columns/'.$column, $value, $postId );
143
+        if( 0 !== $value && empty($value) ) {
144 144
             $value = '&mdash;';
145 145
         }
146 146
         echo $value;
@@ -150,44 +150,44 @@  discard block
 block discarded – undo
150 150
      * @param array $ratings
151 151
      * @return void
152 152
      */
153
-    protected function renderFilterRatings($ratings)
153
+    protected function renderFilterRatings( $ratings )
154 154
     {
155
-        if (empty($ratings)) {
155
+        if( empty($ratings) ) {
156 156
             return;
157 157
         }
158
-        $ratings = array_flip(array_reverse($ratings));
159
-        array_walk($ratings, function (&$value, $key) {
160
-            $label = _n('%s star', '%s stars', $key, 'site-reviews');
161
-            $value = sprintf($label, $key);
158
+        $ratings = array_flip( array_reverse( $ratings ) );
159
+        array_walk( $ratings, function( &$value, $key ) {
160
+            $label = _n( '%s star', '%s stars', $key, 'site-reviews' );
161
+            $value = sprintf( $label, $key );
162 162
         });
163
-        echo glsr(Builder::class)->label(__('Filter by rating', 'site-reviews'), [
163
+        echo glsr( Builder::class )->label( __( 'Filter by rating', 'site-reviews' ), [
164 164
             'class' => 'screen-reader-text',
165 165
             'for' => 'rating',
166
-        ]);
167
-        echo glsr(Builder::class)->select([
166
+        ] );
167
+        echo glsr( Builder::class )->select( [
168 168
             'name' => 'rating',
169
-            'options' => ['' => __('All ratings', 'site-reviews')] + $ratings,
170
-            'value' => filter_input(INPUT_GET, 'rating'),
171
-        ]);
169
+            'options' => ['' => __( 'All ratings', 'site-reviews' )] + $ratings,
170
+            'value' => filter_input( INPUT_GET, 'rating' ),
171
+        ] );
172 172
     }
173 173
 
174 174
     /**
175 175
      * @param array $types
176 176
      * @return void
177 177
      */
178
-    protected function renderFilterTypes($types)
178
+    protected function renderFilterTypes( $types )
179 179
     {
180
-        if (count(glsr()->reviewTypes) < 2) {
180
+        if( count( glsr()->reviewTypes ) < 2 ) {
181 181
             return;
182 182
         }
183
-        echo glsr(Builder::class)->label(__('Filter by type', 'site-reviews'), [
183
+        echo glsr( Builder::class )->label( __( 'Filter by type', 'site-reviews' ), [
184 184
             'class' => 'screen-reader-text',
185 185
             'for' => 'review_type',
186
-        ]);
187
-        echo glsr(Builder::class)->select([
186
+        ] );
187
+        echo glsr( Builder::class )->select( [
188 188
             'name' => 'review_type',
189
-            'options' => ['' => __('All types', 'site-reviews')] + glsr()->reviewTypes,
190
-            'value' => filter_input(INPUT_GET, 'review_type'),
191
-        ]);
189
+            'options' => ['' => __( 'All types', 'site-reviews' )] + glsr()->reviewTypes,
190
+            'value' => filter_input( INPUT_GET, 'review_type' ),
191
+        ] );
192 192
     }
193 193
 }
Please login to merge, or discard this patch.
plugin/Database/SqlQueries.php 2 patches
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -8,47 +8,47 @@  discard block
 block discarded – undo
8 8
 
9 9
 class SqlQueries
10 10
 {
11
-    protected $db;
12
-    protected $postType;
11
+	protected $db;
12
+	protected $postType;
13 13
 
14
-    public function __construct()
15
-    {
16
-        global $wpdb;
17
-        $this->db = $wpdb;
18
-        $this->postType = Application::POST_TYPE;
19
-    }
14
+	public function __construct()
15
+	{
16
+		global $wpdb;
17
+		$this->db = $wpdb;
18
+		$this->postType = Application::POST_TYPE;
19
+	}
20 20
 
21
-    /**
22
-     * @return bool
23
-     */
24
-    public function deletePostCountMetaKeys()
25
-    {
26
-        return $this->db->query("
21
+	/**
22
+	 * @return bool
23
+	 */
24
+	public function deletePostCountMetaKeys()
25
+	{
26
+		return $this->db->query("
27 27
             DELETE
28 28
             FROM {$this->db->postmeta}
29 29
             WHERE meta_key LIKE '_glsr_%'
30 30
         ");
31
-    }
31
+	}
32 32
 
33
-    /**
34
-     * @return bool
35
-     */
36
-    public function deleteTermCountMetaKeys()
37
-    {
38
-        return $this->db->query("
33
+	/**
34
+	 * @return bool
35
+	 */
36
+	public function deleteTermCountMetaKeys()
37
+	{
38
+		return $this->db->query("
39 39
             DELETE
40 40
             FROM {$this->db->termmeta}
41 41
             WHERE meta_key LIKE '_glsr_%'
42 42
         ");
43
-    }
43
+	}
44 44
 
45
-    /**
46
-     * @param string $metaReviewId
47
-     * @return int
48
-     */
49
-    public function getPostIdFromReviewId($metaReviewId)
50
-    {
51
-        $postId = $this->db->get_var("
45
+	/**
46
+	 * @param string $metaReviewId
47
+	 * @return int
48
+	 */
49
+	public function getPostIdFromReviewId($metaReviewId)
50
+	{
51
+		$postId = $this->db->get_var("
52 52
             SELECT p.ID
53 53
             FROM {$this->db->posts} AS p
54 54
             INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
@@ -56,17 +56,17 @@  discard block
 block discarded – undo
56 56
             AND m.meta_key = '_review_id'
57 57
             AND m.meta_value = '{$metaReviewId}'
58 58
         ");
59
-        return intval($postId);
60
-    }
59
+		return intval($postId);
60
+	}
61 61
 
62
-    /**
63
-     * @param int $lastPostId
64
-     * @param int $limit
65
-     * @return array
66
-     */
67
-    public function getReviewCounts(array $args, $lastPostId = 0, $limit = 500)
68
-    {
69
-        return (array) $this->db->get_results("
62
+	/**
63
+	 * @param int $lastPostId
64
+	 * @param int $limit
65
+	 * @return array
66
+	 */
67
+	public function getReviewCounts(array $args, $lastPostId = 0, $limit = 500)
68
+	{
69
+		return (array) $this->db->get_results("
70 70
             SELECT DISTINCT p.ID, m1.meta_value AS rating, m2.meta_value AS type
71 71
             FROM {$this->db->posts} AS p
72 72
             INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id
@@ -81,17 +81,17 @@  discard block
 block discarded – undo
81 81
             ORDER By p.ID ASC
82 82
             LIMIT {$limit}
83 83
         ");
84
-    }
84
+	}
85 85
 
86
-    /**
87
-     * @todo remove this?
88
-     * @param string $metaKey
89
-     * @return array
90
-     */
91
-    public function getReviewCountsFor($metaKey)
92
-    {
93
-        $metaKey = Str::prefix('_', $metaKey);
94
-        return (array) $this->db->get_results("
86
+	/**
87
+	 * @todo remove this?
88
+	 * @param string $metaKey
89
+	 * @return array
90
+	 */
91
+	public function getReviewCountsFor($metaKey)
92
+	{
93
+		$metaKey = Str::prefix('_', $metaKey);
94
+		return (array) $this->db->get_results("
95 95
             SELECT DISTINCT m.meta_value AS name, COUNT(*) num_posts
96 96
             FROM {$this->db->posts} AS p
97 97
             INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
@@ -99,16 +99,16 @@  discard block
 block discarded – undo
99 99
             AND m.meta_key = '{$metaKey}'
100 100
             GROUP BY name
101 101
         ");
102
-    }
102
+	}
103 103
 
104
-    /**
105
-     * @todo remove this?
106
-     * @param string $reviewType
107
-     * @return array
108
-     */
109
-    public function getReviewIdsByType($reviewType)
110
-    {
111
-        $results = $this->db->get_col("
104
+	/**
105
+	 * @todo remove this?
106
+	 * @param string $reviewType
107
+	 * @return array
108
+	 */
109
+	public function getReviewIdsByType($reviewType)
110
+	{
111
+		$results = $this->db->get_col("
112 112
             SELECT DISTINCT m1.meta_value AS review_id
113 113
             FROM {$this->db->posts} AS p
114 114
             INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id
@@ -118,20 +118,20 @@  discard block
 block discarded – undo
118 118
             AND m2.meta_key = '_review_type'
119 119
             AND m2.meta_value = '{$reviewType}'
120 120
         ");
121
-        return array_keys(array_flip($results));
122
-    }
121
+		return array_keys(array_flip($results));
122
+	}
123 123
 
124
-    /**
125
-     * @param int $greaterThanId
126
-     * @param int $limit
127
-     * @return array
128
-     */
129
-    public function getReviewRatingsFromIds(array $postIds, $greaterThanId = 0, $limit = 100)
130
-    {
131
-        sort($postIds);
132
-        $postIds = array_slice($postIds, intval(array_search($greaterThanId, $postIds)), $limit);
133
-        $postIds = implode(',', $postIds);
134
-        return (array) $this->db->get_results("
124
+	/**
125
+	 * @param int $greaterThanId
126
+	 * @param int $limit
127
+	 * @return array
128
+	 */
129
+	public function getReviewRatingsFromIds(array $postIds, $greaterThanId = 0, $limit = 100)
130
+	{
131
+		sort($postIds);
132
+		$postIds = array_slice($postIds, intval(array_search($greaterThanId, $postIds)), $limit);
133
+		$postIds = implode(',', $postIds);
134
+		return (array) $this->db->get_results("
135 135
             SELECT p.ID, m.meta_value AS rating
136 136
             FROM {$this->db->posts} AS p
137 137
             INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
@@ -144,20 +144,20 @@  discard block
 block discarded – undo
144 144
             ORDER By p.ID ASC
145 145
             LIMIT {$limit}
146 146
         ");
147
-    }
147
+	}
148 148
 
149
-    /**
150
-     * @param string $key
151
-     * @param string $status
152
-     * @return array
153
-     */
154
-    public function getReviewsMeta($key, $status = 'publish')
155
-    {
156
-        $postStatusQuery = 'all' != $status && !empty($status)
157
-            ? "AND p.post_status = '{$status}'"
158
-            : '';
159
-        $key = Str::prefix('_', $key);
160
-        $values = $this->db->get_col("
149
+	/**
150
+	 * @param string $key
151
+	 * @param string $status
152
+	 * @return array
153
+	 */
154
+	public function getReviewsMeta($key, $status = 'publish')
155
+	{
156
+		$postStatusQuery = 'all' != $status && !empty($status)
157
+			? "AND p.post_status = '{$status}'"
158
+			: '';
159
+		$key = Str::prefix('_', $key);
160
+		$values = $this->db->get_col("
161 161
             SELECT DISTINCT m.meta_value
162 162
             FROM {$this->db->postmeta} m
163 163
             LEFT JOIN {$this->db->posts} p ON p.ID = m.post_id
@@ -168,42 +168,42 @@  discard block
 block discarded – undo
168 168
             GROUP BY p.ID -- remove duplicate meta_value entries
169 169
             ORDER BY m.meta_id ASC -- sort by oldest meta_value
170 170
         ");
171
-        sort($values);
172
-        return $values;
173
-    }
171
+		sort($values);
172
+		return $values;
173
+	}
174 174
 
175
-    /**
176
-     * @param string $and
177
-     * @return string
178
-     */
179
-    protected function getAndForCounts(array $args, $and = '')
180
-    {
181
-        $postIds = implode(',', array_filter(Arr::get($args, 'post_ids', [])));
182
-        $termIds = implode(',', array_filter(Arr::get($args, 'term_ids', [])));
183
-        if (!empty($args['type'])) {
184
-            $and.= "AND m2.meta_value = '{$args['type']}' ";
185
-        }
186
-        if ($postIds) {
187
-            $and.= "AND m3.meta_key = '_assigned_to' AND m3.meta_value IN ({$postIds}) ";
188
-        }
189
-        if ($termIds) {
190
-            $and.= "AND tr.term_taxonomy_id IN ({$termIds}) ";
191
-        }
192
-        return apply_filters('site-reviews/query/and-for-counts', $and);
193
-    }
175
+	/**
176
+	 * @param string $and
177
+	 * @return string
178
+	 */
179
+	protected function getAndForCounts(array $args, $and = '')
180
+	{
181
+		$postIds = implode(',', array_filter(Arr::get($args, 'post_ids', [])));
182
+		$termIds = implode(',', array_filter(Arr::get($args, 'term_ids', [])));
183
+		if (!empty($args['type'])) {
184
+			$and.= "AND m2.meta_value = '{$args['type']}' ";
185
+		}
186
+		if ($postIds) {
187
+			$and.= "AND m3.meta_key = '_assigned_to' AND m3.meta_value IN ({$postIds}) ";
188
+		}
189
+		if ($termIds) {
190
+			$and.= "AND tr.term_taxonomy_id IN ({$termIds}) ";
191
+		}
192
+		return apply_filters('site-reviews/query/and-for-counts', $and);
193
+	}
194 194
 
195
-    /**
196
-     * @param string $innerJoin
197
-     * @return string
198
-     */
199
-    protected function getInnerJoinForCounts(array $args, $innerJoin = '')
200
-    {
201
-        if (!empty(Arr::get($args, 'post_ids'))) {
202
-            $innerJoin.= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id ";
203
-        }
204
-        if (!empty(Arr::get($args, 'term_ids'))) {
205
-            $innerJoin.= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id ";
206
-        }
207
-        return apply_filters('site-reviews/query/inner-join-for-counts', $innerJoin);
208
-    }
195
+	/**
196
+	 * @param string $innerJoin
197
+	 * @return string
198
+	 */
199
+	protected function getInnerJoinForCounts(array $args, $innerJoin = '')
200
+	{
201
+		if (!empty(Arr::get($args, 'post_ids'))) {
202
+			$innerJoin.= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id ";
203
+		}
204
+		if (!empty(Arr::get($args, 'term_ids'))) {
205
+			$innerJoin.= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id ";
206
+		}
207
+		return apply_filters('site-reviews/query/inner-join-for-counts', $innerJoin);
208
+	}
209 209
 }
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public function deletePostCountMetaKeys()
25 25
     {
26
-        return $this->db->query("
26
+        return $this->db->query( "
27 27
             DELETE
28 28
             FROM {$this->db->postmeta}
29 29
             WHERE meta_key LIKE '_glsr_%'
30
-        ");
30
+        " );
31 31
     }
32 32
 
33 33
     /**
@@ -35,28 +35,28 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function deleteTermCountMetaKeys()
37 37
     {
38
-        return $this->db->query("
38
+        return $this->db->query( "
39 39
             DELETE
40 40
             FROM {$this->db->termmeta}
41 41
             WHERE meta_key LIKE '_glsr_%'
42
-        ");
42
+        " );
43 43
     }
44 44
 
45 45
     /**
46 46
      * @param string $metaReviewId
47 47
      * @return int
48 48
      */
49
-    public function getPostIdFromReviewId($metaReviewId)
49
+    public function getPostIdFromReviewId( $metaReviewId )
50 50
     {
51
-        $postId = $this->db->get_var("
51
+        $postId = $this->db->get_var( "
52 52
             SELECT p.ID
53 53
             FROM {$this->db->posts} AS p
54 54
             INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
55 55
             WHERE p.post_type = '{$this->postType}'
56 56
             AND m.meta_key = '_review_id'
57 57
             AND m.meta_value = '{$metaReviewId}'
58
-        ");
59
-        return intval($postId);
58
+        " );
59
+        return intval( $postId );
60 60
     }
61 61
 
62 62
     /**
@@ -64,23 +64,23 @@  discard block
 block discarded – undo
64 64
      * @param int $limit
65 65
      * @return array
66 66
      */
67
-    public function getReviewCounts(array $args, $lastPostId = 0, $limit = 500)
67
+    public function getReviewCounts( array $args, $lastPostId = 0, $limit = 500 )
68 68
     {
69
-        return (array) $this->db->get_results("
69
+        return (array)$this->db->get_results( "
70 70
             SELECT DISTINCT p.ID, m1.meta_value AS rating, m2.meta_value AS type
71 71
             FROM {$this->db->posts} AS p
72 72
             INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id
73 73
             INNER JOIN {$this->db->postmeta} AS m2 ON p.ID = m2.post_id
74
-            {$this->getInnerJoinForCounts($args)}
74
+            {$this->getInnerJoinForCounts( $args )}
75 75
             WHERE p.ID > {$lastPostId}
76 76
             AND p.post_status = 'publish'
77 77
             AND p.post_type = '{$this->postType}'
78 78
             AND m1.meta_key = '_rating'
79 79
             AND m2.meta_key = '_review_type'
80
-            {$this->getAndForCounts($args)}
80
+            {$this->getAndForCounts( $args )}
81 81
             ORDER By p.ID ASC
82 82
             LIMIT {$limit}
83
-        ");
83
+        " );
84 84
     }
85 85
 
86 86
     /**
@@ -88,17 +88,17 @@  discard block
 block discarded – undo
88 88
      * @param string $metaKey
89 89
      * @return array
90 90
      */
91
-    public function getReviewCountsFor($metaKey)
91
+    public function getReviewCountsFor( $metaKey )
92 92
     {
93
-        $metaKey = Str::prefix('_', $metaKey);
94
-        return (array) $this->db->get_results("
93
+        $metaKey = Str::prefix( '_', $metaKey );
94
+        return (array)$this->db->get_results( "
95 95
             SELECT DISTINCT m.meta_value AS name, COUNT(*) num_posts
96 96
             FROM {$this->db->posts} AS p
97 97
             INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
98 98
             WHERE p.post_type = '{$this->postType}'
99 99
             AND m.meta_key = '{$metaKey}'
100 100
             GROUP BY name
101
-        ");
101
+        " );
102 102
     }
103 103
 
104 104
     /**
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
      * @param string $reviewType
107 107
      * @return array
108 108
      */
109
-    public function getReviewIdsByType($reviewType)
109
+    public function getReviewIdsByType( $reviewType )
110 110
     {
111
-        $results = $this->db->get_col("
111
+        $results = $this->db->get_col( "
112 112
             SELECT DISTINCT m1.meta_value AS review_id
113 113
             FROM {$this->db->posts} AS p
114 114
             INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
             AND m1.meta_key = '_review_id'
118 118
             AND m2.meta_key = '_review_type'
119 119
             AND m2.meta_value = '{$reviewType}'
120
-        ");
121
-        return array_keys(array_flip($results));
120
+        " );
121
+        return array_keys( array_flip( $results ) );
122 122
     }
123 123
 
124 124
     /**
@@ -126,12 +126,12 @@  discard block
 block discarded – undo
126 126
      * @param int $limit
127 127
      * @return array
128 128
      */
129
-    public function getReviewRatingsFromIds(array $postIds, $greaterThanId = 0, $limit = 100)
129
+    public function getReviewRatingsFromIds( array $postIds, $greaterThanId = 0, $limit = 100 )
130 130
     {
131
-        sort($postIds);
132
-        $postIds = array_slice($postIds, intval(array_search($greaterThanId, $postIds)), $limit);
133
-        $postIds = implode(',', $postIds);
134
-        return (array) $this->db->get_results("
131
+        sort( $postIds );
132
+        $postIds = array_slice( $postIds, intval( array_search( $greaterThanId, $postIds ) ), $limit );
133
+        $postIds = implode( ',', $postIds );
134
+        return (array)$this->db->get_results( "
135 135
             SELECT p.ID, m.meta_value AS rating
136 136
             FROM {$this->db->posts} AS p
137 137
             INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
             GROUP BY p.ID
144 144
             ORDER By p.ID ASC
145 145
             LIMIT {$limit}
146
-        ");
146
+        " );
147 147
     }
148 148
 
149 149
     /**
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
      * @param string $status
152 152
      * @return array
153 153
      */
154
-    public function getReviewsMeta($key, $status = 'publish')
154
+    public function getReviewsMeta( $key, $status = 'publish' )
155 155
     {
156 156
         $postStatusQuery = 'all' != $status && !empty($status)
157 157
             ? "AND p.post_status = '{$status}'"
158 158
             : '';
159
-        $key = Str::prefix('_', $key);
160
-        $values = $this->db->get_col("
159
+        $key = Str::prefix( '_', $key );
160
+        $values = $this->db->get_col( "
161 161
             SELECT DISTINCT m.meta_value
162 162
             FROM {$this->db->postmeta} m
163 163
             LEFT JOIN {$this->db->posts} p ON p.ID = m.post_id
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
             $postStatusQuery
168 168
             GROUP BY p.ID -- remove duplicate meta_value entries
169 169
             ORDER BY m.meta_id ASC -- sort by oldest meta_value
170
-        ");
171
-        sort($values);
170
+        " );
171
+        sort( $values );
172 172
         return $values;
173 173
     }
174 174
 
@@ -176,34 +176,34 @@  discard block
 block discarded – undo
176 176
      * @param string $and
177 177
      * @return string
178 178
      */
179
-    protected function getAndForCounts(array $args, $and = '')
179
+    protected function getAndForCounts( array $args, $and = '' )
180 180
     {
181
-        $postIds = implode(',', array_filter(Arr::get($args, 'post_ids', [])));
182
-        $termIds = implode(',', array_filter(Arr::get($args, 'term_ids', [])));
183
-        if (!empty($args['type'])) {
184
-            $and.= "AND m2.meta_value = '{$args['type']}' ";
181
+        $postIds = implode( ',', array_filter( Arr::get( $args, 'post_ids', [] ) ) );
182
+        $termIds = implode( ',', array_filter( Arr::get( $args, 'term_ids', [] ) ) );
183
+        if( !empty($args['type']) ) {
184
+            $and .= "AND m2.meta_value = '{$args['type']}' ";
185 185
         }
186
-        if ($postIds) {
187
-            $and.= "AND m3.meta_key = '_assigned_to' AND m3.meta_value IN ({$postIds}) ";
186
+        if( $postIds ) {
187
+            $and .= "AND m3.meta_key = '_assigned_to' AND m3.meta_value IN ({$postIds}) ";
188 188
         }
189
-        if ($termIds) {
190
-            $and.= "AND tr.term_taxonomy_id IN ({$termIds}) ";
189
+        if( $termIds ) {
190
+            $and .= "AND tr.term_taxonomy_id IN ({$termIds}) ";
191 191
         }
192
-        return apply_filters('site-reviews/query/and-for-counts', $and);
192
+        return apply_filters( 'site-reviews/query/and-for-counts', $and );
193 193
     }
194 194
 
195 195
     /**
196 196
      * @param string $innerJoin
197 197
      * @return string
198 198
      */
199
-    protected function getInnerJoinForCounts(array $args, $innerJoin = '')
199
+    protected function getInnerJoinForCounts( array $args, $innerJoin = '' )
200 200
     {
201
-        if (!empty(Arr::get($args, 'post_ids'))) {
202
-            $innerJoin.= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id ";
201
+        if( !empty(Arr::get( $args, 'post_ids' )) ) {
202
+            $innerJoin .= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id ";
203 203
         }
204
-        if (!empty(Arr::get($args, 'term_ids'))) {
205
-            $innerJoin.= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id ";
204
+        if( !empty(Arr::get( $args, 'term_ids' )) ) {
205
+            $innerJoin .= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id ";
206 206
         }
207
-        return apply_filters('site-reviews/query/inner-join-for-counts', $innerJoin);
207
+        return apply_filters( 'site-reviews/query/inner-join-for-counts', $innerJoin );
208 208
     }
209 209
 }
Please login to merge, or discard this patch.
plugin/Database/TermCountsManager.php 2 patches
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -9,91 +9,91 @@
 block discarded – undo
9 9
 
10 10
 class TermCountsManager
11 11
 {
12
-    /**
13
-     * @var CountsManager
14
-     */
15
-    protected $manager;
12
+	/**
13
+	 * @var CountsManager
14
+	 */
15
+	protected $manager;
16 16
 
17
-    public function __construct()
18
-    {
19
-        $this->manager = glsr(CountsManager::class);
20
-    }
17
+	public function __construct()
18
+	{
19
+		$this->manager = glsr(CountsManager::class);
20
+	}
21 21
 
22
-    /**
23
-     * @param int $termTaxonomyId
24
-     * @return array
25
-     */
26
-    public function build($termTaxonomyId)
27
-    {
28
-        return $this->manager->buildCounts([
29
-            'term_ids' => [$termTaxonomyId],
30
-        ]);
31
-    }
22
+	/**
23
+	 * @param int $termTaxonomyId
24
+	 * @return array
25
+	 */
26
+	public function build($termTaxonomyId)
27
+	{
28
+		return $this->manager->buildCounts([
29
+			'term_ids' => [$termTaxonomyId],
30
+		]);
31
+	}
32 32
 
33
-    /**
34
-     * @return void
35
-     */
36
-    public function decrease(Review $review)
37
-    {
38
-        foreach ($review->term_ids as $termId) {
39
-            if (empty($counts = $this->get($termId))) {
40
-                continue;
41
-            }
42
-            $this->update($termId,
43
-                $this->manager->decreaseRating($counts, $review->review_type, $review->rating)
44
-            );
45
-        }
46
-    }
33
+	/**
34
+	 * @return void
35
+	 */
36
+	public function decrease(Review $review)
37
+	{
38
+		foreach ($review->term_ids as $termId) {
39
+			if (empty($counts = $this->get($termId))) {
40
+				continue;
41
+			}
42
+			$this->update($termId,
43
+				$this->manager->decreaseRating($counts, $review->review_type, $review->rating)
44
+			);
45
+		}
46
+	}
47 47
 
48
-    /**
49
-     * @param int $termId
50
-     * @return array
51
-     */
52
-    public function get($termId)
53
-    {
54
-        return array_filter((array) get_term_meta($termId, CountsManager::META_COUNT, true));
55
-    }
48
+	/**
49
+	 * @param int $termId
50
+	 * @return array
51
+	 */
52
+	public function get($termId)
53
+	{
54
+		return array_filter((array) get_term_meta($termId, CountsManager::META_COUNT, true));
55
+	}
56 56
 
57
-    /**
58
-     * @return void
59
-     */
60
-    public function increase(Review $review)
61
-    {
62
-        $terms = glsr(ReviewManager::class)->normalizeTerms(implode(',', $review->term_ids));
63
-        foreach ($terms as $term) {
64
-            $counts = $this->get($term['term_id']);
65
-            $counts = empty($counts)
66
-                ? $this->build($term['term_taxonomy_id'])
67
-                : $this->manager->increaseRating($counts, $review->review_type, $review->rating);
68
-            $this->update($term['term_id'], $counts);
69
-        }
70
-    }
57
+	/**
58
+	 * @return void
59
+	 */
60
+	public function increase(Review $review)
61
+	{
62
+		$terms = glsr(ReviewManager::class)->normalizeTerms(implode(',', $review->term_ids));
63
+		foreach ($terms as $term) {
64
+			$counts = $this->get($term['term_id']);
65
+			$counts = empty($counts)
66
+				? $this->build($term['term_taxonomy_id'])
67
+				: $this->manager->increaseRating($counts, $review->review_type, $review->rating);
68
+			$this->update($term['term_id'], $counts);
69
+		}
70
+	}
71 71
 
72
-    /**
73
-     * @param int $termId
74
-     * @return void
75
-     */
76
-    public function update($termId, array $reviewCounts)
77
-    {
78
-        $term = get_term($termId, Application::TAXONOMY);
79
-        if (isset($term->term_id)) {
80
-            $ratingCounts = $this->manager->flatten($reviewCounts);
81
-            update_term_meta($termId, CountsManager::META_COUNT, $reviewCounts);
82
-            update_term_meta($termId, CountsManager::META_AVERAGE, glsr(Rating::class)->getAverage($ratingCounts));
83
-            update_term_meta($termId, CountsManager::META_RANKING, glsr(Rating::class)->getRanking($ratingCounts));
84
-        }
85
-    }
72
+	/**
73
+	 * @param int $termId
74
+	 * @return void
75
+	 */
76
+	public function update($termId, array $reviewCounts)
77
+	{
78
+		$term = get_term($termId, Application::TAXONOMY);
79
+		if (isset($term->term_id)) {
80
+			$ratingCounts = $this->manager->flatten($reviewCounts);
81
+			update_term_meta($termId, CountsManager::META_COUNT, $reviewCounts);
82
+			update_term_meta($termId, CountsManager::META_AVERAGE, glsr(Rating::class)->getAverage($ratingCounts));
83
+			update_term_meta($termId, CountsManager::META_RANKING, glsr(Rating::class)->getRanking($ratingCounts));
84
+		}
85
+	}
86 86
 
87
-    /**
88
-     * @return void
89
-     */
90
-    public function updateAll()
91
-    {
92
-        $terms = glsr(Database::class)->getTerms([
93
-            'fields' => 'all',
94
-        ]);
95
-        foreach ($terms as $term) {
96
-            $this->update($term->term_id, $this->build($term->term_taxonomy_id));
97
-        }
98
-    }
87
+	/**
88
+	 * @return void
89
+	 */
90
+	public function updateAll()
91
+	{
92
+		$terms = glsr(Database::class)->getTerms([
93
+			'fields' => 'all',
94
+		]);
95
+		foreach ($terms as $term) {
96
+			$this->update($term->term_id, $this->build($term->term_taxonomy_id));
97
+		}
98
+	}
99 99
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -16,31 +16,31 @@  discard block
 block discarded – undo
16 16
 
17 17
     public function __construct()
18 18
     {
19
-        $this->manager = glsr(CountsManager::class);
19
+        $this->manager = glsr( CountsManager::class );
20 20
     }
21 21
 
22 22
     /**
23 23
      * @param int $termTaxonomyId
24 24
      * @return array
25 25
      */
26
-    public function build($termTaxonomyId)
26
+    public function build( $termTaxonomyId )
27 27
     {
28
-        return $this->manager->buildCounts([
28
+        return $this->manager->buildCounts( [
29 29
             'term_ids' => [$termTaxonomyId],
30
-        ]);
30
+        ] );
31 31
     }
32 32
 
33 33
     /**
34 34
      * @return void
35 35
      */
36
-    public function decrease(Review $review)
36
+    public function decrease( Review $review )
37 37
     {
38
-        foreach ($review->term_ids as $termId) {
39
-            if (empty($counts = $this->get($termId))) {
38
+        foreach( $review->term_ids as $termId ) {
39
+            if( empty($counts = $this->get( $termId )) ) {
40 40
                 continue;
41 41
             }
42
-            $this->update($termId,
43
-                $this->manager->decreaseRating($counts, $review->review_type, $review->rating)
42
+            $this->update( $termId,
43
+                $this->manager->decreaseRating( $counts, $review->review_type, $review->rating )
44 44
             );
45 45
         }
46 46
     }
@@ -49,23 +49,23 @@  discard block
 block discarded – undo
49 49
      * @param int $termId
50 50
      * @return array
51 51
      */
52
-    public function get($termId)
52
+    public function get( $termId )
53 53
     {
54
-        return array_filter((array) get_term_meta($termId, CountsManager::META_COUNT, true));
54
+        return array_filter( (array)get_term_meta( $termId, CountsManager::META_COUNT, true ) );
55 55
     }
56 56
 
57 57
     /**
58 58
      * @return void
59 59
      */
60
-    public function increase(Review $review)
60
+    public function increase( Review $review )
61 61
     {
62
-        $terms = glsr(ReviewManager::class)->normalizeTerms(implode(',', $review->term_ids));
63
-        foreach ($terms as $term) {
64
-            $counts = $this->get($term['term_id']);
62
+        $terms = glsr( ReviewManager::class )->normalizeTerms( implode( ',', $review->term_ids ) );
63
+        foreach( $terms as $term ) {
64
+            $counts = $this->get( $term['term_id'] );
65 65
             $counts = empty($counts)
66
-                ? $this->build($term['term_taxonomy_id'])
67
-                : $this->manager->increaseRating($counts, $review->review_type, $review->rating);
68
-            $this->update($term['term_id'], $counts);
66
+                ? $this->build( $term['term_taxonomy_id'] )
67
+                : $this->manager->increaseRating( $counts, $review->review_type, $review->rating );
68
+            $this->update( $term['term_id'], $counts );
69 69
         }
70 70
     }
71 71
 
@@ -73,14 +73,14 @@  discard block
 block discarded – undo
73 73
      * @param int $termId
74 74
      * @return void
75 75
      */
76
-    public function update($termId, array $reviewCounts)
76
+    public function update( $termId, array $reviewCounts )
77 77
     {
78
-        $term = get_term($termId, Application::TAXONOMY);
79
-        if (isset($term->term_id)) {
80
-            $ratingCounts = $this->manager->flatten($reviewCounts);
81
-            update_term_meta($termId, CountsManager::META_COUNT, $reviewCounts);
82
-            update_term_meta($termId, CountsManager::META_AVERAGE, glsr(Rating::class)->getAverage($ratingCounts));
83
-            update_term_meta($termId, CountsManager::META_RANKING, glsr(Rating::class)->getRanking($ratingCounts));
78
+        $term = get_term( $termId, Application::TAXONOMY );
79
+        if( isset($term->term_id) ) {
80
+            $ratingCounts = $this->manager->flatten( $reviewCounts );
81
+            update_term_meta( $termId, CountsManager::META_COUNT, $reviewCounts );
82
+            update_term_meta( $termId, CountsManager::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ) );
83
+            update_term_meta( $termId, CountsManager::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ) );
84 84
         }
85 85
     }
86 86
 
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
      */
90 90
     public function updateAll()
91 91
     {
92
-        $terms = glsr(Database::class)->getTerms([
92
+        $terms = glsr( Database::class )->getTerms( [
93 93
             'fields' => 'all',
94
-        ]);
95
-        foreach ($terms as $term) {
96
-            $this->update($term->term_id, $this->build($term->term_taxonomy_id));
94
+        ] );
95
+        foreach( $terms as $term ) {
96
+            $this->update( $term->term_id, $this->build( $term->term_taxonomy_id ) );
97 97
         }
98 98
     }
99 99
 }
Please login to merge, or discard this patch.