Passed
Push — feature/rebusify ( 495106...67b08f )
by Paul
06:10 queued 02:03
created
plugin/Defaults/ValidateReviewDefaults.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -7,22 +7,22 @@
 block discarded – undo
7 7
 
8 8
 class ValidateReviewDefaults extends Defaults
9 9
 {
10
-    /**
11
-     * @return array
12
-     */
13
-    protected function defaults()
14
-    {
15
-        return [
16
-            'assign_to' => '',
17
-            'category' => '',
18
-            'content' => '',
19
-            'email' => '',
20
-            'form_id' => '',
21
-            'ip_address' => glsr(Helper::class)->getIpAddress(), // required for Akismet and Blacklist validation
22
-            'name' => '',
23
-            'rating' => '0',
24
-            'terms' => '',
25
-            'title' => '',
26
-        ];
27
-    }
10
+	/**
11
+	 * @return array
12
+	 */
13
+	protected function defaults()
14
+	{
15
+		return [
16
+			'assign_to' => '',
17
+			'category' => '',
18
+			'content' => '',
19
+			'email' => '',
20
+			'form_id' => '',
21
+			'ip_address' => glsr(Helper::class)->getIpAddress(), // required for Akismet and Blacklist validation
22
+			'name' => '',
23
+			'rating' => '0',
24
+			'terms' => '',
25
+			'title' => '',
26
+		];
27
+	}
28 28
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
             'content' => '',
19 19
             'email' => '',
20 20
             'form_id' => '',
21
-            'ip_address' => glsr(Helper::class)->getIpAddress(), // required for Akismet and Blacklist validation
21
+            'ip_address' => glsr( Helper::class )->getIpAddress(), // required for Akismet and Blacklist validation
22 22
             'name' => '',
23 23
             'rating' => '0',
24 24
             'terms' => '',
Please login to merge, or discard this patch.
plugin/Defaults/StyleValidationDefaults.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -6,22 +6,22 @@
 block discarded – undo
6 6
 
7 7
 class StyleValidationDefaults extends Defaults
8 8
 {
9
-    /**
10
-     * @return array
11
-     */
12
-    protected function defaults()
13
-    {
14
-        return [
15
-            'error_tag' => 'div',
16
-            'error_tag_class' => 'glsr-field-error',
17
-            'field_class' => 'glsr-field',
18
-            'field_error_class' => 'glsr-has-error',
19
-            'input_error_class' => 'glsr-is-invalid',
20
-            'message_error_class' => 'glsr-has-errors',
21
-            'message_initial_class' => 'glsr-is-visible',
22
-            'message_success_class' => 'glsr-has-success',
23
-            'message_tag' => 'div',
24
-            'message_tag_class' => 'glsr-form-message',
25
-        ];
26
-    }
9
+	/**
10
+	 * @return array
11
+	 */
12
+	protected function defaults()
13
+	{
14
+		return [
15
+			'error_tag' => 'div',
16
+			'error_tag_class' => 'glsr-field-error',
17
+			'field_class' => 'glsr-field',
18
+			'field_error_class' => 'glsr-has-error',
19
+			'input_error_class' => 'glsr-is-invalid',
20
+			'message_error_class' => 'glsr-has-errors',
21
+			'message_initial_class' => 'glsr-is-visible',
22
+			'message_success_class' => 'glsr-has-success',
23
+			'message_tag' => 'div',
24
+			'message_tag_class' => 'glsr-form-message',
25
+		];
26
+	}
27 27
 }
Please login to merge, or discard this patch.
plugin/Defaults/SlackDefaults.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -6,19 +6,19 @@
 block discarded – undo
6 6
 
7 7
 class SlackDefaults extends Defaults
8 8
 {
9
-    /**
10
-     * @return array
11
-     */
12
-    protected function defaults()
13
-    {
14
-        return [
15
-            'button_text' => __('View Review', 'site-reviews'),
16
-            'button_url' => '',
17
-            'color' => '#665068',
18
-            'fallback' => '',
19
-            'icon_url' => glsr()->url('assets/images/icon.png'),
20
-            'pretext' => '',
21
-            'username' => glsr()->name,
22
-        ];
23
-    }
9
+	/**
10
+	 * @return array
11
+	 */
12
+	protected function defaults()
13
+	{
14
+		return [
15
+			'button_text' => __('View Review', 'site-reviews'),
16
+			'button_url' => '',
17
+			'color' => '#665068',
18
+			'fallback' => '',
19
+			'icon_url' => glsr()->url('assets/images/icon.png'),
20
+			'pretext' => '',
21
+			'username' => glsr()->name,
22
+		];
23
+	}
24 24
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@
 block discarded – undo
12 12
     protected function defaults()
13 13
     {
14 14
         return [
15
-            'button_text' => __('View Review', 'site-reviews'),
15
+            'button_text' => __( 'View Review', 'site-reviews' ),
16 16
             'button_url' => '',
17 17
             'color' => '#665068',
18 18
             'fallback' => '',
19
-            'icon_url' => glsr()->url('assets/images/icon.png'),
19
+            'icon_url' => glsr()->url( 'assets/images/icon.png' ),
20 20
             'pretext' => '',
21 21
             'username' => glsr()->name,
22 22
         ];
Please login to merge, or discard this patch.
plugin/Defaults/BuilderDefaults.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -6,19 +6,19 @@
 block discarded – undo
6 6
 
7 7
 class BuilderDefaults extends Defaults
8 8
 {
9
-    /**
10
-     * @return array
11
-     */
12
-    protected function defaults()
13
-    {
14
-        return [
15
-            'class' => '',
16
-            'id' => '',
17
-            'label' => '',
18
-            'options' => [],
19
-            'text' => '',
20
-            'type' => '',
21
-            'value' => '',
22
-        ];
23
-    }
9
+	/**
10
+	 * @return array
11
+	 */
12
+	protected function defaults()
13
+	{
14
+		return [
15
+			'class' => '',
16
+			'id' => '',
17
+			'label' => '',
18
+			'options' => [],
19
+			'text' => '',
20
+			'type' => '',
21
+			'value' => '',
22
+		];
23
+	}
24 24
 }
Please login to merge, or discard this patch.
plugin/Defaults/PostTypeDefaults.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -6,32 +6,32 @@
 block discarded – undo
6 6
 
7 7
 class PostTypeDefaults extends Defaults
8 8
 {
9
-    /**
10
-     * @return array
11
-     */
12
-    protected function defaults()
13
-    {
14
-        return [
15
-            'columns' => [
16
-                'title' => __('Title', 'site-reviews'),
17
-                'date' => __('Date', 'site-reviews'),
18
-            ],
19
-            'has_archive' => false,
20
-            'hierarchical' => false,
21
-            'labels' => [],
22
-            'menu_icon' => null,
23
-            'menu_name' => '',
24
-            'menu_position' => 25,
25
-            'plural' => '', //Required
26
-            'post_type' => '', //Required
27
-            'public' => false,
28
-            'query_var' => true,
29
-            'rewrite' => ['with_front' => false],
30
-            'show_in_menu' => true,
31
-            'show_ui' => true,
32
-            'single' => '', //Required
33
-            'supports' => ['title', 'editor'],
34
-            'taxonomies' => [],
35
-        ];
36
-    }
9
+	/**
10
+	 * @return array
11
+	 */
12
+	protected function defaults()
13
+	{
14
+		return [
15
+			'columns' => [
16
+				'title' => __('Title', 'site-reviews'),
17
+				'date' => __('Date', 'site-reviews'),
18
+			],
19
+			'has_archive' => false,
20
+			'hierarchical' => false,
21
+			'labels' => [],
22
+			'menu_icon' => null,
23
+			'menu_name' => '',
24
+			'menu_position' => 25,
25
+			'plural' => '', //Required
26
+			'post_type' => '', //Required
27
+			'public' => false,
28
+			'query_var' => true,
29
+			'rewrite' => ['with_front' => false],
30
+			'show_in_menu' => true,
31
+			'show_ui' => true,
32
+			'single' => '', //Required
33
+			'supports' => ['title', 'editor'],
34
+			'taxonomies' => [],
35
+		];
36
+	}
37 37
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,8 +13,8 @@
 block discarded – undo
13 13
     {
14 14
         return [
15 15
             'columns' => [
16
-                'title' => __('Title', 'site-reviews'),
17
-                'date' => __('Date', 'site-reviews'),
16
+                'title' => __( 'Title', 'site-reviews' ),
17
+                'date' => __( 'Date', 'site-reviews' ),
18 18
             ],
19 19
             'has_archive' => false,
20 20
             'hierarchical' => false,
Please login to merge, or discard this patch.
plugin/Controllers/RestCategoryController.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -11,27 +11,27 @@
 block discarded – undo
11 11
 
12 12
 class RestCategoryController extends RestController
13 13
 {
14
-    public function __construct()
15
-    {
16
-        $this->meta = new WP_REST_Term_Meta_Fields(Application::TAXONOMY);
17
-        $this->namespace = Application::ID.'/v1';
18
-        $this->rest_base = 'categories';
19
-        $this->taxonomy = Application::TAXONOMY;
20
-    }
14
+	public function __construct()
15
+	{
16
+		$this->meta = new WP_REST_Term_Meta_Fields(Application::TAXONOMY);
17
+		$this->namespace = Application::ID.'/v1';
18
+		$this->rest_base = 'categories';
19
+		$this->taxonomy = Application::TAXONOMY;
20
+	}
21 21
 
22
-    /**
23
-     * @return void
24
-     */
25
-    public function register_routes()
26
-    {
27
-        register_rest_route($this->namespace, '/'.$this->rest_base, [
28
-            [
29
-                'args' => $this->get_collection_params(),
30
-                'callback' => [$this, 'get_items'],
31
-                'methods' => Server::READABLE,
32
-                'permission_callback' => [$this, 'get_items_permissions_check'],
33
-            ],
34
-            'schema' => [$this, 'get_public_item_schema'],
35
-        ]);
36
-    }
22
+	/**
23
+	 * @return void
24
+	 */
25
+	public function register_routes()
26
+	{
27
+		register_rest_route($this->namespace, '/'.$this->rest_base, [
28
+			[
29
+				'args' => $this->get_collection_params(),
30
+				'callback' => [$this, 'get_items'],
31
+				'methods' => Server::READABLE,
32
+				'permission_callback' => [$this, 'get_items_permissions_check'],
33
+			],
34
+			'schema' => [$this, 'get_public_item_schema'],
35
+		]);
36
+	}
37 37
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 {
14 14
     public function __construct()
15 15
     {
16
-        $this->meta = new WP_REST_Term_Meta_Fields(Application::TAXONOMY);
16
+        $this->meta = new WP_REST_Term_Meta_Fields( Application::TAXONOMY );
17 17
         $this->namespace = Application::ID.'/v1';
18 18
         $this->rest_base = 'categories';
19 19
         $this->taxonomy = Application::TAXONOMY;
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      */
25 25
     public function register_routes()
26 26
     {
27
-        register_rest_route($this->namespace, '/'.$this->rest_base, [
27
+        register_rest_route( $this->namespace, '/'.$this->rest_base, [
28 28
             [
29 29
                 'args' => $this->get_collection_params(),
30 30
                 'callback' => [$this, 'get_items'],
@@ -32,6 +32,6 @@  discard block
 block discarded – undo
32 32
                 'permission_callback' => [$this, 'get_items_permissions_check'],
33 33
             ],
34 34
             'schema' => [$this, 'get_public_item_schema'],
35
-        ]);
35
+        ] );
36 36
     }
37 37
 }
Please login to merge, or discard this patch.
plugin/Controllers/PublicController.php 2 patches
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -13,93 +13,93 @@
 block discarded – undo
13 13
 
14 14
 class PublicController extends Controller
15 15
 {
16
-    /**
17
-     * @return void
18
-     * @action wp_enqueue_scripts
19
-     */
20
-    public function enqueueAssets()
21
-    {
22
-        (new EnqueuePublicAssets())->handle();
23
-    }
16
+	/**
17
+	 * @return void
18
+	 * @action wp_enqueue_scripts
19
+	 */
20
+	public function enqueueAssets()
21
+	{
22
+		(new EnqueuePublicAssets())->handle();
23
+	}
24 24
 
25
-    /**
26
-     * @param string $tag
27
-     * @param string $handle
28
-     * @return string
29
-     * @filter script_loader_tag
30
-     */
31
-    public function filterEnqueuedScripts($tag, $handle)
32
-    {
33
-        $scripts = [Application::ID.'/google-recaptcha'];
34
-        if (in_array($handle, apply_filters('site-reviews/async-scripts', $scripts))) {
35
-            $tag = str_replace(' src=', ' async src=', $tag);
36
-        }
37
-        if (in_array($handle, apply_filters('site-reviews/defer-scripts', $scripts))) {
38
-            $tag = str_replace(' src=', ' defer src=', $tag);
39
-        }
40
-        return $tag;
41
-    }
25
+	/**
26
+	 * @param string $tag
27
+	 * @param string $handle
28
+	 * @return string
29
+	 * @filter script_loader_tag
30
+	 */
31
+	public function filterEnqueuedScripts($tag, $handle)
32
+	{
33
+		$scripts = [Application::ID.'/google-recaptcha'];
34
+		if (in_array($handle, apply_filters('site-reviews/async-scripts', $scripts))) {
35
+			$tag = str_replace(' src=', ' async src=', $tag);
36
+		}
37
+		if (in_array($handle, apply_filters('site-reviews/defer-scripts', $scripts))) {
38
+			$tag = str_replace(' src=', ' defer src=', $tag);
39
+		}
40
+		return $tag;
41
+	}
42 42
 
43
-    /**
44
-     * @return array
45
-     * @filter site-reviews/config/forms/submission-form
46
-     */
47
-    public function filterFieldOrder(array $config)
48
-    {
49
-        $order = (array) apply_filters('site-reviews/submission-form/order', array_keys($config));
50
-        return array_intersect_key(array_merge(array_flip($order), $config), $config);
51
-    }
43
+	/**
44
+	 * @return array
45
+	 * @filter site-reviews/config/forms/submission-form
46
+	 */
47
+	public function filterFieldOrder(array $config)
48
+	{
49
+		$order = (array) apply_filters('site-reviews/submission-form/order', array_keys($config));
50
+		return array_intersect_key(array_merge(array_flip($order), $config), $config);
51
+	}
52 52
 
53
-    /**
54
-     * @param array $vars
55
-     * @return array
56
-     * @filter query_vars
57
-     */
58
-    public function filterQueryVars($vars)
59
-    {
60
-        $vars = glsr(Helper::class)->consolidateArray($vars);
61
-        $vars[] = glsr()->constant('PAGED_QUERY_VAR');
62
-        return $vars;
63
-    }
53
+	/**
54
+	 * @param array $vars
55
+	 * @return array
56
+	 * @filter query_vars
57
+	 */
58
+	public function filterQueryVars($vars)
59
+	{
60
+		$vars = glsr(Helper::class)->consolidateArray($vars);
61
+		$vars[] = glsr()->constant('PAGED_QUERY_VAR');
62
+		return $vars;
63
+	}
64 64
 
65
-    /**
66
-     * @param string $view
67
-     * @return string
68
-     * @filter site-reviews/render/view
69
-     */
70
-    public function filterRenderView($view)
71
-    {
72
-        return glsr(Style::class)->filterView($view);
73
-    }
65
+	/**
66
+	 * @param string $view
67
+	 * @return string
68
+	 * @filter site-reviews/render/view
69
+	 */
70
+	public function filterRenderView($view)
71
+	{
72
+		return glsr(Style::class)->filterView($view);
73
+	}
74 74
 
75
-    /**
76
-     * @return void
77
-     * @action site-reviews/builder
78
-     */
79
-    public function modifyBuilder(Builder $instance)
80
-    {
81
-        call_user_func_array([glsr(Style::class), 'modifyField'], [$instance]);
82
-    }
75
+	/**
76
+	 * @return void
77
+	 * @action site-reviews/builder
78
+	 */
79
+	public function modifyBuilder(Builder $instance)
80
+	{
81
+		call_user_func_array([glsr(Style::class), 'modifyField'], [$instance]);
82
+	}
83 83
 
84
-    /**
85
-     * @return void
86
-     * @action wp_footer
87
-     */
88
-    public function renderSchema()
89
-    {
90
-        glsr(Schema::class)->render();
91
-    }
84
+	/**
85
+	 * @return void
86
+	 * @action wp_footer
87
+	 */
88
+	public function renderSchema()
89
+	{
90
+		glsr(Schema::class)->render();
91
+	}
92 92
 
93
-    /**
94
-     * @return CreateReview
95
-     */
96
-    public function routerSubmitReview(array $request)
97
-    {
98
-        $validated = glsr(ValidateReview::class)->validate($request);
99
-        $command = new CreateReview($validated->request);
100
-        if (empty($validated->error) && !$validated->recaptchaIsUnset) {
101
-            $this->execute($command);
102
-        }
103
-        return $command;
104
-    }
93
+	/**
94
+	 * @return CreateReview
95
+	 */
96
+	public function routerSubmitReview(array $request)
97
+	{
98
+		$validated = glsr(ValidateReview::class)->validate($request);
99
+		$command = new CreateReview($validated->request);
100
+		if (empty($validated->error) && !$validated->recaptchaIsUnset) {
101
+			$this->execute($command);
102
+		}
103
+		return $command;
104
+	}
105 105
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
      * @return string
29 29
      * @filter script_loader_tag
30 30
      */
31
-    public function filterEnqueuedScripts($tag, $handle)
31
+    public function filterEnqueuedScripts( $tag, $handle )
32 32
     {
33 33
         $scripts = [Application::ID.'/google-recaptcha'];
34
-        if (in_array($handle, apply_filters('site-reviews/async-scripts', $scripts))) {
35
-            $tag = str_replace(' src=', ' async src=', $tag);
34
+        if( in_array( $handle, apply_filters( 'site-reviews/async-scripts', $scripts ) ) ) {
35
+            $tag = str_replace( ' src=', ' async src=', $tag );
36 36
         }
37
-        if (in_array($handle, apply_filters('site-reviews/defer-scripts', $scripts))) {
38
-            $tag = str_replace(' src=', ' defer src=', $tag);
37
+        if( in_array( $handle, apply_filters( 'site-reviews/defer-scripts', $scripts ) ) ) {
38
+            $tag = str_replace( ' src=', ' defer src=', $tag );
39 39
         }
40 40
         return $tag;
41 41
     }
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
      * @return array
45 45
      * @filter site-reviews/config/forms/submission-form
46 46
      */
47
-    public function filterFieldOrder(array $config)
47
+    public function filterFieldOrder( array $config )
48 48
     {
49
-        $order = (array) apply_filters('site-reviews/submission-form/order', array_keys($config));
50
-        return array_intersect_key(array_merge(array_flip($order), $config), $config);
49
+        $order = (array)apply_filters( 'site-reviews/submission-form/order', array_keys( $config ) );
50
+        return array_intersect_key( array_merge( array_flip( $order ), $config ), $config );
51 51
     }
52 52
 
53 53
     /**
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
      * @return array
56 56
      * @filter query_vars
57 57
      */
58
-    public function filterQueryVars($vars)
58
+    public function filterQueryVars( $vars )
59 59
     {
60
-        $vars = glsr(Helper::class)->consolidateArray($vars);
61
-        $vars[] = glsr()->constant('PAGED_QUERY_VAR');
60
+        $vars = glsr( Helper::class )->consolidateArray( $vars );
61
+        $vars[] = glsr()->constant( 'PAGED_QUERY_VAR' );
62 62
         return $vars;
63 63
     }
64 64
 
@@ -67,18 +67,18 @@  discard block
 block discarded – undo
67 67
      * @return string
68 68
      * @filter site-reviews/render/view
69 69
      */
70
-    public function filterRenderView($view)
70
+    public function filterRenderView( $view )
71 71
     {
72
-        return glsr(Style::class)->filterView($view);
72
+        return glsr( Style::class )->filterView( $view );
73 73
     }
74 74
 
75 75
     /**
76 76
      * @return void
77 77
      * @action site-reviews/builder
78 78
      */
79
-    public function modifyBuilder(Builder $instance)
79
+    public function modifyBuilder( Builder $instance )
80 80
     {
81
-        call_user_func_array([glsr(Style::class), 'modifyField'], [$instance]);
81
+        call_user_func_array( [glsr( Style::class ), 'modifyField'], [$instance] );
82 82
     }
83 83
 
84 84
     /**
@@ -87,18 +87,18 @@  discard block
 block discarded – undo
87 87
      */
88 88
     public function renderSchema()
89 89
     {
90
-        glsr(Schema::class)->render();
90
+        glsr( Schema::class )->render();
91 91
     }
92 92
 
93 93
     /**
94 94
      * @return CreateReview
95 95
      */
96
-    public function routerSubmitReview(array $request)
96
+    public function routerSubmitReview( array $request )
97 97
     {
98
-        $validated = glsr(ValidateReview::class)->validate($request);
99
-        $command = new CreateReview($validated->request);
100
-        if (empty($validated->error) && !$validated->recaptchaIsUnset) {
101
-            $this->execute($command);
98
+        $validated = glsr( ValidateReview::class )->validate( $request );
99
+        $command = new CreateReview( $validated->request );
100
+        if( empty($validated->error) && !$validated->recaptchaIsUnset ) {
101
+            $this->execute( $command );
102 102
         }
103 103
         return $command;
104 104
     }
Please login to merge, or discard this patch.
plugin/Controllers/AdminController.php 2 patches
Indentation   +215 added lines, -215 removed lines patch added patch discarded remove patch
@@ -15,219 +15,219 @@
 block discarded – undo
15 15
 
16 16
 class AdminController extends Controller
17 17
 {
18
-    /**
19
-     * @return void
20
-     * @action admin_enqueue_scripts
21
-     */
22
-    public function enqueueAssets()
23
-    {
24
-        $command = new EnqueueAdminAssets([
25
-            'pointers' => [[
26
-                'content' => __('You can pin exceptional reviews so that they are always shown first.', 'site-reviews'),
27
-                'id' => 'glsr-pointer-pinned',
28
-                'position' => [
29
-                    'edge' => 'right',
30
-                    'align' => 'middle',
31
-                ],
32
-                'screen' => Application::POST_TYPE,
33
-                'target' => '#misc-pub-pinned',
34
-                'title' => __('Pin Your Reviews', 'site-reviews'),
35
-            ]],
36
-        ]);
37
-        $this->execute($command);
38
-    }
39
-
40
-    /**
41
-     * @return array
42
-     * @filter plugin_action_links_site-reviews/site-reviews.php
43
-     */
44
-    public function filterActionLinks(array $links)
45
-    {
46
-        $links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [
47
-            'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=settings'),
48
-        ]);
49
-        return $links;
50
-    }
51
-
52
-    /**
53
-     * @param array $capabilities
54
-     * @param string $capability
55
-     * @return array
56
-     * @filter map_meta_cap
57
-     */
58
-    public function filterCreateCapability($capabilities, $capability)
59
-    {
60
-        if ($capability == 'create_'.Application::POST_TYPE) {
61
-            $capabilities[] = 'do_not_allow';
62
-        }
63
-        return $capabilities;
64
-    }
65
-
66
-    /**
67
-     * @param array $items
68
-     * @return array
69
-     * @filter dashboard_glance_items
70
-     */
71
-    public function filterDashboardGlanceItems($items)
72
-    {
73
-        $postCount = wp_count_posts(Application::POST_TYPE);
74
-        if (empty($postCount->publish)) {
75
-            return $items;
76
-        }
77
-        $text = _n('%s Review', '%s Reviews', $postCount->publish, 'site-reviews');
78
-        $text = sprintf($text, number_format_i18n($postCount->publish));
79
-        $items = glsr(Helper::class)->consolidateArray($items);
80
-        $items[] = current_user_can(get_post_type_object(Application::POST_TYPE)->cap->edit_posts)
81
-            ? glsr(Builder::class)->a($text, [
82
-                'class' => 'glsr-review-count',
83
-                'href' => 'edit.php?post_type='.Application::POST_TYPE,
84
-            ])
85
-            : glsr(Builder::class)->span($text, [
86
-                'class' => 'glsr-review-count',
87
-            ]);
88
-        return $items;
89
-    }
90
-
91
-    /**
92
-     * @param array $plugins
93
-     * @return array
94
-     * @filter mce_external_plugins
95
-     */
96
-    public function filterTinymcePlugins($plugins)
97
-    {
98
-        if (current_user_can('edit_posts') || current_user_can('edit_pages')) {
99
-            $plugins = glsr(Helper::class)->consolidateArray($plugins);
100
-            $plugins['glsr_shortcode'] = glsr()->url('assets/scripts/mce-plugin.js');
101
-        }
102
-        return $plugins;
103
-    }
104
-
105
-    /**
106
-     * @return void
107
-     * @action admin_init
108
-     */
109
-    public function registerTinymcePopups()
110
-    {
111
-        $command = new RegisterTinymcePopups([
112
-            'site_reviews' => esc_html__('Recent Reviews', 'site-reviews'),
113
-            'site_reviews_form' => esc_html__('Submit a Review', 'site-reviews'),
114
-            'site_reviews_summary' => esc_html__('Summary of Reviews', 'site-reviews'),
115
-        ]);
116
-        $this->execute($command);
117
-    }
118
-
119
-    /**
120
-     * @param string $editorId
121
-     * @return void|null
122
-     * @action media_buttons
123
-     */
124
-    public function renderTinymceButton($editorId)
125
-    {
126
-        $allowedEditors = apply_filters('site-reviews/tinymce/editor-ids', ['content'], $editorId);
127
-        if ('post' != glsr_current_screen()->base || !in_array($editorId, $allowedEditors)) {
128
-            return;
129
-        }
130
-        $shortcodes = [];
131
-        foreach (glsr()->mceShortcodes as $shortcode => $values) {
132
-            $shortcodes[$shortcode] = $values;
133
-        }
134
-        if (empty($shortcodes)) {
135
-            return;
136
-        }
137
-        glsr()->render('partials/editor/tinymce', [
138
-            'shortcodes' => $shortcodes,
139
-        ]);
140
-    }
141
-
142
-    /**
143
-     * @return void
144
-     */
145
-    public function routerClearConsole()
146
-    {
147
-        glsr(Console::class)->clear();
148
-        glsr(Notice::class)->addSuccess(__('Console cleared.', 'site-reviews'));
149
-    }
150
-
151
-    /**
152
-     * @return void
153
-     */
154
-    public function routerFetchConsole()
155
-    {
156
-        glsr(Notice::class)->addSuccess(__('Console reloaded.', 'site-reviews'));
157
-    }
158
-
159
-    /**
160
-     * @param bool $showNotice
161
-     * @return void
162
-     */
163
-    public function routerCountReviews($showNotice = true)
164
-    {
165
-        glsr(CountsManager::class)->countAll();
166
-        glsr(OptionManager::class)->set('last_review_count', current_time('timestamp'));
167
-        if ($showNotice) {
168
-            glsr(Notice::class)->clear()->addSuccess(__('Recalculated rating counts.', 'site-reviews'));
169
-        }
170
-    }
171
-
172
-    /**
173
-     * @return void
174
-     */
175
-    public function routerDownloadConsole()
176
-    {
177
-        $this->download(Application::ID.'-console.txt', glsr(Console::class)->get());
178
-    }
179
-
180
-    /**
181
-     * @return void
182
-     */
183
-    public function routerDownloadSystemInfo()
184
-    {
185
-        $this->download(Application::ID.'-system-info.txt', glsr(System::class)->get());
186
-    }
187
-
188
-    /**
189
-     * @return void
190
-     */
191
-    public function routerExportSettings()
192
-    {
193
-        $this->download(Application::ID.'-settings.json', glsr(OptionManager::class)->json());
194
-    }
195
-
196
-    /**
197
-     * @return void
198
-     */
199
-    public function routerImportSettings()
200
-    {
201
-        $file = $_FILES['import-file'];
202
-        if (UPLOAD_ERR_OK !== $file['error']) {
203
-            return glsr(Notice::class)->addError($this->getUploadError($file['error']));
204
-        }
205
-        if ('application/json' !== $file['type'] || !glsr(Helper::class)->endsWith('.json', $file['name'])) {
206
-            return glsr(Notice::class)->addError(__('Please use a valid Site Reviews settings file.', 'site-reviews'));
207
-        }
208
-        $settings = json_decode(file_get_contents($file['tmp_name']), true);
209
-        if (empty($settings)) {
210
-            return glsr(Notice::class)->addWarning(__('There were no settings found to import.', 'site-reviews'));
211
-        }
212
-        glsr(OptionManager::class)->set(glsr(OptionManager::class)->normalize($settings));
213
-        glsr(Notice::class)->addSuccess(__('Settings imported.', 'site-reviews'));
214
-    }
215
-
216
-    /**
217
-     * @param int $errorCode
218
-     * @return string
219
-     */
220
-    protected function getUploadError($errorCode)
221
-    {
222
-        $errors = [
223
-            UPLOAD_ERR_INI_SIZE => __('The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews'),
224
-            UPLOAD_ERR_FORM_SIZE => __('The uploaded file is too big.', 'site-reviews'),
225
-            UPLOAD_ERR_PARTIAL => __('The uploaded file was only partially uploaded.', 'site-reviews'),
226
-            UPLOAD_ERR_NO_FILE => __('No file was uploaded.', 'site-reviews'),
227
-            UPLOAD_ERR_NO_TMP_DIR => __('Missing a temporary folder.', 'site-reviews'),
228
-            UPLOAD_ERR_CANT_WRITE => __('Failed to write file to disk.', 'site-reviews'),
229
-            UPLOAD_ERR_EXTENSION => __('A PHP extension stopped the file upload.', 'site-reviews'),
230
-        ];
231
-        return glsr_get($errors, $errorCode, __('Unknown upload error.', 'site-reviews'));
232
-    }
18
+	/**
19
+	 * @return void
20
+	 * @action admin_enqueue_scripts
21
+	 */
22
+	public function enqueueAssets()
23
+	{
24
+		$command = new EnqueueAdminAssets([
25
+			'pointers' => [[
26
+				'content' => __('You can pin exceptional reviews so that they are always shown first.', 'site-reviews'),
27
+				'id' => 'glsr-pointer-pinned',
28
+				'position' => [
29
+					'edge' => 'right',
30
+					'align' => 'middle',
31
+				],
32
+				'screen' => Application::POST_TYPE,
33
+				'target' => '#misc-pub-pinned',
34
+				'title' => __('Pin Your Reviews', 'site-reviews'),
35
+			]],
36
+		]);
37
+		$this->execute($command);
38
+	}
39
+
40
+	/**
41
+	 * @return array
42
+	 * @filter plugin_action_links_site-reviews/site-reviews.php
43
+	 */
44
+	public function filterActionLinks(array $links)
45
+	{
46
+		$links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [
47
+			'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=settings'),
48
+		]);
49
+		return $links;
50
+	}
51
+
52
+	/**
53
+	 * @param array $capabilities
54
+	 * @param string $capability
55
+	 * @return array
56
+	 * @filter map_meta_cap
57
+	 */
58
+	public function filterCreateCapability($capabilities, $capability)
59
+	{
60
+		if ($capability == 'create_'.Application::POST_TYPE) {
61
+			$capabilities[] = 'do_not_allow';
62
+		}
63
+		return $capabilities;
64
+	}
65
+
66
+	/**
67
+	 * @param array $items
68
+	 * @return array
69
+	 * @filter dashboard_glance_items
70
+	 */
71
+	public function filterDashboardGlanceItems($items)
72
+	{
73
+		$postCount = wp_count_posts(Application::POST_TYPE);
74
+		if (empty($postCount->publish)) {
75
+			return $items;
76
+		}
77
+		$text = _n('%s Review', '%s Reviews', $postCount->publish, 'site-reviews');
78
+		$text = sprintf($text, number_format_i18n($postCount->publish));
79
+		$items = glsr(Helper::class)->consolidateArray($items);
80
+		$items[] = current_user_can(get_post_type_object(Application::POST_TYPE)->cap->edit_posts)
81
+			? glsr(Builder::class)->a($text, [
82
+				'class' => 'glsr-review-count',
83
+				'href' => 'edit.php?post_type='.Application::POST_TYPE,
84
+			])
85
+			: glsr(Builder::class)->span($text, [
86
+				'class' => 'glsr-review-count',
87
+			]);
88
+		return $items;
89
+	}
90
+
91
+	/**
92
+	 * @param array $plugins
93
+	 * @return array
94
+	 * @filter mce_external_plugins
95
+	 */
96
+	public function filterTinymcePlugins($plugins)
97
+	{
98
+		if (current_user_can('edit_posts') || current_user_can('edit_pages')) {
99
+			$plugins = glsr(Helper::class)->consolidateArray($plugins);
100
+			$plugins['glsr_shortcode'] = glsr()->url('assets/scripts/mce-plugin.js');
101
+		}
102
+		return $plugins;
103
+	}
104
+
105
+	/**
106
+	 * @return void
107
+	 * @action admin_init
108
+	 */
109
+	public function registerTinymcePopups()
110
+	{
111
+		$command = new RegisterTinymcePopups([
112
+			'site_reviews' => esc_html__('Recent Reviews', 'site-reviews'),
113
+			'site_reviews_form' => esc_html__('Submit a Review', 'site-reviews'),
114
+			'site_reviews_summary' => esc_html__('Summary of Reviews', 'site-reviews'),
115
+		]);
116
+		$this->execute($command);
117
+	}
118
+
119
+	/**
120
+	 * @param string $editorId
121
+	 * @return void|null
122
+	 * @action media_buttons
123
+	 */
124
+	public function renderTinymceButton($editorId)
125
+	{
126
+		$allowedEditors = apply_filters('site-reviews/tinymce/editor-ids', ['content'], $editorId);
127
+		if ('post' != glsr_current_screen()->base || !in_array($editorId, $allowedEditors)) {
128
+			return;
129
+		}
130
+		$shortcodes = [];
131
+		foreach (glsr()->mceShortcodes as $shortcode => $values) {
132
+			$shortcodes[$shortcode] = $values;
133
+		}
134
+		if (empty($shortcodes)) {
135
+			return;
136
+		}
137
+		glsr()->render('partials/editor/tinymce', [
138
+			'shortcodes' => $shortcodes,
139
+		]);
140
+	}
141
+
142
+	/**
143
+	 * @return void
144
+	 */
145
+	public function routerClearConsole()
146
+	{
147
+		glsr(Console::class)->clear();
148
+		glsr(Notice::class)->addSuccess(__('Console cleared.', 'site-reviews'));
149
+	}
150
+
151
+	/**
152
+	 * @return void
153
+	 */
154
+	public function routerFetchConsole()
155
+	{
156
+		glsr(Notice::class)->addSuccess(__('Console reloaded.', 'site-reviews'));
157
+	}
158
+
159
+	/**
160
+	 * @param bool $showNotice
161
+	 * @return void
162
+	 */
163
+	public function routerCountReviews($showNotice = true)
164
+	{
165
+		glsr(CountsManager::class)->countAll();
166
+		glsr(OptionManager::class)->set('last_review_count', current_time('timestamp'));
167
+		if ($showNotice) {
168
+			glsr(Notice::class)->clear()->addSuccess(__('Recalculated rating counts.', 'site-reviews'));
169
+		}
170
+	}
171
+
172
+	/**
173
+	 * @return void
174
+	 */
175
+	public function routerDownloadConsole()
176
+	{
177
+		$this->download(Application::ID.'-console.txt', glsr(Console::class)->get());
178
+	}
179
+
180
+	/**
181
+	 * @return void
182
+	 */
183
+	public function routerDownloadSystemInfo()
184
+	{
185
+		$this->download(Application::ID.'-system-info.txt', glsr(System::class)->get());
186
+	}
187
+
188
+	/**
189
+	 * @return void
190
+	 */
191
+	public function routerExportSettings()
192
+	{
193
+		$this->download(Application::ID.'-settings.json', glsr(OptionManager::class)->json());
194
+	}
195
+
196
+	/**
197
+	 * @return void
198
+	 */
199
+	public function routerImportSettings()
200
+	{
201
+		$file = $_FILES['import-file'];
202
+		if (UPLOAD_ERR_OK !== $file['error']) {
203
+			return glsr(Notice::class)->addError($this->getUploadError($file['error']));
204
+		}
205
+		if ('application/json' !== $file['type'] || !glsr(Helper::class)->endsWith('.json', $file['name'])) {
206
+			return glsr(Notice::class)->addError(__('Please use a valid Site Reviews settings file.', 'site-reviews'));
207
+		}
208
+		$settings = json_decode(file_get_contents($file['tmp_name']), true);
209
+		if (empty($settings)) {
210
+			return glsr(Notice::class)->addWarning(__('There were no settings found to import.', 'site-reviews'));
211
+		}
212
+		glsr(OptionManager::class)->set(glsr(OptionManager::class)->normalize($settings));
213
+		glsr(Notice::class)->addSuccess(__('Settings imported.', 'site-reviews'));
214
+	}
215
+
216
+	/**
217
+	 * @param int $errorCode
218
+	 * @return string
219
+	 */
220
+	protected function getUploadError($errorCode)
221
+	{
222
+		$errors = [
223
+			UPLOAD_ERR_INI_SIZE => __('The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews'),
224
+			UPLOAD_ERR_FORM_SIZE => __('The uploaded file is too big.', 'site-reviews'),
225
+			UPLOAD_ERR_PARTIAL => __('The uploaded file was only partially uploaded.', 'site-reviews'),
226
+			UPLOAD_ERR_NO_FILE => __('No file was uploaded.', 'site-reviews'),
227
+			UPLOAD_ERR_NO_TMP_DIR => __('Missing a temporary folder.', 'site-reviews'),
228
+			UPLOAD_ERR_CANT_WRITE => __('Failed to write file to disk.', 'site-reviews'),
229
+			UPLOAD_ERR_EXTENSION => __('A PHP extension stopped the file upload.', 'site-reviews'),
230
+		];
231
+		return glsr_get($errors, $errorCode, __('Unknown upload error.', 'site-reviews'));
232
+	}
233 233
 }
Please login to merge, or discard this patch.
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
      */
22 22
     public function enqueueAssets()
23 23
     {
24
-        $command = new EnqueueAdminAssets([
24
+        $command = new EnqueueAdminAssets( [
25 25
             'pointers' => [[
26
-                'content' => __('You can pin exceptional reviews so that they are always shown first.', 'site-reviews'),
26
+                'content' => __( 'You can pin exceptional reviews so that they are always shown first.', 'site-reviews' ),
27 27
                 'id' => 'glsr-pointer-pinned',
28 28
                 'position' => [
29 29
                     'edge' => 'right',
@@ -31,21 +31,21 @@  discard block
 block discarded – undo
31 31
                 ],
32 32
                 'screen' => Application::POST_TYPE,
33 33
                 'target' => '#misc-pub-pinned',
34
-                'title' => __('Pin Your Reviews', 'site-reviews'),
34
+                'title' => __( 'Pin Your Reviews', 'site-reviews' ),
35 35
             ]],
36
-        ]);
37
-        $this->execute($command);
36
+        ] );
37
+        $this->execute( $command );
38 38
     }
39 39
 
40 40
     /**
41 41
      * @return array
42 42
      * @filter plugin_action_links_site-reviews/site-reviews.php
43 43
      */
44
-    public function filterActionLinks(array $links)
44
+    public function filterActionLinks( array $links )
45 45
     {
46
-        $links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [
47
-            'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=settings'),
48
-        ]);
46
+        $links['settings'] = glsr( Builder::class )->a( __( 'Settings', 'site-reviews' ), [
47
+            'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=settings' ),
48
+        ] );
49 49
         return $links;
50 50
     }
51 51
 
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
      * @return array
56 56
      * @filter map_meta_cap
57 57
      */
58
-    public function filterCreateCapability($capabilities, $capability)
58
+    public function filterCreateCapability( $capabilities, $capability )
59 59
     {
60
-        if ($capability == 'create_'.Application::POST_TYPE) {
60
+        if( $capability == 'create_'.Application::POST_TYPE ) {
61 61
             $capabilities[] = 'do_not_allow';
62 62
         }
63 63
         return $capabilities;
@@ -68,23 +68,23 @@  discard block
 block discarded – undo
68 68
      * @return array
69 69
      * @filter dashboard_glance_items
70 70
      */
71
-    public function filterDashboardGlanceItems($items)
71
+    public function filterDashboardGlanceItems( $items )
72 72
     {
73
-        $postCount = wp_count_posts(Application::POST_TYPE);
74
-        if (empty($postCount->publish)) {
73
+        $postCount = wp_count_posts( Application::POST_TYPE );
74
+        if( empty($postCount->publish) ) {
75 75
             return $items;
76 76
         }
77
-        $text = _n('%s Review', '%s Reviews', $postCount->publish, 'site-reviews');
78
-        $text = sprintf($text, number_format_i18n($postCount->publish));
79
-        $items = glsr(Helper::class)->consolidateArray($items);
80
-        $items[] = current_user_can(get_post_type_object(Application::POST_TYPE)->cap->edit_posts)
81
-            ? glsr(Builder::class)->a($text, [
77
+        $text = _n( '%s Review', '%s Reviews', $postCount->publish, 'site-reviews' );
78
+        $text = sprintf( $text, number_format_i18n( $postCount->publish ) );
79
+        $items = glsr( Helper::class )->consolidateArray( $items );
80
+        $items[] = current_user_can( get_post_type_object( Application::POST_TYPE )->cap->edit_posts )
81
+            ? glsr( Builder::class )->a( $text, [
82 82
                 'class' => 'glsr-review-count',
83 83
                 'href' => 'edit.php?post_type='.Application::POST_TYPE,
84
-            ])
85
-            : glsr(Builder::class)->span($text, [
84
+            ] )
85
+            : glsr( Builder::class )->span( $text, [
86 86
                 'class' => 'glsr-review-count',
87
-            ]);
87
+            ] );
88 88
         return $items;
89 89
     }
90 90
 
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
      * @return array
94 94
      * @filter mce_external_plugins
95 95
      */
96
-    public function filterTinymcePlugins($plugins)
96
+    public function filterTinymcePlugins( $plugins )
97 97
     {
98
-        if (current_user_can('edit_posts') || current_user_can('edit_pages')) {
99
-            $plugins = glsr(Helper::class)->consolidateArray($plugins);
100
-            $plugins['glsr_shortcode'] = glsr()->url('assets/scripts/mce-plugin.js');
98
+        if( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) {
99
+            $plugins = glsr( Helper::class )->consolidateArray( $plugins );
100
+            $plugins['glsr_shortcode'] = glsr()->url( 'assets/scripts/mce-plugin.js' );
101 101
         }
102 102
         return $plugins;
103 103
     }
@@ -108,12 +108,12 @@  discard block
 block discarded – undo
108 108
      */
109 109
     public function registerTinymcePopups()
110 110
     {
111
-        $command = new RegisterTinymcePopups([
112
-            'site_reviews' => esc_html__('Recent Reviews', 'site-reviews'),
113
-            'site_reviews_form' => esc_html__('Submit a Review', 'site-reviews'),
114
-            'site_reviews_summary' => esc_html__('Summary of Reviews', 'site-reviews'),
115
-        ]);
116
-        $this->execute($command);
111
+        $command = new RegisterTinymcePopups( [
112
+            'site_reviews' => esc_html__( 'Recent Reviews', 'site-reviews' ),
113
+            'site_reviews_form' => esc_html__( 'Submit a Review', 'site-reviews' ),
114
+            'site_reviews_summary' => esc_html__( 'Summary of Reviews', 'site-reviews' ),
115
+        ] );
116
+        $this->execute( $command );
117 117
     }
118 118
 
119 119
     /**
@@ -121,22 +121,22 @@  discard block
 block discarded – undo
121 121
      * @return void|null
122 122
      * @action media_buttons
123 123
      */
124
-    public function renderTinymceButton($editorId)
124
+    public function renderTinymceButton( $editorId )
125 125
     {
126
-        $allowedEditors = apply_filters('site-reviews/tinymce/editor-ids', ['content'], $editorId);
127
-        if ('post' != glsr_current_screen()->base || !in_array($editorId, $allowedEditors)) {
126
+        $allowedEditors = apply_filters( 'site-reviews/tinymce/editor-ids', ['content'], $editorId );
127
+        if( 'post' != glsr_current_screen()->base || !in_array( $editorId, $allowedEditors ) ) {
128 128
             return;
129 129
         }
130 130
         $shortcodes = [];
131
-        foreach (glsr()->mceShortcodes as $shortcode => $values) {
131
+        foreach( glsr()->mceShortcodes as $shortcode => $values ) {
132 132
             $shortcodes[$shortcode] = $values;
133 133
         }
134
-        if (empty($shortcodes)) {
134
+        if( empty($shortcodes) ) {
135 135
             return;
136 136
         }
137
-        glsr()->render('partials/editor/tinymce', [
137
+        glsr()->render( 'partials/editor/tinymce', [
138 138
             'shortcodes' => $shortcodes,
139
-        ]);
139
+        ] );
140 140
     }
141 141
 
142 142
     /**
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
      */
145 145
     public function routerClearConsole()
146 146
     {
147
-        glsr(Console::class)->clear();
148
-        glsr(Notice::class)->addSuccess(__('Console cleared.', 'site-reviews'));
147
+        glsr( Console::class )->clear();
148
+        glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ) );
149 149
     }
150 150
 
151 151
     /**
@@ -153,19 +153,19 @@  discard block
 block discarded – undo
153 153
      */
154 154
     public function routerFetchConsole()
155 155
     {
156
-        glsr(Notice::class)->addSuccess(__('Console reloaded.', 'site-reviews'));
156
+        glsr( Notice::class )->addSuccess( __( 'Console reloaded.', 'site-reviews' ) );
157 157
     }
158 158
 
159 159
     /**
160 160
      * @param bool $showNotice
161 161
      * @return void
162 162
      */
163
-    public function routerCountReviews($showNotice = true)
163
+    public function routerCountReviews( $showNotice = true )
164 164
     {
165
-        glsr(CountsManager::class)->countAll();
166
-        glsr(OptionManager::class)->set('last_review_count', current_time('timestamp'));
167
-        if ($showNotice) {
168
-            glsr(Notice::class)->clear()->addSuccess(__('Recalculated rating counts.', 'site-reviews'));
165
+        glsr( CountsManager::class )->countAll();
166
+        glsr( OptionManager::class )->set( 'last_review_count', current_time( 'timestamp' ) );
167
+        if( $showNotice ) {
168
+            glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' ) );
169 169
         }
170 170
     }
171 171
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
      */
175 175
     public function routerDownloadConsole()
176 176
     {
177
-        $this->download(Application::ID.'-console.txt', glsr(Console::class)->get());
177
+        $this->download( Application::ID.'-console.txt', glsr( Console::class )->get() );
178 178
     }
179 179
 
180 180
     /**
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
      */
183 183
     public function routerDownloadSystemInfo()
184 184
     {
185
-        $this->download(Application::ID.'-system-info.txt', glsr(System::class)->get());
185
+        $this->download( Application::ID.'-system-info.txt', glsr( System::class )->get() );
186 186
     }
187 187
 
188 188
     /**
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
      */
191 191
     public function routerExportSettings()
192 192
     {
193
-        $this->download(Application::ID.'-settings.json', glsr(OptionManager::class)->json());
193
+        $this->download( Application::ID.'-settings.json', glsr( OptionManager::class )->json() );
194 194
     }
195 195
 
196 196
     /**
@@ -199,35 +199,35 @@  discard block
 block discarded – undo
199 199
     public function routerImportSettings()
200 200
     {
201 201
         $file = $_FILES['import-file'];
202
-        if (UPLOAD_ERR_OK !== $file['error']) {
203
-            return glsr(Notice::class)->addError($this->getUploadError($file['error']));
202
+        if( UPLOAD_ERR_OK !== $file['error'] ) {
203
+            return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ) );
204 204
         }
205
-        if ('application/json' !== $file['type'] || !glsr(Helper::class)->endsWith('.json', $file['name'])) {
206
-            return glsr(Notice::class)->addError(__('Please use a valid Site Reviews settings file.', 'site-reviews'));
205
+        if( 'application/json' !== $file['type'] || !glsr( Helper::class )->endsWith( '.json', $file['name'] ) ) {
206
+            return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ) );
207 207
         }
208
-        $settings = json_decode(file_get_contents($file['tmp_name']), true);
209
-        if (empty($settings)) {
210
-            return glsr(Notice::class)->addWarning(__('There were no settings found to import.', 'site-reviews'));
208
+        $settings = json_decode( file_get_contents( $file['tmp_name'] ), true );
209
+        if( empty($settings) ) {
210
+            return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ) );
211 211
         }
212
-        glsr(OptionManager::class)->set(glsr(OptionManager::class)->normalize($settings));
213
-        glsr(Notice::class)->addSuccess(__('Settings imported.', 'site-reviews'));
212
+        glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ) );
213
+        glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ) );
214 214
     }
215 215
 
216 216
     /**
217 217
      * @param int $errorCode
218 218
      * @return string
219 219
      */
220
-    protected function getUploadError($errorCode)
220
+    protected function getUploadError( $errorCode )
221 221
     {
222 222
         $errors = [
223
-            UPLOAD_ERR_INI_SIZE => __('The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews'),
224
-            UPLOAD_ERR_FORM_SIZE => __('The uploaded file is too big.', 'site-reviews'),
225
-            UPLOAD_ERR_PARTIAL => __('The uploaded file was only partially uploaded.', 'site-reviews'),
226
-            UPLOAD_ERR_NO_FILE => __('No file was uploaded.', 'site-reviews'),
227
-            UPLOAD_ERR_NO_TMP_DIR => __('Missing a temporary folder.', 'site-reviews'),
228
-            UPLOAD_ERR_CANT_WRITE => __('Failed to write file to disk.', 'site-reviews'),
229
-            UPLOAD_ERR_EXTENSION => __('A PHP extension stopped the file upload.', 'site-reviews'),
223
+            UPLOAD_ERR_INI_SIZE => __( 'The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews' ),
224
+            UPLOAD_ERR_FORM_SIZE => __( 'The uploaded file is too big.', 'site-reviews' ),
225
+            UPLOAD_ERR_PARTIAL => __( 'The uploaded file was only partially uploaded.', 'site-reviews' ),
226
+            UPLOAD_ERR_NO_FILE => __( 'No file was uploaded.', 'site-reviews' ),
227
+            UPLOAD_ERR_NO_TMP_DIR => __( 'Missing a temporary folder.', 'site-reviews' ),
228
+            UPLOAD_ERR_CANT_WRITE => __( 'Failed to write file to disk.', 'site-reviews' ),
229
+            UPLOAD_ERR_EXTENSION => __( 'A PHP extension stopped the file upload.', 'site-reviews' ),
230 230
         ];
231
-        return glsr_get($errors, $errorCode, __('Unknown upload error.', 'site-reviews'));
231
+        return glsr_get( $errors, $errorCode, __( 'Unknown upload error.', 'site-reviews' ) );
232 232
     }
233 233
 }
Please login to merge, or discard this patch.
plugin/Controllers/Controller.php 3 patches
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -10,55 +10,55 @@
 block discarded – undo
10 10
 
11 11
 abstract class Controller
12 12
 {
13
-    /**
14
-     * @return void
15
-     */
16
-    public function download($filename, $content)
17
-    {
18
-        if (!current_user_can(glsr()->constant('CAPABILITY'))) {
19
-            return;
20
-        }
21
-        nocache_headers();
22
-        header('Content-Type: text/plain');
23
-        header('Content-Disposition: attachment; filename="'.$filename.'"');
24
-        echo html_entity_decode($content);
25
-        exit;
26
-    }
13
+	/**
14
+	 * @return void
15
+	 */
16
+	public function download($filename, $content)
17
+	{
18
+		if (!current_user_can(glsr()->constant('CAPABILITY'))) {
19
+			return;
20
+		}
21
+		nocache_headers();
22
+		header('Content-Type: text/plain');
23
+		header('Content-Disposition: attachment; filename="'.$filename.'"');
24
+		echo html_entity_decode($content);
25
+		exit;
26
+	}
27 27
 
28
-    /**
29
-     * @param object $command
30
-     * @return mixed
31
-     * @throws InvalidArgumentException
32
-     */
33
-    public function execute($command)
34
-    {
35
-        $handlerClass = str_replace('Commands', 'Handlers', get_class($command));
36
-        if (!class_exists($handlerClass)) {
37
-            throw new InvalidArgumentException('Handler '.$handlerClass.' not found.');
38
-        }
39
-        try {
40
-            return glsr($handlerClass)->handle($command);
41
-        } catch (Exception $e) {
42
-            status_header(400);
43
-            glsr(Notice::class)->addError(new WP_Error('site_reviews_error', $e->getMessage()));
44
-            glsr_log()->error($e->getMessage());
45
-        }
46
-    }
28
+	/**
29
+	 * @param object $command
30
+	 * @return mixed
31
+	 * @throws InvalidArgumentException
32
+	 */
33
+	public function execute($command)
34
+	{
35
+		$handlerClass = str_replace('Commands', 'Handlers', get_class($command));
36
+		if (!class_exists($handlerClass)) {
37
+			throw new InvalidArgumentException('Handler '.$handlerClass.' not found.');
38
+		}
39
+		try {
40
+			return glsr($handlerClass)->handle($command);
41
+		} catch (Exception $e) {
42
+			status_header(400);
43
+			glsr(Notice::class)->addError(new WP_Error('site_reviews_error', $e->getMessage()));
44
+			glsr_log()->error($e->getMessage());
45
+		}
46
+	}
47 47
 
48
-    /**
49
-     * @return int
50
-     */
51
-    protected function getPostId()
52
-    {
53
-        return intval(filter_input(INPUT_GET, 'post'));
54
-    }
48
+	/**
49
+	 * @return int
50
+	 */
51
+	protected function getPostId()
52
+	{
53
+		return intval(filter_input(INPUT_GET, 'post'));
54
+	}
55 55
 
56
-    /**
57
-     * @param int $postId
58
-     * @return bool
59
-     */
60
-    protected function isReviewPostId($postId)
61
-    {
62
-        return Application::POST_TYPE == get_post_field('post_type', $postId);
63
-    }
56
+	/**
57
+	 * @param int $postId
58
+	 * @return bool
59
+	 */
60
+	protected function isReviewPostId($postId)
61
+	{
62
+		return Application::POST_TYPE == get_post_field('post_type', $postId);
63
+	}
64 64
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -13,15 +13,15 @@  discard block
 block discarded – undo
13 13
     /**
14 14
      * @return void
15 15
      */
16
-    public function download($filename, $content)
16
+    public function download( $filename, $content )
17 17
     {
18
-        if (!current_user_can(glsr()->constant('CAPABILITY'))) {
18
+        if( !current_user_can( glsr()->constant( 'CAPABILITY' ) ) ) {
19 19
             return;
20 20
         }
21 21
         nocache_headers();
22
-        header('Content-Type: text/plain');
23
-        header('Content-Disposition: attachment; filename="'.$filename.'"');
24
-        echo html_entity_decode($content);
22
+        header( 'Content-Type: text/plain' );
23
+        header( 'Content-Disposition: attachment; filename="'.$filename.'"' );
24
+        echo html_entity_decode( $content );
25 25
         exit;
26 26
     }
27 27
 
@@ -30,18 +30,18 @@  discard block
 block discarded – undo
30 30
      * @return mixed
31 31
      * @throws InvalidArgumentException
32 32
      */
33
-    public function execute($command)
33
+    public function execute( $command )
34 34
     {
35
-        $handlerClass = str_replace('Commands', 'Handlers', get_class($command));
36
-        if (!class_exists($handlerClass)) {
37
-            throw new InvalidArgumentException('Handler '.$handlerClass.' not found.');
35
+        $handlerClass = str_replace( 'Commands', 'Handlers', get_class( $command ) );
36
+        if( !class_exists( $handlerClass ) ) {
37
+            throw new InvalidArgumentException( 'Handler '.$handlerClass.' not found.' );
38 38
         }
39 39
         try {
40
-            return glsr($handlerClass)->handle($command);
41
-        } catch (Exception $e) {
42
-            status_header(400);
43
-            glsr(Notice::class)->addError(new WP_Error('site_reviews_error', $e->getMessage()));
44
-            glsr_log()->error($e->getMessage());
40
+            return glsr( $handlerClass )->handle( $command );
41
+        } catch( Exception $e ) {
42
+            status_header( 400 );
43
+            glsr( Notice::class )->addError( new WP_Error( 'site_reviews_error', $e->getMessage() ) );
44
+            glsr_log()->error( $e->getMessage() );
45 45
         }
46 46
     }
47 47
 
@@ -50,15 +50,15 @@  discard block
 block discarded – undo
50 50
      */
51 51
     protected function getPostId()
52 52
     {
53
-        return intval(filter_input(INPUT_GET, 'post'));
53
+        return intval( filter_input( INPUT_GET, 'post' ) );
54 54
     }
55 55
 
56 56
     /**
57 57
      * @param int $postId
58 58
      * @return bool
59 59
      */
60
-    protected function isReviewPostId($postId)
60
+    protected function isReviewPostId( $postId )
61 61
     {
62
-        return Application::POST_TYPE == get_post_field('post_type', $postId);
62
+        return Application::POST_TYPE == get_post_field( 'post_type', $postId );
63 63
     }
64 64
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,8 @@
 block discarded – undo
38 38
         }
39 39
         try {
40 40
             return glsr($handlerClass)->handle($command);
41
-        } catch (Exception $e) {
41
+        }
42
+        catch (Exception $e) {
42 43
             status_header(400);
43 44
             glsr(Notice::class)->addError(new WP_Error('site_reviews_error', $e->getMessage()));
44 45
             glsr_log()->error($e->getMessage());
Please login to merge, or discard this patch.