Passed
Push — master ( 6b35fa...ccb079 )
by Paul
10:24 queued 05:13
created
plugin/Commands/CreateReview.php 2 patches
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -6,145 +6,145 @@
 block discarded – undo
6 6
 
7 7
 class CreateReview
8 8
 {
9
-    public $ajax_request;
10
-    public $assigned_to;
11
-    public $author;
12
-    public $avatar;
13
-    public $blacklisted;
14
-    public $category;
15
-    public $content;
16
-    public $custom;
17
-    public $date;
18
-    public $email;
19
-    public $form_id;
20
-    public $ip_address;
21
-    public $post_id;
22
-    public $rating;
23
-    public $referer;
24
-    public $request;
25
-    public $response;
26
-    public $terms;
27
-    public $title;
28
-    public $url;
9
+	public $ajax_request;
10
+	public $assigned_to;
11
+	public $author;
12
+	public $avatar;
13
+	public $blacklisted;
14
+	public $category;
15
+	public $content;
16
+	public $custom;
17
+	public $date;
18
+	public $email;
19
+	public $form_id;
20
+	public $ip_address;
21
+	public $post_id;
22
+	public $rating;
23
+	public $referer;
24
+	public $request;
25
+	public $response;
26
+	public $terms;
27
+	public $title;
28
+	public $url;
29 29
 
30
-    public function __construct($input)
31
-    {
32
-        $this->request = $input;
33
-        $this->ajax_request = isset($input['_ajax_request']);
34
-        $this->assigned_to = $this->getNumeric('assign_to');
35
-        $this->author = sanitize_text_field($this->getUser('name'));
36
-        $this->avatar = $this->getAvatar();
37
-        $this->blacklisted = isset($input['blacklisted']);
38
-        $this->category = $this->getCategory();
39
-        $this->content = sanitize_textarea_field($this->get('content'));
40
-        $this->custom = $this->getCustom();
41
-        $this->date = $this->getDate('date');
42
-        $this->email = sanitize_email($this->getUser('email'));
43
-        $this->form_id = sanitize_key($this->get('form_id'));
44
-        $this->ip_address = $this->get('ip_address');
45
-        $this->post_id = intval($this->get('_post_id'));
46
-        $this->rating = intval($this->get('rating'));
47
-        $this->referer = sanitize_text_field($this->get('_referer'));
48
-        $this->response = sanitize_textarea_field($this->get('response'));
49
-        $this->terms = !empty($input['terms']);
50
-        $this->title = sanitize_text_field($this->get('title'));
51
-        $this->url = esc_url_raw(sanitize_text_field($this->get('url')));
52
-    }
30
+	public function __construct($input)
31
+	{
32
+		$this->request = $input;
33
+		$this->ajax_request = isset($input['_ajax_request']);
34
+		$this->assigned_to = $this->getNumeric('assign_to');
35
+		$this->author = sanitize_text_field($this->getUser('name'));
36
+		$this->avatar = $this->getAvatar();
37
+		$this->blacklisted = isset($input['blacklisted']);
38
+		$this->category = $this->getCategory();
39
+		$this->content = sanitize_textarea_field($this->get('content'));
40
+		$this->custom = $this->getCustom();
41
+		$this->date = $this->getDate('date');
42
+		$this->email = sanitize_email($this->getUser('email'));
43
+		$this->form_id = sanitize_key($this->get('form_id'));
44
+		$this->ip_address = $this->get('ip_address');
45
+		$this->post_id = intval($this->get('_post_id'));
46
+		$this->rating = intval($this->get('rating'));
47
+		$this->referer = sanitize_text_field($this->get('_referer'));
48
+		$this->response = sanitize_textarea_field($this->get('response'));
49
+		$this->terms = !empty($input['terms']);
50
+		$this->title = sanitize_text_field($this->get('title'));
51
+		$this->url = esc_url_raw(sanitize_text_field($this->get('url')));
52
+	}
53 53
 
54
-    /**
55
-     * @param string $key
56
-     * @return string
57
-     */
58
-    protected function get($key)
59
-    {
60
-        return (string) Arr::get($this->request, $key);
61
-    }
54
+	/**
55
+	 * @param string $key
56
+	 * @return string
57
+	 */
58
+	protected function get($key)
59
+	{
60
+		return (string) Arr::get($this->request, $key);
61
+	}
62 62
 
63
-    /**
64
-     * @return string
65
-     */
66
-    protected function getAvatar()
67
-    {
68
-        $avatar = $this->get('avatar');
69
-        return !filter_var($avatar, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)
70
-            ? (string) get_avatar_url($this->get('email'))
71
-            : $avatar;
72
-    }
63
+	/**
64
+	 * @return string
65
+	 */
66
+	protected function getAvatar()
67
+	{
68
+		$avatar = $this->get('avatar');
69
+		return !filter_var($avatar, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)
70
+			? (string) get_avatar_url($this->get('email'))
71
+			: $avatar;
72
+	}
73 73
 
74
-    /**
75
-     * @return string
76
-     */
77
-    protected function getCategory()
78
-    {
79
-        $categories = Arr::convertStringToArray($this->get('category'));
80
-        return sanitize_key(Arr::get($categories, 0));
81
-    }
74
+	/**
75
+	 * @return string
76
+	 */
77
+	protected function getCategory()
78
+	{
79
+		$categories = Arr::convertStringToArray($this->get('category'));
80
+		return sanitize_key(Arr::get($categories, 0));
81
+	}
82 82
 
83
-    /**
84
-     * @return array
85
-     */
86
-    protected function getCustom()
87
-    {
88
-        $unset = [
89
-            '_action', '_ajax_request', '_counter', '_nonce', '_post_id', '_recaptcha-token',
90
-            '_referer', 'assign_to', 'category', 'content', 'date', 'email', 'excluded', 'form_id',
91
-            'gotcha', 'ip_address', 'name', 'rating', 'response', 'terms', 'title', 'url',
92
-        ];
93
-        $unset = apply_filters('site-reviews/create/unset-keys-from-custom', $unset);
94
-        $custom = $this->request;
95
-        foreach ($unset as $key) {
96
-            unset($custom[$key]);
97
-        }
98
-        foreach ($custom as $key => $value) {
99
-            if (is_string($value)) {
100
-                $custom[$key] = sanitize_text_field($value);
101
-            }
102
-        }
103
-        return $custom;
104
-    }
83
+	/**
84
+	 * @return array
85
+	 */
86
+	protected function getCustom()
87
+	{
88
+		$unset = [
89
+			'_action', '_ajax_request', '_counter', '_nonce', '_post_id', '_recaptcha-token',
90
+			'_referer', 'assign_to', 'category', 'content', 'date', 'email', 'excluded', 'form_id',
91
+			'gotcha', 'ip_address', 'name', 'rating', 'response', 'terms', 'title', 'url',
92
+		];
93
+		$unset = apply_filters('site-reviews/create/unset-keys-from-custom', $unset);
94
+		$custom = $this->request;
95
+		foreach ($unset as $key) {
96
+			unset($custom[$key]);
97
+		}
98
+		foreach ($custom as $key => $value) {
99
+			if (is_string($value)) {
100
+				$custom[$key] = sanitize_text_field($value);
101
+			}
102
+		}
103
+		return $custom;
104
+	}
105 105
 
106
-    /**
107
-     * @param string $key
108
-     * @return string
109
-     */
110
-    protected function getDate($key)
111
-    {
112
-        $date = strtotime($this->get($key));
113
-        if (false === $date) {
114
-            $date = time();
115
-        }
116
-        return get_date_from_gmt(gmdate('Y-m-d H:i:s', $date));
117
-    }
106
+	/**
107
+	 * @param string $key
108
+	 * @return string
109
+	 */
110
+	protected function getDate($key)
111
+	{
112
+		$date = strtotime($this->get($key));
113
+		if (false === $date) {
114
+			$date = time();
115
+		}
116
+		return get_date_from_gmt(gmdate('Y-m-d H:i:s', $date));
117
+	}
118 118
 
119
-    /**
120
-     * @param string $key
121
-     * @return string
122
-     */
123
-    protected function getUser($key)
124
-    {
125
-        $value = $this->get($key);
126
-        if (empty($value)) {
127
-            $user = wp_get_current_user();
128
-            $userValues = [
129
-                'email' => 'user_email',
130
-                'name' => 'display_name',
131
-            ];
132
-            if ($user->exists() && array_key_exists($key, $userValues)) {
133
-                return $user->{$userValues[$key]};
134
-            }
135
-        }
136
-        return $value;
137
-    }
119
+	/**
120
+	 * @param string $key
121
+	 * @return string
122
+	 */
123
+	protected function getUser($key)
124
+	{
125
+		$value = $this->get($key);
126
+		if (empty($value)) {
127
+			$user = wp_get_current_user();
128
+			$userValues = [
129
+				'email' => 'user_email',
130
+				'name' => 'display_name',
131
+			];
132
+			if ($user->exists() && array_key_exists($key, $userValues)) {
133
+				return $user->{$userValues[$key]};
134
+			}
135
+		}
136
+		return $value;
137
+	}
138 138
 
139
-    /**
140
-     * @param string $key
141
-     * @return string
142
-     */
143
-    protected function getNumeric($key)
144
-    {
145
-        $value = $this->get($key);
146
-        return is_numeric($value)
147
-            ? $value
148
-            : '';
149
-    }
139
+	/**
140
+	 * @param string $key
141
+	 * @return string
142
+	 */
143
+	protected function getNumeric($key)
144
+	{
145
+		$value = $this->get($key);
146
+		return is_numeric($value)
147
+			? $value
148
+			: '';
149
+	}
150 150
 }
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -27,37 +27,37 @@  discard block
 block discarded – undo
27 27
     public $title;
28 28
     public $url;
29 29
 
30
-    public function __construct($input)
30
+    public function __construct( $input )
31 31
     {
32 32
         $this->request = $input;
33 33
         $this->ajax_request = isset($input['_ajax_request']);
34
-        $this->assigned_to = $this->getNumeric('assign_to');
35
-        $this->author = sanitize_text_field($this->getUser('name'));
34
+        $this->assigned_to = $this->getNumeric( 'assign_to' );
35
+        $this->author = sanitize_text_field( $this->getUser( 'name' ) );
36 36
         $this->avatar = $this->getAvatar();
37 37
         $this->blacklisted = isset($input['blacklisted']);
38 38
         $this->category = $this->getCategory();
39
-        $this->content = sanitize_textarea_field($this->get('content'));
39
+        $this->content = sanitize_textarea_field( $this->get( 'content' ) );
40 40
         $this->custom = $this->getCustom();
41
-        $this->date = $this->getDate('date');
42
-        $this->email = sanitize_email($this->getUser('email'));
43
-        $this->form_id = sanitize_key($this->get('form_id'));
44
-        $this->ip_address = $this->get('ip_address');
45
-        $this->post_id = intval($this->get('_post_id'));
46
-        $this->rating = intval($this->get('rating'));
47
-        $this->referer = sanitize_text_field($this->get('_referer'));
48
-        $this->response = sanitize_textarea_field($this->get('response'));
41
+        $this->date = $this->getDate( 'date' );
42
+        $this->email = sanitize_email( $this->getUser( 'email' ) );
43
+        $this->form_id = sanitize_key( $this->get( 'form_id' ) );
44
+        $this->ip_address = $this->get( 'ip_address' );
45
+        $this->post_id = intval( $this->get( '_post_id' ) );
46
+        $this->rating = intval( $this->get( 'rating' ) );
47
+        $this->referer = sanitize_text_field( $this->get( '_referer' ) );
48
+        $this->response = sanitize_textarea_field( $this->get( 'response' ) );
49 49
         $this->terms = !empty($input['terms']);
50
-        $this->title = sanitize_text_field($this->get('title'));
51
-        $this->url = esc_url_raw(sanitize_text_field($this->get('url')));
50
+        $this->title = sanitize_text_field( $this->get( 'title' ) );
51
+        $this->url = esc_url_raw( sanitize_text_field( $this->get( 'url' ) ) );
52 52
     }
53 53
 
54 54
     /**
55 55
      * @param string $key
56 56
      * @return string
57 57
      */
58
-    protected function get($key)
58
+    protected function get( $key )
59 59
     {
60
-        return (string) Arr::get($this->request, $key);
60
+        return (string)Arr::get( $this->request, $key );
61 61
     }
62 62
 
63 63
     /**
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
      */
66 66
     protected function getAvatar()
67 67
     {
68
-        $avatar = $this->get('avatar');
69
-        return !filter_var($avatar, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)
70
-            ? (string) get_avatar_url($this->get('email'))
68
+        $avatar = $this->get( 'avatar' );
69
+        return !filter_var( $avatar, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED )
70
+            ? (string)get_avatar_url( $this->get( 'email' ) )
71 71
             : $avatar;
72 72
     }
73 73
 
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
      */
77 77
     protected function getCategory()
78 78
     {
79
-        $categories = Arr::convertStringToArray($this->get('category'));
80
-        return sanitize_key(Arr::get($categories, 0));
79
+        $categories = Arr::convertStringToArray( $this->get( 'category' ) );
80
+        return sanitize_key( Arr::get( $categories, 0 ) );
81 81
     }
82 82
 
83 83
     /**
@@ -90,14 +90,14 @@  discard block
 block discarded – undo
90 90
             '_referer', 'assign_to', 'category', 'content', 'date', 'email', 'excluded', 'form_id',
91 91
             'gotcha', 'ip_address', 'name', 'rating', 'response', 'terms', 'title', 'url',
92 92
         ];
93
-        $unset = apply_filters('site-reviews/create/unset-keys-from-custom', $unset);
93
+        $unset = apply_filters( 'site-reviews/create/unset-keys-from-custom', $unset );
94 94
         $custom = $this->request;
95
-        foreach ($unset as $key) {
95
+        foreach( $unset as $key ) {
96 96
             unset($custom[$key]);
97 97
         }
98
-        foreach ($custom as $key => $value) {
99
-            if (is_string($value)) {
100
-                $custom[$key] = sanitize_text_field($value);
98
+        foreach( $custom as $key => $value ) {
99
+            if( is_string( $value ) ) {
100
+                $custom[$key] = sanitize_text_field( $value );
101 101
             }
102 102
         }
103 103
         return $custom;
@@ -107,29 +107,29 @@  discard block
 block discarded – undo
107 107
      * @param string $key
108 108
      * @return string
109 109
      */
110
-    protected function getDate($key)
110
+    protected function getDate( $key )
111 111
     {
112
-        $date = strtotime($this->get($key));
113
-        if (false === $date) {
112
+        $date = strtotime( $this->get( $key ) );
113
+        if( false === $date ) {
114 114
             $date = time();
115 115
         }
116
-        return get_date_from_gmt(gmdate('Y-m-d H:i:s', $date));
116
+        return get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $date ) );
117 117
     }
118 118
 
119 119
     /**
120 120
      * @param string $key
121 121
      * @return string
122 122
      */
123
-    protected function getUser($key)
123
+    protected function getUser( $key )
124 124
     {
125
-        $value = $this->get($key);
126
-        if (empty($value)) {
125
+        $value = $this->get( $key );
126
+        if( empty($value) ) {
127 127
             $user = wp_get_current_user();
128 128
             $userValues = [
129 129
                 'email' => 'user_email',
130 130
                 'name' => 'display_name',
131 131
             ];
132
-            if ($user->exists() && array_key_exists($key, $userValues)) {
132
+            if( $user->exists() && array_key_exists( $key, $userValues ) ) {
133 133
                 return $user->{$userValues[$key]};
134 134
             }
135 135
         }
@@ -140,10 +140,10 @@  discard block
 block discarded – undo
140 140
      * @param string $key
141 141
      * @return string
142 142
      */
143
-    protected function getNumeric($key)
143
+    protected function getNumeric( $key )
144 144
     {
145
-        $value = $this->get($key);
146
-        return is_numeric($value)
145
+        $value = $this->get( $key );
146
+        return is_numeric( $value )
147 147
             ? $value
148 148
             : '';
149 149
     }
Please login to merge, or discard this patch.
plugin/Widgets/Widget.php 2 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -7,39 +7,39 @@
 block discarded – undo
7 7
 
8 8
 abstract class Widget extends WP_Widget
9 9
 {
10
-    /**
11
-     * @var array
12
-     */
13
-    protected $widgetArgs;
10
+	/**
11
+	 * @var array
12
+	 */
13
+	protected $widgetArgs;
14 14
 
15
-    /**
16
-     * @param string $tag
17
-     * @return void
18
-     */
19
-    protected function renderField($tag, array $args = [])
20
-    {
21
-        $args = $this->normalizeFieldAttributes($tag, $args);
22
-        $field = glsr(Builder::class)->$tag($args['name'], $args);
23
-        echo glsr(Builder::class)->div($field, [
24
-            'class' => 'glsr-field',
25
-        ]);
26
-    }
15
+	/**
16
+	 * @param string $tag
17
+	 * @return void
18
+	 */
19
+	protected function renderField($tag, array $args = [])
20
+	{
21
+		$args = $this->normalizeFieldAttributes($tag, $args);
22
+		$field = glsr(Builder::class)->$tag($args['name'], $args);
23
+		echo glsr(Builder::class)->div($field, [
24
+			'class' => 'glsr-field',
25
+		]);
26
+	}
27 27
 
28
-    /**
29
-     * @param string $tag
30
-     * @return array
31
-     */
32
-    protected function normalizeFieldAttributes($tag, array $args)
33
-    {
34
-        if (empty($args['value'])) {
35
-            $args['value'] = $this->widgetArgs[$args['name']];
36
-        }
37
-        if (empty($this->widgetArgs['options']) && in_array($tag, ['checkbox', 'radio'])) {
38
-            $args['checked'] = in_array($args['value'], (array) $this->widgetArgs[$args['name']]);
39
-        }
40
-        $args['id'] = $this->get_field_id($args['name']);
41
-        $args['name'] = $this->get_field_name($args['name']);
42
-        $args['is_widget'] = true;
43
-        return $args;
44
-    }
28
+	/**
29
+	 * @param string $tag
30
+	 * @return array
31
+	 */
32
+	protected function normalizeFieldAttributes($tag, array $args)
33
+	{
34
+		if (empty($args['value'])) {
35
+			$args['value'] = $this->widgetArgs[$args['name']];
36
+		}
37
+		if (empty($this->widgetArgs['options']) && in_array($tag, ['checkbox', 'radio'])) {
38
+			$args['checked'] = in_array($args['value'], (array) $this->widgetArgs[$args['name']]);
39
+		}
40
+		$args['id'] = $this->get_field_id($args['name']);
41
+		$args['name'] = $this->get_field_name($args['name']);
42
+		$args['is_widget'] = true;
43
+		return $args;
44
+	}
45 45
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -16,29 +16,29 @@
 block discarded – undo
16 16
      * @param string $tag
17 17
      * @return void
18 18
      */
19
-    protected function renderField($tag, array $args = [])
19
+    protected function renderField( $tag, array $args = [] )
20 20
     {
21
-        $args = $this->normalizeFieldAttributes($tag, $args);
22
-        $field = glsr(Builder::class)->$tag($args['name'], $args);
23
-        echo glsr(Builder::class)->div($field, [
21
+        $args = $this->normalizeFieldAttributes( $tag, $args );
22
+        $field = glsr( Builder::class )->$tag( $args['name'], $args );
23
+        echo glsr( Builder::class )->div( $field, [
24 24
             'class' => 'glsr-field',
25
-        ]);
25
+        ] );
26 26
     }
27 27
 
28 28
     /**
29 29
      * @param string $tag
30 30
      * @return array
31 31
      */
32
-    protected function normalizeFieldAttributes($tag, array $args)
32
+    protected function normalizeFieldAttributes( $tag, array $args )
33 33
     {
34
-        if (empty($args['value'])) {
34
+        if( empty($args['value']) ) {
35 35
             $args['value'] = $this->widgetArgs[$args['name']];
36 36
         }
37
-        if (empty($this->widgetArgs['options']) && in_array($tag, ['checkbox', 'radio'])) {
38
-            $args['checked'] = in_array($args['value'], (array) $this->widgetArgs[$args['name']]);
37
+        if( empty($this->widgetArgs['options']) && in_array( $tag, ['checkbox', 'radio'] ) ) {
38
+            $args['checked'] = in_array( $args['value'], (array)$this->widgetArgs[$args['name']] );
39 39
         }
40
-        $args['id'] = $this->get_field_id($args['name']);
41
-        $args['name'] = $this->get_field_name($args['name']);
40
+        $args['id'] = $this->get_field_id( $args['name'] );
41
+        $args['name'] = $this->get_field_name( $args['name'] );
42 42
         $args['is_widget'] = true;
43 43
         return $args;
44 44
     }
Please login to merge, or discard this patch.
plugin/Widgets/SiteReviewsWidget.php 2 patches
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -8,103 +8,103 @@
 block discarded – undo
8 8
 
9 9
 class SiteReviewsWidget extends Widget
10 10
 {
11
-    public function __construct()
12
-    {
13
-        $idBase = Application::ID.'_site-reviews';
14
-        $name = __('Recent Reviews', 'site-reviews');
15
-        $widgetOptions = [
16
-            'class' => 'glsr-widget glsr-widget-site-reviews',
17
-            'description' => __('Site Reviews: Display your recent reviews.', 'site-reviews'),
18
-        ];
19
-        parent::__construct($idBase, $name, $widgetOptions);
20
-    }
11
+	public function __construct()
12
+	{
13
+		$idBase = Application::ID.'_site-reviews';
14
+		$name = __('Recent Reviews', 'site-reviews');
15
+		$widgetOptions = [
16
+			'class' => 'glsr-widget glsr-widget-site-reviews',
17
+			'description' => __('Site Reviews: Display your recent reviews.', 'site-reviews'),
18
+		];
19
+		parent::__construct($idBase, $name, $widgetOptions);
20
+	}
21 21
 
22
-    /**
23
-     * @param array $instance
24
-     * @return void
25
-     */
26
-    public function form($instance)
27
-    {
28
-        $this->widgetArgs = glsr(SiteReviewsShortcode::class)->normalizeAtts($instance);
29
-        $terms = glsr(Database::class)->getTerms();
30
-        $this->renderField('text', [
31
-            'class' => 'widefat',
32
-            'label' => __('Title', 'site-reviews'),
33
-            'name' => 'title',
34
-        ]);
35
-        $this->renderField('number', [
36
-            'class' => 'small-text',
37
-            'default' => 10,
38
-            'label' => __('How many reviews would you like to display?', 'site-reviews'),
39
-            'max' => 100,
40
-            'name' => 'display',
41
-        ]);
42
-        $this->renderField('select', [
43
-            'label' => __('What is the minimum rating to display?', 'site-reviews'),
44
-            'name' => 'rating',
45
-            'options' => [
46
-                '5' => sprintf(_n('%s star', '%s stars', 5, 'site-reviews'), 5),
47
-                '4' => sprintf(_n('%s star', '%s stars', 4, 'site-reviews'), 4),
48
-                '3' => sprintf(_n('%s star', '%s stars', 3, 'site-reviews'), 3),
49
-                '2' => sprintf(_n('%s star', '%s stars', 2, 'site-reviews'), 2),
50
-                '1' => sprintf(_n('%s star', '%s stars', 1, 'site-reviews'), 1),
51
-            ],
52
-        ]);
53
-        if (count(glsr()->reviewTypes) > 1) {
54
-            $this->renderField('select', [
55
-                'class' => 'widefat',
56
-                'label' => __('Which type of review would you like to display?', 'site-reviews'),
57
-                'name' => 'type',
58
-                'options' => ['' => __('All Reviews', 'site-reviews')] + glsr()->reviewTypes,
59
-            ]);
60
-        }
61
-        if (!empty($terms)) {
62
-            $this->renderField('select', [
63
-                'class' => 'widefat',
64
-                'label' => __('Limit reviews to this category', 'site-reviews'),
65
-                'name' => 'category',
66
-                'options' => ['' => __('All Categories', 'site-reviews')] + $terms,
67
-            ]);
68
-        }
69
-        $this->renderField('text', [
70
-            'class' => 'widefat',
71
-            'default' => '',
72
-            'description' => sprintf(__("Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews'), '<code>post_id</code>'),
73
-            'label' => __('Limit reviews to those assigned to this page/post ID', 'site-reviews'),
74
-            'name' => 'assigned_to',
75
-        ]);
76
-        $this->renderField('text', [
77
-            'class' => 'widefat',
78
-            'label' => __('Enter any custom CSS classes here', 'site-reviews'),
79
-            'name' => 'class',
80
-        ]);
81
-        $this->renderField('checkbox', [
82
-            'name' => 'hide',
83
-            'options' => glsr(SiteReviewsShortcode::class)->getHideOptions(),
84
-        ]);
85
-    }
22
+	/**
23
+	 * @param array $instance
24
+	 * @return void
25
+	 */
26
+	public function form($instance)
27
+	{
28
+		$this->widgetArgs = glsr(SiteReviewsShortcode::class)->normalizeAtts($instance);
29
+		$terms = glsr(Database::class)->getTerms();
30
+		$this->renderField('text', [
31
+			'class' => 'widefat',
32
+			'label' => __('Title', 'site-reviews'),
33
+			'name' => 'title',
34
+		]);
35
+		$this->renderField('number', [
36
+			'class' => 'small-text',
37
+			'default' => 10,
38
+			'label' => __('How many reviews would you like to display?', 'site-reviews'),
39
+			'max' => 100,
40
+			'name' => 'display',
41
+		]);
42
+		$this->renderField('select', [
43
+			'label' => __('What is the minimum rating to display?', 'site-reviews'),
44
+			'name' => 'rating',
45
+			'options' => [
46
+				'5' => sprintf(_n('%s star', '%s stars', 5, 'site-reviews'), 5),
47
+				'4' => sprintf(_n('%s star', '%s stars', 4, 'site-reviews'), 4),
48
+				'3' => sprintf(_n('%s star', '%s stars', 3, 'site-reviews'), 3),
49
+				'2' => sprintf(_n('%s star', '%s stars', 2, 'site-reviews'), 2),
50
+				'1' => sprintf(_n('%s star', '%s stars', 1, 'site-reviews'), 1),
51
+			],
52
+		]);
53
+		if (count(glsr()->reviewTypes) > 1) {
54
+			$this->renderField('select', [
55
+				'class' => 'widefat',
56
+				'label' => __('Which type of review would you like to display?', 'site-reviews'),
57
+				'name' => 'type',
58
+				'options' => ['' => __('All Reviews', 'site-reviews')] + glsr()->reviewTypes,
59
+			]);
60
+		}
61
+		if (!empty($terms)) {
62
+			$this->renderField('select', [
63
+				'class' => 'widefat',
64
+				'label' => __('Limit reviews to this category', 'site-reviews'),
65
+				'name' => 'category',
66
+				'options' => ['' => __('All Categories', 'site-reviews')] + $terms,
67
+			]);
68
+		}
69
+		$this->renderField('text', [
70
+			'class' => 'widefat',
71
+			'default' => '',
72
+			'description' => sprintf(__("Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews'), '<code>post_id</code>'),
73
+			'label' => __('Limit reviews to those assigned to this page/post ID', 'site-reviews'),
74
+			'name' => 'assigned_to',
75
+		]);
76
+		$this->renderField('text', [
77
+			'class' => 'widefat',
78
+			'label' => __('Enter any custom CSS classes here', 'site-reviews'),
79
+			'name' => 'class',
80
+		]);
81
+		$this->renderField('checkbox', [
82
+			'name' => 'hide',
83
+			'options' => glsr(SiteReviewsShortcode::class)->getHideOptions(),
84
+		]);
85
+	}
86 86
 
87
-    /**
88
-     * @param array $newInstance
89
-     * @param array $oldInstance
90
-     * @return array
91
-     */
92
-    public function update($newInstance, $oldInstance)
93
-    {
94
-        if (!is_numeric($newInstance['display'])) {
95
-            $newInstance['display'] = 10;
96
-        }
97
-        $newInstance['display'] = min(50, max(0, intval($newInstance['display'])));
98
-        return parent::update($newInstance, $oldInstance);
99
-    }
87
+	/**
88
+	 * @param array $newInstance
89
+	 * @param array $oldInstance
90
+	 * @return array
91
+	 */
92
+	public function update($newInstance, $oldInstance)
93
+	{
94
+		if (!is_numeric($newInstance['display'])) {
95
+			$newInstance['display'] = 10;
96
+		}
97
+		$newInstance['display'] = min(50, max(0, intval($newInstance['display'])));
98
+		return parent::update($newInstance, $oldInstance);
99
+	}
100 100
 
101
-    /**
102
-     * @param array $args
103
-     * @param array $instance
104
-     * @return void
105
-     */
106
-    public function widget($args, $instance)
107
-    {
108
-        echo glsr(SiteReviewsShortcode::class)->build($instance, $args, 'widget');
109
-    }
101
+	/**
102
+	 * @param array $args
103
+	 * @param array $instance
104
+	 * @return void
105
+	 */
106
+	public function widget($args, $instance)
107
+	{
108
+		echo glsr(SiteReviewsShortcode::class)->build($instance, $args, 'widget');
109
+	}
110 110
 }
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -11,77 +11,77 @@  discard block
 block discarded – undo
11 11
     public function __construct()
12 12
     {
13 13
         $idBase = Application::ID.'_site-reviews';
14
-        $name = __('Recent Reviews', 'site-reviews');
14
+        $name = __( 'Recent Reviews', 'site-reviews' );
15 15
         $widgetOptions = [
16 16
             'class' => 'glsr-widget glsr-widget-site-reviews',
17
-            'description' => __('Site Reviews: Display your recent reviews.', 'site-reviews'),
17
+            'description' => __( 'Site Reviews: Display your recent reviews.', 'site-reviews' ),
18 18
         ];
19
-        parent::__construct($idBase, $name, $widgetOptions);
19
+        parent::__construct( $idBase, $name, $widgetOptions );
20 20
     }
21 21
 
22 22
     /**
23 23
      * @param array $instance
24 24
      * @return void
25 25
      */
26
-    public function form($instance)
26
+    public function form( $instance )
27 27
     {
28
-        $this->widgetArgs = glsr(SiteReviewsShortcode::class)->normalizeAtts($instance);
29
-        $terms = glsr(Database::class)->getTerms();
30
-        $this->renderField('text', [
28
+        $this->widgetArgs = glsr( SiteReviewsShortcode::class )->normalizeAtts( $instance );
29
+        $terms = glsr( Database::class )->getTerms();
30
+        $this->renderField( 'text', [
31 31
             'class' => 'widefat',
32
-            'label' => __('Title', 'site-reviews'),
32
+            'label' => __( 'Title', 'site-reviews' ),
33 33
             'name' => 'title',
34
-        ]);
35
-        $this->renderField('number', [
34
+        ] );
35
+        $this->renderField( 'number', [
36 36
             'class' => 'small-text',
37 37
             'default' => 10,
38
-            'label' => __('How many reviews would you like to display?', 'site-reviews'),
38
+            'label' => __( 'How many reviews would you like to display?', 'site-reviews' ),
39 39
             'max' => 100,
40 40
             'name' => 'display',
41
-        ]);
42
-        $this->renderField('select', [
43
-            'label' => __('What is the minimum rating to display?', 'site-reviews'),
41
+        ] );
42
+        $this->renderField( 'select', [
43
+            'label' => __( 'What is the minimum rating to display?', 'site-reviews' ),
44 44
             'name' => 'rating',
45 45
             'options' => [
46
-                '5' => sprintf(_n('%s star', '%s stars', 5, 'site-reviews'), 5),
47
-                '4' => sprintf(_n('%s star', '%s stars', 4, 'site-reviews'), 4),
48
-                '3' => sprintf(_n('%s star', '%s stars', 3, 'site-reviews'), 3),
49
-                '2' => sprintf(_n('%s star', '%s stars', 2, 'site-reviews'), 2),
50
-                '1' => sprintf(_n('%s star', '%s stars', 1, 'site-reviews'), 1),
46
+                '5' => sprintf( _n( '%s star', '%s stars', 5, 'site-reviews' ), 5 ),
47
+                '4' => sprintf( _n( '%s star', '%s stars', 4, 'site-reviews' ), 4 ),
48
+                '3' => sprintf( _n( '%s star', '%s stars', 3, 'site-reviews' ), 3 ),
49
+                '2' => sprintf( _n( '%s star', '%s stars', 2, 'site-reviews' ), 2 ),
50
+                '1' => sprintf( _n( '%s star', '%s stars', 1, 'site-reviews' ), 1 ),
51 51
             ],
52
-        ]);
53
-        if (count(glsr()->reviewTypes) > 1) {
54
-            $this->renderField('select', [
52
+        ] );
53
+        if( count( glsr()->reviewTypes ) > 1 ) {
54
+            $this->renderField( 'select', [
55 55
                 'class' => 'widefat',
56
-                'label' => __('Which type of review would you like to display?', 'site-reviews'),
56
+                'label' => __( 'Which type of review would you like to display?', 'site-reviews' ),
57 57
                 'name' => 'type',
58
-                'options' => ['' => __('All Reviews', 'site-reviews')] + glsr()->reviewTypes,
59
-            ]);
58
+                'options' => ['' => __( 'All Reviews', 'site-reviews' )] + glsr()->reviewTypes,
59
+            ] );
60 60
         }
61
-        if (!empty($terms)) {
62
-            $this->renderField('select', [
61
+        if( !empty($terms) ) {
62
+            $this->renderField( 'select', [
63 63
                 'class' => 'widefat',
64
-                'label' => __('Limit reviews to this category', 'site-reviews'),
64
+                'label' => __( 'Limit reviews to this category', 'site-reviews' ),
65 65
                 'name' => 'category',
66
-                'options' => ['' => __('All Categories', 'site-reviews')] + $terms,
67
-            ]);
66
+                'options' => ['' => __( 'All Categories', 'site-reviews' )] + $terms,
67
+            ] );
68 68
         }
69
-        $this->renderField('text', [
69
+        $this->renderField( 'text', [
70 70
             'class' => 'widefat',
71 71
             'default' => '',
72
-            'description' => sprintf(__("Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews'), '<code>post_id</code>'),
73
-            'label' => __('Limit reviews to those assigned to this page/post ID', 'site-reviews'),
72
+            'description' => sprintf( __( "Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews' ), '<code>post_id</code>' ),
73
+            'label' => __( 'Limit reviews to those assigned to this page/post ID', 'site-reviews' ),
74 74
             'name' => 'assigned_to',
75
-        ]);
76
-        $this->renderField('text', [
75
+        ] );
76
+        $this->renderField( 'text', [
77 77
             'class' => 'widefat',
78
-            'label' => __('Enter any custom CSS classes here', 'site-reviews'),
78
+            'label' => __( 'Enter any custom CSS classes here', 'site-reviews' ),
79 79
             'name' => 'class',
80
-        ]);
81
-        $this->renderField('checkbox', [
80
+        ] );
81
+        $this->renderField( 'checkbox', [
82 82
             'name' => 'hide',
83
-            'options' => glsr(SiteReviewsShortcode::class)->getHideOptions(),
84
-        ]);
83
+            'options' => glsr( SiteReviewsShortcode::class )->getHideOptions(),
84
+        ] );
85 85
     }
86 86
 
87 87
     /**
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
      * @param array $oldInstance
90 90
      * @return array
91 91
      */
92
-    public function update($newInstance, $oldInstance)
92
+    public function update( $newInstance, $oldInstance )
93 93
     {
94
-        if (!is_numeric($newInstance['display'])) {
94
+        if( !is_numeric( $newInstance['display'] ) ) {
95 95
             $newInstance['display'] = 10;
96 96
         }
97
-        $newInstance['display'] = min(50, max(0, intval($newInstance['display'])));
98
-        return parent::update($newInstance, $oldInstance);
97
+        $newInstance['display'] = min( 50, max( 0, intval( $newInstance['display'] ) ) );
98
+        return parent::update( $newInstance, $oldInstance );
99 99
     }
100 100
 
101 101
     /**
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
      * @param array $instance
104 104
      * @return void
105 105
      */
106
-    public function widget($args, $instance)
106
+    public function widget( $args, $instance )
107 107
     {
108
-        echo glsr(SiteReviewsShortcode::class)->build($instance, $args, 'widget');
108
+        echo glsr( SiteReviewsShortcode::class )->build( $instance, $args, 'widget' );
109 109
     }
110 110
 }
Please login to merge, or discard this patch.
plugin/Widgets/SiteReviewsFormWidget.php 2 patches
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -8,66 +8,66 @@
 block discarded – undo
8 8
 
9 9
 class SiteReviewsFormWidget extends Widget
10 10
 {
11
-    public function __construct()
12
-    {
13
-        $idBase = Application::ID.'_site-reviews-form';
14
-        $name = __('Submit a Review', 'site-reviews');
15
-        $widgetOptions = [
16
-            'classname' => 'glsr-widget glsr-widget-site-reviews-form',
17
-            'description' => __('Site Reviews: Display a form to submit reviews.', 'site-reviews'),
18
-        ];
19
-        parent::__construct($idBase, $name, $widgetOptions);
20
-    }
11
+	public function __construct()
12
+	{
13
+		$idBase = Application::ID.'_site-reviews-form';
14
+		$name = __('Submit a Review', 'site-reviews');
15
+		$widgetOptions = [
16
+			'classname' => 'glsr-widget glsr-widget-site-reviews-form',
17
+			'description' => __('Site Reviews: Display a form to submit reviews.', 'site-reviews'),
18
+		];
19
+		parent::__construct($idBase, $name, $widgetOptions);
20
+	}
21 21
 
22
-    /**
23
-     * @param array $instance
24
-     * @return void
25
-     */
26
-    public function form($instance)
27
-    {
28
-        $this->widgetArgs = glsr(SiteReviewsFormShortcode::class)->normalizeAtts($instance);
29
-        $terms = glsr(Database::class)->getTerms();
30
-        $this->renderField('text', [
31
-            'class' => 'widefat',
32
-            'label' => __('Title', 'site-reviews'),
33
-            'name' => 'title',
34
-        ]);
35
-        $this->renderField('textarea', [
36
-            'class' => 'widefat',
37
-            'label' => __('Description', 'site-reviews'),
38
-            'name' => 'description',
39
-        ]);
40
-        $this->renderField('select', [
41
-            'class' => 'widefat',
42
-            'label' => __('Automatically assign a category', 'site-reviews'),
43
-            'name' => 'category',
44
-            'options' => ['' => __('Do not assign a category', 'site-reviews')] + $terms,
45
-        ]);
46
-        $this->renderField('text', [
47
-            'class' => 'widefat',
48
-            'default' => '',
49
-            'description' => sprintf(__('You may also enter %s to assign to the current post.', 'site-reviews'), '<code>post_id</code>'),
50
-            'label' => __('Assign reviews to a custom page/post ID', 'site-reviews'),
51
-            'name' => 'assign_to',
52
-        ]);
53
-        $this->renderField('text', [
54
-            'class' => 'widefat',
55
-            'label' => __('Enter any custom CSS classes here', 'site-reviews'),
56
-            'name' => 'class',
57
-        ]);
58
-        $this->renderField('checkbox', [
59
-            'name' => 'hide',
60
-            'options' => glsr(SiteReviewsFormShortcode::class)->getHideOptions(),
61
-        ]);
62
-    }
22
+	/**
23
+	 * @param array $instance
24
+	 * @return void
25
+	 */
26
+	public function form($instance)
27
+	{
28
+		$this->widgetArgs = glsr(SiteReviewsFormShortcode::class)->normalizeAtts($instance);
29
+		$terms = glsr(Database::class)->getTerms();
30
+		$this->renderField('text', [
31
+			'class' => 'widefat',
32
+			'label' => __('Title', 'site-reviews'),
33
+			'name' => 'title',
34
+		]);
35
+		$this->renderField('textarea', [
36
+			'class' => 'widefat',
37
+			'label' => __('Description', 'site-reviews'),
38
+			'name' => 'description',
39
+		]);
40
+		$this->renderField('select', [
41
+			'class' => 'widefat',
42
+			'label' => __('Automatically assign a category', 'site-reviews'),
43
+			'name' => 'category',
44
+			'options' => ['' => __('Do not assign a category', 'site-reviews')] + $terms,
45
+		]);
46
+		$this->renderField('text', [
47
+			'class' => 'widefat',
48
+			'default' => '',
49
+			'description' => sprintf(__('You may also enter %s to assign to the current post.', 'site-reviews'), '<code>post_id</code>'),
50
+			'label' => __('Assign reviews to a custom page/post ID', 'site-reviews'),
51
+			'name' => 'assign_to',
52
+		]);
53
+		$this->renderField('text', [
54
+			'class' => 'widefat',
55
+			'label' => __('Enter any custom CSS classes here', 'site-reviews'),
56
+			'name' => 'class',
57
+		]);
58
+		$this->renderField('checkbox', [
59
+			'name' => 'hide',
60
+			'options' => glsr(SiteReviewsFormShortcode::class)->getHideOptions(),
61
+		]);
62
+	}
63 63
 
64
-    /**
65
-     * @param array $args
66
-     * @param array $instance
67
-     * @return void
68
-     */
69
-    public function widget($args, $instance)
70
-    {
71
-        echo glsr(SiteReviewsFormShortcode::class)->build($instance, $args, 'widget');
72
-    }
64
+	/**
65
+	 * @param array $args
66
+	 * @param array $instance
67
+	 * @return void
68
+	 */
69
+	public function widget($args, $instance)
70
+	{
71
+		echo glsr(SiteReviewsFormShortcode::class)->build($instance, $args, 'widget');
72
+	}
73 73
 }
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -11,54 +11,54 @@  discard block
 block discarded – undo
11 11
     public function __construct()
12 12
     {
13 13
         $idBase = Application::ID.'_site-reviews-form';
14
-        $name = __('Submit a Review', 'site-reviews');
14
+        $name = __( 'Submit a Review', 'site-reviews' );
15 15
         $widgetOptions = [
16 16
             'classname' => 'glsr-widget glsr-widget-site-reviews-form',
17
-            'description' => __('Site Reviews: Display a form to submit reviews.', 'site-reviews'),
17
+            'description' => __( 'Site Reviews: Display a form to submit reviews.', 'site-reviews' ),
18 18
         ];
19
-        parent::__construct($idBase, $name, $widgetOptions);
19
+        parent::__construct( $idBase, $name, $widgetOptions );
20 20
     }
21 21
 
22 22
     /**
23 23
      * @param array $instance
24 24
      * @return void
25 25
      */
26
-    public function form($instance)
26
+    public function form( $instance )
27 27
     {
28
-        $this->widgetArgs = glsr(SiteReviewsFormShortcode::class)->normalizeAtts($instance);
29
-        $terms = glsr(Database::class)->getTerms();
30
-        $this->renderField('text', [
28
+        $this->widgetArgs = glsr( SiteReviewsFormShortcode::class )->normalizeAtts( $instance );
29
+        $terms = glsr( Database::class )->getTerms();
30
+        $this->renderField( 'text', [
31 31
             'class' => 'widefat',
32
-            'label' => __('Title', 'site-reviews'),
32
+            'label' => __( 'Title', 'site-reviews' ),
33 33
             'name' => 'title',
34
-        ]);
35
-        $this->renderField('textarea', [
34
+        ] );
35
+        $this->renderField( 'textarea', [
36 36
             'class' => 'widefat',
37
-            'label' => __('Description', 'site-reviews'),
37
+            'label' => __( 'Description', 'site-reviews' ),
38 38
             'name' => 'description',
39
-        ]);
40
-        $this->renderField('select', [
39
+        ] );
40
+        $this->renderField( 'select', [
41 41
             'class' => 'widefat',
42
-            'label' => __('Automatically assign a category', 'site-reviews'),
42
+            'label' => __( 'Automatically assign a category', 'site-reviews' ),
43 43
             'name' => 'category',
44
-            'options' => ['' => __('Do not assign a category', 'site-reviews')] + $terms,
45
-        ]);
46
-        $this->renderField('text', [
44
+            'options' => ['' => __( 'Do not assign a category', 'site-reviews' )] + $terms,
45
+        ] );
46
+        $this->renderField( 'text', [
47 47
             'class' => 'widefat',
48 48
             'default' => '',
49
-            'description' => sprintf(__('You may also enter %s to assign to the current post.', 'site-reviews'), '<code>post_id</code>'),
50
-            'label' => __('Assign reviews to a custom page/post ID', 'site-reviews'),
49
+            'description' => sprintf( __( 'You may also enter %s to assign to the current post.', 'site-reviews' ), '<code>post_id</code>' ),
50
+            'label' => __( 'Assign reviews to a custom page/post ID', 'site-reviews' ),
51 51
             'name' => 'assign_to',
52
-        ]);
53
-        $this->renderField('text', [
52
+        ] );
53
+        $this->renderField( 'text', [
54 54
             'class' => 'widefat',
55
-            'label' => __('Enter any custom CSS classes here', 'site-reviews'),
55
+            'label' => __( 'Enter any custom CSS classes here', 'site-reviews' ),
56 56
             'name' => 'class',
57
-        ]);
58
-        $this->renderField('checkbox', [
57
+        ] );
58
+        $this->renderField( 'checkbox', [
59 59
             'name' => 'hide',
60
-            'options' => glsr(SiteReviewsFormShortcode::class)->getHideOptions(),
61
-        ]);
60
+            'options' => glsr( SiteReviewsFormShortcode::class )->getHideOptions(),
61
+        ] );
62 62
     }
63 63
 
64 64
     /**
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
      * @param array $instance
67 67
      * @return void
68 68
      */
69
-    public function widget($args, $instance)
69
+    public function widget( $args, $instance )
70 70
     {
71
-        echo glsr(SiteReviewsFormShortcode::class)->build($instance, $args, 'widget');
71
+        echo glsr( SiteReviewsFormShortcode::class )->build( $instance, $args, 'widget' );
72 72
     }
73 73
 }
Please login to merge, or discard this patch.
plugin/Widgets/SiteReviewsSummaryWidget.php 2 patches
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -8,71 +8,71 @@
 block discarded – undo
8 8
 
9 9
 class SiteReviewsSummaryWidget extends Widget
10 10
 {
11
-    public function __construct()
12
-    {
13
-        $idBase = Application::ID.'_site-reviews-summary';
14
-        $name = __('Summary of Reviews', 'site-reviews');
15
-        $widgetOptions = [
16
-            'classname' => 'glsr-widget glsr-widget-site-reviews-summary',
17
-            'description' => __('Site Reviews: Display a summary of your reviews.', 'site-reviews'),
18
-        ];
19
-        parent::__construct($idBase, $name, $widgetOptions);
20
-    }
11
+	public function __construct()
12
+	{
13
+		$idBase = Application::ID.'_site-reviews-summary';
14
+		$name = __('Summary of Reviews', 'site-reviews');
15
+		$widgetOptions = [
16
+			'classname' => 'glsr-widget glsr-widget-site-reviews-summary',
17
+			'description' => __('Site Reviews: Display a summary of your reviews.', 'site-reviews'),
18
+		];
19
+		parent::__construct($idBase, $name, $widgetOptions);
20
+	}
21 21
 
22
-    /**
23
-     * @param array $instance
24
-     * @return void
25
-     */
26
-    public function form($instance)
27
-    {
28
-        $this->widgetArgs = glsr(SiteReviewsSummaryShortcode::class)->normalizeAtts($instance);
29
-        $terms = glsr(Database::class)->getTerms();
30
-        $this->renderField('text', [
31
-            'class' => 'widefat',
32
-            'label' => __('Title', 'site-reviews'),
33
-            'name' => 'title',
34
-        ]);
35
-        if (count(glsr()->reviewTypes) > 1) {
36
-            $this->renderField('select', [
37
-                'class' => 'widefat',
38
-                'label' => __('Which type of review would you like to use?', 'site-reviews'),
39
-                'name' => 'type',
40
-                'options' => ['' => __('All review types', 'site-reviews')] + glsr()->reviewTypes,
41
-            ]);
42
-        }
43
-        if (!empty($terms)) {
44
-            $this->renderField('select', [
45
-                'class' => 'widefat',
46
-                'label' => __('Limit summary to this category', 'site-reviews'),
47
-                'name' => 'category',
48
-                'options' => ['' => __('All Categories', 'site-reviews')] + $terms,
49
-            ]);
50
-        }
51
-        $this->renderField('text', [
52
-            'class' => 'widefat',
53
-            'default' => '',
54
-            'description' => sprintf(__("Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews'), '<code>post_id</code>'),
55
-            'label' => __('Limit summary to reviews assigned to a page/post ID', 'site-reviews'),
56
-            'name' => 'assigned_to',
57
-        ]);
58
-        $this->renderField('text', [
59
-            'class' => 'widefat',
60
-            'label' => __('Enter any custom CSS classes here', 'site-reviews'),
61
-            'name' => 'class',
62
-        ]);
63
-        $this->renderField('checkbox', [
64
-            'name' => 'hide',
65
-            'options' => glsr(SiteReviewsSummaryShortcode::class)->getHideOptions(),
66
-        ]);
67
-    }
22
+	/**
23
+	 * @param array $instance
24
+	 * @return void
25
+	 */
26
+	public function form($instance)
27
+	{
28
+		$this->widgetArgs = glsr(SiteReviewsSummaryShortcode::class)->normalizeAtts($instance);
29
+		$terms = glsr(Database::class)->getTerms();
30
+		$this->renderField('text', [
31
+			'class' => 'widefat',
32
+			'label' => __('Title', 'site-reviews'),
33
+			'name' => 'title',
34
+		]);
35
+		if (count(glsr()->reviewTypes) > 1) {
36
+			$this->renderField('select', [
37
+				'class' => 'widefat',
38
+				'label' => __('Which type of review would you like to use?', 'site-reviews'),
39
+				'name' => 'type',
40
+				'options' => ['' => __('All review types', 'site-reviews')] + glsr()->reviewTypes,
41
+			]);
42
+		}
43
+		if (!empty($terms)) {
44
+			$this->renderField('select', [
45
+				'class' => 'widefat',
46
+				'label' => __('Limit summary to this category', 'site-reviews'),
47
+				'name' => 'category',
48
+				'options' => ['' => __('All Categories', 'site-reviews')] + $terms,
49
+			]);
50
+		}
51
+		$this->renderField('text', [
52
+			'class' => 'widefat',
53
+			'default' => '',
54
+			'description' => sprintf(__("Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews'), '<code>post_id</code>'),
55
+			'label' => __('Limit summary to reviews assigned to a page/post ID', 'site-reviews'),
56
+			'name' => 'assigned_to',
57
+		]);
58
+		$this->renderField('text', [
59
+			'class' => 'widefat',
60
+			'label' => __('Enter any custom CSS classes here', 'site-reviews'),
61
+			'name' => 'class',
62
+		]);
63
+		$this->renderField('checkbox', [
64
+			'name' => 'hide',
65
+			'options' => glsr(SiteReviewsSummaryShortcode::class)->getHideOptions(),
66
+		]);
67
+	}
68 68
 
69
-    /**
70
-     * @param array $args
71
-     * @param array $instance
72
-     * @return void
73
-     */
74
-    public function widget($args, $instance)
75
-    {
76
-        echo glsr(SiteReviewsSummaryShortcode::class)->build($instance, $args, 'widget');
77
-    }
69
+	/**
70
+	 * @param array $args
71
+	 * @param array $instance
72
+	 * @return void
73
+	 */
74
+	public function widget($args, $instance)
75
+	{
76
+		echo glsr(SiteReviewsSummaryShortcode::class)->build($instance, $args, 'widget');
77
+	}
78 78
 }
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -11,59 +11,59 @@  discard block
 block discarded – undo
11 11
     public function __construct()
12 12
     {
13 13
         $idBase = Application::ID.'_site-reviews-summary';
14
-        $name = __('Summary of Reviews', 'site-reviews');
14
+        $name = __( 'Summary of Reviews', 'site-reviews' );
15 15
         $widgetOptions = [
16 16
             'classname' => 'glsr-widget glsr-widget-site-reviews-summary',
17
-            'description' => __('Site Reviews: Display a summary of your reviews.', 'site-reviews'),
17
+            'description' => __( 'Site Reviews: Display a summary of your reviews.', 'site-reviews' ),
18 18
         ];
19
-        parent::__construct($idBase, $name, $widgetOptions);
19
+        parent::__construct( $idBase, $name, $widgetOptions );
20 20
     }
21 21
 
22 22
     /**
23 23
      * @param array $instance
24 24
      * @return void
25 25
      */
26
-    public function form($instance)
26
+    public function form( $instance )
27 27
     {
28
-        $this->widgetArgs = glsr(SiteReviewsSummaryShortcode::class)->normalizeAtts($instance);
29
-        $terms = glsr(Database::class)->getTerms();
30
-        $this->renderField('text', [
28
+        $this->widgetArgs = glsr( SiteReviewsSummaryShortcode::class )->normalizeAtts( $instance );
29
+        $terms = glsr( Database::class )->getTerms();
30
+        $this->renderField( 'text', [
31 31
             'class' => 'widefat',
32
-            'label' => __('Title', 'site-reviews'),
32
+            'label' => __( 'Title', 'site-reviews' ),
33 33
             'name' => 'title',
34
-        ]);
35
-        if (count(glsr()->reviewTypes) > 1) {
36
-            $this->renderField('select', [
34
+        ] );
35
+        if( count( glsr()->reviewTypes ) > 1 ) {
36
+            $this->renderField( 'select', [
37 37
                 'class' => 'widefat',
38
-                'label' => __('Which type of review would you like to use?', 'site-reviews'),
38
+                'label' => __( 'Which type of review would you like to use?', 'site-reviews' ),
39 39
                 'name' => 'type',
40
-                'options' => ['' => __('All review types', 'site-reviews')] + glsr()->reviewTypes,
41
-            ]);
40
+                'options' => ['' => __( 'All review types', 'site-reviews' )] + glsr()->reviewTypes,
41
+            ] );
42 42
         }
43
-        if (!empty($terms)) {
44
-            $this->renderField('select', [
43
+        if( !empty($terms) ) {
44
+            $this->renderField( 'select', [
45 45
                 'class' => 'widefat',
46
-                'label' => __('Limit summary to this category', 'site-reviews'),
46
+                'label' => __( 'Limit summary to this category', 'site-reviews' ),
47 47
                 'name' => 'category',
48
-                'options' => ['' => __('All Categories', 'site-reviews')] + $terms,
49
-            ]);
48
+                'options' => ['' => __( 'All Categories', 'site-reviews' )] + $terms,
49
+            ] );
50 50
         }
51
-        $this->renderField('text', [
51
+        $this->renderField( 'text', [
52 52
             'class' => 'widefat',
53 53
             'default' => '',
54
-            'description' => sprintf(__("Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews'), '<code>post_id</code>'),
55
-            'label' => __('Limit summary to reviews assigned to a page/post ID', 'site-reviews'),
54
+            'description' => sprintf( __( "Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews' ), '<code>post_id</code>' ),
55
+            'label' => __( 'Limit summary to reviews assigned to a page/post ID', 'site-reviews' ),
56 56
             'name' => 'assigned_to',
57
-        ]);
58
-        $this->renderField('text', [
57
+        ] );
58
+        $this->renderField( 'text', [
59 59
             'class' => 'widefat',
60
-            'label' => __('Enter any custom CSS classes here', 'site-reviews'),
60
+            'label' => __( 'Enter any custom CSS classes here', 'site-reviews' ),
61 61
             'name' => 'class',
62
-        ]);
63
-        $this->renderField('checkbox', [
62
+        ] );
63
+        $this->renderField( 'checkbox', [
64 64
             'name' => 'hide',
65
-            'options' => glsr(SiteReviewsSummaryShortcode::class)->getHideOptions(),
66
-        ]);
65
+            'options' => glsr( SiteReviewsSummaryShortcode::class )->getHideOptions(),
66
+        ] );
67 67
     }
68 68
 
69 69
     /**
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
      * @param array $instance
72 72
      * @return void
73 73
      */
74
-    public function widget($args, $instance)
74
+    public function widget( $args, $instance )
75 75
     {
76
-        echo glsr(SiteReviewsSummaryShortcode::class)->build($instance, $args, 'widget');
76
+        echo glsr( SiteReviewsSummaryShortcode::class )->build( $instance, $args, 'widget' );
77 77
     }
78 78
 }
Please login to merge, or discard this patch.
plugin/Handlers/RegisterWidgets.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -8,19 +8,19 @@
 block discarded – undo
8 8
 
9 9
 class RegisterWidgets
10 10
 {
11
-    /**
12
-     * @return void
13
-     */
14
-    public function handle(Command $command)
15
-    {
16
-        global $wp_widget_factory;
17
-        foreach ($command->widgets as $widget) {
18
-            $widgetClass = Helper::buildClassName($widget.'-widget', 'Widgets');
19
-            if (!class_exists($widgetClass)) {
20
-                glsr_log()->error(sprintf('Class missing (%s)', $widgetClass));
21
-                continue;
22
-            }
23
-            $wp_widget_factory->widgets[$widgetClass] = new $widgetClass();
24
-        }
25
-    }
11
+	/**
12
+	 * @return void
13
+	 */
14
+	public function handle(Command $command)
15
+	{
16
+		global $wp_widget_factory;
17
+		foreach ($command->widgets as $widget) {
18
+			$widgetClass = Helper::buildClassName($widget.'-widget', 'Widgets');
19
+			if (!class_exists($widgetClass)) {
20
+				glsr_log()->error(sprintf('Class missing (%s)', $widgetClass));
21
+				continue;
22
+			}
23
+			$wp_widget_factory->widgets[$widgetClass] = new $widgetClass();
24
+		}
25
+	}
26 26
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -11,13 +11,13 @@
 block discarded – undo
11 11
     /**
12 12
      * @return void
13 13
      */
14
-    public function handle(Command $command)
14
+    public function handle( Command $command )
15 15
     {
16 16
         global $wp_widget_factory;
17
-        foreach ($command->widgets as $widget) {
18
-            $widgetClass = Helper::buildClassName($widget.'-widget', 'Widgets');
19
-            if (!class_exists($widgetClass)) {
20
-                glsr_log()->error(sprintf('Class missing (%s)', $widgetClass));
17
+        foreach( $command->widgets as $widget ) {
18
+            $widgetClass = Helper::buildClassName( $widget.'-widget', 'Widgets' );
19
+            if( !class_exists( $widgetClass ) ) {
20
+                glsr_log()->error( sprintf( 'Class missing (%s)', $widgetClass ) );
21 21
                 continue;
22 22
             }
23 23
             $wp_widget_factory->widgets[$widgetClass] = new $widgetClass();
Please login to merge, or discard this patch.
plugin/Modules/Migrate.php 2 patches
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -10,134 +10,134 @@
 block discarded – undo
10 10
 
11 11
 class Migrate
12 12
 {
13
-    /**
14
-     * @var string
15
-     */
16
-    public $currentVersion;
13
+	/**
14
+	 * @var string
15
+	 */
16
+	public $currentVersion;
17 17
 
18
-    /**
19
-     * @var string
20
-     */
21
-    public $transientKey;
18
+	/**
19
+	 * @var string
20
+	 */
21
+	public $transientKey;
22 22
 
23
-    public function __construct()
24
-    {
25
-        $this->currentVersion = $this->getCurrentVersion();
26
-        $this->transientKey = Application::PREFIX.'migrations';
27
-    }
23
+	public function __construct()
24
+	{
25
+		$this->currentVersion = $this->getCurrentVersion();
26
+		$this->transientKey = Application::PREFIX.'migrations';
27
+	}
28 28
 
29
-    /**
30
-     * @return bool
31
-     */
32
-    public function isMigrationNeeded()
33
-    {
34
-        $transient = get_transient($this->transientKey);
35
-        if (false === $transient || !isset($transient[glsr()->version])) {
36
-            $transient = [
37
-                glsr()->version => !empty($this->getNewMigrationFiles()),
38
-            ];
39
-            set_transient($this->transientKey, $transient);
40
-        }
41
-        return Helper::castToBool($transient[glsr()->version]);
42
-    }
29
+	/**
30
+	 * @return bool
31
+	 */
32
+	public function isMigrationNeeded()
33
+	{
34
+		$transient = get_transient($this->transientKey);
35
+		if (false === $transient || !isset($transient[glsr()->version])) {
36
+			$transient = [
37
+				glsr()->version => !empty($this->getNewMigrationFiles()),
38
+			];
39
+			set_transient($this->transientKey, $transient);
40
+		}
41
+		return Helper::castToBool($transient[glsr()->version]);
42
+	}
43 43
 
44
-    /**
45
-     * @return void
46
-     */
47
-    public function run()
48
-    {
49
-        $this->runMigrations($this->getNewMigrationFiles());
50
-    }
44
+	/**
45
+	 * @return void
46
+	 */
47
+	public function run()
48
+	{
49
+		$this->runMigrations($this->getNewMigrationFiles());
50
+	}
51 51
 
52
-    /**
53
-     * @return bool
54
-     */
55
-    public function runAll()
56
-    {
57
-        $this->runMigrations($this->getMigrationFiles());
58
-    }
52
+	/**
53
+	 * @return bool
54
+	 */
55
+	public function runAll()
56
+	{
57
+		$this->runMigrations($this->getMigrationFiles());
58
+	}
59 59
 
60
-    /**
61
-     * @return string
62
-     */
63
-    protected function getCurrentVersion()
64
-    {
65
-        $fallback = '0.0.0';
66
-        $majorVersions = [4, 3, 2, 1];
67
-        foreach ($majorVersions as $majorVersion) {
68
-            $settings = get_option(OptionManager::databaseKey($majorVersion));
69
-            $version = Arr::get($settings, 'version', $fallback);
70
-            if (Helper::isGreaterThan($version, $fallback)) {
71
-                return $version;
72
-            }
73
-        }
74
-        return $fallback;
75
-    }
60
+	/**
61
+	 * @return string
62
+	 */
63
+	protected function getCurrentVersion()
64
+	{
65
+		$fallback = '0.0.0';
66
+		$majorVersions = [4, 3, 2, 1];
67
+		foreach ($majorVersions as $majorVersion) {
68
+			$settings = get_option(OptionManager::databaseKey($majorVersion));
69
+			$version = Arr::get($settings, 'version', $fallback);
70
+			if (Helper::isGreaterThan($version, $fallback)) {
71
+				return $version;
72
+			}
73
+		}
74
+		return $fallback;
75
+	}
76 76
 
77
-    /**
78
-     * @return array
79
-     */
80
-    protected function getMigrationFiles()
81
-    {
82
-        $files = [];
83
-        $dir = glsr()->path('plugin/Modules/Migrations');
84
-        if (is_dir($dir)) {
85
-            $iterator = new DirectoryIterator($dir);
86
-            foreach ($iterator as $fileinfo) {
87
-                if ($fileinfo->isFile()) {
88
-                    $files[] = $fileinfo->getFilename();
89
-                }
90
-            }
91
-            natsort($files);
92
-        }
93
-        return $files;
94
-    }
77
+	/**
78
+	 * @return array
79
+	 */
80
+	protected function getMigrationFiles()
81
+	{
82
+		$files = [];
83
+		$dir = glsr()->path('plugin/Modules/Migrations');
84
+		if (is_dir($dir)) {
85
+			$iterator = new DirectoryIterator($dir);
86
+			foreach ($iterator as $fileinfo) {
87
+				if ($fileinfo->isFile()) {
88
+					$files[] = $fileinfo->getFilename();
89
+				}
90
+			}
91
+			natsort($files);
92
+		}
93
+		return $files;
94
+	}
95 95
 
96
-    /**
97
-     * @return array
98
-     */
99
-    protected function getNewMigrationFiles()
100
-    {
101
-        $files = $this->getMigrationFiles();
102
-        foreach ($files as $index => $file) {
103
-            $className = str_replace('.php', '', $file);
104
-            $migrationVersion = str_replace(['Migrate_', '_'], ['', '.'], $className);
105
-            $suffix = preg_replace('/[\d.]+(.+)?/', '${1}', glsr()->version); // allow alpha/beta versions
106
-            if (Helper::isGreaterThanOrEqual($this->currentVersion, $migrationVersion.$suffix)) {
107
-                unset($files[$index]);
108
-            }
109
-        }
110
-        return $files;
111
-    }
96
+	/**
97
+	 * @return array
98
+	 */
99
+	protected function getNewMigrationFiles()
100
+	{
101
+		$files = $this->getMigrationFiles();
102
+		foreach ($files as $index => $file) {
103
+			$className = str_replace('.php', '', $file);
104
+			$migrationVersion = str_replace(['Migrate_', '_'], ['', '.'], $className);
105
+			$suffix = preg_replace('/[\d.]+(.+)?/', '${1}', glsr()->version); // allow alpha/beta versions
106
+			if (Helper::isGreaterThanOrEqual($this->currentVersion, $migrationVersion.$suffix)) {
107
+				unset($files[$index]);
108
+			}
109
+		}
110
+		return $files;
111
+	}
112 112
 
113
-    /**
114
-     * @return void
115
-     */
116
-    protected function runMigrations(array $files)
117
-    {
118
-        if (empty($files)) {
119
-            return;
120
-        }
121
-        array_walk($files, function ($file) {
122
-            $className = str_replace('.php', '', $file);
123
-            glsr('Modules\\Migrations\\'.$className)->run();
124
-            $versionMigrated = str_replace(['Migrate_', '_'], ['v','.'], $className);
125
-            glsr_log()->debug('migration completed for '.$versionMigrated);
126
-        });
127
-        if ($this->currentVersion !== glsr()->version) {
128
-            $this->updateVersionFrom($this->currentVersion);
129
-        }
130
-        glsr(OptionManager::class)->set('last_migration_run', current_time('timestamp'));
131
-        delete_transient($this->transientKey);
132
-    }
113
+	/**
114
+	 * @return void
115
+	 */
116
+	protected function runMigrations(array $files)
117
+	{
118
+		if (empty($files)) {
119
+			return;
120
+		}
121
+		array_walk($files, function ($file) {
122
+			$className = str_replace('.php', '', $file);
123
+			glsr('Modules\\Migrations\\'.$className)->run();
124
+			$versionMigrated = str_replace(['Migrate_', '_'], ['v','.'], $className);
125
+			glsr_log()->debug('migration completed for '.$versionMigrated);
126
+		});
127
+		if ($this->currentVersion !== glsr()->version) {
128
+			$this->updateVersionFrom($this->currentVersion);
129
+		}
130
+		glsr(OptionManager::class)->set('last_migration_run', current_time('timestamp'));
131
+		delete_transient($this->transientKey);
132
+	}
133 133
 
134
-    /**
135
-     * @param string $previousVersion
136
-     * @return void
137
-     */
138
-    protected function updateVersionFrom($previousVersion)
139
-    {
140
-        glsr(OptionManager::class)->set('version', glsr()->version);
141
-        glsr(OptionManager::class)->set('version_upgraded_from', $previousVersion);
142
-    }
134
+	/**
135
+	 * @param string $previousVersion
136
+	 * @return void
137
+	 */
138
+	protected function updateVersionFrom($previousVersion)
139
+	{
140
+		glsr(OptionManager::class)->set('version', glsr()->version);
141
+		glsr(OptionManager::class)->set('version_upgraded_from', $previousVersion);
142
+	}
143 143
 }
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -31,14 +31,14 @@  discard block
 block discarded – undo
31 31
      */
32 32
     public function isMigrationNeeded()
33 33
     {
34
-        $transient = get_transient($this->transientKey);
35
-        if (false === $transient || !isset($transient[glsr()->version])) {
34
+        $transient = get_transient( $this->transientKey );
35
+        if( false === $transient || !isset($transient[glsr()->version]) ) {
36 36
             $transient = [
37 37
                 glsr()->version => !empty($this->getNewMigrationFiles()),
38 38
             ];
39
-            set_transient($this->transientKey, $transient);
39
+            set_transient( $this->transientKey, $transient );
40 40
         }
41
-        return Helper::castToBool($transient[glsr()->version]);
41
+        return Helper::castToBool( $transient[glsr()->version] );
42 42
     }
43 43
 
44 44
     /**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public function run()
48 48
     {
49
-        $this->runMigrations($this->getNewMigrationFiles());
49
+        $this->runMigrations( $this->getNewMigrationFiles() );
50 50
     }
51 51
 
52 52
     /**
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      */
55 55
     public function runAll()
56 56
     {
57
-        $this->runMigrations($this->getMigrationFiles());
57
+        $this->runMigrations( $this->getMigrationFiles() );
58 58
     }
59 59
 
60 60
     /**
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
     {
65 65
         $fallback = '0.0.0';
66 66
         $majorVersions = [4, 3, 2, 1];
67
-        foreach ($majorVersions as $majorVersion) {
68
-            $settings = get_option(OptionManager::databaseKey($majorVersion));
69
-            $version = Arr::get($settings, 'version', $fallback);
70
-            if (Helper::isGreaterThan($version, $fallback)) {
67
+        foreach( $majorVersions as $majorVersion ) {
68
+            $settings = get_option( OptionManager::databaseKey( $majorVersion ) );
69
+            $version = Arr::get( $settings, 'version', $fallback );
70
+            if( Helper::isGreaterThan( $version, $fallback ) ) {
71 71
                 return $version;
72 72
             }
73 73
         }
@@ -80,15 +80,15 @@  discard block
 block discarded – undo
80 80
     protected function getMigrationFiles()
81 81
     {
82 82
         $files = [];
83
-        $dir = glsr()->path('plugin/Modules/Migrations');
84
-        if (is_dir($dir)) {
85
-            $iterator = new DirectoryIterator($dir);
86
-            foreach ($iterator as $fileinfo) {
87
-                if ($fileinfo->isFile()) {
83
+        $dir = glsr()->path( 'plugin/Modules/Migrations' );
84
+        if( is_dir( $dir ) ) {
85
+            $iterator = new DirectoryIterator( $dir );
86
+            foreach( $iterator as $fileinfo ) {
87
+                if( $fileinfo->isFile() ) {
88 88
                     $files[] = $fileinfo->getFilename();
89 89
                 }
90 90
             }
91
-            natsort($files);
91
+            natsort( $files );
92 92
         }
93 93
         return $files;
94 94
     }
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
     protected function getNewMigrationFiles()
100 100
     {
101 101
         $files = $this->getMigrationFiles();
102
-        foreach ($files as $index => $file) {
103
-            $className = str_replace('.php', '', $file);
104
-            $migrationVersion = str_replace(['Migrate_', '_'], ['', '.'], $className);
105
-            $suffix = preg_replace('/[\d.]+(.+)?/', '${1}', glsr()->version); // allow alpha/beta versions
106
-            if (Helper::isGreaterThanOrEqual($this->currentVersion, $migrationVersion.$suffix)) {
102
+        foreach( $files as $index => $file ) {
103
+            $className = str_replace( '.php', '', $file );
104
+            $migrationVersion = str_replace( ['Migrate_', '_'], ['', '.'], $className );
105
+            $suffix = preg_replace( '/[\d.]+(.+)?/', '${1}', glsr()->version ); // allow alpha/beta versions
106
+            if( Helper::isGreaterThanOrEqual( $this->currentVersion, $migrationVersion.$suffix ) ) {
107 107
                 unset($files[$index]);
108 108
             }
109 109
         }
@@ -113,31 +113,31 @@  discard block
 block discarded – undo
113 113
     /**
114 114
      * @return void
115 115
      */
116
-    protected function runMigrations(array $files)
116
+    protected function runMigrations( array $files )
117 117
     {
118
-        if (empty($files)) {
118
+        if( empty($files) ) {
119 119
             return;
120 120
         }
121
-        array_walk($files, function ($file) {
122
-            $className = str_replace('.php', '', $file);
123
-            glsr('Modules\\Migrations\\'.$className)->run();
124
-            $versionMigrated = str_replace(['Migrate_', '_'], ['v','.'], $className);
125
-            glsr_log()->debug('migration completed for '.$versionMigrated);
121
+        array_walk( $files, function( $file ) {
122
+            $className = str_replace( '.php', '', $file );
123
+            glsr( 'Modules\\Migrations\\'.$className )->run();
124
+            $versionMigrated = str_replace( ['Migrate_', '_'], ['v', '.'], $className );
125
+            glsr_log()->debug( 'migration completed for '.$versionMigrated );
126 126
         });
127
-        if ($this->currentVersion !== glsr()->version) {
128
-            $this->updateVersionFrom($this->currentVersion);
127
+        if( $this->currentVersion !== glsr()->version ) {
128
+            $this->updateVersionFrom( $this->currentVersion );
129 129
         }
130
-        glsr(OptionManager::class)->set('last_migration_run', current_time('timestamp'));
131
-        delete_transient($this->transientKey);
130
+        glsr( OptionManager::class )->set( 'last_migration_run', current_time( 'timestamp' ) );
131
+        delete_transient( $this->transientKey );
132 132
     }
133 133
 
134 134
     /**
135 135
      * @param string $previousVersion
136 136
      * @return void
137 137
      */
138
-    protected function updateVersionFrom($previousVersion)
138
+    protected function updateVersionFrom( $previousVersion )
139 139
     {
140
-        glsr(OptionManager::class)->set('version', glsr()->version);
141
-        glsr(OptionManager::class)->set('version_upgraded_from', $previousVersion);
140
+        glsr( OptionManager::class )->set( 'version', glsr()->version );
141
+        glsr( OptionManager::class )->set( 'version_upgraded_from', $previousVersion );
142 142
     }
143 143
 }
Please login to merge, or discard this patch.
plugin/Application.php 2 patches
Indentation   +325 added lines, -325 removed lines patch added patch discarded remove patch
@@ -17,356 +17,356 @@
 block discarded – undo
17 17
  */
18 18
 final class Application extends Container
19 19
 {
20
-    const CAPABILITY = 'edit_others_posts';
21
-    const CRON_EVENT = 'site-reviews/schedule/session/purge';
22
-    const ID = 'site-reviews';
23
-    const PAGED_QUERY_VAR = 'reviews-page';
24
-    const POST_TYPE = 'site-review';
25
-    const PREFIX = 'glsr_';
26
-    const TAXONOMY = 'site-review-category';
20
+	const CAPABILITY = 'edit_others_posts';
21
+	const CRON_EVENT = 'site-reviews/schedule/session/purge';
22
+	const ID = 'site-reviews';
23
+	const PAGED_QUERY_VAR = 'reviews-page';
24
+	const POST_TYPE = 'site-review';
25
+	const PREFIX = 'glsr_';
26
+	const TAXONOMY = 'site-review-category';
27 27
 
28
-    public $addons = [];
29
-    public $defaults;
30
-    public $deprecated = [];
31
-    public $file;
32
-    public $languages;
33
-    public $mceShortcodes = []; //defined elsewhere
34
-    public $name;
35
-    public $postTypeColumns = []; // defined elsewhere
36
-    public $reviewTypes;
37
-    public $schemas = []; //defined elsewhere
38
-    public $version;
28
+	public $addons = [];
29
+	public $defaults;
30
+	public $deprecated = [];
31
+	public $file;
32
+	public $languages;
33
+	public $mceShortcodes = []; //defined elsewhere
34
+	public $name;
35
+	public $postTypeColumns = []; // defined elsewhere
36
+	public $reviewTypes;
37
+	public $schemas = []; //defined elsewhere
38
+	public $version;
39 39
 
40
-    public function __construct()
41
-    {
42
-        static::$instance = $this;
43
-        $this->file = realpath(trailingslashit(dirname(__DIR__)).static::ID.'.php');
44
-        $plugin = get_file_data($this->file, [
45
-            'languages' => 'Domain Path',
46
-            'name' => 'Plugin Name',
47
-            'version' => 'Version',
48
-        ], 'plugin');
49
-        array_walk($plugin, function ($value, $key) {
50
-            $this->$key = $value;
51
-        });
52
-    }
40
+	public function __construct()
41
+	{
42
+		static::$instance = $this;
43
+		$this->file = realpath(trailingslashit(dirname(__DIR__)).static::ID.'.php');
44
+		$plugin = get_file_data($this->file, [
45
+			'languages' => 'Domain Path',
46
+			'name' => 'Plugin Name',
47
+			'version' => 'Version',
48
+		], 'plugin');
49
+		array_walk($plugin, function ($value, $key) {
50
+			$this->$key = $value;
51
+		});
52
+	}
53 53
 
54
-    /**
55
-     * @return void
56
-     */
57
-    public function activate()
58
-    {
59
-        $this->scheduleCronJob();
60
-        add_option(static::PREFIX.'activated', true);
61
-    }
54
+	/**
55
+	 * @return void
56
+	 */
57
+	public function activate()
58
+	{
59
+		$this->scheduleCronJob();
60
+		add_option(static::PREFIX.'activated', true);
61
+	}
62 62
 
63
-    /**
64
-     * @param string $view
65
-     * @return string
66
-     */
67
-    public function build($view, array $data = [])
68
-    {
69
-        ob_start();
70
-        $this->render($view, $data);
71
-        return ob_get_clean();
72
-    }
63
+	/**
64
+	 * @param string $view
65
+	 * @return string
66
+	 */
67
+	public function build($view, array $data = [])
68
+	{
69
+		ob_start();
70
+		$this->render($view, $data);
71
+		return ob_get_clean();
72
+	}
73 73
 
74
-    /**
75
-     * @param string $capability
76
-     * @return bool
77
-     */
78
-    public function can($capability)
79
-    {
80
-        return $this->make(Role::class)->can($capability);
81
-    }
74
+	/**
75
+	 * @param string $capability
76
+	 * @return bool
77
+	 */
78
+	public function can($capability)
79
+	{
80
+		return $this->make(Role::class)->can($capability);
81
+	}
82 82
 
83
-    /**
84
-     * @return void
85
-     */
86
-    public function catchFatalError()
87
-    {
88
-        $error = error_get_last();
89
-        if (E_ERROR !== $error['type'] || !Str::contains($error['message'], $this->path())) {
90
-            return;
91
-        }
92
-        glsr_log()->error($error['message']);
93
-    }
83
+	/**
84
+	 * @return void
85
+	 */
86
+	public function catchFatalError()
87
+	{
88
+		$error = error_get_last();
89
+		if (E_ERROR !== $error['type'] || !Str::contains($error['message'], $this->path())) {
90
+			return;
91
+		}
92
+		glsr_log()->error($error['message']);
93
+	}
94 94
 
95
-    /**
96
-     * @param string $name
97
-     * @return array
98
-     */
99
-    public function config($name)
100
-    {
101
-        $configFile = $this->path('config/'.$name.'.php');
102
-        $config = file_exists($configFile)
103
-            ? include $configFile
104
-            : [];
105
-        return apply_filters('site-reviews/config/'.$name, $config);
106
-    }
95
+	/**
96
+	 * @param string $name
97
+	 * @return array
98
+	 */
99
+	public function config($name)
100
+	{
101
+		$configFile = $this->path('config/'.$name.'.php');
102
+		$config = file_exists($configFile)
103
+			? include $configFile
104
+			: [];
105
+		return apply_filters('site-reviews/config/'.$name, $config);
106
+	}
107 107
 
108
-    /**
109
-     * @param string $property
110
-     * @return string
111
-     */
112
-    public function constant($property, $className = 'static')
113
-    {
114
-        $constant = $className.'::'.$property;
115
-        return defined($constant)
116
-            ? apply_filters('site-reviews/const/'.$property, constant($constant))
117
-            : '';
118
-    }
108
+	/**
109
+	 * @param string $property
110
+	 * @return string
111
+	 */
112
+	public function constant($property, $className = 'static')
113
+	{
114
+		$constant = $className.'::'.$property;
115
+		return defined($constant)
116
+			? apply_filters('site-reviews/const/'.$property, constant($constant))
117
+			: '';
118
+	}
119 119
 
120
-    /**
121
-     * @return void
122
-     */
123
-    public function deactivate()
124
-    {
125
-        $this->unscheduleCronJob();
126
-    }
120
+	/**
121
+	 * @return void
122
+	 */
123
+	public function deactivate()
124
+	{
125
+		$this->unscheduleCronJob();
126
+	}
127 127
 
128
-    /**
129
-     * @param string $view
130
-     * @return void|string
131
-     */
132
-    public function file($view)
133
-    {
134
-        $view.= '.php';
135
-        $filePaths = [];
136
-        if (Str::startsWith('templates/', $view)) {
137
-            $filePaths[] = $this->themePath(Str::removePrefix('templates/', $view));
138
-        }
139
-        $filePaths[] = $this->path($view);
140
-        $filePaths[] = $this->path('views/'.$view);
141
-        foreach ($filePaths as $file) {
142
-            if (!file_exists($file)) {
143
-                continue;
144
-            }
145
-            return $file;
146
-        }
147
-    }
128
+	/**
129
+	 * @param string $view
130
+	 * @return void|string
131
+	 */
132
+	public function file($view)
133
+	{
134
+		$view.= '.php';
135
+		$filePaths = [];
136
+		if (Str::startsWith('templates/', $view)) {
137
+			$filePaths[] = $this->themePath(Str::removePrefix('templates/', $view));
138
+		}
139
+		$filePaths[] = $this->path($view);
140
+		$filePaths[] = $this->path('views/'.$view);
141
+		foreach ($filePaths as $file) {
142
+			if (!file_exists($file)) {
143
+				continue;
144
+			}
145
+			return $file;
146
+		}
147
+	}
148 148
 
149
-    /**
150
-     * @return array
151
-     */
152
-    public function getDefaults()
153
-    {
154
-        if (empty($this->defaults)) {
155
-            $this->defaults = $this->make(DefaultsManager::class)->get();
156
-        }
157
-        return apply_filters('site-reviews/get/defaults', $this->defaults);
158
-    }
149
+	/**
150
+	 * @return array
151
+	 */
152
+	public function getDefaults()
153
+	{
154
+		if (empty($this->defaults)) {
155
+			$this->defaults = $this->make(DefaultsManager::class)->get();
156
+		}
157
+		return apply_filters('site-reviews/get/defaults', $this->defaults);
158
+	}
159 159
 
160
-    /**
161
-     * @param string $page
162
-     * @param string $tab
163
-     * @return string
164
-     */
165
-    public function getPermission($page = '', $tab = 'index')
166
-    {
167
-        $fallback = 'edit_posts';
168
-        $permissions = [
169
-            'addons' => 'install_plugins',
170
-            'documentation' => [
171
-                'faq' => 'edit_others_posts',
172
-                'functions' => 'manage_options',
173
-                'hooks' => 'edit_others_posts',
174
-                'index' => 'edit_posts',
175
-                'support' => 'edit_others_posts',
176
-            ],
177
-            'settings' => 'manage_options',
178
-            'tools' => [
179
-                'console' => 'edit_others_posts',
180
-                'general' => 'edit_others_posts',
181
-                'index' => 'edit_others_posts',
182
-                'sync' => 'manage_options',
183
-                'system-info' => 'edit_others_posts',
184
-            ]
185
-        ];
186
-        $permission = Arr::get($permissions, $page, $fallback);
187
-        if (is_array($permission)) {
188
-            $permission = Arr::get($permission, $tab, $fallback);
189
-        }
190
-        return empty($permission) || !is_string($permission)
191
-            ? $fallback
192
-            : $permission;
193
-    }
160
+	/**
161
+	 * @param string $page
162
+	 * @param string $tab
163
+	 * @return string
164
+	 */
165
+	public function getPermission($page = '', $tab = 'index')
166
+	{
167
+		$fallback = 'edit_posts';
168
+		$permissions = [
169
+			'addons' => 'install_plugins',
170
+			'documentation' => [
171
+				'faq' => 'edit_others_posts',
172
+				'functions' => 'manage_options',
173
+				'hooks' => 'edit_others_posts',
174
+				'index' => 'edit_posts',
175
+				'support' => 'edit_others_posts',
176
+			],
177
+			'settings' => 'manage_options',
178
+			'tools' => [
179
+				'console' => 'edit_others_posts',
180
+				'general' => 'edit_others_posts',
181
+				'index' => 'edit_others_posts',
182
+				'sync' => 'manage_options',
183
+				'system-info' => 'edit_others_posts',
184
+			]
185
+		];
186
+		$permission = Arr::get($permissions, $page, $fallback);
187
+		if (is_array($permission)) {
188
+			$permission = Arr::get($permission, $tab, $fallback);
189
+		}
190
+		return empty($permission) || !is_string($permission)
191
+			? $fallback
192
+			: $permission;
193
+	}
194 194
 
195
-    /**
196
-     * @param string $page
197
-     * @param string $tab
198
-     * @return bool
199
-     */
200
-    public function hasPermission($page = '', $tab = 'index')
201
-    {
202
-        $isAdmin = $this->isAdmin();
203
-        return !$isAdmin || ($isAdmin && $this->can($this->getPermission($page, $tab)));
204
-    }
195
+	/**
196
+	 * @param string $page
197
+	 * @param string $tab
198
+	 * @return bool
199
+	 */
200
+	public function hasPermission($page = '', $tab = 'index')
201
+	{
202
+		$isAdmin = $this->isAdmin();
203
+		return !$isAdmin || ($isAdmin && $this->can($this->getPermission($page, $tab)));
204
+	}
205 205
 
206
-    /**
207
-     * @return void
208
-     */
209
-    public function init()
210
-    {
211
-        $this->make(Actions::class)->run();
212
-        $this->make(Filters::class)->run();
213
-    }
206
+	/**
207
+	 * @return void
208
+	 */
209
+	public function init()
210
+	{
211
+		$this->make(Actions::class)->run();
212
+		$this->make(Filters::class)->run();
213
+	}
214 214
 
215
-    /**
216
-     * @return bool
217
-     */
218
-    public function isAdmin()
219
-    {
220
-        return is_admin() && !wp_doing_ajax();
221
-    }
215
+	/**
216
+	 * @return bool
217
+	 */
218
+	public function isAdmin()
219
+	{
220
+		return is_admin() && !wp_doing_ajax();
221
+	}
222 222
 
223
-    /**
224
-     * @param string $file
225
-     * @return string
226
-     */
227
-    public function path($file = '', $realpath = true)
228
-    {
229
-        $path = plugin_dir_path($this->file);
230
-        if (!$realpath) {
231
-            $path = trailingslashit(WP_PLUGIN_DIR).basename(dirname($this->file));
232
-        }
233
-        $path = trailingslashit($path).ltrim(trim($file), '/');
234
-        return apply_filters('site-reviews/path', $path, $file);
235
-    }
223
+	/**
224
+	 * @param string $file
225
+	 * @return string
226
+	 */
227
+	public function path($file = '', $realpath = true)
228
+	{
229
+		$path = plugin_dir_path($this->file);
230
+		if (!$realpath) {
231
+			$path = trailingslashit(WP_PLUGIN_DIR).basename(dirname($this->file));
232
+		}
233
+		$path = trailingslashit($path).ltrim(trim($file), '/');
234
+		return apply_filters('site-reviews/path', $path, $file);
235
+	}
236 236
 
237
-    /**
238
-     * @param object $addon
239
-     * @return void
240
-     */
241
-    public function register($addon)
242
-    {
243
-        try {
244
-            $reflection = new \ReflectionClass($addon);
245
-            if ($id = $reflection->getConstant('ID')) {
246
-                $this->addons[] = $id;
247
-                $this->bind($id, $addon);
248
-                $addon->init();
249
-            }
250
-        } catch(\ReflectionException $e) {
251
-            glsr_log()->error('Attempted to register an invalid addon.');
252
-        }
253
-    }
237
+	/**
238
+	 * @param object $addon
239
+	 * @return void
240
+	 */
241
+	public function register($addon)
242
+	{
243
+		try {
244
+			$reflection = new \ReflectionClass($addon);
245
+			if ($id = $reflection->getConstant('ID')) {
246
+				$this->addons[] = $id;
247
+				$this->bind($id, $addon);
248
+				$addon->init();
249
+			}
250
+		} catch(\ReflectionException $e) {
251
+			glsr_log()->error('Attempted to register an invalid addon.');
252
+		}
253
+	}
254 254
 
255
-    /**
256
-     * @return void
257
-     */
258
-    public function registerAddons()
259
-    {
260
-        do_action('site-reviews/addon/register', $this);
261
-    }
255
+	/**
256
+	 * @return void
257
+	 */
258
+	public function registerAddons()
259
+	{
260
+		do_action('site-reviews/addon/register', $this);
261
+	}
262 262
 
263
-    /**
264
-     * @return void
265
-     */
266
-    public function registerLanguages()
267
-    {
268
-        load_plugin_textdomain(static::ID, false,
269
-            trailingslashit(plugin_basename($this->path()).'/'.$this->languages)
270
-        );
271
-    }
263
+	/**
264
+	 * @return void
265
+	 */
266
+	public function registerLanguages()
267
+	{
268
+		load_plugin_textdomain(static::ID, false,
269
+			trailingslashit(plugin_basename($this->path()).'/'.$this->languages)
270
+		);
271
+	}
272 272
 
273
-    /**
274
-     * @return void
275
-     */
276
-    public function registerReviewTypes()
277
-    {
278
-        $types = apply_filters('site-reviews/addon/types', []);
279
-        $this->reviewTypes = wp_parse_args($types, [
280
-            'local' => __('Local', 'site-reviews'),
281
-        ]);
282
-    }
273
+	/**
274
+	 * @return void
275
+	 */
276
+	public function registerReviewTypes()
277
+	{
278
+		$types = apply_filters('site-reviews/addon/types', []);
279
+		$this->reviewTypes = wp_parse_args($types, [
280
+			'local' => __('Local', 'site-reviews'),
281
+		]);
282
+	}
283 283
 
284
-    /**
285
-     * @param string $view
286
-     * @return void
287
-     */
288
-    public function render($view, array $data = [])
289
-    {
290
-        $view = apply_filters('site-reviews/render/view', $view, $data);
291
-        $file = apply_filters('site-reviews/views/file', $this->file($view), $view, $data);
292
-        if (!file_exists($file)) {
293
-            glsr_log()->error('File not found: '.$file);
294
-            return;
295
-        }
296
-        $data = apply_filters('site-reviews/views/data', $data, $view);
297
-        extract($data);
298
-        include $file;
299
-    }
284
+	/**
285
+	 * @param string $view
286
+	 * @return void
287
+	 */
288
+	public function render($view, array $data = [])
289
+	{
290
+		$view = apply_filters('site-reviews/render/view', $view, $data);
291
+		$file = apply_filters('site-reviews/views/file', $this->file($view), $view, $data);
292
+		if (!file_exists($file)) {
293
+			glsr_log()->error('File not found: '.$file);
294
+			return;
295
+		}
296
+		$data = apply_filters('site-reviews/views/data', $data, $view);
297
+		extract($data);
298
+		include $file;
299
+	}
300 300
 
301
-    /**
302
-     * @return void
303
-     */
304
-    public function scheduleCronJob()
305
-    {
306
-        if (false === wp_next_scheduled(static::CRON_EVENT)) {
307
-            wp_schedule_event(time(), 'twicedaily', static::CRON_EVENT);
308
-        }
309
-    }
301
+	/**
302
+	 * @return void
303
+	 */
304
+	public function scheduleCronJob()
305
+	{
306
+		if (false === wp_next_scheduled(static::CRON_EVENT)) {
307
+			wp_schedule_event(time(), 'twicedaily', static::CRON_EVENT);
308
+		}
309
+	}
310 310
 
311
-    /**
312
-     * @return void
313
-     */
314
-    public function setDefaults()
315
-    {
316
-        if (get_option(static::PREFIX.'activated')) {
317
-            $this->make(DefaultsManager::class)->set();
318
-            delete_option(static::PREFIX.'activated');
319
-        }
320
-    }
311
+	/**
312
+	 * @return void
313
+	 */
314
+	public function setDefaults()
315
+	{
316
+		if (get_option(static::PREFIX.'activated')) {
317
+			$this->make(DefaultsManager::class)->set();
318
+			delete_option(static::PREFIX.'activated');
319
+		}
320
+	}
321 321
 
322
-    /**
323
-     * @param string $file
324
-     * @return string
325
-     */
326
-    public function themePath($file = '')
327
-    {
328
-        return get_stylesheet_directory().'/'.static::ID.'/'.ltrim(trim($file), '/');
329
-    }
322
+	/**
323
+	 * @param string $file
324
+	 * @return string
325
+	 */
326
+	public function themePath($file = '')
327
+	{
328
+		return get_stylesheet_directory().'/'.static::ID.'/'.ltrim(trim($file), '/');
329
+	}
330 330
 
331
-    /**
332
-     * @return void
333
-     */
334
-    public function unscheduleCronJob()
335
-    {
336
-        wp_unschedule_event(intval(wp_next_scheduled(static::CRON_EVENT)), static::CRON_EVENT);
337
-    }
331
+	/**
332
+	 * @return void
333
+	 */
334
+	public function unscheduleCronJob()
335
+	{
336
+		wp_unschedule_event(intval(wp_next_scheduled(static::CRON_EVENT)), static::CRON_EVENT);
337
+	}
338 338
 
339
-    /**
340
-     * @param string $path
341
-     * @return string
342
-     */
343
-    public function url($path = '')
344
-    {
345
-        $url = esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/'));
346
-        return apply_filters('site-reviews/url', $url, $path);
347
-    }
339
+	/**
340
+	 * @param string $path
341
+	 * @return string
342
+	 */
343
+	public function url($path = '')
344
+	{
345
+		$url = esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/'));
346
+		return apply_filters('site-reviews/url', $url, $path);
347
+	}
348 348
 
349
-    /**
350
-     * @param string $versionLevel
351
-     * @return string
352
-     */
353
-    public function version($versionLevel = '')
354
-    {
355
-        $pattern = '/^v?(\d{1,5})(\.\d++)?(\.\d++)?(.+)?$/i';
356
-        preg_match($pattern, $this->version, $matches);
357
-        switch ($versionLevel) {
358
-            case 'major':
359
-                $version = Arr::get($matches, 1);
360
-                break;
361
-            case 'minor':
362
-                $version = Arr::get($matches, 1).Arr::get($matches, 2);
363
-                break;
364
-            case 'patch':
365
-                $version = Arr::get($matches, 1).Arr::get($matches, 2).Arr::get($matches, 3);
366
-                break;
367
-        }
368
-        return empty($version)
369
-            ? $this->version
370
-            : $version;
371
-    }
349
+	/**
350
+	 * @param string $versionLevel
351
+	 * @return string
352
+	 */
353
+	public function version($versionLevel = '')
354
+	{
355
+		$pattern = '/^v?(\d{1,5})(\.\d++)?(\.\d++)?(.+)?$/i';
356
+		preg_match($pattern, $this->version, $matches);
357
+		switch ($versionLevel) {
358
+			case 'major':
359
+				$version = Arr::get($matches, 1);
360
+				break;
361
+			case 'minor':
362
+				$version = Arr::get($matches, 1).Arr::get($matches, 2);
363
+				break;
364
+			case 'patch':
365
+				$version = Arr::get($matches, 1).Arr::get($matches, 2).Arr::get($matches, 3);
366
+				break;
367
+		}
368
+		return empty($version)
369
+			? $this->version
370
+			: $version;
371
+	}
372 372
 }
Please login to merge, or discard this patch.
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
     public function __construct()
41 41
     {
42 42
         static::$instance = $this;
43
-        $this->file = realpath(trailingslashit(dirname(__DIR__)).static::ID.'.php');
44
-        $plugin = get_file_data($this->file, [
43
+        $this->file = realpath( trailingslashit( dirname( __DIR__ ) ).static::ID.'.php' );
44
+        $plugin = get_file_data( $this->file, [
45 45
             'languages' => 'Domain Path',
46 46
             'name' => 'Plugin Name',
47 47
             'version' => 'Version',
48
-        ], 'plugin');
49
-        array_walk($plugin, function ($value, $key) {
48
+        ], 'plugin' );
49
+        array_walk( $plugin, function( $value, $key ) {
50 50
             $this->$key = $value;
51 51
         });
52 52
     }
@@ -57,17 +57,17 @@  discard block
 block discarded – undo
57 57
     public function activate()
58 58
     {
59 59
         $this->scheduleCronJob();
60
-        add_option(static::PREFIX.'activated', true);
60
+        add_option( static::PREFIX.'activated', true );
61 61
     }
62 62
 
63 63
     /**
64 64
      * @param string $view
65 65
      * @return string
66 66
      */
67
-    public function build($view, array $data = [])
67
+    public function build( $view, array $data = [] )
68 68
     {
69 69
         ob_start();
70
-        $this->render($view, $data);
70
+        $this->render( $view, $data );
71 71
         return ob_get_clean();
72 72
     }
73 73
 
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
      * @param string $capability
76 76
      * @return bool
77 77
      */
78
-    public function can($capability)
78
+    public function can( $capability )
79 79
     {
80
-        return $this->make(Role::class)->can($capability);
80
+        return $this->make( Role::class )->can( $capability );
81 81
     }
82 82
 
83 83
     /**
@@ -86,34 +86,34 @@  discard block
 block discarded – undo
86 86
     public function catchFatalError()
87 87
     {
88 88
         $error = error_get_last();
89
-        if (E_ERROR !== $error['type'] || !Str::contains($error['message'], $this->path())) {
89
+        if( E_ERROR !== $error['type'] || !Str::contains( $error['message'], $this->path() ) ) {
90 90
             return;
91 91
         }
92
-        glsr_log()->error($error['message']);
92
+        glsr_log()->error( $error['message'] );
93 93
     }
94 94
 
95 95
     /**
96 96
      * @param string $name
97 97
      * @return array
98 98
      */
99
-    public function config($name)
99
+    public function config( $name )
100 100
     {
101
-        $configFile = $this->path('config/'.$name.'.php');
102
-        $config = file_exists($configFile)
101
+        $configFile = $this->path( 'config/'.$name.'.php' );
102
+        $config = file_exists( $configFile )
103 103
             ? include $configFile
104 104
             : [];
105
-        return apply_filters('site-reviews/config/'.$name, $config);
105
+        return apply_filters( 'site-reviews/config/'.$name, $config );
106 106
     }
107 107
 
108 108
     /**
109 109
      * @param string $property
110 110
      * @return string
111 111
      */
112
-    public function constant($property, $className = 'static')
112
+    public function constant( $property, $className = 'static' )
113 113
     {
114 114
         $constant = $className.'::'.$property;
115
-        return defined($constant)
116
-            ? apply_filters('site-reviews/const/'.$property, constant($constant))
115
+        return defined( $constant )
116
+            ? apply_filters( 'site-reviews/const/'.$property, constant( $constant ) )
117 117
             : '';
118 118
     }
119 119
 
@@ -129,17 +129,17 @@  discard block
 block discarded – undo
129 129
      * @param string $view
130 130
      * @return void|string
131 131
      */
132
-    public function file($view)
132
+    public function file( $view )
133 133
     {
134
-        $view.= '.php';
134
+        $view .= '.php';
135 135
         $filePaths = [];
136
-        if (Str::startsWith('templates/', $view)) {
137
-            $filePaths[] = $this->themePath(Str::removePrefix('templates/', $view));
136
+        if( Str::startsWith( 'templates/', $view ) ) {
137
+            $filePaths[] = $this->themePath( Str::removePrefix( 'templates/', $view ) );
138 138
         }
139
-        $filePaths[] = $this->path($view);
140
-        $filePaths[] = $this->path('views/'.$view);
141
-        foreach ($filePaths as $file) {
142
-            if (!file_exists($file)) {
139
+        $filePaths[] = $this->path( $view );
140
+        $filePaths[] = $this->path( 'views/'.$view );
141
+        foreach( $filePaths as $file ) {
142
+            if( !file_exists( $file ) ) {
143 143
                 continue;
144 144
             }
145 145
             return $file;
@@ -151,10 +151,10 @@  discard block
 block discarded – undo
151 151
      */
152 152
     public function getDefaults()
153 153
     {
154
-        if (empty($this->defaults)) {
155
-            $this->defaults = $this->make(DefaultsManager::class)->get();
154
+        if( empty($this->defaults) ) {
155
+            $this->defaults = $this->make( DefaultsManager::class )->get();
156 156
         }
157
-        return apply_filters('site-reviews/get/defaults', $this->defaults);
157
+        return apply_filters( 'site-reviews/get/defaults', $this->defaults );
158 158
     }
159 159
 
160 160
     /**
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
      * @param string $tab
163 163
      * @return string
164 164
      */
165
-    public function getPermission($page = '', $tab = 'index')
165
+    public function getPermission( $page = '', $tab = 'index' )
166 166
     {
167 167
         $fallback = 'edit_posts';
168 168
         $permissions = [
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
                 'system-info' => 'edit_others_posts',
184 184
             ]
185 185
         ];
186
-        $permission = Arr::get($permissions, $page, $fallback);
187
-        if (is_array($permission)) {
188
-            $permission = Arr::get($permission, $tab, $fallback);
186
+        $permission = Arr::get( $permissions, $page, $fallback );
187
+        if( is_array( $permission ) ) {
188
+            $permission = Arr::get( $permission, $tab, $fallback );
189 189
         }
190
-        return empty($permission) || !is_string($permission)
190
+        return empty($permission) || !is_string( $permission )
191 191
             ? $fallback
192 192
             : $permission;
193 193
     }
@@ -197,10 +197,10 @@  discard block
 block discarded – undo
197 197
      * @param string $tab
198 198
      * @return bool
199 199
      */
200
-    public function hasPermission($page = '', $tab = 'index')
200
+    public function hasPermission( $page = '', $tab = 'index' )
201 201
     {
202 202
         $isAdmin = $this->isAdmin();
203
-        return !$isAdmin || ($isAdmin && $this->can($this->getPermission($page, $tab)));
203
+        return !$isAdmin || ($isAdmin && $this->can( $this->getPermission( $page, $tab ) ));
204 204
     }
205 205
 
206 206
     /**
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
      */
209 209
     public function init()
210 210
     {
211
-        $this->make(Actions::class)->run();
212
-        $this->make(Filters::class)->run();
211
+        $this->make( Actions::class )->run();
212
+        $this->make( Filters::class )->run();
213 213
     }
214 214
 
215 215
     /**
@@ -224,31 +224,31 @@  discard block
 block discarded – undo
224 224
      * @param string $file
225 225
      * @return string
226 226
      */
227
-    public function path($file = '', $realpath = true)
227
+    public function path( $file = '', $realpath = true )
228 228
     {
229
-        $path = plugin_dir_path($this->file);
230
-        if (!$realpath) {
231
-            $path = trailingslashit(WP_PLUGIN_DIR).basename(dirname($this->file));
229
+        $path = plugin_dir_path( $this->file );
230
+        if( !$realpath ) {
231
+            $path = trailingslashit( WP_PLUGIN_DIR ).basename( dirname( $this->file ) );
232 232
         }
233
-        $path = trailingslashit($path).ltrim(trim($file), '/');
234
-        return apply_filters('site-reviews/path', $path, $file);
233
+        $path = trailingslashit( $path ).ltrim( trim( $file ), '/' );
234
+        return apply_filters( 'site-reviews/path', $path, $file );
235 235
     }
236 236
 
237 237
     /**
238 238
      * @param object $addon
239 239
      * @return void
240 240
      */
241
-    public function register($addon)
241
+    public function register( $addon )
242 242
     {
243 243
         try {
244
-            $reflection = new \ReflectionClass($addon);
245
-            if ($id = $reflection->getConstant('ID')) {
244
+            $reflection = new \ReflectionClass( $addon );
245
+            if( $id = $reflection->getConstant( 'ID' ) ) {
246 246
                 $this->addons[] = $id;
247
-                $this->bind($id, $addon);
247
+                $this->bind( $id, $addon );
248 248
                 $addon->init();
249 249
             }
250
-        } catch(\ReflectionException $e) {
251
-            glsr_log()->error('Attempted to register an invalid addon.');
250
+        } catch( \ReflectionException $e ) {
251
+            glsr_log()->error( 'Attempted to register an invalid addon.' );
252 252
         }
253 253
     }
254 254
 
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
      */
258 258
     public function registerAddons()
259 259
     {
260
-        do_action('site-reviews/addon/register', $this);
260
+        do_action( 'site-reviews/addon/register', $this );
261 261
     }
262 262
 
263 263
     /**
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
      */
266 266
     public function registerLanguages()
267 267
     {
268
-        load_plugin_textdomain(static::ID, false,
269
-            trailingslashit(plugin_basename($this->path()).'/'.$this->languages)
268
+        load_plugin_textdomain( static::ID, false,
269
+            trailingslashit( plugin_basename( $this->path() ).'/'.$this->languages )
270 270
         );
271 271
     }
272 272
 
@@ -275,26 +275,26 @@  discard block
 block discarded – undo
275 275
      */
276 276
     public function registerReviewTypes()
277 277
     {
278
-        $types = apply_filters('site-reviews/addon/types', []);
279
-        $this->reviewTypes = wp_parse_args($types, [
280
-            'local' => __('Local', 'site-reviews'),
281
-        ]);
278
+        $types = apply_filters( 'site-reviews/addon/types', [] );
279
+        $this->reviewTypes = wp_parse_args( $types, [
280
+            'local' => __( 'Local', 'site-reviews' ),
281
+        ] );
282 282
     }
283 283
 
284 284
     /**
285 285
      * @param string $view
286 286
      * @return void
287 287
      */
288
-    public function render($view, array $data = [])
288
+    public function render( $view, array $data = [] )
289 289
     {
290
-        $view = apply_filters('site-reviews/render/view', $view, $data);
291
-        $file = apply_filters('site-reviews/views/file', $this->file($view), $view, $data);
292
-        if (!file_exists($file)) {
293
-            glsr_log()->error('File not found: '.$file);
290
+        $view = apply_filters( 'site-reviews/render/view', $view, $data );
291
+        $file = apply_filters( 'site-reviews/views/file', $this->file( $view ), $view, $data );
292
+        if( !file_exists( $file ) ) {
293
+            glsr_log()->error( 'File not found: '.$file );
294 294
             return;
295 295
         }
296
-        $data = apply_filters('site-reviews/views/data', $data, $view);
297
-        extract($data);
296
+        $data = apply_filters( 'site-reviews/views/data', $data, $view );
297
+        extract( $data );
298 298
         include $file;
299 299
     }
300 300
 
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
      */
304 304
     public function scheduleCronJob()
305 305
     {
306
-        if (false === wp_next_scheduled(static::CRON_EVENT)) {
307
-            wp_schedule_event(time(), 'twicedaily', static::CRON_EVENT);
306
+        if( false === wp_next_scheduled( static::CRON_EVENT ) ) {
307
+            wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT );
308 308
         }
309 309
     }
310 310
 
@@ -313,9 +313,9 @@  discard block
 block discarded – undo
313 313
      */
314 314
     public function setDefaults()
315 315
     {
316
-        if (get_option(static::PREFIX.'activated')) {
317
-            $this->make(DefaultsManager::class)->set();
318
-            delete_option(static::PREFIX.'activated');
316
+        if( get_option( static::PREFIX.'activated' ) ) {
317
+            $this->make( DefaultsManager::class )->set();
318
+            delete_option( static::PREFIX.'activated' );
319 319
         }
320 320
     }
321 321
 
@@ -323,9 +323,9 @@  discard block
 block discarded – undo
323 323
      * @param string $file
324 324
      * @return string
325 325
      */
326
-    public function themePath($file = '')
326
+    public function themePath( $file = '' )
327 327
     {
328
-        return get_stylesheet_directory().'/'.static::ID.'/'.ltrim(trim($file), '/');
328
+        return get_stylesheet_directory().'/'.static::ID.'/'.ltrim( trim( $file ), '/' );
329 329
     }
330 330
 
331 331
     /**
@@ -333,36 +333,36 @@  discard block
 block discarded – undo
333 333
      */
334 334
     public function unscheduleCronJob()
335 335
     {
336
-        wp_unschedule_event(intval(wp_next_scheduled(static::CRON_EVENT)), static::CRON_EVENT);
336
+        wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT ) ), static::CRON_EVENT );
337 337
     }
338 338
 
339 339
     /**
340 340
      * @param string $path
341 341
      * @return string
342 342
      */
343
-    public function url($path = '')
343
+    public function url( $path = '' )
344 344
     {
345
-        $url = esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/'));
346
-        return apply_filters('site-reviews/url', $url, $path);
345
+        $url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) );
346
+        return apply_filters( 'site-reviews/url', $url, $path );
347 347
     }
348 348
 
349 349
     /**
350 350
      * @param string $versionLevel
351 351
      * @return string
352 352
      */
353
-    public function version($versionLevel = '')
353
+    public function version( $versionLevel = '' )
354 354
     {
355 355
         $pattern = '/^v?(\d{1,5})(\.\d++)?(\.\d++)?(.+)?$/i';
356
-        preg_match($pattern, $this->version, $matches);
357
-        switch ($versionLevel) {
356
+        preg_match( $pattern, $this->version, $matches );
357
+        switch( $versionLevel ) {
358 358
             case 'major':
359
-                $version = Arr::get($matches, 1);
359
+                $version = Arr::get( $matches, 1 );
360 360
                 break;
361 361
             case 'minor':
362
-                $version = Arr::get($matches, 1).Arr::get($matches, 2);
362
+                $version = Arr::get( $matches, 1 ).Arr::get( $matches, 2 );
363 363
                 break;
364 364
             case 'patch':
365
-                $version = Arr::get($matches, 1).Arr::get($matches, 2).Arr::get($matches, 3);
365
+                $version = Arr::get( $matches, 1 ).Arr::get( $matches, 2 ).Arr::get( $matches, 3 );
366 366
                 break;
367 367
         }
368 368
         return empty($version)
Please login to merge, or discard this patch.
plugin/Controllers/EditorController.php 2 patches
Indentation   +374 added lines, -374 removed lines patch added patch discarded remove patch
@@ -20,402 +20,402 @@
 block discarded – undo
20 20
 
21 21
 class EditorController extends Controller
22 22
 {
23
-    /**
24
-     * @param array $settings
25
-     * @return array
26
-     * @filter wp_editor_settings
27
-     */
28
-    public function filterEditorSettings($settings)
29
-    {
30
-        return glsr(Customization::class)->filterEditorSettings(
31
-            Arr::consolidateArray($settings)
32
-        );
33
-    }
23
+	/**
24
+	 * @param array $settings
25
+	 * @return array
26
+	 * @filter wp_editor_settings
27
+	 */
28
+	public function filterEditorSettings($settings)
29
+	{
30
+		return glsr(Customization::class)->filterEditorSettings(
31
+			Arr::consolidateArray($settings)
32
+		);
33
+	}
34 34
 
35
-    /**
36
-     * Modify the WP_Editor html to allow autosizing without breaking the `editor-expand` script.
37
-     * @param string $html
38
-     * @return string
39
-     * @filter the_editor
40
-     */
41
-    public function filterEditorTextarea($html)
42
-    {
43
-        return glsr(Customization::class)->filterEditorTextarea($html);
44
-    }
35
+	/**
36
+	 * Modify the WP_Editor html to allow autosizing without breaking the `editor-expand` script.
37
+	 * @param string $html
38
+	 * @return string
39
+	 * @filter the_editor
40
+	 */
41
+	public function filterEditorTextarea($html)
42
+	{
43
+		return glsr(Customization::class)->filterEditorTextarea($html);
44
+	}
45 45
 
46
-    /**
47
-     * @param bool $protected
48
-     * @param string $metaKey
49
-     * @param string $metaType
50
-     * @return bool
51
-     * @filter is_protected_meta
52
-     */
53
-    public function filterIsProtectedMeta($protected, $metaKey, $metaType)
54
-    {
55
-        if ('post' == $metaType && Application::POST_TYPE == get_post_type()) {
56
-            $values = glsr(CreateReviewDefaults::class)->unguarded();
57
-            $values = Arr::prefixArrayKeys($values);
58
-            if (array_key_exists($metaKey, $values)) {
59
-                $protected = false;
60
-            }
61
-        }
62
-        return $protected;
63
-    }
46
+	/**
47
+	 * @param bool $protected
48
+	 * @param string $metaKey
49
+	 * @param string $metaType
50
+	 * @return bool
51
+	 * @filter is_protected_meta
52
+	 */
53
+	public function filterIsProtectedMeta($protected, $metaKey, $metaType)
54
+	{
55
+		if ('post' == $metaType && Application::POST_TYPE == get_post_type()) {
56
+			$values = glsr(CreateReviewDefaults::class)->unguarded();
57
+			$values = Arr::prefixArrayKeys($values);
58
+			if (array_key_exists($metaKey, $values)) {
59
+				$protected = false;
60
+			}
61
+		}
62
+		return $protected;
63
+	}
64 64
 
65
-    /**
66
-     * @param array $messages
67
-     * @return array
68
-     * @filter post_updated_messages
69
-     */
70
-    public function filterUpdateMessages($messages)
71
-    {
72
-        return glsr(Labels::class)->filterUpdateMessages(
73
-            Arr::consolidateArray($messages)
74
-        );
75
-    }
65
+	/**
66
+	 * @param array $messages
67
+	 * @return array
68
+	 * @filter post_updated_messages
69
+	 */
70
+	public function filterUpdateMessages($messages)
71
+	{
72
+		return glsr(Labels::class)->filterUpdateMessages(
73
+			Arr::consolidateArray($messages)
74
+		);
75
+	}
76 76
 
77
-    /**
78
-     * @return void
79
-     * @action add_meta_boxes_{Application::POST_TYPE}
80
-     */
81
-    public function registerMetaBoxes($post)
82
-    {
83
-        add_meta_box(Application::ID.'_assigned_to', __('Assigned To', 'site-reviews'), [$this, 'renderAssignedToMetabox'], null, 'side');
84
-        add_meta_box(Application::ID.'_review', __('Details', 'site-reviews'), [$this, 'renderDetailsMetaBox'], null, 'side');
85
-        if ('local' != glsr(Database::class)->get($post->ID, 'review_type')) {
86
-            return;
87
-        }
88
-        add_meta_box(Application::ID.'_response', __('Respond Publicly', 'site-reviews'), [$this, 'renderResponseMetaBox'], null, 'normal');
89
-    }
77
+	/**
78
+	 * @return void
79
+	 * @action add_meta_boxes_{Application::POST_TYPE}
80
+	 */
81
+	public function registerMetaBoxes($post)
82
+	{
83
+		add_meta_box(Application::ID.'_assigned_to', __('Assigned To', 'site-reviews'), [$this, 'renderAssignedToMetabox'], null, 'side');
84
+		add_meta_box(Application::ID.'_review', __('Details', 'site-reviews'), [$this, 'renderDetailsMetaBox'], null, 'side');
85
+		if ('local' != glsr(Database::class)->get($post->ID, 'review_type')) {
86
+			return;
87
+		}
88
+		add_meta_box(Application::ID.'_response', __('Respond Publicly', 'site-reviews'), [$this, 'renderResponseMetaBox'], null, 'normal');
89
+	}
90 90
 
91
-    /**
92
-     * @return void
93
-     * @action admin_print_scripts
94
-     */
95
-    public function removeAutosave()
96
-    {
97
-        glsr(Customization::class)->removeAutosave();
98
-    }
91
+	/**
92
+	 * @return void
93
+	 * @action admin_print_scripts
94
+	 */
95
+	public function removeAutosave()
96
+	{
97
+		glsr(Customization::class)->removeAutosave();
98
+	}
99 99
 
100
-    /**
101
-     * @return void
102
-     * @action admin_menu
103
-     */
104
-    public function removeMetaBoxes()
105
-    {
106
-        glsr(Customization::class)->removeMetaBoxes();
107
-    }
100
+	/**
101
+	 * @return void
102
+	 * @action admin_menu
103
+	 */
104
+	public function removeMetaBoxes()
105
+	{
106
+		glsr(Customization::class)->removeMetaBoxes();
107
+	}
108 108
 
109
-    /**
110
-     * @return void
111
-     */
112
-    public function removePostTypeSupport()
113
-    {
114
-        glsr(Customization::class)->removePostTypeSupport();
115
-    }
109
+	/**
110
+	 * @return void
111
+	 */
112
+	public function removePostTypeSupport()
113
+	{
114
+		glsr(Customization::class)->removePostTypeSupport();
115
+	}
116 116
 
117
-    /**
118
-     * @param WP_Post $post
119
-     * @return void
120
-     * @callback add_meta_box
121
-     */
122
-    public function renderAssignedToMetabox($post)
123
-    {
124
-        if (!$this->isReviewPostType($post)) {
125
-            return;
126
-        }
127
-        $assignedTo = (string) glsr(Database::class)->get($post->ID, 'assigned_to');
128
-        wp_nonce_field('assigned_to', '_nonce-assigned-to', false);
129
-        glsr()->render('partials/editor/metabox-assigned-to', [
130
-            'id' => $assignedTo,
131
-            'template' => $this->buildAssignedToTemplate($assignedTo, $post),
132
-        ]);
133
-    }
117
+	/**
118
+	 * @param WP_Post $post
119
+	 * @return void
120
+	 * @callback add_meta_box
121
+	 */
122
+	public function renderAssignedToMetabox($post)
123
+	{
124
+		if (!$this->isReviewPostType($post)) {
125
+			return;
126
+		}
127
+		$assignedTo = (string) glsr(Database::class)->get($post->ID, 'assigned_to');
128
+		wp_nonce_field('assigned_to', '_nonce-assigned-to', false);
129
+		glsr()->render('partials/editor/metabox-assigned-to', [
130
+			'id' => $assignedTo,
131
+			'template' => $this->buildAssignedToTemplate($assignedTo, $post),
132
+		]);
133
+	}
134 134
 
135
-    /**
136
-     * @param WP_Post $post
137
-     * @return void
138
-     * @callback add_meta_box
139
-     */
140
-    public function renderDetailsMetaBox($post)
141
-    {
142
-        if (!$this->isReviewPostType($post)) {
143
-            return;
144
-        }
145
-        $review = glsr_get_review($post);
146
-        glsr()->render('partials/editor/metabox-details', [
147
-            'button' => $this->buildDetailsMetaBoxRevertButton($review, $post),
148
-            'metabox' => $this->normalizeDetailsMetaBox($review),
149
-        ]);
150
-    }
135
+	/**
136
+	 * @param WP_Post $post
137
+	 * @return void
138
+	 * @callback add_meta_box
139
+	 */
140
+	public function renderDetailsMetaBox($post)
141
+	{
142
+		if (!$this->isReviewPostType($post)) {
143
+			return;
144
+		}
145
+		$review = glsr_get_review($post);
146
+		glsr()->render('partials/editor/metabox-details', [
147
+			'button' => $this->buildDetailsMetaBoxRevertButton($review, $post),
148
+			'metabox' => $this->normalizeDetailsMetaBox($review),
149
+		]);
150
+	}
151 151
 
152
-    /**
153
-     * @return void
154
-     * @action post_submitbox_misc_actions
155
-     */
156
-    public function renderPinnedInPublishMetaBox()
157
-    {
158
-        if (!$this->isReviewPostType(get_post())
159
-            || !glsr()->can('edit_others_posts')) {
160
-            return;
161
-        }
162
-        glsr(Template::class)->render('partials/editor/pinned', [
163
-            'context' => [
164
-                'no' => __('No', 'site-reviews'),
165
-                'yes' => __('Yes', 'site-reviews'),
166
-            ],
167
-            'pinned' => wp_validate_boolean(glsr(Database::class)->get(get_the_ID(), 'pinned')),
168
-        ]);
169
-    }
152
+	/**
153
+	 * @return void
154
+	 * @action post_submitbox_misc_actions
155
+	 */
156
+	public function renderPinnedInPublishMetaBox()
157
+	{
158
+		if (!$this->isReviewPostType(get_post())
159
+			|| !glsr()->can('edit_others_posts')) {
160
+			return;
161
+		}
162
+		glsr(Template::class)->render('partials/editor/pinned', [
163
+			'context' => [
164
+				'no' => __('No', 'site-reviews'),
165
+				'yes' => __('Yes', 'site-reviews'),
166
+			],
167
+			'pinned' => wp_validate_boolean(glsr(Database::class)->get(get_the_ID(), 'pinned')),
168
+		]);
169
+	}
170 170
 
171
-    /**
172
-     * @param WP_Post $post
173
-     * @return void
174
-     * @callback add_meta_box
175
-     */
176
-    public function renderResponseMetaBox($post)
177
-    {
178
-        if (!$this->isReviewPostType($post)) {
179
-            return;
180
-        }
181
-        wp_nonce_field('response', '_nonce-response', false);
182
-        glsr()->render('partials/editor/metabox-response', [
183
-            'response' => glsr(Database::class)->get($post->ID, 'response'),
184
-        ]);
185
-    }
171
+	/**
172
+	 * @param WP_Post $post
173
+	 * @return void
174
+	 * @callback add_meta_box
175
+	 */
176
+	public function renderResponseMetaBox($post)
177
+	{
178
+		if (!$this->isReviewPostType($post)) {
179
+			return;
180
+		}
181
+		wp_nonce_field('response', '_nonce-response', false);
182
+		glsr()->render('partials/editor/metabox-response', [
183
+			'response' => glsr(Database::class)->get($post->ID, 'response'),
184
+		]);
185
+	}
186 186
 
187
-    /**
188
-     * @param WP_Post $post
189
-     * @return void
190
-     * @action edit_form_after_title
191
-     */
192
-    public function renderReviewEditor($post)
193
-    {
194
-        if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) {
195
-            return;
196
-        }
197
-        glsr()->render('partials/editor/review', [
198
-            'post' => $post,
199
-            'response' => glsr(Database::class)->get($post->ID, 'response'),
200
-        ]);
201
-    }
187
+	/**
188
+	 * @param WP_Post $post
189
+	 * @return void
190
+	 * @action edit_form_after_title
191
+	 */
192
+	public function renderReviewEditor($post)
193
+	{
194
+		if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) {
195
+			return;
196
+		}
197
+		glsr()->render('partials/editor/review', [
198
+			'post' => $post,
199
+			'response' => glsr(Database::class)->get($post->ID, 'response'),
200
+		]);
201
+	}
202 202
 
203
-    /**
204
-     * @return void
205
-     * @action admin_head
206
-     */
207
-    public function renderReviewFields()
208
-    {
209
-        $screen = glsr_current_screen();
210
-        if ('post' != $screen->base || Application::POST_TYPE != $screen->post_type) {
211
-            return;
212
-        }
213
-        add_action('edit_form_after_title', [$this, 'renderReviewEditor']);
214
-        add_action('edit_form_top', [$this, 'renderReviewNotice']);
215
-    }
203
+	/**
204
+	 * @return void
205
+	 * @action admin_head
206
+	 */
207
+	public function renderReviewFields()
208
+	{
209
+		$screen = glsr_current_screen();
210
+		if ('post' != $screen->base || Application::POST_TYPE != $screen->post_type) {
211
+			return;
212
+		}
213
+		add_action('edit_form_after_title', [$this, 'renderReviewEditor']);
214
+		add_action('edit_form_top', [$this, 'renderReviewNotice']);
215
+	}
216 216
 
217
-    /**
218
-     * @param WP_Post $post
219
-     * @return void
220
-     * @action edit_form_top
221
-     */
222
-    public function renderReviewNotice($post)
223
-    {
224
-        if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) {
225
-            return;
226
-        }
227
-        glsr(Notice::class)->addWarning(sprintf(
228
-            __('%s reviews are read-only.', 'site-reviews'),
229
-            glsr(Columns::class)->buildColumnReviewType($post->ID)
230
-        ));
231
-        glsr(Template::class)->render('partials/editor/notice', [
232
-            'context' => [
233
-                'notices' => glsr(Notice::class)->get(),
234
-            ],
235
-        ]);
236
-    }
217
+	/**
218
+	 * @param WP_Post $post
219
+	 * @return void
220
+	 * @action edit_form_top
221
+	 */
222
+	public function renderReviewNotice($post)
223
+	{
224
+		if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) {
225
+			return;
226
+		}
227
+		glsr(Notice::class)->addWarning(sprintf(
228
+			__('%s reviews are read-only.', 'site-reviews'),
229
+			glsr(Columns::class)->buildColumnReviewType($post->ID)
230
+		));
231
+		glsr(Template::class)->render('partials/editor/notice', [
232
+			'context' => [
233
+				'notices' => glsr(Notice::class)->get(),
234
+			],
235
+		]);
236
+	}
237 237
 
238
-    /**
239
-     * @param WP_Post $post
240
-     * @return void
241
-     * @see glsr_categories_meta_box()
242
-     * @callback register_taxonomy
243
-     */
244
-    public function renderTaxonomyMetabox($post)
245
-    {
246
-        if (!$this->isReviewPostType($post)) {
247
-            return;
248
-        }
249
-        glsr()->render('partials/editor/metabox-categories', [
250
-            'post' => $post,
251
-            'tax_name' => Application::TAXONOMY,
252
-            'taxonomy' => get_taxonomy(Application::TAXONOMY),
253
-        ]);
254
-    }
238
+	/**
239
+	 * @param WP_Post $post
240
+	 * @return void
241
+	 * @see glsr_categories_meta_box()
242
+	 * @callback register_taxonomy
243
+	 */
244
+	public function renderTaxonomyMetabox($post)
245
+	{
246
+		if (!$this->isReviewPostType($post)) {
247
+			return;
248
+		}
249
+		glsr()->render('partials/editor/metabox-categories', [
250
+			'post' => $post,
251
+			'tax_name' => Application::TAXONOMY,
252
+			'taxonomy' => get_taxonomy(Application::TAXONOMY),
253
+		]);
254
+	}
255 255
 
256
-    /**
257
-     * @return void
258
-     * @see $this->filterUpdateMessages()
259
-     * @action admin_action_revert
260
-     */
261
-    public function revertReview()
262
-    {
263
-        if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
264
-            return;
265
-        }
266
-        check_admin_referer('revert-review_'.($postId = $this->getPostId()));
267
-        glsr(ReviewManager::class)->revert($postId);
268
-        $this->redirect($postId, 52);
269
-    }
256
+	/**
257
+	 * @return void
258
+	 * @see $this->filterUpdateMessages()
259
+	 * @action admin_action_revert
260
+	 */
261
+	public function revertReview()
262
+	{
263
+		if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
264
+			return;
265
+		}
266
+		check_admin_referer('revert-review_'.($postId = $this->getPostId()));
267
+		glsr(ReviewManager::class)->revert($postId);
268
+		$this->redirect($postId, 52);
269
+	}
270 270
 
271
-    /**
272
-     * @param int $postId
273
-     * @param \WP_Post $post
274
-     * @param bool $isUpdate
275
-     * @return void
276
-     * @action save_post_.Application::POST_TYPE
277
-     */
278
-    public function saveMetaboxes($postId, $post, $isUpdating)
279
-    {
280
-        glsr(Metaboxes::class)->saveAssignedToMetabox($postId);
281
-        glsr(Metaboxes::class)->saveResponseMetabox($postId);
282
-        if ($isUpdating) {
283
-            do_action('site-reviews/review/saved', glsr_get_review($postId));
284
-        }
285
-    }
271
+	/**
272
+	 * @param int $postId
273
+	 * @param \WP_Post $post
274
+	 * @param bool $isUpdate
275
+	 * @return void
276
+	 * @action save_post_.Application::POST_TYPE
277
+	 */
278
+	public function saveMetaboxes($postId, $post, $isUpdating)
279
+	{
280
+		glsr(Metaboxes::class)->saveAssignedToMetabox($postId);
281
+		glsr(Metaboxes::class)->saveResponseMetabox($postId);
282
+		if ($isUpdating) {
283
+			do_action('site-reviews/review/saved', glsr_get_review($postId));
284
+		}
285
+	}
286 286
 
287
-    /**
288
-     * @param string $assignedTo
289
-     * @return string
290
-     */
291
-    protected function buildAssignedToTemplate($assignedTo, WP_Post $post)
292
-    {
293
-        $assignedPost = glsr(Database::class)->getAssignedToPost($post->ID, $assignedTo);
294
-        if (!($assignedPost instanceof WP_Post)) {
295
-            return;
296
-        }
297
-        return glsr(Template::class)->build('partials/editor/assigned-post', [
298
-            'context' => [
299
-                'data.url' => (string) get_permalink($assignedPost),
300
-                'data.title' => get_the_title($assignedPost),
301
-            ],
302
-        ]);
303
-    }
287
+	/**
288
+	 * @param string $assignedTo
289
+	 * @return string
290
+	 */
291
+	protected function buildAssignedToTemplate($assignedTo, WP_Post $post)
292
+	{
293
+		$assignedPost = glsr(Database::class)->getAssignedToPost($post->ID, $assignedTo);
294
+		if (!($assignedPost instanceof WP_Post)) {
295
+			return;
296
+		}
297
+		return glsr(Template::class)->build('partials/editor/assigned-post', [
298
+			'context' => [
299
+				'data.url' => (string) get_permalink($assignedPost),
300
+				'data.title' => get_the_title($assignedPost),
301
+			],
302
+		]);
303
+	}
304 304
 
305
-    /**
306
-     * @return string
307
-     */
308
-    protected function buildDetailsMetaBoxRevertButton(Review $review, WP_Post $post)
309
-    {
310
-        $isModified = !Arr::compareArrays(
311
-            [$review->title, $review->content, $review->date],
312
-            [
313
-                glsr(Database::class)->get($post->ID, 'title'),
314
-                glsr(Database::class)->get($post->ID, 'content'),
315
-                glsr(Database::class)->get($post->ID, 'date'),
316
-            ]
317
-        );
318
-        if ($isModified) {
319
-            $revertUrl = wp_nonce_url(
320
-                admin_url('post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID),
321
-                'revert-review_'.$post->ID
322
-            );
323
-            return glsr(Builder::class)->a(__('Revert Changes', 'site-reviews'), [
324
-                'class' => 'button button-large',
325
-                'href' => $revertUrl,
326
-                'id' => 'revert',
327
-            ]);
328
-        }
329
-        return glsr(Builder::class)->button(__('Nothing to Revert', 'site-reviews'), [
330
-            'class' => 'button-large',
331
-            'disabled' => true,
332
-            'id' => 'revert',
333
-        ]);
334
-    }
305
+	/**
306
+	 * @return string
307
+	 */
308
+	protected function buildDetailsMetaBoxRevertButton(Review $review, WP_Post $post)
309
+	{
310
+		$isModified = !Arr::compareArrays(
311
+			[$review->title, $review->content, $review->date],
312
+			[
313
+				glsr(Database::class)->get($post->ID, 'title'),
314
+				glsr(Database::class)->get($post->ID, 'content'),
315
+				glsr(Database::class)->get($post->ID, 'date'),
316
+			]
317
+		);
318
+		if ($isModified) {
319
+			$revertUrl = wp_nonce_url(
320
+				admin_url('post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID),
321
+				'revert-review_'.$post->ID
322
+			);
323
+			return glsr(Builder::class)->a(__('Revert Changes', 'site-reviews'), [
324
+				'class' => 'button button-large',
325
+				'href' => $revertUrl,
326
+				'id' => 'revert',
327
+			]);
328
+		}
329
+		return glsr(Builder::class)->button(__('Nothing to Revert', 'site-reviews'), [
330
+			'class' => 'button-large',
331
+			'disabled' => true,
332
+			'id' => 'revert',
333
+		]);
334
+	}
335 335
 
336
-    /**
337
-     * @param object $review
338
-     * @return string|void
339
-     */
340
-    protected function getReviewType($review)
341
-    {
342
-        if (count(glsr()->reviewTypes) < 2) {
343
-            return;
344
-        }
345
-        $reviewType = array_key_exists($review->review_type, glsr()->reviewTypes)
346
-            ? glsr()->reviewTypes[$review->review_type]
347
-            : __('Unknown', 'site-reviews');
348
-        if (!empty($review->url)) {
349
-            $reviewType = glsr(Builder::class)->a($reviewType, [
350
-                'href' => $review->url,
351
-                'target' => '_blank',
352
-            ]);
353
-        }
354
-        return $reviewType;
355
-    }
336
+	/**
337
+	 * @param object $review
338
+	 * @return string|void
339
+	 */
340
+	protected function getReviewType($review)
341
+	{
342
+		if (count(glsr()->reviewTypes) < 2) {
343
+			return;
344
+		}
345
+		$reviewType = array_key_exists($review->review_type, glsr()->reviewTypes)
346
+			? glsr()->reviewTypes[$review->review_type]
347
+			: __('Unknown', 'site-reviews');
348
+		if (!empty($review->url)) {
349
+			$reviewType = glsr(Builder::class)->a($reviewType, [
350
+				'href' => $review->url,
351
+				'target' => '_blank',
352
+			]);
353
+		}
354
+		return $reviewType;
355
+	}
356 356
 
357
-    /**
358
-     * @return bool
359
-     */
360
-    protected function isReviewEditable($post)
361
-    {
362
-        return $this->isReviewPostType($post)
363
-            && post_type_supports(Application::POST_TYPE, 'title')
364
-            && 'local' == glsr(Database::class)->get($post->ID, 'review_type');
365
-    }
357
+	/**
358
+	 * @return bool
359
+	 */
360
+	protected function isReviewEditable($post)
361
+	{
362
+		return $this->isReviewPostType($post)
363
+			&& post_type_supports(Application::POST_TYPE, 'title')
364
+			&& 'local' == glsr(Database::class)->get($post->ID, 'review_type');
365
+	}
366 366
 
367
-    /**
368
-     * @param mixed $post
369
-     * @return bool
370
-     */
371
-    protected function isReviewPostType($post)
372
-    {
373
-        return $post instanceof WP_Post && Application::POST_TYPE == $post->post_type;
374
-    }
367
+	/**
368
+	 * @param mixed $post
369
+	 * @return bool
370
+	 */
371
+	protected function isReviewPostType($post)
372
+	{
373
+		return $post instanceof WP_Post && Application::POST_TYPE == $post->post_type;
374
+	}
375 375
 
376
-    /**
377
-     * @return array
378
-     */
379
-    protected function normalizeDetailsMetaBox(Review $review)
380
-    {
381
-        $user = empty($review->user_id)
382
-            ? __('Unregistered user', 'site-reviews')
383
-            : glsr(Builder::class)->a(get_the_author_meta('display_name', $review->user_id), [
384
-                'href' => get_author_posts_url($review->user_id),
385
-            ]);
386
-        $email = empty($review->email)
387
-            ? '&mdash;'
388
-            : glsr(Builder::class)->a($review->email, [
389
-                'href' => 'mailto:'.$review->email.'?subject='.esc_attr(__('RE:', 'site-reviews').' '.$review->title),
390
-            ]);
391
-        $metabox = [
392
-            __('Rating', 'site-reviews') => glsr_star_rating($review->rating),
393
-            __('Type', 'site-reviews') => $this->getReviewType($review),
394
-            __('Date', 'site-reviews') => get_date_from_gmt($review->date, 'F j, Y'),
395
-            __('Name', 'site-reviews') => $review->author,
396
-            __('Email', 'site-reviews') => $email,
397
-            __('User', 'site-reviews') => $user,
398
-            __('IP Address', 'site-reviews') => $review->ip_address,
399
-            __('Avatar', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar),
400
-        ];
401
-        return array_filter(apply_filters('site-reviews/metabox/details', $metabox, $review));
402
-    }
376
+	/**
377
+	 * @return array
378
+	 */
379
+	protected function normalizeDetailsMetaBox(Review $review)
380
+	{
381
+		$user = empty($review->user_id)
382
+			? __('Unregistered user', 'site-reviews')
383
+			: glsr(Builder::class)->a(get_the_author_meta('display_name', $review->user_id), [
384
+				'href' => get_author_posts_url($review->user_id),
385
+			]);
386
+		$email = empty($review->email)
387
+			? '&mdash;'
388
+			: glsr(Builder::class)->a($review->email, [
389
+				'href' => 'mailto:'.$review->email.'?subject='.esc_attr(__('RE:', 'site-reviews').' '.$review->title),
390
+			]);
391
+		$metabox = [
392
+			__('Rating', 'site-reviews') => glsr_star_rating($review->rating),
393
+			__('Type', 'site-reviews') => $this->getReviewType($review),
394
+			__('Date', 'site-reviews') => get_date_from_gmt($review->date, 'F j, Y'),
395
+			__('Name', 'site-reviews') => $review->author,
396
+			__('Email', 'site-reviews') => $email,
397
+			__('User', 'site-reviews') => $user,
398
+			__('IP Address', 'site-reviews') => $review->ip_address,
399
+			__('Avatar', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar),
400
+		];
401
+		return array_filter(apply_filters('site-reviews/metabox/details', $metabox, $review));
402
+	}
403 403
 
404
-    /**
405
-     * @param int $postId
406
-     * @param int $messageIndex
407
-     * @return void
408
-     */
409
-    protected function redirect($postId, $messageIndex)
410
-    {
411
-        $referer = wp_get_referer();
412
-        $hasReferer = !$referer
413
-            || Str::contains($referer, 'post.php')
414
-            || Str::contains($referer, 'post-new.php');
415
-        $redirectUri = $hasReferer
416
-            ? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer)
417
-            : get_edit_post_link($postId);
418
-        wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri));
419
-        exit;
420
-    }
404
+	/**
405
+	 * @param int $postId
406
+	 * @param int $messageIndex
407
+	 * @return void
408
+	 */
409
+	protected function redirect($postId, $messageIndex)
410
+	{
411
+		$referer = wp_get_referer();
412
+		$hasReferer = !$referer
413
+			|| Str::contains($referer, 'post.php')
414
+			|| Str::contains($referer, 'post-new.php');
415
+		$redirectUri = $hasReferer
416
+			? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer)
417
+			: get_edit_post_link($postId);
418
+		wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri));
419
+		exit;
420
+	}
421 421
 }
Please login to merge, or discard this patch.
Spacing   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
      * @return array
26 26
      * @filter wp_editor_settings
27 27
      */
28
-    public function filterEditorSettings($settings)
28
+    public function filterEditorSettings( $settings )
29 29
     {
30
-        return glsr(Customization::class)->filterEditorSettings(
31
-            Arr::consolidateArray($settings)
30
+        return glsr( Customization::class )->filterEditorSettings(
31
+            Arr::consolidateArray( $settings )
32 32
         );
33 33
     }
34 34
 
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
      * @return string
39 39
      * @filter the_editor
40 40
      */
41
-    public function filterEditorTextarea($html)
41
+    public function filterEditorTextarea( $html )
42 42
     {
43
-        return glsr(Customization::class)->filterEditorTextarea($html);
43
+        return glsr( Customization::class )->filterEditorTextarea( $html );
44 44
     }
45 45
 
46 46
     /**
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
      * @return bool
51 51
      * @filter is_protected_meta
52 52
      */
53
-    public function filterIsProtectedMeta($protected, $metaKey, $metaType)
53
+    public function filterIsProtectedMeta( $protected, $metaKey, $metaType )
54 54
     {
55
-        if ('post' == $metaType && Application::POST_TYPE == get_post_type()) {
56
-            $values = glsr(CreateReviewDefaults::class)->unguarded();
57
-            $values = Arr::prefixArrayKeys($values);
58
-            if (array_key_exists($metaKey, $values)) {
55
+        if( 'post' == $metaType && Application::POST_TYPE == get_post_type() ) {
56
+            $values = glsr( CreateReviewDefaults::class )->unguarded();
57
+            $values = Arr::prefixArrayKeys( $values );
58
+            if( array_key_exists( $metaKey, $values ) ) {
59 59
                 $protected = false;
60 60
             }
61 61
         }
@@ -67,10 +67,10 @@  discard block
 block discarded – undo
67 67
      * @return array
68 68
      * @filter post_updated_messages
69 69
      */
70
-    public function filterUpdateMessages($messages)
70
+    public function filterUpdateMessages( $messages )
71 71
     {
72
-        return glsr(Labels::class)->filterUpdateMessages(
73
-            Arr::consolidateArray($messages)
72
+        return glsr( Labels::class )->filterUpdateMessages(
73
+            Arr::consolidateArray( $messages )
74 74
         );
75 75
     }
76 76
 
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
      * @return void
79 79
      * @action add_meta_boxes_{Application::POST_TYPE}
80 80
      */
81
-    public function registerMetaBoxes($post)
81
+    public function registerMetaBoxes( $post )
82 82
     {
83
-        add_meta_box(Application::ID.'_assigned_to', __('Assigned To', 'site-reviews'), [$this, 'renderAssignedToMetabox'], null, 'side');
84
-        add_meta_box(Application::ID.'_review', __('Details', 'site-reviews'), [$this, 'renderDetailsMetaBox'], null, 'side');
85
-        if ('local' != glsr(Database::class)->get($post->ID, 'review_type')) {
83
+        add_meta_box( Application::ID.'_assigned_to', __( 'Assigned To', 'site-reviews' ), [$this, 'renderAssignedToMetabox'], null, 'side' );
84
+        add_meta_box( Application::ID.'_review', __( 'Details', 'site-reviews' ), [$this, 'renderDetailsMetaBox'], null, 'side' );
85
+        if( 'local' != glsr( Database::class )->get( $post->ID, 'review_type' ) ) {
86 86
             return;
87 87
         }
88
-        add_meta_box(Application::ID.'_response', __('Respond Publicly', 'site-reviews'), [$this, 'renderResponseMetaBox'], null, 'normal');
88
+        add_meta_box( Application::ID.'_response', __( 'Respond Publicly', 'site-reviews' ), [$this, 'renderResponseMetaBox'], null, 'normal' );
89 89
     }
90 90
 
91 91
     /**
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
      */
95 95
     public function removeAutosave()
96 96
     {
97
-        glsr(Customization::class)->removeAutosave();
97
+        glsr( Customization::class )->removeAutosave();
98 98
     }
99 99
 
100 100
     /**
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public function removeMetaBoxes()
105 105
     {
106
-        glsr(Customization::class)->removeMetaBoxes();
106
+        glsr( Customization::class )->removeMetaBoxes();
107 107
     }
108 108
 
109 109
     /**
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
      */
112 112
     public function removePostTypeSupport()
113 113
     {
114
-        glsr(Customization::class)->removePostTypeSupport();
114
+        glsr( Customization::class )->removePostTypeSupport();
115 115
     }
116 116
 
117 117
     /**
@@ -119,17 +119,17 @@  discard block
 block discarded – undo
119 119
      * @return void
120 120
      * @callback add_meta_box
121 121
      */
122
-    public function renderAssignedToMetabox($post)
122
+    public function renderAssignedToMetabox( $post )
123 123
     {
124
-        if (!$this->isReviewPostType($post)) {
124
+        if( !$this->isReviewPostType( $post ) ) {
125 125
             return;
126 126
         }
127
-        $assignedTo = (string) glsr(Database::class)->get($post->ID, 'assigned_to');
128
-        wp_nonce_field('assigned_to', '_nonce-assigned-to', false);
129
-        glsr()->render('partials/editor/metabox-assigned-to', [
127
+        $assignedTo = (string)glsr( Database::class )->get( $post->ID, 'assigned_to' );
128
+        wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false );
129
+        glsr()->render( 'partials/editor/metabox-assigned-to', [
130 130
             'id' => $assignedTo,
131
-            'template' => $this->buildAssignedToTemplate($assignedTo, $post),
132
-        ]);
131
+            'template' => $this->buildAssignedToTemplate( $assignedTo, $post ),
132
+        ] );
133 133
     }
134 134
 
135 135
     /**
@@ -137,16 +137,16 @@  discard block
 block discarded – undo
137 137
      * @return void
138 138
      * @callback add_meta_box
139 139
      */
140
-    public function renderDetailsMetaBox($post)
140
+    public function renderDetailsMetaBox( $post )
141 141
     {
142
-        if (!$this->isReviewPostType($post)) {
142
+        if( !$this->isReviewPostType( $post ) ) {
143 143
             return;
144 144
         }
145
-        $review = glsr_get_review($post);
146
-        glsr()->render('partials/editor/metabox-details', [
147
-            'button' => $this->buildDetailsMetaBoxRevertButton($review, $post),
148
-            'metabox' => $this->normalizeDetailsMetaBox($review),
149
-        ]);
145
+        $review = glsr_get_review( $post );
146
+        glsr()->render( 'partials/editor/metabox-details', [
147
+            'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ),
148
+            'metabox' => $this->normalizeDetailsMetaBox( $review ),
149
+        ] );
150 150
     }
151 151
 
152 152
     /**
@@ -155,17 +155,17 @@  discard block
 block discarded – undo
155 155
      */
156 156
     public function renderPinnedInPublishMetaBox()
157 157
     {
158
-        if (!$this->isReviewPostType(get_post())
159
-            || !glsr()->can('edit_others_posts')) {
158
+        if( !$this->isReviewPostType( get_post() )
159
+            || !glsr()->can( 'edit_others_posts' ) ) {
160 160
             return;
161 161
         }
162
-        glsr(Template::class)->render('partials/editor/pinned', [
162
+        glsr( Template::class )->render( 'partials/editor/pinned', [
163 163
             'context' => [
164
-                'no' => __('No', 'site-reviews'),
165
-                'yes' => __('Yes', 'site-reviews'),
164
+                'no' => __( 'No', 'site-reviews' ),
165
+                'yes' => __( 'Yes', 'site-reviews' ),
166 166
             ],
167
-            'pinned' => wp_validate_boolean(glsr(Database::class)->get(get_the_ID(), 'pinned')),
168
-        ]);
167
+            'pinned' => wp_validate_boolean( glsr( Database::class )->get( get_the_ID(), 'pinned' ) ),
168
+        ] );
169 169
     }
170 170
 
171 171
     /**
@@ -173,15 +173,15 @@  discard block
 block discarded – undo
173 173
      * @return void
174 174
      * @callback add_meta_box
175 175
      */
176
-    public function renderResponseMetaBox($post)
176
+    public function renderResponseMetaBox( $post )
177 177
     {
178
-        if (!$this->isReviewPostType($post)) {
178
+        if( !$this->isReviewPostType( $post ) ) {
179 179
             return;
180 180
         }
181
-        wp_nonce_field('response', '_nonce-response', false);
182
-        glsr()->render('partials/editor/metabox-response', [
183
-            'response' => glsr(Database::class)->get($post->ID, 'response'),
184
-        ]);
181
+        wp_nonce_field( 'response', '_nonce-response', false );
182
+        glsr()->render( 'partials/editor/metabox-response', [
183
+            'response' => glsr( Database::class )->get( $post->ID, 'response' ),
184
+        ] );
185 185
     }
186 186
 
187 187
     /**
@@ -189,15 +189,15 @@  discard block
 block discarded – undo
189 189
      * @return void
190 190
      * @action edit_form_after_title
191 191
      */
192
-    public function renderReviewEditor($post)
192
+    public function renderReviewEditor( $post )
193 193
     {
194
-        if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) {
194
+        if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) ) {
195 195
             return;
196 196
         }
197
-        glsr()->render('partials/editor/review', [
197
+        glsr()->render( 'partials/editor/review', [
198 198
             'post' => $post,
199
-            'response' => glsr(Database::class)->get($post->ID, 'response'),
200
-        ]);
199
+            'response' => glsr( Database::class )->get( $post->ID, 'response' ),
200
+        ] );
201 201
     }
202 202
 
203 203
     /**
@@ -207,11 +207,11 @@  discard block
 block discarded – undo
207 207
     public function renderReviewFields()
208 208
     {
209 209
         $screen = glsr_current_screen();
210
-        if ('post' != $screen->base || Application::POST_TYPE != $screen->post_type) {
210
+        if( 'post' != $screen->base || Application::POST_TYPE != $screen->post_type ) {
211 211
             return;
212 212
         }
213
-        add_action('edit_form_after_title', [$this, 'renderReviewEditor']);
214
-        add_action('edit_form_top', [$this, 'renderReviewNotice']);
213
+        add_action( 'edit_form_after_title', [$this, 'renderReviewEditor'] );
214
+        add_action( 'edit_form_top', [$this, 'renderReviewNotice'] );
215 215
     }
216 216
 
217 217
     /**
@@ -219,20 +219,20 @@  discard block
 block discarded – undo
219 219
      * @return void
220 220
      * @action edit_form_top
221 221
      */
222
-    public function renderReviewNotice($post)
222
+    public function renderReviewNotice( $post )
223 223
     {
224
-        if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) {
224
+        if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) ) {
225 225
             return;
226 226
         }
227
-        glsr(Notice::class)->addWarning(sprintf(
228
-            __('%s reviews are read-only.', 'site-reviews'),
229
-            glsr(Columns::class)->buildColumnReviewType($post->ID)
230
-        ));
231
-        glsr(Template::class)->render('partials/editor/notice', [
227
+        glsr( Notice::class )->addWarning( sprintf(
228
+            __( '%s reviews are read-only.', 'site-reviews' ),
229
+            glsr( Columns::class )->buildColumnReviewType( $post->ID )
230
+        ) );
231
+        glsr( Template::class )->render( 'partials/editor/notice', [
232 232
             'context' => [
233
-                'notices' => glsr(Notice::class)->get(),
233
+                'notices' => glsr( Notice::class )->get(),
234 234
             ],
235
-        ]);
235
+        ] );
236 236
     }
237 237
 
238 238
     /**
@@ -241,16 +241,16 @@  discard block
 block discarded – undo
241 241
      * @see glsr_categories_meta_box()
242 242
      * @callback register_taxonomy
243 243
      */
244
-    public function renderTaxonomyMetabox($post)
244
+    public function renderTaxonomyMetabox( $post )
245 245
     {
246
-        if (!$this->isReviewPostType($post)) {
246
+        if( !$this->isReviewPostType( $post ) ) {
247 247
             return;
248 248
         }
249
-        glsr()->render('partials/editor/metabox-categories', [
249
+        glsr()->render( 'partials/editor/metabox-categories', [
250 250
             'post' => $post,
251 251
             'tax_name' => Application::TAXONOMY,
252
-            'taxonomy' => get_taxonomy(Application::TAXONOMY),
253
-        ]);
252
+            'taxonomy' => get_taxonomy( Application::TAXONOMY ),
253
+        ] );
254 254
     }
255 255
 
256 256
     /**
@@ -260,12 +260,12 @@  discard block
 block discarded – undo
260 260
      */
261 261
     public function revertReview()
262 262
     {
263
-        if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
263
+        if( Application::ID != filter_input( INPUT_GET, 'plugin' ) ) {
264 264
             return;
265 265
         }
266
-        check_admin_referer('revert-review_'.($postId = $this->getPostId()));
267
-        glsr(ReviewManager::class)->revert($postId);
268
-        $this->redirect($postId, 52);
266
+        check_admin_referer( 'revert-review_'.($postId = $this->getPostId()) );
267
+        glsr( ReviewManager::class )->revert( $postId );
268
+        $this->redirect( $postId, 52 );
269 269
     }
270 270
 
271 271
     /**
@@ -275,12 +275,12 @@  discard block
 block discarded – undo
275 275
      * @return void
276 276
      * @action save_post_.Application::POST_TYPE
277 277
      */
278
-    public function saveMetaboxes($postId, $post, $isUpdating)
278
+    public function saveMetaboxes( $postId, $post, $isUpdating )
279 279
     {
280
-        glsr(Metaboxes::class)->saveAssignedToMetabox($postId);
281
-        glsr(Metaboxes::class)->saveResponseMetabox($postId);
282
-        if ($isUpdating) {
283
-            do_action('site-reviews/review/saved', glsr_get_review($postId));
280
+        glsr( Metaboxes::class )->saveAssignedToMetabox( $postId );
281
+        glsr( Metaboxes::class )->saveResponseMetabox( $postId );
282
+        if( $isUpdating ) {
283
+            do_action( 'site-reviews/review/saved', glsr_get_review( $postId ) );
284 284
         }
285 285
     }
286 286
 
@@ -288,68 +288,68 @@  discard block
 block discarded – undo
288 288
      * @param string $assignedTo
289 289
      * @return string
290 290
      */
291
-    protected function buildAssignedToTemplate($assignedTo, WP_Post $post)
291
+    protected function buildAssignedToTemplate( $assignedTo, WP_Post $post )
292 292
     {
293
-        $assignedPost = glsr(Database::class)->getAssignedToPost($post->ID, $assignedTo);
294
-        if (!($assignedPost instanceof WP_Post)) {
293
+        $assignedPost = glsr( Database::class )->getAssignedToPost( $post->ID, $assignedTo );
294
+        if( !($assignedPost instanceof WP_Post) ) {
295 295
             return;
296 296
         }
297
-        return glsr(Template::class)->build('partials/editor/assigned-post', [
297
+        return glsr( Template::class )->build( 'partials/editor/assigned-post', [
298 298
             'context' => [
299
-                'data.url' => (string) get_permalink($assignedPost),
300
-                'data.title' => get_the_title($assignedPost),
299
+                'data.url' => (string)get_permalink( $assignedPost ),
300
+                'data.title' => get_the_title( $assignedPost ),
301 301
             ],
302
-        ]);
302
+        ] );
303 303
     }
304 304
 
305 305
     /**
306 306
      * @return string
307 307
      */
308
-    protected function buildDetailsMetaBoxRevertButton(Review $review, WP_Post $post)
308
+    protected function buildDetailsMetaBoxRevertButton( Review $review, WP_Post $post )
309 309
     {
310 310
         $isModified = !Arr::compareArrays(
311 311
             [$review->title, $review->content, $review->date],
312 312
             [
313
-                glsr(Database::class)->get($post->ID, 'title'),
314
-                glsr(Database::class)->get($post->ID, 'content'),
315
-                glsr(Database::class)->get($post->ID, 'date'),
313
+                glsr( Database::class )->get( $post->ID, 'title' ),
314
+                glsr( Database::class )->get( $post->ID, 'content' ),
315
+                glsr( Database::class )->get( $post->ID, 'date' ),
316 316
             ]
317 317
         );
318
-        if ($isModified) {
318
+        if( $isModified ) {
319 319
             $revertUrl = wp_nonce_url(
320
-                admin_url('post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID),
320
+                admin_url( 'post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID ),
321 321
                 'revert-review_'.$post->ID
322 322
             );
323
-            return glsr(Builder::class)->a(__('Revert Changes', 'site-reviews'), [
323
+            return glsr( Builder::class )->a( __( 'Revert Changes', 'site-reviews' ), [
324 324
                 'class' => 'button button-large',
325 325
                 'href' => $revertUrl,
326 326
                 'id' => 'revert',
327
-            ]);
327
+            ] );
328 328
         }
329
-        return glsr(Builder::class)->button(__('Nothing to Revert', 'site-reviews'), [
329
+        return glsr( Builder::class )->button( __( 'Nothing to Revert', 'site-reviews' ), [
330 330
             'class' => 'button-large',
331 331
             'disabled' => true,
332 332
             'id' => 'revert',
333
-        ]);
333
+        ] );
334 334
     }
335 335
 
336 336
     /**
337 337
      * @param object $review
338 338
      * @return string|void
339 339
      */
340
-    protected function getReviewType($review)
340
+    protected function getReviewType( $review )
341 341
     {
342
-        if (count(glsr()->reviewTypes) < 2) {
342
+        if( count( glsr()->reviewTypes ) < 2 ) {
343 343
             return;
344 344
         }
345
-        $reviewType = array_key_exists($review->review_type, glsr()->reviewTypes)
345
+        $reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes )
346 346
             ? glsr()->reviewTypes[$review->review_type]
347
-            : __('Unknown', 'site-reviews');
348
-        if (!empty($review->url)) {
349
-            $reviewType = glsr(Builder::class)->a($reviewType, [
347
+            : __( 'Unknown', 'site-reviews' );
348
+        if( !empty($review->url) ) {
349
+            $reviewType = glsr( Builder::class )->a( $reviewType, [
350 350
                 'href' => $review->url,
351 351
                 'target' => '_blank',
352
-            ]);
352
+            ] );
353 353
         }
354 354
         return $reviewType;
355 355
     }
@@ -357,18 +357,18 @@  discard block
 block discarded – undo
357 357
     /**
358 358
      * @return bool
359 359
      */
360
-    protected function isReviewEditable($post)
360
+    protected function isReviewEditable( $post )
361 361
     {
362
-        return $this->isReviewPostType($post)
363
-            && post_type_supports(Application::POST_TYPE, 'title')
364
-            && 'local' == glsr(Database::class)->get($post->ID, 'review_type');
362
+        return $this->isReviewPostType( $post )
363
+            && post_type_supports( Application::POST_TYPE, 'title' )
364
+            && 'local' == glsr( Database::class )->get( $post->ID, 'review_type' );
365 365
     }
366 366
 
367 367
     /**
368 368
      * @param mixed $post
369 369
      * @return bool
370 370
      */
371
-    protected function isReviewPostType($post)
371
+    protected function isReviewPostType( $post )
372 372
     {
373 373
         return $post instanceof WP_Post && Application::POST_TYPE == $post->post_type;
374 374
     }
@@ -376,29 +376,29 @@  discard block
 block discarded – undo
376 376
     /**
377 377
      * @return array
378 378
      */
379
-    protected function normalizeDetailsMetaBox(Review $review)
379
+    protected function normalizeDetailsMetaBox( Review $review )
380 380
     {
381 381
         $user = empty($review->user_id)
382
-            ? __('Unregistered user', 'site-reviews')
383
-            : glsr(Builder::class)->a(get_the_author_meta('display_name', $review->user_id), [
384
-                'href' => get_author_posts_url($review->user_id),
385
-            ]);
382
+            ? __( 'Unregistered user', 'site-reviews' )
383
+            : glsr( Builder::class )->a( get_the_author_meta( 'display_name', $review->user_id ), [
384
+                'href' => get_author_posts_url( $review->user_id ),
385
+            ] );
386 386
         $email = empty($review->email)
387 387
             ? '&mdash;'
388
-            : glsr(Builder::class)->a($review->email, [
389
-                'href' => 'mailto:'.$review->email.'?subject='.esc_attr(__('RE:', 'site-reviews').' '.$review->title),
390
-            ]);
388
+            : glsr( Builder::class )->a( $review->email, [
389
+                'href' => 'mailto:'.$review->email.'?subject='.esc_attr( __( 'RE:', 'site-reviews' ).' '.$review->title ),
390
+            ] );
391 391
         $metabox = [
392
-            __('Rating', 'site-reviews') => glsr_star_rating($review->rating),
393
-            __('Type', 'site-reviews') => $this->getReviewType($review),
394
-            __('Date', 'site-reviews') => get_date_from_gmt($review->date, 'F j, Y'),
395
-            __('Name', 'site-reviews') => $review->author,
396
-            __('Email', 'site-reviews') => $email,
397
-            __('User', 'site-reviews') => $user,
398
-            __('IP Address', 'site-reviews') => $review->ip_address,
399
-            __('Avatar', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar),
392
+            __( 'Rating', 'site-reviews' ) => glsr_star_rating( $review->rating ),
393
+            __( 'Type', 'site-reviews' ) => $this->getReviewType( $review ),
394
+            __( 'Date', 'site-reviews' ) => get_date_from_gmt( $review->date, 'F j, Y' ),
395
+            __( 'Name', 'site-reviews' ) => $review->author,
396
+            __( 'Email', 'site-reviews' ) => $email,
397
+            __( 'User', 'site-reviews' ) => $user,
398
+            __( 'IP Address', 'site-reviews' ) => $review->ip_address,
399
+            __( 'Avatar', 'site-reviews' ) => sprintf( '<img src="%s" width="96">', $review->avatar ),
400 400
         ];
401
-        return array_filter(apply_filters('site-reviews/metabox/details', $metabox, $review));
401
+        return array_filter( apply_filters( 'site-reviews/metabox/details', $metabox, $review ) );
402 402
     }
403 403
 
404 404
     /**
@@ -406,16 +406,16 @@  discard block
 block discarded – undo
406 406
      * @param int $messageIndex
407 407
      * @return void
408 408
      */
409
-    protected function redirect($postId, $messageIndex)
409
+    protected function redirect( $postId, $messageIndex )
410 410
     {
411 411
         $referer = wp_get_referer();
412 412
         $hasReferer = !$referer
413
-            || Str::contains($referer, 'post.php')
414
-            || Str::contains($referer, 'post-new.php');
413
+            || Str::contains( $referer, 'post.php' )
414
+            || Str::contains( $referer, 'post-new.php' );
415 415
         $redirectUri = $hasReferer
416
-            ? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer)
417
-            : get_edit_post_link($postId);
418
-        wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri));
416
+            ? remove_query_arg( ['deleted', 'ids', 'trashed', 'untrashed'], $referer )
417
+            : get_edit_post_link( $postId );
418
+        wp_safe_redirect( add_query_arg( ['message' => $messageIndex], $redirectUri ) );
419 419
         exit;
420 420
     }
421 421
 }
Please login to merge, or discard this patch.