Passed
Push — master ( e0a59a...75b6ac )
by Paul
06:30 queued 02:41
created
plugin/Database.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -18,10 +18,10 @@  discard block
 block discarded – undo
18 18
      * @param bool $single
19 19
      * @return mixed
20 20
      */
21
-    public function get($postId, $key, $single = true)
21
+    public function get( $postId, $key, $single = true )
22 22
     {
23
-        $key = Str::prefix('_', $key);
24
-        return get_post_meta(intval($postId), $key, $single);
23
+        $key = Str::prefix( '_', $key );
24
+        return get_post_meta( intval( $postId ), $key, $single );
25 25
     }
26 26
 
27 27
     /**
@@ -29,16 +29,16 @@  discard block
 block discarded – undo
29 29
      * @param string $assignedTo
30 30
      * @return void|WP_Post
31 31
      */
32
-    public function getAssignedToPost($postId, $assignedTo = '')
32
+    public function getAssignedToPost( $postId, $assignedTo = '' )
33 33
     {
34
-        if (empty($assignedTo)) {
35
-            $assignedTo = $this->get($postId, 'assigned_to');
34
+        if( empty($assignedTo) ) {
35
+            $assignedTo = $this->get( $postId, 'assigned_to' );
36 36
         }
37
-        if (empty($assignedTo)) {
37
+        if( empty($assignedTo) ) {
38 38
             return;
39 39
         }
40
-        $assignedPost = get_post($assignedTo);
41
-        if ($assignedPost instanceof WP_Post && $assignedPost->ID != $postId) {
40
+        $assignedPost = get_post( $assignedTo );
41
+        if( $assignedPost instanceof WP_Post && $assignedPost->ID != $postId ) {
42 42
             return $assignedPost;
43 43
         }
44 44
     }
@@ -48,25 +48,25 @@  discard block
 block discarded – undo
48 48
      * @param string $metaValue
49 49
      * @return array|int
50 50
      */
51
-    public function getReviewCount($metaKey = '', $metaValue = '')
51
+    public function getReviewCount( $metaKey = '', $metaValue = '' )
52 52
     {
53
-        if (!$metaKey) {
54
-            return (array) wp_count_posts(Application::POST_TYPE);
53
+        if( !$metaKey ) {
54
+            return (array)wp_count_posts( Application::POST_TYPE );
55 55
         }
56
-        $counts = glsr(Cache::class)->getReviewCountsFor($metaKey);
57
-        if (!$metaValue) {
56
+        $counts = glsr( Cache::class )->getReviewCountsFor( $metaKey );
57
+        if( !$metaValue ) {
58 58
             return $counts;
59 59
         }
60
-        return Arr::get($counts, $metaValue, 0);
60
+        return Arr::get( $counts, $metaValue, 0 );
61 61
     }
62 62
 
63 63
     /**
64 64
      * @param string $metaReviewType
65 65
      * @return array
66 66
      */
67
-    public function getReviewIdsByType($metaReviewType)
67
+    public function getReviewIdsByType( $metaReviewType )
68 68
     {
69
-        return glsr(SqlQueries::class)->getReviewIdsByType($metaReviewType);
69
+        return glsr( SqlQueries::class )->getReviewIdsByType( $metaReviewType );
70 70
     }
71 71
 
72 72
     /**
@@ -74,24 +74,24 @@  discard block
 block discarded – undo
74 74
      * @param string $status
75 75
      * @return array
76 76
      */
77
-    public function getReviewsMeta($key, $status = 'publish')
77
+    public function getReviewsMeta( $key, $status = 'publish' )
78 78
     {
79
-        if ('all' == $status || empty($status)) {
80
-            $status = get_post_stati(['exclude_from_search' => false]);
79
+        if( 'all' == $status || empty($status) ) {
80
+            $status = get_post_stati( ['exclude_from_search' => false] );
81 81
         }
82
-        return glsr(SqlQueries::class)->getReviewsMeta($key, $status);
82
+        return glsr( SqlQueries::class )->getReviewsMeta( $key, $status );
83 83
     }
84 84
 
85 85
     /**
86 86
      * @param string $field
87 87
      * @return array
88 88
      */
89
-    public function getTermIds(array $values, $field)
89
+    public function getTermIds( array $values, $field )
90 90
     {
91 91
         $termIds = [];
92
-        foreach ($values as $value) {
93
-            $term = get_term_by($field, $value, Application::TAXONOMY);
94
-            if (!isset($term->term_id)) {
92
+        foreach( $values as $value ) {
93
+            $term = get_term_by( $field, $value, Application::TAXONOMY );
94
+            if( !isset($term->term_id) ) {
95 95
                 continue;
96 96
             }
97 97
             $termIds[] = $term->term_id;
@@ -102,17 +102,17 @@  discard block
 block discarded – undo
102 102
     /**
103 103
      * @return array
104 104
      */
105
-    public function getTerms(array $args = [])
105
+    public function getTerms( array $args = [] )
106 106
     {
107
-        $args = wp_parse_args($args, [
107
+        $args = wp_parse_args( $args, [
108 108
             'count' => false,
109 109
             'fields' => 'id=>name',
110 110
             'hide_empty' => false,
111 111
             'taxonomy' => Application::TAXONOMY,
112
-        ]);
113
-        $terms = get_terms($args);
114
-        if (is_wp_error($terms)) {
115
-            glsr_log()->error($terms->get_error_message());
112
+        ] );
113
+        $terms = get_terms( $args );
114
+        if( is_wp_error( $terms ) ) {
115
+            glsr_log()->error( $terms->get_error_message() );
116 116
             return [];
117 117
         }
118 118
         return $terms;
@@ -122,36 +122,36 @@  discard block
 block discarded – undo
122 122
      * @param string $searchTerm
123 123
      * @return void|string
124 124
      */
125
-    public function searchPosts($searchTerm)
125
+    public function searchPosts( $searchTerm )
126 126
     {
127 127
         $args = [
128 128
             'post_status' => 'publish',
129 129
             'post_type' => 'any',
130 130
         ];
131
-        if (is_numeric($searchTerm)) {
131
+        if( is_numeric( $searchTerm ) ) {
132 132
             $args['post__in'] = [$searchTerm];
133 133
         } else {
134 134
             $args['orderby'] = 'relevance';
135 135
             $args['posts_per_page'] = 10;
136 136
             $args['s'] = $searchTerm;
137 137
         }
138
-        $queryBuilder = glsr(QueryBuilder::class);
139
-        add_filter('posts_search', [$queryBuilder, 'filterSearchByTitle'], 500, 2);
140
-        $search = new WP_Query($args);
141
-        remove_filter('posts_search', [$queryBuilder, 'filterSearchByTitle'], 500);
142
-        if (!$search->have_posts()) {
138
+        $queryBuilder = glsr( QueryBuilder::class );
139
+        add_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500, 2 );
140
+        $search = new WP_Query( $args );
141
+        remove_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500 );
142
+        if( !$search->have_posts() ) {
143 143
             return;
144 144
         }
145 145
         $results = '';
146
-        while ($search->have_posts()) {
146
+        while( $search->have_posts() ) {
147 147
             $search->the_post();
148 148
             ob_start();
149
-            glsr()->render('partials/editor/search-result', [
149
+            glsr()->render( 'partials/editor/search-result', [
150 150
                 'ID' => get_the_ID(),
151
-                'permalink' => esc_url((string) get_permalink()),
152
-                'title' => esc_attr(get_the_title()),
153
-            ]);
154
-            $results.= ob_get_clean();
151
+                'permalink' => esc_url( (string)get_permalink() ),
152
+                'title' => esc_attr( get_the_title() ),
153
+            ] );
154
+            $results .= ob_get_clean();
155 155
         }
156 156
         wp_reset_postdata();
157 157
         return $results;
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
      * @param mixed $value
164 164
      * @return int|bool
165 165
      */
166
-    public function set($postId, $key, $value)
166
+    public function set( $postId, $key, $value )
167 167
     {
168
-        $key = Str::prefix('_', $key);
169
-        return update_post_meta($postId, $key, $value);
168
+        $key = Str::prefix( '_', $key );
169
+        return update_post_meta( $postId, $key, $value );
170 170
     }
171 171
 
172 172
     /**
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
      * @param mixed $value
176 176
      * @return int|bool
177 177
      */
178
-    public function update($postId, $key, $value)
178
+    public function update( $postId, $key, $value )
179 179
     {
180
-        return $this->set($postId, $key, $value);
180
+        return $this->set( $postId, $key, $value );
181 181
     }
182 182
 }
Please login to merge, or discard this patch.
plugin/Helpers/Str.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@  discard block
 block discarded – undo
10 10
      * @param string $string
11 11
      * @return string
12 12
      */
13
-    public static function camelCase($string)
13
+    public static function camelCase( $string )
14 14
     {
15
-        $string = ucwords(str_replace(['-', '_'], ' ', trim($string)));
16
-        return str_replace(' ', '', $string);
15
+        $string = ucwords( str_replace( ['-', '_'], ' ', trim( $string ) ) );
16
+        return str_replace( ' ', '', $string );
17 17
     }
18 18
 
19 19
     /**
@@ -22,27 +22,27 @@  discard block
 block discarded – undo
22 22
      * @param string $initialType period|period_space|space
23 23
      * @return string
24 24
      */
25
-    public static function convertName($name, $nameType = '', $initialType = '')
25
+    public static function convertName( $name, $nameType = '', $initialType = '' )
26 26
     {
27
-        $names = preg_split('/\W/', $name, 0, PREG_SPLIT_NO_EMPTY);
28
-        $firstName = array_shift($names);
29
-        $lastName = array_pop($names);
27
+        $names = preg_split( '/\W/', $name, 0, PREG_SPLIT_NO_EMPTY );
28
+        $firstName = array_shift( $names );
29
+        $lastName = array_pop( $names );
30 30
         $initialTypes = [
31 31
             'period' => '.',
32 32
             'period_space' => '. ',
33 33
             'space' => ' ',
34 34
         ];
35
-        $initialPunctuation = (string) Arr::get($initialTypes, $initialType, ' ');
36
-        if ('initials' == $nameType) {
37
-            return static::convertToInitials($name, $initialPunctuation);
35
+        $initialPunctuation = (string)Arr::get( $initialTypes, $initialType, ' ' );
36
+        if( 'initials' == $nameType ) {
37
+            return static::convertToInitials( $name, $initialPunctuation );
38 38
         }
39 39
         $nameTypes = [
40 40
             'first' => $firstName,
41
-            'first_initial' => substr($firstName, 0, 1).$initialPunctuation.$lastName,
41
+            'first_initial' => substr( $firstName, 0, 1 ).$initialPunctuation.$lastName,
42 42
             'last' => $lastName,
43
-            'last_initial' => $firstName.' '.substr($lastName, 0, 1).$initialPunctuation,
43
+            'last_initial' => $firstName.' '.substr( $lastName, 0, 1 ).$initialPunctuation,
44 44
         ];
45
-        return trim((string) Arr::get($nameTypes, $nameType, $name));
45
+        return trim( (string)Arr::get( $nameTypes, $nameType, $name ) );
46 46
     }
47 47
 
48 48
     /**
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
      * @param string $prefix
51 51
      * @return string
52 52
      */
53
-    public static function convertPathToId($path, $prefix = '')
53
+    public static function convertPathToId( $path, $prefix = '' )
54 54
     {
55
-        return str_replace(['[', ']'], ['-', ''], static::convertPathToName($path, $prefix));
55
+        return str_replace( ['[', ']'], ['-', ''], static::convertPathToName( $path, $prefix ) );
56 56
     }
57 57
 
58 58
     /**
@@ -60,12 +60,12 @@  discard block
 block discarded – undo
60 60
      * @param string $prefix
61 61
      * @return string
62 62
      */
63
-    public static function convertPathToName($path, $prefix = '')
63
+    public static function convertPathToName( $path, $prefix = '' )
64 64
     {
65
-        $levels = explode('.', $path);
66
-        return array_reduce($levels, function ($result, $value) {
65
+        $levels = explode( '.', $path );
66
+        return array_reduce( $levels, function( $result, $value ) {
67 67
             return $result .= '['.$value.']';
68
-        }, $prefix);
68
+        }, $prefix );
69 69
     }
70 70
 
71 71
     /**
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
      * @param string $initialPunctuation
74 74
      * @return string
75 75
      */
76
-    public static function convertToInitials($name, $initialPunctuation = '')
76
+    public static function convertToInitials( $name, $initialPunctuation = '' )
77 77
     {
78
-        preg_match_all('/(?<=\s|\b)\pL/u', $name, $matches);
79
-        return array_reduce($matches[0], function ($carry, $word) use ($initialPunctuation) {
80
-            return $carry.strtoupper(substr($word, 0, 1)).$initialPunctuation;
78
+        preg_match_all( '/(?<=\s|\b)\pL/u', $name, $matches );
79
+        return array_reduce( $matches[0], function( $carry, $word ) use ($initialPunctuation) {
80
+            return $carry.strtoupper( substr( $word, 0, 1 ) ).$initialPunctuation;
81 81
         });
82 82
     }
83 83
 
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
      * @param string $string
86 86
      * @return string
87 87
      */
88
-    public static function dashCase($string)
88
+    public static function dashCase( $string )
89 89
     {
90
-        return str_replace('_', '-', static::snakeCase($string));
90
+        return str_replace( '_', '-', static::snakeCase( $string ) );
91 91
     }
92 92
 
93 93
     /**
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
      * @param string $haystack
96 96
      * @return bool
97 97
      */
98
-    public static function endsWith($needle, $haystack)
98
+    public static function endsWith( $needle, $haystack )
99 99
     {
100
-        $length = strlen($needle);
100
+        $length = strlen( $needle );
101 101
         return 0 != $length
102
-            ? substr($haystack, -$length) === $needle
102
+            ? substr( $haystack, -$length ) === $needle
103 103
             : true;
104 104
     }
105 105
 
@@ -109,12 +109,12 @@  discard block
 block discarded – undo
109 109
      * @param string|null $trim
110 110
      * @return string
111 111
      */
112
-    public static function prefix($prefix, $string, $trim = null)
112
+    public static function prefix( $prefix, $string, $trim = null )
113 113
     {
114
-        if (null === $trim) {
114
+        if( null === $trim ) {
115 115
             $trim = $prefix;
116 116
         }
117
-        return $prefix.trim(static::removePrefix($trim, $string));
117
+        return $prefix.trim( static::removePrefix( $trim, $string ) );
118 118
     }
119 119
 
120 120
     /**
@@ -122,10 +122,10 @@  discard block
 block discarded – undo
122 122
      * @param string $string
123 123
      * @return string
124 124
      */
125
-    public static function removePrefix($prefix, $string)
125
+    public static function removePrefix( $prefix, $string )
126 126
     {
127
-        return static::startsWith($prefix, $string)
128
-            ? substr($string, strlen($prefix))
127
+        return static::startsWith( $prefix, $string )
128
+            ? substr( $string, strlen( $prefix ) )
129 129
             : $string;
130 130
     }
131 131
 
@@ -133,16 +133,16 @@  discard block
 block discarded – undo
133 133
      * @param string $string
134 134
      * @return string
135 135
      */
136
-    public static function snakeCase($string)
136
+    public static function snakeCase( $string )
137 137
     {
138
-        if (!ctype_lower($string)) {
139
-            $string = preg_replace('/\s+/u', '', $string);
140
-            $string = preg_replace('/(.)(?=[A-Z])/u', '$1_', $string);
141
-            $string = function_exists('mb_strtolower')
142
-                ? mb_strtolower($string, 'UTF-8')
143
-                : strtolower($string);
138
+        if( !ctype_lower( $string ) ) {
139
+            $string = preg_replace( '/\s+/u', '', $string );
140
+            $string = preg_replace( '/(.)(?=[A-Z])/u', '$1_', $string );
141
+            $string = function_exists( 'mb_strtolower' )
142
+                ? mb_strtolower( $string, 'UTF-8' )
143
+                : strtolower( $string );
144 144
         }
145
-        return str_replace('-', '_', $string);
145
+        return str_replace( '-', '_', $string );
146 146
     }
147 147
 
148 148
     /**
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
      * @param string $haystack
151 151
      * @return bool
152 152
      */
153
-    public static function startsWith($needle, $haystack)
153
+    public static function startsWith( $needle, $haystack )
154 154
     {
155
-        return substr($haystack, 0, strlen($needle)) === $needle;
155
+        return substr( $haystack, 0, strlen( $needle ) ) === $needle;
156 156
     }
157 157
 
158 158
     /**
@@ -160,10 +160,10 @@  discard block
 block discarded – undo
160 160
      * @param int $length
161 161
      * @return string
162 162
      */
163
-    public static function truncate($string, $length)
163
+    public static function truncate( $string, $length )
164 164
     {
165
-        return strlen($string) > $length
166
-            ? substr($string, 0, $length)
165
+        return strlen( $string ) > $length
166
+            ? substr( $string, 0, $length )
167 167
             : $string;
168 168
     }
169 169
 }
Please login to merge, or discard this patch.
helpers.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-defined('WPINC') || die;
3
+defined( 'WPINC' ) || die;
4 4
 
5 5
 /*
6 6
  * Alternate method of using the functions without having to use `function_exists()`
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @param mixed ...
9 9
  * @return mixed
10 10
  */
11
-add_filter('plugins_loaded', function () {
11
+add_filter( 'plugins_loaded', function() {
12 12
     $hooks = array(
13 13
         'glsr_calculate_ratings' => 1,
14 14
         'glsr_create_review' => 2,
@@ -21,23 +21,23 @@  discard block
 block discarded – undo
21 21
         'glsr_log' => 3,
22 22
         'glsr_star_rating' => 2,
23 23
     );
24
-    foreach ($hooks as $function => $acceptedArgs) {
25
-        add_filter($function, function () use ($function) {
24
+    foreach( $hooks as $function => $acceptedArgs ) {
25
+        add_filter( $function, function() use ($function) {
26 26
             $args = func_get_args();
27
-            array_shift($args); // remove the fallback value
28
-            return call_user_func_array($function, $args);
29
-        }, 10, $acceptedArgs);
27
+            array_shift( $args ); // remove the fallback value
28
+            return call_user_func_array( $function, $args );
29
+        }, 10, $acceptedArgs );
30 30
     }
31 31
 });
32 32
 
33 33
 /**
34 34
  * @return mixed
35 35
  */
36
-function glsr($alias = null)
36
+function glsr( $alias = null )
37 37
 {
38 38
     $app = \GeminiLabs\SiteReviews\Application::load();
39 39
     return !empty($alias)
40
-        ? $app->make($alias)
40
+        ? $app->make( $alias )
41 41
         : $app;
42 42
 }
43 43
 
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
  * @param $column string
47 47
  * @return array
48 48
  */
49
-function glsr_array_column(array $array, $column)
49
+function glsr_array_column( array $array, $column )
50 50
 {
51 51
     $result = array();
52
-    foreach ($array as $subarray) {
53
-        $subarray = (array) $subarray;
54
-        if (!isset($subarray[$column])) {
52
+    foreach( $array as $subarray ) {
53
+        $subarray = (array)$subarray;
54
+        if( !isset($subarray[$column]) ) {
55 55
             continue;
56 56
         }
57 57
         $result[] = $subarray[$column];
@@ -64,19 +64,19 @@  discard block
 block discarded – undo
64 64
  */
65 65
 function glsr_calculate_ratings()
66 66
 {
67
-    glsr('Controllers\AdminController')->routerCountReviews(false);
68
-    glsr_log()->notice(__('Recalculated rating counts.', 'site-reviews'));
67
+    glsr( 'Controllers\AdminController' )->routerCountReviews( false );
68
+    glsr_log()->notice( __( 'Recalculated rating counts.', 'site-reviews' ) );
69 69
 }
70 70
 
71 71
 /**
72 72
  * @return \GeminiLabs\SiteReviews\Review|false
73 73
  */
74
-function glsr_create_review($reviewValues = array())
74
+function glsr_create_review( $reviewValues = array() )
75 75
 {
76 76
     $review = new \GeminiLabs\SiteReviews\Commands\CreateReview(
77
-        \GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray($reviewValues)
77
+        \GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray( $reviewValues )
78 78
     );
79
-    return glsr('Database\ReviewManager')->create($review);
79
+    return glsr( 'Database\ReviewManager' )->create( $review );
80 80
 }
81 81
 
82 82
 /**
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
  */
85 85
 function glsr_current_screen()
86 86
 {
87
-    if (function_exists('get_current_screen')) {
87
+    if( function_exists( 'get_current_screen' ) ) {
88 88
         $screen = get_current_screen();
89 89
     }
90 90
     return empty($screen)
91
-        ? (object) array_fill_keys(['base', 'id', 'post_type'], null)
91
+        ? (object)array_fill_keys( ['base', 'id', 'post_type'], null )
92 92
         : $screen;
93 93
 }
94 94
 
@@ -96,15 +96,15 @@  discard block
 block discarded – undo
96 96
  * @param mixed ...$vars
97 97
  * @return void
98 98
  */
99
-function glsr_debug(...$vars)
99
+function glsr_debug( ...$vars )
100 100
 {
101
-    if (1 == count($vars)) {
102
-        $value = htmlspecialchars(print_r($vars[0], true), ENT_QUOTES, 'UTF-8');
103
-        printf('<div class="glsr-debug"><pre>%s</pre></div>', $value);
101
+    if( 1 == count( $vars ) ) {
102
+        $value = htmlspecialchars( print_r( $vars[0], true ), ENT_QUOTES, 'UTF-8' );
103
+        printf( '<div class="glsr-debug"><pre>%s</pre></div>', $value );
104 104
     } else {
105 105
         echo '<div class="glsr-debug-group">';
106
-        foreach ($vars as $var) {
107
-            glsr_debug($var);
106
+        foreach( $vars as $var ) {
107
+            glsr_debug( $var );
108 108
         }
109 109
         echo '</div>';
110 110
     }
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
  * @param mixed $fallback
117 117
  * @return mixed
118 118
  */
119
-function glsr_get($array, $path = '', $fallback = '')
119
+function glsr_get( $array, $path = '', $fallback = '' )
120 120
 {
121
-    return \GeminiLabs\SiteReviews\Helpers\Arr::get($array, $path, $fallback);
121
+    return \GeminiLabs\SiteReviews\Helpers\Arr::get( $array, $path, $fallback );
122 122
 }
123 123
 
124 124
 /**
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
  * @param string $cast
128 128
  * @return string|array
129 129
  */
130
-function glsr_get_option($path = '', $fallback = '', $cast = '')
130
+function glsr_get_option( $path = '', $fallback = '', $cast = '' )
131 131
 {
132
-    return is_string($path)
133
-        ? glsr('Database\OptionManager')->get(\GeminiLabs\SiteReviews\Helpers\Str::prefix('settings.', $path), $fallback, $cast)
132
+    return is_string( $path )
133
+        ? glsr( 'Database\OptionManager' )->get( \GeminiLabs\SiteReviews\Helpers\Str::prefix( 'settings.', $path ), $fallback, $cast )
134 134
         : $fallback;
135 135
 }
136 136
 
@@ -139,30 +139,30 @@  discard block
 block discarded – undo
139 139
  */
140 140
 function glsr_get_options()
141 141
 {
142
-    return glsr('Database\OptionManager')->get('settings');
142
+    return glsr( 'Database\OptionManager' )->get( 'settings' );
143 143
 }
144 144
 
145 145
 /**
146 146
  * @param \WP_Post|int $post
147 147
  * @return \GeminiLabs\SiteReviews\Review
148 148
  */
149
-function glsr_get_review($post)
149
+function glsr_get_review( $post )
150 150
 {
151
-    if (is_numeric($post)) {
152
-        $post = get_post($post);
151
+    if( is_numeric( $post ) ) {
152
+        $post = get_post( $post );
153 153
     }
154
-    if (!($post instanceof WP_Post)) {
155
-        $post = new WP_Post((object) []);
154
+    if( !($post instanceof WP_Post) ) {
155
+        $post = new WP_Post( (object)[] );
156 156
     }
157
-    return glsr('Database\ReviewManager')->single($post);
157
+    return glsr( 'Database\ReviewManager' )->single( $post );
158 158
 }
159 159
 
160 160
 /**
161 161
  * @return array
162 162
  */
163
-function glsr_get_reviews($args = array())
163
+function glsr_get_reviews( $args = array() )
164 164
 {
165
-    return glsr('Database\ReviewManager')->get(\GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray($args));
165
+    return glsr( 'Database\ReviewManager' )->get( \GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray( $args ) );
166 166
 }
167 167
 
168 168
 /**
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
 function glsr_log()
172 172
 {
173 173
     $args = func_get_args();
174
-    $console = glsr('Modules\Console');
175
-    if ($value = \GeminiLabs\SiteReviews\Helpers\Arr::get($args, '0')) {
176
-        return $console->debug($value, \GeminiLabs\SiteReviews\Helpers\Arr::get($args, '1', []));
174
+    $console = glsr( 'Modules\Console' );
175
+    if( $value = \GeminiLabs\SiteReviews\Helpers\Arr::get( $args, '0' ) ) {
176
+        return $console->debug( $value, \GeminiLabs\SiteReviews\Helpers\Arr::get( $args, '1', [] ) );
177 177
     }
178 178
     return $console;
179 179
 }
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 /**
182 182
  * @return string
183 183
  */
184
-function glsr_star_rating($rating)
184
+function glsr_star_rating( $rating )
185 185
 {
186
-    return glsr('Modules\Html\Partial')->build('star-rating', ['rating' => $rating]);
186
+    return glsr( 'Modules\Html\Partial' )->build( 'star-rating', ['rating' => $rating] );
187 187
 }
Please login to merge, or discard this patch.
plugin/Modules/Email.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -42,15 +42,15 @@  discard block
 block discarded – undo
42 42
     /**
43 43
      * @return Email
44 44
      */
45
-    public function compose(array $email)
45
+    public function compose( array $email )
46 46
     {
47
-        $this->normalize($email);
47
+        $this->normalize( $email );
48 48
         $this->attachments = $this->email['attachments'];
49 49
         $this->headers = $this->buildHeaders();
50 50
         $this->message = $this->buildHtmlMessage();
51 51
         $this->subject = $this->email['subject'];
52 52
         $this->to = $this->email['to'];
53
-        add_action('phpmailer_init', [$this, 'buildPlainTextMessage']);
53
+        add_action( 'phpmailer_init', [$this, 'buildPlainTextMessage'] );
54 54
         return $this;
55 55
     }
56 56
 
@@ -58,11 +58,11 @@  discard block
 block discarded – undo
58 58
      * @param string $format
59 59
      * @return string|null
60 60
      */
61
-    public function read($format = '')
61
+    public function read( $format = '' )
62 62
     {
63
-        if ('plaintext' == $format) {
64
-            $message = $this->stripHtmlTags($this->message);
65
-            return apply_filters('site-reviews/email/message', $message, 'text', $this);
63
+        if( 'plaintext' == $format ) {
64
+            $message = $this->stripHtmlTags( $this->message );
65
+            return apply_filters( 'site-reviews/email/message', $message, 'text', $this );
66 66
         }
67 67
         return $this->message;
68 68
     }
@@ -72,10 +72,10 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function send()
74 74
     {
75
-        if (!$this->message || !$this->subject || !$this->to) {
75
+        if( !$this->message || !$this->subject || !$this->to ) {
76 76
             return;
77 77
         }
78
-        add_action('wp_mail_failed', [$this, 'logMailError']);
78
+        add_action( 'wp_mail_failed', [$this, 'logMailError'] );
79 79
         $sent = wp_mail(
80 80
             $this->to,
81 81
             $this->subject,
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
             $this->headers,
84 84
             $this->attachments
85 85
         );
86
-        remove_action('wp_mail_failed', [$this, 'logMailError']);
86
+        remove_action( 'wp_mail_failed', [$this, 'logMailError'] );
87 87
         $this->reset();
88 88
         return $sent;
89 89
     }
@@ -92,16 +92,16 @@  discard block
 block discarded – undo
92 92
      * @return void
93 93
      * @action phpmailer_init
94 94
      */
95
-    public function buildPlainTextMessage(PHPMailer $phpmailer)
95
+    public function buildPlainTextMessage( PHPMailer $phpmailer )
96 96
     {
97
-        if (empty($this->email)) {
97
+        if( empty($this->email) ) {
98 98
             return;
99 99
         }
100
-        if ('text/plain' === $phpmailer->ContentType || !empty($phpmailer->AltBody)) {
100
+        if( 'text/plain' === $phpmailer->ContentType || !empty($phpmailer->AltBody) ) {
101 101
             return;
102 102
         }
103
-        $message = $this->stripHtmlTags($phpmailer->Body);
104
-        $phpmailer->AltBody = apply_filters('site-reviews/email/message', $message, 'text', $this);
103
+        $message = $this->stripHtmlTags( $phpmailer->Body );
104
+        $phpmailer->AltBody = apply_filters( 'site-reviews/email/message', $message, 'text', $this );
105 105
     }
106 106
 
107 107
     /**
@@ -112,14 +112,14 @@  discard block
 block discarded – undo
112 112
         $allowed = [
113 113
             'bcc', 'cc', 'from', 'reply-to',
114 114
         ];
115
-        $headers = array_intersect_key($this->email, array_flip($allowed));
116
-        $headers = array_filter($headers);
117
-        foreach ($headers as $key => $value) {
115
+        $headers = array_intersect_key( $this->email, array_flip( $allowed ) );
116
+        $headers = array_filter( $headers );
117
+        foreach( $headers as $key => $value ) {
118 118
             unset($headers[$key]);
119 119
             $headers[] = $key.': '.$value;
120 120
         }
121 121
         $headers[] = 'Content-Type: text/html';
122
-        return apply_filters('site-reviews/email/headers', $headers, $this);
122
+        return apply_filters( 'site-reviews/email/headers', $headers, $this );
123 123
     }
124 124
 
125 125
     /**
@@ -127,54 +127,54 @@  discard block
 block discarded – undo
127 127
      */
128 128
     protected function buildHtmlMessage()
129 129
     {
130
-        $template = trim(glsr(OptionManager::class)->get('settings.general.notification_message'));
131
-        if (!empty($template)) {
132
-            $message = glsr(Template::class)->interpolate(
130
+        $template = trim( glsr( OptionManager::class )->get( 'settings.general.notification_message' ) );
131
+        if( !empty($template) ) {
132
+            $message = glsr( Template::class )->interpolate(
133 133
                 $template, 
134 134
                 ['context' => $this->email['template-tags']], 
135 135
                 $this->email['template']
136 136
             );
137
-        } elseif ($this->email['template']) {
138
-            $message = glsr(Template::class)->build('templates/'.$this->email['template'], [
137
+        } elseif( $this->email['template'] ) {
138
+            $message = glsr( Template::class )->build( 'templates/'.$this->email['template'], [
139 139
                 'context' => $this->email['template-tags'],
140
-            ]);
140
+            ] );
141 141
         }
142
-        if (!isset($message)) {
142
+        if( !isset($message) ) {
143 143
             $message = $this->email['message'];
144 144
         }
145 145
         $message = $this->email['before'].$message.$this->email['after'];
146
-        $message = strip_shortcodes($message);
147
-        $message = wptexturize($message);
148
-        $message = wpautop($message);
149
-        $message = str_replace('&lt;&gt; ', '', $message);
150
-        $message = str_replace(']]>', ']]&gt;', $message);
151
-        $message = glsr(Template::class)->build('partials/email/index', [
146
+        $message = strip_shortcodes( $message );
147
+        $message = wptexturize( $message );
148
+        $message = wpautop( $message );
149
+        $message = str_replace( '&lt;&gt; ', '', $message );
150
+        $message = str_replace( ']]>', ']]&gt;', $message );
151
+        $message = glsr( Template::class )->build( 'partials/email/index', [
152 152
             'context' => ['message' => $message],
153
-        ]);
154
-        return apply_filters('site-reviews/email/message', stripslashes($message), 'html', $this);
153
+        ] );
154
+        return apply_filters( 'site-reviews/email/message', stripslashes( $message ), 'html', $this );
155 155
     }
156 156
 
157 157
     /**
158 158
      * @param \WP_Error $error
159 159
      * @return void
160 160
      */
161
-    protected function logMailError($error)
161
+    protected function logMailError( $error )
162 162
     {
163
-        glsr_log()->error('Email was not sent (wp_mail failed)')
164
-            ->debug($this)
165
-            ->debug($error);
163
+        glsr_log()->error( 'Email was not sent (wp_mail failed)' )
164
+            ->debug( $this )
165
+            ->debug( $error );
166 166
     }
167 167
 
168 168
     /**
169 169
      * @return void
170 170
      */
171
-    protected function normalize(array $email = [])
171
+    protected function normalize( array $email = [] )
172 172
     {
173
-        $email = shortcode_atts(glsr(EmailDefaults::class)->defaults(), $email);
174
-        if (empty($email['reply-to'])) {
173
+        $email = shortcode_atts( glsr( EmailDefaults::class )->defaults(), $email );
174
+        if( empty($email['reply-to']) ) {
175 175
             $email['reply-to'] = $email['from'];
176 176
         }
177
-        $this->email = apply_filters('site-reviews/email/compose', $email, $this);
177
+        $this->email = apply_filters( 'site-reviews/email/compose', $email, $this );
178 178
     }
179 179
 
180 180
     /**
@@ -193,21 +193,21 @@  discard block
 block discarded – undo
193 193
     /**
194 194
      * @return string
195 195
      */
196
-    protected function stripHtmlTags($string)
196
+    protected function stripHtmlTags( $string )
197 197
     {
198 198
         // remove invisible elements
199
-        $string = preg_replace('@<(embed|head|noembed|noscript|object|script|style)[^>]*?>.*?</\\1>@siu', '', $string);
199
+        $string = preg_replace( '@<(embed|head|noembed|noscript|object|script|style)[^>]*?>.*?</\\1>@siu', '', $string );
200 200
         // replace certain elements with a line-break
201
-        $string = preg_replace('@</(div|h[1-9]|p|pre|tr)@iu', "\r\n\$0", $string);
201
+        $string = preg_replace( '@</(div|h[1-9]|p|pre|tr)@iu', "\r\n\$0", $string );
202 202
         // replace other elements with a space
203
-        $string = preg_replace('@</(td|th)@iu', ' $0', $string);
203
+        $string = preg_replace( '@</(td|th)@iu', ' $0', $string );
204 204
         // add a placeholder for plain-text bullets to list elements
205
-        $string = preg_replace('@<(li)[^>]*?>@siu', '$0-o-^-o-', $string);
205
+        $string = preg_replace( '@<(li)[^>]*?>@siu', '$0-o-^-o-', $string );
206 206
         // strip all remaining HTML tags
207
-        $string = wp_strip_all_tags($string);
208
-        $string = wp_specialchars_decode($string, ENT_QUOTES);
209
-        $string = preg_replace('/\v(?:[\v\h]+){2,}/', "\r\n\r\n", $string);
210
-        $string = str_replace('-o-^-o-', ' - ', $string);
211
-        return html_entity_decode($string, ENT_QUOTES, 'UTF-8');
207
+        $string = wp_strip_all_tags( $string );
208
+        $string = wp_specialchars_decode( $string, ENT_QUOTES );
209
+        $string = preg_replace( '/\v(?:[\v\h]+){2,}/', "\r\n\r\n", $string );
210
+        $string = str_replace( '-o-^-o-', ' - ', $string );
211
+        return html_entity_decode( $string, ENT_QUOTES, 'UTF-8' );
212 212
     }
213 213
 }
Please login to merge, or discard this patch.
plugin/Modules/Translation.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
     public function all()
30 30
     {
31 31
         $translations = $this->translations();
32
-        $entries = $this->filter($translations, $this->entries())->results();
33
-        array_walk($translations, function (&$entry) use ($entries) {
34
-            $entry['desc'] = array_key_exists($entry['id'], $entries)
35
-                ? $this->getEntryString($entries[$entry['id']], 'msgctxt')
32
+        $entries = $this->filter( $translations, $this->entries() )->results();
33
+        array_walk( $translations, function( &$entry ) use ($entries) {
34
+            $entry['desc'] = array_key_exists( $entry['id'], $entries )
35
+                ? $this->getEntryString( $entries[$entry['id']], 'msgctxt' )
36 36
                 : '';
37 37
         });
38 38
         return $translations;
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function entries()
45 45
     {
46
-        if (!isset($this->entries)) {
47
-            $potFile = glsr()->path(glsr()->languages.'/'.Application::ID.'.pot');
48
-            $entries = $this->extractEntriesFromPotFile($potFile);
49
-            $entries = apply_filters('site-reviews/translation/entries', $entries);
46
+        if( !isset($this->entries) ) {
47
+            $potFile = glsr()->path( glsr()->languages.'/'.Application::ID.'.pot' );
48
+            $entries = $this->extractEntriesFromPotFile( $potFile );
49
+            $entries = apply_filters( 'site-reviews/translation/entries', $entries );
50 50
             $this->entries = $entries;
51 51
         }
52 52
         return $this->entries;
@@ -57,24 +57,24 @@  discard block
 block discarded – undo
57 57
      * @param array|null $entries
58 58
      * @return static
59 59
      */
60
-    public function exclude($entriesToExclude = null, $entries = null)
60
+    public function exclude( $entriesToExclude = null, $entries = null )
61 61
     {
62
-        return $this->filter($entriesToExclude, $entries, false);
62
+        return $this->filter( $entriesToExclude, $entries, false );
63 63
     }
64 64
 
65 65
     /**
66 66
      * @param string $potFile
67 67
      * @return array
68 68
      */
69
-    public function extractEntriesFromPotFile($potFile, array $entries = [])
69
+    public function extractEntriesFromPotFile( $potFile, array $entries = [] )
70 70
     {
71 71
         try {
72
-            $potEntries = $this->normalize(Parser::parseFile($potFile)->getEntries());
73
-            foreach ($potEntries as $key => $entry) {
74
-                $entries[html_entity_decode($key, ENT_COMPAT, 'UTF-8')] = $entry;
72
+            $potEntries = $this->normalize( Parser::parseFile( $potFile )->getEntries() );
73
+            foreach( $potEntries as $key => $entry ) {
74
+                $entries[html_entity_decode( $key, ENT_COMPAT, 'UTF-8' )] = $entry;
75 75
             }
76
-        } catch (Exception $e) {
77
-            glsr_log()->error($e->getMessage());
76
+        } catch( Exception $e ) {
77
+            glsr_log()->error( $e->getMessage() );
78 78
         }
79 79
         return $entries;
80 80
     }
@@ -85,18 +85,18 @@  discard block
 block discarded – undo
85 85
      * @param bool $intersect
86 86
      * @return static
87 87
      */
88
-    public function filter($filterWith = null, $entries = null, $intersect = true)
88
+    public function filter( $filterWith = null, $entries = null, $intersect = true )
89 89
     {
90
-        if (!is_array($entries)) {
90
+        if( !is_array( $entries ) ) {
91 91
             $entries = $this->results;
92 92
         }
93
-        if (!is_array($filterWith)) {
93
+        if( !is_array( $filterWith ) ) {
94 94
             $filterWith = $this->translations();
95 95
         }
96
-        $keys = array_flip(glsr_array_column($filterWith, 'id'));
96
+        $keys = array_flip( glsr_array_column( $filterWith, 'id' ) );
97 97
         $this->results = $intersect
98
-            ? array_intersect_key($entries, $keys)
99
-            : array_diff_key($entries, $keys);
98
+            ? array_intersect_key( $entries, $keys )
99
+            : array_diff_key( $entries, $keys );
100 100
         return $this;
101 101
     }
102 102
 
@@ -104,20 +104,20 @@  discard block
 block discarded – undo
104 104
      * @param string $template
105 105
      * @return string
106 106
      */
107
-    public function render($template, array $entry)
107
+    public function render( $template, array $entry )
108 108
     {
109 109
         $data = array_combine(
110
-            array_map(function ($key) { return 'data.'.$key; }, array_keys($entry)),
110
+            array_map( function( $key ) { return 'data.'.$key; }, array_keys( $entry ) ),
111 111
             $entry
112 112
         );
113 113
         $data['data.class'] = $data['data.error'] = '';
114
-        if (false === array_search($entry['s1'], glsr_array_column($this->entries(), 'msgid'))) {
114
+        if( false === array_search( $entry['s1'], glsr_array_column( $this->entries(), 'msgid' ) ) ) {
115 115
             $data['data.class'] = 'is-invalid';
116
-            $data['data.error'] = __('This custom translation is no longer valid as the original text has been changed or removed.', 'site-reviews');
116
+            $data['data.error'] = __( 'This custom translation is no longer valid as the original text has been changed or removed.', 'site-reviews' );
117 117
         }
118
-        return glsr(Template::class)->build('partials/translations/'.$template, [
119
-            'context' => array_map('esc_html', $data),
120
-        ]);
118
+        return glsr( Template::class )->build( 'partials/translations/'.$template, [
119
+            'context' => array_map( 'esc_html', $data ),
120
+        ] );
121 121
     }
122 122
 
123 123
     /**
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
     public function renderAll()
128 128
     {
129 129
         $rendered = '';
130
-        foreach ($this->all() as $index => $entry) {
130
+        foreach( $this->all() as $index => $entry ) {
131 131
             $entry['index'] = $index;
132 132
             $entry['prefix'] = OptionManager::databaseKey();
133
-            $rendered.= $this->render($entry['type'], $entry);
133
+            $rendered .= $this->render( $entry['type'], $entry );
134 134
         }
135 135
         return $rendered;
136 136
     }
@@ -139,25 +139,25 @@  discard block
 block discarded – undo
139 139
      * @param bool $resetAfterRender
140 140
      * @return string
141 141
      */
142
-    public function renderResults($resetAfterRender = true)
142
+    public function renderResults( $resetAfterRender = true )
143 143
     {
144 144
         $rendered = '';
145
-        foreach ($this->results as $id => $entry) {
145
+        foreach( $this->results as $id => $entry ) {
146 146
             $data = [
147
-                'desc' => $this->getEntryString($entry, 'msgctxt'),
147
+                'desc' => $this->getEntryString( $entry, 'msgctxt' ),
148 148
                 'id' => $id,
149
-                'p1' => $this->getEntryString($entry, 'msgid_plural'),
150
-                's1' => $this->getEntryString($entry, 'msgid'),
149
+                'p1' => $this->getEntryString( $entry, 'msgid_plural' ),
150
+                's1' => $this->getEntryString( $entry, 'msgid' ),
151 151
             ];
152 152
             $text = !empty($data['p1'])
153
-                ? sprintf('%s | %s', $data['s1'], $data['p1'])
153
+                ? sprintf( '%s | %s', $data['s1'], $data['p1'] )
154 154
                 : $data['s1'];
155
-            $rendered.= $this->render('result', [
156
-                'entry' => json_encode($data, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE),
157
-                'text' => wp_strip_all_tags($text),
158
-            ]);
155
+            $rendered .= $this->render( 'result', [
156
+                'entry' => json_encode( $data, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ),
157
+                'text' => wp_strip_all_tags( $text ),
158
+            ] );
159 159
         }
160
-        if ($resetAfterRender) {
160
+        if( $resetAfterRender ) {
161 161
             $this->reset();
162 162
         }
163 163
         return $rendered;
@@ -185,18 +185,18 @@  discard block
 block discarded – undo
185 185
      * @param string $needle
186 186
      * @return static
187 187
      */
188
-    public function search($needle = '')
188
+    public function search( $needle = '' )
189 189
     {
190 190
         $this->reset();
191
-        $needle = trim(strtolower($needle));
192
-        foreach ($this->entries() as $key => $entry) {
193
-            $single = strtolower($this->getEntryString($entry, 'msgid'));
194
-            $plural = strtolower($this->getEntryString($entry, 'msgid_plural'));
195
-            if (strlen($needle) < static::SEARCH_THRESHOLD) {
196
-                if (in_array($needle, [$single, $plural])) {
191
+        $needle = trim( strtolower( $needle ) );
192
+        foreach( $this->entries() as $key => $entry ) {
193
+            $single = strtolower( $this->getEntryString( $entry, 'msgid' ) );
194
+            $plural = strtolower( $this->getEntryString( $entry, 'msgid_plural' ) );
195
+            if( strlen( $needle ) < static::SEARCH_THRESHOLD ) {
196
+                if( in_array( $needle, [$single, $plural] ) ) {
197 197
                     $this->results[$key] = $entry;
198 198
                 }
199
-            } elseif (false !== strpos(sprintf('%s %s', $single, $plural), $needle)) {
199
+            } elseif( false !== strpos( sprintf( '%s %s', $single, $plural ), $needle ) ) {
200 200
                 $this->results[$key] = $entry;
201 201
             }
202 202
         }
@@ -210,10 +210,10 @@  discard block
 block discarded – undo
210 210
     public function translations()
211 211
     {
212 212
         static $translations;
213
-        if (empty($translations)) {
214
-            $settings = glsr(OptionManager::class)->get('settings');
213
+        if( empty($translations) ) {
214
+            $settings = glsr( OptionManager::class )->get( 'settings' );
215 215
             $translations = isset($settings['strings'])
216
-                ? $this->normalizeSettings((array) $settings['strings'])
216
+                ? $this->normalizeSettings( (array)$settings['strings'] )
217 217
                 : [];
218 218
         }
219 219
         return $translations;
@@ -223,28 +223,28 @@  discard block
 block discarded – undo
223 223
      * @param string $key
224 224
      * @return string
225 225
      */
226
-    protected function getEntryString(array $entry, $key)
226
+    protected function getEntryString( array $entry, $key )
227 227
     {
228 228
         return isset($entry[$key])
229
-            ? implode('', (array) $entry[$key])
229
+            ? implode( '', (array)$entry[$key] )
230 230
             : '';
231 231
     }
232 232
 
233 233
     /**
234 234
      * @return array
235 235
      */
236
-    protected function normalize(array $entries)
236
+    protected function normalize( array $entries )
237 237
     {
238 238
         $keys = [
239 239
             'msgctxt', 'msgid', 'msgid_plural', 'msgstr', 'msgstr[0]', 'msgstr[1]',
240 240
         ];
241
-        array_walk($entries, function (&$entry) use ($keys) {
242
-            foreach ($keys as $key) {
241
+        array_walk( $entries, function( &$entry ) use ($keys) {
242
+            foreach( $keys as $key ) {
243 243
                 try {
244
-                    $entry = $this->normalizeEntryString($entry, $key);
245
-                } catch (\TypeError $error) {
246
-                    glsr_log()->once('error', 'Translation/normalize', $error);
247
-                    glsr_log()->once('debug', 'Translation/normalize', $entry);
244
+                    $entry = $this->normalizeEntryString( $entry, $key );
245
+                } catch( \TypeError $error ) {
246
+                    glsr_log()->once( 'error', 'Translation/normalize', $error );
247
+                    glsr_log()->once( 'debug', 'Translation/normalize', $entry );
248 248
                 }
249 249
             }
250 250
         });
@@ -255,10 +255,10 @@  discard block
 block discarded – undo
255 255
      * @param string $key
256 256
      * @return array
257 257
      */
258
-    protected function normalizeEntryString(array $entry, $key)
258
+    protected function normalizeEntryString( array $entry, $key )
259 259
     {
260
-        if (isset($entry[$key])) {
261
-            $entry[$key] = $this->getEntryString($entry, $key);
260
+        if( isset($entry[$key]) ) {
261
+            $entry[$key] = $this->getEntryString( $entry, $key );
262 262
         }
263 263
         return $entry;
264 264
     }
@@ -266,15 +266,15 @@  discard block
 block discarded – undo
266 266
     /**
267 267
      * @return array
268 268
      */
269
-    protected function normalizeSettings(array $strings)
269
+    protected function normalizeSettings( array $strings )
270 270
     {
271
-        $defaultString = array_fill_keys(['id', 's1', 's2', 'p1', 'p2'], '');
272
-        $strings = array_filter($strings, 'is_array');
273
-        foreach ($strings as &$string) {
271
+        $defaultString = array_fill_keys( ['id', 's1', 's2', 'p1', 'p2'], '' );
272
+        $strings = array_filter( $strings, 'is_array' );
273
+        foreach( $strings as &$string ) {
274 274
             $string['type'] = isset($string['p1']) ? 'plural' : 'single';
275
-            $string = wp_parse_args($string, $defaultString);
275
+            $string = wp_parse_args( $string, $defaultString );
276 276
         }
277
-        return array_filter($strings, function ($string) {
277
+        return array_filter( $strings, function( $string ) {
278 278
             return !empty($string['id']);
279 279
         });
280 280
     }
Please login to merge, or discard this patch.
plugin/Modules/Html/Partials/SiteReviews.php 1 patch
Spacing   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -45,13 +45,13 @@  discard block
 block discarded – undo
45 45
      * @param Reviews|null $reviews
46 46
      * @return ReviewsHtml
47 47
      */
48
-    public function build(array $args = [], $reviews = null)
48
+    public function build( array $args = [], $reviews = null )
49 49
     {
50
-        $this->args = glsr(SiteReviewsDefaults::class)->merge($args);
51
-        $this->options = Arr::flattenArray(glsr(OptionManager::class)->all());
50
+        $this->args = glsr( SiteReviewsDefaults::class )->merge( $args );
51
+        $this->options = Arr::flattenArray( glsr( OptionManager::class )->all() );
52 52
         $this->reviews = $reviews instanceof Reviews
53 53
             ? $reviews
54
-            : glsr(ReviewManager::class)->get($this->args);
54
+            : glsr( ReviewManager::class )->get( $this->args );
55 55
         $this->generateSchema();
56 56
         return $this->buildReviews();
57 57
     }
@@ -59,26 +59,26 @@  discard block
 block discarded – undo
59 59
     /**
60 60
      * @return ReviewHtml
61 61
      */
62
-    public function buildReview(Review $review)
62
+    public function buildReview( Review $review )
63 63
     {
64
-        $review = apply_filters('site-reviews/review/build/before', $review);
64
+        $review = apply_filters( 'site-reviews/review/build/before', $review );
65 65
         $this->current = $review;
66 66
         $renderedFields = [];
67
-        foreach ($review as $key => $value) {
68
-            $method = Helper::buildMethodName($key, 'buildOption');
69
-            $field = method_exists($this, $method)
70
-                ? $this->$method($key, $value)
67
+        foreach( $review as $key => $value ) {
68
+            $method = Helper::buildMethodName( $key, 'buildOption' );
69
+            $field = method_exists( $this, $method )
70
+                ? $this->$method( $key, $value )
71 71
                 : false;
72
-            $field = apply_filters('site-reviews/review/build/'.$key, $field, $value, $review, $this);
73
-            if (false === $field) {
72
+            $field = apply_filters( 'site-reviews/review/build/'.$key, $field, $value, $review, $this );
73
+            if( false === $field ) {
74 74
                 continue;
75 75
             }
76 76
             $renderedFields[$key] = $field;
77 77
         }
78
-        $this->wrap($renderedFields, $review);
79
-        $renderedFields = apply_filters('site-reviews/review/build/after', $renderedFields, $review, $this);
78
+        $this->wrap( $renderedFields, $review );
79
+        $renderedFields = apply_filters( 'site-reviews/review/build/after', $renderedFields, $review, $this );
80 80
         $this->current = null;
81
-        return new ReviewHtml($review, (array) $renderedFields);
81
+        return new ReviewHtml( $review, (array)$renderedFields );
82 82
     }
83 83
 
84 84
     /**
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
     public function buildReviews()
88 88
     {
89 89
         $renderedReviews = [];
90
-        foreach ($this->reviews as $index => $review) {
91
-            $renderedReviews[] = $this->buildReview($review);
90
+        foreach( $this->reviews as $index => $review ) {
91
+            $renderedReviews[] = $this->buildReview( $review );
92 92
         }
93
-        return new ReviewsHtml($renderedReviews, $this->reviews->max_num_pages, $this->args);
93
+        return new ReviewsHtml( $renderedReviews, $this->reviews->max_num_pages, $this->args );
94 94
     }
95 95
 
96 96
     /**
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
      */
99 99
     public function generateSchema()
100 100
     {
101
-        if (!wp_validate_boolean($this->args['schema'])) {
101
+        if( !wp_validate_boolean( $this->args['schema'] ) ) {
102 102
             return;
103 103
         }
104
-        glsr(Schema::class)->store(
105
-            glsr(Schema::class)->build($this->args)
104
+        glsr( Schema::class )->store(
105
+            glsr( Schema::class )->build( $this->args )
106 106
         );
107 107
     }
108 108
 
@@ -110,20 +110,20 @@  discard block
 block discarded – undo
110 110
      * @param string $text
111 111
      * @return string
112 112
      */
113
-    public function getExcerpt($text)
113
+    public function getExcerpt( $text )
114 114
     {
115
-        $limit = intval($this->getOption('settings.reviews.excerpts_length', 55));
116
-        $split = extension_loaded('intl')
117
-            ? $this->getExcerptIntlSplit($text, $limit)
118
-            : $this->getExcerptSplit($text, $limit);
119
-        $hiddenText = substr($text, $split);
120
-        if (!empty($hiddenText)) {
121
-            $showMore = glsr(Builder::class)->span($hiddenText, [
115
+        $limit = intval( $this->getOption( 'settings.reviews.excerpts_length', 55 ) );
116
+        $split = extension_loaded( 'intl' )
117
+            ? $this->getExcerptIntlSplit( $text, $limit )
118
+            : $this->getExcerptSplit( $text, $limit );
119
+        $hiddenText = substr( $text, $split );
120
+        if( !empty($hiddenText) ) {
121
+            $showMore = glsr( Builder::class )->span( $hiddenText, [
122 122
                 'class' => 'glsr-hidden glsr-hidden-text',
123
-                'data-show-less' => __('Show less', 'site-reviews'),
124
-                'data-show-more' => __('Show more', 'site-reviews'),
125
-            ]);
126
-            $text = ltrim(substr($text, 0, $split)).$showMore;
123
+                'data-show-less' => __( 'Show less', 'site-reviews' ),
124
+                'data-show-more' => __( 'Show more', 'site-reviews' ),
125
+            ] );
126
+            $text = ltrim( substr( $text, 0, $split ) ).$showMore;
127 127
         }
128 128
         return $text;
129 129
     }
@@ -133,12 +133,12 @@  discard block
 block discarded – undo
133 133
      * @param string $path
134 134
      * @return bool
135 135
      */
136
-    public function isHidden($key, $path = '')
136
+    public function isHidden( $key, $path = '' )
137 137
     {
138 138
         $isOptionEnabled = !empty($path)
139
-            ? $this->isOptionEnabled($path)
139
+            ? $this->isOptionEnabled( $path )
140 140
             : true;
141
-        return in_array($key, $this->args['hide']) || !$isOptionEnabled;
141
+        return in_array( $key, $this->args['hide'] ) || !$isOptionEnabled;
142 142
     }
143 143
 
144 144
     /**
@@ -146,25 +146,25 @@  discard block
 block discarded – undo
146 146
      * @param string $value
147 147
      * @return bool
148 148
      */
149
-    public function isHiddenOrEmpty($key, $value)
149
+    public function isHiddenOrEmpty( $key, $value )
150 150
     {
151
-        return $this->isHidden($key) || empty($value);
151
+        return $this->isHidden( $key ) || empty($value);
152 152
     }
153 153
 
154 154
     /**
155 155
      * @param string $text
156 156
      * @return string
157 157
      */
158
-    public function normalizeText($text)
158
+    public function normalizeText( $text )
159 159
     {
160
-        $text = wp_kses($text, wp_kses_allowed_html());
161
-        $text = convert_smilies(strip_shortcodes($text));
162
-        $text = str_replace(']]>', ']]&gt;', $text);
163
-        $text = preg_replace('/(\R){2,}/', '$1', $text);
164
-        if ($this->isOptionEnabled('settings.reviews.excerpts')) {
165
-            $text = $this->getExcerpt($text);
160
+        $text = wp_kses( $text, wp_kses_allowed_html() );
161
+        $text = convert_smilies( strip_shortcodes( $text ) );
162
+        $text = str_replace( ']]>', ']]&gt;', $text );
163
+        $text = preg_replace( '/(\R){2,}/', '$1', $text );
164
+        if( $this->isOptionEnabled( 'settings.reviews.excerpts' ) ) {
165
+            $text = $this->getExcerpt( $text );
166 166
         }
167
-        return wptexturize(nl2br($text));
167
+        return wptexturize( nl2br( $text ) );
168 168
     }
169 169
 
170 170
     /**
@@ -172,19 +172,19 @@  discard block
 block discarded – undo
172 172
      * @param string $value
173 173
      * @return void|string
174 174
      */
175
-    protected function buildOptionAssignedTo($key, $value)
175
+    protected function buildOptionAssignedTo( $key, $value )
176 176
     {
177
-        if ($this->isHidden($key, 'settings.reviews.assigned_links')) {
177
+        if( $this->isHidden( $key, 'settings.reviews.assigned_links' ) ) {
178 178
             return;
179 179
         }
180
-        $post = glsr(Polylang::class)->getPost($value);
181
-        if (!($post instanceof WP_Post)) {
180
+        $post = glsr( Polylang::class )->getPost( $value );
181
+        if( !($post instanceof WP_Post) ) {
182 182
             return;
183 183
         }
184
-        $permalink = glsr(Builder::class)->a(get_the_title($post->ID), [
185
-            'href' => get_the_permalink($post->ID),
186
-        ]);
187
-        $assignedTo = sprintf(__('Review of %s', 'site-reviews'), $permalink);
184
+        $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [
185
+            'href' => get_the_permalink( $post->ID ),
186
+        ] );
187
+        $assignedTo = sprintf( __( 'Review of %s', 'site-reviews' ), $permalink );
188 188
         return '<span>'.$assignedTo.'</span>';
189 189
     }
190 190
 
@@ -193,13 +193,13 @@  discard block
 block discarded – undo
193 193
      * @param string $value
194 194
      * @return void|string
195 195
      */
196
-    protected function buildOptionAuthor($key, $value)
196
+    protected function buildOptionAuthor( $key, $value )
197 197
     {
198
-        if (!$this->isHidden($key)) {
198
+        if( !$this->isHidden( $key ) ) {
199 199
             $name = Str::convertName(
200 200
                 $value,
201
-                glsr_get_option('reviews.name.format'),
202
-                glsr_get_option('reviews.name.initial')
201
+                glsr_get_option( 'reviews.name.format' ),
202
+                glsr_get_option( 'reviews.name.initial' )
203 203
             );
204 204
             return '<span>'.$name.'</span>';
205 205
         }
@@ -210,18 +210,18 @@  discard block
 block discarded – undo
210 210
      * @param string $value
211 211
      * @return void|string
212 212
      */
213
-    protected function buildOptionAvatar($key, $value)
213
+    protected function buildOptionAvatar( $key, $value )
214 214
     {
215
-        if ($this->isHidden($key, 'settings.reviews.avatars')) {
215
+        if( $this->isHidden( $key, 'settings.reviews.avatars' ) ) {
216 216
             return;
217 217
         }
218
-        $size = $this->getOption('settings.reviews.avatars_size', 40);
219
-        return glsr(Builder::class)->img([
218
+        $size = $this->getOption( 'settings.reviews.avatars_size', 40 );
219
+        return glsr( Builder::class )->img( [
220 220
             'height' => $size,
221
-            'src' => $this->generateAvatar($value),
222
-            'style' => sprintf('width:%1$spx; height:%1$spx;', $size),
221
+            'src' => $this->generateAvatar( $value ),
222
+            'style' => sprintf( 'width:%1$spx; height:%1$spx;', $size ),
223 223
             'width' => $size,
224
-        ]);
224
+        ] );
225 225
     }
226 226
 
227 227
     /**
@@ -229,10 +229,10 @@  discard block
 block discarded – undo
229 229
      * @param string $value
230 230
      * @return void|string
231 231
      */
232
-    protected function buildOptionContent($key, $value)
232
+    protected function buildOptionContent( $key, $value )
233 233
     {
234
-        $text = $this->normalizeText($value);
235
-        if (!$this->isHiddenOrEmpty($key, $text)) {
234
+        $text = $this->normalizeText( $value );
235
+        if( !$this->isHiddenOrEmpty( $key, $text ) ) {
236 236
             return '<p>'.$text.'</p>';
237 237
         }
238 238
     }
@@ -242,19 +242,19 @@  discard block
 block discarded – undo
242 242
      * @param string $value
243 243
      * @return void|string
244 244
      */
245
-    protected function buildOptionDate($key, $value)
245
+    protected function buildOptionDate( $key, $value )
246 246
     {
247
-        if ($this->isHidden($key)) {
247
+        if( $this->isHidden( $key ) ) {
248 248
             return;
249 249
         }
250
-        $dateFormat = $this->getOption('settings.reviews.date.format', 'default');
251
-        if ('relative' == $dateFormat) {
252
-            $date = glsr(Date::class)->relative($value);
250
+        $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' );
251
+        if( 'relative' == $dateFormat ) {
252
+            $date = glsr( Date::class )->relative( $value );
253 253
         } else {
254 254
             $format = 'custom' == $dateFormat
255
-                ? $this->getOption('settings.reviews.date.custom', 'M j, Y')
256
-                : glsr(OptionManager::class)->getWP('date_format', 'F j, Y');
257
-            $date = date_i18n($format, strtotime($value));
255
+                ? $this->getOption( 'settings.reviews.date.custom', 'M j, Y' )
256
+                : glsr( OptionManager::class )->getWP( 'date_format', 'F j, Y' );
257
+            $date = date_i18n( $format, strtotime( $value ) );
258 258
         }
259 259
         return '<span>'.$date.'</span>';
260 260
     }
@@ -264,10 +264,10 @@  discard block
 block discarded – undo
264 264
      * @param string $value
265 265
      * @return void|string
266 266
      */
267
-    protected function buildOptionRating($key, $value)
267
+    protected function buildOptionRating( $key, $value )
268 268
     {
269
-        if (!$this->isHiddenOrEmpty($key, $value)) {
270
-            return glsr_star_rating($value);
269
+        if( !$this->isHiddenOrEmpty( $key, $value ) ) {
270
+            return glsr_star_rating( $value );
271 271
         }
272 272
     }
273 273
 
@@ -276,16 +276,16 @@  discard block
 block discarded – undo
276 276
      * @param string $value
277 277
      * @return void|string
278 278
      */
279
-    protected function buildOptionResponse($key, $value)
279
+    protected function buildOptionResponse( $key, $value )
280 280
     {
281
-        if ($this->isHiddenOrEmpty($key, $value)) {
281
+        if( $this->isHiddenOrEmpty( $key, $value ) ) {
282 282
             return;
283 283
         }
284
-        $title = sprintf(__('Response from %s', 'site-reviews'), get_bloginfo('name'));
285
-        $text = $this->normalizeText($value);
284
+        $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ) );
285
+        $text = $this->normalizeText( $value );
286 286
         $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>';
287
-        $response = glsr(Builder::class)->div($text, ['class' => 'glsr-review-response-inner']);
288
-        $background = glsr(Builder::class)->div(['class' => 'glsr-review-response-background']);
287
+        $response = glsr( Builder::class )->div( $text, ['class' => 'glsr-review-response-inner'] );
288
+        $background = glsr( Builder::class )->div( ['class' => 'glsr-review-response-background'] );
289 289
         return $response.$background;
290 290
     }
291 291
 
@@ -294,13 +294,13 @@  discard block
 block discarded – undo
294 294
      * @param string $value
295 295
      * @return void|string
296 296
      */
297
-    protected function buildOptionTitle($key, $value)
297
+    protected function buildOptionTitle( $key, $value )
298 298
     {
299
-        if ($this->isHidden($key)) {
299
+        if( $this->isHidden( $key ) ) {
300 300
             return;
301 301
         }
302
-        if (empty($value)) {
303
-            $value = __('No Title', 'site-reviews');
302
+        if( empty($value) ) {
303
+            $value = __( 'No Title', 'site-reviews' );
304 304
         }
305 305
         return '<h3>'.$value.'</h3>';
306 306
     }
@@ -309,16 +309,16 @@  discard block
 block discarded – undo
309 309
      * @param string $avatarUrl
310 310
      * @return string
311 311
      */
312
-    protected function generateAvatar($avatarUrl)
312
+    protected function generateAvatar( $avatarUrl )
313 313
     {
314
-        if (!$this->isOptionEnabled('settings.reviews.avatars_regenerate') || 'local' != $this->current->review_type) {
314
+        if( !$this->isOptionEnabled( 'settings.reviews.avatars_regenerate' ) || 'local' != $this->current->review_type ) {
315 315
             return $avatarUrl;
316 316
         }
317
-        $authorIdOrEmail = get_the_author_meta('ID', $this->current->user_id);
318
-        if (empty($authorIdOrEmail)) {
317
+        $authorIdOrEmail = get_the_author_meta( 'ID', $this->current->user_id );
318
+        if( empty($authorIdOrEmail) ) {
319 319
             $authorIdOrEmail = $this->current->email;
320 320
         }
321
-        if ($newAvatar = get_avatar_url($authorIdOrEmail)) {
321
+        if( $newAvatar = get_avatar_url( $authorIdOrEmail ) ) {
322 322
             return $newAvatar;
323 323
         }
324 324
         return $avatarUrl;
@@ -329,22 +329,22 @@  discard block
 block discarded – undo
329 329
      * @param int $limit
330 330
      * @return int
331 331
      */
332
-    protected function getExcerptIntlSplit($text, $limit)
332
+    protected function getExcerptIntlSplit( $text, $limit )
333 333
     {
334
-        $words = IntlRuleBasedBreakIterator::createWordInstance('');
335
-        $words->setText($text);
334
+        $words = IntlRuleBasedBreakIterator::createWordInstance( '' );
335
+        $words->setText( $text );
336 336
         $count = 0;
337
-        foreach ($words as $offset) {
338
-            if (IntlRuleBasedBreakIterator::WORD_NONE === $words->getRuleStatus()) {
337
+        foreach( $words as $offset ) {
338
+            if( IntlRuleBasedBreakIterator::WORD_NONE === $words->getRuleStatus() ) {
339 339
                 continue;
340 340
             }
341 341
             ++$count;
342
-            if ($count != $limit) {
342
+            if( $count != $limit ) {
343 343
                 continue;
344 344
             }
345 345
             return $offset;
346 346
         }
347
-        return strlen($text);
347
+        return strlen( $text );
348 348
     }
349 349
 
350 350
     /**
@@ -352,13 +352,13 @@  discard block
 block discarded – undo
352 352
      * @param int $limit
353 353
      * @return int
354 354
      */
355
-    protected function getExcerptSplit($text, $limit)
355
+    protected function getExcerptSplit( $text, $limit )
356 356
     {
357
-        if (str_word_count($text, 0) > $limit) {
358
-            $words = array_keys(str_word_count($text, 2));
357
+        if( str_word_count( $text, 0 ) > $limit ) {
358
+            $words = array_keys( str_word_count( $text, 2 ) );
359 359
             return $words[$limit];
360 360
         }
361
-        return strlen($text);
361
+        return strlen( $text );
362 362
     }
363 363
 
364 364
     /**
@@ -366,9 +366,9 @@  discard block
 block discarded – undo
366 366
      * @param mixed $fallback
367 367
      * @return mixed
368 368
      */
369
-    protected function getOption($path, $fallback = '')
369
+    protected function getOption( $path, $fallback = '' )
370 370
     {
371
-        if (array_key_exists($path, $this->options)) {
371
+        if( array_key_exists( $path, $this->options ) ) {
372 372
             return $this->options[$path];
373 373
         }
374 374
         return $fallback;
@@ -378,25 +378,25 @@  discard block
 block discarded – undo
378 378
      * @param string $path
379 379
      * @return bool
380 380
      */
381
-    protected function isOptionEnabled($path)
381
+    protected function isOptionEnabled( $path )
382 382
     {
383
-        return 'yes' == $this->getOption($path);
383
+        return 'yes' == $this->getOption( $path );
384 384
     }
385 385
 
386 386
     /**
387 387
      * @return void
388 388
      */
389
-    protected function wrap(array &$renderedFields, Review $review)
389
+    protected function wrap( array &$renderedFields, Review $review )
390 390
     {
391
-        $renderedFields = apply_filters('site-reviews/review/wrap', $renderedFields, $review, $this);
392
-        array_walk($renderedFields, function (&$value, $key) use ($review) {
393
-            $value = apply_filters('site-reviews/review/wrap/'.$key, $value, $review);
394
-            if (empty($value)) {
391
+        $renderedFields = apply_filters( 'site-reviews/review/wrap', $renderedFields, $review, $this );
392
+        array_walk( $renderedFields, function( &$value, $key ) use ($review) {
393
+            $value = apply_filters( 'site-reviews/review/wrap/'.$key, $value, $review );
394
+            if( empty($value) ) {
395 395
                 return;
396 396
             }
397
-            $value = glsr(Builder::class)->div($value, [
397
+            $value = glsr( Builder::class )->div( $value, [
398 398
                 'class' => 'glsr-review-'.$key,
399
-            ]);
399
+            ] );
400 400
         });
401 401
     }
402 402
 }
Please login to merge, or discard this patch.
plugin/Modules/Translator.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
      * @return string
14 14
      * @filter gettext
15 15
      */
16
-    public function filterGettext($translation, $text, $domain)
16
+    public function filterGettext( $translation, $text, $domain )
17 17
     {
18
-        return $this->translate($translation, $domain, [
18
+        return $this->translate( $translation, $domain, [
19 19
             'single' => $text,
20
-        ]);
20
+        ] );
21 21
     }
22 22
 
23 23
     /**
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
28 28
      * @return string
29 29
      * @filter gettext_with_context
30 30
      */
31
-    public function filterGettextWithContext($translation, $text, $context, $domain)
31
+    public function filterGettextWithContext( $translation, $text, $context, $domain )
32 32
     {
33
-        return $this->translate($translation, $domain, [
33
+        return $this->translate( $translation, $domain, [
34 34
             'context' => $context,
35 35
             'single' => $text,
36
-        ]);
36
+        ] );
37 37
     }
38 38
 
39 39
     /**
@@ -45,13 +45,13 @@  discard block
 block discarded – undo
45 45
      * @return string
46 46
      * @filter ngettext
47 47
      */
48
-    public function filterNgettext($translation, $single, $plural, $number, $domain)
48
+    public function filterNgettext( $translation, $single, $plural, $number, $domain )
49 49
     {
50
-        return $this->translate($translation, $domain, [
50
+        return $this->translate( $translation, $domain, [
51 51
             'number' => $number,
52 52
             'plural' => $plural,
53 53
             'single' => $single,
54
-        ]);
54
+        ] );
55 55
     }
56 56
 
57 57
     /**
@@ -64,14 +64,14 @@  discard block
 block discarded – undo
64 64
      * @return string
65 65
      * @filter ngettext_with_context
66 66
      */
67
-    public function filterNgettextWithContext($translation, $single, $plural, $number, $context, $domain)
67
+    public function filterNgettextWithContext( $translation, $single, $plural, $number, $context, $domain )
68 68
     {
69
-        return $this->translate($translation, $domain, [
69
+        return $this->translate( $translation, $domain, [
70 70
             'context' => $context,
71 71
             'number' => $number,
72 72
             'plural' => $plural,
73 73
             'single' => $single,
74
-        ]);
74
+        ] );
75 75
     }
76 76
 
77 77
     /**
@@ -79,21 +79,21 @@  discard block
 block discarded – undo
79 79
      * @param string $domain
80 80
      * @return string
81 81
      */
82
-    public function translate($original, $domain, array $args)
82
+    public function translate( $original, $domain, array $args )
83 83
     {
84
-        $domains = apply_filters('site-reviews/translator/domains', [Application::ID]);
85
-        if (!in_array($domain, $domains)) {
84
+        $domains = apply_filters( 'site-reviews/translator/domains', [Application::ID] );
85
+        if( !in_array( $domain, $domains ) ) {
86 86
             return $original;
87 87
         }
88
-        $args = $this->normalizeTranslationArgs($args);
89
-        $strings = $this->getTranslationStrings($args['single'], $args['plural']);
90
-        if (empty($strings)) {
88
+        $args = $this->normalizeTranslationArgs( $args );
89
+        $strings = $this->getTranslationStrings( $args['single'], $args['plural'] );
90
+        if( empty($strings) ) {
91 91
             return $original;
92 92
         }
93
-        $string = current($strings);
93
+        $string = current( $strings );
94 94
         return 'plural' == $string['type']
95
-            ? $this->translatePlural($domain, $string, $args)
96
-            : $this->translateSingle($domain, $string, $args);
95
+            ? $this->translatePlural( $domain, $string, $args )
96
+            : $this->translateSingle( $domain, $string, $args );
97 97
     }
98 98
 
99 99
     /**
@@ -101,18 +101,18 @@  discard block
 block discarded – undo
101 101
      * @param string $plural
102 102
      * @return array
103 103
      */
104
-    protected function getTranslationStrings($single, $plural)
104
+    protected function getTranslationStrings( $single, $plural )
105 105
     {
106
-        return array_filter(glsr(Translation::class)->translations(), function ($string) use ($single, $plural) {
107
-            return $string['s1'] == html_entity_decode($single, ENT_COMPAT, 'UTF-8')
108
-                && $string['p1'] == html_entity_decode($plural, ENT_COMPAT, 'UTF-8');
106
+        return array_filter( glsr( Translation::class )->translations(), function( $string ) use ($single, $plural) {
107
+            return $string['s1'] == html_entity_decode( $single, ENT_COMPAT, 'UTF-8' )
108
+                && $string['p1'] == html_entity_decode( $plural, ENT_COMPAT, 'UTF-8' );
109 109
         });
110 110
     }
111 111
 
112 112
     /**
113 113
      * @return array
114 114
      */
115
-    protected function normalizeTranslationArgs(array $args)
115
+    protected function normalizeTranslationArgs( array $args )
116 116
     {
117 117
         $defaults = [
118 118
             'context' => '',
@@ -120,22 +120,22 @@  discard block
 block discarded – undo
120 120
             'plural' => '',
121 121
             'single' => '',
122 122
         ];
123
-        return shortcode_atts($defaults, $args);
123
+        return shortcode_atts( $defaults, $args );
124 124
     }
125 125
 
126 126
     /**
127 127
      * @param string $domain
128 128
      * @return string
129 129
      */
130
-    protected function translatePlural($domain, array $string, array $args)
130
+    protected function translatePlural( $domain, array $string, array $args )
131 131
     {
132
-        if (!empty($string['s2'])) {
132
+        if( !empty($string['s2']) ) {
133 133
             $args['single'] = $string['s2'];
134 134
         }
135
-        if (!empty($string['p2'])) {
135
+        if( !empty($string['p2']) ) {
136 136
             $args['plural'] = $string['p2'];
137 137
         }
138
-        return get_translations_for_domain($domain)->translate_plural(
138
+        return get_translations_for_domain( $domain )->translate_plural(
139 139
             $args['single'],
140 140
             $args['plural'],
141 141
             $args['number'],
@@ -147,12 +147,12 @@  discard block
 block discarded – undo
147 147
      * @param string $domain
148 148
      * @return string
149 149
      */
150
-    protected function translateSingle($domain, array $string, array $args)
150
+    protected function translateSingle( $domain, array $string, array $args )
151 151
     {
152
-        if (!empty($string['s2'])) {
152
+        if( !empty($string['s2']) ) {
153 153
             $args['single'] = $string['s2'];
154 154
         }
155
-        return get_translations_for_domain($domain)->translate(
155
+        return get_translations_for_domain( $domain )->translate(
156 156
             $args['single'],
157 157
             $args['context']
158 158
         );
Please login to merge, or discard this patch.
plugin/Controllers/EditorController/Labels.php 1 patch
Spacing   +33 added lines, -33 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 (isset($wp_scripts->registered['post']->extra['data'])) {
20
+        if( 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
     }
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
30 30
      * @param string $test
31 31
      * @return string
32 32
      */
33
-    public function filterPostStatusLabels($translation, $text)
33
+    public function filterPostStatusLabels( $translation, $text )
34 34
     {
35 35
         $replacements = $this->getStatusLabels();
36
-        return array_key_exists($text, $replacements)
36
+        return array_key_exists( $text, $replacements )
37 37
             ? $replacements[$text]
38 38
             : $translation;
39 39
     }
@@ -41,18 +41,18 @@  discard block
 block discarded – undo
41 41
     /**
42 42
      * @return array
43 43
      */
44
-    public function filterUpdateMessages(array $messages)
44
+    public function filterUpdateMessages( array $messages )
45 45
     {
46 46
         $post = get_post();
47
-        if (!($post instanceof WP_Post)) {
47
+        if( !($post instanceof WP_Post) ) {
48 48
             return;
49 49
         }
50 50
         $strings = $this->getReviewLabels();
51
-        $restored = filter_input(INPUT_GET, 'revision');
52
-        if ($revisionTitle = wp_post_revision_title(intval($restored), false)) {
53
-            $restored = sprintf($strings['restored'], $revisionTitle);
51
+        $restored = filter_input( INPUT_GET, 'revision' );
52
+        if( $revisionTitle = wp_post_revision_title( intval( $restored ), false ) ) {
53
+            $restored = sprintf( $strings['restored'], $revisionTitle );
54 54
         }
55
-        $scheduled_date = date_i18n('M j, Y @ H:i', strtotime($post->post_date));
55
+        $scheduled_date = date_i18n( 'M j, Y @ H:i', strtotime( $post->post_date ) );
56 56
         $messages[Application::POST_TYPE] = [
57 57
              1 => $strings['updated'],
58 58
              4 => $strings['updated'],
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
              6 => $strings['published'],
61 61
              7 => $strings['saved'],
62 62
              8 => $strings['submitted'],
63
-             9 => sprintf($strings['scheduled'], '<strong>'.$scheduled_date.'</strong>'),
63
+             9 => sprintf( $strings['scheduled'], '<strong>'.$scheduled_date.'</strong>' ),
64 64
             10 => $strings['draft_updated'],
65 65
             50 => $strings['approved'],
66 66
             51 => $strings['unapproved'],
@@ -75,18 +75,18 @@  discard block
 block discarded – undo
75 75
     protected function getReviewLabels()
76 76
     {
77 77
         return [
78
-            'approved' => __('Review has been approved and published.', 'site-reviews'),
79
-            'draft_updated' => __('Review draft updated.', 'site-reviews'),
80
-            'preview' => __('Preview review', 'site-reviews'),
81
-            'published' => __('Review approved and published.', 'site-reviews'),
82
-            'restored' => __('Review restored to revision from %s.', 'site-reviews'),
83
-            'reverted' => __('Review has been reverted to its original submission state (title, content, and submission date).', 'site-reviews'),
84
-            'saved' => __('Review saved.', 'site-reviews'),
85
-            'scheduled' => __('Review scheduled for: %s.', 'site-reviews'),
86
-            'submitted' => __('Review submitted.', 'site-reviews'),
87
-            'unapproved' => __('Review has been unapproved and is now pending.', 'site-reviews'),
88
-            'updated' => __('Review updated.', 'site-reviews'),
89
-            'view' => __('View review', 'site-reviews'),
78
+            'approved' => __( 'Review has been approved and published.', 'site-reviews' ),
79
+            'draft_updated' => __( 'Review draft updated.', 'site-reviews' ),
80
+            'preview' => __( 'Preview review', 'site-reviews' ),
81
+            'published' => __( 'Review approved and published.', 'site-reviews' ),
82
+            'restored' => __( 'Review restored to revision from %s.', 'site-reviews' ),
83
+            'reverted' => __( 'Review has been reverted to its original submission state (title, content, and submission date).', 'site-reviews' ),
84
+            'saved' => __( 'Review saved.', 'site-reviews' ),
85
+            'scheduled' => __( 'Review scheduled for: %s.', 'site-reviews' ),
86
+            'submitted' => __( 'Review submitted.', 'site-reviews' ),
87
+            'unapproved' => __( 'Review has been unapproved and is now pending.', 'site-reviews' ),
88
+            'updated' => __( 'Review updated.', 'site-reviews' ),
89
+            'view' => __( 'View review', 'site-reviews' ),
90 90
         ];
91 91
     }
92 92
 
@@ -97,14 +97,14 @@  discard block
 block discarded – undo
97 97
     protected function getStatusLabels()
98 98
     {
99 99
         static $labels;
100
-        if (empty($labels)) {
100
+        if( empty($labels) ) {
101 101
             $labels = [
102
-                'Pending' => __('Unapproved', 'site-reviews'),
103
-                'Pending Review' => __('Unapproved', 'site-reviews'),
104
-                'Privately Published' => __('Privately Approved', 'site-reviews'),
105
-                'Publish' => __('Approve', 'site-reviews'),
106
-                'Published' => __('Approved', 'site-reviews'),
107
-                'Save as Pending' => __('Save as Unapproved', 'site-reviews'),
102
+                'Pending' => __( 'Unapproved', 'site-reviews' ),
103
+                'Pending Review' => __( 'Unapproved', 'site-reviews' ),
104
+                'Privately Published' => __( 'Privately Approved', 'site-reviews' ),
105
+                'Publish' => __( 'Approve', 'site-reviews' ),
106
+                'Published' => __( 'Approved', 'site-reviews' ),
107
+                'Save as Pending' => __( 'Save as Unapproved', 'site-reviews' ),
108 108
             ];
109 109
         }
110 110
         return $labels;
Please login to merge, or discard this patch.
plugin/Controllers/EditorController.php 1 patch
Spacing   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
      */
26 26
     public function customizePostStatusLabels()
27 27
     {
28
-        if ($this->canModifyTranslation()) {
29
-            glsr(Labels::class)->customizePostStatusLabels();
28
+        if( $this->canModifyTranslation() ) {
29
+            glsr( Labels::class )->customizePostStatusLabels();
30 30
         }
31 31
     }
32 32
 
@@ -35,10 +35,10 @@  discard block
 block discarded – undo
35 35
      * @return array
36 36
      * @filter wp_editor_settings
37 37
      */
38
-    public function filterEditorSettings($settings)
38
+    public function filterEditorSettings( $settings )
39 39
     {
40
-        return glsr(Customization::class)->filterEditorSettings(
41
-            Arr::consolidateArray($settings)
40
+        return glsr( Customization::class )->filterEditorSettings(
41
+            Arr::consolidateArray( $settings )
42 42
         );
43 43
     }
44 44
 
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
      * @return string
49 49
      * @filter the_editor
50 50
      */
51
-    public function filterEditorTextarea($html)
51
+    public function filterEditorTextarea( $html )
52 52
     {
53
-        return glsr(Customization::class)->filterEditorTextarea($html);
53
+        return glsr( Customization::class )->filterEditorTextarea( $html );
54 54
     }
55 55
 
56 56
     /**
@@ -60,12 +60,12 @@  discard block
 block discarded – undo
60 60
      * @return bool
61 61
      * @filter is_protected_meta
62 62
      */
63
-    public function filterIsProtectedMeta($protected, $metaKey, $metaType)
63
+    public function filterIsProtectedMeta( $protected, $metaKey, $metaType )
64 64
     {
65
-        if ('post' == $metaType && Application::POST_TYPE == get_post_type()) {
66
-            $values = glsr(CreateReviewDefaults::class)->unguarded();
67
-            $values = Arr::prefixArrayKeys($values);
68
-            if (array_key_exists($metaKey, $values)) {
65
+        if( 'post' == $metaType && Application::POST_TYPE == get_post_type() ) {
66
+            $values = glsr( CreateReviewDefaults::class )->unguarded();
67
+            $values = Arr::prefixArrayKeys( $values );
68
+            if( array_key_exists( $metaKey, $values ) ) {
69 69
                 $protected = false;
70 70
             }
71 71
         }
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
      * @return string
80 80
      * @filter gettext
81 81
      */
82
-    public function filterPostStatusLabels($translation, $text, $domain)
82
+    public function filterPostStatusLabels( $translation, $text, $domain )
83 83
     {
84
-        return $this->canModifyTranslation($domain)
85
-            ? glsr(Labels::class)->filterPostStatusLabels($translation, $text)
84
+        return $this->canModifyTranslation( $domain )
85
+            ? glsr( Labels::class )->filterPostStatusLabels( $translation, $text )
86 86
             : $translation;
87 87
     }
88 88
 
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
      * @return string
94 94
      * @filter gettext_with_context
95 95
      */
96
-    public function filterPostStatusLabelsWithContext($translation, $text, $context, $domain)
96
+    public function filterPostStatusLabelsWithContext( $translation, $text, $context, $domain )
97 97
     {
98
-        return $this->canModifyTranslation($domain)
99
-            ? glsr(Labels::class)->filterPostStatusLabels($translation, $text)
98
+        return $this->canModifyTranslation( $domain )
99
+            ? glsr( Labels::class )->filterPostStatusLabels( $translation, $text )
100 100
             : $translation;
101 101
     }
102 102
 
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
      * @return array
106 106
      * @filter post_updated_messages
107 107
      */
108
-    public function filterUpdateMessages($messages)
108
+    public function filterUpdateMessages( $messages )
109 109
     {
110
-        return glsr(Labels::class)->filterUpdateMessages(
111
-            Arr::consolidateArray($messages)
110
+        return glsr( Labels::class )->filterUpdateMessages(
111
+            Arr::consolidateArray( $messages )
112 112
         );
113 113
     }
114 114
 
@@ -116,14 +116,14 @@  discard block
 block discarded – undo
116 116
      * @return void
117 117
      * @action add_meta_boxes_{Application::POST_TYPE}
118 118
      */
119
-    public function registerMetaBoxes($post)
119
+    public function registerMetaBoxes( $post )
120 120
     {
121
-        add_meta_box(Application::ID.'_assigned_to', __('Assigned To', 'site-reviews'), [$this, 'renderAssignedToMetabox'], null, 'side');
122
-        add_meta_box(Application::ID.'_review', __('Details', 'site-reviews'), [$this, 'renderDetailsMetaBox'], null, 'side');
123
-        if ('local' != glsr(Database::class)->get($post->ID, 'review_type')) {
121
+        add_meta_box( Application::ID.'_assigned_to', __( 'Assigned To', 'site-reviews' ), [$this, 'renderAssignedToMetabox'], null, 'side' );
122
+        add_meta_box( Application::ID.'_review', __( 'Details', 'site-reviews' ), [$this, 'renderDetailsMetaBox'], null, 'side' );
123
+        if( 'local' != glsr( Database::class )->get( $post->ID, 'review_type' ) ) {
124 124
             return;
125 125
         }
126
-        add_meta_box(Application::ID.'_response', __('Respond Publicly', 'site-reviews'), [$this, 'renderResponseMetaBox'], null, 'normal');
126
+        add_meta_box( Application::ID.'_response', __( 'Respond Publicly', 'site-reviews' ), [$this, 'renderResponseMetaBox'], null, 'normal' );
127 127
     }
128 128
 
129 129
     /**
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
      */
133 133
     public function removeAutosave()
134 134
     {
135
-        glsr(Customization::class)->removeAutosave();
135
+        glsr( Customization::class )->removeAutosave();
136 136
     }
137 137
 
138 138
     /**
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
      */
142 142
     public function removeMetaBoxes()
143 143
     {
144
-        glsr(Customization::class)->removeMetaBoxes();
144
+        glsr( Customization::class )->removeMetaBoxes();
145 145
     }
146 146
 
147 147
     /**
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
      */
150 150
     public function removePostTypeSupport()
151 151
     {
152
-        glsr(Customization::class)->removePostTypeSupport();
152
+        glsr( Customization::class )->removePostTypeSupport();
153 153
     }
154 154
 
155 155
     /**
@@ -157,17 +157,17 @@  discard block
 block discarded – undo
157 157
      * @return void
158 158
      * @callback add_meta_box
159 159
      */
160
-    public function renderAssignedToMetabox($post)
160
+    public function renderAssignedToMetabox( $post )
161 161
     {
162
-        if (!$this->isReviewPostType($post)) {
162
+        if( !$this->isReviewPostType( $post ) ) {
163 163
             return;
164 164
         }
165
-        $assignedTo = (string) glsr(Database::class)->get($post->ID, 'assigned_to');
166
-        wp_nonce_field('assigned_to', '_nonce-assigned-to', false);
167
-        glsr()->render('partials/editor/metabox-assigned-to', [
165
+        $assignedTo = (string)glsr( Database::class )->get( $post->ID, 'assigned_to' );
166
+        wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false );
167
+        glsr()->render( 'partials/editor/metabox-assigned-to', [
168 168
             'id' => $assignedTo,
169
-            'template' => $this->buildAssignedToTemplate($assignedTo, $post),
170
-        ]);
169
+            'template' => $this->buildAssignedToTemplate( $assignedTo, $post ),
170
+        ] );
171 171
     }
172 172
 
173 173
     /**
@@ -175,16 +175,16 @@  discard block
 block discarded – undo
175 175
      * @return void
176 176
      * @callback add_meta_box
177 177
      */
178
-    public function renderDetailsMetaBox($post)
178
+    public function renderDetailsMetaBox( $post )
179 179
     {
180
-        if (!$this->isReviewPostType($post)) {
180
+        if( !$this->isReviewPostType( $post ) ) {
181 181
             return;
182 182
         }
183
-        $review = glsr_get_review($post);
184
-        glsr()->render('partials/editor/metabox-details', [
185
-            'button' => $this->buildDetailsMetaBoxRevertButton($review, $post),
186
-            'metabox' => $this->normalizeDetailsMetaBox($review),
187
-        ]);
183
+        $review = glsr_get_review( $post );
184
+        glsr()->render( 'partials/editor/metabox-details', [
185
+            'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ),
186
+            'metabox' => $this->normalizeDetailsMetaBox( $review ),
187
+        ] );
188 188
     }
189 189
 
190 190
     /**
@@ -193,16 +193,16 @@  discard block
 block discarded – undo
193 193
      */
194 194
     public function renderPinnedInPublishMetaBox()
195 195
     {
196
-        if (!$this->isReviewPostType(get_post())) {
196
+        if( !$this->isReviewPostType( get_post() ) ) {
197 197
             return;
198 198
         }
199
-        glsr(Template::class)->render('partials/editor/pinned', [
199
+        glsr( Template::class )->render( 'partials/editor/pinned', [
200 200
             'context' => [
201
-                'no' => __('No', 'site-reviews'),
202
-                'yes' => __('Yes', 'site-reviews'),
201
+                'no' => __( 'No', 'site-reviews' ),
202
+                'yes' => __( 'Yes', 'site-reviews' ),
203 203
             ],
204
-            'pinned' => wp_validate_boolean(glsr(Database::class)->get(get_the_ID(), 'pinned')),
205
-        ]);
204
+            'pinned' => wp_validate_boolean( glsr( Database::class )->get( get_the_ID(), 'pinned' ) ),
205
+        ] );
206 206
     }
207 207
 
208 208
     /**
@@ -210,15 +210,15 @@  discard block
 block discarded – undo
210 210
      * @return void
211 211
      * @callback add_meta_box
212 212
      */
213
-    public function renderResponseMetaBox($post)
213
+    public function renderResponseMetaBox( $post )
214 214
     {
215
-        if (!$this->isReviewPostType($post)) {
215
+        if( !$this->isReviewPostType( $post ) ) {
216 216
             return;
217 217
         }
218
-        wp_nonce_field('response', '_nonce-response', false);
219
-        glsr()->render('partials/editor/metabox-response', [
220
-            'response' => glsr(Database::class)->get($post->ID, 'response'),
221
-        ]);
218
+        wp_nonce_field( 'response', '_nonce-response', false );
219
+        glsr()->render( 'partials/editor/metabox-response', [
220
+            'response' => glsr( Database::class )->get( $post->ID, 'response' ),
221
+        ] );
222 222
     }
223 223
 
224 224
     /**
@@ -226,15 +226,15 @@  discard block
 block discarded – undo
226 226
      * @return void
227 227
      * @action edit_form_after_title
228 228
      */
229
-    public function renderReviewEditor($post)
229
+    public function renderReviewEditor( $post )
230 230
     {
231
-        if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) {
231
+        if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) ) {
232 232
             return;
233 233
         }
234
-        glsr()->render('partials/editor/review', [
234
+        glsr()->render( 'partials/editor/review', [
235 235
             'post' => $post,
236
-            'response' => glsr(Database::class)->get($post->ID, 'response'),
237
-        ]);
236
+            'response' => glsr( Database::class )->get( $post->ID, 'response' ),
237
+        ] );
238 238
     }
239 239
 
240 240
     /**
@@ -244,11 +244,11 @@  discard block
 block discarded – undo
244 244
     public function renderReviewFields()
245 245
     {
246 246
         $screen = glsr_current_screen();
247
-        if ('post' != $screen->base || Application::POST_TYPE != $screen->post_type) {
247
+        if( 'post' != $screen->base || Application::POST_TYPE != $screen->post_type ) {
248 248
             return;
249 249
         }
250
-        add_action('edit_form_after_title', [$this, 'renderReviewEditor']);
251
-        add_action('edit_form_top', [$this, 'renderReviewNotice']);
250
+        add_action( 'edit_form_after_title', [$this, 'renderReviewEditor'] );
251
+        add_action( 'edit_form_top', [$this, 'renderReviewNotice'] );
252 252
     }
253 253
 
254 254
     /**
@@ -256,20 +256,20 @@  discard block
 block discarded – undo
256 256
      * @return void
257 257
      * @action edit_form_top
258 258
      */
259
-    public function renderReviewNotice($post)
259
+    public function renderReviewNotice( $post )
260 260
     {
261
-        if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) {
261
+        if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) ) {
262 262
             return;
263 263
         }
264
-        glsr(Notice::class)->addWarning(sprintf(
265
-            __('%s reviews are read-only.', 'site-reviews'),
266
-            glsr(Columns::class)->buildColumnReviewType($post->ID)
267
-        ));
268
-        glsr(Template::class)->render('partials/editor/notice', [
264
+        glsr( Notice::class )->addWarning( sprintf(
265
+            __( '%s reviews are read-only.', 'site-reviews' ),
266
+            glsr( Columns::class )->buildColumnReviewType( $post->ID )
267
+        ) );
268
+        glsr( Template::class )->render( 'partials/editor/notice', [
269 269
             'context' => [
270
-                'notices' => glsr(Notice::class)->get(),
270
+                'notices' => glsr( Notice::class )->get(),
271 271
             ],
272
-        ]);
272
+        ] );
273 273
     }
274 274
 
275 275
     /**
@@ -278,16 +278,16 @@  discard block
 block discarded – undo
278 278
      * @see glsr_categories_meta_box()
279 279
      * @callback register_taxonomy
280 280
      */
281
-    public function renderTaxonomyMetabox($post)
281
+    public function renderTaxonomyMetabox( $post )
282 282
     {
283
-        if (!$this->isReviewPostType($post)) {
283
+        if( !$this->isReviewPostType( $post ) ) {
284 284
             return;
285 285
         }
286
-        glsr()->render('partials/editor/metabox-categories', [
286
+        glsr()->render( 'partials/editor/metabox-categories', [
287 287
             'post' => $post,
288 288
             'tax_name' => Application::TAXONOMY,
289
-            'taxonomy' => get_taxonomy(Application::TAXONOMY),
290
-        ]);
289
+            'taxonomy' => get_taxonomy( Application::TAXONOMY ),
290
+        ] );
291 291
     }
292 292
 
293 293
     /**
@@ -297,12 +297,12 @@  discard block
 block discarded – undo
297 297
      */
298 298
     public function revertReview()
299 299
     {
300
-        if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
300
+        if( Application::ID != filter_input( INPUT_GET, 'plugin' ) ) {
301 301
             return;
302 302
         }
303
-        check_admin_referer('revert-review_'.($postId = $this->getPostId()));
304
-        glsr(ReviewManager::class)->revert($postId);
305
-        $this->redirect($postId, 52);
303
+        check_admin_referer( 'revert-review_'.($postId = $this->getPostId()) );
304
+        glsr( ReviewManager::class )->revert( $postId );
305
+        $this->redirect( $postId, 52 );
306 306
     }
307 307
 
308 308
     /**
@@ -312,12 +312,12 @@  discard block
 block discarded – undo
312 312
      * @return void
313 313
      * @action save_post_.Application::POST_TYPE
314 314
      */
315
-    public function saveMetaboxes($postId, $post, $isUpdating)
315
+    public function saveMetaboxes( $postId, $post, $isUpdating )
316 316
     {
317
-        glsr(Metaboxes::class)->saveAssignedToMetabox($postId);
318
-        glsr(Metaboxes::class)->saveResponseMetabox($postId);
319
-        if ($isUpdating) {
320
-            do_action('site-reviews/review/saved', glsr_get_review($postId));
317
+        glsr( Metaboxes::class )->saveAssignedToMetabox( $postId );
318
+        glsr( Metaboxes::class )->saveResponseMetabox( $postId );
319
+        if( $isUpdating ) {
320
+            do_action( 'site-reviews/review/saved', glsr_get_review( $postId ) );
321 321
         }
322 322
     }
323 323
 
@@ -325,81 +325,81 @@  discard block
 block discarded – undo
325 325
      * @param string $assignedTo
326 326
      * @return string
327 327
      */
328
-    protected function buildAssignedToTemplate($assignedTo, WP_Post $post)
328
+    protected function buildAssignedToTemplate( $assignedTo, WP_Post $post )
329 329
     {
330
-        $assignedPost = glsr(Database::class)->getAssignedToPost($post->ID, $assignedTo);
331
-        if (!($assignedPost instanceof WP_Post)) {
330
+        $assignedPost = glsr( Database::class )->getAssignedToPost( $post->ID, $assignedTo );
331
+        if( !($assignedPost instanceof WP_Post) ) {
332 332
             return;
333 333
         }
334
-        return glsr(Template::class)->build('partials/editor/assigned-post', [
334
+        return glsr( Template::class )->build( 'partials/editor/assigned-post', [
335 335
             'context' => [
336
-                'data.url' => (string) get_permalink($assignedPost),
337
-                'data.title' => get_the_title($assignedPost),
336
+                'data.url' => (string)get_permalink( $assignedPost ),
337
+                'data.title' => get_the_title( $assignedPost ),
338 338
             ],
339
-        ]);
339
+        ] );
340 340
     }
341 341
 
342 342
     /**
343 343
      * @return string
344 344
      */
345
-    protected function buildDetailsMetaBoxRevertButton(Review $review, WP_Post $post)
345
+    protected function buildDetailsMetaBoxRevertButton( Review $review, WP_Post $post )
346 346
     {
347 347
         $isModified = !Arr::compareArrays(
348 348
             [$review->title, $review->content, $review->date],
349 349
             [
350
-                glsr(Database::class)->get($post->ID, 'title'),
351
-                glsr(Database::class)->get($post->ID, 'content'),
352
-                glsr(Database::class)->get($post->ID, 'date'),
350
+                glsr( Database::class )->get( $post->ID, 'title' ),
351
+                glsr( Database::class )->get( $post->ID, 'content' ),
352
+                glsr( Database::class )->get( $post->ID, 'date' ),
353 353
             ]
354 354
         );
355
-        if ($isModified) {
355
+        if( $isModified ) {
356 356
             $revertUrl = wp_nonce_url(
357
-                admin_url('post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID),
357
+                admin_url( 'post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID ),
358 358
                 'revert-review_'.$post->ID
359 359
             );
360
-            return glsr(Builder::class)->a(__('Revert Changes', 'site-reviews'), [
360
+            return glsr( Builder::class )->a( __( 'Revert Changes', 'site-reviews' ), [
361 361
                 'class' => 'button button-large',
362 362
                 'href' => $revertUrl,
363 363
                 'id' => 'revert',
364
-            ]);
364
+            ] );
365 365
         }
366
-        return glsr(Builder::class)->button(__('Nothing to Revert', 'site-reviews'), [
366
+        return glsr( Builder::class )->button( __( 'Nothing to Revert', 'site-reviews' ), [
367 367
             'class' => 'button-large',
368 368
             'disabled' => true,
369 369
             'id' => 'revert',
370
-        ]);
370
+        ] );
371 371
     }
372 372
 
373 373
     /**
374 374
      * @param string $domain
375 375
      * @return bool
376 376
      */
377
-    protected function canModifyTranslation($domain = 'default')
377
+    protected function canModifyTranslation( $domain = 'default' )
378 378
     {
379
-        if ('default' != $domain || empty(glsr_current_screen()->base)) {
379
+        if( 'default' != $domain || empty(glsr_current_screen()->base) ) {
380 380
             return false;
381 381
         }
382 382
         return Application::POST_TYPE == glsr_current_screen()->post_type
383
-            && in_array(glsr_current_screen()->base, ['edit', 'post']);
383
+            && in_array( glsr_current_screen()->base, ['edit', 'post'] );
384 384
     }
385 385
 
386 386
     /**
387 387
      * @param object $review
388 388
      * @return string|void
389 389
      */
390
-    protected function getReviewType($review)
390
+    protected function getReviewType( $review )
391 391
     {
392
-        if (count(glsr()->reviewTypes) < 2) {
392
+        if( count( glsr()->reviewTypes ) < 2 ) {
393 393
             return;
394 394
         }
395
-        $reviewType = array_key_exists($review->review_type, glsr()->reviewTypes)
395
+        $reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes )
396 396
             ? glsr()->reviewTypes[$review->review_type]
397
-            : __('Unknown', 'site-reviews');
398
-        if (!empty($review->url)) {
399
-            $reviewType = glsr(Builder::class)->a($reviewType, [
397
+            : __( 'Unknown', 'site-reviews' );
398
+        if( !empty($review->url) ) {
399
+            $reviewType = glsr( Builder::class )->a( $reviewType, [
400 400
                 'href' => $review->url,
401 401
                 'target' => '_blank',
402
-            ]);
402
+            ] );
403 403
         }
404 404
         return $reviewType;
405 405
     }
@@ -407,18 +407,18 @@  discard block
 block discarded – undo
407 407
     /**
408 408
      * @return bool
409 409
      */
410
-    protected function isReviewEditable($post)
410
+    protected function isReviewEditable( $post )
411 411
     {
412
-        return $this->isReviewPostType($post)
413
-            && post_type_supports(Application::POST_TYPE, 'title')
414
-            && 'local' == glsr(Database::class)->get($post->ID, 'review_type');
412
+        return $this->isReviewPostType( $post )
413
+            && post_type_supports( Application::POST_TYPE, 'title' )
414
+            && 'local' == glsr( Database::class )->get( $post->ID, 'review_type' );
415 415
     }
416 416
 
417 417
     /**
418 418
      * @param mixed $post
419 419
      * @return bool
420 420
      */
421
-    protected function isReviewPostType($post)
421
+    protected function isReviewPostType( $post )
422 422
     {
423 423
         return $post instanceof WP_Post && Application::POST_TYPE == $post->post_type;
424 424
     }
@@ -426,29 +426,29 @@  discard block
 block discarded – undo
426 426
     /**
427 427
      * @return array
428 428
      */
429
-    protected function normalizeDetailsMetaBox(Review $review)
429
+    protected function normalizeDetailsMetaBox( Review $review )
430 430
     {
431 431
         $user = empty($review->user_id)
432
-            ? __('Unregistered user', 'site-reviews')
433
-            : glsr(Builder::class)->a(get_the_author_meta('display_name', $review->user_id), [
434
-                'href' => get_author_posts_url($review->user_id),
435
-            ]);
432
+            ? __( 'Unregistered user', 'site-reviews' )
433
+            : glsr( Builder::class )->a( get_the_author_meta( 'display_name', $review->user_id ), [
434
+                'href' => get_author_posts_url( $review->user_id ),
435
+            ] );
436 436
         $email = empty($review->email)
437 437
             ? '&mdash;'
438
-            : glsr(Builder::class)->a($review->email, [
439
-                'href' => 'mailto:'.$review->email.'?subject='.esc_attr(__('RE:', 'site-reviews').' '.$review->title),
440
-            ]);
438
+            : glsr( Builder::class )->a( $review->email, [
439
+                'href' => 'mailto:'.$review->email.'?subject='.esc_attr( __( 'RE:', 'site-reviews' ).' '.$review->title ),
440
+            ] );
441 441
         $metabox = [
442
-            __('Rating', 'site-reviews') => glsr_star_rating($review->rating),
443
-            __('Type', 'site-reviews') => $this->getReviewType($review),
444
-            __('Date', 'site-reviews') => get_date_from_gmt($review->date, 'F j, Y'),
445
-            __('Name', 'site-reviews') => $review->author,
446
-            __('Email', 'site-reviews') => $email,
447
-            __('User', 'site-reviews') => $user,
448
-            __('IP Address', 'site-reviews') => $review->ip_address,
449
-            __('Avatar', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar),
442
+            __( 'Rating', 'site-reviews' ) => glsr_star_rating( $review->rating ),
443
+            __( 'Type', 'site-reviews' ) => $this->getReviewType( $review ),
444
+            __( 'Date', 'site-reviews' ) => get_date_from_gmt( $review->date, 'F j, Y' ),
445
+            __( 'Name', 'site-reviews' ) => $review->author,
446
+            __( 'Email', 'site-reviews' ) => $email,
447
+            __( 'User', 'site-reviews' ) => $user,
448
+            __( 'IP Address', 'site-reviews' ) => $review->ip_address,
449
+            __( 'Avatar', 'site-reviews' ) => sprintf( '<img src="%s" width="96">', $review->avatar ),
450 450
         ];
451
-        return array_filter(apply_filters('site-reviews/metabox/details', $metabox, $review));
451
+        return array_filter( apply_filters( 'site-reviews/metabox/details', $metabox, $review ) );
452 452
     }
453 453
 
454 454
     /**
@@ -456,16 +456,16 @@  discard block
 block discarded – undo
456 456
      * @param int $messageIndex
457 457
      * @return void
458 458
      */
459
-    protected function redirect($postId, $messageIndex)
459
+    protected function redirect( $postId, $messageIndex )
460 460
     {
461 461
         $referer = wp_get_referer();
462 462
         $hasReferer = !$referer
463
-            || false !== strpos($referer, 'post.php')
464
-            || false !== strpos($referer, 'post-new.php');
463
+            || false !== strpos( $referer, 'post.php' )
464
+            || false !== strpos( $referer, 'post-new.php' );
465 465
         $redirectUri = $hasReferer
466
-            ? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer)
467
-            : get_edit_post_link($postId);
468
-        wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri));
466
+            ? remove_query_arg( ['deleted', 'ids', 'trashed', 'untrashed'], $referer )
467
+            : get_edit_post_link( $postId );
468
+        wp_safe_redirect( add_query_arg( ['message' => $messageIndex], $redirectUri ) );
469 469
         exit;
470 470
     }
471 471
 }
Please login to merge, or discard this patch.