Passed
Push — master ( ae1954...aab291 )
by Paul
08:17 queued 04:15
created
plugin/Modules/Html/ReviewHtml.php 2 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -7,48 +7,48 @@
 block discarded – undo
7 7
 
8 8
 class ReviewHtml extends ArrayObject
9 9
 {
10
-    /**
11
-     * @var Review
12
-     */
13
-    public $review;
10
+	/**
11
+	 * @var Review
12
+	 */
13
+	public $review;
14 14
 
15
-    /**
16
-     * @var array
17
-     */
18
-    public $values;
15
+	/**
16
+	 * @var array
17
+	 */
18
+	public $values;
19 19
 
20
-    public function __construct(Review $review, array $values = [])
21
-    {
22
-        $this->review = $review;
23
-        $this->values = $values;
24
-        parent::__construct($values, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
25
-    }
20
+	public function __construct(Review $review, array $values = [])
21
+	{
22
+		$this->review = $review;
23
+		$this->values = $values;
24
+		parent::__construct($values, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
25
+	}
26 26
 
27
-    /**
28
-     * @return string|void
29
-     */
30
-    public function __toString()
31
-    {
32
-        if (empty($this->values)) {
33
-            return;
34
-        }
35
-        return glsr(Template::class)->build('templates/review', [
36
-            'context' => $this->values,
37
-            'review' => $this->review,
38
-        ]);
39
-    }
27
+	/**
28
+	 * @return string|void
29
+	 */
30
+	public function __toString()
31
+	{
32
+		if (empty($this->values)) {
33
+			return;
34
+		}
35
+		return glsr(Template::class)->build('templates/review', [
36
+			'context' => $this->values,
37
+			'review' => $this->review,
38
+		]);
39
+	}
40 40
 
41
-    /**
42
-     * @param mixed $key
43
-     * @return mixed
44
-     */
45
-    public function offsetGet($key)
46
-    {
47
-        if (property_exists($this, $key)) {
48
-            return $this->$key;
49
-        }
50
-        return array_key_exists($key, $this->values)
51
-            ? $this->values[$key]
52
-            : null;
53
-    }
41
+	/**
42
+	 * @param mixed $key
43
+	 * @return mixed
44
+	 */
45
+	public function offsetGet($key)
46
+	{
47
+		if (property_exists($this, $key)) {
48
+			return $this->$key;
49
+		}
50
+		return array_key_exists($key, $this->values)
51
+			? $this->values[$key]
52
+			: null;
53
+	}
54 54
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
      */
18 18
     public $values;
19 19
 
20
-    public function __construct(Review $review, array $values = [])
20
+    public function __construct( Review $review, array $values = [] )
21 21
     {
22 22
         $this->review = $review;
23 23
         $this->values = $values;
24
-        parent::__construct($values, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
24
+        parent::__construct( $values, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS );
25 25
     }
26 26
 
27 27
     /**
@@ -29,25 +29,25 @@  discard block
 block discarded – undo
29 29
      */
30 30
     public function __toString()
31 31
     {
32
-        if (empty($this->values)) {
32
+        if( empty($this->values) ) {
33 33
             return;
34 34
         }
35
-        return glsr(Template::class)->build('templates/review', [
35
+        return glsr( Template::class )->build( 'templates/review', [
36 36
             'context' => $this->values,
37 37
             'review' => $this->review,
38
-        ]);
38
+        ] );
39 39
     }
40 40
 
41 41
     /**
42 42
      * @param mixed $key
43 43
      * @return mixed
44 44
      */
45
-    public function offsetGet($key)
45
+    public function offsetGet( $key )
46 46
     {
47
-        if (property_exists($this, $key)) {
47
+        if( property_exists( $this, $key ) ) {
48 48
             return $this->$key;
49 49
         }
50
-        return array_key_exists($key, $this->values)
50
+        return array_key_exists( $key, $this->values )
51 51
             ? $this->values[$key]
52 52
             : null;
53 53
     }
Please login to merge, or discard this patch.
plugin/Modules/Html/ReviewsHtml.php 2 patches
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -7,135 +7,135 @@
 block discarded – undo
7 7
 
8 8
 class ReviewsHtml extends ArrayObject
9 9
 {
10
-    /**
11
-     * @var array
12
-     */
13
-    public $args;
10
+	/**
11
+	 * @var array
12
+	 */
13
+	public $args;
14 14
 
15
-    /**
16
-     * @var int
17
-     */
18
-    public $max_num_pages;
15
+	/**
16
+	 * @var int
17
+	 */
18
+	public $max_num_pages;
19 19
 
20
-    /**
21
-     * @var string
22
-     */
23
-    public $pagination;
20
+	/**
21
+	 * @var string
22
+	 */
23
+	public $pagination;
24 24
 
25
-    /**
26
-     * @var array
27
-     */
28
-    public $reviews;
25
+	/**
26
+	 * @var array
27
+	 */
28
+	public $reviews;
29 29
 
30
-    public function __construct(array $reviews, $maxPageCount, array $args)
31
-    {
32
-        $this->args = $args;
33
-        $this->max_num_pages = $maxPageCount;
34
-        $this->reviews = $reviews;
35
-        $this->pagination = $this->buildPagination();
36
-        parent::__construct($reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
37
-    }
30
+	public function __construct(array $reviews, $maxPageCount, array $args)
31
+	{
32
+		$this->args = $args;
33
+		$this->max_num_pages = $maxPageCount;
34
+		$this->reviews = $reviews;
35
+		$this->pagination = $this->buildPagination();
36
+		parent::__construct($reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
37
+	}
38 38
 
39
-    /**
40
-     * @return string
41
-     */
42
-    public function __toString()
43
-    {
44
-        return glsr(Template::class)->build('templates/reviews', [
45
-            'args' => $this->args,
46
-            'context' => [
47
-                'assigned_to' => $this->args['assigned_to'],
48
-                'category' => $this->args['category'],
49
-                'class' => $this->getClass(),
50
-                'id' => $this->args['id'],
51
-                'pagination' => $this->getPagination(),
52
-                'reviews' => $this->getReviews(),
53
-            ],
54
-        ]);
55
-    }
39
+	/**
40
+	 * @return string
41
+	 */
42
+	public function __toString()
43
+	{
44
+		return glsr(Template::class)->build('templates/reviews', [
45
+			'args' => $this->args,
46
+			'context' => [
47
+				'assigned_to' => $this->args['assigned_to'],
48
+				'category' => $this->args['category'],
49
+				'class' => $this->getClass(),
50
+				'id' => $this->args['id'],
51
+				'pagination' => $this->getPagination(),
52
+				'reviews' => $this->getReviews(),
53
+			],
54
+		]);
55
+	}
56 56
 
57
-    /**
58
-     * @return string
59
-     */
60
-    public function getPagination()
61
-    {
62
-        return wp_validate_boolean($this->args['pagination'])
63
-            ? $this->pagination
64
-            : '';
65
-    }
57
+	/**
58
+	 * @return string
59
+	 */
60
+	public function getPagination()
61
+	{
62
+		return wp_validate_boolean($this->args['pagination'])
63
+			? $this->pagination
64
+			: '';
65
+	}
66 66
 
67
-    /**
68
-     * @return string
69
-     */
70
-    public function getReviews()
71
-    {
72
-        $html = empty($this->reviews)
73
-            ? $this->getReviewsFallback()
74
-            : implode(PHP_EOL, $this->reviews);
75
-        $wrapper = '<div class="glsr-reviews">%s</div>';
76
-        $wrapper = apply_filters('site-reviews/reviews/reviews-wrapper', $wrapper);
77
-        return sprintf($wrapper, $html);
78
-    }
67
+	/**
68
+	 * @return string
69
+	 */
70
+	public function getReviews()
71
+	{
72
+		$html = empty($this->reviews)
73
+			? $this->getReviewsFallback()
74
+			: implode(PHP_EOL, $this->reviews);
75
+		$wrapper = '<div class="glsr-reviews">%s</div>';
76
+		$wrapper = apply_filters('site-reviews/reviews/reviews-wrapper', $wrapper);
77
+		return sprintf($wrapper, $html);
78
+	}
79 79
 
80
-    /**
81
-     * @param mixed $key
82
-     * @return mixed
83
-     */
84
-    public function offsetGet($key)
85
-    {
86
-        if ('navigation' == $key) {
87
-            glsr()->deprecated[] = 'The $reviewsHtml->navigation property has been been deprecated. Please use the $reviewsHtml->pagination property instead.';
88
-            return $this->pagination;
89
-        }
90
-        if (property_exists($this, $key)) {
91
-            return $this->$key;
92
-        }
93
-        return array_key_exists($key, $this->reviews)
94
-            ? $this->reviews[$key]
95
-            : null;
96
-    }
80
+	/**
81
+	 * @param mixed $key
82
+	 * @return mixed
83
+	 */
84
+	public function offsetGet($key)
85
+	{
86
+		if ('navigation' == $key) {
87
+			glsr()->deprecated[] = 'The $reviewsHtml->navigation property has been been deprecated. Please use the $reviewsHtml->pagination property instead.';
88
+			return $this->pagination;
89
+		}
90
+		if (property_exists($this, $key)) {
91
+			return $this->$key;
92
+		}
93
+		return array_key_exists($key, $this->reviews)
94
+			? $this->reviews[$key]
95
+			: null;
96
+	}
97 97
 
98
-    /**
99
-     * @return string
100
-     */
101
-    protected function buildPagination()
102
-    {
103
-        $html = glsr(Partial::class)->build('pagination', [
104
-            'baseUrl' => glsr_get($this->args, 'pagedUrl'),
105
-            'current' => glsr_get($this->args, 'paged'),
106
-            'total' => $this->max_num_pages,
107
-        ]);
108
-        $html.= sprintf('<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json']);
109
-        $wrapper = '<div class="glsr-pagination">%s</div>';
110
-        $wrapper = apply_filters('site-reviews/reviews/pagination-wrapper', $wrapper);
111
-        return sprintf($wrapper, $html);
112
-    }
98
+	/**
99
+	 * @return string
100
+	 */
101
+	protected function buildPagination()
102
+	{
103
+		$html = glsr(Partial::class)->build('pagination', [
104
+			'baseUrl' => glsr_get($this->args, 'pagedUrl'),
105
+			'current' => glsr_get($this->args, 'paged'),
106
+			'total' => $this->max_num_pages,
107
+		]);
108
+		$html.= sprintf('<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json']);
109
+		$wrapper = '<div class="glsr-pagination">%s</div>';
110
+		$wrapper = apply_filters('site-reviews/reviews/pagination-wrapper', $wrapper);
111
+		return sprintf($wrapper, $html);
112
+	}
113 113
 
114
-    /**
115
-     * @return string
116
-     */
117
-    protected function getClass()
118
-    {
119
-        $defaults = [
120
-            'glsr-default',
121
-        ];
122
-        if ('ajax' == $this->args['pagination']) {
123
-            $defaults[] = 'glsr-ajax-pagination';
124
-        }
125
-        $classes = explode(' ', $this->args['class']);
126
-        $classes = array_unique(array_merge($defaults, array_filter($classes)));
127
-        return implode(' ', $classes);
128
-    }
114
+	/**
115
+	 * @return string
116
+	 */
117
+	protected function getClass()
118
+	{
119
+		$defaults = [
120
+			'glsr-default',
121
+		];
122
+		if ('ajax' == $this->args['pagination']) {
123
+			$defaults[] = 'glsr-ajax-pagination';
124
+		}
125
+		$classes = explode(' ', $this->args['class']);
126
+		$classes = array_unique(array_merge($defaults, array_filter($classes)));
127
+		return implode(' ', $classes);
128
+	}
129 129
 
130
-    /**
131
-     * @return string
132
-     */
133
-    protected function getReviewsFallback()
134
-    {
135
-        if (empty($this->args['fallback']) && glsr(OptionManager::class)->getBool('settings.reviews.fallback')) {
136
-            $this->args['fallback'] = __('There are no reviews yet. Be the first one to write one.', 'site-reviews');
137
-        }
138
-        $fallback = '<p class="glsr-no-margins">'.$this->args['fallback'].'</p>';
139
-        return apply_filters('site-reviews/reviews/fallback', $fallback, $this->args);
140
-    }
130
+	/**
131
+	 * @return string
132
+	 */
133
+	protected function getReviewsFallback()
134
+	{
135
+		if (empty($this->args['fallback']) && glsr(OptionManager::class)->getBool('settings.reviews.fallback')) {
136
+			$this->args['fallback'] = __('There are no reviews yet. Be the first one to write one.', 'site-reviews');
137
+		}
138
+		$fallback = '<p class="glsr-no-margins">'.$this->args['fallback'].'</p>';
139
+		return apply_filters('site-reviews/reviews/fallback', $fallback, $this->args);
140
+	}
141 141
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -27,13 +27,13 @@  discard block
 block discarded – undo
27 27
      */
28 28
     public $reviews;
29 29
 
30
-    public function __construct(array $reviews, $maxPageCount, array $args)
30
+    public function __construct( array $reviews, $maxPageCount, array $args )
31 31
     {
32 32
         $this->args = $args;
33 33
         $this->max_num_pages = $maxPageCount;
34 34
         $this->reviews = $reviews;
35 35
         $this->pagination = $this->buildPagination();
36
-        parent::__construct($reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
36
+        parent::__construct( $reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS );
37 37
     }
38 38
 
39 39
     /**
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public function __toString()
43 43
     {
44
-        return glsr(Template::class)->build('templates/reviews', [
44
+        return glsr( Template::class )->build( 'templates/reviews', [
45 45
             'args' => $this->args,
46 46
             'context' => [
47 47
                 'assigned_to' => $this->args['assigned_to'],
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
                 'pagination' => $this->getPagination(),
52 52
                 'reviews' => $this->getReviews(),
53 53
             ],
54
-        ]);
54
+        ] );
55 55
     }
56 56
 
57 57
     /**
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      */
60 60
     public function getPagination()
61 61
     {
62
-        return wp_validate_boolean($this->args['pagination'])
62
+        return wp_validate_boolean( $this->args['pagination'] )
63 63
             ? $this->pagination
64 64
             : '';
65 65
     }
@@ -71,26 +71,26 @@  discard block
 block discarded – undo
71 71
     {
72 72
         $html = empty($this->reviews)
73 73
             ? $this->getReviewsFallback()
74
-            : implode(PHP_EOL, $this->reviews);
74
+            : implode( PHP_EOL, $this->reviews );
75 75
         $wrapper = '<div class="glsr-reviews">%s</div>';
76
-        $wrapper = apply_filters('site-reviews/reviews/reviews-wrapper', $wrapper);
77
-        return sprintf($wrapper, $html);
76
+        $wrapper = apply_filters( 'site-reviews/reviews/reviews-wrapper', $wrapper );
77
+        return sprintf( $wrapper, $html );
78 78
     }
79 79
 
80 80
     /**
81 81
      * @param mixed $key
82 82
      * @return mixed
83 83
      */
84
-    public function offsetGet($key)
84
+    public function offsetGet( $key )
85 85
     {
86
-        if ('navigation' == $key) {
86
+        if( 'navigation' == $key ) {
87 87
             glsr()->deprecated[] = 'The $reviewsHtml->navigation property has been been deprecated. Please use the $reviewsHtml->pagination property instead.';
88 88
             return $this->pagination;
89 89
         }
90
-        if (property_exists($this, $key)) {
90
+        if( property_exists( $this, $key ) ) {
91 91
             return $this->$key;
92 92
         }
93
-        return array_key_exists($key, $this->reviews)
93
+        return array_key_exists( $key, $this->reviews )
94 94
             ? $this->reviews[$key]
95 95
             : null;
96 96
     }
@@ -100,15 +100,15 @@  discard block
 block discarded – undo
100 100
      */
101 101
     protected function buildPagination()
102 102
     {
103
-        $html = glsr(Partial::class)->build('pagination', [
104
-            'baseUrl' => glsr_get($this->args, 'pagedUrl'),
105
-            'current' => glsr_get($this->args, 'paged'),
103
+        $html = glsr( Partial::class )->build( 'pagination', [
104
+            'baseUrl' => glsr_get( $this->args, 'pagedUrl' ),
105
+            'current' => glsr_get( $this->args, 'paged' ),
106 106
             'total' => $this->max_num_pages,
107
-        ]);
108
-        $html.= sprintf('<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json']);
107
+        ] );
108
+        $html .= sprintf( '<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json'] );
109 109
         $wrapper = '<div class="glsr-pagination">%s</div>';
110
-        $wrapper = apply_filters('site-reviews/reviews/pagination-wrapper', $wrapper);
111
-        return sprintf($wrapper, $html);
110
+        $wrapper = apply_filters( 'site-reviews/reviews/pagination-wrapper', $wrapper );
111
+        return sprintf( $wrapper, $html );
112 112
     }
113 113
 
114 114
     /**
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
         $defaults = [
120 120
             'glsr-default',
121 121
         ];
122
-        if ('ajax' == $this->args['pagination']) {
122
+        if( 'ajax' == $this->args['pagination'] ) {
123 123
             $defaults[] = 'glsr-ajax-pagination';
124 124
         }
125
-        $classes = explode(' ', $this->args['class']);
126
-        $classes = array_unique(array_merge($defaults, array_filter($classes)));
127
-        return implode(' ', $classes);
125
+        $classes = explode( ' ', $this->args['class'] );
126
+        $classes = array_unique( array_merge( $defaults, array_filter( $classes ) ) );
127
+        return implode( ' ', $classes );
128 128
     }
129 129
 
130 130
     /**
@@ -132,10 +132,10 @@  discard block
 block discarded – undo
132 132
      */
133 133
     protected function getReviewsFallback()
134 134
     {
135
-        if (empty($this->args['fallback']) && glsr(OptionManager::class)->getBool('settings.reviews.fallback')) {
136
-            $this->args['fallback'] = __('There are no reviews yet. Be the first one to write one.', 'site-reviews');
135
+        if( empty($this->args['fallback']) && glsr( OptionManager::class )->getBool( 'settings.reviews.fallback' ) ) {
136
+            $this->args['fallback'] = __( 'There are no reviews yet. Be the first one to write one.', 'site-reviews' );
137 137
         }
138 138
         $fallback = '<p class="glsr-no-margins">'.$this->args['fallback'].'</p>';
139
-        return apply_filters('site-reviews/reviews/fallback', $fallback, $this->args);
139
+        return apply_filters( 'site-reviews/reviews/fallback', $fallback, $this->args );
140 140
     }
141 141
 }
Please login to merge, or discard this patch.
plugin/Modules/System.php 2 patches
Indentation   +346 added lines, -346 removed lines patch added patch discarded remove patch
@@ -10,371 +10,371 @@
 block discarded – undo
10 10
 
11 11
 class System
12 12
 {
13
-    const PAD = 40;
13
+	const PAD = 40;
14 14
 
15
-    /**
16
-     * @return string
17
-     */
18
-    public function __toString()
19
-    {
20
-        return $this->get();
21
-    }
15
+	/**
16
+	 * @return string
17
+	 */
18
+	public function __toString()
19
+	{
20
+		return $this->get();
21
+	}
22 22
 
23
-    /**
24
-     * @return string
25
-     */
26
-    public function get()
27
-    {
28
-        $details = [
29
-            'plugin' => 'Plugin Details',
30
-            'addon' => 'Addon Details',
31
-            'browser' => 'Browser Details',
32
-            'server' => 'Server Details',
33
-            'php' => 'PHP Configuration',
34
-            'wordpress' => 'WordPress Configuration',
35
-            'mu-plugin' => 'Must-Use Plugins',
36
-            'multisite-plugin' => 'Network Active Plugins',
37
-            'active-plugin' => 'Active Plugins',
38
-            'inactive-plugin' => 'Inactive Plugins',
39
-            'setting' => 'Plugin Settings',
40
-            'reviews' => 'Review Counts',
41
-        ];
42
-        $systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) {
43
-            $methodName = glsr(Helper::class)->buildMethodName('get-'.$key.'-details');
44
-            if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) {
45
-                return $carry.$this->implode(
46
-                    strtoupper($details[$key]),
47
-                    apply_filters('site-reviews/system/'.$key, $systemDetails)
48
-                );
49
-            }
50
-            return $carry;
51
-        });
52
-        return trim($systemInfo);
53
-    }
23
+	/**
24
+	 * @return string
25
+	 */
26
+	public function get()
27
+	{
28
+		$details = [
29
+			'plugin' => 'Plugin Details',
30
+			'addon' => 'Addon Details',
31
+			'browser' => 'Browser Details',
32
+			'server' => 'Server Details',
33
+			'php' => 'PHP Configuration',
34
+			'wordpress' => 'WordPress Configuration',
35
+			'mu-plugin' => 'Must-Use Plugins',
36
+			'multisite-plugin' => 'Network Active Plugins',
37
+			'active-plugin' => 'Active Plugins',
38
+			'inactive-plugin' => 'Inactive Plugins',
39
+			'setting' => 'Plugin Settings',
40
+			'reviews' => 'Review Counts',
41
+		];
42
+		$systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) {
43
+			$methodName = glsr(Helper::class)->buildMethodName('get-'.$key.'-details');
44
+			if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) {
45
+				return $carry.$this->implode(
46
+					strtoupper($details[$key]),
47
+					apply_filters('site-reviews/system/'.$key, $systemDetails)
48
+				);
49
+			}
50
+			return $carry;
51
+		});
52
+		return trim($systemInfo);
53
+	}
54 54
 
55
-    /**
56
-     * @return array
57
-     */
58
-    public function getActivePluginDetails()
59
-    {
60
-        $plugins = get_plugins();
61
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
62
-        $inactive = array_diff_key($plugins, array_flip($activePlugins));
63
-        return $this->normalizePluginList(array_diff_key($plugins, $inactive));
64
-    }
55
+	/**
56
+	 * @return array
57
+	 */
58
+	public function getActivePluginDetails()
59
+	{
60
+		$plugins = get_plugins();
61
+		$activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
62
+		$inactive = array_diff_key($plugins, array_flip($activePlugins));
63
+		return $this->normalizePluginList(array_diff_key($plugins, $inactive));
64
+	}
65 65
 
66
-    /**
67
-     * @return array
68
-     */
69
-    public function getAddonDetails()
70
-    {
71
-        $details = apply_filters('site-reviews/addon/system-info', []);
72
-        ksort($details);
73
-        return $details;
74
-    }
66
+	/**
67
+	 * @return array
68
+	 */
69
+	public function getAddonDetails()
70
+	{
71
+		$details = apply_filters('site-reviews/addon/system-info', []);
72
+		ksort($details);
73
+		return $details;
74
+	}
75 75
 
76
-    /**
77
-     * @return array
78
-     */
79
-    public function getBrowserDetails()
80
-    {
81
-        $browser = new Browser();
82
-        $name = esc_attr($browser->getName());
83
-        $userAgent = esc_attr($browser->getUserAgent()->getUserAgentString());
84
-        $version = esc_attr($browser->getVersion());
85
-        return [
86
-            'Browser Name' => sprintf('%s %s', $name, $version),
87
-            'Browser UA' => $userAgent,
88
-        ];
89
-    }
76
+	/**
77
+	 * @return array
78
+	 */
79
+	public function getBrowserDetails()
80
+	{
81
+		$browser = new Browser();
82
+		$name = esc_attr($browser->getName());
83
+		$userAgent = esc_attr($browser->getUserAgent()->getUserAgentString());
84
+		$version = esc_attr($browser->getVersion());
85
+		return [
86
+			'Browser Name' => sprintf('%s %s', $name, $version),
87
+			'Browser UA' => $userAgent,
88
+		];
89
+	}
90 90
 
91
-    /**
92
-     * @return array
93
-     */
94
-    public function getInactivePluginDetails()
95
-    {
96
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
97
-        $inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins)));
98
-        $multisitePlugins = $this->getMultisitePluginDetails();
99
-        return empty($multisitePlugins)
100
-            ? $inactivePlugins
101
-            : array_diff($inactivePlugins, $multisitePlugins);
102
-    }
91
+	/**
92
+	 * @return array
93
+	 */
94
+	public function getInactivePluginDetails()
95
+	{
96
+		$activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
97
+		$inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins)));
98
+		$multisitePlugins = $this->getMultisitePluginDetails();
99
+		return empty($multisitePlugins)
100
+			? $inactivePlugins
101
+			: array_diff($inactivePlugins, $multisitePlugins);
102
+	}
103 103
 
104
-    /**
105
-     * @return array
106
-     */
107
-    public function getMuPluginDetails()
108
-    {
109
-        if (empty($plugins = get_mu_plugins())) {
110
-            return [];
111
-        }
112
-        return $this->normalizePluginList($plugins);
113
-    }
104
+	/**
105
+	 * @return array
106
+	 */
107
+	public function getMuPluginDetails()
108
+	{
109
+		if (empty($plugins = get_mu_plugins())) {
110
+			return [];
111
+		}
112
+		return $this->normalizePluginList($plugins);
113
+	}
114 114
 
115
-    /**
116
-     * @return array
117
-     */
118
-    public function getMultisitePluginDetails()
119
-    {
120
-        $activePlugins = (array) get_site_option('active_sitewide_plugins', []);
121
-        if (!is_multisite() || empty($activePlugins)) {
122
-            return [];
123
-        }
124
-        return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins));
125
-    }
115
+	/**
116
+	 * @return array
117
+	 */
118
+	public function getMultisitePluginDetails()
119
+	{
120
+		$activePlugins = (array) get_site_option('active_sitewide_plugins', []);
121
+		if (!is_multisite() || empty($activePlugins)) {
122
+			return [];
123
+		}
124
+		return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins));
125
+	}
126 126
 
127
-    /**
128
-     * @return array
129
-     */
130
-    public function getPhpDetails()
131
-    {
132
-        $displayErrors = ini_get('display_errors')
133
-            ? 'On ('.ini_get('display_errors').')'
134
-            : 'N/A';
135
-        $intlSupport = extension_loaded('intl')
136
-            ? phpversion('intl')
137
-            : 'false';
138
-        return [
139
-            'cURL' => var_export(function_exists('curl_init'), true),
140
-            'Default Charset' => ini_get('default_charset'),
141
-            'Display Errors' => $displayErrors,
142
-            'fsockopen' => var_export(function_exists('fsockopen'), true),
143
-            'Intl' => $intlSupport,
144
-            'IPv6' => var_export(defined('AF_INET6'), true),
145
-            'Max Execution Time' => ini_get('max_execution_time'),
146
-            'Max Input Nesting Level' => ini_get('max_input_nesting_level'),
147
-            'Max Input Vars' => ini_get('max_input_vars'),
148
-            'Memory Limit' => ini_get('memory_limit'),
149
-            'Post Max Size' => ini_get('post_max_size'),
150
-            'Sendmail Path' => ini_get('sendmail_path'),
151
-            'Session Cookie Path' => esc_html(ini_get('session.cookie_path')),
152
-            'Session Name' => esc_html(ini_get('session.name')),
153
-            'Session Save Path' => esc_html(ini_get('session.save_path')),
154
-            'Session Use Cookies' => var_export(wp_validate_boolean(ini_get('session.use_cookies')), true),
155
-            'Session Use Only Cookies' => var_export(wp_validate_boolean(ini_get('session.use_only_cookies')), true),
156
-            'Upload Max Filesize' => ini_get('upload_max_filesize'),
157
-        ];
158
-    }
127
+	/**
128
+	 * @return array
129
+	 */
130
+	public function getPhpDetails()
131
+	{
132
+		$displayErrors = ini_get('display_errors')
133
+			? 'On ('.ini_get('display_errors').')'
134
+			: 'N/A';
135
+		$intlSupport = extension_loaded('intl')
136
+			? phpversion('intl')
137
+			: 'false';
138
+		return [
139
+			'cURL' => var_export(function_exists('curl_init'), true),
140
+			'Default Charset' => ini_get('default_charset'),
141
+			'Display Errors' => $displayErrors,
142
+			'fsockopen' => var_export(function_exists('fsockopen'), true),
143
+			'Intl' => $intlSupport,
144
+			'IPv6' => var_export(defined('AF_INET6'), true),
145
+			'Max Execution Time' => ini_get('max_execution_time'),
146
+			'Max Input Nesting Level' => ini_get('max_input_nesting_level'),
147
+			'Max Input Vars' => ini_get('max_input_vars'),
148
+			'Memory Limit' => ini_get('memory_limit'),
149
+			'Post Max Size' => ini_get('post_max_size'),
150
+			'Sendmail Path' => ini_get('sendmail_path'),
151
+			'Session Cookie Path' => esc_html(ini_get('session.cookie_path')),
152
+			'Session Name' => esc_html(ini_get('session.name')),
153
+			'Session Save Path' => esc_html(ini_get('session.save_path')),
154
+			'Session Use Cookies' => var_export(wp_validate_boolean(ini_get('session.use_cookies')), true),
155
+			'Session Use Only Cookies' => var_export(wp_validate_boolean(ini_get('session.use_only_cookies')), true),
156
+			'Upload Max Filesize' => ini_get('upload_max_filesize'),
157
+		];
158
+	}
159 159
 
160
-    /**
161
-     * @return array
162
-     */
163
-    public function getReviewsDetails()
164
-    {
165
-        $counts = glsr(CountsManager::class)->getCounts();
166
-        $counts = glsr(Helper::class)->flattenArray($counts);
167
-        array_walk($counts, function (&$ratings) use ($counts) {
168
-            if (!is_array($ratings)) {
169
-                glsr_log()
170
-                    ->error('$ratings is not an array, possibly due to incorrectly imported reviews.')
171
-                    ->debug($ratings)
172
-                    ->debug($counts);
173
-                return;
174
-            }
175
-            $ratings = array_sum($ratings).' ('.implode(', ', $ratings).')';
176
-        });
177
-        ksort($counts);
178
-        return $counts;
179
-    }
160
+	/**
161
+	 * @return array
162
+	 */
163
+	public function getReviewsDetails()
164
+	{
165
+		$counts = glsr(CountsManager::class)->getCounts();
166
+		$counts = glsr(Helper::class)->flattenArray($counts);
167
+		array_walk($counts, function (&$ratings) use ($counts) {
168
+			if (!is_array($ratings)) {
169
+				glsr_log()
170
+					->error('$ratings is not an array, possibly due to incorrectly imported reviews.')
171
+					->debug($ratings)
172
+					->debug($counts);
173
+				return;
174
+			}
175
+			$ratings = array_sum($ratings).' ('.implode(', ', $ratings).')';
176
+		});
177
+		ksort($counts);
178
+		return $counts;
179
+	}
180 180
 
181
-    /**
182
-     * @return array
183
-     */
184
-    public function getServerDetails()
185
-    {
186
-        global $wpdb;
187
-        return [
188
-            'Host Name' => $this->getHostName(),
189
-            'MySQL Version' => $wpdb->db_version(),
190
-            'PHP Version' => PHP_VERSION,
191
-            'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'),
192
-        ];
193
-    }
181
+	/**
182
+	 * @return array
183
+	 */
184
+	public function getServerDetails()
185
+	{
186
+		global $wpdb;
187
+		return [
188
+			'Host Name' => $this->getHostName(),
189
+			'MySQL Version' => $wpdb->db_version(),
190
+			'PHP Version' => PHP_VERSION,
191
+			'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'),
192
+		];
193
+	}
194 194
 
195
-    /**
196
-     * @return array
197
-     */
198
-    public function getSettingDetails()
199
-    {
200
-        $helper = glsr(Helper::class);
201
-        $settings = glsr(OptionManager::class)->get('settings', []);
202
-        $settings = $helper->flattenArray($settings, true);
203
-        $settings = $this->purgeSensitiveData($settings);
204
-        ksort($settings);
205
-        $details = [];
206
-        foreach ($settings as $key => $value) {
207
-            if ($helper->startsWith('strings', $key) && $helper->endsWith('id', $key)) {
208
-                continue;
209
-            }
210
-            $value = htmlspecialchars(trim(preg_replace('/\s\s+/', '\\n', $value)), ENT_QUOTES, 'UTF-8');
211
-            $details[$key] = $value;
212
-        }
213
-        return $details;
214
-    }
195
+	/**
196
+	 * @return array
197
+	 */
198
+	public function getSettingDetails()
199
+	{
200
+		$helper = glsr(Helper::class);
201
+		$settings = glsr(OptionManager::class)->get('settings', []);
202
+		$settings = $helper->flattenArray($settings, true);
203
+		$settings = $this->purgeSensitiveData($settings);
204
+		ksort($settings);
205
+		$details = [];
206
+		foreach ($settings as $key => $value) {
207
+			if ($helper->startsWith('strings', $key) && $helper->endsWith('id', $key)) {
208
+				continue;
209
+			}
210
+			$value = htmlspecialchars(trim(preg_replace('/\s\s+/', '\\n', $value)), ENT_QUOTES, 'UTF-8');
211
+			$details[$key] = $value;
212
+		}
213
+		return $details;
214
+	}
215 215
 
216
-    /**
217
-     * @return array
218
-     */
219
-    public function getPluginDetails()
220
-    {
221
-        return [
222
-            'Console level' => glsr(Console::class)->humanLevel(),
223
-            'Console size' => glsr(Console::class)->humanSize('0'),
224
-            'Last Rating Count' => date_i18n('Y-m-d H:i', glsr(OptionManager::class)->get('last_review_count')),
225
-            'Version (current)' => glsr()->version,
226
-            'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'),
227
-        ];
228
-    }
216
+	/**
217
+	 * @return array
218
+	 */
219
+	public function getPluginDetails()
220
+	{
221
+		return [
222
+			'Console level' => glsr(Console::class)->humanLevel(),
223
+			'Console size' => glsr(Console::class)->humanSize('0'),
224
+			'Last Rating Count' => date_i18n('Y-m-d H:i', glsr(OptionManager::class)->get('last_review_count')),
225
+			'Version (current)' => glsr()->version,
226
+			'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'),
227
+		];
228
+	}
229 229
 
230
-    /**
231
-     * @return array
232
-     */
233
-    public function getWordpressDetails()
234
-    {
235
-        global $wpdb;
236
-        $theme = wp_get_theme();
237
-        return [
238
-            'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version),
239
-            'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1),
240
-            'Home URL' => home_url(),
241
-            'Language' => get_locale(),
242
-            'Memory Limit' => WP_MEMORY_LIMIT,
243
-            'Multisite' => var_export(is_multisite(), true),
244
-            'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'),
245
-            'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'),
246
-            'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'),
247
-            'Post Stati' => implode(', ', get_post_stati()),
248
-            'Remote Post' => glsr(Cache::class)->getRemotePostTest(),
249
-            'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'),
250
-            'Site URL' => site_url(),
251
-            'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', ini_get('date.timezone').' (PHP)'),
252
-            'Version' => get_bloginfo('version'),
253
-            'WP Debug' => var_export(defined('WP_DEBUG'), true),
254
-            'WP Max Upload Size' => size_format(wp_max_upload_size()),
255
-            'WP Memory Limit' => WP_MEMORY_LIMIT,
256
-        ];
257
-    }
230
+	/**
231
+	 * @return array
232
+	 */
233
+	public function getWordpressDetails()
234
+	{
235
+		global $wpdb;
236
+		$theme = wp_get_theme();
237
+		return [
238
+			'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version),
239
+			'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1),
240
+			'Home URL' => home_url(),
241
+			'Language' => get_locale(),
242
+			'Memory Limit' => WP_MEMORY_LIMIT,
243
+			'Multisite' => var_export(is_multisite(), true),
244
+			'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'),
245
+			'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'),
246
+			'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'),
247
+			'Post Stati' => implode(', ', get_post_stati()),
248
+			'Remote Post' => glsr(Cache::class)->getRemotePostTest(),
249
+			'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'),
250
+			'Site URL' => site_url(),
251
+			'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', ini_get('date.timezone').' (PHP)'),
252
+			'Version' => get_bloginfo('version'),
253
+			'WP Debug' => var_export(defined('WP_DEBUG'), true),
254
+			'WP Max Upload Size' => size_format(wp_max_upload_size()),
255
+			'WP Memory Limit' => WP_MEMORY_LIMIT,
256
+		];
257
+	}
258 258
 
259
-    /**
260
-     * @return string
261
-     */
262
-    protected function detectWebhostProvider()
263
-    {
264
-        $checks = [
265
-            '.accountservergroup.com' => 'Site5',
266
-            '.gridserver.com' => 'MediaTemple Grid',
267
-            '.inmotionhosting.com' => 'InMotion Hosting',
268
-            '.ovh.net' => 'OVH',
269
-            '.pair.com' => 'pair Networks',
270
-            '.stabletransit.com' => 'Rackspace Cloud',
271
-            '.stratoserver.net' => 'STRATO',
272
-            '.sysfix.eu' => 'SysFix.eu Power Hosting',
273
-            'bluehost.com' => 'Bluehost',
274
-            'DH_USER' => 'DreamHost',
275
-            'Flywheel' => 'Flywheel',
276
-            'ipagemysql.com' => 'iPage',
277
-            'ipowermysql.com' => 'IPower',
278
-            'localhost:/tmp/mysql5.sock' => 'ICDSoft',
279
-            'mysqlv5' => 'NetworkSolutions',
280
-            'PAGELYBIN' => 'Pagely',
281
-            'secureserver.net' => 'GoDaddy',
282
-            'WPE_APIKEY' => 'WP Engine',
283
-        ];
284
-        foreach ($checks as $key => $value) {
285
-            if (!$this->isWebhostCheckValid($key)) {
286
-                continue;
287
-            }
288
-            return $value;
289
-        }
290
-        return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')]));
291
-    }
259
+	/**
260
+	 * @return string
261
+	 */
262
+	protected function detectWebhostProvider()
263
+	{
264
+		$checks = [
265
+			'.accountservergroup.com' => 'Site5',
266
+			'.gridserver.com' => 'MediaTemple Grid',
267
+			'.inmotionhosting.com' => 'InMotion Hosting',
268
+			'.ovh.net' => 'OVH',
269
+			'.pair.com' => 'pair Networks',
270
+			'.stabletransit.com' => 'Rackspace Cloud',
271
+			'.stratoserver.net' => 'STRATO',
272
+			'.sysfix.eu' => 'SysFix.eu Power Hosting',
273
+			'bluehost.com' => 'Bluehost',
274
+			'DH_USER' => 'DreamHost',
275
+			'Flywheel' => 'Flywheel',
276
+			'ipagemysql.com' => 'iPage',
277
+			'ipowermysql.com' => 'IPower',
278
+			'localhost:/tmp/mysql5.sock' => 'ICDSoft',
279
+			'mysqlv5' => 'NetworkSolutions',
280
+			'PAGELYBIN' => 'Pagely',
281
+			'secureserver.net' => 'GoDaddy',
282
+			'WPE_APIKEY' => 'WP Engine',
283
+		];
284
+		foreach ($checks as $key => $value) {
285
+			if (!$this->isWebhostCheckValid($key)) {
286
+				continue;
287
+			}
288
+			return $value;
289
+		}
290
+		return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')]));
291
+	}
292 292
 
293
-    /**
294
-     * @return string
295
-     */
296
-    protected function getHostName()
297
-    {
298
-        return sprintf('%s (%s)',
299
-            $this->detectWebhostProvider(),
300
-            glsr(Helper::class)->getIpAddress()
301
-        );
302
-    }
293
+	/**
294
+	 * @return string
295
+	 */
296
+	protected function getHostName()
297
+	{
298
+		return sprintf('%s (%s)',
299
+			$this->detectWebhostProvider(),
300
+			glsr(Helper::class)->getIpAddress()
301
+		);
302
+	}
303 303
 
304
-    /**
305
-     * @return array
306
-     */
307
-    protected function getWordpressPlugins()
308
-    {
309
-        $plugins = get_plugins();
310
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
311
-        $inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins)));
312
-        $active = $this->normalizePluginList(array_diff_key($plugins, $inactive));
313
-        return $active + $inactive;
314
-    }
304
+	/**
305
+	 * @return array
306
+	 */
307
+	protected function getWordpressPlugins()
308
+	{
309
+		$plugins = get_plugins();
310
+		$activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
311
+		$inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins)));
312
+		$active = $this->normalizePluginList(array_diff_key($plugins, $inactive));
313
+		return $active + $inactive;
314
+	}
315 315
 
316
-    /**
317
-     * @param string $title
318
-     * @return string
319
-     */
320
-    protected function implode($title, array $details)
321
-    {
322
-        $strings = ['['.$title.']'];
323
-        $padding = max(array_map('strlen', array_keys($details)));
324
-        $padding = max([$padding, static::PAD]);
325
-        foreach ($details as $key => $value) {
326
-            $strings[] = is_string($key)
327
-                ? sprintf('%s : %s', str_pad($key, $padding, '.'), $value)
328
-                : ' - '.$value;
329
-        }
330
-        return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL;
331
-    }
316
+	/**
317
+	 * @param string $title
318
+	 * @return string
319
+	 */
320
+	protected function implode($title, array $details)
321
+	{
322
+		$strings = ['['.$title.']'];
323
+		$padding = max(array_map('strlen', array_keys($details)));
324
+		$padding = max([$padding, static::PAD]);
325
+		foreach ($details as $key => $value) {
326
+			$strings[] = is_string($key)
327
+				? sprintf('%s : %s', str_pad($key, $padding, '.'), $value)
328
+				: ' - '.$value;
329
+		}
330
+		return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL;
331
+	}
332 332
 
333
-    /**
334
-     * @param string $key
335
-     * @return bool
336
-     */
337
-    protected function isWebhostCheckValid($key)
338
-    {
339
-        return defined($key)
340
-            || filter_input(INPUT_SERVER, $key)
341
-            || false !== strpos(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key)
342
-            || false !== strpos(DB_HOST, $key)
343
-            || false !== strpos(php_uname(), $key);
344
-    }
333
+	/**
334
+	 * @param string $key
335
+	 * @return bool
336
+	 */
337
+	protected function isWebhostCheckValid($key)
338
+	{
339
+		return defined($key)
340
+			|| filter_input(INPUT_SERVER, $key)
341
+			|| false !== strpos(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key)
342
+			|| false !== strpos(DB_HOST, $key)
343
+			|| false !== strpos(php_uname(), $key);
344
+	}
345 345
 
346
-    /**
347
-     * @return array
348
-     */
349
-    protected function normalizePluginList(array $plugins)
350
-    {
351
-        $plugins = array_map(function ($plugin) {
352
-            return sprintf('%s v%s', glsr_get($plugin, 'Name'), glsr_get($plugin, 'Version'));
353
-        }, $plugins);
354
-        natcasesort($plugins);
355
-        return array_flip($plugins);
356
-    }
346
+	/**
347
+	 * @return array
348
+	 */
349
+	protected function normalizePluginList(array $plugins)
350
+	{
351
+		$plugins = array_map(function ($plugin) {
352
+			return sprintf('%s v%s', glsr_get($plugin, 'Name'), glsr_get($plugin, 'Version'));
353
+		}, $plugins);
354
+		natcasesort($plugins);
355
+		return array_flip($plugins);
356
+	}
357 357
 
358
-    /**
359
-     * @return array
360
-     */
361
-    protected function purgeSensitiveData(array $settings)
362
-    {
363
-        $keys = [
364
-            'general.rebusify_serial',
365
-            'licenses.',
366
-            'submissions.recaptcha.key',
367
-            'submissions.recaptcha.secret',
368
-        ];
369
-        array_walk($settings, function (&$value, $setting) use ($keys) {
370
-            foreach ($keys as $key) {
371
-                if (!glsr(Helper::class)->startsWith($key, $setting) || empty($value)) {
372
-                    continue;
373
-                }
374
-                $value = str_repeat('•', 13);
375
-                return;
376
-            }
377
-        });
378
-        return $settings;
379
-    }
358
+	/**
359
+	 * @return array
360
+	 */
361
+	protected function purgeSensitiveData(array $settings)
362
+	{
363
+		$keys = [
364
+			'general.rebusify_serial',
365
+			'licenses.',
366
+			'submissions.recaptcha.key',
367
+			'submissions.recaptcha.secret',
368
+		];
369
+		array_walk($settings, function (&$value, $setting) use ($keys) {
370
+			foreach ($keys as $key) {
371
+				if (!glsr(Helper::class)->startsWith($key, $setting) || empty($value)) {
372
+					continue;
373
+				}
374
+				$value = str_repeat('•', 13);
375
+				return;
376
+			}
377
+		});
378
+		return $settings;
379
+	}
380 380
 }
Please login to merge, or discard this patch.
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -39,17 +39,17 @@  discard block
 block discarded – undo
39 39
             'setting' => 'Plugin Settings',
40 40
             'reviews' => 'Review Counts',
41 41
         ];
42
-        $systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) {
43
-            $methodName = glsr(Helper::class)->buildMethodName('get-'.$key.'-details');
44
-            if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) {
42
+        $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use ($details) {
43
+            $methodName = glsr( Helper::class )->buildMethodName( 'get-'.$key.'-details' );
44
+            if( method_exists( $this, $methodName ) && $systemDetails = $this->$methodName() ) {
45 45
                 return $carry.$this->implode(
46
-                    strtoupper($details[$key]),
47
-                    apply_filters('site-reviews/system/'.$key, $systemDetails)
46
+                    strtoupper( $details[$key] ),
47
+                    apply_filters( 'site-reviews/system/'.$key, $systemDetails )
48 48
                 );
49 49
             }
50 50
             return $carry;
51 51
         });
52
-        return trim($systemInfo);
52
+        return trim( $systemInfo );
53 53
     }
54 54
 
55 55
     /**
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
     public function getActivePluginDetails()
59 59
     {
60 60
         $plugins = get_plugins();
61
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
62
-        $inactive = array_diff_key($plugins, array_flip($activePlugins));
63
-        return $this->normalizePluginList(array_diff_key($plugins, $inactive));
61
+        $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' );
62
+        $inactive = array_diff_key( $plugins, array_flip( $activePlugins ) );
63
+        return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) );
64 64
     }
65 65
 
66 66
     /**
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public function getAddonDetails()
70 70
     {
71
-        $details = apply_filters('site-reviews/addon/system-info', []);
72
-        ksort($details);
71
+        $details = apply_filters( 'site-reviews/addon/system-info', [] );
72
+        ksort( $details );
73 73
         return $details;
74 74
     }
75 75
 
@@ -79,11 +79,11 @@  discard block
 block discarded – undo
79 79
     public function getBrowserDetails()
80 80
     {
81 81
         $browser = new Browser();
82
-        $name = esc_attr($browser->getName());
83
-        $userAgent = esc_attr($browser->getUserAgent()->getUserAgentString());
84
-        $version = esc_attr($browser->getVersion());
82
+        $name = esc_attr( $browser->getName() );
83
+        $userAgent = esc_attr( $browser->getUserAgent()->getUserAgentString() );
84
+        $version = esc_attr( $browser->getVersion() );
85 85
         return [
86
-            'Browser Name' => sprintf('%s %s', $name, $version),
86
+            'Browser Name' => sprintf( '%s %s', $name, $version ),
87 87
             'Browser UA' => $userAgent,
88 88
         ];
89 89
     }
@@ -93,12 +93,12 @@  discard block
 block discarded – undo
93 93
      */
94 94
     public function getInactivePluginDetails()
95 95
     {
96
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
97
-        $inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins)));
96
+        $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' );
97
+        $inactivePlugins = $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) );
98 98
         $multisitePlugins = $this->getMultisitePluginDetails();
99 99
         return empty($multisitePlugins)
100 100
             ? $inactivePlugins
101
-            : array_diff($inactivePlugins, $multisitePlugins);
101
+            : array_diff( $inactivePlugins, $multisitePlugins );
102 102
     }
103 103
 
104 104
     /**
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
      */
107 107
     public function getMuPluginDetails()
108 108
     {
109
-        if (empty($plugins = get_mu_plugins())) {
109
+        if( empty($plugins = get_mu_plugins()) ) {
110 110
             return [];
111 111
         }
112
-        return $this->normalizePluginList($plugins);
112
+        return $this->normalizePluginList( $plugins );
113 113
     }
114 114
 
115 115
     /**
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
      */
118 118
     public function getMultisitePluginDetails()
119 119
     {
120
-        $activePlugins = (array) get_site_option('active_sitewide_plugins', []);
121
-        if (!is_multisite() || empty($activePlugins)) {
120
+        $activePlugins = (array)get_site_option( 'active_sitewide_plugins', [] );
121
+        if( !is_multisite() || empty($activePlugins) ) {
122 122
             return [];
123 123
         }
124
-        return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins));
124
+        return $this->normalizePluginList( array_intersect_key( get_plugins(), $activePlugins ) );
125 125
     }
126 126
 
127 127
     /**
@@ -129,31 +129,31 @@  discard block
 block discarded – undo
129 129
      */
130 130
     public function getPhpDetails()
131 131
     {
132
-        $displayErrors = ini_get('display_errors')
133
-            ? 'On ('.ini_get('display_errors').')'
132
+        $displayErrors = ini_get( 'display_errors' )
133
+            ? 'On ('.ini_get( 'display_errors' ).')'
134 134
             : 'N/A';
135
-        $intlSupport = extension_loaded('intl')
136
-            ? phpversion('intl')
135
+        $intlSupport = extension_loaded( 'intl' )
136
+            ? phpversion( 'intl' )
137 137
             : 'false';
138 138
         return [
139
-            'cURL' => var_export(function_exists('curl_init'), true),
140
-            'Default Charset' => ini_get('default_charset'),
139
+            'cURL' => var_export( function_exists( 'curl_init' ), true ),
140
+            'Default Charset' => ini_get( 'default_charset' ),
141 141
             'Display Errors' => $displayErrors,
142
-            'fsockopen' => var_export(function_exists('fsockopen'), true),
142
+            'fsockopen' => var_export( function_exists( 'fsockopen' ), true ),
143 143
             'Intl' => $intlSupport,
144
-            'IPv6' => var_export(defined('AF_INET6'), true),
145
-            'Max Execution Time' => ini_get('max_execution_time'),
146
-            'Max Input Nesting Level' => ini_get('max_input_nesting_level'),
147
-            'Max Input Vars' => ini_get('max_input_vars'),
148
-            'Memory Limit' => ini_get('memory_limit'),
149
-            'Post Max Size' => ini_get('post_max_size'),
150
-            'Sendmail Path' => ini_get('sendmail_path'),
151
-            'Session Cookie Path' => esc_html(ini_get('session.cookie_path')),
152
-            'Session Name' => esc_html(ini_get('session.name')),
153
-            'Session Save Path' => esc_html(ini_get('session.save_path')),
154
-            'Session Use Cookies' => var_export(wp_validate_boolean(ini_get('session.use_cookies')), true),
155
-            'Session Use Only Cookies' => var_export(wp_validate_boolean(ini_get('session.use_only_cookies')), true),
156
-            'Upload Max Filesize' => ini_get('upload_max_filesize'),
144
+            'IPv6' => var_export( defined( 'AF_INET6' ), true ),
145
+            'Max Execution Time' => ini_get( 'max_execution_time' ),
146
+            'Max Input Nesting Level' => ini_get( 'max_input_nesting_level' ),
147
+            'Max Input Vars' => ini_get( 'max_input_vars' ),
148
+            'Memory Limit' => ini_get( 'memory_limit' ),
149
+            'Post Max Size' => ini_get( 'post_max_size' ),
150
+            'Sendmail Path' => ini_get( 'sendmail_path' ),
151
+            'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' ) ),
152
+            'Session Name' => esc_html( ini_get( 'session.name' ) ),
153
+            'Session Save Path' => esc_html( ini_get( 'session.save_path' ) ),
154
+            'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' ) ), true ),
155
+            'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' ) ), true ),
156
+            'Upload Max Filesize' => ini_get( 'upload_max_filesize' ),
157 157
         ];
158 158
     }
159 159
 
@@ -162,19 +162,19 @@  discard block
 block discarded – undo
162 162
      */
163 163
     public function getReviewsDetails()
164 164
     {
165
-        $counts = glsr(CountsManager::class)->getCounts();
166
-        $counts = glsr(Helper::class)->flattenArray($counts);
167
-        array_walk($counts, function (&$ratings) use ($counts) {
168
-            if (!is_array($ratings)) {
165
+        $counts = glsr( CountsManager::class )->getCounts();
166
+        $counts = glsr( Helper::class )->flattenArray( $counts );
167
+        array_walk( $counts, function( &$ratings ) use ($counts) {
168
+            if( !is_array( $ratings ) ) {
169 169
                 glsr_log()
170
-                    ->error('$ratings is not an array, possibly due to incorrectly imported reviews.')
171
-                    ->debug($ratings)
172
-                    ->debug($counts);
170
+                    ->error( '$ratings is not an array, possibly due to incorrectly imported reviews.' )
171
+                    ->debug( $ratings )
172
+                    ->debug( $counts );
173 173
                 return;
174 174
             }
175
-            $ratings = array_sum($ratings).' ('.implode(', ', $ratings).')';
175
+            $ratings = array_sum( $ratings ).' ('.implode( ', ', $ratings ).')';
176 176
         });
177
-        ksort($counts);
177
+        ksort( $counts );
178 178
         return $counts;
179 179
     }
180 180
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
             'Host Name' => $this->getHostName(),
189 189
             'MySQL Version' => $wpdb->db_version(),
190 190
             'PHP Version' => PHP_VERSION,
191
-            'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'),
191
+            'Server Software' => filter_input( INPUT_SERVER, 'SERVER_SOFTWARE' ),
192 192
         ];
193 193
     }
194 194
 
@@ -197,17 +197,17 @@  discard block
 block discarded – undo
197 197
      */
198 198
     public function getSettingDetails()
199 199
     {
200
-        $helper = glsr(Helper::class);
201
-        $settings = glsr(OptionManager::class)->get('settings', []);
202
-        $settings = $helper->flattenArray($settings, true);
203
-        $settings = $this->purgeSensitiveData($settings);
204
-        ksort($settings);
200
+        $helper = glsr( Helper::class );
201
+        $settings = glsr( OptionManager::class )->get( 'settings', [] );
202
+        $settings = $helper->flattenArray( $settings, true );
203
+        $settings = $this->purgeSensitiveData( $settings );
204
+        ksort( $settings );
205 205
         $details = [];
206
-        foreach ($settings as $key => $value) {
207
-            if ($helper->startsWith('strings', $key) && $helper->endsWith('id', $key)) {
206
+        foreach( $settings as $key => $value ) {
207
+            if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ) ) {
208 208
                 continue;
209 209
             }
210
-            $value = htmlspecialchars(trim(preg_replace('/\s\s+/', '\\n', $value)), ENT_QUOTES, 'UTF-8');
210
+            $value = htmlspecialchars( trim( preg_replace( '/\s\s+/', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' );
211 211
             $details[$key] = $value;
212 212
         }
213 213
         return $details;
@@ -219,11 +219,11 @@  discard block
 block discarded – undo
219 219
     public function getPluginDetails()
220 220
     {
221 221
         return [
222
-            'Console level' => glsr(Console::class)->humanLevel(),
223
-            'Console size' => glsr(Console::class)->humanSize('0'),
224
-            'Last Rating Count' => date_i18n('Y-m-d H:i', glsr(OptionManager::class)->get('last_review_count')),
222
+            'Console level' => glsr( Console::class )->humanLevel(),
223
+            'Console size' => glsr( Console::class )->humanSize( '0' ),
224
+            'Last Rating Count' => date_i18n( 'Y-m-d H:i', glsr( OptionManager::class )->get( 'last_review_count' ) ),
225 225
             'Version (current)' => glsr()->version,
226
-            'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'),
226
+            'Version (previous)' => glsr( OptionManager::class )->get( 'version_upgraded_from' ),
227 227
         ];
228 228
     }
229 229
 
@@ -235,23 +235,23 @@  discard block
 block discarded – undo
235 235
         global $wpdb;
236 236
         $theme = wp_get_theme();
237 237
         return [
238
-            'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version),
239
-            'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1),
238
+            'Active Theme' => sprintf( '%s v%s', (string)$theme->Name, (string)$theme->Version ),
239
+            'Email Domain' => substr( strrchr( glsr( OptionManager::class )->getWP( 'admin_email' ), '@' ), 1 ),
240 240
             'Home URL' => home_url(),
241 241
             'Language' => get_locale(),
242 242
             'Memory Limit' => WP_MEMORY_LIMIT,
243
-            'Multisite' => var_export(is_multisite(), true),
244
-            'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'),
245
-            'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'),
246
-            'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'),
247
-            'Post Stati' => implode(', ', get_post_stati()),
248
-            'Remote Post' => glsr(Cache::class)->getRemotePostTest(),
249
-            'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'),
243
+            'Multisite' => var_export( is_multisite(), true ),
244
+            'Page For Posts ID' => glsr( OptionManager::class )->getWP( 'page_for_posts' ),
245
+            'Page On Front ID' => glsr( OptionManager::class )->getWP( 'page_on_front' ),
246
+            'Permalink Structure' => glsr( OptionManager::class )->getWP( 'permalink_structure', 'default' ),
247
+            'Post Stati' => implode( ', ', get_post_stati() ),
248
+            'Remote Post' => glsr( Cache::class )->getRemotePostTest(),
249
+            'Show On Front' => glsr( OptionManager::class )->getWP( 'show_on_front' ),
250 250
             'Site URL' => site_url(),
251
-            'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', ini_get('date.timezone').' (PHP)'),
252
-            'Version' => get_bloginfo('version'),
253
-            'WP Debug' => var_export(defined('WP_DEBUG'), true),
254
-            'WP Max Upload Size' => size_format(wp_max_upload_size()),
251
+            'Timezone' => glsr( OptionManager::class )->getWP( 'timezone_string', ini_get( 'date.timezone' ).' (PHP)' ),
252
+            'Version' => get_bloginfo( 'version' ),
253
+            'WP Debug' => var_export( defined( 'WP_DEBUG' ), true ),
254
+            'WP Max Upload Size' => size_format( wp_max_upload_size() ),
255 255
             'WP Memory Limit' => WP_MEMORY_LIMIT,
256 256
         ];
257 257
     }
@@ -281,13 +281,13 @@  discard block
 block discarded – undo
281 281
             'secureserver.net' => 'GoDaddy',
282 282
             'WPE_APIKEY' => 'WP Engine',
283 283
         ];
284
-        foreach ($checks as $key => $value) {
285
-            if (!$this->isWebhostCheckValid($key)) {
284
+        foreach( $checks as $key => $value ) {
285
+            if( !$this->isWebhostCheckValid( $key ) ) {
286 286
                 continue;
287 287
             }
288 288
             return $value;
289 289
         }
290
-        return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')]));
290
+        return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ) );
291 291
     }
292 292
 
293 293
     /**
@@ -295,9 +295,9 @@  discard block
 block discarded – undo
295 295
      */
296 296
     protected function getHostName()
297 297
     {
298
-        return sprintf('%s (%s)',
298
+        return sprintf( '%s (%s)',
299 299
             $this->detectWebhostProvider(),
300
-            glsr(Helper::class)->getIpAddress()
300
+            glsr( Helper::class )->getIpAddress()
301 301
         );
302 302
     }
303 303
 
@@ -307,9 +307,9 @@  discard block
 block discarded – undo
307 307
     protected function getWordpressPlugins()
308 308
     {
309 309
         $plugins = get_plugins();
310
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
311
-        $inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins)));
312
-        $active = $this->normalizePluginList(array_diff_key($plugins, $inactive));
310
+        $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' );
311
+        $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) );
312
+        $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) );
313 313
         return $active + $inactive;
314 314
     }
315 315
 
@@ -317,48 +317,48 @@  discard block
 block discarded – undo
317 317
      * @param string $title
318 318
      * @return string
319 319
      */
320
-    protected function implode($title, array $details)
320
+    protected function implode( $title, array $details )
321 321
     {
322 322
         $strings = ['['.$title.']'];
323
-        $padding = max(array_map('strlen', array_keys($details)));
324
-        $padding = max([$padding, static::PAD]);
325
-        foreach ($details as $key => $value) {
326
-            $strings[] = is_string($key)
327
-                ? sprintf('%s : %s', str_pad($key, $padding, '.'), $value)
323
+        $padding = max( array_map( 'strlen', array_keys( $details ) ) );
324
+        $padding = max( [$padding, static::PAD] );
325
+        foreach( $details as $key => $value ) {
326
+            $strings[] = is_string( $key )
327
+                ? sprintf( '%s : %s', str_pad( $key, $padding, '.' ), $value )
328 328
                 : ' - '.$value;
329 329
         }
330
-        return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL;
330
+        return implode( PHP_EOL, $strings ).PHP_EOL.PHP_EOL;
331 331
     }
332 332
 
333 333
     /**
334 334
      * @param string $key
335 335
      * @return bool
336 336
      */
337
-    protected function isWebhostCheckValid($key)
337
+    protected function isWebhostCheckValid( $key )
338 338
     {
339
-        return defined($key)
340
-            || filter_input(INPUT_SERVER, $key)
341
-            || false !== strpos(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key)
342
-            || false !== strpos(DB_HOST, $key)
343
-            || false !== strpos(php_uname(), $key);
339
+        return defined( $key )
340
+            || filter_input( INPUT_SERVER, $key )
341
+            || false !== strpos( filter_input( INPUT_SERVER, 'SERVER_NAME' ), $key )
342
+            || false !== strpos( DB_HOST, $key )
343
+            || false !== strpos( php_uname(), $key );
344 344
     }
345 345
 
346 346
     /**
347 347
      * @return array
348 348
      */
349
-    protected function normalizePluginList(array $plugins)
349
+    protected function normalizePluginList( array $plugins )
350 350
     {
351
-        $plugins = array_map(function ($plugin) {
352
-            return sprintf('%s v%s', glsr_get($plugin, 'Name'), glsr_get($plugin, 'Version'));
353
-        }, $plugins);
354
-        natcasesort($plugins);
355
-        return array_flip($plugins);
351
+        $plugins = array_map( function( $plugin ) {
352
+            return sprintf( '%s v%s', glsr_get( $plugin, 'Name' ), glsr_get( $plugin, 'Version' ) );
353
+        }, $plugins );
354
+        natcasesort( $plugins );
355
+        return array_flip( $plugins );
356 356
     }
357 357
 
358 358
     /**
359 359
      * @return array
360 360
      */
361
-    protected function purgeSensitiveData(array $settings)
361
+    protected function purgeSensitiveData( array $settings )
362 362
     {
363 363
         $keys = [
364 364
             'general.rebusify_serial',
@@ -366,12 +366,12 @@  discard block
 block discarded – undo
366 366
             'submissions.recaptcha.key',
367 367
             'submissions.recaptcha.secret',
368 368
         ];
369
-        array_walk($settings, function (&$value, $setting) use ($keys) {
370
-            foreach ($keys as $key) {
371
-                if (!glsr(Helper::class)->startsWith($key, $setting) || empty($value)) {
369
+        array_walk( $settings, function( &$value, $setting ) use ($keys) {
370
+            foreach( $keys as $key ) {
371
+                if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty($value) ) {
372 372
                     continue;
373 373
                 }
374
-                $value = str_repeat('•', 13);
374
+                $value = str_repeat( '•', 13 );
375 375
                 return;
376 376
             }
377 377
         });
Please login to merge, or discard this patch.
plugin/Database/CountsManager.php 3 patches
Indentation   +354 added lines, -354 removed lines patch added patch discarded remove patch
@@ -11,385 +11,385 @@
 block discarded – undo
11 11
 
12 12
 class CountsManager
13 13
 {
14
-    const LIMIT = 500;
15
-    const META_AVERAGE = '_glsr_average';
16
-    const META_COUNT = '_glsr_count';
17
-    const META_RANKING = '_glsr_ranking';
14
+	const LIMIT = 500;
15
+	const META_AVERAGE = '_glsr_average';
16
+	const META_COUNT = '_glsr_count';
17
+	const META_RANKING = '_glsr_ranking';
18 18
 
19
-    /**
20
-     * @return array
21
-     * @todo verify the additional type checks are needed
22
-     */
23
-    public function buildCounts(array $args = [])
24
-    {
25
-        $counts = [];
26
-        $query = $this->queryReviews($args);
27
-        while ($query) {
28
-            $types = array_keys(array_flip(glsr_array_column($query->reviews, 'type')));
29
-            $types = array_unique(array_merge(['local'], $types));
30
-            foreach ($types as $type) {
31
-                $type = $this->normalizeType($type);
32
-                if (isset($counts[$type])) {
33
-                    continue;
34
-            }
35
-                $counts[$type] = array_fill_keys(range(0, glsr()->constant('MAX_RATING', Rating::class)), 0);
36
-            }
37
-            foreach ($query->reviews as $review) {
38
-                $type = $this->normalizeType($review->type);
39
-                ++$counts[$type][$review->rating];
40
-            }
41
-            $query = $query->has_more
42
-                ? $this->queryReviews($args, end($query->reviews)->ID)
43
-                : false;
44
-        }
45
-        return $counts;
46
-    }
19
+	/**
20
+	 * @return array
21
+	 * @todo verify the additional type checks are needed
22
+	 */
23
+	public function buildCounts(array $args = [])
24
+	{
25
+		$counts = [];
26
+		$query = $this->queryReviews($args);
27
+		while ($query) {
28
+			$types = array_keys(array_flip(glsr_array_column($query->reviews, 'type')));
29
+			$types = array_unique(array_merge(['local'], $types));
30
+			foreach ($types as $type) {
31
+				$type = $this->normalizeType($type);
32
+				if (isset($counts[$type])) {
33
+					continue;
34
+			}
35
+				$counts[$type] = array_fill_keys(range(0, glsr()->constant('MAX_RATING', Rating::class)), 0);
36
+			}
37
+			foreach ($query->reviews as $review) {
38
+				$type = $this->normalizeType($review->type);
39
+				++$counts[$type][$review->rating];
40
+			}
41
+			$query = $query->has_more
42
+				? $this->queryReviews($args, end($query->reviews)->ID)
43
+				: false;
44
+		}
45
+		return $counts;
46
+	}
47 47
 
48
-    /**
49
-     * @param int $postId
50
-     * @return array
51
-     */
52
-    public function buildPostCounts($postId)
53
-    {
54
-        return $this->buildCounts(['post_ids' => [$postId]]);
55
-    }
48
+	/**
49
+	 * @param int $postId
50
+	 * @return array
51
+	 */
52
+	public function buildPostCounts($postId)
53
+	{
54
+		return $this->buildCounts(['post_ids' => [$postId]]);
55
+	}
56 56
 
57
-    /**
58
-     * @param int $termTaxonomyId
59
-     * @return array
60
-     */
61
-    public function buildTermCounts($termTaxonomyId)
62
-    {
63
-        return $this->buildCounts(['term_ids' => [$termTaxonomyId]]);
64
-    }
57
+	/**
58
+	 * @param int $termTaxonomyId
59
+	 * @return array
60
+	 */
61
+	public function buildTermCounts($termTaxonomyId)
62
+	{
63
+		return $this->buildCounts(['term_ids' => [$termTaxonomyId]]);
64
+	}
65 65
 
66
-    /**
67
-     * @return void
68
-     */
69
-    public function countAll()
70
-    {
71
-        $terms = glsr(Database::class)->getTerms(['fields' => 'all']);
72
-        foreach ($terms as $term) {
73
-            $this->setTermCounts($term->term_id, $this->buildTermCounts($term->term_taxonomy_id));
74
-        }
75
-        $postIds = glsr(SqlQueries::class)->getReviewsMeta('assigned_to');
76
-        foreach ($postIds as $postId) {
77
-            $this->setPostCounts($postId, $this->buildPostCounts($postId));
78
-        }
79
-        $this->setCounts($this->buildCounts());
80
-    }
66
+	/**
67
+	 * @return void
68
+	 */
69
+	public function countAll()
70
+	{
71
+		$terms = glsr(Database::class)->getTerms(['fields' => 'all']);
72
+		foreach ($terms as $term) {
73
+			$this->setTermCounts($term->term_id, $this->buildTermCounts($term->term_taxonomy_id));
74
+		}
75
+		$postIds = glsr(SqlQueries::class)->getReviewsMeta('assigned_to');
76
+		foreach ($postIds as $postId) {
77
+			$this->setPostCounts($postId, $this->buildPostCounts($postId));
78
+		}
79
+		$this->setCounts($this->buildCounts());
80
+	}
81 81
 
82
-    /**
83
-     * @return void
84
-     */
85
-    public function decrease(Review $review)
86
-    {
87
-        $this->decreaseCounts($review);
88
-        $this->decreasePostCounts($review);
89
-        $this->decreaseTermCounts($review);
90
-    }
82
+	/**
83
+	 * @return void
84
+	 */
85
+	public function decrease(Review $review)
86
+	{
87
+		$this->decreaseCounts($review);
88
+		$this->decreasePostCounts($review);
89
+		$this->decreaseTermCounts($review);
90
+	}
91 91
 
92
-    /**
93
-     * @return void
94
-     */
95
-    public function decreaseCounts(Review $review)
96
-    {
97
-        $this->setCounts($this->decreaseRating(
98
-            $this->getCounts(),
99
-            $review->review_type,
100
-            $review->rating
101
-        ));
102
-    }
92
+	/**
93
+	 * @return void
94
+	 */
95
+	public function decreaseCounts(Review $review)
96
+	{
97
+		$this->setCounts($this->decreaseRating(
98
+			$this->getCounts(),
99
+			$review->review_type,
100
+			$review->rating
101
+		));
102
+	}
103 103
 
104
-    /**
105
-     * @return void
106
-     */
107
-    public function decreasePostCounts(Review $review)
108
-    {
109
-        if (empty($counts = $this->getPostCounts($review->assigned_to))) {
110
-            return;
111
-        }
112
-        $counts = $this->decreaseRating($counts, $review->review_type, $review->rating);
113
-        $this->setPostCounts($review->assigned_to, $counts);
114
-    }
104
+	/**
105
+	 * @return void
106
+	 */
107
+	public function decreasePostCounts(Review $review)
108
+	{
109
+		if (empty($counts = $this->getPostCounts($review->assigned_to))) {
110
+			return;
111
+		}
112
+		$counts = $this->decreaseRating($counts, $review->review_type, $review->rating);
113
+		$this->setPostCounts($review->assigned_to, $counts);
114
+	}
115 115
 
116
-    /**
117
-     * @return void
118
-     */
119
-    public function decreaseTermCounts(Review $review)
120
-    {
121
-        foreach ($review->term_ids as $termId) {
122
-            if (empty($counts = $this->getTermCounts($termId))) {
123
-                continue;
124
-            }
125
-            $counts = $this->decreaseRating($counts, $review->review_type, $review->rating);
126
-            $this->setTermCounts($termId, $counts);
127
-        }
128
-    }
116
+	/**
117
+	 * @return void
118
+	 */
119
+	public function decreaseTermCounts(Review $review)
120
+	{
121
+		foreach ($review->term_ids as $termId) {
122
+			if (empty($counts = $this->getTermCounts($termId))) {
123
+				continue;
124
+			}
125
+			$counts = $this->decreaseRating($counts, $review->review_type, $review->rating);
126
+			$this->setTermCounts($termId, $counts);
127
+		}
128
+	}
129 129
 
130
-    /**
131
-     * @return array
132
-     */
133
-    public function flatten(array $reviewCounts, array $args = [])
134
-    {
135
-        $counts = [];
136
-        array_walk_recursive($reviewCounts, function ($num, $index) use (&$counts) {
137
-            $counts[$index] = $num + intval(glsr_get($counts, $index, 0));
138
-        });
139
-        $args = wp_parse_args($args, [
140
-            'max' => glsr()->constant('MAX_RATING', Rating::class),
141
-            'min' => glsr()->constant('MIN_RATING', Rating::class),
142
-        ]);
143
-        foreach ($counts as $index => &$num) {
144
-            if ($index >= intval($args['min']) && $index <= intval($args['max'])) {
145
-                continue;
146
-            }
147
-            $num = 0;
148
-        }
149
-        return $counts;
150
-    }
130
+	/**
131
+	 * @return array
132
+	 */
133
+	public function flatten(array $reviewCounts, array $args = [])
134
+	{
135
+		$counts = [];
136
+		array_walk_recursive($reviewCounts, function ($num, $index) use (&$counts) {
137
+			$counts[$index] = $num + intval(glsr_get($counts, $index, 0));
138
+		});
139
+		$args = wp_parse_args($args, [
140
+			'max' => glsr()->constant('MAX_RATING', Rating::class),
141
+			'min' => glsr()->constant('MIN_RATING', Rating::class),
142
+		]);
143
+		foreach ($counts as $index => &$num) {
144
+			if ($index >= intval($args['min']) && $index <= intval($args['max'])) {
145
+				continue;
146
+			}
147
+			$num = 0;
148
+		}
149
+		return $counts;
150
+	}
151 151
 
152
-    /**
153
-     * @return array
154
-     */
155
-    public function get(array $args = [])
156
-    {
157
-        $args = $this->normalizeArgs($args);
158
-        $counts = [];
159
-        if ($this->isMixedCount($args)) {
160
-            $counts = [$this->buildCounts($args)]; // force query the database
161
-        } else {
162
-            foreach ($args['post_ids'] as $postId) {
163
-                $counts[] = $this->getPostCounts($postId);
164
-        }
165
-            foreach ($args['term_ids'] as $termId) {
166
-                $counts[] = $this->getTermCounts($termId);
167
-            }
168
-            if (empty($counts)) {
169
-                $counts[] = $this->getCounts();
170
-            }
171
-        }
172
-        return in_array($args['type'], ['', 'all'])
173
-            ? $this->normalize([$this->flatten($counts)])
174
-            : $this->normalize(glsr_array_column($counts, $args['type']));
175
-    }
152
+	/**
153
+	 * @return array
154
+	 */
155
+	public function get(array $args = [])
156
+	{
157
+		$args = $this->normalizeArgs($args);
158
+		$counts = [];
159
+		if ($this->isMixedCount($args)) {
160
+			$counts = [$this->buildCounts($args)]; // force query the database
161
+		} else {
162
+			foreach ($args['post_ids'] as $postId) {
163
+				$counts[] = $this->getPostCounts($postId);
164
+		}
165
+			foreach ($args['term_ids'] as $termId) {
166
+				$counts[] = $this->getTermCounts($termId);
167
+			}
168
+			if (empty($counts)) {
169
+				$counts[] = $this->getCounts();
170
+			}
171
+		}
172
+		return in_array($args['type'], ['', 'all'])
173
+			? $this->normalize([$this->flatten($counts)])
174
+			: $this->normalize(glsr_array_column($counts, $args['type']));
175
+	}
176 176
 
177
-    /**
178
-     * @return array
179
-     */
180
-    public function getCounts()
181
-    {
182
-        $counts = glsr(OptionManager::class)->get('counts', []);
183
-        if (!is_array($counts)) {
184
-            glsr_log()->error('Review counts is not an array; possibly due to incorrectly imported reviews.')->debug($counts);
185
-            return [];
186
-        }
187
-        return $counts;
188
-    }
177
+	/**
178
+	 * @return array
179
+	 */
180
+	public function getCounts()
181
+	{
182
+		$counts = glsr(OptionManager::class)->get('counts', []);
183
+		if (!is_array($counts)) {
184
+			glsr_log()->error('Review counts is not an array; possibly due to incorrectly imported reviews.')->debug($counts);
185
+			return [];
186
+		}
187
+		return $counts;
188
+	}
189 189
 
190
-    /**
191
-     * @param int $postId
192
-     * @return array
193
-     */
194
-    public function getPostCounts($postId)
195
-    {
196
-        return array_filter((array) get_post_meta($postId, static::META_COUNT, true));
197
-    }
190
+	/**
191
+	 * @param int $postId
192
+	 * @return array
193
+	 */
194
+	public function getPostCounts($postId)
195
+	{
196
+		return array_filter((array) get_post_meta($postId, static::META_COUNT, true));
197
+	}
198 198
 
199
-    /**
200
-     * @param int $termId
201
-     * @return array
202
-     */
203
-    public function getTermCounts($termId)
204
-    {
205
-        return array_filter((array) get_term_meta($termId, static::META_COUNT, true));
206
-    }
199
+	/**
200
+	 * @param int $termId
201
+	 * @return array
202
+	 */
203
+	public function getTermCounts($termId)
204
+	{
205
+		return array_filter((array) get_term_meta($termId, static::META_COUNT, true));
206
+	}
207 207
 
208
-    /**
209
-     * @return void
210
-     */
211
-    public function increase(Review $review)
212
-    {
213
-        $this->increaseCounts($review);
214
-        $this->increasePostCounts($review);
215
-        $this->increaseTermCounts($review);
216
-    }
208
+	/**
209
+	 * @return void
210
+	 */
211
+	public function increase(Review $review)
212
+	{
213
+		$this->increaseCounts($review);
214
+		$this->increasePostCounts($review);
215
+		$this->increaseTermCounts($review);
216
+	}
217 217
 
218
-    /**
219
-     * @return void
220
-     */
221
-    public function increaseCounts(Review $review)
222
-    {
223
-        if (empty($counts = $this->getCounts())) {
224
-            $counts = $this->buildCounts();
225
-        }
226
-        $this->setCounts($this->increaseRating($counts, $review->review_type, $review->rating));
227
-    }
218
+	/**
219
+	 * @return void
220
+	 */
221
+	public function increaseCounts(Review $review)
222
+	{
223
+		if (empty($counts = $this->getCounts())) {
224
+			$counts = $this->buildCounts();
225
+		}
226
+		$this->setCounts($this->increaseRating($counts, $review->review_type, $review->rating));
227
+	}
228 228
 
229
-    /**
230
-     * @return void
231
-     */
232
-    public function increasePostCounts(Review $review)
233
-    {
234
-        if (!(get_post($review->assigned_to) instanceof WP_Post)) {
235
-            return;
236
-        }
237
-        $counts = $this->getPostCounts($review->assigned_to);
238
-        $counts = empty($counts)
239
-            ? $this->buildPostCounts($review->assigned_to)
240
-            : $this->increaseRating($counts, $review->review_type, $review->rating);
241
-        $this->setPostCounts($review->assigned_to, $counts);
242
-    }
229
+	/**
230
+	 * @return void
231
+	 */
232
+	public function increasePostCounts(Review $review)
233
+	{
234
+		if (!(get_post($review->assigned_to) instanceof WP_Post)) {
235
+			return;
236
+		}
237
+		$counts = $this->getPostCounts($review->assigned_to);
238
+		$counts = empty($counts)
239
+			? $this->buildPostCounts($review->assigned_to)
240
+			: $this->increaseRating($counts, $review->review_type, $review->rating);
241
+		$this->setPostCounts($review->assigned_to, $counts);
242
+	}
243 243
 
244
-    /**
245
-     * @return void
246
-     */
247
-    public function increaseTermCounts(Review $review)
248
-    {
249
-        $terms = glsr(ReviewManager::class)->normalizeTerms(implode(',', $review->term_ids));
250
-        foreach ($terms as $term) {
251
-            $counts = $this->getTermCounts($term['term_id']);
252
-            $counts = empty($counts)
253
-                ? $this->buildTermCounts($term['term_taxonomy_id'])
254
-                : $this->increaseRating($counts, $review->review_type, $review->rating);
255
-            $this->setTermCounts($term['term_id'], $counts);
256
-        }
257
-    }
244
+	/**
245
+	 * @return void
246
+	 */
247
+	public function increaseTermCounts(Review $review)
248
+	{
249
+		$terms = glsr(ReviewManager::class)->normalizeTerms(implode(',', $review->term_ids));
250
+		foreach ($terms as $term) {
251
+			$counts = $this->getTermCounts($term['term_id']);
252
+			$counts = empty($counts)
253
+				? $this->buildTermCounts($term['term_taxonomy_id'])
254
+				: $this->increaseRating($counts, $review->review_type, $review->rating);
255
+			$this->setTermCounts($term['term_id'], $counts);
256
+		}
257
+	}
258 258
 
259
-    /**
260
-     * @return void
261
-     */
262
-    public function setCounts(array $reviewCounts)
263
-    {
264
-        glsr(OptionManager::class)->set('counts', $reviewCounts);
265
-    }
259
+	/**
260
+	 * @return void
261
+	 */
262
+	public function setCounts(array $reviewCounts)
263
+	{
264
+		glsr(OptionManager::class)->set('counts', $reviewCounts);
265
+	}
266 266
 
267
-    /**
268
-     * @param int $postId
269
-     * @return void
270
-     */
271
-    public function setPostCounts($postId, array $reviewCounts)
272
-    {
273
-        $ratingCounts = $this->flatten($reviewCounts);
274
-        update_post_meta($postId, static::META_COUNT, $reviewCounts);
275
-        update_post_meta($postId, static::META_AVERAGE, glsr(Rating::class)->getAverage($ratingCounts));
276
-        update_post_meta($postId, static::META_RANKING, glsr(Rating::class)->getRanking($ratingCounts));
277
-    }
267
+	/**
268
+	 * @param int $postId
269
+	 * @return void
270
+	 */
271
+	public function setPostCounts($postId, array $reviewCounts)
272
+	{
273
+		$ratingCounts = $this->flatten($reviewCounts);
274
+		update_post_meta($postId, static::META_COUNT, $reviewCounts);
275
+		update_post_meta($postId, static::META_AVERAGE, glsr(Rating::class)->getAverage($ratingCounts));
276
+		update_post_meta($postId, static::META_RANKING, glsr(Rating::class)->getRanking($ratingCounts));
277
+	}
278 278
 
279
-    /**
280
-     * @param int $termId
281
-     * @return void
282
-     */
283
-    public function setTermCounts($termId, array $reviewCounts)
284
-    {
285
-        $term = get_term($termId, Application::TAXONOMY);
286
-        if (!isset($term->term_id)) {
287
-            return;
288
-        }
289
-        $ratingCounts = $this->flatten($reviewCounts);
290
-        update_term_meta($termId, static::META_COUNT, $reviewCounts);
291
-        update_term_meta($termId, static::META_AVERAGE, glsr(Rating::class)->getAverage($ratingCounts));
292
-        update_term_meta($termId, static::META_RANKING, glsr(Rating::class)->getRanking($ratingCounts));
293
-    }
279
+	/**
280
+	 * @param int $termId
281
+	 * @return void
282
+	 */
283
+	public function setTermCounts($termId, array $reviewCounts)
284
+	{
285
+		$term = get_term($termId, Application::TAXONOMY);
286
+		if (!isset($term->term_id)) {
287
+			return;
288
+		}
289
+		$ratingCounts = $this->flatten($reviewCounts);
290
+		update_term_meta($termId, static::META_COUNT, $reviewCounts);
291
+		update_term_meta($termId, static::META_AVERAGE, glsr(Rating::class)->getAverage($ratingCounts));
292
+		update_term_meta($termId, static::META_RANKING, glsr(Rating::class)->getRanking($ratingCounts));
293
+	}
294 294
 
295
-    /**
296
-     * @param string $type
297
-     * @param int $rating
298
-     * @return array
299
-     */
300
-    protected function decreaseRating(array $reviewCounts, $type, $rating)
301
-    {
302
-        if (isset($reviewCounts[$type][$rating])) {
303
-            $reviewCounts[$type][$rating] = max(0, $reviewCounts[$type][$rating] - 1);
304
-        }
305
-        return $reviewCounts;
306
-    }
295
+	/**
296
+	 * @param string $type
297
+	 * @param int $rating
298
+	 * @return array
299
+	 */
300
+	protected function decreaseRating(array $reviewCounts, $type, $rating)
301
+	{
302
+		if (isset($reviewCounts[$type][$rating])) {
303
+			$reviewCounts[$type][$rating] = max(0, $reviewCounts[$type][$rating] - 1);
304
+		}
305
+		return $reviewCounts;
306
+	}
307 307
 
308
-    /**
309
-     * @param string $type
310
-     * @param int $rating
311
-     * @return array
312
-     */
313
-    protected function increaseRating(array $reviewCounts, $type, $rating)
314
-    {
315
-        if (!array_key_exists($type, glsr()->reviewTypes)) {
316
-            return $reviewCounts;
317
-        }
318
-        if (!array_key_exists($type, $reviewCounts)) {
319
-            $reviewCounts[$type] = [];
320
-        }
321
-        $reviewCounts = $this->normalize($reviewCounts);
322
-        $reviewCounts[$type][$rating] = intval($reviewCounts[$type][$rating]) + 1;
323
-        return $reviewCounts;
324
-    }
308
+	/**
309
+	 * @param string $type
310
+	 * @param int $rating
311
+	 * @return array
312
+	 */
313
+	protected function increaseRating(array $reviewCounts, $type, $rating)
314
+	{
315
+		if (!array_key_exists($type, glsr()->reviewTypes)) {
316
+			return $reviewCounts;
317
+		}
318
+		if (!array_key_exists($type, $reviewCounts)) {
319
+			$reviewCounts[$type] = [];
320
+		}
321
+		$reviewCounts = $this->normalize($reviewCounts);
322
+		$reviewCounts[$type][$rating] = intval($reviewCounts[$type][$rating]) + 1;
323
+		return $reviewCounts;
324
+	}
325 325
 
326
-    /**
327
-     * @return bool
328
-     */
329
-    protected function isMixedCount(array $args)
330
-    {
331
-        return !empty($args['post_ids']) && !empty($args['term_ids']);
332
-    }
326
+	/**
327
+	 * @return bool
328
+	 */
329
+	protected function isMixedCount(array $args)
330
+	{
331
+		return !empty($args['post_ids']) && !empty($args['term_ids']);
332
+	}
333 333
 
334
-    /**
335
-     * @return array
336
-     */
337
-    protected function normalize(array $reviewCounts)
338
-    {
339
-        if (empty($reviewCounts)) {
340
-            $reviewCounts = [[]];
341
-        }
342
-        foreach ($reviewCounts as &$counts) {
343
-            foreach (range(0, glsr()->constant('MAX_RATING', Rating::class)) as $index) {
344
-                if (isset($counts[$index])) {
345
-                    continue;
346
-                }
347
-                $counts[$index] = 0;
348
-            }
349
-            ksort($counts);
350
-        }
351
-        return $reviewCounts;
352
-    }
334
+	/**
335
+	 * @return array
336
+	 */
337
+	protected function normalize(array $reviewCounts)
338
+	{
339
+		if (empty($reviewCounts)) {
340
+			$reviewCounts = [[]];
341
+		}
342
+		foreach ($reviewCounts as &$counts) {
343
+			foreach (range(0, glsr()->constant('MAX_RATING', Rating::class)) as $index) {
344
+				if (isset($counts[$index])) {
345
+					continue;
346
+				}
347
+				$counts[$index] = 0;
348
+			}
349
+			ksort($counts);
350
+		}
351
+		return $reviewCounts;
352
+	}
353 353
 
354
-    /**
355
-     * @return array
356
-     */
357
-    protected function normalizeArgs(array $args)
358
-    {
359
-        $args = wp_parse_args(array_filter($args), [
360
-            'post_ids' => [],
361
-            'term_ids' => [],
362
-            'type' => 'local',
363
-        ]);
364
-        $args['post_ids'] = glsr(Polylang::class)->getPostIds($args['post_ids']);
365
-        $args['type'] = $this->normalizeType($args['type']);
366
-        return $args;
367
-    }
354
+	/**
355
+	 * @return array
356
+	 */
357
+	protected function normalizeArgs(array $args)
358
+	{
359
+		$args = wp_parse_args(array_filter($args), [
360
+			'post_ids' => [],
361
+			'term_ids' => [],
362
+			'type' => 'local',
363
+		]);
364
+		$args['post_ids'] = glsr(Polylang::class)->getPostIds($args['post_ids']);
365
+		$args['type'] = $this->normalizeType($args['type']);
366
+		return $args;
367
+	}
368 368
 
369
-    /**
370
-     * @param string $type
371
-     * @return string
372
-     */
373
-    protected function normalizeType($type)
374
-    {
375
-        return empty($type) || !is_string($type)
376
-            ? 'local'
377
-            : $type;
378
-    }
369
+	/**
370
+	 * @param string $type
371
+	 * @return string
372
+	 */
373
+	protected function normalizeType($type)
374
+	{
375
+		return empty($type) || !is_string($type)
376
+			? 'local'
377
+			: $type;
378
+	}
379 379
 
380
-    /**
381
-     * @param int $lastPostId
382
-     * @return object
383
-     */
384
-    protected function queryReviews(array $args = [], $lastPostId = 0)
385
-    {
386
-        $reviews = glsr(SqlQueries::class)->getReviewCounts($args, $lastPostId, static::LIMIT);
387
-        $hasMore = is_array($reviews)
388
-            ? count($reviews) == static::LIMIT
389
-            : false;
390
-        return (object) [
391
-            'has_more' => $hasMore,
392
-            'reviews' => $reviews,
393
-        ];
394
-    }
380
+	/**
381
+	 * @param int $lastPostId
382
+	 * @return object
383
+	 */
384
+	protected function queryReviews(array $args = [], $lastPostId = 0)
385
+	{
386
+		$reviews = glsr(SqlQueries::class)->getReviewCounts($args, $lastPostId, static::LIMIT);
387
+		$hasMore = is_array($reviews)
388
+			? count($reviews) == static::LIMIT
389
+			: false;
390
+		return (object) [
391
+			'has_more' => $hasMore,
392
+			'reviews' => $reviews,
393
+		];
394
+	}
395 395
 }
Please login to merge, or discard this patch.
Spacing   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -20,26 +20,26 @@  discard block
 block discarded – undo
20 20
      * @return array
21 21
      * @todo verify the additional type checks are needed
22 22
      */
23
-    public function buildCounts(array $args = [])
23
+    public function buildCounts( array $args = [] )
24 24
     {
25 25
         $counts = [];
26
-        $query = $this->queryReviews($args);
27
-        while ($query) {
28
-            $types = array_keys(array_flip(glsr_array_column($query->reviews, 'type')));
29
-            $types = array_unique(array_merge(['local'], $types));
30
-            foreach ($types as $type) {
31
-                $type = $this->normalizeType($type);
32
-                if (isset($counts[$type])) {
26
+        $query = $this->queryReviews( $args );
27
+        while( $query ) {
28
+            $types = array_keys( array_flip( glsr_array_column( $query->reviews, 'type' ) ) );
29
+            $types = array_unique( array_merge( ['local'], $types ) );
30
+            foreach( $types as $type ) {
31
+                $type = $this->normalizeType( $type );
32
+                if( isset($counts[$type]) ) {
33 33
                     continue;
34 34
             }
35
-                $counts[$type] = array_fill_keys(range(0, glsr()->constant('MAX_RATING', Rating::class)), 0);
35
+                $counts[$type] = array_fill_keys( range( 0, glsr()->constant( 'MAX_RATING', Rating::class ) ), 0 );
36 36
             }
37
-            foreach ($query->reviews as $review) {
38
-                $type = $this->normalizeType($review->type);
37
+            foreach( $query->reviews as $review ) {
38
+                $type = $this->normalizeType( $review->type );
39 39
                 ++$counts[$type][$review->rating];
40 40
             }
41 41
             $query = $query->has_more
42
-                ? $this->queryReviews($args, end($query->reviews)->ID)
42
+                ? $this->queryReviews( $args, end( $query->reviews )->ID )
43 43
                 : false;
44 44
         }
45 45
         return $counts;
@@ -49,18 +49,18 @@  discard block
 block discarded – undo
49 49
      * @param int $postId
50 50
      * @return array
51 51
      */
52
-    public function buildPostCounts($postId)
52
+    public function buildPostCounts( $postId )
53 53
     {
54
-        return $this->buildCounts(['post_ids' => [$postId]]);
54
+        return $this->buildCounts( ['post_ids' => [$postId]] );
55 55
     }
56 56
 
57 57
     /**
58 58
      * @param int $termTaxonomyId
59 59
      * @return array
60 60
      */
61
-    public function buildTermCounts($termTaxonomyId)
61
+    public function buildTermCounts( $termTaxonomyId )
62 62
     {
63
-        return $this->buildCounts(['term_ids' => [$termTaxonomyId]]);
63
+        return $this->buildCounts( ['term_ids' => [$termTaxonomyId]] );
64 64
     }
65 65
 
66 66
     /**
@@ -68,80 +68,80 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public function countAll()
70 70
     {
71
-        $terms = glsr(Database::class)->getTerms(['fields' => 'all']);
72
-        foreach ($terms as $term) {
73
-            $this->setTermCounts($term->term_id, $this->buildTermCounts($term->term_taxonomy_id));
71
+        $terms = glsr( Database::class )->getTerms( ['fields' => 'all'] );
72
+        foreach( $terms as $term ) {
73
+            $this->setTermCounts( $term->term_id, $this->buildTermCounts( $term->term_taxonomy_id ) );
74 74
         }
75
-        $postIds = glsr(SqlQueries::class)->getReviewsMeta('assigned_to');
76
-        foreach ($postIds as $postId) {
77
-            $this->setPostCounts($postId, $this->buildPostCounts($postId));
75
+        $postIds = glsr( SqlQueries::class )->getReviewsMeta( 'assigned_to' );
76
+        foreach( $postIds as $postId ) {
77
+            $this->setPostCounts( $postId, $this->buildPostCounts( $postId ) );
78 78
         }
79
-        $this->setCounts($this->buildCounts());
79
+        $this->setCounts( $this->buildCounts() );
80 80
     }
81 81
 
82 82
     /**
83 83
      * @return void
84 84
      */
85
-    public function decrease(Review $review)
85
+    public function decrease( Review $review )
86 86
     {
87
-        $this->decreaseCounts($review);
88
-        $this->decreasePostCounts($review);
89
-        $this->decreaseTermCounts($review);
87
+        $this->decreaseCounts( $review );
88
+        $this->decreasePostCounts( $review );
89
+        $this->decreaseTermCounts( $review );
90 90
     }
91 91
 
92 92
     /**
93 93
      * @return void
94 94
      */
95
-    public function decreaseCounts(Review $review)
95
+    public function decreaseCounts( Review $review )
96 96
     {
97
-        $this->setCounts($this->decreaseRating(
97
+        $this->setCounts( $this->decreaseRating(
98 98
             $this->getCounts(),
99 99
             $review->review_type,
100 100
             $review->rating
101
-        ));
101
+        ) );
102 102
     }
103 103
 
104 104
     /**
105 105
      * @return void
106 106
      */
107
-    public function decreasePostCounts(Review $review)
107
+    public function decreasePostCounts( Review $review )
108 108
     {
109
-        if (empty($counts = $this->getPostCounts($review->assigned_to))) {
109
+        if( empty($counts = $this->getPostCounts( $review->assigned_to )) ) {
110 110
             return;
111 111
         }
112
-        $counts = $this->decreaseRating($counts, $review->review_type, $review->rating);
113
-        $this->setPostCounts($review->assigned_to, $counts);
112
+        $counts = $this->decreaseRating( $counts, $review->review_type, $review->rating );
113
+        $this->setPostCounts( $review->assigned_to, $counts );
114 114
     }
115 115
 
116 116
     /**
117 117
      * @return void
118 118
      */
119
-    public function decreaseTermCounts(Review $review)
119
+    public function decreaseTermCounts( Review $review )
120 120
     {
121
-        foreach ($review->term_ids as $termId) {
122
-            if (empty($counts = $this->getTermCounts($termId))) {
121
+        foreach( $review->term_ids as $termId ) {
122
+            if( empty($counts = $this->getTermCounts( $termId )) ) {
123 123
                 continue;
124 124
             }
125
-            $counts = $this->decreaseRating($counts, $review->review_type, $review->rating);
126
-            $this->setTermCounts($termId, $counts);
125
+            $counts = $this->decreaseRating( $counts, $review->review_type, $review->rating );
126
+            $this->setTermCounts( $termId, $counts );
127 127
         }
128 128
     }
129 129
 
130 130
     /**
131 131
      * @return array
132 132
      */
133
-    public function flatten(array $reviewCounts, array $args = [])
133
+    public function flatten( array $reviewCounts, array $args = [] )
134 134
     {
135 135
         $counts = [];
136
-        array_walk_recursive($reviewCounts, function ($num, $index) use (&$counts) {
137
-            $counts[$index] = $num + intval(glsr_get($counts, $index, 0));
136
+        array_walk_recursive( $reviewCounts, function( $num, $index ) use (&$counts) {
137
+            $counts[$index] = $num + intval( glsr_get( $counts, $index, 0 ) );
138 138
         });
139
-        $args = wp_parse_args($args, [
140
-            'max' => glsr()->constant('MAX_RATING', Rating::class),
141
-            'min' => glsr()->constant('MIN_RATING', Rating::class),
142
-        ]);
143
-        foreach ($counts as $index => &$num) {
144
-            if ($index >= intval($args['min']) && $index <= intval($args['max'])) {
139
+        $args = wp_parse_args( $args, [
140
+            'max' => glsr()->constant( 'MAX_RATING', Rating::class ),
141
+            'min' => glsr()->constant( 'MIN_RATING', Rating::class ),
142
+        ] );
143
+        foreach( $counts as $index => &$num ) {
144
+            if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ) ) {
145 145
                 continue;
146 146
             }
147 147
             $num = 0;
@@ -152,26 +152,26 @@  discard block
 block discarded – undo
152 152
     /**
153 153
      * @return array
154 154
      */
155
-    public function get(array $args = [])
155
+    public function get( array $args = [] )
156 156
     {
157
-        $args = $this->normalizeArgs($args);
157
+        $args = $this->normalizeArgs( $args );
158 158
         $counts = [];
159
-        if ($this->isMixedCount($args)) {
160
-            $counts = [$this->buildCounts($args)]; // force query the database
159
+        if( $this->isMixedCount( $args ) ) {
160
+            $counts = [$this->buildCounts( $args )]; // force query the database
161 161
         } else {
162
-            foreach ($args['post_ids'] as $postId) {
163
-                $counts[] = $this->getPostCounts($postId);
162
+            foreach( $args['post_ids'] as $postId ) {
163
+                $counts[] = $this->getPostCounts( $postId );
164 164
         }
165
-            foreach ($args['term_ids'] as $termId) {
166
-                $counts[] = $this->getTermCounts($termId);
165
+            foreach( $args['term_ids'] as $termId ) {
166
+                $counts[] = $this->getTermCounts( $termId );
167 167
             }
168
-            if (empty($counts)) {
168
+            if( empty($counts) ) {
169 169
                 $counts[] = $this->getCounts();
170 170
             }
171 171
         }
172
-        return in_array($args['type'], ['', 'all'])
173
-            ? $this->normalize([$this->flatten($counts)])
174
-            : $this->normalize(glsr_array_column($counts, $args['type']));
172
+        return in_array( $args['type'], ['', 'all'] )
173
+            ? $this->normalize( [$this->flatten( $counts )] )
174
+            : $this->normalize( glsr_array_column( $counts, $args['type'] ) );
175 175
     }
176 176
 
177 177
     /**
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
      */
180 180
     public function getCounts()
181 181
     {
182
-        $counts = glsr(OptionManager::class)->get('counts', []);
183
-        if (!is_array($counts)) {
184
-            glsr_log()->error('Review counts is not an array; possibly due to incorrectly imported reviews.')->debug($counts);
182
+        $counts = glsr( OptionManager::class )->get( 'counts', [] );
183
+        if( !is_array( $counts ) ) {
184
+            glsr_log()->error( 'Review counts is not an array; possibly due to incorrectly imported reviews.' )->debug( $counts );
185 185
             return [];
186 186
         }
187 187
         return $counts;
@@ -191,105 +191,105 @@  discard block
 block discarded – undo
191 191
      * @param int $postId
192 192
      * @return array
193 193
      */
194
-    public function getPostCounts($postId)
194
+    public function getPostCounts( $postId )
195 195
     {
196
-        return array_filter((array) get_post_meta($postId, static::META_COUNT, true));
196
+        return array_filter( (array)get_post_meta( $postId, static::META_COUNT, true ) );
197 197
     }
198 198
 
199 199
     /**
200 200
      * @param int $termId
201 201
      * @return array
202 202
      */
203
-    public function getTermCounts($termId)
203
+    public function getTermCounts( $termId )
204 204
     {
205
-        return array_filter((array) get_term_meta($termId, static::META_COUNT, true));
205
+        return array_filter( (array)get_term_meta( $termId, static::META_COUNT, true ) );
206 206
     }
207 207
 
208 208
     /**
209 209
      * @return void
210 210
      */
211
-    public function increase(Review $review)
211
+    public function increase( Review $review )
212 212
     {
213
-        $this->increaseCounts($review);
214
-        $this->increasePostCounts($review);
215
-        $this->increaseTermCounts($review);
213
+        $this->increaseCounts( $review );
214
+        $this->increasePostCounts( $review );
215
+        $this->increaseTermCounts( $review );
216 216
     }
217 217
 
218 218
     /**
219 219
      * @return void
220 220
      */
221
-    public function increaseCounts(Review $review)
221
+    public function increaseCounts( Review $review )
222 222
     {
223
-        if (empty($counts = $this->getCounts())) {
223
+        if( empty($counts = $this->getCounts()) ) {
224 224
             $counts = $this->buildCounts();
225 225
         }
226
-        $this->setCounts($this->increaseRating($counts, $review->review_type, $review->rating));
226
+        $this->setCounts( $this->increaseRating( $counts, $review->review_type, $review->rating ) );
227 227
     }
228 228
 
229 229
     /**
230 230
      * @return void
231 231
      */
232
-    public function increasePostCounts(Review $review)
232
+    public function increasePostCounts( Review $review )
233 233
     {
234
-        if (!(get_post($review->assigned_to) instanceof WP_Post)) {
234
+        if( !(get_post( $review->assigned_to ) instanceof WP_Post) ) {
235 235
             return;
236 236
         }
237
-        $counts = $this->getPostCounts($review->assigned_to);
237
+        $counts = $this->getPostCounts( $review->assigned_to );
238 238
         $counts = empty($counts)
239
-            ? $this->buildPostCounts($review->assigned_to)
240
-            : $this->increaseRating($counts, $review->review_type, $review->rating);
241
-        $this->setPostCounts($review->assigned_to, $counts);
239
+            ? $this->buildPostCounts( $review->assigned_to )
240
+            : $this->increaseRating( $counts, $review->review_type, $review->rating );
241
+        $this->setPostCounts( $review->assigned_to, $counts );
242 242
     }
243 243
 
244 244
     /**
245 245
      * @return void
246 246
      */
247
-    public function increaseTermCounts(Review $review)
247
+    public function increaseTermCounts( Review $review )
248 248
     {
249
-        $terms = glsr(ReviewManager::class)->normalizeTerms(implode(',', $review->term_ids));
250
-        foreach ($terms as $term) {
251
-            $counts = $this->getTermCounts($term['term_id']);
249
+        $terms = glsr( ReviewManager::class )->normalizeTerms( implode( ',', $review->term_ids ) );
250
+        foreach( $terms as $term ) {
251
+            $counts = $this->getTermCounts( $term['term_id'] );
252 252
             $counts = empty($counts)
253
-                ? $this->buildTermCounts($term['term_taxonomy_id'])
254
-                : $this->increaseRating($counts, $review->review_type, $review->rating);
255
-            $this->setTermCounts($term['term_id'], $counts);
253
+                ? $this->buildTermCounts( $term['term_taxonomy_id'] )
254
+                : $this->increaseRating( $counts, $review->review_type, $review->rating );
255
+            $this->setTermCounts( $term['term_id'], $counts );
256 256
         }
257 257
     }
258 258
 
259 259
     /**
260 260
      * @return void
261 261
      */
262
-    public function setCounts(array $reviewCounts)
262
+    public function setCounts( array $reviewCounts )
263 263
     {
264
-        glsr(OptionManager::class)->set('counts', $reviewCounts);
264
+        glsr( OptionManager::class )->set( 'counts', $reviewCounts );
265 265
     }
266 266
 
267 267
     /**
268 268
      * @param int $postId
269 269
      * @return void
270 270
      */
271
-    public function setPostCounts($postId, array $reviewCounts)
271
+    public function setPostCounts( $postId, array $reviewCounts )
272 272
     {
273
-        $ratingCounts = $this->flatten($reviewCounts);
274
-        update_post_meta($postId, static::META_COUNT, $reviewCounts);
275
-        update_post_meta($postId, static::META_AVERAGE, glsr(Rating::class)->getAverage($ratingCounts));
276
-        update_post_meta($postId, static::META_RANKING, glsr(Rating::class)->getRanking($ratingCounts));
273
+        $ratingCounts = $this->flatten( $reviewCounts );
274
+        update_post_meta( $postId, static::META_COUNT, $reviewCounts );
275
+        update_post_meta( $postId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ) );
276
+        update_post_meta( $postId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ) );
277 277
     }
278 278
 
279 279
     /**
280 280
      * @param int $termId
281 281
      * @return void
282 282
      */
283
-    public function setTermCounts($termId, array $reviewCounts)
283
+    public function setTermCounts( $termId, array $reviewCounts )
284 284
     {
285
-        $term = get_term($termId, Application::TAXONOMY);
286
-        if (!isset($term->term_id)) {
285
+        $term = get_term( $termId, Application::TAXONOMY );
286
+        if( !isset($term->term_id) ) {
287 287
             return;
288 288
         }
289
-        $ratingCounts = $this->flatten($reviewCounts);
290
-        update_term_meta($termId, static::META_COUNT, $reviewCounts);
291
-        update_term_meta($termId, static::META_AVERAGE, glsr(Rating::class)->getAverage($ratingCounts));
292
-        update_term_meta($termId, static::META_RANKING, glsr(Rating::class)->getRanking($ratingCounts));
289
+        $ratingCounts = $this->flatten( $reviewCounts );
290
+        update_term_meta( $termId, static::META_COUNT, $reviewCounts );
291
+        update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ) );
292
+        update_term_meta( $termId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ) );
293 293
     }
294 294
 
295 295
     /**
@@ -297,10 +297,10 @@  discard block
 block discarded – undo
297 297
      * @param int $rating
298 298
      * @return array
299 299
      */
300
-    protected function decreaseRating(array $reviewCounts, $type, $rating)
300
+    protected function decreaseRating( array $reviewCounts, $type, $rating )
301 301
     {
302
-        if (isset($reviewCounts[$type][$rating])) {
303
-            $reviewCounts[$type][$rating] = max(0, $reviewCounts[$type][$rating] - 1);
302
+        if( isset($reviewCounts[$type][$rating]) ) {
303
+            $reviewCounts[$type][$rating] = max( 0, $reviewCounts[$type][$rating] - 1 );
304 304
         }
305 305
         return $reviewCounts;
306 306
     }
@@ -310,23 +310,23 @@  discard block
 block discarded – undo
310 310
      * @param int $rating
311 311
      * @return array
312 312
      */
313
-    protected function increaseRating(array $reviewCounts, $type, $rating)
313
+    protected function increaseRating( array $reviewCounts, $type, $rating )
314 314
     {
315
-        if (!array_key_exists($type, glsr()->reviewTypes)) {
315
+        if( !array_key_exists( $type, glsr()->reviewTypes ) ) {
316 316
             return $reviewCounts;
317 317
         }
318
-        if (!array_key_exists($type, $reviewCounts)) {
318
+        if( !array_key_exists( $type, $reviewCounts ) ) {
319 319
             $reviewCounts[$type] = [];
320 320
         }
321
-        $reviewCounts = $this->normalize($reviewCounts);
322
-        $reviewCounts[$type][$rating] = intval($reviewCounts[$type][$rating]) + 1;
321
+        $reviewCounts = $this->normalize( $reviewCounts );
322
+        $reviewCounts[$type][$rating] = intval( $reviewCounts[$type][$rating] ) + 1;
323 323
         return $reviewCounts;
324 324
     }
325 325
 
326 326
     /**
327 327
      * @return bool
328 328
      */
329
-    protected function isMixedCount(array $args)
329
+    protected function isMixedCount( array $args )
330 330
     {
331 331
         return !empty($args['post_ids']) && !empty($args['term_ids']);
332 332
     }
@@ -334,19 +334,19 @@  discard block
 block discarded – undo
334 334
     /**
335 335
      * @return array
336 336
      */
337
-    protected function normalize(array $reviewCounts)
337
+    protected function normalize( array $reviewCounts )
338 338
     {
339
-        if (empty($reviewCounts)) {
339
+        if( empty($reviewCounts) ) {
340 340
             $reviewCounts = [[]];
341 341
         }
342
-        foreach ($reviewCounts as &$counts) {
343
-            foreach (range(0, glsr()->constant('MAX_RATING', Rating::class)) as $index) {
344
-                if (isset($counts[$index])) {
342
+        foreach( $reviewCounts as &$counts ) {
343
+            foreach( range( 0, glsr()->constant( 'MAX_RATING', Rating::class ) ) as $index ) {
344
+                if( isset($counts[$index]) ) {
345 345
                     continue;
346 346
                 }
347 347
                 $counts[$index] = 0;
348 348
             }
349
-            ksort($counts);
349
+            ksort( $counts );
350 350
         }
351 351
         return $reviewCounts;
352 352
     }
@@ -354,15 +354,15 @@  discard block
 block discarded – undo
354 354
     /**
355 355
      * @return array
356 356
      */
357
-    protected function normalizeArgs(array $args)
357
+    protected function normalizeArgs( array $args )
358 358
     {
359
-        $args = wp_parse_args(array_filter($args), [
359
+        $args = wp_parse_args( array_filter( $args ), [
360 360
             'post_ids' => [],
361 361
             'term_ids' => [],
362 362
             'type' => 'local',
363
-        ]);
364
-        $args['post_ids'] = glsr(Polylang::class)->getPostIds($args['post_ids']);
365
-        $args['type'] = $this->normalizeType($args['type']);
363
+        ] );
364
+        $args['post_ids'] = glsr( Polylang::class )->getPostIds( $args['post_ids'] );
365
+        $args['type'] = $this->normalizeType( $args['type'] );
366 366
         return $args;
367 367
     }
368 368
 
@@ -370,9 +370,9 @@  discard block
 block discarded – undo
370 370
      * @param string $type
371 371
      * @return string
372 372
      */
373
-    protected function normalizeType($type)
373
+    protected function normalizeType( $type )
374 374
     {
375
-        return empty($type) || !is_string($type)
375
+        return empty($type) || !is_string( $type )
376 376
             ? 'local'
377 377
             : $type;
378 378
     }
@@ -381,13 +381,13 @@  discard block
 block discarded – undo
381 381
      * @param int $lastPostId
382 382
      * @return object
383 383
      */
384
-    protected function queryReviews(array $args = [], $lastPostId = 0)
384
+    protected function queryReviews( array $args = [], $lastPostId = 0 )
385 385
     {
386
-        $reviews = glsr(SqlQueries::class)->getReviewCounts($args, $lastPostId, static::LIMIT);
387
-        $hasMore = is_array($reviews)
388
-            ? count($reviews) == static::LIMIT
386
+        $reviews = glsr( SqlQueries::class )->getReviewCounts( $args, $lastPostId, static::LIMIT );
387
+        $hasMore = is_array( $reviews )
388
+            ? count( $reviews ) == static::LIMIT
389 389
             : false;
390
-        return (object) [
390
+        return (object)[
391 391
             'has_more' => $hasMore,
392 392
             'reviews' => $reviews,
393 393
         ];
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -158,7 +158,8 @@
 block discarded – undo
158 158
         $counts = [];
159 159
         if ($this->isMixedCount($args)) {
160 160
             $counts = [$this->buildCounts($args)]; // force query the database
161
-        } else {
161
+        }
162
+        else {
162 163
             foreach ($args['post_ids'] as $postId) {
163 164
                 $counts[] = $this->getPostCounts($postId);
164 165
         }
Please login to merge, or discard this patch.
plugin/Review.php 2 patches
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -11,173 +11,173 @@
 block discarded – undo
11 11
 
12 12
 class Review implements \ArrayAccess
13 13
 {
14
-    public $assigned_to;
15
-    public $author;
16
-    public $avatar;
17
-    public $content;
18
-    public $custom;
19
-    public $date;
20
-    public $email;
21
-    public $ID;
22
-    public $ip_address;
23
-    public $modified;
24
-    public $pinned;
25
-    public $rating;
26
-    public $response;
27
-    public $review_id;
28
-    public $review_type;
29
-    public $status;
30
-    public $term_ids;
31
-    public $title;
32
-    public $url;
33
-    public $user_id;
14
+	public $assigned_to;
15
+	public $author;
16
+	public $avatar;
17
+	public $content;
18
+	public $custom;
19
+	public $date;
20
+	public $email;
21
+	public $ID;
22
+	public $ip_address;
23
+	public $modified;
24
+	public $pinned;
25
+	public $rating;
26
+	public $response;
27
+	public $review_id;
28
+	public $review_type;
29
+	public $status;
30
+	public $term_ids;
31
+	public $title;
32
+	public $url;
33
+	public $user_id;
34 34
 
35
-    public function __construct(WP_Post $post)
36
-    {
37
-        if (Application::POST_TYPE != $post->post_type) {
38
-            return;
39
-        }
40
-        $this->content = $post->post_content;
41
-        $this->date = $post->post_date;
42
-        $this->ID = intval($post->ID);
43
-        $this->status = $post->post_status;
44
-        $this->title = $post->post_title;
45
-        $this->user_id = intval($post->post_author);
46
-        $this->setProperties($post);
47
-        $this->setTermIds($post);
48
-    }
35
+	public function __construct(WP_Post $post)
36
+	{
37
+		if (Application::POST_TYPE != $post->post_type) {
38
+			return;
39
+		}
40
+		$this->content = $post->post_content;
41
+		$this->date = $post->post_date;
42
+		$this->ID = intval($post->ID);
43
+		$this->status = $post->post_status;
44
+		$this->title = $post->post_title;
45
+		$this->user_id = intval($post->post_author);
46
+		$this->setProperties($post);
47
+		$this->setTermIds($post);
48
+	}
49 49
 
50
-    /**
51
-     * @return mixed
52
-     */
53
-    public function __get($key)
54
-    {
55
-        return $this->offsetGet($key);
56
-    }
50
+	/**
51
+	 * @return mixed
52
+	 */
53
+	public function __get($key)
54
+	{
55
+		return $this->offsetGet($key);
56
+	}
57 57
 
58
-    /**
59
-     * @return string
60
-     */
61
-    public function __toString()
62
-    {
63
-        return (string) $this->build();
64
-    }
58
+	/**
59
+	 * @return string
60
+	 */
61
+	public function __toString()
62
+	{
63
+		return (string) $this->build();
64
+	}
65 65
 
66
-    /**
67
-     * @return ReviewHtml
68
-     */
69
-    public function build(array $args = [])
70
-    {
71
-        if (empty($this->ID)) {
72
-            return new ReviewHtml($this);
73
-        }
74
-        $partial = glsr(SiteReviewsPartial::class);
75
-        $partial->args = glsr(SiteReviewsDefaults::class)->merge($args);
76
-        $partial->options = glsr(Helper::class)->flattenArray(glsr(OptionManager::class)->all());
77
-        return $partial->buildReview($this);
78
-    }
66
+	/**
67
+	 * @return ReviewHtml
68
+	 */
69
+	public function build(array $args = [])
70
+	{
71
+		if (empty($this->ID)) {
72
+			return new ReviewHtml($this);
73
+		}
74
+		$partial = glsr(SiteReviewsPartial::class);
75
+		$partial->args = glsr(SiteReviewsDefaults::class)->merge($args);
76
+		$partial->options = glsr(Helper::class)->flattenArray(glsr(OptionManager::class)->all());
77
+		return $partial->buildReview($this);
78
+	}
79 79
 
80
-    /**
81
-     * @param mixed $key
82
-     * @return bool
83
-     */
84
-    public function offsetExists($key)
85
-    {
86
-        return property_exists($this, $key) || array_key_exists($key, (array) $this->custom);
87
-    }
80
+	/**
81
+	 * @param mixed $key
82
+	 * @return bool
83
+	 */
84
+	public function offsetExists($key)
85
+	{
86
+		return property_exists($this, $key) || array_key_exists($key, (array) $this->custom);
87
+	}
88 88
 
89
-    /**
90
-     * @param mixed $key
91
-     * @return mixed
92
-     */
93
-    public function offsetGet($key)
94
-    {
95
-        return property_exists($this, $key)
96
-            ? $this->$key
97
-            : glsr_get($this->custom, $key, null);
98
-    }
89
+	/**
90
+	 * @param mixed $key
91
+	 * @return mixed
92
+	 */
93
+	public function offsetGet($key)
94
+	{
95
+		return property_exists($this, $key)
96
+			? $this->$key
97
+			: glsr_get($this->custom, $key, null);
98
+	}
99 99
 
100
-    /**
101
-     * @param mixed $key
102
-     * @param mixed $value
103
-     * @return void
104
-     */
105
-    public function offsetSet($key, $value)
106
-    {
107
-        if (property_exists($this, $key)) {
108
-            $this->$key = $value;
109
-            return;
110
-        }
111
-        if (!is_array($this->custom)) {
112
-            $this->custom = array_filter((array) $this->custom);
113
-        }
114
-        $this->custom[$key] = $value;
115
-    }
100
+	/**
101
+	 * @param mixed $key
102
+	 * @param mixed $value
103
+	 * @return void
104
+	 */
105
+	public function offsetSet($key, $value)
106
+	{
107
+		if (property_exists($this, $key)) {
108
+			$this->$key = $value;
109
+			return;
110
+		}
111
+		if (!is_array($this->custom)) {
112
+			$this->custom = array_filter((array) $this->custom);
113
+		}
114
+		$this->custom[$key] = $value;
115
+	}
116 116
 
117
-    /**
118
-     * @param mixed $key
119
-     * @return void
120
-     */
121
-    public function offsetUnset($key)
122
-    {
123
-        $this->offsetSet($key, null);
124
-    }
117
+	/**
118
+	 * @param mixed $key
119
+	 * @return void
120
+	 */
121
+	public function offsetUnset($key)
122
+	{
123
+		$this->offsetSet($key, null);
124
+	}
125 125
 
126
-    /**
127
-     * @return void
128
-     */
129
-    public function render()
130
-    {
131
-        echo $this->build();
132
-    }
126
+	/**
127
+	 * @return void
128
+	 */
129
+	public function render()
130
+	{
131
+		echo $this->build();
132
+	}
133 133
 
134
-    /**
135
-     * @return bool
136
-     */
137
-    protected function isModified(array $properties)
138
-    {
139
-        return $this->date != $properties['date']
140
-            || $this->content != $properties['content']
141
-            || $this->title != $properties['title'];
142
-    }
134
+	/**
135
+	 * @return bool
136
+	 */
137
+	protected function isModified(array $properties)
138
+	{
139
+		return $this->date != $properties['date']
140
+			|| $this->content != $properties['content']
141
+			|| $this->title != $properties['title'];
142
+	}
143 143
 
144
-    /**
145
-     * @return void
146
-     */
147
-    protected function setProperties(WP_Post $post)
148
-    {
149
-        $defaults = [
150
-            'author' => __('Anonymous', 'site-reviews'),
151
-            'date' => '',
152
-            'review_id' => '',
153
-            'review_type' => 'local',
154
-        ];
155
-        $meta = array_filter(
156
-            array_map('array_shift', array_filter((array) get_post_meta($post->ID))),
157
-            'strlen'
158
-        );
159
-        $meta = array_merge($defaults, glsr(Helper::class)->unprefixArrayKeys($meta));
160
-        $properties = glsr(CreateReviewDefaults::class)->restrict(array_merge($defaults, $meta));
161
-        $this->modified = $this->isModified($properties);
162
-        array_walk($properties, function ($value, $key) {
163
-            if (!property_exists($this, $key) || isset($this->$key)) {
164
-                return;
165
-            }
166
-            $this->$key = maybe_unserialize($value);
167
-        });
168
-    }
144
+	/**
145
+	 * @return void
146
+	 */
147
+	protected function setProperties(WP_Post $post)
148
+	{
149
+		$defaults = [
150
+			'author' => __('Anonymous', 'site-reviews'),
151
+			'date' => '',
152
+			'review_id' => '',
153
+			'review_type' => 'local',
154
+		];
155
+		$meta = array_filter(
156
+			array_map('array_shift', array_filter((array) get_post_meta($post->ID))),
157
+			'strlen'
158
+		);
159
+		$meta = array_merge($defaults, glsr(Helper::class)->unprefixArrayKeys($meta));
160
+		$properties = glsr(CreateReviewDefaults::class)->restrict(array_merge($defaults, $meta));
161
+		$this->modified = $this->isModified($properties);
162
+		array_walk($properties, function ($value, $key) {
163
+			if (!property_exists($this, $key) || isset($this->$key)) {
164
+				return;
165
+			}
166
+			$this->$key = maybe_unserialize($value);
167
+		});
168
+	}
169 169
 
170
-    /**
171
-     * @return void
172
-     */
173
-    protected function setTermIds(WP_Post $post)
174
-    {
175
-        $this->term_ids = [];
176
-        if (!is_array($terms = get_the_terms($post, Application::TAXONOMY))) {
177
-            return;
178
-        }
179
-        foreach ($terms as $term) {
180
-            $this->term_ids[] = $term->term_id;
181
-        }
182
-    }
170
+	/**
171
+	 * @return void
172
+	 */
173
+	protected function setTermIds(WP_Post $post)
174
+	{
175
+		$this->term_ids = [];
176
+		if (!is_array($terms = get_the_terms($post, Application::TAXONOMY))) {
177
+			return;
178
+		}
179
+		foreach ($terms as $term) {
180
+			$this->term_ids[] = $term->term_id;
181
+		}
182
+	}
183 183
 }
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -32,27 +32,27 @@  discard block
 block discarded – undo
32 32
     public $url;
33 33
     public $user_id;
34 34
 
35
-    public function __construct(WP_Post $post)
35
+    public function __construct( WP_Post $post )
36 36
     {
37
-        if (Application::POST_TYPE != $post->post_type) {
37
+        if( Application::POST_TYPE != $post->post_type ) {
38 38
             return;
39 39
         }
40 40
         $this->content = $post->post_content;
41 41
         $this->date = $post->post_date;
42
-        $this->ID = intval($post->ID);
42
+        $this->ID = intval( $post->ID );
43 43
         $this->status = $post->post_status;
44 44
         $this->title = $post->post_title;
45
-        $this->user_id = intval($post->post_author);
46
-        $this->setProperties($post);
47
-        $this->setTermIds($post);
45
+        $this->user_id = intval( $post->post_author );
46
+        $this->setProperties( $post );
47
+        $this->setTermIds( $post );
48 48
     }
49 49
 
50 50
     /**
51 51
      * @return mixed
52 52
      */
53
-    public function __get($key)
53
+    public function __get( $key )
54 54
     {
55
-        return $this->offsetGet($key);
55
+        return $this->offsetGet( $key );
56 56
     }
57 57
 
58 58
     /**
@@ -60,41 +60,41 @@  discard block
 block discarded – undo
60 60
      */
61 61
     public function __toString()
62 62
     {
63
-        return (string) $this->build();
63
+        return (string)$this->build();
64 64
     }
65 65
 
66 66
     /**
67 67
      * @return ReviewHtml
68 68
      */
69
-    public function build(array $args = [])
69
+    public function build( array $args = [] )
70 70
     {
71
-        if (empty($this->ID)) {
72
-            return new ReviewHtml($this);
71
+        if( empty($this->ID) ) {
72
+            return new ReviewHtml( $this );
73 73
         }
74
-        $partial = glsr(SiteReviewsPartial::class);
75
-        $partial->args = glsr(SiteReviewsDefaults::class)->merge($args);
76
-        $partial->options = glsr(Helper::class)->flattenArray(glsr(OptionManager::class)->all());
77
-        return $partial->buildReview($this);
74
+        $partial = glsr( SiteReviewsPartial::class );
75
+        $partial->args = glsr( SiteReviewsDefaults::class )->merge( $args );
76
+        $partial->options = glsr( Helper::class )->flattenArray( glsr( OptionManager::class )->all() );
77
+        return $partial->buildReview( $this );
78 78
     }
79 79
 
80 80
     /**
81 81
      * @param mixed $key
82 82
      * @return bool
83 83
      */
84
-    public function offsetExists($key)
84
+    public function offsetExists( $key )
85 85
     {
86
-        return property_exists($this, $key) || array_key_exists($key, (array) $this->custom);
86
+        return property_exists( $this, $key ) || array_key_exists( $key, (array)$this->custom );
87 87
     }
88 88
 
89 89
     /**
90 90
      * @param mixed $key
91 91
      * @return mixed
92 92
      */
93
-    public function offsetGet($key)
93
+    public function offsetGet( $key )
94 94
     {
95
-        return property_exists($this, $key)
95
+        return property_exists( $this, $key )
96 96
             ? $this->$key
97
-            : glsr_get($this->custom, $key, null);
97
+            : glsr_get( $this->custom, $key, null );
98 98
     }
99 99
 
100 100
     /**
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
      * @param mixed $value
103 103
      * @return void
104 104
      */
105
-    public function offsetSet($key, $value)
105
+    public function offsetSet( $key, $value )
106 106
     {
107
-        if (property_exists($this, $key)) {
107
+        if( property_exists( $this, $key ) ) {
108 108
             $this->$key = $value;
109 109
             return;
110 110
         }
111
-        if (!is_array($this->custom)) {
112
-            $this->custom = array_filter((array) $this->custom);
111
+        if( !is_array( $this->custom ) ) {
112
+            $this->custom = array_filter( (array)$this->custom );
113 113
         }
114 114
         $this->custom[$key] = $value;
115 115
     }
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
      * @param mixed $key
119 119
      * @return void
120 120
      */
121
-    public function offsetUnset($key)
121
+    public function offsetUnset( $key )
122 122
     {
123
-        $this->offsetSet($key, null);
123
+        $this->offsetSet( $key, null );
124 124
     }
125 125
 
126 126
     /**
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
     /**
135 135
      * @return bool
136 136
      */
137
-    protected function isModified(array $properties)
137
+    protected function isModified( array $properties )
138 138
     {
139 139
         return $this->date != $properties['date']
140 140
             || $this->content != $properties['content']
@@ -144,39 +144,39 @@  discard block
 block discarded – undo
144 144
     /**
145 145
      * @return void
146 146
      */
147
-    protected function setProperties(WP_Post $post)
147
+    protected function setProperties( WP_Post $post )
148 148
     {
149 149
         $defaults = [
150
-            'author' => __('Anonymous', 'site-reviews'),
150
+            'author' => __( 'Anonymous', 'site-reviews' ),
151 151
             'date' => '',
152 152
             'review_id' => '',
153 153
             'review_type' => 'local',
154 154
         ];
155 155
         $meta = array_filter(
156
-            array_map('array_shift', array_filter((array) get_post_meta($post->ID))),
156
+            array_map( 'array_shift', array_filter( (array)get_post_meta( $post->ID ) ) ),
157 157
             'strlen'
158 158
         );
159
-        $meta = array_merge($defaults, glsr(Helper::class)->unprefixArrayKeys($meta));
160
-        $properties = glsr(CreateReviewDefaults::class)->restrict(array_merge($defaults, $meta));
161
-        $this->modified = $this->isModified($properties);
162
-        array_walk($properties, function ($value, $key) {
163
-            if (!property_exists($this, $key) || isset($this->$key)) {
159
+        $meta = array_merge( $defaults, glsr( Helper::class )->unprefixArrayKeys( $meta ) );
160
+        $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta ) );
161
+        $this->modified = $this->isModified( $properties );
162
+        array_walk( $properties, function( $value, $key ) {
163
+            if( !property_exists( $this, $key ) || isset($this->$key) ) {
164 164
                 return;
165 165
             }
166
-            $this->$key = maybe_unserialize($value);
166
+            $this->$key = maybe_unserialize( $value );
167 167
         });
168 168
     }
169 169
 
170 170
     /**
171 171
      * @return void
172 172
      */
173
-    protected function setTermIds(WP_Post $post)
173
+    protected function setTermIds( WP_Post $post )
174 174
     {
175 175
         $this->term_ids = [];
176
-        if (!is_array($terms = get_the_terms($post, Application::TAXONOMY))) {
176
+        if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY ) ) ) {
177 177
             return;
178 178
         }
179
-        foreach ($terms as $term) {
179
+        foreach( $terms as $term ) {
180 180
             $this->term_ids[] = $term->term_id;
181 181
         }
182 182
     }
Please login to merge, or discard this patch.
views/pages/welcome/support.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1
-<?php defined('WPINC') || die; ?>
1
+<?php defined( 'WPINC' ) || die; ?>
2 2
 
3 3
 <p class="about-description">
4
-    Still need help with <?= glsr()->name; ?>? We offer excellent support for you. But don't forget to check our <a href="<?= admin_url('edit.php?post_type=site-review&page=documentation#!shortcodes'); ?>">documentation</a> first.
4
+    Still need help with <?= glsr()->name; ?>? We offer excellent support for you. But don't forget to check our <a href="<?= admin_url( 'edit.php?post_type=site-review&page=documentation#!shortcodes' ); ?>">documentation</a> first.
5 5
 </p>
6 6
 <div class="is-fullwidth">
7 7
     <div class="glsr-flex-row glsr-has-2-columns">
Please login to merge, or discard this patch.
views/pages/welcome/getting-started.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@  discard block
 block discarded – undo
1
-<?php defined('WPINC') || die; ?>
1
+<?php defined( 'WPINC' ) || die; ?>
2 2
 
3 3
 <div class="is-fullwidth">
4 4
     <div class="glsr-flex-row glsr-has-2-columns">
5 5
         <div class="glsr-column">
6 6
             <h3>Editor Blocks</h3>
7 7
             <p>The fastest way to getting started with Site Reviews is use the three provided blocks in the WordPress Block Editor. Each block comes with multiple settings which let you configure the block exactly as needed. To add a block to your page, click the "Add Block" button and search for "Site Reviews".</p>
8
-            <img class="screenshot" src="<?= glsr()->url('assets/images/blocks.png'); ?>" alt="Editor Blocks" />
8
+            <img class="screenshot" src="<?= glsr()->url( 'assets/images/blocks.png' ); ?>" alt="Editor Blocks" />
9 9
         </div>
10 10
         <div class="glsr-column">
11 11
             <h3>Shortcodes and Widgets</h3>
12 12
             <p>You can also use the shortcodes or widgets on your page. Keep in mind, however, that widgets are limited in options compared to the shortcodes (for example, the "Latest Reviews" widget does not allow pagination). If you are using the Classic Editor in WordPress, you can click on the Site Reviews shortcode button above the editor (next to the media button) to add a shortcode via a friendly popup.</p>
13 13
             <p>To learn more about the shortcodes and the available shortcode options, please see the Shortcode Documentation page of the plugin.</p>
14
-            <a class="button" href="<?= admin_url('edit.php?post_type=site-review&page=documentation#!shortcodes'); ?>">View Shortcode Documentation</a>
14
+            <a class="button" href="<?= admin_url( 'edit.php?post_type=site-review&page=documentation#!shortcodes' ); ?>">View Shortcode Documentation</a>
15 15
         </div>
16 16
     </div>
17 17
 </div>
@@ -20,31 +20,31 @@  discard block
 block discarded – undo
20 20
     <h2>Features</h2>
21 21
     <ul class="glsr-flex-row glsr-has-3-columns">
22 22
         <li class="glsr-column">
23
-            <h3><a href="<?= admin_url('edit.php?post_type=site-review&page=addons'); ?>">Add-ons</a></h3>
23
+            <h3><a href="<?= admin_url( 'edit.php?post_type=site-review&page=addons' ); ?>">Add-ons</a></h3>
24 24
             <p>Extend Site Reviews with add-ons that provide additional features.</p>
25 25
         </li>
26 26
         <li class="glsr-column">
27
-            <h3><a href="<?= admin_url('edit.php?post_type=site-review&page=settings#!reviews'); ?>">Avatars</a></h3>
27
+            <h3><a href="<?= admin_url( 'edit.php?post_type=site-review&page=settings#!reviews' ); ?>">Avatars</a></h3>
28 28
             <p>Enable avatars to generate images using the WordPress Gravatar service.</p>
29 29
         </li>
30 30
         <li class="glsr-column">
31
-            <h3><a href="<?= admin_url('edit.php?post_type=site-review&page=tools#!general'); ?>">Backup/Restore</a></h3>
31
+            <h3><a href="<?= admin_url( 'edit.php?post_type=site-review&page=tools#!general' ); ?>">Backup/Restore</a></h3>
32 32
             <p>Backup and restore your plugin settings as needed.</p>
33 33
         </li>
34 34
         <li class="glsr-column">
35
-            <h3><a data-expand="#faq-14" href="<?= admin_url('edit.php?post_type=site-review&page=documentation#!faq'); ?>">Bayesian Ranking</a></h3>
35
+            <h3><a data-expand="#faq-14" href="<?= admin_url( 'edit.php?post_type=site-review&page=documentation#!faq' ); ?>">Bayesian Ranking</a></h3>
36 36
             <p>Easily rank pages with assigned reviews using the bayesian algorithm.</p>
37 37
         </li>
38 38
         <li class="glsr-column">
39
-            <h3><a href="<?= admin_url('edit.php?post_type=site-review&page=settings#!submissions'); ?>">Blacklist</a></h3>
39
+            <h3><a href="<?= admin_url( 'edit.php?post_type=site-review&page=settings#!submissions' ); ?>">Blacklist</a></h3>
40 40
             <p>Blacklist words, phrases, IP addresses, names, and emails.</p>
41 41
         </li>
42 42
         <li class="glsr-column">
43
-            <h3><a href="<?= admin_url('edit.php?post_type=site-review&page=settings#!general'); ?>">Blockchain Validation</a></h3>
43
+            <h3><a href="<?= admin_url( 'edit.php?post_type=site-review&page=settings#!general' ); ?>">Blockchain Validation</a></h3>
44 44
             <p>Verify your reviews on the Blockchain with <a href="https://rebusify.com?ref=105">Rebusify</a>.</p>
45 45
         </li>
46 46
         <li class="glsr-column">
47
-            <h3><a href="<?= admin_url('edit-tags.php?taxonomy=site-review-category&post_type=site-review'); ?>">Categories</a></h3>
47
+            <h3><a href="<?= admin_url( 'edit-tags.php?taxonomy=site-review-category&post_type=site-review' ); ?>">Categories</a></h3>
48 48
             <p>Add your own categories and assign reviews to them.</p>
49 49
         </li>
50 50
         <li class="glsr-column">
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
             <p>Designed for WordPress developers with over 100 filter hooks and convenient functions.</p>
53 53
         </li>
54 54
         <li class="glsr-column">
55
-            <h3><a href="<?= admin_url('edit.php?post_type=site-review&page=documentation#!faq'); ?>">Documentation</a></h3>
55
+            <h3><a href="<?= admin_url( 'edit.php?post_type=site-review&page=documentation#!faq' ); ?>">Documentation</a></h3>
56 56
             <p>Provides FAQ and documenation for hooks and all shortcodes and functions.</p>
57 57
         </li>
58 58
         <li class="glsr-column">
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
             <p>Use configurable editor blocks in the new WordPress 5.0 editor.</p>
61 61
         </li>
62 62
         <li class="glsr-column">
63
-            <h3><a href="<?= admin_url('edit.php?post_type=site-review&page=settings#!schema'); ?>">JSON-LD Schema</a></h3>
63
+            <h3><a href="<?= admin_url( 'edit.php?post_type=site-review&page=settings#!schema' ); ?>">JSON-LD Schema</a></h3>
64 64
             <p>Enable JSON-LD schema to display your reviews and ratings in search results.</p>
65 65
         </li>
66 66
         <li class="glsr-column">
67
-            <h3><a href="<?= admin_url('edit.php?post_type=site-review&page=settings#!general'); ?>">Multilingual</a></h3>
67
+            <h3><a href="<?= admin_url( 'edit.php?post_type=site-review&page=settings#!general' ); ?>">Multilingual</a></h3>
68 68
             <p>Integrates with Polylang and WPML and provides easy search/replace translation.</p>
69 69
         </li>
70 70
         <li class="glsr-column">
@@ -72,47 +72,47 @@  discard block
 block discarded – undo
72 72
             <p>Provides full support for the WordPress multisite feature.</p>
73 73
         </li>
74 74
         <li class="glsr-column">
75
-            <h3><a href="<?= admin_url('edit.php?post_type=site-review&page=settings#!general'); ?>">Notifications</a></h3>
75
+            <h3><a href="<?= admin_url( 'edit.php?post_type=site-review&page=settings#!general' ); ?>">Notifications</a></h3>
76 76
             <p>Send notifications to one or more emails when a review is submitted.</p>
77 77
         </li>
78 78
         <li class="glsr-column">
79
-            <h3><a data-expand="#faq-03" href="<?= admin_url('edit.php?post_type=site-review&page=documentation#!faq'); ?>">Page Assignment</a></h3>
79
+            <h3><a data-expand="#faq-03" href="<?= admin_url( 'edit.php?post_type=site-review&page=documentation#!faq' ); ?>">Page Assignment</a></h3>
80 80
             <p>Assign reviews to Posts, Pages, and Custom Post Types.</p>
81 81
         </li>
82 82
         <li class="glsr-column">
83
-            <h3><a data-expand="#faq-02" href="<?= admin_url('edit.php?post_type=site-review&page=documentation#!faq'); ?>">Pagination</a></h3>
83
+            <h3><a data-expand="#faq-02" href="<?= admin_url( 'edit.php?post_type=site-review&page=documentation#!faq' ); ?>">Pagination</a></h3>
84 84
             <p>Enable AJAX pagination to display a custom number of reviews per-page.</p>
85 85
         </li>
86 86
         <li class="glsr-column">
87
-            <h3><a href="<?= admin_url('edit.php?post_type=site-review'); ?>">Responses</a></h3>
87
+            <h3><a href="<?= admin_url( 'edit.php?post_type=site-review' ); ?>">Responses</a></h3>
88 88
             <p>Write a response to reviews that require a response.</p>
89 89
         </li>
90 90
         <li class="glsr-column">
91
-            <h3><a href="<?= admin_url('edit.php?post_type=site-review&page=settings#!general'); ?>">Restrictions</a></h3>
91
+            <h3><a href="<?= admin_url( 'edit.php?post_type=site-review&page=settings#!general' ); ?>">Restrictions</a></h3>
92 92
             <p>Require approval before publishing reviews and limit to registered users.</p>
93 93
         </li>
94 94
         <li class="glsr-column">
95
-            <h3><a href="<?= admin_url('edit.php?post_type=site-review&page=settings#!submissions'); ?>">Review Limits</a></h3>
95
+            <h3><a href="<?= admin_url( 'edit.php?post_type=site-review&page=settings#!submissions' ); ?>">Review Limits</a></h3>
96 96
             <p>Limit review submissions by email address, IP address, or username.</p>
97 97
         </li>
98 98
         <li class="glsr-column">
99
-            <h3><a href="<?= admin_url('edit.php?post_type=site-review&page=documentation#!shortcodes'); ?>">Review Summaries</a></h3>
99
+            <h3><a href="<?= admin_url( 'edit.php?post_type=site-review&page=documentation#!shortcodes' ); ?>">Review Summaries</a></h3>
100 100
             <p>Display a summary of your review ratings from high to low.</p>
101 101
         </li>
102 102
         <li class="glsr-column">
103
-            <h3><a href="<?= admin_url('edit.php?post_type=site-review&page=documentation#!shortcodes'); ?>">Shortcodes</a></h3>
103
+            <h3><a href="<?= admin_url( 'edit.php?post_type=site-review&page=documentation#!shortcodes' ); ?>">Shortcodes</a></h3>
104 104
             <p>Use the configurable shortcodes complete with documentation.</p>
105 105
         </li>
106 106
         <li class="glsr-column">
107
-            <h3><a href="<?= admin_url('edit.php?post_type=site-review&page=settings#!general'); ?>">Slack</a></h3>
107
+            <h3><a href="<?= admin_url( 'edit.php?post_type=site-review&page=settings#!general' ); ?>">Slack</a></h3>
108 108
             <p>Receive notifications in Slack when a review is submitted.</p>
109 109
         </li>
110 110
         <li class="glsr-column">
111
-            <h3><a href="<?= admin_url('edit.php?post_type=site-review&page=settings#!submissions'); ?>">SPAM Protection</a></h3>
111
+            <h3><a href="<?= admin_url( 'edit.php?post_type=site-review&page=settings#!submissions' ); ?>">SPAM Protection</a></h3>
112 112
             <p>Uses a Honeypot and integrates with Invisible reCAPTCHA and Akismet.</p>
113 113
         </li>
114 114
         <li class="glsr-column">
115
-            <h3><a href="<?= admin_url('edit.php?post_type=site-review&page=settings#!general'); ?>">Styles</a></h3>
115
+            <h3><a href="<?= admin_url( 'edit.php?post_type=site-review&page=settings#!general' ); ?>">Styles</a></h3>
116 116
             <p>Change the submission form style to match popular themes and form plugins.</p>
117 117
         </li>
118 118
         <li class="glsr-column">
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
             <p>Free premium-level support included on the WordPress support forum.</p>
121 121
         </li>
122 122
         <li class="glsr-column">
123
-            <h3><a data-expand="#faq-17" href="<?= admin_url('edit.php?post_type=site-review&page=documentation#!faq'); ?>">Templates</a></h3>
123
+            <h3><a data-expand="#faq-17" href="<?= admin_url( 'edit.php?post_type=site-review&page=documentation#!faq' ); ?>">Templates</a></h3>
124 124
             <p>Use the Site Reviews templates in your theme for full control over the HTML.</p>
125 125
         </li>
126 126
         <li class="glsr-column">
127
-            <h3><a href="<?= admin_url('widgets.php'); ?>">Widgets</a></h3>
127
+            <h3><a href="<?= admin_url( 'widgets.php' ); ?>">Widgets</a></h3>
128 128
             <p>Use the configurable widgets in your sidebars.</p>
129 129
         </li>
130 130
     </ul>
Please login to merge, or discard this patch.
views/pages/settings/index.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@
 block discarded – undo
1
-<?php defined('WPINC') || die; ?>
1
+<?php defined( 'WPINC' ) || die; ?>
2 2
 
3 3
 <div class="wrap">
4
-    <h1 class="wp-heading-inline"><?= esc_html(get_admin_page_title()); ?></h1>
4
+    <h1 class="wp-heading-inline"><?= esc_html( get_admin_page_title() ); ?></h1>
5 5
     <?= $notices; ?>
6 6
     <h2 class="glsr-nav-tab-wrapper nav-tab-wrapper">
7
-        <?php foreach ($tabs as $id => $title) : ?>
7
+        <?php foreach( $tabs as $id => $title ) : ?>
8 8
         <a class="glsr-nav-tab nav-tab" href="#<?= $id; ?>"><?= $title; ?></a>
9 9
         <?php endforeach; ?>
10 10
     </h2>
11 11
     <form class="glsr-form" action="options.php" enctype="multipart/form-data" method="post">
12
-        <?php foreach ($tabs as $id => $title) : ?>
12
+        <?php foreach( $tabs as $id => $title ) : ?>
13 13
         <div class="glsr-nav-view ui-tabs-hide" id="<?= $id; ?>">
14
-            <?= $settings->buildFields($id); ?>
14
+            <?= $settings->buildFields( $id ); ?>
15 15
         </div>
16 16
         <?php endforeach; ?>
17 17
         <input type="hidden" name="_active_tab">
18
-        <?php settings_fields(glsr()->id.'-settings'); ?>
18
+        <?php settings_fields( glsr()->id.'-settings' ); ?>
19 19
         <?php submit_button(); ?>
20 20
     </form>
21 21
 </div>
Please login to merge, or discard this patch.
views/pages/tools/index.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
1
-<?php defined('WPINC') || die; ?>
1
+<?php defined( 'WPINC' ) || die; ?>
2 2
 
3 3
 <div class="wrap">
4
-    <h1 class="wp-heading-inline"><?= esc_html(get_admin_page_title()); ?></h1>
4
+    <h1 class="wp-heading-inline"><?= esc_html( get_admin_page_title() ); ?></h1>
5 5
     <?= $notices; ?>
6 6
     <h2 class="glsr-nav-tab-wrapper nav-tab-wrapper">
7
-        <?php foreach ($tabs as $id => $title) : ?>
7
+        <?php foreach( $tabs as $id => $title ) : ?>
8 8
         <a class="glsr-nav-tab nav-tab" href="#<?= $id; ?>"><?= $title; ?></a>
9 9
         <?php endforeach; ?>
10 10
     </h2>
11
-    <?php foreach ($tabs as $id => $title) : ?>
11
+    <?php foreach( $tabs as $id => $title ) : ?>
12 12
     <div class="glsr-nav-view ui-tabs-hide" id="<?= $id; ?>">
13
-        <?php $template->render('pages/tools/'.$id, $data); ?>
13
+        <?php $template->render( 'pages/tools/'.$id, $data ); ?>
14 14
     </div>
15 15
     <?php endforeach; ?>
16 16
     <input type="hidden" name="_active_tab">
Please login to merge, or discard this patch.