Passed
Push — master ( dd57fd...bbdbbd )
by Paul
04:15
created
plugin/Role.php 2 patches
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -6,133 +6,133 @@
 block discarded – undo
6 6
 
7 7
 class Role
8 8
 {
9
-    /**
10
-     * @param string $role
11
-     * @return void
12
-     */
13
-    public function addCapabilities($role)
14
-    {
15
-        $roleCapabilities = $this->roleCapabilities();
16
-        $wpRole = get_role($role);
17
-        if (empty($wpRole) || !array_key_exists($role, $roleCapabilities)) {
18
-            return;
19
-        }
20
-        foreach ($roleCapabilities[$role] as $capability) {
21
-            $wpRole->add_cap($this->normalizeCapability($capability));
22
-        }
23
-    }
9
+	/**
10
+	 * @param string $role
11
+	 * @return void
12
+	 */
13
+	public function addCapabilities($role)
14
+	{
15
+		$roleCapabilities = $this->roleCapabilities();
16
+		$wpRole = get_role($role);
17
+		if (empty($wpRole) || !array_key_exists($role, $roleCapabilities)) {
18
+			return;
19
+		}
20
+		foreach ($roleCapabilities[$role] as $capability) {
21
+			$wpRole->add_cap($this->normalizeCapability($capability));
22
+		}
23
+	}
24 24
 
25
-    /**
26
-     * @param string $capability
27
-     * @return bool
28
-     */
29
-    public function can($capability)
30
-    {
31
-        return in_array($capability, $this->capabilities())
32
-            ? current_user_can($this->normalizeCapability($capability))
33
-            : current_user_can($capability);
34
-    }
25
+	/**
26
+	 * @param string $capability
27
+	 * @return bool
28
+	 */
29
+	public function can($capability)
30
+	{
31
+		return in_array($capability, $this->capabilities())
32
+			? current_user_can($this->normalizeCapability($capability))
33
+			: current_user_can($capability);
34
+	}
35 35
 
36
-    /**
37
-     * @param string $role
38
-     * @return void
39
-     */
40
-    public function removeCapabilities($role)
41
-    {
42
-        $wpRole = get_role($role);
43
-        if (empty($wpRole) || 'administrator' === $role) { // do not remove from administrator role
44
-            return;
45
-        }
46
-        foreach ($this->capabilities() as $capability) {
47
-            $wpRole->remove_cap($this->normalizeCapability($capability));
48
-        }
49
-    }
36
+	/**
37
+	 * @param string $role
38
+	 * @return void
39
+	 */
40
+	public function removeCapabilities($role)
41
+	{
42
+		$wpRole = get_role($role);
43
+		if (empty($wpRole) || 'administrator' === $role) { // do not remove from administrator role
44
+			return;
45
+		}
46
+		foreach ($this->capabilities() as $capability) {
47
+			$wpRole->remove_cap($this->normalizeCapability($capability));
48
+		}
49
+	}
50 50
 
51
-    /**
52
-     * @return void
53
-     */
54
-    public function resetAll()
55
-    {
56
-        $roles = array_keys(wp_roles()->roles);
57
-        array_walk($roles, [$this, 'removeCapabilities']);
58
-        $roles = array_keys($this->roleCapabilities());
59
-        array_walk($roles, [$this, 'addCapabilities']);
60
-    }
51
+	/**
52
+	 * @return void
53
+	 */
54
+	public function resetAll()
55
+	{
56
+		$roles = array_keys(wp_roles()->roles);
57
+		array_walk($roles, [$this, 'removeCapabilities']);
58
+		$roles = array_keys($this->roleCapabilities());
59
+		array_walk($roles, [$this, 'addCapabilities']);
60
+	}
61 61
 
62
-    /**
63
-     * @return array
64
-     */
65
-    protected function capabilities()
66
-    {
67
-        $capabilities = [
68
-            'delete_others_posts',
69
-            'delete_post',
70
-            'delete_posts',
71
-            'delete_private_posts',
72
-            'delete_published_posts',
73
-            'edit_others_posts',
74
-            'edit_post',
75
-            'edit_posts',
76
-            'edit_private_posts',
77
-            'edit_published_posts',
78
-            'publish_posts',
79
-            'read_post',
80
-            'read_private_posts',
81
-        ];
82
-        return apply_filters('site-reviews/capabilities', $capabilities);
83
-    }
62
+	/**
63
+	 * @return array
64
+	 */
65
+	protected function capabilities()
66
+	{
67
+		$capabilities = [
68
+			'delete_others_posts',
69
+			'delete_post',
70
+			'delete_posts',
71
+			'delete_private_posts',
72
+			'delete_published_posts',
73
+			'edit_others_posts',
74
+			'edit_post',
75
+			'edit_posts',
76
+			'edit_private_posts',
77
+			'edit_published_posts',
78
+			'publish_posts',
79
+			'read_post',
80
+			'read_private_posts',
81
+		];
82
+		return apply_filters('site-reviews/capabilities', $capabilities);
83
+	}
84 84
 
85
-    /**
86
-     * @param string $capability
87
-     * @return string
88
-     */
89
-    protected function normalizeCapability($capability)
90
-    {
91
-        return str_replace('post', Application::POST_TYPE, $capability);
92
-    }
85
+	/**
86
+	 * @param string $capability
87
+	 * @return string
88
+	 */
89
+	protected function normalizeCapability($capability)
90
+	{
91
+		return str_replace('post', Application::POST_TYPE, $capability);
92
+	}
93 93
 
94
-    /**
95
-     * @return array
96
-     */
97
-    protected function roleCapabilities()
98
-    {
99
-        $capabilities = [
100
-            'administrator' => [
101
-                'delete_others_posts',
102
-                'delete_posts',
103
-                'delete_private_posts',
104
-                'delete_published_posts',
105
-                'edit_others_posts',
106
-                'edit_posts',
107
-                'edit_private_posts',
108
-                'edit_published_posts',
109
-                'publish_posts',
110
-                'read_private_posts',
111
-            ],
112
-            'editor' => [
113
-                'delete_others_posts',
114
-                'delete_posts',
115
-                'delete_private_posts',
116
-                'delete_published_posts',
117
-                'edit_others_posts',
118
-                'edit_posts',
119
-                'edit_private_posts',
120
-                'edit_published_posts',
121
-                'publish_posts',
122
-                'read_private_posts',
123
-            ],
124
-            'author' => [
125
-                'delete_posts',
126
-                'delete_published_posts',
127
-                'edit_posts',
128
-                'edit_published_posts',
129
-                'publish_posts',
130
-            ],
131
-            'contributor' => [
132
-                'delete_posts',
133
-                'edit_posts',
134
-            ],
135
-        ];
136
-        return apply_filters('site-reviews/capabilities/for-roles', $capabilities);
137
-    }
94
+	/**
95
+	 * @return array
96
+	 */
97
+	protected function roleCapabilities()
98
+	{
99
+		$capabilities = [
100
+			'administrator' => [
101
+				'delete_others_posts',
102
+				'delete_posts',
103
+				'delete_private_posts',
104
+				'delete_published_posts',
105
+				'edit_others_posts',
106
+				'edit_posts',
107
+				'edit_private_posts',
108
+				'edit_published_posts',
109
+				'publish_posts',
110
+				'read_private_posts',
111
+			],
112
+			'editor' => [
113
+				'delete_others_posts',
114
+				'delete_posts',
115
+				'delete_private_posts',
116
+				'delete_published_posts',
117
+				'edit_others_posts',
118
+				'edit_posts',
119
+				'edit_private_posts',
120
+				'edit_published_posts',
121
+				'publish_posts',
122
+				'read_private_posts',
123
+			],
124
+			'author' => [
125
+				'delete_posts',
126
+				'delete_published_posts',
127
+				'edit_posts',
128
+				'edit_published_posts',
129
+				'publish_posts',
130
+			],
131
+			'contributor' => [
132
+				'delete_posts',
133
+				'edit_posts',
134
+			],
135
+		];
136
+		return apply_filters('site-reviews/capabilities/for-roles', $capabilities);
137
+	}
138 138
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -10,15 +10,15 @@  discard block
 block discarded – undo
10 10
      * @param string $role
11 11
      * @return void
12 12
      */
13
-    public function addCapabilities($role)
13
+    public function addCapabilities( $role )
14 14
     {
15 15
         $roleCapabilities = $this->roleCapabilities();
16
-        $wpRole = get_role($role);
17
-        if (empty($wpRole) || !array_key_exists($role, $roleCapabilities)) {
16
+        $wpRole = get_role( $role );
17
+        if( empty($wpRole) || !array_key_exists( $role, $roleCapabilities ) ) {
18 18
             return;
19 19
         }
20
-        foreach ($roleCapabilities[$role] as $capability) {
21
-            $wpRole->add_cap($this->normalizeCapability($capability));
20
+        foreach( $roleCapabilities[$role] as $capability ) {
21
+            $wpRole->add_cap( $this->normalizeCapability( $capability ) );
22 22
         }
23 23
     }
24 24
 
@@ -26,25 +26,25 @@  discard block
 block discarded – undo
26 26
      * @param string $capability
27 27
      * @return bool
28 28
      */
29
-    public function can($capability)
29
+    public function can( $capability )
30 30
     {
31
-        return in_array($capability, $this->capabilities())
32
-            ? current_user_can($this->normalizeCapability($capability))
33
-            : current_user_can($capability);
31
+        return in_array( $capability, $this->capabilities() )
32
+            ? current_user_can( $this->normalizeCapability( $capability ) )
33
+            : current_user_can( $capability );
34 34
     }
35 35
 
36 36
     /**
37 37
      * @param string $role
38 38
      * @return void
39 39
      */
40
-    public function removeCapabilities($role)
40
+    public function removeCapabilities( $role )
41 41
     {
42
-        $wpRole = get_role($role);
43
-        if (empty($wpRole) || 'administrator' === $role) { // do not remove from administrator role
42
+        $wpRole = get_role( $role );
43
+        if( empty($wpRole) || 'administrator' === $role ) { // do not remove from administrator role
44 44
             return;
45 45
         }
46
-        foreach ($this->capabilities() as $capability) {
47
-            $wpRole->remove_cap($this->normalizeCapability($capability));
46
+        foreach( $this->capabilities() as $capability ) {
47
+            $wpRole->remove_cap( $this->normalizeCapability( $capability ) );
48 48
         }
49 49
     }
50 50
 
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public function resetAll()
55 55
     {
56
-        $roles = array_keys(wp_roles()->roles);
57
-        array_walk($roles, [$this, 'removeCapabilities']);
58
-        $roles = array_keys($this->roleCapabilities());
59
-        array_walk($roles, [$this, 'addCapabilities']);
56
+        $roles = array_keys( wp_roles()->roles );
57
+        array_walk( $roles, [$this, 'removeCapabilities'] );
58
+        $roles = array_keys( $this->roleCapabilities() );
59
+        array_walk( $roles, [$this, 'addCapabilities'] );
60 60
     }
61 61
 
62 62
     /**
@@ -79,16 +79,16 @@  discard block
 block discarded – undo
79 79
             'read_post',
80 80
             'read_private_posts',
81 81
         ];
82
-        return apply_filters('site-reviews/capabilities', $capabilities);
82
+        return apply_filters( 'site-reviews/capabilities', $capabilities );
83 83
     }
84 84
 
85 85
     /**
86 86
      * @param string $capability
87 87
      * @return string
88 88
      */
89
-    protected function normalizeCapability($capability)
89
+    protected function normalizeCapability( $capability )
90 90
     {
91
-        return str_replace('post', Application::POST_TYPE, $capability);
91
+        return str_replace( 'post', Application::POST_TYPE, $capability );
92 92
     }
93 93
 
94 94
     /**
@@ -133,6 +133,6 @@  discard block
 block discarded – undo
133 133
                 'edit_posts',
134 134
             ],
135 135
         ];
136
-        return apply_filters('site-reviews/capabilities/for-roles', $capabilities);
136
+        return apply_filters( 'site-reviews/capabilities/for-roles', $capabilities );
137 137
     }
138 138
 }
Please login to merge, or discard this patch.
plugin/Controllers/MenuController.php 2 patches
Indentation   +184 added lines, -184 removed lines patch added patch discarded remove patch
@@ -15,197 +15,197 @@
 block discarded – undo
15 15
 
16 16
 class MenuController extends Controller
17 17
 {
18
-    /**
19
-     * @return void
20
-     * @action admin_menu
21
-     */
22
-    public function registerMenuCount()
23
-    {
24
-        global $menu, $typenow;
25
-        foreach ($menu as $key => $value) {
26
-            if (!isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE) {
27
-                continue;
28
-            }
29
-            $postCount = wp_count_posts(Application::POST_TYPE);
30
-            $pendingCount = glsr(Builder::class)->span(number_format_i18n($postCount->pending), [
31
-                'class' => 'unapproved-count',
32
-            ]);
33
-            $awaitingModeration = glsr(Builder::class)->span($pendingCount, [
34
-                'class' => 'awaiting-mod count-'.$postCount->pending,
35
-            ]);
36
-            $menu[$key][0].= ' '.$awaitingModeration;
37
-            if (Application::POST_TYPE === $typenow) {
38
-                $menu[$key][4].= ' current';
39
-            }
40
-            break;
41
-        }
42
-    }
18
+	/**
19
+	 * @return void
20
+	 * @action admin_menu
21
+	 */
22
+	public function registerMenuCount()
23
+	{
24
+		global $menu, $typenow;
25
+		foreach ($menu as $key => $value) {
26
+			if (!isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE) {
27
+				continue;
28
+			}
29
+			$postCount = wp_count_posts(Application::POST_TYPE);
30
+			$pendingCount = glsr(Builder::class)->span(number_format_i18n($postCount->pending), [
31
+				'class' => 'unapproved-count',
32
+			]);
33
+			$awaitingModeration = glsr(Builder::class)->span($pendingCount, [
34
+				'class' => 'awaiting-mod count-'.$postCount->pending,
35
+			]);
36
+			$menu[$key][0].= ' '.$awaitingModeration;
37
+			if (Application::POST_TYPE === $typenow) {
38
+				$menu[$key][4].= ' current';
39
+			}
40
+			break;
41
+		}
42
+	}
43 43
 
44
-    /**
45
-     * @return void
46
-     * @action admin_menu
47
-     */
48
-    public function registerSubMenus()
49
-    {
50
-        $pages = $this->parseWithFilter('submenu/pages', [
51
-            'settings' => __('Settings', 'site-reviews'),
52
-            'tools' => __('Tools', 'site-reviews'),
53
-            'addons' => __('Add-ons', 'site-reviews'),
54
-            'documentation' => __('Help', 'site-reviews'),
55
-        ]);
56
-        foreach ($pages as $slug => $title) {
57
-            $method = Helper::buildMethodName('render-'.$slug.'-menu');
58
-            $callback = apply_filters('site-reviews/addon/submenu/callback', [$this, $method], $slug);
59
-            if (!is_callable($callback)) {
60
-                continue;
61
-            }
62
-            add_submenu_page('edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->getPermission($slug), $slug, $callback);
63
-        }
64
-    }
44
+	/**
45
+	 * @return void
46
+	 * @action admin_menu
47
+	 */
48
+	public function registerSubMenus()
49
+	{
50
+		$pages = $this->parseWithFilter('submenu/pages', [
51
+			'settings' => __('Settings', 'site-reviews'),
52
+			'tools' => __('Tools', 'site-reviews'),
53
+			'addons' => __('Add-ons', 'site-reviews'),
54
+			'documentation' => __('Help', 'site-reviews'),
55
+		]);
56
+		foreach ($pages as $slug => $title) {
57
+			$method = Helper::buildMethodName('render-'.$slug.'-menu');
58
+			$callback = apply_filters('site-reviews/addon/submenu/callback', [$this, $method], $slug);
59
+			if (!is_callable($callback)) {
60
+				continue;
61
+			}
62
+			add_submenu_page('edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->getPermission($slug), $slug, $callback);
63
+		}
64
+	}
65 65
 
66
-    /**
67
-     * @return void
68
-     * @see $this->registerSubMenus()
69
-     * @callback add_submenu_page
70
-     */
71
-    public function renderAddonsMenu()
72
-    {
73
-        $this->renderPage('addons', [
74
-            'template' => glsr(Template::class),
75
-        ]);
76
-    }
66
+	/**
67
+	 * @return void
68
+	 * @see $this->registerSubMenus()
69
+	 * @callback add_submenu_page
70
+	 */
71
+	public function renderAddonsMenu()
72
+	{
73
+		$this->renderPage('addons', [
74
+			'template' => glsr(Template::class),
75
+		]);
76
+	}
77 77
 
78
-    /**
79
-     * @return void
80
-     * @see $this->registerSubMenus()
81
-     * @callback add_submenu_page
82
-     */
83
-    public function renderDocumentationMenu()
84
-    {
85
-        $tabs = $this->parseWithFilter('documentation/tabs', [
86
-            'support' => __('Support', 'site-reviews'),
87
-            'faq' => __('FAQ', 'site-reviews'),
88
-            'shortcodes' => __('Shortcodes', 'site-reviews'),
89
-            'hooks' => __('Hooks', 'site-reviews'),
90
-            'functions' => __('Functions', 'site-reviews'),
91
-            'addons' => __('Addons', 'site-reviews'),
92
-        ]);
93
-        $addons = apply_filters('site-reviews/addon/documentation', []);
94
-        ksort($addons);
95
-        if (empty($addons)) {
96
-            unset($tabs['addons']);
97
-        }
98
-        $this->renderPage('documentation', [
99
-            'addons' => $addons,
100
-            'tabs' => $tabs,
101
-        ]);
102
-    }
78
+	/**
79
+	 * @return void
80
+	 * @see $this->registerSubMenus()
81
+	 * @callback add_submenu_page
82
+	 */
83
+	public function renderDocumentationMenu()
84
+	{
85
+		$tabs = $this->parseWithFilter('documentation/tabs', [
86
+			'support' => __('Support', 'site-reviews'),
87
+			'faq' => __('FAQ', 'site-reviews'),
88
+			'shortcodes' => __('Shortcodes', 'site-reviews'),
89
+			'hooks' => __('Hooks', 'site-reviews'),
90
+			'functions' => __('Functions', 'site-reviews'),
91
+			'addons' => __('Addons', 'site-reviews'),
92
+		]);
93
+		$addons = apply_filters('site-reviews/addon/documentation', []);
94
+		ksort($addons);
95
+		if (empty($addons)) {
96
+			unset($tabs['addons']);
97
+		}
98
+		$this->renderPage('documentation', [
99
+			'addons' => $addons,
100
+			'tabs' => $tabs,
101
+		]);
102
+	}
103 103
 
104
-    /**
105
-     * @return void
106
-     * @see $this->registerSubMenus()
107
-     * @callback add_submenu_page
108
-     */
109
-    public function renderSettingsMenu()
110
-    {
111
-        $tabs = $this->parseWithFilter('settings/tabs', [
112
-            'general' => __('General', 'site-reviews'),
113
-            'reviews' => __('Reviews', 'site-reviews'),
114
-            'submissions' => __('Submissions', 'site-reviews'),
115
-            'schema' => __('Schema', 'site-reviews'),
116
-            'translations' => __('Translations', 'site-reviews'),
117
-            'addons' => __('Addons', 'site-reviews'),
118
-            'licenses' => __('Licenses', 'site-reviews'),
119
-        ]);
120
-        if (empty(Arr::get(glsr()->defaults, 'settings.addons'))) {
121
-            unset($tabs['addons']);
122
-        }
123
-        if (empty(Arr::get(glsr()->defaults, 'settings.licenses'))) {
124
-            unset($tabs['licenses']);
125
-        }
126
-        $this->renderPage('settings', [
127
-            'settings' => glsr(Settings::class),
128
-            'tabs' => $tabs,
129
-        ]);
130
-    }
104
+	/**
105
+	 * @return void
106
+	 * @see $this->registerSubMenus()
107
+	 * @callback add_submenu_page
108
+	 */
109
+	public function renderSettingsMenu()
110
+	{
111
+		$tabs = $this->parseWithFilter('settings/tabs', [
112
+			'general' => __('General', 'site-reviews'),
113
+			'reviews' => __('Reviews', 'site-reviews'),
114
+			'submissions' => __('Submissions', 'site-reviews'),
115
+			'schema' => __('Schema', 'site-reviews'),
116
+			'translations' => __('Translations', 'site-reviews'),
117
+			'addons' => __('Addons', 'site-reviews'),
118
+			'licenses' => __('Licenses', 'site-reviews'),
119
+		]);
120
+		if (empty(Arr::get(glsr()->defaults, 'settings.addons'))) {
121
+			unset($tabs['addons']);
122
+		}
123
+		if (empty(Arr::get(glsr()->defaults, 'settings.licenses'))) {
124
+			unset($tabs['licenses']);
125
+		}
126
+		$this->renderPage('settings', [
127
+			'settings' => glsr(Settings::class),
128
+			'tabs' => $tabs,
129
+		]);
130
+	}
131 131
 
132
-    /**
133
-     * @return void
134
-     * @see $this->registerSubMenus()
135
-     * @callback add_submenu_page
136
-     */
137
-    public function renderToolsMenu()
138
-    {
139
-        $tabs = $this->parseWithFilter('tools/tabs', [
140
-            'general' => __('General', 'site-reviews'),
141
-            'sync' => __('Sync Reviews', 'site-reviews'),
142
-            'console' => __('Console', 'site-reviews'),
143
-            'system-info' => __('System Info', 'site-reviews'),
144
-        ]);
145
-        if (!apply_filters('site-reviews/addon/sync/enable', false)) {
146
-            unset($tabs['sync']);
147
-        }
148
-        $this->renderPage('tools', [
149
-            'data' => [
150
-                'context' => [
151
-                    'base_url' => admin_url('edit.php?post_type='.Application::POST_TYPE),
152
-                    'console' => strval(glsr(Console::class)),
153
-                    'id' => Application::ID,
154
-                    'system' => strval(glsr(System::class)),
155
-                ],
156
-                'services' => apply_filters('site-reviews/addon/sync/services', []),
157
-            ],
158
-            'tabs' => $tabs,
159
-            'template' => glsr(Template::class),
160
-        ]);
161
-    }
132
+	/**
133
+	 * @return void
134
+	 * @see $this->registerSubMenus()
135
+	 * @callback add_submenu_page
136
+	 */
137
+	public function renderToolsMenu()
138
+	{
139
+		$tabs = $this->parseWithFilter('tools/tabs', [
140
+			'general' => __('General', 'site-reviews'),
141
+			'sync' => __('Sync Reviews', 'site-reviews'),
142
+			'console' => __('Console', 'site-reviews'),
143
+			'system-info' => __('System Info', 'site-reviews'),
144
+		]);
145
+		if (!apply_filters('site-reviews/addon/sync/enable', false)) {
146
+			unset($tabs['sync']);
147
+		}
148
+		$this->renderPage('tools', [
149
+			'data' => [
150
+				'context' => [
151
+					'base_url' => admin_url('edit.php?post_type='.Application::POST_TYPE),
152
+					'console' => strval(glsr(Console::class)),
153
+					'id' => Application::ID,
154
+					'system' => strval(glsr(System::class)),
155
+				],
156
+				'services' => apply_filters('site-reviews/addon/sync/services', []),
157
+			],
158
+			'tabs' => $tabs,
159
+			'template' => glsr(Template::class),
160
+		]);
161
+	}
162 162
 
163
-    /**
164
-     * @return void
165
-     * @action admin_init
166
-     */
167
-    public function setCustomPermissions()
168
-    {
169
-        foreach (wp_roles()->roles as $role => $value) {
170
-            wp_roles()->remove_cap($role, 'create_'.Application::POST_TYPE);
171
-        }
172
-    }
163
+	/**
164
+	 * @return void
165
+	 * @action admin_init
166
+	 */
167
+	public function setCustomPermissions()
168
+	{
169
+		foreach (wp_roles()->roles as $role => $value) {
170
+			wp_roles()->remove_cap($role, 'create_'.Application::POST_TYPE);
171
+		}
172
+	}
173 173
 
174
-    /**
175
-     * @return string
176
-     */
177
-    protected function getNotices()
178
-    {
179
-        return glsr(Builder::class)->div(glsr(Notice::class)->get(), [
180
-            'id' => 'glsr-notices',
181
-        ]);
182
-    }
174
+	/**
175
+	 * @return string
176
+	 */
177
+	protected function getNotices()
178
+	{
179
+		return glsr(Builder::class)->div(glsr(Notice::class)->get(), [
180
+			'id' => 'glsr-notices',
181
+		]);
182
+	}
183 183
 
184
-    /**
185
-     * @param string $hookSuffix
186
-     * @return array
187
-     */
188
-    protected function parseWithFilter($hookSuffix, array $args = [])
189
-    {
190
-        if (Str::endsWith('/tabs', $hookSuffix)) {
191
-            $page = str_replace('/tabs', '', $hookSuffix);
192
-            foreach ($args as $tab => $title) {
193
-                if (!glsr()->hasPermission($page, $tab)) {
194
-                    unset($args[$tab]);
195
-                }
196
-            }
197
-        }
198
-        return apply_filters('site-reviews/addon/'.$hookSuffix, $args);
199
-    }
184
+	/**
185
+	 * @param string $hookSuffix
186
+	 * @return array
187
+	 */
188
+	protected function parseWithFilter($hookSuffix, array $args = [])
189
+	{
190
+		if (Str::endsWith('/tabs', $hookSuffix)) {
191
+			$page = str_replace('/tabs', '', $hookSuffix);
192
+			foreach ($args as $tab => $title) {
193
+				if (!glsr()->hasPermission($page, $tab)) {
194
+					unset($args[$tab]);
195
+				}
196
+			}
197
+		}
198
+		return apply_filters('site-reviews/addon/'.$hookSuffix, $args);
199
+	}
200 200
 
201
-    /**
202
-     * @param string $page
203
-     * @return void
204
-     */
205
-    protected function renderPage($page, array $data = [])
206
-    {
207
-        $data['http_referer'] = (string) wp_get_referer();
208
-        $data['notices'] = $this->getNotices();
209
-        glsr()->render('pages/'.$page.'/index', $data);
210
-    }
201
+	/**
202
+	 * @param string $page
203
+	 * @return void
204
+	 */
205
+	protected function renderPage($page, array $data = [])
206
+	{
207
+		$data['http_referer'] = (string) wp_get_referer();
208
+		$data['notices'] = $this->getNotices();
209
+		glsr()->render('pages/'.$page.'/index', $data);
210
+	}
211 211
 }
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -22,20 +22,20 @@  discard block
 block discarded – undo
22 22
     public function registerMenuCount()
23 23
     {
24 24
         global $menu, $typenow;
25
-        foreach ($menu as $key => $value) {
26
-            if (!isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE) {
25
+        foreach( $menu as $key => $value ) {
26
+            if( !isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE ) {
27 27
                 continue;
28 28
             }
29
-            $postCount = wp_count_posts(Application::POST_TYPE);
30
-            $pendingCount = glsr(Builder::class)->span(number_format_i18n($postCount->pending), [
29
+            $postCount = wp_count_posts( Application::POST_TYPE );
30
+            $pendingCount = glsr( Builder::class )->span( number_format_i18n( $postCount->pending ), [
31 31
                 'class' => 'unapproved-count',
32
-            ]);
33
-            $awaitingModeration = glsr(Builder::class)->span($pendingCount, [
32
+            ] );
33
+            $awaitingModeration = glsr( Builder::class )->span( $pendingCount, [
34 34
                 'class' => 'awaiting-mod count-'.$postCount->pending,
35
-            ]);
36
-            $menu[$key][0].= ' '.$awaitingModeration;
37
-            if (Application::POST_TYPE === $typenow) {
38
-                $menu[$key][4].= ' current';
35
+            ] );
36
+            $menu[$key][0] .= ' '.$awaitingModeration;
37
+            if( Application::POST_TYPE === $typenow ) {
38
+                $menu[$key][4] .= ' current';
39 39
             }
40 40
             break;
41 41
         }
@@ -47,19 +47,19 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public function registerSubMenus()
49 49
     {
50
-        $pages = $this->parseWithFilter('submenu/pages', [
51
-            'settings' => __('Settings', 'site-reviews'),
52
-            'tools' => __('Tools', 'site-reviews'),
53
-            'addons' => __('Add-ons', 'site-reviews'),
54
-            'documentation' => __('Help', 'site-reviews'),
55
-        ]);
56
-        foreach ($pages as $slug => $title) {
57
-            $method = Helper::buildMethodName('render-'.$slug.'-menu');
58
-            $callback = apply_filters('site-reviews/addon/submenu/callback', [$this, $method], $slug);
59
-            if (!is_callable($callback)) {
50
+        $pages = $this->parseWithFilter( 'submenu/pages', [
51
+            'settings' => __( 'Settings', 'site-reviews' ),
52
+            'tools' => __( 'Tools', 'site-reviews' ),
53
+            'addons' => __( 'Add-ons', 'site-reviews' ),
54
+            'documentation' => __( 'Help', 'site-reviews' ),
55
+        ] );
56
+        foreach( $pages as $slug => $title ) {
57
+            $method = Helper::buildMethodName( 'render-'.$slug.'-menu' );
58
+            $callback = apply_filters( 'site-reviews/addon/submenu/callback', [$this, $method], $slug );
59
+            if( !is_callable( $callback ) ) {
60 60
                 continue;
61 61
             }
62
-            add_submenu_page('edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->getPermission($slug), $slug, $callback);
62
+            add_submenu_page( 'edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->getPermission( $slug ), $slug, $callback );
63 63
         }
64 64
     }
65 65
 
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
      */
71 71
     public function renderAddonsMenu()
72 72
     {
73
-        $this->renderPage('addons', [
74
-            'template' => glsr(Template::class),
75
-        ]);
73
+        $this->renderPage( 'addons', [
74
+            'template' => glsr( Template::class ),
75
+        ] );
76 76
     }
77 77
 
78 78
     /**
@@ -82,23 +82,23 @@  discard block
 block discarded – undo
82 82
      */
83 83
     public function renderDocumentationMenu()
84 84
     {
85
-        $tabs = $this->parseWithFilter('documentation/tabs', [
86
-            'support' => __('Support', 'site-reviews'),
87
-            'faq' => __('FAQ', 'site-reviews'),
88
-            'shortcodes' => __('Shortcodes', 'site-reviews'),
89
-            'hooks' => __('Hooks', 'site-reviews'),
90
-            'functions' => __('Functions', 'site-reviews'),
91
-            'addons' => __('Addons', 'site-reviews'),
92
-        ]);
93
-        $addons = apply_filters('site-reviews/addon/documentation', []);
94
-        ksort($addons);
95
-        if (empty($addons)) {
85
+        $tabs = $this->parseWithFilter( 'documentation/tabs', [
86
+            'support' => __( 'Support', 'site-reviews' ),
87
+            'faq' => __( 'FAQ', 'site-reviews' ),
88
+            'shortcodes' => __( 'Shortcodes', 'site-reviews' ),
89
+            'hooks' => __( 'Hooks', 'site-reviews' ),
90
+            'functions' => __( 'Functions', 'site-reviews' ),
91
+            'addons' => __( 'Addons', 'site-reviews' ),
92
+        ] );
93
+        $addons = apply_filters( 'site-reviews/addon/documentation', [] );
94
+        ksort( $addons );
95
+        if( empty($addons) ) {
96 96
             unset($tabs['addons']);
97 97
         }
98
-        $this->renderPage('documentation', [
98
+        $this->renderPage( 'documentation', [
99 99
             'addons' => $addons,
100 100
             'tabs' => $tabs,
101
-        ]);
101
+        ] );
102 102
     }
103 103
 
104 104
     /**
@@ -108,25 +108,25 @@  discard block
 block discarded – undo
108 108
      */
109 109
     public function renderSettingsMenu()
110 110
     {
111
-        $tabs = $this->parseWithFilter('settings/tabs', [
112
-            'general' => __('General', 'site-reviews'),
113
-            'reviews' => __('Reviews', 'site-reviews'),
114
-            'submissions' => __('Submissions', 'site-reviews'),
115
-            'schema' => __('Schema', 'site-reviews'),
116
-            'translations' => __('Translations', 'site-reviews'),
117
-            'addons' => __('Addons', 'site-reviews'),
118
-            'licenses' => __('Licenses', 'site-reviews'),
119
-        ]);
120
-        if (empty(Arr::get(glsr()->defaults, 'settings.addons'))) {
111
+        $tabs = $this->parseWithFilter( 'settings/tabs', [
112
+            'general' => __( 'General', 'site-reviews' ),
113
+            'reviews' => __( 'Reviews', 'site-reviews' ),
114
+            'submissions' => __( 'Submissions', 'site-reviews' ),
115
+            'schema' => __( 'Schema', 'site-reviews' ),
116
+            'translations' => __( 'Translations', 'site-reviews' ),
117
+            'addons' => __( 'Addons', 'site-reviews' ),
118
+            'licenses' => __( 'Licenses', 'site-reviews' ),
119
+        ] );
120
+        if( empty(Arr::get( glsr()->defaults, 'settings.addons' )) ) {
121 121
             unset($tabs['addons']);
122 122
         }
123
-        if (empty(Arr::get(glsr()->defaults, 'settings.licenses'))) {
123
+        if( empty(Arr::get( glsr()->defaults, 'settings.licenses' )) ) {
124 124
             unset($tabs['licenses']);
125 125
         }
126
-        $this->renderPage('settings', [
127
-            'settings' => glsr(Settings::class),
126
+        $this->renderPage( 'settings', [
127
+            'settings' => glsr( Settings::class ),
128 128
             'tabs' => $tabs,
129
-        ]);
129
+        ] );
130 130
     }
131 131
 
132 132
     /**
@@ -136,28 +136,28 @@  discard block
 block discarded – undo
136 136
      */
137 137
     public function renderToolsMenu()
138 138
     {
139
-        $tabs = $this->parseWithFilter('tools/tabs', [
140
-            'general' => __('General', 'site-reviews'),
141
-            'sync' => __('Sync Reviews', 'site-reviews'),
142
-            'console' => __('Console', 'site-reviews'),
143
-            'system-info' => __('System Info', 'site-reviews'),
144
-        ]);
145
-        if (!apply_filters('site-reviews/addon/sync/enable', false)) {
139
+        $tabs = $this->parseWithFilter( 'tools/tabs', [
140
+            'general' => __( 'General', 'site-reviews' ),
141
+            'sync' => __( 'Sync Reviews', 'site-reviews' ),
142
+            'console' => __( 'Console', 'site-reviews' ),
143
+            'system-info' => __( 'System Info', 'site-reviews' ),
144
+        ] );
145
+        if( !apply_filters( 'site-reviews/addon/sync/enable', false ) ) {
146 146
             unset($tabs['sync']);
147 147
         }
148
-        $this->renderPage('tools', [
148
+        $this->renderPage( 'tools', [
149 149
             'data' => [
150 150
                 'context' => [
151
-                    'base_url' => admin_url('edit.php?post_type='.Application::POST_TYPE),
152
-                    'console' => strval(glsr(Console::class)),
151
+                    'base_url' => admin_url( 'edit.php?post_type='.Application::POST_TYPE ),
152
+                    'console' => strval( glsr( Console::class ) ),
153 153
                     'id' => Application::ID,
154
-                    'system' => strval(glsr(System::class)),
154
+                    'system' => strval( glsr( System::class ) ),
155 155
                 ],
156
-                'services' => apply_filters('site-reviews/addon/sync/services', []),
156
+                'services' => apply_filters( 'site-reviews/addon/sync/services', [] ),
157 157
             ],
158 158
             'tabs' => $tabs,
159
-            'template' => glsr(Template::class),
160
-        ]);
159
+            'template' => glsr( Template::class ),
160
+        ] );
161 161
     }
162 162
 
163 163
     /**
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
      */
167 167
     public function setCustomPermissions()
168 168
     {
169
-        foreach (wp_roles()->roles as $role => $value) {
170
-            wp_roles()->remove_cap($role, 'create_'.Application::POST_TYPE);
169
+        foreach( wp_roles()->roles as $role => $value ) {
170
+            wp_roles()->remove_cap( $role, 'create_'.Application::POST_TYPE );
171 171
         }
172 172
     }
173 173
 
@@ -176,36 +176,36 @@  discard block
 block discarded – undo
176 176
      */
177 177
     protected function getNotices()
178 178
     {
179
-        return glsr(Builder::class)->div(glsr(Notice::class)->get(), [
179
+        return glsr( Builder::class )->div( glsr( Notice::class )->get(), [
180 180
             'id' => 'glsr-notices',
181
-        ]);
181
+        ] );
182 182
     }
183 183
 
184 184
     /**
185 185
      * @param string $hookSuffix
186 186
      * @return array
187 187
      */
188
-    protected function parseWithFilter($hookSuffix, array $args = [])
188
+    protected function parseWithFilter( $hookSuffix, array $args = [] )
189 189
     {
190
-        if (Str::endsWith('/tabs', $hookSuffix)) {
191
-            $page = str_replace('/tabs', '', $hookSuffix);
192
-            foreach ($args as $tab => $title) {
193
-                if (!glsr()->hasPermission($page, $tab)) {
190
+        if( Str::endsWith( '/tabs', $hookSuffix ) ) {
191
+            $page = str_replace( '/tabs', '', $hookSuffix );
192
+            foreach( $args as $tab => $title ) {
193
+                if( !glsr()->hasPermission( $page, $tab ) ) {
194 194
                     unset($args[$tab]);
195 195
                 }
196 196
             }
197 197
         }
198
-        return apply_filters('site-reviews/addon/'.$hookSuffix, $args);
198
+        return apply_filters( 'site-reviews/addon/'.$hookSuffix, $args );
199 199
     }
200 200
 
201 201
     /**
202 202
      * @param string $page
203 203
      * @return void
204 204
      */
205
-    protected function renderPage($page, array $data = [])
205
+    protected function renderPage( $page, array $data = [] )
206 206
     {
207
-        $data['http_referer'] = (string) wp_get_referer();
207
+        $data['http_referer'] = (string)wp_get_referer();
208 208
         $data['notices'] = $this->getNotices();
209
-        glsr()->render('pages/'.$page.'/index', $data);
209
+        glsr()->render( 'pages/'.$page.'/index', $data );
210 210
     }
211 211
 }
Please login to merge, or discard this patch.
plugin/Controllers/ListTableController/Columns.php 2 patches
Indentation   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -10,180 +10,180 @@
 block discarded – undo
10 10
 
11 11
 class Columns
12 12
 {
13
-    /**
14
-     * @param int $postId
15
-     * @return void|string
16
-     */
17
-    public function buildColumnAssignedTo($postId)
18
-    {
19
-        $assignedPost = glsr(Database::class)->getAssignedToPost($postId);
20
-        if ($assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status) {
21
-            return glsr(Builder::class)->a(get_the_title($assignedPost->ID), [
22
-                'href' => (string) get_the_permalink($assignedPost->ID),
23
-            ]);
24
-        }
25
-    }
13
+	/**
14
+	 * @param int $postId
15
+	 * @return void|string
16
+	 */
17
+	public function buildColumnAssignedTo($postId)
18
+	{
19
+		$assignedPost = glsr(Database::class)->getAssignedToPost($postId);
20
+		if ($assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status) {
21
+			return glsr(Builder::class)->a(get_the_title($assignedPost->ID), [
22
+				'href' => (string) get_the_permalink($assignedPost->ID),
23
+			]);
24
+		}
25
+	}
26 26
 
27
-    /**
28
-     * @param int $postId
29
-     * @return void|string
30
-     */
31
-    public function buildColumnEmail($postId)
32
-    {
33
-        if ($email = glsr(Database::class)->get($postId, 'email')) {
34
-            return $email;
35
-        }
36
-    }
27
+	/**
28
+	 * @param int $postId
29
+	 * @return void|string
30
+	 */
31
+	public function buildColumnEmail($postId)
32
+	{
33
+		if ($email = glsr(Database::class)->get($postId, 'email')) {
34
+			return $email;
35
+		}
36
+	}
37 37
 
38
-    /**
39
-     * @param int $postId
40
-     * @return void|string
41
-     */
42
-    public function buildColumnIpAddress($postId)
43
-    {
44
-        if ($ipAddress = glsr(Database::class)->get($postId, 'ip_address')) {
45
-            return $ipAddress;
46
-        }
47
-    }
38
+	/**
39
+	 * @param int $postId
40
+	 * @return void|string
41
+	 */
42
+	public function buildColumnIpAddress($postId)
43
+	{
44
+		if ($ipAddress = glsr(Database::class)->get($postId, 'ip_address')) {
45
+			return $ipAddress;
46
+		}
47
+	}
48 48
 
49
-    /**
50
-     * @param int $postId
51
-     * @return string
52
-     */
53
-    public function buildColumnPinned($postId)
54
-    {
55
-        $pinned = glsr(Database::class)->get($postId, 'pinned')
56
-            ? 'pinned '
57
-            : '';
58
-        if (glsr()->can('edit_others_posts')) {
59
-            $pinned.= 'pin-review ';
60
-        }
61
-        return glsr(Builder::class)->i([
62
-            'class' => $pinned.'dashicons dashicons-sticky',
63
-            'data-id' => $postId,
64
-        ]);
65
-    }
49
+	/**
50
+	 * @param int $postId
51
+	 * @return string
52
+	 */
53
+	public function buildColumnPinned($postId)
54
+	{
55
+		$pinned = glsr(Database::class)->get($postId, 'pinned')
56
+			? 'pinned '
57
+			: '';
58
+		if (glsr()->can('edit_others_posts')) {
59
+			$pinned.= 'pin-review ';
60
+		}
61
+		return glsr(Builder::class)->i([
62
+			'class' => $pinned.'dashicons dashicons-sticky',
63
+			'data-id' => $postId,
64
+		]);
65
+	}
66 66
 
67
-    /**
68
-     * @param int $postId
69
-     * @return string
70
-     */
71
-    public function buildColumnResponse($postId)
72
-    {
73
-        return glsr(Database::class)->get($postId, 'response')
74
-            ? __('Yes', 'site-reviews')
75
-            : __('No', 'site-reviews');
76
-    }
67
+	/**
68
+	 * @param int $postId
69
+	 * @return string
70
+	 */
71
+	public function buildColumnResponse($postId)
72
+	{
73
+		return glsr(Database::class)->get($postId, 'response')
74
+			? __('Yes', 'site-reviews')
75
+			: __('No', 'site-reviews');
76
+	}
77 77
 
78
-    /**
79
-     * @param int $postId
80
-     * @return string
81
-     */
82
-    public function buildColumnReviewer($postId)
83
-    {
84
-        return strval(glsr(Database::class)->get($postId, 'author'));
85
-    }
78
+	/**
79
+	 * @param int $postId
80
+	 * @return string
81
+	 */
82
+	public function buildColumnReviewer($postId)
83
+	{
84
+		return strval(glsr(Database::class)->get($postId, 'author'));
85
+	}
86 86
 
87
-    /**
88
-     * @param int $postId
89
-     * @param int|null $rating
90
-     * @return string
91
-     */
92
-    public function buildColumnRating($postId)
93
-    {
94
-        return glsr_star_rating(intval(glsr(Database::class)->get($postId, 'rating')));
95
-    }
87
+	/**
88
+	 * @param int $postId
89
+	 * @param int|null $rating
90
+	 * @return string
91
+	 */
92
+	public function buildColumnRating($postId)
93
+	{
94
+		return glsr_star_rating(intval(glsr(Database::class)->get($postId, 'rating')));
95
+	}
96 96
 
97
-    /**
98
-     * @param int $postId
99
-     * @return string
100
-     */
101
-    public function buildColumnReviewType($postId)
102
-    {
103
-        $type = glsr(Database::class)->get($postId, 'review_type');
104
-        return array_key_exists($type, glsr()->reviewTypes)
105
-            ? glsr()->reviewTypes[$type]
106
-            : __('Unsupported Type', 'site-reviews');
107
-    }
97
+	/**
98
+	 * @param int $postId
99
+	 * @return string
100
+	 */
101
+	public function buildColumnReviewType($postId)
102
+	{
103
+		$type = glsr(Database::class)->get($postId, 'review_type');
104
+		return array_key_exists($type, glsr()->reviewTypes)
105
+			? glsr()->reviewTypes[$type]
106
+			: __('Unsupported Type', 'site-reviews');
107
+	}
108 108
 
109
-    /**
110
-     * @param string $postType
111
-     * @return void
112
-     */
113
-    public function renderFilters($postType)
114
-    {
115
-        if (Application::POST_TYPE !== $postType) {
116
-            return;
117
-        }
118
-        if (!($status = filter_input(INPUT_GET, 'post_status'))) {
119
-            $status = 'publish';
120
-        }
121
-        $ratings = glsr(Database::class)->getReviewsMeta('rating', $status);
122
-        $types = glsr(Database::class)->getReviewsMeta('review_type', $status);
123
-        $this->renderFilterRatings($ratings);
124
-        $this->renderFilterTypes($types);
125
-    }
109
+	/**
110
+	 * @param string $postType
111
+	 * @return void
112
+	 */
113
+	public function renderFilters($postType)
114
+	{
115
+		if (Application::POST_TYPE !== $postType) {
116
+			return;
117
+		}
118
+		if (!($status = filter_input(INPUT_GET, 'post_status'))) {
119
+			$status = 'publish';
120
+		}
121
+		$ratings = glsr(Database::class)->getReviewsMeta('rating', $status);
122
+		$types = glsr(Database::class)->getReviewsMeta('review_type', $status);
123
+		$this->renderFilterRatings($ratings);
124
+		$this->renderFilterTypes($types);
125
+	}
126 126
 
127
-    /**
128
-     * @param string $column
129
-     * @param int $postId
130
-     * @return void
131
-     */
132
-    public function renderValues($column, $postId)
133
-    {
134
-        $method = Helper::buildMethodName($column, 'buildColumn');
135
-        $value = method_exists($this, $method)
136
-            ? call_user_func([$this, $method], $postId)
137
-            : '';
138
-        $value = apply_filters('site-reviews/columns/'.$column, $value, $postId);
139
-        if (0 !== $value && empty($value)) {
140
-            $value = '—';
141
-        }
142
-        echo $value;
143
-    }
127
+	/**
128
+	 * @param string $column
129
+	 * @param int $postId
130
+	 * @return void
131
+	 */
132
+	public function renderValues($column, $postId)
133
+	{
134
+		$method = Helper::buildMethodName($column, 'buildColumn');
135
+		$value = method_exists($this, $method)
136
+			? call_user_func([$this, $method], $postId)
137
+			: '';
138
+		$value = apply_filters('site-reviews/columns/'.$column, $value, $postId);
139
+		if (0 !== $value && empty($value)) {
140
+			$value = '—';
141
+		}
142
+		echo $value;
143
+	}
144 144
 
145
-    /**
146
-     * @param array $ratings
147
-     * @return void
148
-     */
149
-    protected function renderFilterRatings($ratings)
150
-    {
151
-        if (empty($ratings)) {
152
-            return;
153
-        }
154
-        $ratings = array_flip(array_reverse($ratings));
155
-        array_walk($ratings, function (&$value, $key) {
156
-            $label = _n('%s star', '%s stars', $key, 'site-reviews');
157
-            $value = sprintf($label, $key);
158
-        });
159
-        echo glsr(Builder::class)->label(__('Filter by rating', 'site-reviews'), [
160
-            'class' => 'screen-reader-text',
161
-            'for' => 'rating',
162
-        ]);
163
-        echo glsr(Builder::class)->select([
164
-            'name' => 'rating',
165
-            'options' => ['' => __('All ratings', 'site-reviews')] + $ratings,
166
-            'value' => filter_input(INPUT_GET, 'rating'),
167
-        ]);
168
-    }
145
+	/**
146
+	 * @param array $ratings
147
+	 * @return void
148
+	 */
149
+	protected function renderFilterRatings($ratings)
150
+	{
151
+		if (empty($ratings)) {
152
+			return;
153
+		}
154
+		$ratings = array_flip(array_reverse($ratings));
155
+		array_walk($ratings, function (&$value, $key) {
156
+			$label = _n('%s star', '%s stars', $key, 'site-reviews');
157
+			$value = sprintf($label, $key);
158
+		});
159
+		echo glsr(Builder::class)->label(__('Filter by rating', 'site-reviews'), [
160
+			'class' => 'screen-reader-text',
161
+			'for' => 'rating',
162
+		]);
163
+		echo glsr(Builder::class)->select([
164
+			'name' => 'rating',
165
+			'options' => ['' => __('All ratings', 'site-reviews')] + $ratings,
166
+			'value' => filter_input(INPUT_GET, 'rating'),
167
+		]);
168
+	}
169 169
 
170
-    /**
171
-     * @param array $types
172
-     * @return void
173
-     */
174
-    protected function renderFilterTypes($types)
175
-    {
176
-        if (count(glsr()->reviewTypes) < 2) {
177
-            return;
178
-        }
179
-        echo glsr(Builder::class)->label(__('Filter by type', 'site-reviews'), [
180
-            'class' => 'screen-reader-text',
181
-            'for' => 'review_type',
182
-        ]);
183
-        echo glsr(Builder::class)->select([
184
-            'name' => 'review_type',
185
-            'options' => ['' => __('All types', 'site-reviews')] + glsr()->reviewTypes,
186
-            'value' => filter_input(INPUT_GET, 'review_type'),
187
-        ]);
188
-    }
170
+	/**
171
+	 * @param array $types
172
+	 * @return void
173
+	 */
174
+	protected function renderFilterTypes($types)
175
+	{
176
+		if (count(glsr()->reviewTypes) < 2) {
177
+			return;
178
+		}
179
+		echo glsr(Builder::class)->label(__('Filter by type', 'site-reviews'), [
180
+			'class' => 'screen-reader-text',
181
+			'for' => 'review_type',
182
+		]);
183
+		echo glsr(Builder::class)->select([
184
+			'name' => 'review_type',
185
+			'options' => ['' => __('All types', 'site-reviews')] + glsr()->reviewTypes,
186
+			'value' => filter_input(INPUT_GET, 'review_type'),
187
+		]);
188
+	}
189 189
 }
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
      * @param int $postId
15 15
      * @return void|string
16 16
      */
17
-    public function buildColumnAssignedTo($postId)
17
+    public function buildColumnAssignedTo( $postId )
18 18
     {
19
-        $assignedPost = glsr(Database::class)->getAssignedToPost($postId);
20
-        if ($assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status) {
21
-            return glsr(Builder::class)->a(get_the_title($assignedPost->ID), [
22
-                'href' => (string) get_the_permalink($assignedPost->ID),
23
-            ]);
19
+        $assignedPost = glsr( Database::class )->getAssignedToPost( $postId );
20
+        if( $assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status ) {
21
+            return glsr( Builder::class )->a( get_the_title( $assignedPost->ID ), [
22
+                'href' => (string)get_the_permalink( $assignedPost->ID ),
23
+            ] );
24 24
         }
25 25
     }
26 26
 
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
      * @param int $postId
29 29
      * @return void|string
30 30
      */
31
-    public function buildColumnEmail($postId)
31
+    public function buildColumnEmail( $postId )
32 32
     {
33
-        if ($email = glsr(Database::class)->get($postId, 'email')) {
33
+        if( $email = glsr( Database::class )->get( $postId, 'email' ) ) {
34 34
             return $email;
35 35
         }
36 36
     }
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
      * @param int $postId
40 40
      * @return void|string
41 41
      */
42
-    public function buildColumnIpAddress($postId)
42
+    public function buildColumnIpAddress( $postId )
43 43
     {
44
-        if ($ipAddress = glsr(Database::class)->get($postId, 'ip_address')) {
44
+        if( $ipAddress = glsr( Database::class )->get( $postId, 'ip_address' ) ) {
45 45
             return $ipAddress;
46 46
         }
47 47
     }
@@ -50,38 +50,38 @@  discard block
 block discarded – undo
50 50
      * @param int $postId
51 51
      * @return string
52 52
      */
53
-    public function buildColumnPinned($postId)
53
+    public function buildColumnPinned( $postId )
54 54
     {
55
-        $pinned = glsr(Database::class)->get($postId, 'pinned')
55
+        $pinned = glsr( Database::class )->get( $postId, 'pinned' )
56 56
             ? 'pinned '
57 57
             : '';
58
-        if (glsr()->can('edit_others_posts')) {
59
-            $pinned.= 'pin-review ';
58
+        if( glsr()->can( 'edit_others_posts' ) ) {
59
+            $pinned .= 'pin-review ';
60 60
         }
61
-        return glsr(Builder::class)->i([
61
+        return glsr( Builder::class )->i( [
62 62
             'class' => $pinned.'dashicons dashicons-sticky',
63 63
             'data-id' => $postId,
64
-        ]);
64
+        ] );
65 65
     }
66 66
 
67 67
     /**
68 68
      * @param int $postId
69 69
      * @return string
70 70
      */
71
-    public function buildColumnResponse($postId)
71
+    public function buildColumnResponse( $postId )
72 72
     {
73
-        return glsr(Database::class)->get($postId, 'response')
74
-            ? __('Yes', 'site-reviews')
75
-            : __('No', 'site-reviews');
73
+        return glsr( Database::class )->get( $postId, 'response' )
74
+            ? __( 'Yes', 'site-reviews' )
75
+            : __( 'No', 'site-reviews' );
76 76
     }
77 77
 
78 78
     /**
79 79
      * @param int $postId
80 80
      * @return string
81 81
      */
82
-    public function buildColumnReviewer($postId)
82
+    public function buildColumnReviewer( $postId )
83 83
     {
84
-        return strval(glsr(Database::class)->get($postId, 'author'));
84
+        return strval( glsr( Database::class )->get( $postId, 'author' ) );
85 85
     }
86 86
 
87 87
     /**
@@ -89,39 +89,39 @@  discard block
 block discarded – undo
89 89
      * @param int|null $rating
90 90
      * @return string
91 91
      */
92
-    public function buildColumnRating($postId)
92
+    public function buildColumnRating( $postId )
93 93
     {
94
-        return glsr_star_rating(intval(glsr(Database::class)->get($postId, 'rating')));
94
+        return glsr_star_rating( intval( glsr( Database::class )->get( $postId, 'rating' ) ) );
95 95
     }
96 96
 
97 97
     /**
98 98
      * @param int $postId
99 99
      * @return string
100 100
      */
101
-    public function buildColumnReviewType($postId)
101
+    public function buildColumnReviewType( $postId )
102 102
     {
103
-        $type = glsr(Database::class)->get($postId, 'review_type');
104
-        return array_key_exists($type, glsr()->reviewTypes)
103
+        $type = glsr( Database::class )->get( $postId, 'review_type' );
104
+        return array_key_exists( $type, glsr()->reviewTypes )
105 105
             ? glsr()->reviewTypes[$type]
106
-            : __('Unsupported Type', 'site-reviews');
106
+            : __( 'Unsupported Type', 'site-reviews' );
107 107
     }
108 108
 
109 109
     /**
110 110
      * @param string $postType
111 111
      * @return void
112 112
      */
113
-    public function renderFilters($postType)
113
+    public function renderFilters( $postType )
114 114
     {
115
-        if (Application::POST_TYPE !== $postType) {
115
+        if( Application::POST_TYPE !== $postType ) {
116 116
             return;
117 117
         }
118
-        if (!($status = filter_input(INPUT_GET, 'post_status'))) {
118
+        if( !($status = filter_input( INPUT_GET, 'post_status' )) ) {
119 119
             $status = 'publish';
120 120
         }
121
-        $ratings = glsr(Database::class)->getReviewsMeta('rating', $status);
122
-        $types = glsr(Database::class)->getReviewsMeta('review_type', $status);
123
-        $this->renderFilterRatings($ratings);
124
-        $this->renderFilterTypes($types);
121
+        $ratings = glsr( Database::class )->getReviewsMeta( 'rating', $status );
122
+        $types = glsr( Database::class )->getReviewsMeta( 'review_type', $status );
123
+        $this->renderFilterRatings( $ratings );
124
+        $this->renderFilterTypes( $types );
125 125
     }
126 126
 
127 127
     /**
@@ -129,14 +129,14 @@  discard block
 block discarded – undo
129 129
      * @param int $postId
130 130
      * @return void
131 131
      */
132
-    public function renderValues($column, $postId)
132
+    public function renderValues( $column, $postId )
133 133
     {
134
-        $method = Helper::buildMethodName($column, 'buildColumn');
135
-        $value = method_exists($this, $method)
136
-            ? call_user_func([$this, $method], $postId)
134
+        $method = Helper::buildMethodName( $column, 'buildColumn' );
135
+        $value = method_exists( $this, $method )
136
+            ? call_user_func( [$this, $method], $postId )
137 137
             : '';
138
-        $value = apply_filters('site-reviews/columns/'.$column, $value, $postId);
139
-        if (0 !== $value && empty($value)) {
138
+        $value = apply_filters( 'site-reviews/columns/'.$column, $value, $postId );
139
+        if( 0 !== $value && empty($value) ) {
140 140
             $value = '&mdash;';
141 141
         }
142 142
         echo $value;
@@ -146,44 +146,44 @@  discard block
 block discarded – undo
146 146
      * @param array $ratings
147 147
      * @return void
148 148
      */
149
-    protected function renderFilterRatings($ratings)
149
+    protected function renderFilterRatings( $ratings )
150 150
     {
151
-        if (empty($ratings)) {
151
+        if( empty($ratings) ) {
152 152
             return;
153 153
         }
154
-        $ratings = array_flip(array_reverse($ratings));
155
-        array_walk($ratings, function (&$value, $key) {
156
-            $label = _n('%s star', '%s stars', $key, 'site-reviews');
157
-            $value = sprintf($label, $key);
154
+        $ratings = array_flip( array_reverse( $ratings ) );
155
+        array_walk( $ratings, function( &$value, $key ) {
156
+            $label = _n( '%s star', '%s stars', $key, 'site-reviews' );
157
+            $value = sprintf( $label, $key );
158 158
         });
159
-        echo glsr(Builder::class)->label(__('Filter by rating', 'site-reviews'), [
159
+        echo glsr( Builder::class )->label( __( 'Filter by rating', 'site-reviews' ), [
160 160
             'class' => 'screen-reader-text',
161 161
             'for' => 'rating',
162
-        ]);
163
-        echo glsr(Builder::class)->select([
162
+        ] );
163
+        echo glsr( Builder::class )->select( [
164 164
             'name' => 'rating',
165
-            'options' => ['' => __('All ratings', 'site-reviews')] + $ratings,
166
-            'value' => filter_input(INPUT_GET, 'rating'),
167
-        ]);
165
+            'options' => ['' => __( 'All ratings', 'site-reviews' )] + $ratings,
166
+            'value' => filter_input( INPUT_GET, 'rating' ),
167
+        ] );
168 168
     }
169 169
 
170 170
     /**
171 171
      * @param array $types
172 172
      * @return void
173 173
      */
174
-    protected function renderFilterTypes($types)
174
+    protected function renderFilterTypes( $types )
175 175
     {
176
-        if (count(glsr()->reviewTypes) < 2) {
176
+        if( count( glsr()->reviewTypes ) < 2 ) {
177 177
             return;
178 178
         }
179
-        echo glsr(Builder::class)->label(__('Filter by type', 'site-reviews'), [
179
+        echo glsr( Builder::class )->label( __( 'Filter by type', 'site-reviews' ), [
180 180
             'class' => 'screen-reader-text',
181 181
             'for' => 'review_type',
182
-        ]);
183
-        echo glsr(Builder::class)->select([
182
+        ] );
183
+        echo glsr( Builder::class )->select( [
184 184
             'name' => 'review_type',
185
-            'options' => ['' => __('All types', 'site-reviews')] + glsr()->reviewTypes,
186
-            'value' => filter_input(INPUT_GET, 'review_type'),
187
-        ]);
185
+            'options' => ['' => __( 'All types', 'site-reviews' )] + glsr()->reviewTypes,
186
+            'value' => filter_input( INPUT_GET, 'review_type' ),
187
+        ] );
188 188
     }
189 189
 }
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.
plugin/Controllers/ListTableController.php 2 patches
Indentation   +249 added lines, -249 removed lines patch added patch discarded remove patch
@@ -14,268 +14,268 @@
 block discarded – undo
14 14
 
15 15
 class ListTableController extends Controller
16 16
 {
17
-    /**
18
-     * @return void
19
-     * @action admin_action_approve
20
-     */
21
-    public function approve()
22
-    {
23
-        if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
24
-            return;
25
-        }
26
-        check_admin_referer('approve-review_'.($postId = $this->getPostId()));
27
-        wp_update_post([
28
-            'ID' => $postId,
29
-            'post_status' => 'publish',
30
-        ]);
31
-        wp_safe_redirect(wp_get_referer());
32
-        exit;
33
-    }
17
+	/**
18
+	 * @return void
19
+	 * @action admin_action_approve
20
+	 */
21
+	public function approve()
22
+	{
23
+		if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
24
+			return;
25
+		}
26
+		check_admin_referer('approve-review_'.($postId = $this->getPostId()));
27
+		wp_update_post([
28
+			'ID' => $postId,
29
+			'post_status' => 'publish',
30
+		]);
31
+		wp_safe_redirect(wp_get_referer());
32
+		exit;
33
+	}
34 34
 
35
-    /**
36
-     * @param array $columns
37
-     * @return array
38
-     * @filter manage_.Application::POST_TYPE._posts_columns
39
-     */
40
-    public function filterColumnsForPostType($columns)
41
-    {
42
-        $columns = Arr::consolidateArray($columns);
43
-        $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE];
44
-        foreach ($postTypeColumns as $key => &$value) {
45
-            if (!array_key_exists($key, $columns) || !empty($value)) {
46
-                continue;
47
-            }
48
-            $value = $columns[$key];
49
-        }
50
-        if (count(glsr(Database::class)->getReviewsMeta('review_type')) < 2) {
51
-            unset($postTypeColumns['review_type']);
52
-        }
53
-        return array_filter($postTypeColumns, 'strlen');
54
-    }
35
+	/**
36
+	 * @param array $columns
37
+	 * @return array
38
+	 * @filter manage_.Application::POST_TYPE._posts_columns
39
+	 */
40
+	public function filterColumnsForPostType($columns)
41
+	{
42
+		$columns = Arr::consolidateArray($columns);
43
+		$postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE];
44
+		foreach ($postTypeColumns as $key => &$value) {
45
+			if (!array_key_exists($key, $columns) || !empty($value)) {
46
+				continue;
47
+			}
48
+			$value = $columns[$key];
49
+		}
50
+		if (count(glsr(Database::class)->getReviewsMeta('review_type')) < 2) {
51
+			unset($postTypeColumns['review_type']);
52
+		}
53
+		return array_filter($postTypeColumns, 'strlen');
54
+	}
55 55
 
56
-    /**
57
-     * @param string $status
58
-     * @param WP_Post $post
59
-     * @return string
60
-     * @filter post_date_column_status
61
-     */
62
-    public function filterDateColumnStatus($status, $post)
63
-    {
64
-        if (Application::POST_TYPE == Arr::get($post, 'post_type')) {
65
-            $status = __('Submitted', 'site-reviews');
66
-        }
67
-        return $status;
68
-    }
56
+	/**
57
+	 * @param string $status
58
+	 * @param WP_Post $post
59
+	 * @return string
60
+	 * @filter post_date_column_status
61
+	 */
62
+	public function filterDateColumnStatus($status, $post)
63
+	{
64
+		if (Application::POST_TYPE == Arr::get($post, 'post_type')) {
65
+			$status = __('Submitted', 'site-reviews');
66
+		}
67
+		return $status;
68
+	}
69 69
 
70
-    /**
71
-     * @param array $hidden
72
-     * @param WP_Screen $post
73
-     * @return array
74
-     * @filter default_hidden_columns
75
-     */
76
-    public function filterDefaultHiddenColumns($hidden, $screen)
77
-    {
78
-        if (Arr::get($screen, 'id') == 'edit-'.Application::POST_TYPE) {
79
-            $hidden = Arr::consolidateArray($hidden);
80
-            $hidden = array_unique(array_merge($hidden, [
81
-                'email', 'ip_address', 'response', 'reviewer',
82
-            ]));
83
-        }
84
-        return $hidden;
85
-    }
70
+	/**
71
+	 * @param array $hidden
72
+	 * @param WP_Screen $post
73
+	 * @return array
74
+	 * @filter default_hidden_columns
75
+	 */
76
+	public function filterDefaultHiddenColumns($hidden, $screen)
77
+	{
78
+		if (Arr::get($screen, 'id') == 'edit-'.Application::POST_TYPE) {
79
+			$hidden = Arr::consolidateArray($hidden);
80
+			$hidden = array_unique(array_merge($hidden, [
81
+				'email', 'ip_address', 'response', 'reviewer',
82
+			]));
83
+		}
84
+		return $hidden;
85
+	}
86 86
 
87
-    /**
88
-     * @param array $actions
89
-     * @param WP_Post $post
90
-     * @return array
91
-     * @filter post_row_actions
92
-     */
93
-    public function filterRowActions($actions, $post)
94
-    {
95
-        if (Application::POST_TYPE != Arr::get($post, 'post_type')
96
-            || 'trash' == $post->post_status
97
-            || !user_can(get_current_user_id(), 'edit_post', $post->ID)) {
98
-            return $actions;
99
-        }
100
-        unset($actions['inline hide-if-no-js']); //Remove Quick-edit
101
-        $rowActions = [
102
-            'approve' => esc_attr__('Approve', 'site-reviews'),
103
-            'unapprove' => esc_attr__('Unapprove', 'site-reviews'),
104
-        ];
105
-        $newActions = [];
106
-        foreach ($rowActions as $key => $text) {
107
-            $newActions[$key] = glsr(Builder::class)->a($text, [
108
-                'aria-label' => sprintf(esc_attr_x('%s this review', 'Approve the review', 'site-reviews'), $text),
109
-                'class' => 'glsr-change-status',
110
-                'href' => wp_nonce_url(
111
-                    admin_url('post.php?post='.$post->ID.'&action='.$key.'&plugin='.Application::ID),
112
-                    $key.'-review_'.$post->ID
113
-                ),
114
-            ]);
115
-        }
116
-        return $newActions + Arr::consolidateArray($actions);
117
-    }
87
+	/**
88
+	 * @param array $actions
89
+	 * @param WP_Post $post
90
+	 * @return array
91
+	 * @filter post_row_actions
92
+	 */
93
+	public function filterRowActions($actions, $post)
94
+	{
95
+		if (Application::POST_TYPE != Arr::get($post, 'post_type')
96
+			|| 'trash' == $post->post_status
97
+			|| !user_can(get_current_user_id(), 'edit_post', $post->ID)) {
98
+			return $actions;
99
+		}
100
+		unset($actions['inline hide-if-no-js']); //Remove Quick-edit
101
+		$rowActions = [
102
+			'approve' => esc_attr__('Approve', 'site-reviews'),
103
+			'unapprove' => esc_attr__('Unapprove', 'site-reviews'),
104
+		];
105
+		$newActions = [];
106
+		foreach ($rowActions as $key => $text) {
107
+			$newActions[$key] = glsr(Builder::class)->a($text, [
108
+				'aria-label' => sprintf(esc_attr_x('%s this review', 'Approve the review', 'site-reviews'), $text),
109
+				'class' => 'glsr-change-status',
110
+				'href' => wp_nonce_url(
111
+					admin_url('post.php?post='.$post->ID.'&action='.$key.'&plugin='.Application::ID),
112
+					$key.'-review_'.$post->ID
113
+				),
114
+			]);
115
+		}
116
+		return $newActions + Arr::consolidateArray($actions);
117
+	}
118 118
 
119
-    /**
120
-     * @param array $columns
121
-     * @return array
122
-     * @filter manage_edit-.Application::POST_TYPE._sortable_columns
123
-     */
124
-    public function filterSortableColumns($columns)
125
-    {
126
-        $columns = Arr::consolidateArray($columns);
127
-        $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE];
128
-        unset($postTypeColumns['cb']);
129
-        foreach ($postTypeColumns as $key => $value) {
130
-            if (Str::startsWith('taxonomy', $key)) {
131
-                continue;
132
-            }
133
-            $columns[$key] = $key;
134
-        }
135
-        return $columns;
136
-    }
119
+	/**
120
+	 * @param array $columns
121
+	 * @return array
122
+	 * @filter manage_edit-.Application::POST_TYPE._sortable_columns
123
+	 */
124
+	public function filterSortableColumns($columns)
125
+	{
126
+		$columns = Arr::consolidateArray($columns);
127
+		$postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE];
128
+		unset($postTypeColumns['cb']);
129
+		foreach ($postTypeColumns as $key => $value) {
130
+			if (Str::startsWith('taxonomy', $key)) {
131
+				continue;
132
+			}
133
+			$columns[$key] = $key;
134
+		}
135
+		return $columns;
136
+	}
137 137
 
138
-    /**
139
-     * @param string $columnName
140
-     * @param string $postType
141
-     * @return void
142
-     * @action bulk_edit_custom_box
143
-     */
144
-    public function renderBulkEditFields($columnName, $postType)
145
-    {
146
-        if ('assigned_to' == $columnName && Application::POST_TYPE == $postType) {
147
-            glsr()->render('partials/editor/bulk-edit-assigned-to');
148
-        }
149
-    }
138
+	/**
139
+	 * @param string $columnName
140
+	 * @param string $postType
141
+	 * @return void
142
+	 * @action bulk_edit_custom_box
143
+	 */
144
+	public function renderBulkEditFields($columnName, $postType)
145
+	{
146
+		if ('assigned_to' == $columnName && Application::POST_TYPE == $postType) {
147
+			glsr()->render('partials/editor/bulk-edit-assigned-to');
148
+		}
149
+	}
150 150
 
151
-    /**
152
-     * @param string $postType
153
-     * @return void
154
-     * @action restrict_manage_posts
155
-     */
156
-    public function renderColumnFilters($postType)
157
-    {
158
-        glsr(Columns::class)->renderFilters($postType);
159
-    }
151
+	/**
152
+	 * @param string $postType
153
+	 * @return void
154
+	 * @action restrict_manage_posts
155
+	 */
156
+	public function renderColumnFilters($postType)
157
+	{
158
+		glsr(Columns::class)->renderFilters($postType);
159
+	}
160 160
 
161
-    /**
162
-     * @param string $column
163
-     * @param string $postId
164
-     * @return void
165
-     * @action manage_posts_custom_column
166
-     */
167
-    public function renderColumnValues($column, $postId)
168
-    {
169
-        glsr(Columns::class)->renderValues($column, $postId);
170
-    }
161
+	/**
162
+	 * @param string $column
163
+	 * @param string $postId
164
+	 * @return void
165
+	 * @action manage_posts_custom_column
166
+	 */
167
+	public function renderColumnValues($column, $postId)
168
+	{
169
+		glsr(Columns::class)->renderValues($column, $postId);
170
+	}
171 171
 
172
-    /**
173
-     * @param int $postId
174
-     * @return void
175
-     * @action save_post_.Application::POST_TYPE
176
-     */
177
-    public function saveBulkEditFields($postId)
178
-    {
179
-        if (!glsr()->can('edit_posts')) {
180
-            return;
181
-        }
182
-        $assignedTo = filter_input(INPUT_GET, 'assigned_to');
183
-        if ($assignedTo && get_post($assignedTo)) {
184
-            glsr(Database::class)->update($postId, 'assigned_to', $assignedTo);
185
-        }
186
-    }
172
+	/**
173
+	 * @param int $postId
174
+	 * @return void
175
+	 * @action save_post_.Application::POST_TYPE
176
+	 */
177
+	public function saveBulkEditFields($postId)
178
+	{
179
+		if (!glsr()->can('edit_posts')) {
180
+			return;
181
+		}
182
+		$assignedTo = filter_input(INPUT_GET, 'assigned_to');
183
+		if ($assignedTo && get_post($assignedTo)) {
184
+			glsr(Database::class)->update($postId, 'assigned_to', $assignedTo);
185
+		}
186
+	}
187 187
 
188
-    /**
189
-     * @return void
190
-     * @action pre_get_posts
191
-     */
192
-    public function setQueryForColumn(WP_Query $query)
193
-    {
194
-        if (!$this->hasPermission($query)) {
195
-            return;
196
-        }
197
-        $this->setMetaQuery($query, [
198
-            'rating', 'review_type',
199
-        ]);
200
-        $this->setOrderby($query);
201
-    }
188
+	/**
189
+	 * @return void
190
+	 * @action pre_get_posts
191
+	 */
192
+	public function setQueryForColumn(WP_Query $query)
193
+	{
194
+		if (!$this->hasPermission($query)) {
195
+			return;
196
+		}
197
+		$this->setMetaQuery($query, [
198
+			'rating', 'review_type',
199
+		]);
200
+		$this->setOrderby($query);
201
+	}
202 202
 
203
-    /**
204
-     * @return void
205
-     * @action admin_action_unapprove
206
-     */
207
-    public function unapprove()
208
-    {
209
-        if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
210
-            return;
211
-        }
212
-        check_admin_referer('unapprove-review_'.($postId = $this->getPostId()));
213
-        wp_update_post([
214
-            'ID' => $postId,
215
-            'post_status' => 'pending',
216
-        ]);
217
-        wp_safe_redirect(wp_get_referer());
218
-        exit;
219
-    }
203
+	/**
204
+	 * @return void
205
+	 * @action admin_action_unapprove
206
+	 */
207
+	public function unapprove()
208
+	{
209
+		if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
210
+			return;
211
+		}
212
+		check_admin_referer('unapprove-review_'.($postId = $this->getPostId()));
213
+		wp_update_post([
214
+			'ID' => $postId,
215
+			'post_status' => 'pending',
216
+		]);
217
+		wp_safe_redirect(wp_get_referer());
218
+		exit;
219
+	}
220 220
 
221
-    /**
222
-     * Check if the translation string can be modified.
223
-     * @param string $domain
224
-     * @return bool
225
-     */
226
-    protected function canModifyTranslation($domain = 'default')
227
-    {
228
-        $screen = glsr_current_screen();
229
-        return 'default' == $domain
230
-            && 'edit' == $screen->base
231
-            && Application::POST_TYPE == $screen->post_type;
232
-    }
221
+	/**
222
+	 * Check if the translation string can be modified.
223
+	 * @param string $domain
224
+	 * @return bool
225
+	 */
226
+	protected function canModifyTranslation($domain = 'default')
227
+	{
228
+		$screen = glsr_current_screen();
229
+		return 'default' == $domain
230
+			&& 'edit' == $screen->base
231
+			&& Application::POST_TYPE == $screen->post_type;
232
+	}
233 233
 
234
-    /**
235
-     * @return bool
236
-     */
237
-    protected function hasPermission(WP_Query $query)
238
-    {
239
-        global $pagenow;
240
-        return is_admin()
241
-            && $query->is_main_query()
242
-            && Application::POST_TYPE == $query->get('post_type')
243
-            && 'edit.php' == $pagenow;
244
-    }
234
+	/**
235
+	 * @return bool
236
+	 */
237
+	protected function hasPermission(WP_Query $query)
238
+	{
239
+		global $pagenow;
240
+		return is_admin()
241
+			&& $query->is_main_query()
242
+			&& Application::POST_TYPE == $query->get('post_type')
243
+			&& 'edit.php' == $pagenow;
244
+	}
245 245
 
246
-    /**
247
-     * @return void
248
-     */
249
-    protected function setMetaQuery(WP_Query $query, array $metaKeys)
250
-    {
251
-        foreach ($metaKeys as $key) {
252
-            $value = (string) filter_input(INPUT_GET, $key);
253
-            if ('' === $value) {
254
-                continue;
255
-            }
256
-            $metaQuery = (array) $query->get('meta_query');
257
-            $metaQuery[] = [
258
-                'key' => Str::prefix('_', $key, '_'),
259
-                'value' => $value,
260
-            ];
261
-            $query->set('meta_query', array_filter($metaQuery));
262
-        }
263
-    }
246
+	/**
247
+	 * @return void
248
+	 */
249
+	protected function setMetaQuery(WP_Query $query, array $metaKeys)
250
+	{
251
+		foreach ($metaKeys as $key) {
252
+			$value = (string) filter_input(INPUT_GET, $key);
253
+			if ('' === $value) {
254
+				continue;
255
+			}
256
+			$metaQuery = (array) $query->get('meta_query');
257
+			$metaQuery[] = [
258
+				'key' => Str::prefix('_', $key, '_'),
259
+				'value' => $value,
260
+			];
261
+			$query->set('meta_query', array_filter($metaQuery));
262
+		}
263
+	}
264 264
 
265
-    /**
266
-     * @return void
267
-     */
268
-    protected function setOrderby(WP_Query $query)
269
-    {
270
-        $orderby = $query->get('orderby');
271
-        $columns = glsr()->postTypeColumns[Application::POST_TYPE];
272
-        unset($columns['cb'], $columns['title'], $columns['date']);
273
-        if (in_array($orderby, array_keys($columns))) {
274
-            if ('reviewer' == $orderby) {
275
-                $orderby = 'author';
276
-            }
277
-            $query->set('meta_key', Str::prefix('_', $orderby, '_'));
278
-            $query->set('orderby', 'meta_value');
279
-        }
280
-    }
265
+	/**
266
+	 * @return void
267
+	 */
268
+	protected function setOrderby(WP_Query $query)
269
+	{
270
+		$orderby = $query->get('orderby');
271
+		$columns = glsr()->postTypeColumns[Application::POST_TYPE];
272
+		unset($columns['cb'], $columns['title'], $columns['date']);
273
+		if (in_array($orderby, array_keys($columns))) {
274
+			if ('reviewer' == $orderby) {
275
+				$orderby = 'author';
276
+			}
277
+			$query->set('meta_key', Str::prefix('_', $orderby, '_'));
278
+			$query->set('orderby', 'meta_value');
279
+		}
280
+	}
281 281
 }
Please login to merge, or discard this patch.
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -20,15 +20,15 @@  discard block
 block discarded – undo
20 20
      */
21 21
     public function approve()
22 22
     {
23
-        if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
23
+        if( Application::ID != filter_input( INPUT_GET, 'plugin' ) ) {
24 24
             return;
25 25
         }
26
-        check_admin_referer('approve-review_'.($postId = $this->getPostId()));
27
-        wp_update_post([
26
+        check_admin_referer( 'approve-review_'.($postId = $this->getPostId()) );
27
+        wp_update_post( [
28 28
             'ID' => $postId,
29 29
             'post_status' => 'publish',
30
-        ]);
31
-        wp_safe_redirect(wp_get_referer());
30
+        ] );
31
+        wp_safe_redirect( wp_get_referer() );
32 32
         exit;
33 33
     }
34 34
 
@@ -37,20 +37,20 @@  discard block
 block discarded – undo
37 37
      * @return array
38 38
      * @filter manage_.Application::POST_TYPE._posts_columns
39 39
      */
40
-    public function filterColumnsForPostType($columns)
40
+    public function filterColumnsForPostType( $columns )
41 41
     {
42
-        $columns = Arr::consolidateArray($columns);
42
+        $columns = Arr::consolidateArray( $columns );
43 43
         $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE];
44
-        foreach ($postTypeColumns as $key => &$value) {
45
-            if (!array_key_exists($key, $columns) || !empty($value)) {
44
+        foreach( $postTypeColumns as $key => &$value ) {
45
+            if( !array_key_exists( $key, $columns ) || !empty($value) ) {
46 46
                 continue;
47 47
             }
48 48
             $value = $columns[$key];
49 49
         }
50
-        if (count(glsr(Database::class)->getReviewsMeta('review_type')) < 2) {
50
+        if( count( glsr( Database::class )->getReviewsMeta( 'review_type' ) ) < 2 ) {
51 51
             unset($postTypeColumns['review_type']);
52 52
         }
53
-        return array_filter($postTypeColumns, 'strlen');
53
+        return array_filter( $postTypeColumns, 'strlen' );
54 54
     }
55 55
 
56 56
     /**
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
      * @return string
60 60
      * @filter post_date_column_status
61 61
      */
62
-    public function filterDateColumnStatus($status, $post)
62
+    public function filterDateColumnStatus( $status, $post )
63 63
     {
64
-        if (Application::POST_TYPE == Arr::get($post, 'post_type')) {
65
-            $status = __('Submitted', 'site-reviews');
64
+        if( Application::POST_TYPE == Arr::get( $post, 'post_type' ) ) {
65
+            $status = __( 'Submitted', 'site-reviews' );
66 66
         }
67 67
         return $status;
68 68
     }
@@ -73,13 +73,13 @@  discard block
 block discarded – undo
73 73
      * @return array
74 74
      * @filter default_hidden_columns
75 75
      */
76
-    public function filterDefaultHiddenColumns($hidden, $screen)
76
+    public function filterDefaultHiddenColumns( $hidden, $screen )
77 77
     {
78
-        if (Arr::get($screen, 'id') == 'edit-'.Application::POST_TYPE) {
79
-            $hidden = Arr::consolidateArray($hidden);
80
-            $hidden = array_unique(array_merge($hidden, [
78
+        if( Arr::get( $screen, 'id' ) == 'edit-'.Application::POST_TYPE ) {
79
+            $hidden = Arr::consolidateArray( $hidden );
80
+            $hidden = array_unique( array_merge( $hidden, [
81 81
                 'email', 'ip_address', 'response', 'reviewer',
82
-            ]));
82
+            ] ) );
83 83
         }
84 84
         return $hidden;
85 85
     }
@@ -90,30 +90,30 @@  discard block
 block discarded – undo
90 90
      * @return array
91 91
      * @filter post_row_actions
92 92
      */
93
-    public function filterRowActions($actions, $post)
93
+    public function filterRowActions( $actions, $post )
94 94
     {
95
-        if (Application::POST_TYPE != Arr::get($post, 'post_type')
95
+        if( Application::POST_TYPE != Arr::get( $post, 'post_type' )
96 96
             || 'trash' == $post->post_status
97
-            || !user_can(get_current_user_id(), 'edit_post', $post->ID)) {
97
+            || !user_can( get_current_user_id(), 'edit_post', $post->ID ) ) {
98 98
             return $actions;
99 99
         }
100 100
         unset($actions['inline hide-if-no-js']); //Remove Quick-edit
101 101
         $rowActions = [
102
-            'approve' => esc_attr__('Approve', 'site-reviews'),
103
-            'unapprove' => esc_attr__('Unapprove', 'site-reviews'),
102
+            'approve' => esc_attr__( 'Approve', 'site-reviews' ),
103
+            'unapprove' => esc_attr__( 'Unapprove', 'site-reviews' ),
104 104
         ];
105 105
         $newActions = [];
106
-        foreach ($rowActions as $key => $text) {
107
-            $newActions[$key] = glsr(Builder::class)->a($text, [
108
-                'aria-label' => sprintf(esc_attr_x('%s this review', 'Approve the review', 'site-reviews'), $text),
106
+        foreach( $rowActions as $key => $text ) {
107
+            $newActions[$key] = glsr( Builder::class )->a( $text, [
108
+                'aria-label' => sprintf( esc_attr_x( '%s this review', 'Approve the review', 'site-reviews' ), $text ),
109 109
                 'class' => 'glsr-change-status',
110 110
                 'href' => wp_nonce_url(
111
-                    admin_url('post.php?post='.$post->ID.'&action='.$key.'&plugin='.Application::ID),
111
+                    admin_url( 'post.php?post='.$post->ID.'&action='.$key.'&plugin='.Application::ID ),
112 112
                     $key.'-review_'.$post->ID
113 113
                 ),
114
-            ]);
114
+            ] );
115 115
         }
116
-        return $newActions + Arr::consolidateArray($actions);
116
+        return $newActions + Arr::consolidateArray( $actions );
117 117
     }
118 118
 
119 119
     /**
@@ -121,13 +121,13 @@  discard block
 block discarded – undo
121 121
      * @return array
122 122
      * @filter manage_edit-.Application::POST_TYPE._sortable_columns
123 123
      */
124
-    public function filterSortableColumns($columns)
124
+    public function filterSortableColumns( $columns )
125 125
     {
126
-        $columns = Arr::consolidateArray($columns);
126
+        $columns = Arr::consolidateArray( $columns );
127 127
         $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE];
128 128
         unset($postTypeColumns['cb']);
129
-        foreach ($postTypeColumns as $key => $value) {
130
-            if (Str::startsWith('taxonomy', $key)) {
129
+        foreach( $postTypeColumns as $key => $value ) {
130
+            if( Str::startsWith( 'taxonomy', $key ) ) {
131 131
                 continue;
132 132
             }
133 133
             $columns[$key] = $key;
@@ -141,10 +141,10 @@  discard block
 block discarded – undo
141 141
      * @return void
142 142
      * @action bulk_edit_custom_box
143 143
      */
144
-    public function renderBulkEditFields($columnName, $postType)
144
+    public function renderBulkEditFields( $columnName, $postType )
145 145
     {
146
-        if ('assigned_to' == $columnName && Application::POST_TYPE == $postType) {
147
-            glsr()->render('partials/editor/bulk-edit-assigned-to');
146
+        if( 'assigned_to' == $columnName && Application::POST_TYPE == $postType ) {
147
+            glsr()->render( 'partials/editor/bulk-edit-assigned-to' );
148 148
         }
149 149
     }
150 150
 
@@ -153,9 +153,9 @@  discard block
 block discarded – undo
153 153
      * @return void
154 154
      * @action restrict_manage_posts
155 155
      */
156
-    public function renderColumnFilters($postType)
156
+    public function renderColumnFilters( $postType )
157 157
     {
158
-        glsr(Columns::class)->renderFilters($postType);
158
+        glsr( Columns::class )->renderFilters( $postType );
159 159
     }
160 160
 
161 161
     /**
@@ -164,9 +164,9 @@  discard block
 block discarded – undo
164 164
      * @return void
165 165
      * @action manage_posts_custom_column
166 166
      */
167
-    public function renderColumnValues($column, $postId)
167
+    public function renderColumnValues( $column, $postId )
168 168
     {
169
-        glsr(Columns::class)->renderValues($column, $postId);
169
+        glsr( Columns::class )->renderValues( $column, $postId );
170 170
     }
171 171
 
172 172
     /**
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
      * @return void
175 175
      * @action save_post_.Application::POST_TYPE
176 176
      */
177
-    public function saveBulkEditFields($postId)
177
+    public function saveBulkEditFields( $postId )
178 178
     {
179
-        if (!glsr()->can('edit_posts')) {
179
+        if( !glsr()->can( 'edit_posts' ) ) {
180 180
             return;
181 181
         }
182
-        $assignedTo = filter_input(INPUT_GET, 'assigned_to');
183
-        if ($assignedTo && get_post($assignedTo)) {
184
-            glsr(Database::class)->update($postId, 'assigned_to', $assignedTo);
182
+        $assignedTo = filter_input( INPUT_GET, 'assigned_to' );
183
+        if( $assignedTo && get_post( $assignedTo ) ) {
184
+            glsr( Database::class )->update( $postId, 'assigned_to', $assignedTo );
185 185
         }
186 186
     }
187 187
 
@@ -189,15 +189,15 @@  discard block
 block discarded – undo
189 189
      * @return void
190 190
      * @action pre_get_posts
191 191
      */
192
-    public function setQueryForColumn(WP_Query $query)
192
+    public function setQueryForColumn( WP_Query $query )
193 193
     {
194
-        if (!$this->hasPermission($query)) {
194
+        if( !$this->hasPermission( $query ) ) {
195 195
             return;
196 196
         }
197
-        $this->setMetaQuery($query, [
197
+        $this->setMetaQuery( $query, [
198 198
             'rating', 'review_type',
199
-        ]);
200
-        $this->setOrderby($query);
199
+        ] );
200
+        $this->setOrderby( $query );
201 201
     }
202 202
 
203 203
     /**
@@ -206,15 +206,15 @@  discard block
 block discarded – undo
206 206
      */
207 207
     public function unapprove()
208 208
     {
209
-        if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
209
+        if( Application::ID != filter_input( INPUT_GET, 'plugin' ) ) {
210 210
             return;
211 211
         }
212
-        check_admin_referer('unapprove-review_'.($postId = $this->getPostId()));
213
-        wp_update_post([
212
+        check_admin_referer( 'unapprove-review_'.($postId = $this->getPostId()) );
213
+        wp_update_post( [
214 214
             'ID' => $postId,
215 215
             'post_status' => 'pending',
216
-        ]);
217
-        wp_safe_redirect(wp_get_referer());
216
+        ] );
217
+        wp_safe_redirect( wp_get_referer() );
218 218
         exit;
219 219
     }
220 220
 
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
      * @param string $domain
224 224
      * @return bool
225 225
      */
226
-    protected function canModifyTranslation($domain = 'default')
226
+    protected function canModifyTranslation( $domain = 'default' )
227 227
     {
228 228
         $screen = glsr_current_screen();
229 229
         return 'default' == $domain
@@ -234,48 +234,48 @@  discard block
 block discarded – undo
234 234
     /**
235 235
      * @return bool
236 236
      */
237
-    protected function hasPermission(WP_Query $query)
237
+    protected function hasPermission( WP_Query $query )
238 238
     {
239 239
         global $pagenow;
240 240
         return is_admin()
241 241
             && $query->is_main_query()
242
-            && Application::POST_TYPE == $query->get('post_type')
242
+            && Application::POST_TYPE == $query->get( 'post_type' )
243 243
             && 'edit.php' == $pagenow;
244 244
     }
245 245
 
246 246
     /**
247 247
      * @return void
248 248
      */
249
-    protected function setMetaQuery(WP_Query $query, array $metaKeys)
249
+    protected function setMetaQuery( WP_Query $query, array $metaKeys )
250 250
     {
251
-        foreach ($metaKeys as $key) {
252
-            $value = (string) filter_input(INPUT_GET, $key);
253
-            if ('' === $value) {
251
+        foreach( $metaKeys as $key ) {
252
+            $value = (string)filter_input( INPUT_GET, $key );
253
+            if( '' === $value ) {
254 254
                 continue;
255 255
             }
256
-            $metaQuery = (array) $query->get('meta_query');
256
+            $metaQuery = (array)$query->get( 'meta_query' );
257 257
             $metaQuery[] = [
258
-                'key' => Str::prefix('_', $key, '_'),
258
+                'key' => Str::prefix( '_', $key, '_' ),
259 259
                 'value' => $value,
260 260
             ];
261
-            $query->set('meta_query', array_filter($metaQuery));
261
+            $query->set( 'meta_query', array_filter( $metaQuery ) );
262 262
         }
263 263
     }
264 264
 
265 265
     /**
266 266
      * @return void
267 267
      */
268
-    protected function setOrderby(WP_Query $query)
268
+    protected function setOrderby( WP_Query $query )
269 269
     {
270
-        $orderby = $query->get('orderby');
270
+        $orderby = $query->get( 'orderby' );
271 271
         $columns = glsr()->postTypeColumns[Application::POST_TYPE];
272 272
         unset($columns['cb'], $columns['title'], $columns['date']);
273
-        if (in_array($orderby, array_keys($columns))) {
274
-            if ('reviewer' == $orderby) {
273
+        if( in_array( $orderby, array_keys( $columns ) ) ) {
274
+            if( 'reviewer' == $orderby ) {
275 275
                 $orderby = 'author';
276 276
             }
277
-            $query->set('meta_key', Str::prefix('_', $orderby, '_'));
278
-            $query->set('orderby', 'meta_value');
277
+            $query->set( 'meta_key', Str::prefix( '_', $orderby, '_' ) );
278
+            $query->set( 'orderby', 'meta_value' );
279 279
         }
280 280
     }
281 281
 }
Please login to merge, or discard this patch.
plugin/Controllers/AdminController.php 2 patches
Indentation   +227 added lines, -227 removed lines patch added patch discarded remove patch
@@ -18,248 +18,248 @@
 block discarded – undo
18 18
 
19 19
 class AdminController extends Controller
20 20
 {
21
-    /**
22
-     * @return void
23
-     * @action admin_enqueue_scripts
24
-     */
25
-    public function enqueueAssets()
26
-    {
27
-        $command = new EnqueueAdminAssets([
28
-            'pointers' => [[
29
-                'content' => __('You can pin exceptional reviews so that they are always shown first.', 'site-reviews'),
30
-                'id' => 'glsr-pointer-pinned',
31
-                'position' => [
32
-                    'edge' => 'right',
33
-                    'align' => 'middle',
34
-                ],
35
-                'screen' => Application::POST_TYPE,
36
-                'target' => '#misc-pub-pinned',
37
-                'title' => __('Pin Your Reviews', 'site-reviews'),
38
-            ]],
39
-        ]);
40
-        $this->execute($command);
41
-    }
21
+	/**
22
+	 * @return void
23
+	 * @action admin_enqueue_scripts
24
+	 */
25
+	public function enqueueAssets()
26
+	{
27
+		$command = new EnqueueAdminAssets([
28
+			'pointers' => [[
29
+				'content' => __('You can pin exceptional reviews so that they are always shown first.', 'site-reviews'),
30
+				'id' => 'glsr-pointer-pinned',
31
+				'position' => [
32
+					'edge' => 'right',
33
+					'align' => 'middle',
34
+				],
35
+				'screen' => Application::POST_TYPE,
36
+				'target' => '#misc-pub-pinned',
37
+				'title' => __('Pin Your Reviews', 'site-reviews'),
38
+			]],
39
+		]);
40
+		$this->execute($command);
41
+	}
42 42
 
43
-    /**
44
-     * @return array
45
-     * @filter plugin_action_links_site-reviews/site-reviews.php
46
-     */
47
-    public function filterActionLinks(array $links)
48
-    {
49
-        $links['documentation'] = glsr(Builder::class)->a(__('Help', 'site-reviews'), [
50
-            'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=documentation'),
51
-        ]);
52
-        $links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [
53
-            'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=settings'),
54
-        ]);
55
-        return $links;
56
-    }
43
+	/**
44
+	 * @return array
45
+	 * @filter plugin_action_links_site-reviews/site-reviews.php
46
+	 */
47
+	public function filterActionLinks(array $links)
48
+	{
49
+		$links['documentation'] = glsr(Builder::class)->a(__('Help', 'site-reviews'), [
50
+			'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=documentation'),
51
+		]);
52
+		$links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [
53
+			'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=settings'),
54
+		]);
55
+		return $links;
56
+	}
57 57
 
58
-    /**
59
-     * @param array $capabilities
60
-     * @param string $capability
61
-     * @return array
62
-     * @filter map_meta_cap
63
-     */
64
-    public function filterCreateCapability($capabilities, $capability)
65
-    {
66
-        if ($capability == 'create_'.Application::POST_TYPE) {
67
-            $capabilities[] = 'do_not_allow';
68
-        }
69
-        return $capabilities;
70
-    }
58
+	/**
59
+	 * @param array $capabilities
60
+	 * @param string $capability
61
+	 * @return array
62
+	 * @filter map_meta_cap
63
+	 */
64
+	public function filterCreateCapability($capabilities, $capability)
65
+	{
66
+		if ($capability == 'create_'.Application::POST_TYPE) {
67
+			$capabilities[] = 'do_not_allow';
68
+		}
69
+		return $capabilities;
70
+	}
71 71
 
72
-    /**
73
-     * @param array $items
74
-     * @return array
75
-     * @filter dashboard_glance_items
76
-     */
77
-    public function filterDashboardGlanceItems($items)
78
-    {
79
-        $postCount = wp_count_posts(Application::POST_TYPE);
80
-        if (empty($postCount->publish)) {
81
-            return $items;
82
-        }
83
-        $text = _n('%s Review', '%s Reviews', $postCount->publish, 'site-reviews');
84
-        $text = sprintf($text, number_format_i18n($postCount->publish));
85
-        $items = Arr::consolidateArray($items);
86
-        $items[] = glsr()->can('edit_posts')
87
-            ? glsr(Builder::class)->a($text, [
88
-                'class' => 'glsr-review-count',
89
-                'href' => 'edit.php?post_type='.Application::POST_TYPE,
90
-            ])
91
-            : glsr(Builder::class)->span($text, [
92
-                'class' => 'glsr-review-count',
93
-            ]);
94
-        return $items;
95
-    }
72
+	/**
73
+	 * @param array $items
74
+	 * @return array
75
+	 * @filter dashboard_glance_items
76
+	 */
77
+	public function filterDashboardGlanceItems($items)
78
+	{
79
+		$postCount = wp_count_posts(Application::POST_TYPE);
80
+		if (empty($postCount->publish)) {
81
+			return $items;
82
+		}
83
+		$text = _n('%s Review', '%s Reviews', $postCount->publish, 'site-reviews');
84
+		$text = sprintf($text, number_format_i18n($postCount->publish));
85
+		$items = Arr::consolidateArray($items);
86
+		$items[] = glsr()->can('edit_posts')
87
+			? glsr(Builder::class)->a($text, [
88
+				'class' => 'glsr-review-count',
89
+				'href' => 'edit.php?post_type='.Application::POST_TYPE,
90
+			])
91
+			: glsr(Builder::class)->span($text, [
92
+				'class' => 'glsr-review-count',
93
+			]);
94
+		return $items;
95
+	}
96 96
 
97
-    /**
98
-     * @param array $plugins
99
-     * @return array
100
-     * @filter mce_external_plugins
101
-     */
102
-    public function filterTinymcePlugins($plugins)
103
-    {
104
-        if (glsr()->can('edit_posts')) {
105
-            $plugins = Arr::consolidateArray($plugins);
106
-            $plugins['glsr_shortcode'] = glsr()->url('assets/scripts/mce-plugin.js');
107
-        }
108
-        return $plugins;
109
-    }
97
+	/**
98
+	 * @param array $plugins
99
+	 * @return array
100
+	 * @filter mce_external_plugins
101
+	 */
102
+	public function filterTinymcePlugins($plugins)
103
+	{
104
+		if (glsr()->can('edit_posts')) {
105
+			$plugins = Arr::consolidateArray($plugins);
106
+			$plugins['glsr_shortcode'] = glsr()->url('assets/scripts/mce-plugin.js');
107
+		}
108
+		return $plugins;
109
+	}
110 110
 
111
-    /**
112
-     * @return void
113
-     * @action admin_init
114
-     */
115
-    public function registerTinymcePopups()
116
-    {
117
-        $command = new RegisterTinymcePopups([
118
-            'site_reviews' => esc_html__('Recent Reviews', 'site-reviews'),
119
-            'site_reviews_form' => esc_html__('Submit a Review', 'site-reviews'),
120
-            'site_reviews_summary' => esc_html__('Summary of Reviews', 'site-reviews'),
121
-        ]);
122
-        $this->execute($command);
123
-    }
111
+	/**
112
+	 * @return void
113
+	 * @action admin_init
114
+	 */
115
+	public function registerTinymcePopups()
116
+	{
117
+		$command = new RegisterTinymcePopups([
118
+			'site_reviews' => esc_html__('Recent Reviews', 'site-reviews'),
119
+			'site_reviews_form' => esc_html__('Submit a Review', 'site-reviews'),
120
+			'site_reviews_summary' => esc_html__('Summary of Reviews', 'site-reviews'),
121
+		]);
122
+		$this->execute($command);
123
+	}
124 124
 
125
-    /**
126
-     * @param string $editorId
127
-     * @return void|null
128
-     * @action media_buttons
129
-     */
130
-    public function renderTinymceButton($editorId)
131
-    {
132
-        $allowedEditors = apply_filters('site-reviews/tinymce/editor-ids', ['content'], $editorId);
133
-        if ('post' != glsr_current_screen()->base || !in_array($editorId, $allowedEditors)) {
134
-            return;
135
-        }
136
-        $shortcodes = [];
137
-        foreach (glsr()->mceShortcodes as $shortcode => $values) {
138
-            $shortcodes[$shortcode] = $values;
139
-        }
140
-        if (empty($shortcodes)) {
141
-            return;
142
-        }
143
-        glsr()->render('partials/editor/tinymce', [
144
-            'shortcodes' => $shortcodes,
145
-        ]);
146
-    }
125
+	/**
126
+	 * @param string $editorId
127
+	 * @return void|null
128
+	 * @action media_buttons
129
+	 */
130
+	public function renderTinymceButton($editorId)
131
+	{
132
+		$allowedEditors = apply_filters('site-reviews/tinymce/editor-ids', ['content'], $editorId);
133
+		if ('post' != glsr_current_screen()->base || !in_array($editorId, $allowedEditors)) {
134
+			return;
135
+		}
136
+		$shortcodes = [];
137
+		foreach (glsr()->mceShortcodes as $shortcode => $values) {
138
+			$shortcodes[$shortcode] = $values;
139
+		}
140
+		if (empty($shortcodes)) {
141
+			return;
142
+		}
143
+		glsr()->render('partials/editor/tinymce', [
144
+			'shortcodes' => $shortcodes,
145
+		]);
146
+	}
147 147
 
148
-    /**
149
-     * @return void
150
-     */
151
-    public function routerClearConsole()
152
-    {
153
-        glsr(Console::class)->clear();
154
-        glsr(Notice::class)->addSuccess(__('Console cleared.', 'site-reviews'));
155
-    }
148
+	/**
149
+	 * @return void
150
+	 */
151
+	public function routerClearConsole()
152
+	{
153
+		glsr(Console::class)->clear();
154
+		glsr(Notice::class)->addSuccess(__('Console cleared.', 'site-reviews'));
155
+	}
156 156
 
157
-    /**
158
-     * @return void
159
-     */
160
-    public function routerCountReviews()
161
-    {
162
-        glsr(CountsManager::class)->updateAll();
163
-        glsr(Notice::class)->clear()->addSuccess(__('Recalculated rating counts.', 'site-reviews'));
164
-    }
157
+	/**
158
+	 * @return void
159
+	 */
160
+	public function routerCountReviews()
161
+	{
162
+		glsr(CountsManager::class)->updateAll();
163
+		glsr(Notice::class)->clear()->addSuccess(__('Recalculated rating counts.', 'site-reviews'));
164
+	}
165 165
 
166
-    /**
167
-     * @return void
168
-     */
169
-    public function routerDownloadConsole()
170
-    {
171
-        $this->download(Application::ID.'-console.txt', glsr(Console::class)->get());
172
-    }
166
+	/**
167
+	 * @return void
168
+	 */
169
+	public function routerDownloadConsole()
170
+	{
171
+		$this->download(Application::ID.'-console.txt', glsr(Console::class)->get());
172
+	}
173 173
 
174
-    /**
175
-     * @return void
176
-     */
177
-    public function routerDownloadSystemInfo()
178
-    {
179
-        $this->download(Application::ID.'-system-info.txt', glsr(System::class)->get());
180
-    }
174
+	/**
175
+	 * @return void
176
+	 */
177
+	public function routerDownloadSystemInfo()
178
+	{
179
+		$this->download(Application::ID.'-system-info.txt', glsr(System::class)->get());
180
+	}
181 181
 
182
-    /**
183
-     * @return void
184
-     */
185
-    public function routerExportSettings()
186
-    {
187
-        $this->download(Application::ID.'-settings.json', glsr(OptionManager::class)->json());
188
-    }
182
+	/**
183
+	 * @return void
184
+	 */
185
+	public function routerExportSettings()
186
+	{
187
+		$this->download(Application::ID.'-settings.json', glsr(OptionManager::class)->json());
188
+	}
189 189
 
190
-    /**
191
-     * @return void
192
-     */
193
-    public function routerFetchConsole()
194
-    {
195
-        glsr(Notice::class)->addSuccess(__('Console reloaded.', 'site-reviews'));
196
-    }
190
+	/**
191
+	 * @return void
192
+	 */
193
+	public function routerFetchConsole()
194
+	{
195
+		glsr(Notice::class)->addSuccess(__('Console reloaded.', 'site-reviews'));
196
+	}
197 197
 
198
-    /**
199
-     * @return void
200
-     */
201
-    public function routerImportSettings()
202
-    {
203
-        $file = $_FILES['import-file'];
204
-        if (UPLOAD_ERR_OK !== $file['error']) {
205
-            return glsr(Notice::class)->addError($this->getUploadError($file['error']));
206
-        }
207
-        if ('application/json' !== $file['type'] || !Str::endsWith('.json', $file['name'])) {
208
-            return glsr(Notice::class)->addError(__('Please use a valid Site Reviews settings file.', 'site-reviews'));
209
-        }
210
-        $settings = json_decode(file_get_contents($file['tmp_name']), true);
211
-        if (empty($settings)) {
212
-            return glsr(Notice::class)->addWarning(__('There were no settings found to import.', 'site-reviews'));
213
-        }
214
-        glsr(OptionManager::class)->set(glsr(OptionManager::class)->normalize($settings));
215
-        glsr(Notice::class)->addSuccess(__('Settings imported.', 'site-reviews'));
216
-    }
198
+	/**
199
+	 * @return void
200
+	 */
201
+	public function routerImportSettings()
202
+	{
203
+		$file = $_FILES['import-file'];
204
+		if (UPLOAD_ERR_OK !== $file['error']) {
205
+			return glsr(Notice::class)->addError($this->getUploadError($file['error']));
206
+		}
207
+		if ('application/json' !== $file['type'] || !Str::endsWith('.json', $file['name'])) {
208
+			return glsr(Notice::class)->addError(__('Please use a valid Site Reviews settings file.', 'site-reviews'));
209
+		}
210
+		$settings = json_decode(file_get_contents($file['tmp_name']), true);
211
+		if (empty($settings)) {
212
+			return glsr(Notice::class)->addWarning(__('There were no settings found to import.', 'site-reviews'));
213
+		}
214
+		glsr(OptionManager::class)->set(glsr(OptionManager::class)->normalize($settings));
215
+		glsr(Notice::class)->addSuccess(__('Settings imported.', 'site-reviews'));
216
+	}
217 217
 
218
-    /**
219
-     * @return void
220
-     */
221
-    public function routerMigrateReviews()
222
-    {
223
-        glsr(Migrate::class)->runAll();
224
-        glsr(Notice::class)->clear()->addSuccess(__('The plugin has been migrated to the latest version.', 'site-reviews'));
225
-    }
218
+	/**
219
+	 * @return void
220
+	 */
221
+	public function routerMigrateReviews()
222
+	{
223
+		glsr(Migrate::class)->runAll();
224
+		glsr(Notice::class)->clear()->addSuccess(__('The plugin has been migrated to the latest version.', 'site-reviews'));
225
+	}
226 226
 
227
-    /**
228
-     * @return void
229
-     */
230
-    public function routerResetPermissions()
231
-    {
232
-        glsr(Role::class)->resetAll();
233
-        glsr(Notice::class)->clear()->addSuccess(__('The permissions have been reset.', 'site-reviews'));
234
-    }
227
+	/**
228
+	 * @return void
229
+	 */
230
+	public function routerResetPermissions()
231
+	{
232
+		glsr(Role::class)->resetAll();
233
+		glsr(Notice::class)->clear()->addSuccess(__('The permissions have been reset.', 'site-reviews'));
234
+	}
235 235
 
236
-    /**
237
-     * @return void
238
-     * @action admin_init
239
-     */
240
-    public function runMigrations()
241
-    {
242
-        if (glsr(Migrate::class)->isMigrationNeeded()) {
243
-            glsr(Migrate::class)->run();
244
-            glsr(CountsManager::class)->updateAll();
245
-        }
246
-    }
236
+	/**
237
+	 * @return void
238
+	 * @action admin_init
239
+	 */
240
+	public function runMigrations()
241
+	{
242
+		if (glsr(Migrate::class)->isMigrationNeeded()) {
243
+			glsr(Migrate::class)->run();
244
+			glsr(CountsManager::class)->updateAll();
245
+		}
246
+	}
247 247
 
248
-    /**
249
-     * @param int $errorCode
250
-     * @return string
251
-     */
252
-    protected function getUploadError($errorCode)
253
-    {
254
-        $errors = [
255
-            UPLOAD_ERR_INI_SIZE => __('The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews'),
256
-            UPLOAD_ERR_FORM_SIZE => __('The uploaded file is too big.', 'site-reviews'),
257
-            UPLOAD_ERR_PARTIAL => __('The uploaded file was only partially uploaded.', 'site-reviews'),
258
-            UPLOAD_ERR_NO_FILE => __('No file was uploaded.', 'site-reviews'),
259
-            UPLOAD_ERR_NO_TMP_DIR => __('Missing a temporary folder.', 'site-reviews'),
260
-            UPLOAD_ERR_CANT_WRITE => __('Failed to write file to disk.', 'site-reviews'),
261
-            UPLOAD_ERR_EXTENSION => __('A PHP extension stopped the file upload.', 'site-reviews'),
262
-        ];
263
-        return Arr::get($errors, $errorCode, __('Unknown upload error.', 'site-reviews'));
264
-    }
248
+	/**
249
+	 * @param int $errorCode
250
+	 * @return string
251
+	 */
252
+	protected function getUploadError($errorCode)
253
+	{
254
+		$errors = [
255
+			UPLOAD_ERR_INI_SIZE => __('The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews'),
256
+			UPLOAD_ERR_FORM_SIZE => __('The uploaded file is too big.', 'site-reviews'),
257
+			UPLOAD_ERR_PARTIAL => __('The uploaded file was only partially uploaded.', 'site-reviews'),
258
+			UPLOAD_ERR_NO_FILE => __('No file was uploaded.', 'site-reviews'),
259
+			UPLOAD_ERR_NO_TMP_DIR => __('Missing a temporary folder.', 'site-reviews'),
260
+			UPLOAD_ERR_CANT_WRITE => __('Failed to write file to disk.', 'site-reviews'),
261
+			UPLOAD_ERR_EXTENSION => __('A PHP extension stopped the file upload.', 'site-reviews'),
262
+		];
263
+		return Arr::get($errors, $errorCode, __('Unknown upload error.', 'site-reviews'));
264
+	}
265 265
 }
Please login to merge, or discard this patch.
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
      */
25 25
     public function enqueueAssets()
26 26
     {
27
-        $command = new EnqueueAdminAssets([
27
+        $command = new EnqueueAdminAssets( [
28 28
             'pointers' => [[
29
-                'content' => __('You can pin exceptional reviews so that they are always shown first.', 'site-reviews'),
29
+                'content' => __( 'You can pin exceptional reviews so that they are always shown first.', 'site-reviews' ),
30 30
                 'id' => 'glsr-pointer-pinned',
31 31
                 'position' => [
32 32
                     'edge' => 'right',
@@ -34,24 +34,24 @@  discard block
 block discarded – undo
34 34
                 ],
35 35
                 'screen' => Application::POST_TYPE,
36 36
                 'target' => '#misc-pub-pinned',
37
-                'title' => __('Pin Your Reviews', 'site-reviews'),
37
+                'title' => __( 'Pin Your Reviews', 'site-reviews' ),
38 38
             ]],
39
-        ]);
40
-        $this->execute($command);
39
+        ] );
40
+        $this->execute( $command );
41 41
     }
42 42
 
43 43
     /**
44 44
      * @return array
45 45
      * @filter plugin_action_links_site-reviews/site-reviews.php
46 46
      */
47
-    public function filterActionLinks(array $links)
47
+    public function filterActionLinks( array $links )
48 48
     {
49
-        $links['documentation'] = glsr(Builder::class)->a(__('Help', 'site-reviews'), [
50
-            'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=documentation'),
51
-        ]);
52
-        $links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [
53
-            'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=settings'),
54
-        ]);
49
+        $links['documentation'] = glsr( Builder::class )->a( __( 'Help', 'site-reviews' ), [
50
+            'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=documentation' ),
51
+        ] );
52
+        $links['settings'] = glsr( Builder::class )->a( __( 'Settings', 'site-reviews' ), [
53
+            'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=settings' ),
54
+        ] );
55 55
         return $links;
56 56
     }
57 57
 
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
      * @return array
62 62
      * @filter map_meta_cap
63 63
      */
64
-    public function filterCreateCapability($capabilities, $capability)
64
+    public function filterCreateCapability( $capabilities, $capability )
65 65
     {
66
-        if ($capability == 'create_'.Application::POST_TYPE) {
66
+        if( $capability == 'create_'.Application::POST_TYPE ) {
67 67
             $capabilities[] = 'do_not_allow';
68 68
         }
69 69
         return $capabilities;
@@ -74,23 +74,23 @@  discard block
 block discarded – undo
74 74
      * @return array
75 75
      * @filter dashboard_glance_items
76 76
      */
77
-    public function filterDashboardGlanceItems($items)
77
+    public function filterDashboardGlanceItems( $items )
78 78
     {
79
-        $postCount = wp_count_posts(Application::POST_TYPE);
80
-        if (empty($postCount->publish)) {
79
+        $postCount = wp_count_posts( Application::POST_TYPE );
80
+        if( empty($postCount->publish) ) {
81 81
             return $items;
82 82
         }
83
-        $text = _n('%s Review', '%s Reviews', $postCount->publish, 'site-reviews');
84
-        $text = sprintf($text, number_format_i18n($postCount->publish));
85
-        $items = Arr::consolidateArray($items);
86
-        $items[] = glsr()->can('edit_posts')
87
-            ? glsr(Builder::class)->a($text, [
83
+        $text = _n( '%s Review', '%s Reviews', $postCount->publish, 'site-reviews' );
84
+        $text = sprintf( $text, number_format_i18n( $postCount->publish ) );
85
+        $items = Arr::consolidateArray( $items );
86
+        $items[] = glsr()->can( 'edit_posts' )
87
+            ? glsr( Builder::class )->a( $text, [
88 88
                 'class' => 'glsr-review-count',
89 89
                 'href' => 'edit.php?post_type='.Application::POST_TYPE,
90
-            ])
91
-            : glsr(Builder::class)->span($text, [
90
+            ] )
91
+            : glsr( Builder::class )->span( $text, [
92 92
                 'class' => 'glsr-review-count',
93
-            ]);
93
+            ] );
94 94
         return $items;
95 95
     }
96 96
 
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
      * @return array
100 100
      * @filter mce_external_plugins
101 101
      */
102
-    public function filterTinymcePlugins($plugins)
102
+    public function filterTinymcePlugins( $plugins )
103 103
     {
104
-        if (glsr()->can('edit_posts')) {
105
-            $plugins = Arr::consolidateArray($plugins);
106
-            $plugins['glsr_shortcode'] = glsr()->url('assets/scripts/mce-plugin.js');
104
+        if( glsr()->can( 'edit_posts' ) ) {
105
+            $plugins = Arr::consolidateArray( $plugins );
106
+            $plugins['glsr_shortcode'] = glsr()->url( 'assets/scripts/mce-plugin.js' );
107 107
         }
108 108
         return $plugins;
109 109
     }
@@ -114,12 +114,12 @@  discard block
 block discarded – undo
114 114
      */
115 115
     public function registerTinymcePopups()
116 116
     {
117
-        $command = new RegisterTinymcePopups([
118
-            'site_reviews' => esc_html__('Recent Reviews', 'site-reviews'),
119
-            'site_reviews_form' => esc_html__('Submit a Review', 'site-reviews'),
120
-            'site_reviews_summary' => esc_html__('Summary of Reviews', 'site-reviews'),
121
-        ]);
122
-        $this->execute($command);
117
+        $command = new RegisterTinymcePopups( [
118
+            'site_reviews' => esc_html__( 'Recent Reviews', 'site-reviews' ),
119
+            'site_reviews_form' => esc_html__( 'Submit a Review', 'site-reviews' ),
120
+            'site_reviews_summary' => esc_html__( 'Summary of Reviews', 'site-reviews' ),
121
+        ] );
122
+        $this->execute( $command );
123 123
     }
124 124
 
125 125
     /**
@@ -127,22 +127,22 @@  discard block
 block discarded – undo
127 127
      * @return void|null
128 128
      * @action media_buttons
129 129
      */
130
-    public function renderTinymceButton($editorId)
130
+    public function renderTinymceButton( $editorId )
131 131
     {
132
-        $allowedEditors = apply_filters('site-reviews/tinymce/editor-ids', ['content'], $editorId);
133
-        if ('post' != glsr_current_screen()->base || !in_array($editorId, $allowedEditors)) {
132
+        $allowedEditors = apply_filters( 'site-reviews/tinymce/editor-ids', ['content'], $editorId );
133
+        if( 'post' != glsr_current_screen()->base || !in_array( $editorId, $allowedEditors ) ) {
134 134
             return;
135 135
         }
136 136
         $shortcodes = [];
137
-        foreach (glsr()->mceShortcodes as $shortcode => $values) {
137
+        foreach( glsr()->mceShortcodes as $shortcode => $values ) {
138 138
             $shortcodes[$shortcode] = $values;
139 139
         }
140
-        if (empty($shortcodes)) {
140
+        if( empty($shortcodes) ) {
141 141
             return;
142 142
         }
143
-        glsr()->render('partials/editor/tinymce', [
143
+        glsr()->render( 'partials/editor/tinymce', [
144 144
             'shortcodes' => $shortcodes,
145
-        ]);
145
+        ] );
146 146
     }
147 147
 
148 148
     /**
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
      */
151 151
     public function routerClearConsole()
152 152
     {
153
-        glsr(Console::class)->clear();
154
-        glsr(Notice::class)->addSuccess(__('Console cleared.', 'site-reviews'));
153
+        glsr( Console::class )->clear();
154
+        glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ) );
155 155
     }
156 156
 
157 157
     /**
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
      */
160 160
     public function routerCountReviews()
161 161
     {
162
-        glsr(CountsManager::class)->updateAll();
163
-        glsr(Notice::class)->clear()->addSuccess(__('Recalculated rating counts.', 'site-reviews'));
162
+        glsr( CountsManager::class )->updateAll();
163
+        glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' ) );
164 164
     }
165 165
 
166 166
     /**
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
      */
169 169
     public function routerDownloadConsole()
170 170
     {
171
-        $this->download(Application::ID.'-console.txt', glsr(Console::class)->get());
171
+        $this->download( Application::ID.'-console.txt', glsr( Console::class )->get() );
172 172
     }
173 173
 
174 174
     /**
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
      */
177 177
     public function routerDownloadSystemInfo()
178 178
     {
179
-        $this->download(Application::ID.'-system-info.txt', glsr(System::class)->get());
179
+        $this->download( Application::ID.'-system-info.txt', glsr( System::class )->get() );
180 180
     }
181 181
 
182 182
     /**
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
      */
185 185
     public function routerExportSettings()
186 186
     {
187
-        $this->download(Application::ID.'-settings.json', glsr(OptionManager::class)->json());
187
+        $this->download( Application::ID.'-settings.json', glsr( OptionManager::class )->json() );
188 188
     }
189 189
 
190 190
     /**
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
      */
193 193
     public function routerFetchConsole()
194 194
     {
195
-        glsr(Notice::class)->addSuccess(__('Console reloaded.', 'site-reviews'));
195
+        glsr( Notice::class )->addSuccess( __( 'Console reloaded.', 'site-reviews' ) );
196 196
     }
197 197
 
198 198
     /**
@@ -201,18 +201,18 @@  discard block
 block discarded – undo
201 201
     public function routerImportSettings()
202 202
     {
203 203
         $file = $_FILES['import-file'];
204
-        if (UPLOAD_ERR_OK !== $file['error']) {
205
-            return glsr(Notice::class)->addError($this->getUploadError($file['error']));
204
+        if( UPLOAD_ERR_OK !== $file['error'] ) {
205
+            return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ) );
206 206
         }
207
-        if ('application/json' !== $file['type'] || !Str::endsWith('.json', $file['name'])) {
208
-            return glsr(Notice::class)->addError(__('Please use a valid Site Reviews settings file.', 'site-reviews'));
207
+        if( 'application/json' !== $file['type'] || !Str::endsWith( '.json', $file['name'] ) ) {
208
+            return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ) );
209 209
         }
210
-        $settings = json_decode(file_get_contents($file['tmp_name']), true);
211
-        if (empty($settings)) {
212
-            return glsr(Notice::class)->addWarning(__('There were no settings found to import.', 'site-reviews'));
210
+        $settings = json_decode( file_get_contents( $file['tmp_name'] ), true );
211
+        if( empty($settings) ) {
212
+            return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ) );
213 213
         }
214
-        glsr(OptionManager::class)->set(glsr(OptionManager::class)->normalize($settings));
215
-        glsr(Notice::class)->addSuccess(__('Settings imported.', 'site-reviews'));
214
+        glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ) );
215
+        glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ) );
216 216
     }
217 217
 
218 218
     /**
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
      */
221 221
     public function routerMigrateReviews()
222 222
     {
223
-        glsr(Migrate::class)->runAll();
224
-        glsr(Notice::class)->clear()->addSuccess(__('The plugin has been migrated to the latest version.', 'site-reviews'));
223
+        glsr( Migrate::class )->runAll();
224
+        glsr( Notice::class )->clear()->addSuccess( __( 'The plugin has been migrated to the latest version.', 'site-reviews' ) );
225 225
     }
226 226
 
227 227
     /**
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
      */
230 230
     public function routerResetPermissions()
231 231
     {
232
-        glsr(Role::class)->resetAll();
233
-        glsr(Notice::class)->clear()->addSuccess(__('The permissions have been reset.', 'site-reviews'));
232
+        glsr( Role::class )->resetAll();
233
+        glsr( Notice::class )->clear()->addSuccess( __( 'The permissions have been reset.', 'site-reviews' ) );
234 234
     }
235 235
 
236 236
     /**
@@ -239,9 +239,9 @@  discard block
 block discarded – undo
239 239
      */
240 240
     public function runMigrations()
241 241
     {
242
-        if (glsr(Migrate::class)->isMigrationNeeded()) {
243
-            glsr(Migrate::class)->run();
244
-            glsr(CountsManager::class)->updateAll();
242
+        if( glsr( Migrate::class )->isMigrationNeeded() ) {
243
+            glsr( Migrate::class )->run();
244
+            glsr( CountsManager::class )->updateAll();
245 245
         }
246 246
     }
247 247
 
@@ -249,17 +249,17 @@  discard block
 block discarded – undo
249 249
      * @param int $errorCode
250 250
      * @return string
251 251
      */
252
-    protected function getUploadError($errorCode)
252
+    protected function getUploadError( $errorCode )
253 253
     {
254 254
         $errors = [
255
-            UPLOAD_ERR_INI_SIZE => __('The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews'),
256
-            UPLOAD_ERR_FORM_SIZE => __('The uploaded file is too big.', 'site-reviews'),
257
-            UPLOAD_ERR_PARTIAL => __('The uploaded file was only partially uploaded.', 'site-reviews'),
258
-            UPLOAD_ERR_NO_FILE => __('No file was uploaded.', 'site-reviews'),
259
-            UPLOAD_ERR_NO_TMP_DIR => __('Missing a temporary folder.', 'site-reviews'),
260
-            UPLOAD_ERR_CANT_WRITE => __('Failed to write file to disk.', 'site-reviews'),
261
-            UPLOAD_ERR_EXTENSION => __('A PHP extension stopped the file upload.', 'site-reviews'),
255
+            UPLOAD_ERR_INI_SIZE => __( 'The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews' ),
256
+            UPLOAD_ERR_FORM_SIZE => __( 'The uploaded file is too big.', 'site-reviews' ),
257
+            UPLOAD_ERR_PARTIAL => __( 'The uploaded file was only partially uploaded.', 'site-reviews' ),
258
+            UPLOAD_ERR_NO_FILE => __( 'No file was uploaded.', 'site-reviews' ),
259
+            UPLOAD_ERR_NO_TMP_DIR => __( 'Missing a temporary folder.', 'site-reviews' ),
260
+            UPLOAD_ERR_CANT_WRITE => __( 'Failed to write file to disk.', 'site-reviews' ),
261
+            UPLOAD_ERR_EXTENSION => __( 'A PHP extension stopped the file upload.', 'site-reviews' ),
262 262
         ];
263
-        return Arr::get($errors, $errorCode, __('Unknown upload error.', 'site-reviews'));
263
+        return Arr::get( $errors, $errorCode, __( 'Unknown upload error.', 'site-reviews' ) );
264 264
     }
265 265
 }
Please login to merge, or discard this patch.
plugin/Controllers/AjaxController.php 2 patches
Indentation   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -15,192 +15,192 @@
 block discarded – undo
15 15
 
16 16
 class AjaxController extends Controller
17 17
 {
18
-    /**
19
-     * @return void
20
-     */
21
-    public function routerChangeStatus(array $request)
22
-    {
23
-        wp_send_json_success($this->execute(new ChangeStatus($request)));
24
-    }
18
+	/**
19
+	 * @return void
20
+	 */
21
+	public function routerChangeStatus(array $request)
22
+	{
23
+		wp_send_json_success($this->execute(new ChangeStatus($request)));
24
+	}
25 25
 
26
-    /**
27
-     * @return void
28
-     */
29
-    public function routerClearConsole()
30
-    {
31
-        glsr(AdminController::class)->routerClearConsole();
32
-        wp_send_json_success([
33
-            'console' => glsr(Console::class)->get(),
34
-            'notices' => glsr(Notice::class)->get(),
35
-        ]);
36
-    }
26
+	/**
27
+	 * @return void
28
+	 */
29
+	public function routerClearConsole()
30
+	{
31
+		glsr(AdminController::class)->routerClearConsole();
32
+		wp_send_json_success([
33
+			'console' => glsr(Console::class)->get(),
34
+			'notices' => glsr(Notice::class)->get(),
35
+		]);
36
+	}
37 37
 
38
-    /**
39
-     * @return void
40
-     */
41
-    public function routerCountReviews()
42
-    {
43
-        glsr(AdminController::class)->routerCountReviews();
44
-        wp_send_json_success([
45
-            'notices' => glsr(Notice::class)->get(),
46
-        ]);
47
-    }
38
+	/**
39
+	 * @return void
40
+	 */
41
+	public function routerCountReviews()
42
+	{
43
+		glsr(AdminController::class)->routerCountReviews();
44
+		wp_send_json_success([
45
+			'notices' => glsr(Notice::class)->get(),
46
+		]);
47
+	}
48 48
 
49
-    /**
50
-     * @return void
51
-     */
52
-    public function routerMigrateReviews()
53
-    {
54
-        glsr(AdminController::class)->routerMigrateReviews();
55
-        wp_send_json_success([
56
-            'notices' => glsr(Notice::class)->get(),
57
-        ]);
58
-    }
49
+	/**
50
+	 * @return void
51
+	 */
52
+	public function routerMigrateReviews()
53
+	{
54
+		glsr(AdminController::class)->routerMigrateReviews();
55
+		wp_send_json_success([
56
+			'notices' => glsr(Notice::class)->get(),
57
+		]);
58
+	}
59 59
 
60
-    /**
61
-     * @return void
62
-     */
63
-    public function routerDismissNotice(array $request)
64
-    {
65
-        glsr(NoticeController::class)->routerDismissNotice($request);
66
-        wp_send_json_success();
67
-    }
60
+	/**
61
+	 * @return void
62
+	 */
63
+	public function routerDismissNotice(array $request)
64
+	{
65
+		glsr(NoticeController::class)->routerDismissNotice($request);
66
+		wp_send_json_success();
67
+	}
68 68
 
69
-    /**
70
-     * @return void
71
-     */
72
-    public function routerMceShortcode(array $request)
73
-    {
74
-        $shortcode = $request['shortcode'];
75
-        $response = false;
76
-        if (array_key_exists($shortcode, glsr()->mceShortcodes)) {
77
-            $data = glsr()->mceShortcodes[$shortcode];
78
-            if (!empty($data['errors'])) {
79
-                $data['btn_okay'] = [esc_html__('Okay', 'site-reviews')];
80
-            }
81
-            $response = [
82
-                'body' => $data['fields'],
83
-                'close' => $data['btn_close'],
84
-                'ok' => $data['btn_okay'],
85
-                'shortcode' => $shortcode,
86
-                'title' => $data['title'],
87
-            ];
88
-        }
89
-        wp_send_json_success($response);
90
-    }
69
+	/**
70
+	 * @return void
71
+	 */
72
+	public function routerMceShortcode(array $request)
73
+	{
74
+		$shortcode = $request['shortcode'];
75
+		$response = false;
76
+		if (array_key_exists($shortcode, glsr()->mceShortcodes)) {
77
+			$data = glsr()->mceShortcodes[$shortcode];
78
+			if (!empty($data['errors'])) {
79
+				$data['btn_okay'] = [esc_html__('Okay', 'site-reviews')];
80
+			}
81
+			$response = [
82
+				'body' => $data['fields'],
83
+				'close' => $data['btn_close'],
84
+				'ok' => $data['btn_okay'],
85
+				'shortcode' => $shortcode,
86
+				'title' => $data['title'],
87
+			];
88
+		}
89
+		wp_send_json_success($response);
90
+	}
91 91
 
92
-    /**
93
-     * @return void
94
-     */
95
-    public function routerFetchConsole()
96
-    {
97
-        glsr(AdminController::class)->routerFetchConsole();
98
-        wp_send_json_success([
99
-            'console' => glsr(Console::class)->get(),
100
-            'notices' => glsr(Notice::class)->get(),
101
-        ]);
102
-    }
92
+	/**
93
+	 * @return void
94
+	 */
95
+	public function routerFetchConsole()
96
+	{
97
+		glsr(AdminController::class)->routerFetchConsole();
98
+		wp_send_json_success([
99
+			'console' => glsr(Console::class)->get(),
100
+			'notices' => glsr(Notice::class)->get(),
101
+		]);
102
+	}
103 103
 
104
-    /**
105
-     * @return void
106
-     */
107
-    public function routerResetPermissions()
108
-    {
109
-        glsr(Role::class)->resetAll();
110
-        glsr(Notice::class)->clear()->addSuccess(__('The permissions have been reset, please reload the page for them to take effect.', 'site-reviews'));
111
-        wp_send_json_success([
112
-            'notices' => glsr(Notice::class)->get(),
113
-        ]);
114
-    }
104
+	/**
105
+	 * @return void
106
+	 */
107
+	public function routerResetPermissions()
108
+	{
109
+		glsr(Role::class)->resetAll();
110
+		glsr(Notice::class)->clear()->addSuccess(__('The permissions have been reset, please reload the page for them to take effect.', 'site-reviews'));
111
+		wp_send_json_success([
112
+			'notices' => glsr(Notice::class)->get(),
113
+		]);
114
+	}
115 115
 
116
-    /**
117
-     * @return void
118
-     */
119
-    public function routerSearchPosts(array $request)
120
-    {
121
-        $results = glsr(Database::class)->searchPosts($request['search']);
122
-        wp_send_json_success([
123
-            'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>',
124
-            'items' => $results,
125
-        ]);
126
-    }
116
+	/**
117
+	 * @return void
118
+	 */
119
+	public function routerSearchPosts(array $request)
120
+	{
121
+		$results = glsr(Database::class)->searchPosts($request['search']);
122
+		wp_send_json_success([
123
+			'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>',
124
+			'items' => $results,
125
+		]);
126
+	}
127 127
 
128
-    /**
129
-     * @return void
130
-     */
131
-    public function routerSearchTranslations(array $request)
132
-    {
133
-        if (empty($request['exclude'])) {
134
-            $request['exclude'] = [];
135
-        }
136
-        $results = glsr(Translation::class)
137
-            ->search($request['search'])
138
-            ->exclude()
139
-            ->exclude($request['exclude'])
140
-            ->renderResults();
141
-        wp_send_json_success([
142
-            'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>',
143
-            'items' => $results,
144
-        ]);
145
-    }
128
+	/**
129
+	 * @return void
130
+	 */
131
+	public function routerSearchTranslations(array $request)
132
+	{
133
+		if (empty($request['exclude'])) {
134
+			$request['exclude'] = [];
135
+		}
136
+		$results = glsr(Translation::class)
137
+			->search($request['search'])
138
+			->exclude()
139
+			->exclude($request['exclude'])
140
+			->renderResults();
141
+		wp_send_json_success([
142
+			'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>',
143
+			'items' => $results,
144
+		]);
145
+	}
146 146
 
147
-    /**
148
-     * @return void
149
-     */
150
-    public function routerSubmitReview(array $request)
151
-    {
152
-        $command = glsr(PublicController::class)->routerSubmitReview($request);
153
-        $redirect = trim(strval(get_post_meta($command->post_id, 'redirect_to', true)));
154
-        $redirect = apply_filters('site-reviews/review/redirect', $redirect, $command);
155
-        $data = [
156
-            'errors' => glsr()->sessionGet($command->form_id.'errors', false),
157
-            'message' => glsr()->sessionGet($command->form_id.'message', ''),
158
-            'recaptcha' => glsr()->sessionGet($command->form_id.'recaptcha', false),
159
-            'redirect' => $redirect,
160
-        ];
161
-        if (false === $data['errors']) {
162
-            glsr()->sessionClear();
163
-            wp_send_json_success($data);
164
-        }
165
-        wp_send_json_error($data);
166
-    }
147
+	/**
148
+	 * @return void
149
+	 */
150
+	public function routerSubmitReview(array $request)
151
+	{
152
+		$command = glsr(PublicController::class)->routerSubmitReview($request);
153
+		$redirect = trim(strval(get_post_meta($command->post_id, 'redirect_to', true)));
154
+		$redirect = apply_filters('site-reviews/review/redirect', $redirect, $command);
155
+		$data = [
156
+			'errors' => glsr()->sessionGet($command->form_id.'errors', false),
157
+			'message' => glsr()->sessionGet($command->form_id.'message', ''),
158
+			'recaptcha' => glsr()->sessionGet($command->form_id.'recaptcha', false),
159
+			'redirect' => $redirect,
160
+		];
161
+		if (false === $data['errors']) {
162
+			glsr()->sessionClear();
163
+			wp_send_json_success($data);
164
+		}
165
+		wp_send_json_error($data);
166
+	}
167 167
 
168
-    /**
169
-     * @return void
170
-     */
171
-    public function routerFetchPagedReviews(array $request)
172
-    {
173
-        $homePath = untrailingslashit(parse_url(home_url(), PHP_URL_PATH));
174
-        $urlPath = untrailingslashit(parse_url(Arr::get($request, 'url'), PHP_URL_PATH));
175
-        $urlQuery = [];
176
-        parse_str(parse_url(Arr::get($request, 'url'), PHP_URL_QUERY), $urlQuery);
177
-        $pagedUrl = $homePath === $urlPath
178
-            ? home_url()
179
-            : home_url($urlPath);
180
-        $args = [
181
-            'paged' => (int) Arr::get($urlQuery, glsr()->constant('PAGED_QUERY_VAR'), 1),
182
-            'pagedUrl' => trailingslashit($pagedUrl),
183
-            'pagination' => 'ajax',
184
-            'schema' => false,
185
-        ];
186
-        $atts = (array) json_decode(Arr::get($request, 'atts'));
187
-        $atts = glsr(SiteReviewsShortcode::class)->normalizeAtts($atts);
188
-        $html = glsr(SiteReviewsPartial::class)->build(wp_parse_args($args, $atts));
189
-        return wp_send_json_success([
190
-            'pagination' => $html->getPagination(),
191
-            'reviews' => $html->getReviews(),
192
-        ]);
193
-    }
168
+	/**
169
+	 * @return void
170
+	 */
171
+	public function routerFetchPagedReviews(array $request)
172
+	{
173
+		$homePath = untrailingslashit(parse_url(home_url(), PHP_URL_PATH));
174
+		$urlPath = untrailingslashit(parse_url(Arr::get($request, 'url'), PHP_URL_PATH));
175
+		$urlQuery = [];
176
+		parse_str(parse_url(Arr::get($request, 'url'), PHP_URL_QUERY), $urlQuery);
177
+		$pagedUrl = $homePath === $urlPath
178
+			? home_url()
179
+			: home_url($urlPath);
180
+		$args = [
181
+			'paged' => (int) Arr::get($urlQuery, glsr()->constant('PAGED_QUERY_VAR'), 1),
182
+			'pagedUrl' => trailingslashit($pagedUrl),
183
+			'pagination' => 'ajax',
184
+			'schema' => false,
185
+		];
186
+		$atts = (array) json_decode(Arr::get($request, 'atts'));
187
+		$atts = glsr(SiteReviewsShortcode::class)->normalizeAtts($atts);
188
+		$html = glsr(SiteReviewsPartial::class)->build(wp_parse_args($args, $atts));
189
+		return wp_send_json_success([
190
+			'pagination' => $html->getPagination(),
191
+			'reviews' => $html->getReviews(),
192
+		]);
193
+	}
194 194
 
195
-    /**
196
-     * @return void
197
-     */
198
-    public function routerTogglePinned(array $request)
199
-    {
200
-        $isPinned = $this->execute(new TogglePinned($request));
201
-        wp_send_json_success([
202
-            'notices' => glsr(Notice::class)->get(),
203
-            'pinned' => $isPinned,
204
-        ]);
205
-    }
195
+	/**
196
+	 * @return void
197
+	 */
198
+	public function routerTogglePinned(array $request)
199
+	{
200
+		$isPinned = $this->execute(new TogglePinned($request));
201
+		wp_send_json_success([
202
+			'notices' => glsr(Notice::class)->get(),
203
+			'pinned' => $isPinned,
204
+		]);
205
+	}
206 206
 }
Please login to merge, or discard this patch.
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -18,9 +18,9 @@  discard block
 block discarded – undo
18 18
     /**
19 19
      * @return void
20 20
      */
21
-    public function routerChangeStatus(array $request)
21
+    public function routerChangeStatus( array $request )
22 22
     {
23
-        wp_send_json_success($this->execute(new ChangeStatus($request)));
23
+        wp_send_json_success( $this->execute( new ChangeStatus( $request ) ) );
24 24
     }
25 25
 
26 26
     /**
@@ -28,11 +28,11 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public function routerClearConsole()
30 30
     {
31
-        glsr(AdminController::class)->routerClearConsole();
32
-        wp_send_json_success([
33
-            'console' => glsr(Console::class)->get(),
34
-            'notices' => glsr(Notice::class)->get(),
35
-        ]);
31
+        glsr( AdminController::class )->routerClearConsole();
32
+        wp_send_json_success( [
33
+            'console' => glsr( Console::class )->get(),
34
+            'notices' => glsr( Notice::class )->get(),
35
+        ] );
36 36
     }
37 37
 
38 38
     /**
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public function routerCountReviews()
42 42
     {
43
-        glsr(AdminController::class)->routerCountReviews();
44
-        wp_send_json_success([
45
-            'notices' => glsr(Notice::class)->get(),
46
-        ]);
43
+        glsr( AdminController::class )->routerCountReviews();
44
+        wp_send_json_success( [
45
+            'notices' => glsr( Notice::class )->get(),
46
+        ] );
47 47
     }
48 48
 
49 49
     /**
@@ -51,32 +51,32 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function routerMigrateReviews()
53 53
     {
54
-        glsr(AdminController::class)->routerMigrateReviews();
55
-        wp_send_json_success([
56
-            'notices' => glsr(Notice::class)->get(),
57
-        ]);
54
+        glsr( AdminController::class )->routerMigrateReviews();
55
+        wp_send_json_success( [
56
+            'notices' => glsr( Notice::class )->get(),
57
+        ] );
58 58
     }
59 59
 
60 60
     /**
61 61
      * @return void
62 62
      */
63
-    public function routerDismissNotice(array $request)
63
+    public function routerDismissNotice( array $request )
64 64
     {
65
-        glsr(NoticeController::class)->routerDismissNotice($request);
65
+        glsr( NoticeController::class )->routerDismissNotice( $request );
66 66
         wp_send_json_success();
67 67
     }
68 68
 
69 69
     /**
70 70
      * @return void
71 71
      */
72
-    public function routerMceShortcode(array $request)
72
+    public function routerMceShortcode( array $request )
73 73
     {
74 74
         $shortcode = $request['shortcode'];
75 75
         $response = false;
76
-        if (array_key_exists($shortcode, glsr()->mceShortcodes)) {
76
+        if( array_key_exists( $shortcode, glsr()->mceShortcodes ) ) {
77 77
             $data = glsr()->mceShortcodes[$shortcode];
78
-            if (!empty($data['errors'])) {
79
-                $data['btn_okay'] = [esc_html__('Okay', 'site-reviews')];
78
+            if( !empty($data['errors']) ) {
79
+                $data['btn_okay'] = [esc_html__( 'Okay', 'site-reviews' )];
80 80
             }
81 81
             $response = [
82 82
                 'body' => $data['fields'],
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
                 'title' => $data['title'],
87 87
             ];
88 88
         }
89
-        wp_send_json_success($response);
89
+        wp_send_json_success( $response );
90 90
     }
91 91
 
92 92
     /**
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
      */
95 95
     public function routerFetchConsole()
96 96
     {
97
-        glsr(AdminController::class)->routerFetchConsole();
98
-        wp_send_json_success([
99
-            'console' => glsr(Console::class)->get(),
100
-            'notices' => glsr(Notice::class)->get(),
101
-        ]);
97
+        glsr( AdminController::class )->routerFetchConsole();
98
+        wp_send_json_success( [
99
+            'console' => glsr( Console::class )->get(),
100
+            'notices' => glsr( Notice::class )->get(),
101
+        ] );
102 102
     }
103 103
 
104 104
     /**
@@ -106,101 +106,101 @@  discard block
 block discarded – undo
106 106
      */
107 107
     public function routerResetPermissions()
108 108
     {
109
-        glsr(Role::class)->resetAll();
110
-        glsr(Notice::class)->clear()->addSuccess(__('The permissions have been reset, please reload the page for them to take effect.', 'site-reviews'));
111
-        wp_send_json_success([
112
-            'notices' => glsr(Notice::class)->get(),
113
-        ]);
109
+        glsr( Role::class )->resetAll();
110
+        glsr( Notice::class )->clear()->addSuccess( __( 'The permissions have been reset, please reload the page for them to take effect.', 'site-reviews' ) );
111
+        wp_send_json_success( [
112
+            'notices' => glsr( Notice::class )->get(),
113
+        ] );
114 114
     }
115 115
 
116 116
     /**
117 117
      * @return void
118 118
      */
119
-    public function routerSearchPosts(array $request)
119
+    public function routerSearchPosts( array $request )
120 120
     {
121
-        $results = glsr(Database::class)->searchPosts($request['search']);
122
-        wp_send_json_success([
123
-            'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>',
121
+        $results = glsr( Database::class )->searchPosts( $request['search'] );
122
+        wp_send_json_success( [
123
+            'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>',
124 124
             'items' => $results,
125
-        ]);
125
+        ] );
126 126
     }
127 127
 
128 128
     /**
129 129
      * @return void
130 130
      */
131
-    public function routerSearchTranslations(array $request)
131
+    public function routerSearchTranslations( array $request )
132 132
     {
133
-        if (empty($request['exclude'])) {
133
+        if( empty($request['exclude']) ) {
134 134
             $request['exclude'] = [];
135 135
         }
136
-        $results = glsr(Translation::class)
137
-            ->search($request['search'])
136
+        $results = glsr( Translation::class )
137
+            ->search( $request['search'] )
138 138
             ->exclude()
139
-            ->exclude($request['exclude'])
139
+            ->exclude( $request['exclude'] )
140 140
             ->renderResults();
141
-        wp_send_json_success([
142
-            'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>',
141
+        wp_send_json_success( [
142
+            'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>',
143 143
             'items' => $results,
144
-        ]);
144
+        ] );
145 145
     }
146 146
 
147 147
     /**
148 148
      * @return void
149 149
      */
150
-    public function routerSubmitReview(array $request)
150
+    public function routerSubmitReview( array $request )
151 151
     {
152
-        $command = glsr(PublicController::class)->routerSubmitReview($request);
153
-        $redirect = trim(strval(get_post_meta($command->post_id, 'redirect_to', true)));
154
-        $redirect = apply_filters('site-reviews/review/redirect', $redirect, $command);
152
+        $command = glsr( PublicController::class )->routerSubmitReview( $request );
153
+        $redirect = trim( strval( get_post_meta( $command->post_id, 'redirect_to', true ) ) );
154
+        $redirect = apply_filters( 'site-reviews/review/redirect', $redirect, $command );
155 155
         $data = [
156
-            'errors' => glsr()->sessionGet($command->form_id.'errors', false),
157
-            'message' => glsr()->sessionGet($command->form_id.'message', ''),
158
-            'recaptcha' => glsr()->sessionGet($command->form_id.'recaptcha', false),
156
+            'errors' => glsr()->sessionGet( $command->form_id.'errors', false ),
157
+            'message' => glsr()->sessionGet( $command->form_id.'message', '' ),
158
+            'recaptcha' => glsr()->sessionGet( $command->form_id.'recaptcha', false ),
159 159
             'redirect' => $redirect,
160 160
         ];
161
-        if (false === $data['errors']) {
161
+        if( false === $data['errors'] ) {
162 162
             glsr()->sessionClear();
163
-            wp_send_json_success($data);
163
+            wp_send_json_success( $data );
164 164
         }
165
-        wp_send_json_error($data);
165
+        wp_send_json_error( $data );
166 166
     }
167 167
 
168 168
     /**
169 169
      * @return void
170 170
      */
171
-    public function routerFetchPagedReviews(array $request)
171
+    public function routerFetchPagedReviews( array $request )
172 172
     {
173
-        $homePath = untrailingslashit(parse_url(home_url(), PHP_URL_PATH));
174
-        $urlPath = untrailingslashit(parse_url(Arr::get($request, 'url'), PHP_URL_PATH));
173
+        $homePath = untrailingslashit( parse_url( home_url(), PHP_URL_PATH ) );
174
+        $urlPath = untrailingslashit( parse_url( Arr::get( $request, 'url' ), PHP_URL_PATH ) );
175 175
         $urlQuery = [];
176
-        parse_str(parse_url(Arr::get($request, 'url'), PHP_URL_QUERY), $urlQuery);
176
+        parse_str( parse_url( Arr::get( $request, 'url' ), PHP_URL_QUERY ), $urlQuery );
177 177
         $pagedUrl = $homePath === $urlPath
178 178
             ? home_url()
179
-            : home_url($urlPath);
179
+            : home_url( $urlPath );
180 180
         $args = [
181
-            'paged' => (int) Arr::get($urlQuery, glsr()->constant('PAGED_QUERY_VAR'), 1),
182
-            'pagedUrl' => trailingslashit($pagedUrl),
181
+            'paged' => (int)Arr::get( $urlQuery, glsr()->constant( 'PAGED_QUERY_VAR' ), 1 ),
182
+            'pagedUrl' => trailingslashit( $pagedUrl ),
183 183
             'pagination' => 'ajax',
184 184
             'schema' => false,
185 185
         ];
186
-        $atts = (array) json_decode(Arr::get($request, 'atts'));
187
-        $atts = glsr(SiteReviewsShortcode::class)->normalizeAtts($atts);
188
-        $html = glsr(SiteReviewsPartial::class)->build(wp_parse_args($args, $atts));
189
-        return wp_send_json_success([
186
+        $atts = (array)json_decode( Arr::get( $request, 'atts' ) );
187
+        $atts = glsr( SiteReviewsShortcode::class )->normalizeAtts( $atts );
188
+        $html = glsr( SiteReviewsPartial::class )->build( wp_parse_args( $args, $atts ) );
189
+        return wp_send_json_success( [
190 190
             'pagination' => $html->getPagination(),
191 191
             'reviews' => $html->getReviews(),
192
-        ]);
192
+        ] );
193 193
     }
194 194
 
195 195
     /**
196 196
      * @return void
197 197
      */
198
-    public function routerTogglePinned(array $request)
198
+    public function routerTogglePinned( array $request )
199 199
     {
200
-        $isPinned = $this->execute(new TogglePinned($request));
201
-        wp_send_json_success([
202
-            'notices' => glsr(Notice::class)->get(),
200
+        $isPinned = $this->execute( new TogglePinned( $request ) );
201
+        wp_send_json_success( [
202
+            'notices' => glsr( Notice::class )->get(),
203 203
             'pinned' => $isPinned,
204
-        ]);
204
+        ] );
205 205
     }
206 206
 }
Please login to merge, or discard this patch.
plugin/Controllers/MainController.php 2 patches
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -10,86 +10,86 @@
 block discarded – undo
10 10
 
11 11
 class MainController extends Controller
12 12
 {
13
-    /**
14
-     * @return void
15
-     * @action init
16
-     */
17
-    public function registerPostType()
18
-    {
19
-        if (!glsr()->hasPermission()) {
20
-            return;
21
-        }
22
-        $command = new RegisterPostType([
23
-            'capabilities' => ['create_posts' => 'create_'.Application::POST_TYPE],
24
-            'capability_type' => Application::POST_TYPE,
25
-            'columns' => [
26
-                'title' => '',
27
-                'category' => '',
28
-                'assigned_to' => __('Assigned To', 'site-reviews'),
29
-                'reviewer' => __('Author', 'site-reviews'),
30
-                'email' => __('Email', 'site-reviews'),
31
-                'ip_address' => __('IP Address', 'site-reviews'),
32
-                'response' => __('Response', 'site-reviews'),
33
-                'review_type' => __('Type', 'site-reviews'),
34
-                'rating' => __('Rating', 'site-reviews'),
35
-                'pinned' => __('Pinned', 'site-reviews'),
36
-                'date' => '',
37
-            ],
38
-            'menu_icon' => 'dashicons-star-half',
39
-            'menu_name' => glsr()->name,
40
-            'map_meta_cap' => true,
41
-            'plural' => __('Reviews', 'site-reviews'),
42
-            'post_type' => Application::POST_TYPE,
43
-            'rest_controller_class' => RestReviewController::class,
44
-            'show_in_rest' => true,
45
-            'single' => __('Review', 'site-reviews'),
46
-        ]);
47
-        $this->execute($command);
48
-    }
13
+	/**
14
+	 * @return void
15
+	 * @action init
16
+	 */
17
+	public function registerPostType()
18
+	{
19
+		if (!glsr()->hasPermission()) {
20
+			return;
21
+		}
22
+		$command = new RegisterPostType([
23
+			'capabilities' => ['create_posts' => 'create_'.Application::POST_TYPE],
24
+			'capability_type' => Application::POST_TYPE,
25
+			'columns' => [
26
+				'title' => '',
27
+				'category' => '',
28
+				'assigned_to' => __('Assigned To', 'site-reviews'),
29
+				'reviewer' => __('Author', 'site-reviews'),
30
+				'email' => __('Email', 'site-reviews'),
31
+				'ip_address' => __('IP Address', 'site-reviews'),
32
+				'response' => __('Response', 'site-reviews'),
33
+				'review_type' => __('Type', 'site-reviews'),
34
+				'rating' => __('Rating', 'site-reviews'),
35
+				'pinned' => __('Pinned', 'site-reviews'),
36
+				'date' => '',
37
+			],
38
+			'menu_icon' => 'dashicons-star-half',
39
+			'menu_name' => glsr()->name,
40
+			'map_meta_cap' => true,
41
+			'plural' => __('Reviews', 'site-reviews'),
42
+			'post_type' => Application::POST_TYPE,
43
+			'rest_controller_class' => RestReviewController::class,
44
+			'show_in_rest' => true,
45
+			'single' => __('Review', 'site-reviews'),
46
+		]);
47
+		$this->execute($command);
48
+	}
49 49
 
50
-    /**
51
-     * @return void
52
-     * @action init
53
-     */
54
-    public function registerShortcodes()
55
-    {
56
-        $command = new RegisterShortcodes([
57
-            'site_reviews',
58
-            'site_reviews_form',
59
-            'site_reviews_summary',
60
-        ]);
61
-        $this->execute($command);
62
-    }
50
+	/**
51
+	 * @return void
52
+	 * @action init
53
+	 */
54
+	public function registerShortcodes()
55
+	{
56
+		$command = new RegisterShortcodes([
57
+			'site_reviews',
58
+			'site_reviews_form',
59
+			'site_reviews_summary',
60
+		]);
61
+		$this->execute($command);
62
+	}
63 63
 
64
-    /**
65
-     * @return void
66
-     * @action init
67
-     */
68
-    public function registerTaxonomy()
69
-    {
70
-        $command = new RegisterTaxonomy([
71
-            'hierarchical' => true,
72
-            'meta_box_cb' => [glsr(EditorController::class), 'renderTaxonomyMetabox'],
73
-            'public' => false,
74
-            'rest_controller_class' => RestCategoryController::class,
75
-            'show_admin_column' => true,
76
-            'show_in_rest' => true,
77
-            'show_ui' => true,
78
-        ]);
79
-        $this->execute($command);
80
-    }
64
+	/**
65
+	 * @return void
66
+	 * @action init
67
+	 */
68
+	public function registerTaxonomy()
69
+	{
70
+		$command = new RegisterTaxonomy([
71
+			'hierarchical' => true,
72
+			'meta_box_cb' => [glsr(EditorController::class), 'renderTaxonomyMetabox'],
73
+			'public' => false,
74
+			'rest_controller_class' => RestCategoryController::class,
75
+			'show_admin_column' => true,
76
+			'show_in_rest' => true,
77
+			'show_ui' => true,
78
+		]);
79
+		$this->execute($command);
80
+	}
81 81
 
82
-    /**
83
-     * @return void
84
-     * @action widgets_init
85
-     */
86
-    public function registerWidgets()
87
-    {
88
-        $command = new RegisterWidgets([
89
-            'site-reviews',
90
-            'site-reviews-form',
91
-            'site-reviews-summary',
92
-        ]);
93
-        $this->execute($command);
94
-    }
82
+	/**
83
+	 * @return void
84
+	 * @action widgets_init
85
+	 */
86
+	public function registerWidgets()
87
+	{
88
+		$command = new RegisterWidgets([
89
+			'site-reviews',
90
+			'site-reviews-form',
91
+			'site-reviews-summary',
92
+		]);
93
+		$this->execute($command);
94
+	}
95 95
 }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -16,35 +16,35 @@  discard block
 block discarded – undo
16 16
      */
17 17
     public function registerPostType()
18 18
     {
19
-        if (!glsr()->hasPermission()) {
19
+        if( !glsr()->hasPermission() ) {
20 20
             return;
21 21
         }
22
-        $command = new RegisterPostType([
22
+        $command = new RegisterPostType( [
23 23
             'capabilities' => ['create_posts' => 'create_'.Application::POST_TYPE],
24 24
             'capability_type' => Application::POST_TYPE,
25 25
             'columns' => [
26 26
                 'title' => '',
27 27
                 'category' => '',
28
-                'assigned_to' => __('Assigned To', 'site-reviews'),
29
-                'reviewer' => __('Author', 'site-reviews'),
30
-                'email' => __('Email', 'site-reviews'),
31
-                'ip_address' => __('IP Address', 'site-reviews'),
32
-                'response' => __('Response', 'site-reviews'),
33
-                'review_type' => __('Type', 'site-reviews'),
34
-                'rating' => __('Rating', 'site-reviews'),
35
-                'pinned' => __('Pinned', 'site-reviews'),
28
+                'assigned_to' => __( 'Assigned To', 'site-reviews' ),
29
+                'reviewer' => __( 'Author', 'site-reviews' ),
30
+                'email' => __( 'Email', 'site-reviews' ),
31
+                'ip_address' => __( 'IP Address', 'site-reviews' ),
32
+                'response' => __( 'Response', 'site-reviews' ),
33
+                'review_type' => __( 'Type', 'site-reviews' ),
34
+                'rating' => __( 'Rating', 'site-reviews' ),
35
+                'pinned' => __( 'Pinned', 'site-reviews' ),
36 36
                 'date' => '',
37 37
             ],
38 38
             'menu_icon' => 'dashicons-star-half',
39 39
             'menu_name' => glsr()->name,
40 40
             'map_meta_cap' => true,
41
-            'plural' => __('Reviews', 'site-reviews'),
41
+            'plural' => __( 'Reviews', 'site-reviews' ),
42 42
             'post_type' => Application::POST_TYPE,
43 43
             'rest_controller_class' => RestReviewController::class,
44 44
             'show_in_rest' => true,
45
-            'single' => __('Review', 'site-reviews'),
46
-        ]);
47
-        $this->execute($command);
45
+            'single' => __( 'Review', 'site-reviews' ),
46
+        ] );
47
+        $this->execute( $command );
48 48
     }
49 49
 
50 50
     /**
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public function registerShortcodes()
55 55
     {
56
-        $command = new RegisterShortcodes([
56
+        $command = new RegisterShortcodes( [
57 57
             'site_reviews',
58 58
             'site_reviews_form',
59 59
             'site_reviews_summary',
60
-        ]);
61
-        $this->execute($command);
60
+        ] );
61
+        $this->execute( $command );
62 62
     }
63 63
 
64 64
     /**
@@ -67,16 +67,16 @@  discard block
 block discarded – undo
67 67
      */
68 68
     public function registerTaxonomy()
69 69
     {
70
-        $command = new RegisterTaxonomy([
70
+        $command = new RegisterTaxonomy( [
71 71
             'hierarchical' => true,
72
-            'meta_box_cb' => [glsr(EditorController::class), 'renderTaxonomyMetabox'],
72
+            'meta_box_cb' => [glsr( EditorController::class ), 'renderTaxonomyMetabox'],
73 73
             'public' => false,
74 74
             'rest_controller_class' => RestCategoryController::class,
75 75
             'show_admin_column' => true,
76 76
             'show_in_rest' => true,
77 77
             'show_ui' => true,
78
-        ]);
79
-        $this->execute($command);
78
+        ] );
79
+        $this->execute( $command );
80 80
     }
81 81
 
82 82
     /**
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
      */
86 86
     public function registerWidgets()
87 87
     {
88
-        $command = new RegisterWidgets([
88
+        $command = new RegisterWidgets( [
89 89
             'site-reviews',
90 90
             'site-reviews-form',
91 91
             'site-reviews-summary',
92
-        ]);
93
-        $this->execute($command);
92
+        ] );
93
+        $this->execute( $command );
94 94
     }
95 95
 }
Please login to merge, or discard this patch.
plugin/Modules/Migrations/Migrate_4_4_0.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -6,11 +6,11 @@
 block discarded – undo
6 6
 
7 7
 class Migrate_4_4_0
8 8
 {
9
-    /**
10
-     * @return void
11
-     */
12
-    public function run()
13
-    {
14
-        glsr(Role::class)->resetAll();
15
-    }
9
+	/**
10
+	 * @return void
11
+	 */
12
+	public function run()
13
+	{
14
+		glsr(Role::class)->resetAll();
15
+	}
16 16
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,6 +11,6 @@
 block discarded – undo
11 11
      */
12 12
     public function run()
13 13
     {
14
-        glsr(Role::class)->resetAll();
14
+        glsr( Role::class )->resetAll();
15 15
     }
16 16
 }
Please login to merge, or discard this patch.