Passed
Push — feature/rebusify ( 0fe5b2...103190 )
by Paul
08:37 queued 03:55
created
plugin/Widgets/SiteReviewsWidget.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -11,65 +11,65 @@  discard block
 block discarded – undo
11 11
      * @param array $instance
12 12
      * @return void
13 13
      */
14
-    public function form($instance)
14
+    public function form( $instance )
15 15
     {
16
-        $this->widgetArgs = glsr(SiteReviewsShortcode::class)->normalizeAtts($instance);
17
-        $terms = glsr(Database::class)->getTerms();
18
-        $this->renderField('text', [
16
+        $this->widgetArgs = glsr( SiteReviewsShortcode::class )->normalizeAtts( $instance );
17
+        $terms = glsr( Database::class )->getTerms();
18
+        $this->renderField( 'text', [
19 19
             'class' => 'widefat',
20
-            'label' => __('Title', 'site-reviews'),
20
+            'label' => __( 'Title', 'site-reviews' ),
21 21
             'name' => 'title',
22
-        ]);
23
-        $this->renderField('number', [
22
+        ] );
23
+        $this->renderField( 'number', [
24 24
             'class' => 'small-text',
25 25
             'default' => 5,
26
-            'label' => __('How many reviews would you like to display?', 'site-reviews'),
26
+            'label' => __( 'How many reviews would you like to display?', 'site-reviews' ),
27 27
             'max' => 100,
28 28
             'name' => 'count',
29
-        ]);
30
-        $this->renderField('select', [
31
-            'label' => __('What is the minimum rating to display?', 'site-reviews'),
29
+        ] );
30
+        $this->renderField( 'select', [
31
+            'label' => __( 'What is the minimum rating to display?', 'site-reviews' ),
32 32
             'name' => 'rating',
33 33
             'options' => [
34
-                '5' => sprintf(_n('%s star', '%s stars', 5, 'site-reviews'), 5),
35
-                '4' => sprintf(_n('%s star', '%s stars', 4, 'site-reviews'), 4),
36
-                '3' => sprintf(_n('%s star', '%s stars', 3, 'site-reviews'), 3),
37
-                '2' => sprintf(_n('%s star', '%s stars', 2, 'site-reviews'), 2),
38
-                '1' => sprintf(_n('%s star', '%s stars', 1, 'site-reviews'), 1),
34
+                '5' => sprintf( _n( '%s star', '%s stars', 5, 'site-reviews' ), 5 ),
35
+                '4' => sprintf( _n( '%s star', '%s stars', 4, 'site-reviews' ), 4 ),
36
+                '3' => sprintf( _n( '%s star', '%s stars', 3, 'site-reviews' ), 3 ),
37
+                '2' => sprintf( _n( '%s star', '%s stars', 2, 'site-reviews' ), 2 ),
38
+                '1' => sprintf( _n( '%s star', '%s stars', 1, 'site-reviews' ), 1 ),
39 39
             ],
40
-        ]);
41
-        if (count(glsr()->reviewTypes) > 1) {
42
-            $this->renderField('select', [
40
+        ] );
41
+        if( count( glsr()->reviewTypes ) > 1 ) {
42
+            $this->renderField( 'select', [
43 43
                 'class' => 'widefat',
44
-                'label' => __('Which type of review would you like to display?', 'site-reviews'),
44
+                'label' => __( 'Which type of review would you like to display?', 'site-reviews' ),
45 45
                 'name' => 'type',
46
-                'options' => ['' => __('All Reviews', 'site-reviews')] + glsr()->reviewTypes,
47
-            ]);
46
+                'options' => ['' => __( 'All Reviews', 'site-reviews' )] + glsr()->reviewTypes,
47
+            ] );
48 48
         }
49
-        if (!empty($terms)) {
50
-            $this->renderField('select', [
49
+        if( !empty($terms) ) {
50
+            $this->renderField( 'select', [
51 51
                 'class' => 'widefat',
52
-                'label' => __('Limit reviews to this category', 'site-reviews'),
52
+                'label' => __( 'Limit reviews to this category', 'site-reviews' ),
53 53
                 'name' => 'category',
54
-                'options' => ['' => __('All Categories', 'site-reviews')] + $terms,
55
-            ]);
54
+                'options' => ['' => __( 'All Categories', 'site-reviews' )] + $terms,
55
+            ] );
56 56
         }
57
-        $this->renderField('text', [
57
+        $this->renderField( 'text', [
58 58
             'class' => 'widefat',
59 59
             'default' => '',
60
-            'description' => sprintf(__("Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews'), '<code>post_id</code>'),
61
-            'label' => __('Limit reviews to those assigned to this page/post ID', 'site-reviews'),
60
+            'description' => sprintf( __( "Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews' ), '<code>post_id</code>' ),
61
+            'label' => __( 'Limit reviews to those assigned to this page/post ID', 'site-reviews' ),
62 62
             'name' => 'assigned_to',
63
-        ]);
64
-        $this->renderField('text', [
63
+        ] );
64
+        $this->renderField( 'text', [
65 65
             'class' => 'widefat',
66
-            'label' => __('Enter any custom CSS classes here', 'site-reviews'),
66
+            'label' => __( 'Enter any custom CSS classes here', 'site-reviews' ),
67 67
             'name' => 'class',
68
-        ]);
69
-        $this->renderField('checkbox', [
68
+        ] );
69
+        $this->renderField( 'checkbox', [
70 70
             'name' => 'hide',
71
-            'options' => glsr(SiteReviewsShortcode::class)->getHideOptions(),
72
-        ]);
71
+            'options' => glsr( SiteReviewsShortcode::class )->getHideOptions(),
72
+        ] );
73 73
     }
74 74
 
75 75
     /**
@@ -77,13 +77,13 @@  discard block
 block discarded – undo
77 77
      * @param array $oldInstance
78 78
      * @return array
79 79
      */
80
-    public function update($newInstance, $oldInstance)
80
+    public function update( $newInstance, $oldInstance )
81 81
     {
82
-        if (!is_numeric($newInstance['count'])) {
82
+        if( !is_numeric( $newInstance['count'] ) ) {
83 83
             $newInstance['count'] = 10;
84 84
         }
85
-        $newInstance['count'] = min(50, max(0, intval($newInstance['count'])));
86
-        return parent::update($newInstance, $oldInstance);
85
+        $newInstance['count'] = min( 50, max( 0, intval( $newInstance['count'] ) ) );
86
+        return parent::update( $newInstance, $oldInstance );
87 87
     }
88 88
 
89 89
     /**
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
      * @param array $instance
92 92
      * @return void
93 93
      */
94
-    public function widget($args, $instance)
94
+    public function widget( $args, $instance )
95 95
     {
96
-        echo glsr(SiteReviewsShortcode::class)->build($instance, $args, 'widget');
96
+        echo glsr( SiteReviewsShortcode::class )->build( $instance, $args, 'widget' );
97 97
     }
98 98
 }
Please login to merge, or discard this patch.
plugin/Widgets/SiteReviewsFormWidget.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -11,42 +11,42 @@  discard block
 block discarded – undo
11 11
      * @param array $instance
12 12
      * @return void
13 13
      */
14
-    public function form($instance)
14
+    public function form( $instance )
15 15
     {
16
-        $this->widgetArgs = glsr(SiteReviewsFormShortcode::class)->normalizeAtts($instance);
17
-        $terms = glsr(Database::class)->getTerms();
18
-        $this->renderField('text', [
16
+        $this->widgetArgs = glsr( SiteReviewsFormShortcode::class )->normalizeAtts( $instance );
17
+        $terms = glsr( Database::class )->getTerms();
18
+        $this->renderField( 'text', [
19 19
             'class' => 'widefat',
20
-            'label' => __('Title', 'site-reviews'),
20
+            'label' => __( 'Title', 'site-reviews' ),
21 21
             'name' => 'title',
22
-        ]);
23
-        $this->renderField('textarea', [
22
+        ] );
23
+        $this->renderField( 'textarea', [
24 24
             'class' => 'widefat',
25
-            'label' => __('Description', 'site-reviews'),
25
+            'label' => __( 'Description', 'site-reviews' ),
26 26
             'name' => 'description',
27
-        ]);
28
-        $this->renderField('select', [
27
+        ] );
28
+        $this->renderField( 'select', [
29 29
             'class' => 'widefat',
30
-            'label' => __('Automatically assign a category', 'site-reviews'),
30
+            'label' => __( 'Automatically assign a category', 'site-reviews' ),
31 31
             'name' => 'category',
32
-            'options' => ['' => __('Do not assign a category', 'site-reviews')] + $terms,
33
-        ]);
34
-        $this->renderField('text', [
32
+            'options' => ['' => __( 'Do not assign a category', 'site-reviews' )] + $terms,
33
+        ] );
34
+        $this->renderField( 'text', [
35 35
             'class' => 'widefat',
36 36
             'default' => '',
37
-            'description' => sprintf(__('You may also enter %s to assign to the current post.', 'site-reviews'), '<code>post_id</code>'),
38
-            'label' => __('Assign reviews to a custom page/post ID', 'site-reviews'),
37
+            'description' => sprintf( __( 'You may also enter %s to assign to the current post.', 'site-reviews' ), '<code>post_id</code>' ),
38
+            'label' => __( 'Assign reviews to a custom page/post ID', 'site-reviews' ),
39 39
             'name' => 'assign_to',
40
-        ]);
41
-        $this->renderField('text', [
40
+        ] );
41
+        $this->renderField( 'text', [
42 42
             'class' => 'widefat',
43
-            'label' => __('Enter any custom CSS classes here', 'site-reviews'),
43
+            'label' => __( 'Enter any custom CSS classes here', 'site-reviews' ),
44 44
             'name' => 'class',
45
-        ]);
46
-        $this->renderField('checkbox', [
45
+        ] );
46
+        $this->renderField( 'checkbox', [
47 47
             'name' => 'hide',
48
-            'options' => glsr(SiteReviewsFormShortcode::class)->getHideOptions(),
49
-        ]);
48
+            'options' => glsr( SiteReviewsFormShortcode::class )->getHideOptions(),
49
+        ] );
50 50
     }
51 51
 
52 52
     /**
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
      * @param array $instance
55 55
      * @return void
56 56
      */
57
-    public function widget($args, $instance)
57
+    public function widget( $args, $instance )
58 58
     {
59
-        echo glsr(SiteReviewsFormShortcode::class)->build($instance, $args, 'widget');
59
+        echo glsr( SiteReviewsFormShortcode::class )->build( $instance, $args, 'widget' );
60 60
     }
61 61
 }
Please login to merge, or discard this patch.
plugin/Widgets/SiteReviewsSummaryWidget.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -11,47 +11,47 @@  discard block
 block discarded – undo
11 11
      * @param array $instance
12 12
      * @return void
13 13
      */
14
-    public function form($instance)
14
+    public function form( $instance )
15 15
     {
16
-        $this->widgetArgs = glsr(SiteReviewsSummaryShortcode::class)->normalizeAtts($instance);
17
-        $terms = glsr(Database::class)->getTerms();
18
-        $this->renderField('text', [
16
+        $this->widgetArgs = glsr( SiteReviewsSummaryShortcode::class )->normalizeAtts( $instance );
17
+        $terms = glsr( Database::class )->getTerms();
18
+        $this->renderField( 'text', [
19 19
             'class' => 'widefat',
20
-            'label' => __('Title', 'site-reviews'),
20
+            'label' => __( 'Title', 'site-reviews' ),
21 21
             'name' => 'title',
22
-        ]);
23
-        if (count(glsr()->reviewTypes) > 1) {
24
-            $this->renderField('select', [
22
+        ] );
23
+        if( count( glsr()->reviewTypes ) > 1 ) {
24
+            $this->renderField( 'select', [
25 25
                 'class' => 'widefat',
26
-                'label' => __('Which type of review would you like to use?', 'site-reviews'),
26
+                'label' => __( 'Which type of review would you like to use?', 'site-reviews' ),
27 27
                 'name' => 'type',
28
-                'options' => ['' => __('All review types', 'site-reviews')] + glsr()->reviewTypes,
29
-            ]);
28
+                'options' => ['' => __( 'All review types', 'site-reviews' )] + glsr()->reviewTypes,
29
+            ] );
30 30
         }
31
-        if (!empty($terms)) {
32
-            $this->renderField('select', [
31
+        if( !empty($terms) ) {
32
+            $this->renderField( 'select', [
33 33
                 'class' => 'widefat',
34
-                'label' => __('Limit summary to this category', 'site-reviews'),
34
+                'label' => __( 'Limit summary to this category', 'site-reviews' ),
35 35
                 'name' => 'category',
36
-                'options' => ['' => __('All Categories', 'site-reviews')] + $terms,
37
-            ]);
36
+                'options' => ['' => __( 'All Categories', 'site-reviews' )] + $terms,
37
+            ] );
38 38
         }
39
-        $this->renderField('text', [
39
+        $this->renderField( 'text', [
40 40
             'class' => 'widefat',
41 41
             'default' => '',
42
-            'description' => sprintf(__("Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews'), '<code>post_id</code>'),
43
-            'label' => __('Limit summary to reviews assigned to a page/post ID', 'site-reviews'),
42
+            'description' => sprintf( __( "Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews' ), '<code>post_id</code>' ),
43
+            'label' => __( 'Limit summary to reviews assigned to a page/post ID', 'site-reviews' ),
44 44
             'name' => 'assigned_to',
45
-        ]);
46
-        $this->renderField('text', [
45
+        ] );
46
+        $this->renderField( 'text', [
47 47
             'class' => 'widefat',
48
-            'label' => __('Enter any custom CSS classes here', 'site-reviews'),
48
+            'label' => __( 'Enter any custom CSS classes here', 'site-reviews' ),
49 49
             'name' => 'class',
50
-        ]);
51
-        $this->renderField('checkbox', [
50
+        ] );
51
+        $this->renderField( 'checkbox', [
52 52
             'name' => 'hide',
53
-            'options' => glsr(SiteReviewsSummaryShortcode::class)->getHideOptions(),
54
-        ]);
53
+            'options' => glsr( SiteReviewsSummaryShortcode::class )->getHideOptions(),
54
+        ] );
55 55
     }
56 56
 
57 57
     /**
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
      * @param array $instance
60 60
      * @return void
61 61
      */
62
-    public function widget($args, $instance)
62
+    public function widget( $args, $instance )
63 63
     {
64
-        echo glsr(SiteReviewsSummaryShortcode::class)->build($instance, $args, 'widget');
64
+        echo glsr( SiteReviewsSummaryShortcode::class )->build( $instance, $args, 'widget' );
65 65
     }
66 66
 }
Please login to merge, or discard this patch.
plugin/Router.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@  discard block
 block discarded – undo
13 13
 
14 14
     public function __construct()
15 15
     {
16
-        $this->unguardedActions = apply_filters('site-reviews/router/unguarded-actions', [
16
+        $this->unguardedActions = apply_filters( 'site-reviews/router/unguarded-actions', [
17 17
             'fetch-paged-reviews',
18
-        ]);
18
+        ] );
19 19
     }
20 20
 
21 21
     /**
@@ -24,11 +24,11 @@  discard block
 block discarded – undo
24 24
     public function routeAdminPostRequest()
25 25
     {
26 26
         $request = $this->getRequest();
27
-        if (!$this->isValidPostRequest($request)) {
27
+        if( !$this->isValidPostRequest( $request ) ) {
28 28
             return;
29 29
         }
30
-        check_admin_referer($request['_action']);
31
-        $this->routeRequest('admin', $request['_action'], $request);
30
+        check_admin_referer( $request['_action'] );
31
+        $this->routeRequest( 'admin', $request['_action'], $request );
32 32
     }
33 33
 
34 34
     /**
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
     public function routeAjaxRequest()
38 38
     {
39 39
         $request = $this->getRequest();
40
-        $this->checkAjaxRequest($request);
41
-        $this->checkAjaxNonce($request);
42
-        $this->routeRequest('ajax', $request['_action'], $request);
40
+        $this->checkAjaxRequest( $request );
41
+        $this->checkAjaxNonce( $request );
42
+        $this->routeRequest( 'ajax', $request['_action'], $request );
43 43
         wp_die();
44 44
     }
45 45
 
@@ -48,45 +48,45 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function routePublicPostRequest()
50 50
     {
51
-        if (is_admin()) {
51
+        if( is_admin() ) {
52 52
             return;
53 53
         }
54 54
         $request = $this->getRequest();
55
-        if (!$this->isValidPostRequest($request)) {
55
+        if( !$this->isValidPostRequest( $request ) ) {
56 56
             return;
57 57
         }
58
-        if (!$this->isValidPublicNonce($request)) {
58
+        if( !$this->isValidPublicNonce( $request ) ) {
59 59
             return;
60 60
         }
61
-        $this->routeRequest('public', $request['_action'], $request);
61
+        $this->routeRequest( 'public', $request['_action'], $request );
62 62
     }
63 63
 
64 64
     /**
65 65
      * @return void
66 66
      */
67
-    protected function checkAjaxNonce(array $request)
67
+    protected function checkAjaxNonce( array $request )
68 68
     {
69
-        if (!is_user_logged_in() || in_array(glsr_get($request, '_action'), $this->unguardedActions)) {
69
+        if( !is_user_logged_in() || in_array( glsr_get( $request, '_action' ), $this->unguardedActions ) ) {
70 70
             return;
71 71
         }
72
-        if (!isset($request['_nonce'])) {
73
-            $this->sendAjaxError('request is missing a nonce', $request);
72
+        if( !isset($request['_nonce']) ) {
73
+            $this->sendAjaxError( 'request is missing a nonce', $request );
74 74
         }
75
-        if (!wp_verify_nonce($request['_nonce'], $request['_action'])) {
76
-            $this->sendAjaxError('request failed the nonce check', $request, 403);
75
+        if( !wp_verify_nonce( $request['_nonce'], $request['_action'] ) ) {
76
+            $this->sendAjaxError( 'request failed the nonce check', $request, 403 );
77 77
         }
78 78
     }
79 79
 
80 80
     /**
81 81
      * @return void
82 82
      */
83
-    protected function checkAjaxRequest(array $request)
83
+    protected function checkAjaxRequest( array $request )
84 84
     {
85
-        if (!isset($request['_action'])) {
86
-            $this->sendAjaxError('request must include an action', $request);
85
+        if( !isset($request['_action']) ) {
86
+            $this->sendAjaxError( 'request must include an action', $request );
87 87
         }
88
-        if (empty($request['_ajax_request'])) {
89
-            $this->sendAjaxError('request is invalid', $request);
88
+        if( empty($request['_ajax_request']) ) {
89
+            $this->sendAjaxError( 'request is invalid', $request );
90 90
         }
91 91
     }
92 92
 
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
      */
98 98
     protected function getRequest()
99 99
     {
100
-        $request = glsr(Helper::class)->filterInputArray(Application::ID);
101
-        if (glsr(Helper::class)->filterInput('action') == Application::PREFIX.'action') {
100
+        $request = glsr( Helper::class )->filterInputArray( Application::ID );
101
+        if( glsr( Helper::class )->filterInput( 'action' ) == Application::PREFIX.'action' ) {
102 102
             $request['_ajax_request'] = true;
103 103
         }
104
-        if ('submit-review' == glsr(Helper::class)->filterInput('_action', $request)) {
105
-            $request['_recaptcha-token'] = glsr(Helper::class)->filterInput('g-recaptcha-response');
104
+        if( 'submit-review' == glsr( Helper::class )->filterInput( '_action', $request ) ) {
105
+            $request['_recaptcha-token'] = glsr( Helper::class )->filterInput( 'g-recaptcha-response' );
106 106
         }
107 107
         return $request;
108 108
     }
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
     /**
111 111
      * @return bool
112 112
      */
113
-    protected function isValidPostRequest(array $request = [])
113
+    protected function isValidPostRequest( array $request = [] )
114 114
     {
115 115
         return !empty($request['_action']) && empty($request['_ajax_request']);
116 116
     }
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
     /**
119 119
      * @return bool
120 120
      */
121
-    protected function isValidPublicNonce(array $request)
121
+    protected function isValidPublicNonce( array $request )
122 122
     {
123
-        if (is_user_logged_in() && !wp_verify_nonce($request['_nonce'], $request['_action'])) {
124
-            glsr_log()->error('nonce check failed for public request')->debug($request);
123
+        if( is_user_logged_in() && !wp_verify_nonce( $request['_nonce'], $request['_action'] ) ) {
124
+            glsr_log()->error( 'nonce check failed for public request' )->debug( $request );
125 125
             return false;
126 126
         }
127 127
         return true;
@@ -132,19 +132,19 @@  discard block
 block discarded – undo
132 132
      * @param string $action
133 133
      * @return void
134 134
      */
135
-    protected function routeRequest($type, $action, array $request = [])
135
+    protected function routeRequest( $type, $action, array $request = [] )
136 136
     {
137 137
         $actionHook = 'site-reviews/route/'.$type.'/request';
138
-        $controller = glsr(glsr(Helper::class)->buildClassName($type.'-controller', 'Controllers'));
139
-        $method = glsr(Helper::class)->buildMethodName($action, 'router');
140
-        $request = apply_filters('site-reviews/route/request', $request, $action, $type);
141
-        do_action($actionHook, $action, $request);
142
-        if (is_callable([$controller, $method])) {
143
-            call_user_func([$controller, $method], $request);
138
+        $controller = glsr( glsr( Helper::class )->buildClassName( $type.'-controller', 'Controllers' ) );
139
+        $method = glsr( Helper::class )->buildMethodName( $action, 'router' );
140
+        $request = apply_filters( 'site-reviews/route/request', $request, $action, $type );
141
+        do_action( $actionHook, $action, $request );
142
+        if( is_callable( [$controller, $method] ) ) {
143
+            call_user_func( [$controller, $method], $request );
144 144
             return;
145 145
         }
146
-        if (0 === did_action($actionHook)) {
147
-            glsr_log('Unknown '.$type.' router request: '.$action);
146
+        if( 0 === did_action( $actionHook ) ) {
147
+            glsr_log( 'Unknown '.$type.' router request: '.$action );
148 148
         }
149 149
     }
150 150
 
@@ -153,14 +153,14 @@  discard block
 block discarded – undo
153 153
      * @param int $statusCode
154 154
      * @return void
155 155
      */
156
-    protected function sendAjaxError($error, array $request, $statusCode = 400)
156
+    protected function sendAjaxError( $error, array $request, $statusCode = 400 )
157 157
     {
158
-        glsr_log()->error($error)->debug($request);
159
-        glsr(Notice::class)->addError(__('There was an error (try reloading the page).', 'site-reviews').' <code>'.$error.'</code>');
160
-        wp_send_json_error([
161
-            'message' => __('The form could not be submitted. Please notify the site administrator.', 'site-reviews'),
162
-            'notices' => glsr(Notice::class)->get(),
158
+        glsr_log()->error( $error )->debug( $request );
159
+        glsr( Notice::class )->addError( __( 'There was an error (try reloading the page).', 'site-reviews' ).' <code>'.$error.'</code>' );
160
+        wp_send_json_error( [
161
+            'message' => __( 'The form could not be submitted. Please notify the site administrator.', 'site-reviews' ),
162
+            'notices' => glsr( Notice::class )->get(),
163 163
             'error' => $error,
164
-        ]);
164
+        ] );
165 165
     }
166 166
 }
Please login to merge, or discard this patch.
plugin/Container.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public static function load()
45 45
     {
46
-        if (empty(static::$instance)) {
46
+        if( empty(static::$instance) ) {
47 47
             static::$instance = new static();
48 48
         }
49 49
         return static::$instance;
@@ -53,16 +53,16 @@  discard block
 block discarded – undo
53 53
      * @param string $property
54 54
      * @return mixed
55 55
      */
56
-    public function __get($property)
56
+    public function __get( $property )
57 57
     {
58
-        if (property_exists($this, $property) && !in_array($property, static::PROTECTED_PROPERTIES)) {
58
+        if( property_exists( $this, $property ) && !in_array( $property, static::PROTECTED_PROPERTIES ) ) {
59 59
             return $this->$property;
60 60
         }
61
-        $constant = 'static::'.strtoupper($this->make(Helper::class)->snakeCase($property));
62
-        if (defined($constant)) {
63
-            return constant($constant);
61
+        $constant = 'static::'.strtoupper( $this->make( Helper::class )->snakeCase( $property ) );
62
+        if( defined( $constant ) ) {
63
+            return constant( $constant );
64 64
         }
65
-        return glsr_get($this->storage, $property, null);
65
+        return glsr_get( $this->storage, $property, null );
66 66
     }
67 67
 
68 68
     /**
@@ -70,14 +70,14 @@  discard block
 block discarded – undo
70 70
      * @param string $value
71 71
      * @return void
72 72
      */
73
-    public function __set($property, $value)
73
+    public function __set( $property, $value )
74 74
     {
75
-        if (!property_exists($this, $property) || in_array($property, static::PROTECTED_PROPERTIES)) {
75
+        if( !property_exists( $this, $property ) || in_array( $property, static::PROTECTED_PROPERTIES ) ) {
76 76
             $this->storage[$property] = $value;
77
-        } elseif (!isset($this->$property)) {
77
+        } elseif( !isset($this->$property) ) {
78 78
             $this->$property = $value;
79 79
         } else {
80
-            throw new Exception(sprintf('The "%s" property cannot be changed once set.', $property));
80
+            throw new Exception( sprintf( 'The "%s" property cannot be changed once set.', $property ) );
81 81
         }
82 82
     }
83 83
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
      * @param mixed $concrete
88 88
      * @return mixed
89 89
      */
90
-    public function bind($alias, $concrete)
90
+    public function bind( $alias, $concrete )
91 91
     {
92 92
         $this->services[$alias] = $concrete;
93 93
     }
@@ -97,21 +97,21 @@  discard block
 block discarded – undo
97 97
      * @param mixed $abstract
98 98
      * @return mixed
99 99
      */
100
-    public function make($abstract)
100
+    public function make( $abstract )
101 101
     {
102
-        if (!isset($this->services[$abstract])) {
103
-            $abstract = $this->addNamespace($abstract);
102
+        if( !isset($this->services[$abstract]) ) {
103
+            $abstract = $this->addNamespace( $abstract );
104 104
         }
105
-        if (isset($this->services[$abstract])) {
105
+        if( isset($this->services[$abstract]) ) {
106 106
             $abstract = $this->services[$abstract];
107 107
         }
108
-        if (is_callable($abstract)) {
109
-            return call_user_func_array($abstract, [$this]);
108
+        if( is_callable( $abstract ) ) {
109
+            return call_user_func_array( $abstract, [$this] );
110 110
         }
111
-        if (is_object($abstract)) {
111
+        if( is_object( $abstract ) ) {
112 112
             return $abstract;
113 113
         }
114
-        return $this->resolve($abstract);
114
+        return $this->resolve( $abstract );
115 115
     }
116 116
 
117 117
     /**
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
     /**
126 126
      * @return mixed
127 127
      */
128
-    public function sessionGet($key, $fallback = '')
128
+    public function sessionGet( $key, $fallback = '' )
129 129
     {
130
-        $value = glsr_get($this->session, $key, $fallback);
130
+        $value = glsr_get( $this->session, $key, $fallback );
131 131
         unset($this->session[$key]);
132 132
         return $value;
133 133
     }
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
     /**
136 136
      * @return void
137 137
      */
138
-    public function sessionSet($key, $value)
138
+    public function sessionSet( $key, $value )
139 139
     {
140 140
         $this->session[$key] = $value;
141 141
     }
@@ -146,9 +146,9 @@  discard block
 block discarded – undo
146 146
      * @param callable|string|null $binding
147 147
      * @return void
148 148
      */
149
-    public function singleton($alias, $binding)
149
+    public function singleton( $alias, $binding )
150 150
     {
151
-        $this->bind($alias, $this->make($binding));
151
+        $this->bind( $alias, $this->make( $binding ) );
152 152
     }
153 153
 
154 154
     /**
@@ -156,9 +156,9 @@  discard block
 block discarded – undo
156 156
      * @param string $abstract
157 157
      * @return string
158 158
      */
159
-    protected function addNamespace($abstract)
159
+    protected function addNamespace( $abstract )
160 160
     {
161
-        if (false === strpos($abstract, __NAMESPACE__) && !class_exists($abstract)) {
161
+        if( false === strpos( $abstract, __NAMESPACE__ ) && !class_exists( $abstract ) ) {
162 162
             $abstract = __NAMESPACE__.'\\'.$abstract;
163 163
         }
164 164
         return $abstract;
@@ -170,21 +170,21 @@  discard block
 block discarded – undo
170 170
      * @return mixed
171 171
      * @throws Exception
172 172
      */
173
-    protected function resolve($concrete)
173
+    protected function resolve( $concrete )
174 174
     {
175
-        if ($concrete instanceof Closure) {
176
-            return $concrete($this);
175
+        if( $concrete instanceof Closure ) {
176
+            return $concrete( $this );
177 177
         }
178
-        $reflector = new ReflectionClass($concrete);
179
-        if (!$reflector->isInstantiable()) {
180
-            throw new Exception('Target ['.$concrete.'] is not instantiable.');
178
+        $reflector = new ReflectionClass( $concrete );
179
+        if( !$reflector->isInstantiable() ) {
180
+            throw new Exception( 'Target ['.$concrete.'] is not instantiable.' );
181 181
         }
182 182
         $constructor = $reflector->getConstructor();
183
-        if (empty($constructor)) {
183
+        if( empty($constructor) ) {
184 184
             return new $concrete();
185 185
         }
186 186
         return $reflector->newInstanceArgs(
187
-            $this->resolveDependencies($constructor->getParameters())
187
+            $this->resolveDependencies( $constructor->getParameters() )
188 188
         );
189 189
     }
190 190
 
@@ -193,12 +193,12 @@  discard block
 block discarded – undo
193 193
      * @return mixed
194 194
      * @throws Exception
195 195
      */
196
-    protected function resolveClass(ReflectionParameter $parameter)
196
+    protected function resolveClass( ReflectionParameter $parameter )
197 197
     {
198 198
         try {
199
-            return $this->make($parameter->getClass()->name);
200
-        } catch (Exception $error) {
201
-            if ($parameter->isOptional()) {
199
+            return $this->make( $parameter->getClass()->name );
200
+        } catch( Exception $error ) {
201
+            if( $parameter->isOptional() ) {
202 202
                 return $parameter->getDefaultValue();
203 203
             }
204 204
             throw $error;
@@ -209,13 +209,13 @@  discard block
 block discarded – undo
209 209
      * Resolve all of the dependencies from the ReflectionParameters.
210 210
      * @return array
211 211
      */
212
-    protected function resolveDependencies(array $dependencies)
212
+    protected function resolveDependencies( array $dependencies )
213 213
     {
214 214
         $results = [];
215
-        foreach ($dependencies as $dependency) {
216
-            $results[] = !is_null($class = $dependency->getClass())
217
-                ? $this->resolveClass($dependency)
218
-                : $this->resolveDependency($dependency);
215
+        foreach( $dependencies as $dependency ) {
216
+            $results[] = !is_null( $class = $dependency->getClass() )
217
+                ? $this->resolveClass( $dependency )
218
+                : $this->resolveDependency( $dependency );
219 219
         }
220 220
         return $results;
221 221
     }
@@ -224,9 +224,9 @@  discard block
 block discarded – undo
224 224
      * Resolve a single ReflectionParameter dependency.
225 225
      * @return array|null
226 226
      */
227
-    protected function resolveDependency(ReflectionParameter $parameter)
227
+    protected function resolveDependency( ReflectionParameter $parameter )
228 228
     {
229
-        if ($parameter->isArray() && $parameter->isDefaultValueAvailable()) {
229
+        if( $parameter->isArray() && $parameter->isDefaultValueAvailable() ) {
230 230
             return $parameter->getDefaultValue();
231 231
         }
232 232
         return null;
Please login to merge, or discard this patch.
plugin/Controllers/EditorController/Labels.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
     {
15 15
         global $wp_scripts;
16 16
         $strings = [
17
-            'savePending' => __('Save as Unapproved', 'site-reviews'),
18
-            'published' => __('Approved', 'site-reviews'),
17
+            'savePending' => __( 'Save as Unapproved', 'site-reviews' ),
18
+            'published' => __( 'Approved', 'site-reviews' ),
19 19
         ];
20
-        if ($this->canModifyTranslation() && isset($wp_scripts->registered['post']->extra['data'])) {
20
+        if( $this->canModifyTranslation() && isset($wp_scripts->registered['post']->extra['data']) ) {
21 21
             $l10n = &$wp_scripts->registered['post']->extra['data'];
22
-            foreach ($strings as $search => $replace) {
23
-                $l10n = preg_replace('/("'.$search.'":")([^"]+)/', '$1'.$replace, $l10n);
22
+            foreach( $strings as $search => $replace ) {
23
+                $l10n = preg_replace( '/("'.$search.'":")([^"]+)/', '$1'.$replace, $l10n );
24 24
             }
25 25
         }
26 26
     }
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
      * @param string $domain
32 32
      * @return string
33 33
      */
34
-    public function filterPostStatusLabels($translation, $text, $domain)
34
+    public function filterPostStatusLabels( $translation, $text, $domain )
35 35
     {
36
-        if ($this->canModifyTranslation($domain)) {
36
+        if( $this->canModifyTranslation( $domain ) ) {
37 37
             $replacements = $this->getStatusLabels();
38
-            if (array_key_exists($text, $replacements)) {
38
+            if( array_key_exists( $text, $replacements ) ) {
39 39
                 $translation = $replacements[$text];
40 40
             }
41 41
         }
@@ -45,18 +45,18 @@  discard block
 block discarded – undo
45 45
     /**
46 46
      * @return array
47 47
      */
48
-    public function filterUpdateMessages(array $messages)
48
+    public function filterUpdateMessages( array $messages )
49 49
     {
50 50
         $post = get_post();
51
-        if (!($post instanceof WP_Post)) {
51
+        if( !($post instanceof WP_Post) ) {
52 52
             return;
53 53
         }
54 54
         $strings = $this->getReviewLabels();
55
-        $restored = filter_input(INPUT_GET, 'revision');
56
-        if ($revisionTitle = wp_post_revision_title(intval($restored), false)) {
57
-            $restored = sprintf($strings['restored'], $revisionTitle);
55
+        $restored = filter_input( INPUT_GET, 'revision' );
56
+        if( $revisionTitle = wp_post_revision_title( intval( $restored ), false ) ) {
57
+            $restored = sprintf( $strings['restored'], $revisionTitle );
58 58
         }
59
-        $scheduled_date = date_i18n('M j, Y @ H:i', strtotime($post->post_date));
59
+        $scheduled_date = date_i18n( 'M j, Y @ H:i', strtotime( $post->post_date ) );
60 60
         $messages[Application::POST_TYPE] = [
61 61
              1 => $strings['updated'],
62 62
              4 => $strings['updated'],
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
              6 => $strings['published'],
65 65
              7 => $strings['saved'],
66 66
              8 => $strings['submitted'],
67
-             9 => sprintf($strings['scheduled'], '<strong>'.$scheduled_date.'</strong>'),
67
+             9 => sprintf( $strings['scheduled'], '<strong>'.$scheduled_date.'</strong>' ),
68 68
             10 => $strings['draft_updated'],
69 69
             50 => $strings['approved'],
70 70
             51 => $strings['unapproved'],
@@ -77,13 +77,13 @@  discard block
 block discarded – undo
77 77
      * @param string $domain
78 78
      * @return bool
79 79
      */
80
-    protected function canModifyTranslation($domain = 'default')
80
+    protected function canModifyTranslation( $domain = 'default' )
81 81
     {
82
-        if ('default' != $domain || empty(glsr_current_screen()->base)) {
82
+        if( 'default' != $domain || empty(glsr_current_screen()->base) ) {
83 83
             return false;
84 84
         }
85 85
         return Application::POST_TYPE == glsr_current_screen()->post_type
86
-            && in_array(glsr_current_screen()->base, ['edit', 'post']);
86
+            && in_array( glsr_current_screen()->base, ['edit', 'post'] );
87 87
     }
88 88
 
89 89
     /**
@@ -92,18 +92,18 @@  discard block
 block discarded – undo
92 92
     protected function getReviewLabels()
93 93
     {
94 94
         return [
95
-            'approved' => __('Review has been approved and published.', 'site-reviews'),
96
-            'draft_updated' => __('Review draft updated.', 'site-reviews'),
97
-            'preview' => __('Preview review', 'site-reviews'),
98
-            'published' => __('Review approved and published.', 'site-reviews'),
99
-            'restored' => __('Review restored to revision from %s.', 'site-reviews'),
100
-            'reverted' => __('Review has been reverted to its original submission state (title, content, and submission date).', 'site-reviews'),
101
-            'saved' => __('Review saved.', 'site-reviews'),
102
-            'scheduled' => __('Review scheduled for: %s.', 'site-reviews'),
103
-            'submitted' => __('Review submitted.', 'site-reviews'),
104
-            'unapproved' => __('Review has been unapproved and is now pending.', 'site-reviews'),
105
-            'updated' => __('Review updated.', 'site-reviews'),
106
-            'view' => __('View review', 'site-reviews'),
95
+            'approved' => __( 'Review has been approved and published.', 'site-reviews' ),
96
+            'draft_updated' => __( 'Review draft updated.', 'site-reviews' ),
97
+            'preview' => __( 'Preview review', 'site-reviews' ),
98
+            'published' => __( 'Review approved and published.', 'site-reviews' ),
99
+            'restored' => __( 'Review restored to revision from %s.', 'site-reviews' ),
100
+            'reverted' => __( 'Review has been reverted to its original submission state (title, content, and submission date).', 'site-reviews' ),
101
+            'saved' => __( 'Review saved.', 'site-reviews' ),
102
+            'scheduled' => __( 'Review scheduled for: %s.', 'site-reviews' ),
103
+            'submitted' => __( 'Review submitted.', 'site-reviews' ),
104
+            'unapproved' => __( 'Review has been unapproved and is now pending.', 'site-reviews' ),
105
+            'updated' => __( 'Review updated.', 'site-reviews' ),
106
+            'view' => __( 'View review', 'site-reviews' ),
107 107
         ];
108 108
     }
109 109
 
@@ -114,14 +114,14 @@  discard block
 block discarded – undo
114 114
     protected function getStatusLabels()
115 115
     {
116 116
         static $labels;
117
-        if (empty($labels)) {
117
+        if( empty($labels) ) {
118 118
             $labels = [
119
-                'Pending' => __('Unapproved', 'site-reviews'),
120
-                'Pending Review' => __('Unapproved', 'site-reviews'),
121
-                'Privately Published' => __('Privately Approved', 'site-reviews'),
122
-                'Publish' => __('Approve', 'site-reviews'),
123
-                'Published' => __('Approved', 'site-reviews'),
124
-                'Save as Pending' => __('Save as Unapproved', 'site-reviews'),
119
+                'Pending' => __( 'Unapproved', 'site-reviews' ),
120
+                'Pending Review' => __( 'Unapproved', 'site-reviews' ),
121
+                'Privately Published' => __( 'Privately Approved', 'site-reviews' ),
122
+                'Publish' => __( 'Approve', 'site-reviews' ),
123
+                'Published' => __( 'Approved', 'site-reviews' ),
124
+                'Save as Pending' => __( 'Save as Unapproved', 'site-reviews' ),
125 125
             ];
126 126
         }
127 127
         return $labels;
Please login to merge, or discard this patch.
plugin/Controllers/MenuController.php 1 patch
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -20,20 +20,20 @@  discard block
 block discarded – undo
20 20
     public function registerMenuCount()
21 21
     {
22 22
         global $menu, $typenow;
23
-        foreach ($menu as $key => $value) {
24
-            if (!isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE) {
23
+        foreach( $menu as $key => $value ) {
24
+            if( !isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE ) {
25 25
                 continue;
26 26
             }
27
-            $postCount = wp_count_posts(Application::POST_TYPE);
28
-            $pendingCount = glsr(Builder::class)->span(number_format_i18n($postCount->pending), [
27
+            $postCount = wp_count_posts( Application::POST_TYPE );
28
+            $pendingCount = glsr( Builder::class )->span( number_format_i18n( $postCount->pending ), [
29 29
                 'class' => 'unapproved-count',
30
-            ]);
31
-            $awaitingModeration = glsr(Builder::class)->span($pendingCount, [
30
+            ] );
31
+            $awaitingModeration = glsr( Builder::class )->span( $pendingCount, [
32 32
                 'class' => 'awaiting-mod count-'.$postCount->pending,
33
-            ]);
34
-            $menu[$key][0].= ' '.$awaitingModeration;
35
-            if (Application::POST_TYPE === $typenow) {
36
-                $menu[$key][4].= ' current';
33
+            ] );
34
+            $menu[$key][0] .= ' '.$awaitingModeration;
35
+            if( Application::POST_TYPE === $typenow ) {
36
+                $menu[$key][4] .= ' current';
37 37
             }
38 38
             break;
39 39
         }
@@ -45,19 +45,19 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function registerSubMenus()
47 47
     {
48
-        $pages = $this->parseWithFilter('submenu/pages', [
49
-            'settings' => __('Settings', 'site-reviews'),
50
-            'tools' => __('Tools', 'site-reviews'),
51
-            'addons' => __('Add-ons', 'site-reviews'),
52
-            'documentation' => __('Documentation', 'site-reviews'),
53
-        ]);
54
-        foreach ($pages as $slug => $title) {
55
-            $method = glsr(Helper::class)->buildMethodName('render-'.$slug.'-menu');
56
-            $callback = apply_filters('site-reviews/addon/submenu/callback', [$this, $method], $slug);
57
-            if (!is_callable($callback)) {
48
+        $pages = $this->parseWithFilter( 'submenu/pages', [
49
+            'settings' => __( 'Settings', 'site-reviews' ),
50
+            'tools' => __( 'Tools', 'site-reviews' ),
51
+            'addons' => __( 'Add-ons', 'site-reviews' ),
52
+            'documentation' => __( 'Documentation', 'site-reviews' ),
53
+        ] );
54
+        foreach( $pages as $slug => $title ) {
55
+            $method = glsr( Helper::class )->buildMethodName( 'render-'.$slug.'-menu' );
56
+            $callback = apply_filters( 'site-reviews/addon/submenu/callback', [$this, $method], $slug );
57
+            if( !is_callable( $callback ) ) {
58 58
                 continue;
59 59
             }
60
-            add_submenu_page('edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->getPermission($slug), $slug, $callback);
60
+            add_submenu_page( 'edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->getPermission( $slug ), $slug, $callback );
61 61
         }
62 62
     }
63 63
 
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public function renderAddonsMenu()
70 70
     {
71
-        $this->renderPage('addons', [
72
-            'template' => glsr(Template::class),
73
-        ]);
71
+        $this->renderPage( 'addons', [
72
+            'template' => glsr( Template::class ),
73
+        ] );
74 74
     }
75 75
 
76 76
     /**
@@ -80,23 +80,23 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public function renderDocumentationMenu()
82 82
     {
83
-        $tabs = $this->parseWithFilter('documentation/tabs', [
84
-            'support' => __('Support', 'site-reviews'),
85
-            'faq' => __('FAQ', 'site-reviews'),
86
-            'shortcodes' => __('Shortcodes', 'site-reviews'),
87
-            'hooks' => __('Hooks', 'site-reviews'),
88
-            'functions' => __('Functions', 'site-reviews'),
89
-            'addons' => __('Addons', 'site-reviews'),
90
-        ]);
91
-        $addons = apply_filters('site-reviews/addon/documentation', []);
92
-        ksort($addons);
93
-        if (empty($addons)) {
83
+        $tabs = $this->parseWithFilter( 'documentation/tabs', [
84
+            'support' => __( 'Support', 'site-reviews' ),
85
+            'faq' => __( 'FAQ', 'site-reviews' ),
86
+            'shortcodes' => __( 'Shortcodes', 'site-reviews' ),
87
+            'hooks' => __( 'Hooks', 'site-reviews' ),
88
+            'functions' => __( 'Functions', 'site-reviews' ),
89
+            'addons' => __( 'Addons', 'site-reviews' ),
90
+        ] );
91
+        $addons = apply_filters( 'site-reviews/addon/documentation', [] );
92
+        ksort( $addons );
93
+        if( empty($addons) ) {
94 94
             unset($tabs['addons']);
95 95
         }
96
-        $this->renderPage('documentation', [
96
+        $this->renderPage( 'documentation', [
97 97
             'addons' => $addons,
98 98
             'tabs' => $tabs,
99
-        ]);
99
+        ] );
100 100
     }
101 101
 
102 102
     /**
@@ -106,26 +106,26 @@  discard block
 block discarded – undo
106 106
      */
107 107
     public function renderSettingsMenu()
108 108
     {
109
-        $tabs = $this->parseWithFilter('settings/tabs', [
110
-            'general' => __('General', 'site-reviews'),
111
-            'reviews' => __('Reviews', 'site-reviews'),
112
-            'submissions' => __('Submissions', 'site-reviews'),
113
-            'schema' => __('Schema', 'site-reviews'),
114
-            'translations' => __('Translations', 'site-reviews'),
115
-            'addons' => __('Addons', 'site-reviews'),
116
-            'licenses' => __('Licenses', 'site-reviews'),
117
-        ]);
118
-        if (empty(glsr(Helper::class)->dataGet(glsr()->defaults, 'settings.addons'))) {
109
+        $tabs = $this->parseWithFilter( 'settings/tabs', [
110
+            'general' => __( 'General', 'site-reviews' ),
111
+            'reviews' => __( 'Reviews', 'site-reviews' ),
112
+            'submissions' => __( 'Submissions', 'site-reviews' ),
113
+            'schema' => __( 'Schema', 'site-reviews' ),
114
+            'translations' => __( 'Translations', 'site-reviews' ),
115
+            'addons' => __( 'Addons', 'site-reviews' ),
116
+            'licenses' => __( 'Licenses', 'site-reviews' ),
117
+        ] );
118
+        if( empty(glsr( Helper::class )->dataGet( glsr()->defaults, 'settings.addons' )) ) {
119 119
             unset($tabs['addons']);
120 120
         }
121
-        if (empty(glsr(Helper::class)->dataGet(glsr()->defaults, 'settings.licenses'))) {
121
+        if( empty(glsr( Helper::class )->dataGet( glsr()->defaults, 'settings.licenses' )) ) {
122 122
             unset($tabs['licenses']);
123 123
         }
124
-        $this->renderPage('settings', [
124
+        $this->renderPage( 'settings', [
125 125
             'notices' => $this->getNotices(),
126
-            'settings' => glsr(Settings::class),
126
+            'settings' => glsr( Settings::class ),
127 127
             'tabs' => $tabs,
128
-        ]);
128
+        ] );
129 129
     }
130 130
 
131 131
     /**
@@ -135,29 +135,29 @@  discard block
 block discarded – undo
135 135
      */
136 136
     public function renderToolsMenu()
137 137
     {
138
-        $tabs = $this->parseWithFilter('tools/tabs', [
139
-            'general' => __('General', 'site-reviews'),
140
-            'sync' => __('Sync Reviews', 'site-reviews'),
141
-            'console' => __('Console', 'site-reviews'),
142
-            'system-info' => __('System Info', 'site-reviews'),
143
-        ]);
144
-        if (!apply_filters('site-reviews/addon/sync/enable', false)) {
138
+        $tabs = $this->parseWithFilter( 'tools/tabs', [
139
+            'general' => __( 'General', 'site-reviews' ),
140
+            'sync' => __( 'Sync Reviews', 'site-reviews' ),
141
+            'console' => __( 'Console', 'site-reviews' ),
142
+            'system-info' => __( 'System Info', 'site-reviews' ),
143
+        ] );
144
+        if( !apply_filters( 'site-reviews/addon/sync/enable', false ) ) {
145 145
             unset($tabs['sync']);
146 146
         }
147
-        $this->renderPage('tools', [
147
+        $this->renderPage( 'tools', [
148 148
             'data' => [
149 149
                 'context' => [
150
-                    'base_url' => admin_url('edit.php?post_type='.Application::POST_TYPE),
151
-                    'console' => strval(glsr(Console::class)),
150
+                    'base_url' => admin_url( 'edit.php?post_type='.Application::POST_TYPE ),
151
+                    'console' => strval( glsr( Console::class ) ),
152 152
                     'id' => Application::ID,
153
-                    'system' => strval(glsr(System::class)),
153
+                    'system' => strval( glsr( System::class ) ),
154 154
                 ],
155
-                'services' => apply_filters('site-reviews/addon/sync/services', []),
155
+                'services' => apply_filters( 'site-reviews/addon/sync/services', [] ),
156 156
             ],
157 157
             'notices' => $this->getNotices(),
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,27 +176,27 @@  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
-        return apply_filters('site-reviews/addon/'.$hookSuffix, $args);
190
+        return apply_filters( 'site-reviews/addon/'.$hookSuffix, $args );
191 191
     }
192 192
 
193 193
     /**
194 194
      * @param string $page
195 195
      * @return void
196 196
      */
197
-    protected function renderPage($page, array $data = [])
197
+    protected function renderPage( $page, array $data = [] )
198 198
     {
199
-        $data['http_referer'] = (string) wp_get_referer();
200
-        glsr()->render('pages/'.$page.'/index', $data);
199
+        $data['http_referer'] = (string)wp_get_referer();
200
+        glsr()->render( 'pages/'.$page.'/index', $data );
201 201
     }
202 202
 }
Please login to merge, or discard this patch.
plugin/Defaults/DefaultsAbstract.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -23,16 +23,16 @@  discard block
 block discarded – undo
23 23
      * @param string $name
24 24
      * @return void|array
25 25
      */
26
-    public function __call($name, array $args = [])
26
+    public function __call( $name, array $args = [] )
27 27
     {
28
-        if (!method_exists($this, $name) || !in_array($name, $this->callable)) {
28
+        if( !method_exists( $this, $name ) || !in_array( $name, $this->callable ) ) {
29 29
             return;
30 30
         }
31
-        $defaults = call_user_func_array([$this, $name], $args);
32
-        $hookName = (new ReflectionClass($this))->getShortName();
33
-        $hookName = str_replace('Defaults', '', $hookName);
34
-        $hookName = glsr(Helper::class)->dashCase($hookName);
35
-        return apply_filters('site-reviews/defaults/'.$hookName, $defaults, $name);
31
+        $defaults = call_user_func_array( [$this, $name], $args );
32
+        $hookName = (new ReflectionClass( $this ))->getShortName();
33
+        $hookName = str_replace( 'Defaults', '', $hookName );
34
+        $hookName = glsr( Helper::class )->dashCase( $hookName );
35
+        return apply_filters( 'site-reviews/defaults/'.$hookName, $defaults, $name );
36 36
     }
37 37
 
38 38
     /**
@@ -43,38 +43,38 @@  discard block
 block discarded – undo
43 43
     /**
44 44
      * @return array
45 45
      */
46
-    protected function filter(array $values = [])
46
+    protected function filter( array $values = [] )
47 47
     {
48
-        return $this->normalize($this->merge(array_filter($values)), $values);
48
+        return $this->normalize( $this->merge( array_filter( $values ) ), $values );
49 49
     }
50 50
 
51 51
     /**
52 52
      * @return string
53 53
      */
54
-    protected function filteredJson(array $values = [])
54
+    protected function filteredJson( array $values = [] )
55 55
     {
56 56
         $defaults = $this->flattenArray(
57
-            array_diff_key($this->defaults(), array_flip($this->guarded))
57
+            array_diff_key( $this->defaults(), array_flip( $this->guarded ) )
58 58
         );
59 59
         $values = $this->flattenArray(
60
-            shortcode_atts($defaults, $values)
60
+            shortcode_atts( $defaults, $values )
61 61
         );
62
-        $filtered = array_filter(array_diff_assoc($values, $defaults), function ($value) {
63
-            return !$this->isEmpty($value);
62
+        $filtered = array_filter( array_diff_assoc( $values, $defaults ), function( $value ) {
63
+            return !$this->isEmpty( $value );
64 64
         });
65
-        return json_encode($filtered, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
65
+        return json_encode( $filtered, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
66 66
     }
67 67
 
68 68
     /**
69 69
      * @return array
70 70
      */
71
-    protected function flattenArray(array $values)
71
+    protected function flattenArray( array $values )
72 72
     {
73
-        array_walk($values, function (&$value) {
74
-            if (!is_array($value)) {
73
+        array_walk( $values, function( &$value ) {
74
+            if( !is_array( $value ) ) {
75 75
                 return;
76 76
             }
77
-            $value = implode(',', $value);
77
+            $value = implode( ',', $value );
78 78
         });
79 79
         return $values;
80 80
     }
@@ -83,34 +83,34 @@  discard block
 block discarded – undo
83 83
      * @param mixed $var
84 84
      * @return bool
85 85
      */
86
-    protected function isEmpty($var)
86
+    protected function isEmpty( $var )
87 87
     {
88
-        return !is_numeric($var) && !is_bool($var) && empty($var);
88
+        return !is_numeric( $var ) && !is_bool( $var ) && empty($var);
89 89
     }
90 90
 
91 91
     /**
92 92
      * @return array
93 93
      */
94
-    protected function merge(array $values = [])
94
+    protected function merge( array $values = [] )
95 95
     {
96
-        return $this->normalize(wp_parse_args($values, $this->defaults()), $values);
96
+        return $this->normalize( wp_parse_args( $values, $this->defaults() ), $values );
97 97
     }
98 98
 
99 99
     /**
100 100
      * @return array
101 101
      */
102
-    protected function normalize(array $values, array $originalValues)
102
+    protected function normalize( array $values, array $originalValues )
103 103
     {
104
-        $values['json'] = $this->filteredJson($originalValues);
104
+        $values['json'] = $this->filteredJson( $originalValues );
105 105
         return $values;
106 106
     }
107 107
 
108 108
     /**
109 109
      * @return array
110 110
      */
111
-    protected function restrict(array $values = [])
111
+    protected function restrict( array $values = [] )
112 112
     {
113
-        return $this->normalize(shortcode_atts($this->defaults(), $values), $values);
113
+        return $this->normalize( shortcode_atts( $this->defaults(), $values ), $values );
114 114
     }
115 115
 
116 116
     /**
@@ -118,6 +118,6 @@  discard block
 block discarded – undo
118 118
      */
119 119
     protected function unguarded()
120 120
     {
121
-        return array_diff_key($this->defaults(), array_flip($this->guarded));
121
+        return array_diff_key( $this->defaults(), array_flip( $this->guarded ) );
122 122
     }
123 123
 }
Please login to merge, or discard this patch.
plugin/Database/QueryBuilder.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -14,19 +14,19 @@  discard block
 block discarded – undo
14 14
      * Build a WP_Query meta_query/tax_query.
15 15
      * @return array
16 16
      */
17
-    public function buildQuery(array $keys = [], array $values = [])
17
+    public function buildQuery( array $keys = [], array $values = [] )
18 18
     {
19 19
         $queries = [];
20
-        foreach ($keys as $key) {
21
-            if (!array_key_exists($key, $values)) {
20
+        foreach( $keys as $key ) {
21
+            if( !array_key_exists( $key, $values ) ) {
22 22
                 continue;
23 23
             }
24
-            $methodName = glsr(Helper::class)->buildMethodName($key, __FUNCTION__);
25
-            if (!method_exists($this, $methodName)) {
24
+            $methodName = glsr( Helper::class )->buildMethodName( $key, __FUNCTION__ );
25
+            if( !method_exists( $this, $methodName ) ) {
26 26
                 continue;
27 27
             }
28
-            $query = call_user_func([$this, $methodName], $values[$key]);
29
-            if (is_array($query)) {
28
+            $query = call_user_func( [$this, $methodName], $values[$key] );
29
+            if( is_array( $query ) ) {
30 30
                 $queries[] = $query;
31 31
             }
32 32
         }
@@ -36,17 +36,17 @@  discard block
 block discarded – undo
36 36
     /**
37 37
      * @return string
38 38
      */
39
-    public function buildSqlLines(array $values, array $conditions)
39
+    public function buildSqlLines( array $values, array $conditions )
40 40
     {
41 41
         $string = '';
42
-        $values = array_filter($values);
43
-        foreach ($conditions as $key => $value) {
44
-            if (!isset($values[$key])) {
42
+        $values = array_filter( $values );
43
+        foreach( $conditions as $key => $value ) {
44
+            if( !isset($values[$key]) ) {
45 45
                 continue;
46 46
             }
47
-            $values[$key] = implode(',', (array) $values[$key]);
48
-            $string.= false !== strpos($value, '%s')
49
-                ? sprintf($value, strval($values[$key]))
47
+            $values[$key] = implode( ',', (array)$values[$key] );
48
+            $string .= false !== strpos( $value, '%s' )
49
+                ? sprintf( $value, strval( $values[$key] ) )
50 50
                 : $value;
51 51
         }
52 52
         return $string;
@@ -58,16 +58,16 @@  discard block
 block discarded – undo
58 58
      * @param string $sprintfFormat
59 59
      * @return string
60 60
      */
61
-    public function buildSqlOr($values, $sprintfFormat)
61
+    public function buildSqlOr( $values, $sprintfFormat )
62 62
     {
63
-        if (!is_array($values)) {
64
-            $values = explode(',', $values);
63
+        if( !is_array( $values ) ) {
64
+            $values = explode( ',', $values );
65 65
         }
66
-        $values = array_filter(array_map('trim', (array) $values));
67
-        $values = array_map(function ($value) use ($sprintfFormat) {
68
-            return sprintf($sprintfFormat, $value);
69
-        }, $values);
70
-        return implode(' OR ', $values);
66
+        $values = array_filter( array_map( 'trim', (array)$values ) );
67
+        $values = array_map( function( $value ) use ($sprintfFormat) {
68
+            return sprintf( $sprintfFormat, $value );
69
+        }, $values );
70
+        return implode( ' OR ', $values );
71 71
     }
72 72
 
73 73
     /**
@@ -77,23 +77,23 @@  discard block
 block discarded – undo
77 77
      * @return string
78 78
      * @filter posts_search
79 79
      */
80
-    public function filterSearchByTitle($search, WP_Query $query)
80
+    public function filterSearchByTitle( $search, WP_Query $query )
81 81
     {
82
-        if (empty($search) || empty($query->get('search_terms'))) {
82
+        if( empty($search) || empty($query->get( 'search_terms' )) ) {
83 83
             return $search;
84 84
         }
85 85
         global $wpdb;
86
-        $n = empty($query->get('exact'))
86
+        $n = empty($query->get( 'exact' ))
87 87
             ? '%'
88 88
             : '';
89 89
         $search = [];
90
-        foreach ((array) $query->get('search_terms') as $term) {
91
-            $search[] = $wpdb->prepare("{$wpdb->posts}.post_title LIKE %s", $n.$wpdb->esc_like($term).$n);
90
+        foreach( (array)$query->get( 'search_terms' ) as $term ) {
91
+            $search[] = $wpdb->prepare( "{$wpdb->posts}.post_title LIKE %s", $n.$wpdb->esc_like( $term ).$n );
92 92
         }
93
-        if (!is_user_logged_in()) {
93
+        if( !is_user_logged_in() ) {
94 94
             $search[] = "{$wpdb->posts}.post_password = ''";
95 95
         }
96
-        return ' AND '.implode(' AND ', $search);
96
+        return ' AND '.implode( ' AND ', $search );
97 97
     }
98 98
 
99 99
     /**
@@ -101,13 +101,13 @@  discard block
 block discarded – undo
101 101
      * @param bool $isEnabled
102 102
      * @return int
103 103
      */
104
-    public function getPaged($isEnabled = true)
104
+    public function getPaged( $isEnabled = true )
105 105
     {
106 106
         $pagedQuery = !is_front_page()
107
-            ? glsr()->constant('PAGED_QUERY_VAR')
107
+            ? glsr()->constant( 'PAGED_QUERY_VAR' )
108 108
             : 'page';
109 109
         return $isEnabled
110
-            ? max(1, intval(get_query_var($pagedQuery)))
110
+            ? max( 1, intval( get_query_var( $pagedQuery ) ) )
111 111
             : 1;
112 112
     }
113 113
 
@@ -115,14 +115,14 @@  discard block
 block discarded – undo
115 115
      * @param string $value
116 116
      * @return void|array
117 117
      */
118
-    protected function buildQueryAssignedTo($value)
118
+    protected function buildQueryAssignedTo( $value )
119 119
     {
120
-        if (!empty($value)) {
121
-            $postIds = glsr(Helper::class)->convertStringToArray($value, 'is_numeric');
120
+        if( !empty($value) ) {
121
+            $postIds = glsr( Helper::class )->convertStringToArray( $value, 'is_numeric' );
122 122
             return [
123 123
                 'compare' => 'IN',
124 124
                 'key' => '_assigned_to',
125
-                'value' => glsr(Polylang::class)->getPostIds($postIds),
125
+                'value' => glsr( Polylang::class )->getPostIds( $postIds ),
126 126
             ];
127 127
         }
128 128
     }
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
      * @param array $value
132 132
      * @return void|array
133 133
      */
134
-    protected function buildQueryCategory($value)
134
+    protected function buildQueryCategory( $value )
135 135
     {
136
-        if (!empty($value)) {
136
+        if( !empty($value) ) {
137 137
             return [
138 138
                 'field' => 'term_id',
139 139
                 'taxonomy' => Application::TAXONOMY,
@@ -146,10 +146,10 @@  discard block
 block discarded – undo
146 146
      * @param string $value
147 147
      * @return void|array
148 148
      */
149
-    protected function buildQueryRating($value)
149
+    protected function buildQueryRating( $value )
150 150
     {
151
-        if (is_numeric($value)
152
-            && in_array(intval($value), range(1, glsr()->constant('MAX_RATING', Rating::class)))) {
151
+        if( is_numeric( $value )
152
+            && in_array( intval( $value ), range( 1, glsr()->constant( 'MAX_RATING', Rating::class ) ) ) ) {
153 153
             return [
154 154
                 'compare' => '>=',
155 155
                 'key' => '_rating',
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
      * @param string $value
163 163
      * @return void|array
164 164
      */
165
-    protected function buildQueryType($value)
165
+    protected function buildQueryType( $value )
166 166
     {
167
-        if (!in_array($value, ['', 'all'])) {
167
+        if( !in_array( $value, ['', 'all'] ) ) {
168 168
             return [
169 169
                 'key' => '_review_type',
170 170
                 'value' => $value,
Please login to merge, or discard this patch.