@@ -19,11 +19,11 @@ discard block |
||
19 | 19 | /** |
20 | 20 | * @return false|Review |
21 | 21 | */ |
22 | - public function create(CreateReview $command) |
|
22 | + public function create( CreateReview $command ) |
|
23 | 23 | { |
24 | - $reviewValues = glsr(CreateReviewDefaults::class)->restrict((array) $command); |
|
25 | - $reviewValues = apply_filters('site-reviews/create/review-values', $reviewValues, $command); |
|
26 | - $reviewValues = Arr::prefixKeys($reviewValues); |
|
24 | + $reviewValues = glsr( CreateReviewDefaults::class )->restrict( (array)$command ); |
|
25 | + $reviewValues = apply_filters( 'site-reviews/create/review-values', $reviewValues, $command ); |
|
26 | + $reviewValues = Arr::prefixKeys( $reviewValues ); |
|
27 | 27 | unset($reviewValues['json']); // @todo remove the need for this |
28 | 28 | $postValues = [ |
29 | 29 | 'comment_status' => 'closed', |
@@ -31,20 +31,20 @@ discard block |
||
31 | 31 | 'ping_status' => 'closed', |
32 | 32 | 'post_content' => $reviewValues['_content'], |
33 | 33 | 'post_date' => $reviewValues['_date'], |
34 | - 'post_date_gmt' => get_gmt_from_date($reviewValues['_date']), |
|
34 | + 'post_date_gmt' => get_gmt_from_date( $reviewValues['_date'] ), |
|
35 | 35 | 'post_name' => $reviewValues['_review_type'].'-'.$reviewValues['_review_id'], |
36 | - 'post_status' => $this->getNewPostStatus($reviewValues, $command->blacklisted), |
|
36 | + 'post_status' => $this->getNewPostStatus( $reviewValues, $command->blacklisted ), |
|
37 | 37 | 'post_title' => $reviewValues['_title'], |
38 | 38 | 'post_type' => Application::POST_TYPE, |
39 | 39 | ]; |
40 | - $postId = wp_insert_post($postValues, true); |
|
41 | - if (is_wp_error($postId)) { |
|
42 | - glsr_log()->error($postId->get_error_message())->debug($postValues); |
|
40 | + $postId = wp_insert_post( $postValues, true ); |
|
41 | + if( is_wp_error( $postId ) ) { |
|
42 | + glsr_log()->error( $postId->get_error_message() )->debug( $postValues ); |
|
43 | 43 | return false; |
44 | 44 | } |
45 | - $this->setTerms($postId, $command->category); |
|
46 | - $review = $this->single(get_post($postId)); |
|
47 | - do_action('site-reviews/review/created', $review, $command); |
|
45 | + $this->setTerms( $postId, $command->category ); |
|
46 | + $review = $this->single( get_post( $postId ) ); |
|
47 | + do_action( 'site-reviews/review/created', $review, $command ); |
|
48 | 48 | return $review; |
49 | 49 | } |
50 | 50 | |
@@ -52,29 +52,29 @@ discard block |
||
52 | 52 | * @param string $metaReviewId |
53 | 53 | * @return void |
54 | 54 | */ |
55 | - public function delete($metaReviewId) |
|
55 | + public function delete( $metaReviewId ) |
|
56 | 56 | { |
57 | - if ($postId = $this->getPostId($metaReviewId)) { |
|
58 | - wp_delete_post($postId, true); |
|
57 | + if( $postId = $this->getPostId( $metaReviewId ) ) { |
|
58 | + wp_delete_post( $postId, true ); |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
63 | 63 | * @return object |
64 | 64 | */ |
65 | - public function get(array $args = []) |
|
65 | + public function get( array $args = [] ) |
|
66 | 66 | { |
67 | - $args = glsr(ReviewsDefaults::class)->merge($args); |
|
68 | - $metaQuery = glsr(QueryBuilder::class)->buildQuery( |
|
67 | + $args = glsr( ReviewsDefaults::class )->merge( $args ); |
|
68 | + $metaQuery = glsr( QueryBuilder::class )->buildQuery( |
|
69 | 69 | ['assigned_to', 'email', 'ip_address', 'type', 'rating'], |
70 | 70 | $args |
71 | 71 | ); |
72 | - $taxQuery = glsr(QueryBuilder::class)->buildQuery( |
|
72 | + $taxQuery = glsr( QueryBuilder::class )->buildQuery( |
|
73 | 73 | ['category'], |
74 | - ['category' => $this->normalizeTermIds($args['category'])] |
|
74 | + ['category' => $this->normalizeTermIds( $args['category'] )] |
|
75 | 75 | ); |
76 | - $paged = glsr(QueryBuilder::class)->getPaged( |
|
77 | - wp_validate_boolean($args['pagination']) |
|
76 | + $paged = glsr( QueryBuilder::class )->getPaged( |
|
77 | + wp_validate_boolean( $args['pagination'] ) |
|
78 | 78 | ); |
79 | 79 | $parameters = [ |
80 | 80 | 'meta_key' => '_pinned', |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | 'offset' => $args['offset'], |
83 | 83 | 'order' => $args['order'], |
84 | 84 | 'orderby' => 'meta_value '.$args['orderby'], |
85 | - 'paged' => Arr::get($args, 'paged', $paged), |
|
85 | + 'paged' => Arr::get( $args, 'paged', $paged ), |
|
86 | 86 | 'post__in' => $args['post__in'], |
87 | 87 | 'post__not_in' => $args['post__not_in'], |
88 | 88 | 'post_status' => 'publish', |
@@ -90,62 +90,62 @@ discard block |
||
90 | 90 | 'posts_per_page' => $args['per_page'], |
91 | 91 | 'tax_query' => $taxQuery, |
92 | 92 | ]; |
93 | - $parameters = apply_filters('site-reviews/get/reviews/query', $parameters, $args); |
|
94 | - $query = new WP_Query($parameters); |
|
95 | - $results = array_map([$this, 'single'], $query->posts); |
|
96 | - $reviews = new Reviews($results, $query->max_num_pages, $args); |
|
97 | - return apply_filters('site-reviews/get/reviews', $reviews, $query); |
|
93 | + $parameters = apply_filters( 'site-reviews/get/reviews/query', $parameters, $args ); |
|
94 | + $query = new WP_Query( $parameters ); |
|
95 | + $results = array_map( [$this, 'single'], $query->posts ); |
|
96 | + $reviews = new Reviews( $results, $query->max_num_pages, $args ); |
|
97 | + return apply_filters( 'site-reviews/get/reviews', $reviews, $query ); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
101 | 101 | * @param string $metaReviewId |
102 | 102 | * @return int |
103 | 103 | */ |
104 | - public function getPostId($metaReviewId) |
|
104 | + public function getPostId( $metaReviewId ) |
|
105 | 105 | { |
106 | - return glsr(SqlQueries::class)->getPostIdFromReviewId($metaReviewId); |
|
106 | + return glsr( SqlQueries::class )->getPostIdFromReviewId( $metaReviewId ); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
110 | 110 | * @return array |
111 | 111 | */ |
112 | - public function getRatingCounts(array $args = []) |
|
112 | + public function getRatingCounts( array $args = [] ) |
|
113 | 113 | { |
114 | - $args = glsr(SiteReviewsSummaryDefaults::class)->filter($args); |
|
115 | - $counts = glsr(CountsManager::class)->getCounts([ |
|
116 | - 'post_ids' => Arr::convertFromString($args['assigned_to']), |
|
117 | - 'term_ids' => $this->normalizeTermIds($args['category']), |
|
114 | + $args = glsr( SiteReviewsSummaryDefaults::class )->filter( $args ); |
|
115 | + $counts = glsr( CountsManager::class )->getCounts( [ |
|
116 | + 'post_ids' => Arr::convertFromString( $args['assigned_to'] ), |
|
117 | + 'term_ids' => $this->normalizeTermIds( $args['category'] ), |
|
118 | 118 | 'type' => $args['type'], |
119 | - ]); |
|
120 | - return glsr(CountsManager::class)->flatten($counts, [ |
|
119 | + ] ); |
|
120 | + return glsr( CountsManager::class )->flatten( $counts, [ |
|
121 | 121 | 'min' => $args['rating'], |
122 | - ]); |
|
122 | + ] ); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
126 | 126 | * @param string $commaSeparatedTermIds |
127 | 127 | * @return array |
128 | 128 | */ |
129 | - public function normalizeTermIds($commaSeparatedTermIds) |
|
129 | + public function normalizeTermIds( $commaSeparatedTermIds ) |
|
130 | 130 | { |
131 | - $termIds = glsr_array_column($this->normalizeTerms($commaSeparatedTermIds), 'term_id'); |
|
132 | - return array_unique(array_map('intval', $termIds)); |
|
131 | + $termIds = glsr_array_column( $this->normalizeTerms( $commaSeparatedTermIds ), 'term_id' ); |
|
132 | + return array_unique( array_map( 'intval', $termIds ) ); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
136 | 136 | * @param string $commaSeparatedTermIds |
137 | 137 | * @return array |
138 | 138 | */ |
139 | - public function normalizeTerms($commaSeparatedTermIds) |
|
139 | + public function normalizeTerms( $commaSeparatedTermIds ) |
|
140 | 140 | { |
141 | 141 | $terms = []; |
142 | - $termIds = Arr::convertFromString($commaSeparatedTermIds); |
|
143 | - foreach ($termIds as $termId) { |
|
144 | - if (is_numeric($termId)) { |
|
145 | - $termId = intval($termId); |
|
142 | + $termIds = Arr::convertFromString( $commaSeparatedTermIds ); |
|
143 | + foreach( $termIds as $termId ) { |
|
144 | + if( is_numeric( $termId ) ) { |
|
145 | + $termId = intval( $termId ); |
|
146 | 146 | } |
147 | - $term = term_exists($termId, Application::TAXONOMY); |
|
148 | - if (!isset($term['term_id'])) { |
|
147 | + $term = term_exists( $termId, Application::TAXONOMY ); |
|
148 | + if( !isset($term['term_id']) ) { |
|
149 | 149 | continue; |
150 | 150 | } |
151 | 151 | $terms[] = $term; |
@@ -157,44 +157,44 @@ discard block |
||
157 | 157 | * @param int $postId |
158 | 158 | * @return void |
159 | 159 | */ |
160 | - public function revert($postId) |
|
160 | + public function revert( $postId ) |
|
161 | 161 | { |
162 | - if (Application::POST_TYPE != get_post_field('post_type', $postId)) { |
|
162 | + if( Application::POST_TYPE != get_post_field( 'post_type', $postId ) ) { |
|
163 | 163 | return; |
164 | 164 | } |
165 | - delete_post_meta($postId, '_edit_last'); |
|
166 | - $result = wp_update_post([ |
|
165 | + delete_post_meta( $postId, '_edit_last' ); |
|
166 | + $result = wp_update_post( [ |
|
167 | 167 | 'ID' => $postId, |
168 | - 'post_content' => glsr(Database::class)->get($postId, 'content'), |
|
169 | - 'post_date' => glsr(Database::class)->get($postId, 'date'), |
|
170 | - 'post_title' => glsr(Database::class)->get($postId, 'title'), |
|
171 | - ]); |
|
172 | - if (is_wp_error($result)) { |
|
173 | - glsr_log()->error($result->get_error_message()); |
|
168 | + 'post_content' => glsr( Database::class )->get( $postId, 'content' ), |
|
169 | + 'post_date' => glsr( Database::class )->get( $postId, 'date' ), |
|
170 | + 'post_title' => glsr( Database::class )->get( $postId, 'title' ), |
|
171 | + ] ); |
|
172 | + if( is_wp_error( $result ) ) { |
|
173 | + glsr_log()->error( $result->get_error_message() ); |
|
174 | 174 | return; |
175 | 175 | } |
176 | - do_action('site-reviews/review/reverted', glsr_get_review($postId)); |
|
176 | + do_action( 'site-reviews/review/reverted', glsr_get_review( $postId ) ); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
180 | 180 | * @return Review |
181 | 181 | */ |
182 | - public function single(WP_Post $post) |
|
182 | + public function single( WP_Post $post ) |
|
183 | 183 | { |
184 | - if (Application::POST_TYPE != $post->post_type) { |
|
185 | - $post = new WP_Post((object) []); |
|
184 | + if( Application::POST_TYPE != $post->post_type ) { |
|
185 | + $post = new WP_Post( (object)[] ); |
|
186 | 186 | } |
187 | - $review = new Review($post); |
|
188 | - return apply_filters('site-reviews/get/review', $review, $post); |
|
187 | + $review = new Review( $post ); |
|
188 | + return apply_filters( 'site-reviews/get/review', $review, $post ); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
192 | 192 | * @param bool $isBlacklisted |
193 | 193 | * @return string |
194 | 194 | */ |
195 | - protected function getNewPostStatus(array $reviewValues, $isBlacklisted) |
|
195 | + protected function getNewPostStatus( array $reviewValues, $isBlacklisted ) |
|
196 | 196 | { |
197 | - $requireApproval = glsr(OptionManager::class)->getBool('settings.general.require.approval'); |
|
197 | + $requireApproval = glsr( OptionManager::class )->getBool( 'settings.general.require.approval' ); |
|
198 | 198 | return 'local' == $reviewValues['_review_type'] && ($requireApproval || $isBlacklisted) |
199 | 199 | ? 'pending' |
200 | 200 | : 'publish'; |
@@ -205,15 +205,15 @@ discard block |
||
205 | 205 | * @param string $termIds |
206 | 206 | * @return void |
207 | 207 | */ |
208 | - protected function setTerms($postId, $termIds) |
|
208 | + protected function setTerms( $postId, $termIds ) |
|
209 | 209 | { |
210 | - $termIds = $this->normalizeTermIds($termIds); |
|
211 | - if (empty($termIds)) { |
|
210 | + $termIds = $this->normalizeTermIds( $termIds ); |
|
211 | + if( empty($termIds) ) { |
|
212 | 212 | return; |
213 | 213 | } |
214 | - $termTaxonomyIds = wp_set_object_terms($postId, $termIds, Application::TAXONOMY); |
|
215 | - if (is_wp_error($termTaxonomyIds)) { |
|
216 | - glsr_log()->error($termTaxonomyIds->get_error_message()); |
|
214 | + $termTaxonomyIds = wp_set_object_terms( $postId, $termIds, Application::TAXONOMY ); |
|
215 | + if( is_wp_error( $termTaxonomyIds ) ) { |
|
216 | + glsr_log()->error( $termTaxonomyIds->get_error_message() ); |
|
217 | 217 | } |
218 | 218 | } |
219 | 219 | } |
@@ -12,11 +12,11 @@ discard block |
||
12 | 12 | public function defaults() |
13 | 13 | { |
14 | 14 | $settings = $this->settings(); |
15 | - $defaults = (array) array_combine(array_keys($settings), glsr_array_column($settings, 'default')); |
|
16 | - return wp_parse_args($defaults, [ |
|
15 | + $defaults = (array)array_combine( array_keys( $settings ), glsr_array_column( $settings, 'default' ) ); |
|
16 | + return wp_parse_args( $defaults, [ |
|
17 | 17 | 'version' => '', |
18 | 18 | 'version_upgraded_from' => '', |
19 | - ]); |
|
19 | + ] ); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function get() |
26 | 26 | { |
27 | - return Arr::convertFromDotNotation($this->defaults()); |
|
27 | + return Arr::convertFromDotNotation( $this->defaults() ); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public function set() |
34 | 34 | { |
35 | - $settings = glsr(OptionManager::class)->all(); |
|
36 | - $currentSettings = Arr::removeEmptyValues($settings); |
|
37 | - $defaultSettings = array_replace_recursive($this->get(), $currentSettings); |
|
38 | - $updatedSettings = array_replace_recursive($settings, $defaultSettings); |
|
39 | - update_option(OptionManager::databaseKey(), $updatedSettings); |
|
35 | + $settings = glsr( OptionManager::class )->all(); |
|
36 | + $currentSettings = Arr::removeEmptyValues( $settings ); |
|
37 | + $defaultSettings = array_replace_recursive( $this->get(), $currentSettings ); |
|
38 | + $updatedSettings = array_replace_recursive( $settings, $defaultSettings ); |
|
39 | + update_option( OptionManager::databaseKey(), $updatedSettings ); |
|
40 | 40 | return $defaultSettings; |
41 | 41 | } |
42 | 42 | |
@@ -45,17 +45,17 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function settings() |
47 | 47 | { |
48 | - $settings = apply_filters('site-reviews/addon/settings', glsr()->config('settings')); |
|
49 | - return $this->normalize($settings); |
|
48 | + $settings = apply_filters( 'site-reviews/addon/settings', glsr()->config( 'settings' ) ); |
|
49 | + return $this->normalize( $settings ); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @return array |
54 | 54 | */ |
55 | - protected function normalize(array $settings) |
|
55 | + protected function normalize( array $settings ) |
|
56 | 56 | { |
57 | - array_walk($settings, function (&$setting) { |
|
58 | - if (isset($setting['default'])) { |
|
57 | + array_walk( $settings, function( &$setting ) { |
|
58 | + if( isset($setting['default']) ) { |
|
59 | 59 | return; |
60 | 60 | } |
61 | 61 | $setting['default'] = ''; |
@@ -17,19 +17,19 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * @return string |
19 | 19 | */ |
20 | - public static function databaseKey($version = null) |
|
20 | + public static function databaseKey( $version = null ) |
|
21 | 21 | { |
22 | - if (1 == $version) { |
|
22 | + if( 1 == $version ) { |
|
23 | 23 | return 'geminilabs_site_reviews_settings'; |
24 | 24 | } |
25 | - if (2 == $version) { |
|
25 | + if( 2 == $version ) { |
|
26 | 26 | return 'geminilabs_site_reviews-v2'; |
27 | 27 | } |
28 | - if (null === $version) { |
|
29 | - $version = explode('.', glsr()->version); |
|
30 | - $version = array_shift($version); |
|
28 | + if( null === $version ) { |
|
29 | + $version = explode( '.', glsr()->version ); |
|
30 | + $version = array_shift( $version ); |
|
31 | 31 | } |
32 | - return Str::snakeCase(Application::ID.'-v'.intval($version)); |
|
32 | + return Str::snakeCase( Application::ID.'-v'.intval( $version ) ); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function all() |
39 | 39 | { |
40 | - if (empty($this->options)) { |
|
40 | + if( empty($this->options) ) { |
|
41 | 41 | $this->reset(); |
42 | 42 | } |
43 | 43 | return $this->options; |
@@ -47,20 +47,20 @@ discard block |
||
47 | 47 | * @param string $path |
48 | 48 | * @return bool |
49 | 49 | */ |
50 | - public function delete($path) |
|
50 | + public function delete( $path ) |
|
51 | 51 | { |
52 | - $keys = explode('.', $path); |
|
53 | - $last = array_pop($keys); |
|
52 | + $keys = explode( '.', $path ); |
|
53 | + $last = array_pop( $keys ); |
|
54 | 54 | $options = $this->all(); |
55 | 55 | $pointer = &$options; |
56 | - foreach ($keys as $key) { |
|
57 | - if (!isset($pointer[$key]) || !is_array($pointer[$key])) { |
|
56 | + foreach( $keys as $key ) { |
|
57 | + if( !isset($pointer[$key]) || !is_array( $pointer[$key] ) ) { |
|
58 | 58 | continue; |
59 | 59 | } |
60 | 60 | $pointer = &$pointer[$key]; |
61 | 61 | } |
62 | 62 | unset($pointer[$last]); |
63 | - return $this->set($options); |
|
63 | + return $this->set( $options ); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -69,19 +69,19 @@ discard block |
||
69 | 69 | * @param string $cast |
70 | 70 | * @return mixed |
71 | 71 | */ |
72 | - public function get($path = '', $fallback = '', $cast = '') |
|
72 | + public function get( $path = '', $fallback = '', $cast = '' ) |
|
73 | 73 | { |
74 | - $result = Arr::get($this->all(), $path, $fallback); |
|
75 | - return Helper::castTo($cast, $result); |
|
74 | + $result = Arr::get( $this->all(), $path, $fallback ); |
|
75 | + return Helper::castTo( $cast, $result ); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | 79 | * @param string $path |
80 | 80 | * @return bool |
81 | 81 | */ |
82 | - public function getBool($path) |
|
82 | + public function getBool( $path ) |
|
83 | 83 | { |
84 | - return Helper::castToBool($this->get($path)); |
|
84 | + return Helper::castToBool( $this->get( $path ) ); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | * @param string $cast |
91 | 91 | * @return mixed |
92 | 92 | */ |
93 | - public function getWP($path, $fallback = '', $cast = '') |
|
93 | + public function getWP( $path, $fallback = '', $cast = '' ) |
|
94 | 94 | { |
95 | - $option = get_option($path, $fallback); |
|
96 | - if (empty($option)) { |
|
95 | + $option = get_option( $path, $fallback ); |
|
96 | + if( empty($option) ) { |
|
97 | 97 | $option = $fallback; |
98 | 98 | } |
99 | - return Helper::castTo($cast, $option); |
|
99 | + return Helper::castTo( $cast, $option ); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -104,25 +104,25 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function json() |
106 | 106 | { |
107 | - return json_encode($this->all()); |
|
107 | + return json_encode( $this->all() ); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
111 | 111 | * @return array |
112 | 112 | */ |
113 | - public function normalize(array $options = []) |
|
113 | + public function normalize( array $options = [] ) |
|
114 | 114 | { |
115 | 115 | $options = wp_parse_args( |
116 | - Arr::flatten($options), |
|
117 | - glsr(DefaultsManager::class)->defaults() |
|
116 | + Arr::flatten( $options ), |
|
117 | + glsr( DefaultsManager::class )->defaults() |
|
118 | 118 | ); |
119 | - array_walk($options, function (&$value) { |
|
120 | - if (!is_string($value)) { |
|
119 | + array_walk( $options, function( &$value ) { |
|
120 | + if( !is_string( $value ) ) { |
|
121 | 121 | return; |
122 | 122 | } |
123 | - $value = wp_kses($value, wp_kses_allowed_html('post')); |
|
123 | + $value = wp_kses( $value, wp_kses_allowed_html( 'post' ) ); |
|
124 | 124 | }); |
125 | - return Arr::convertFromDotNotation($options); |
|
125 | + return Arr::convertFromDotNotation( $options ); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function isRecaptchaEnabled() |
132 | 132 | { |
133 | - $integration = $this->get('settings.submissions.recaptcha.integration'); |
|
133 | + $integration = $this->get( 'settings.submissions.recaptcha.integration' ); |
|
134 | 134 | return 'all' == $integration || ('guest' == $integration && !is_user_logged_in()); |
135 | 135 | } |
136 | 136 | |
@@ -139,9 +139,9 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function reset() |
141 | 141 | { |
142 | - $options = $this->getWP(static::databaseKey(), []); |
|
143 | - if (!is_array($options) || empty($options)) { |
|
144 | - delete_option(static::databaseKey()); |
|
142 | + $options = $this->getWP( static::databaseKey(), [] ); |
|
143 | + if( !is_array( $options ) || empty($options) ) { |
|
144 | + delete_option( static::databaseKey() ); |
|
145 | 145 | $options = glsr()->defaults ?: []; |
146 | 146 | } |
147 | 147 | $this->options = $options; |
@@ -152,12 +152,12 @@ discard block |
||
152 | 152 | * @param mixed $value |
153 | 153 | * @return bool |
154 | 154 | */ |
155 | - public function set($pathOrOptions, $value = '') |
|
155 | + public function set( $pathOrOptions, $value = '' ) |
|
156 | 156 | { |
157 | - if (is_string($pathOrOptions)) { |
|
158 | - $pathOrOptions = Arr::set($this->all(), $pathOrOptions, $value); |
|
157 | + if( is_string( $pathOrOptions ) ) { |
|
158 | + $pathOrOptions = Arr::set( $this->all(), $pathOrOptions, $value ); |
|
159 | 159 | } |
160 | - if ($result = update_option(static::databaseKey(), (array) $pathOrOptions)) { |
|
160 | + if( $result = update_option( static::databaseKey(), (array)$pathOrOptions ) ) { |
|
161 | 161 | $this->reset(); |
162 | 162 | } |
163 | 163 | return $result; |
@@ -24,15 +24,15 @@ discard block |
||
24 | 24 | |
25 | 25 | public function __construct() |
26 | 26 | { |
27 | - $this->file = str_replace('plugin/Application', static::ID, (new ReflectionClass($this))->getFileName()); |
|
28 | - $plugin = get_file_data($this->file, [ |
|
27 | + $this->file = str_replace( 'plugin/Application', static::ID, (new ReflectionClass( $this ))->getFileName() ); |
|
28 | + $plugin = get_file_data( $this->file, [ |
|
29 | 29 | 'languages' => 'Domain Path', |
30 | 30 | 'name' => 'Plugin Name', |
31 | 31 | 'testedTo' => 'Tested up to', |
32 | 32 | 'version' => 'Version', |
33 | - ], 'plugin'); |
|
34 | - array_walk($plugin, function ($value, $key) { |
|
35 | - if (property_exists($this, $key)) { |
|
33 | + ], 'plugin' ); |
|
34 | + array_walk( $plugin, function( $value, $key ) { |
|
35 | + if( property_exists( $this, $key ) ) { |
|
36 | 36 | $this->$key = $value; |
37 | 37 | } |
38 | 38 | }); |
@@ -42,18 +42,18 @@ discard block |
||
42 | 42 | * @param string $property |
43 | 43 | * @return void|string |
44 | 44 | */ |
45 | - public function __get($property) |
|
45 | + public function __get( $property ) |
|
46 | 46 | { |
47 | - if (property_exists($this, $property)) { |
|
47 | + if( property_exists( $this, $property ) ) { |
|
48 | 48 | return $this->$property; |
49 | 49 | } |
50 | - $constant = 'static::'.strtoupper($property); |
|
51 | - if (defined($constant)) { |
|
52 | - return constant($constant); |
|
50 | + $constant = 'static::'.strtoupper( $property ); |
|
51 | + if( defined( $constant ) ) { |
|
52 | + return constant( $constant ); |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
56 | - public function make($class) |
|
56 | + public function make( $class ) |
|
57 | 57 | {} |
58 | 58 | |
59 | 59 | /** |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | * @param string $file |
66 | 66 | * @return string |
67 | 67 | */ |
68 | - public function path($file = '') |
|
68 | + public function path( $file = '' ) |
|
69 | 69 | { |
70 | - return plugin_dir_path($this->file).ltrim(trim($file), '/'); |
|
70 | + return plugin_dir_path( $this->file ).ltrim( trim( $file ), '/' ); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -75,10 +75,10 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function update() |
77 | 77 | { |
78 | - $this->updater = new Updater(static::UPDATE_URL, $this->file, [ |
|
79 | - 'license' => glsr_get_option('settings.licenses.'.static::ID), |
|
78 | + $this->updater = new Updater( static::UPDATE_URL, $this->file, [ |
|
79 | + 'license' => glsr_get_option( 'settings.licenses.'.static::ID ), |
|
80 | 80 | 'testedTo' => $this->testedTo, |
81 | - ]); |
|
81 | + ] ); |
|
82 | 82 | $this->updater->init(); |
83 | 83 | } |
84 | 84 | |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | * @param string $path |
87 | 87 | * @return string |
88 | 88 | */ |
89 | - public function url($path = '') |
|
89 | + public function url( $path = '' ) |
|
90 | 90 | { |
91 | - return esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/')); |
|
91 | + return esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) ); |
|
92 | 92 | } |
93 | 93 | } |
@@ -28,11 +28,11 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function enqueueAdminAssets() |
30 | 30 | { |
31 | - if (!$this->isReviewAdminPage()) { |
|
31 | + if( !$this->isReviewAdminPage() ) { |
|
32 | 32 | return; |
33 | 33 | } |
34 | - $this->enqueueAsset('css', ['suffix' => 'admin']); |
|
35 | - $this->enqueueAsset('js', ['suffix' => 'admin']); |
|
34 | + $this->enqueueAsset( 'css', ['suffix' => 'admin'] ); |
|
35 | + $this->enqueueAsset( 'js', ['suffix' => 'admin'] ); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function enqueueBlockAssets() |
43 | 43 | { |
44 | - $this->registerAsset('css', ['suffix' => 'blocks']); |
|
45 | - $this->registerAsset('js', ['suffix' => 'blocks']); |
|
44 | + $this->registerAsset( 'css', ['suffix' => 'blocks'] ); |
|
45 | + $this->registerAsset( 'js', ['suffix' => 'blocks'] ); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -51,19 +51,19 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function enqueuePublicAssets() |
53 | 53 | { |
54 | - $this->enqueueAsset('css'); |
|
55 | - $this->enqueueAsset('js'); |
|
54 | + $this->enqueueAsset( 'css' ); |
|
55 | + $this->enqueueAsset( 'js' ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
59 | 59 | * @return array |
60 | 60 | * @filter plugin_action_links_{addon_id}/{addon_id}.php |
61 | 61 | */ |
62 | - public function filterActionLinks(array $links) |
|
62 | + public function filterActionLinks( array $links ) |
|
63 | 63 | { |
64 | - $links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [ |
|
65 | - 'href' => admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-addons'), |
|
66 | - ]); |
|
64 | + $links['settings'] = glsr( Builder::class )->a( __( 'Settings', 'site-reviews' ), [ |
|
65 | + 'href' => admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-addons' ), |
|
66 | + ] ); |
|
67 | 67 | return $links; |
68 | 68 | } |
69 | 69 | |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | * @return string |
73 | 73 | * @filter site-reviews/config |
74 | 74 | */ |
75 | - public function filterConfigPath($path) |
|
75 | + public function filterConfigPath( $path ) |
|
76 | 76 | { |
77 | 77 | $addonPrefix = $this->addon->id.'/'; |
78 | - return Str::contains($path, $addonPrefix) |
|
79 | - ? $addonPrefix.str_replace($addonPrefix, '', $path) |
|
78 | + return Str::contains( $path, $addonPrefix ) |
|
79 | + ? $addonPrefix.str_replace( $addonPrefix, '', $path ) |
|
80 | 80 | : $path; |
81 | 81 | } |
82 | 82 | |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | * @return array |
85 | 85 | * @filter site-reviews/addon/documentation |
86 | 86 | */ |
87 | - public function filterDocumentation(array $documentation) |
|
87 | + public function filterDocumentation( array $documentation ) |
|
88 | 88 | { |
89 | - $documentation[$this->addon->name] = glsr(Template::class)->build($this->addon->id.'/documentation'); |
|
89 | + $documentation[$this->addon->name] = glsr( Template::class )->build( $this->addon->id.'/documentation' ); |
|
90 | 90 | return $documentation; |
91 | 91 | } |
92 | 92 | |
@@ -96,11 +96,11 @@ discard block |
||
96 | 96 | * @return string |
97 | 97 | * @filter site-reviews/path |
98 | 98 | */ |
99 | - public function filterFilePaths($path, $file) |
|
99 | + public function filterFilePaths( $path, $file ) |
|
100 | 100 | { |
101 | 101 | $addonPrefix = $this->addon->id.'/'; |
102 | - return Str::startsWith($addonPrefix, $file) |
|
103 | - ? $this->addon->path(Str::replaceFirst($addonPrefix, '', $file)) |
|
102 | + return Str::startsWith( $addonPrefix, $file ) |
|
103 | + ? $this->addon->path( Str::replaceFirst( $addonPrefix, '', $file ) ) |
|
104 | 104 | : $path; |
105 | 105 | } |
106 | 106 | |
@@ -110,11 +110,11 @@ discard block |
||
110 | 110 | * @return string |
111 | 111 | * @filter site-reviews/gettext/{addon_id} |
112 | 112 | */ |
113 | - public function filterGettext($translation, $text) |
|
113 | + public function filterGettext( $translation, $text ) |
|
114 | 114 | { |
115 | - return glsr(Translator::class)->translate($translation, $this->addon->id, [ |
|
115 | + return glsr( Translator::class )->translate( $translation, $this->addon->id, [ |
|
116 | 116 | 'single' => $text, |
117 | - ]); |
|
117 | + ] ); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | * @return string |
125 | 125 | * @filter site-reviews/gettext_with_context/{addon_id} |
126 | 126 | */ |
127 | - public function filterGettextWithContext($translation, $text, $context) |
|
127 | + public function filterGettextWithContext( $translation, $text, $context ) |
|
128 | 128 | { |
129 | - return glsr(Translator::class)->translate($translation, $this->addon->id, [ |
|
129 | + return glsr( Translator::class )->translate( $translation, $this->addon->id, [ |
|
130 | 130 | 'context' => $context, |
131 | 131 | 'single' => $text, |
132 | - ]); |
|
132 | + ] ); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -140,13 +140,13 @@ discard block |
||
140 | 140 | * @return string |
141 | 141 | * @filter site-reviews/ngettext/{addon_id} |
142 | 142 | */ |
143 | - public function filterNgettext($translation, $single, $plural, $number) |
|
143 | + public function filterNgettext( $translation, $single, $plural, $number ) |
|
144 | 144 | { |
145 | - return glsr(Translator::class)->translate($translation, $this->addon->id, [ |
|
145 | + return glsr( Translator::class )->translate( $translation, $this->addon->id, [ |
|
146 | 146 | 'number' => $number, |
147 | 147 | 'plural' => $plural, |
148 | 148 | 'single' => $single, |
149 | - ]); |
|
149 | + ] ); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -158,25 +158,25 @@ discard block |
||
158 | 158 | * @return string |
159 | 159 | * @filter site-reviews/ngettext_with_context/{addon_id} |
160 | 160 | */ |
161 | - public function filterNgettextWithContextSiteReviews($translation, $single, $plural, $number, $context) |
|
161 | + public function filterNgettextWithContextSiteReviews( $translation, $single, $plural, $number, $context ) |
|
162 | 162 | { |
163 | - return glsr(Translator::class)->translate($translation, $this->addon->id, [ |
|
163 | + return glsr( Translator::class )->translate( $translation, $this->addon->id, [ |
|
164 | 164 | 'context' => $context, |
165 | 165 | 'number' => $number, |
166 | 166 | 'plural' => $plural, |
167 | 167 | 'single' => $single, |
168 | - ]); |
|
168 | + ] ); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
172 | 172 | * @return array |
173 | 173 | * @filter site-reviews/addon/settings |
174 | 174 | */ |
175 | - public function filterSettings(array $settings) |
|
175 | + public function filterSettings( array $settings ) |
|
176 | 176 | { |
177 | - $settingsFile = $this->addon->path('config/settings.php'); |
|
178 | - if (file_exists($settingsFile)) { |
|
179 | - $settings = array_merge((include $settingsFile), $settings); |
|
177 | + $settingsFile = $this->addon->path( 'config/settings.php' ); |
|
178 | + if( file_exists( $settingsFile ) ) { |
|
179 | + $settings = array_merge( (include $settingsFile), $settings ); |
|
180 | 180 | } |
181 | 181 | return $settings; |
182 | 182 | } |
@@ -185,14 +185,14 @@ discard block |
||
185 | 185 | * @return array |
186 | 186 | * @filter site-reviews/addon/system-info |
187 | 187 | */ |
188 | - public function filterSystemInfo(array $details) |
|
188 | + public function filterSystemInfo( array $details ) |
|
189 | 189 | { |
190 | 190 | $version = $this->addon->version; |
191 | - $previousVersion = glsr(OptionManager::class)->get('addons.'.$this->addon->id.'.version_upgraded_from'); |
|
192 | - if (empty($previousVersion)) { |
|
191 | + $previousVersion = glsr( OptionManager::class )->get( 'addons.'.$this->addon->id.'.version_upgraded_from' ); |
|
192 | + if( empty($previousVersion) ) { |
|
193 | 193 | $previousVersion = $version; |
194 | 194 | } |
195 | - $details[$this->addon->name] = sprintf('%s (%s)', $this->addon->version, $previousVersion); |
|
195 | + $details[$this->addon->name] = sprintf( '%s (%s)', $this->addon->version, $previousVersion ); |
|
196 | 196 | return $details; |
197 | 197 | } |
198 | 198 | |
@@ -200,17 +200,17 @@ discard block |
||
200 | 200 | * @return array |
201 | 201 | * @filter site-reviews/translation/entries |
202 | 202 | */ |
203 | - public function filterTranslationEntries(array $entries) |
|
203 | + public function filterTranslationEntries( array $entries ) |
|
204 | 204 | { |
205 | - $potFile = $this->addon->path($this->addon->languages.'/'.$this->addon->id.'.pot'); |
|
206 | - return glsr(Translation::class)->extractEntriesFromPotFile($potFile, $entries); |
|
205 | + $potFile = $this->addon->path( $this->addon->languages.'/'.$this->addon->id.'.pot' ); |
|
206 | + return glsr( Translation::class )->extractEntriesFromPotFile( $potFile, $entries ); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
210 | 210 | * @return array |
211 | 211 | * @filter site-reviews/translator/domains |
212 | 212 | */ |
213 | - public function filterTranslatorDomains(array $domains) |
|
213 | + public function filterTranslatorDomains( array $domains ) |
|
214 | 214 | { |
215 | 215 | $domains[] = $this->addon->id; |
216 | 216 | return $domains; |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | */ |
231 | 231 | public function registerLanguages() |
232 | 232 | { |
233 | - load_plugin_textdomain($this->addon->id, false, |
|
234 | - trailingslashit(plugin_basename($this->addon->path()).'/'.$this->addon->languages) |
|
233 | + load_plugin_textdomain( $this->addon->id, false, |
|
234 | + trailingslashit( plugin_basename( $this->addon->path() ).'/'.$this->addon->languages ) |
|
235 | 235 | ); |
236 | 236 | } |
237 | 237 | |
@@ -264,38 +264,38 @@ discard block |
||
264 | 264 | * @return void |
265 | 265 | * @action site-reviews/addon/settings/{addon_slug} |
266 | 266 | */ |
267 | - public function renderSettings($rows) |
|
267 | + public function renderSettings( $rows ) |
|
268 | 268 | { |
269 | - glsr(Template::class)->render($this->addon->id.'/views/settings', [ |
|
269 | + glsr( Template::class )->render( $this->addon->id.'/views/settings', [ |
|
270 | 270 | 'context' => [ |
271 | 271 | 'rows' => $rows, |
272 | 272 | 'title' => $this->addon->name, |
273 | 273 | ], |
274 | - ]); |
|
274 | + ] ); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
278 | 278 | * @param string $extension |
279 | 279 | * @return array |
280 | 280 | */ |
281 | - protected function buildAssetArgs($extension, array $args = []) |
|
281 | + protected function buildAssetArgs( $extension, array $args = [] ) |
|
282 | 282 | { |
283 | - $args = wp_parse_args($args, [ |
|
283 | + $args = wp_parse_args( $args, [ |
|
284 | 284 | 'dependencies' => [], |
285 | 285 | 'in_footer' => true, |
286 | 286 | 'suffix' => '', |
287 | - ]); |
|
288 | - $path = 'assets/'.$this->addon->id.Str::prefix('-', $args['suffix']).'.'.$extension; |
|
289 | - if (!file_exists($this->addon->path($path)) || !in_array($extension, ['css', 'js'])) { |
|
287 | + ] ); |
|
288 | + $path = 'assets/'.$this->addon->id.Str::prefix( '-', $args['suffix'] ).'.'.$extension; |
|
289 | + if( !file_exists( $this->addon->path( $path ) ) || !in_array( $extension, ['css', 'js'] ) ) { |
|
290 | 290 | return []; |
291 | 291 | } |
292 | 292 | $funcArgs = [ |
293 | - $this->addon->id.Str::prefix('/', $args['suffix']), |
|
294 | - $this->addon->url($path), |
|
295 | - array_merge([glsr()->id.Str::prefix('/', $args['suffix'])], $args['dependencies']), |
|
293 | + $this->addon->id.Str::prefix( '/', $args['suffix'] ), |
|
294 | + $this->addon->url( $path ), |
|
295 | + array_merge( [glsr()->id.Str::prefix( '/', $args['suffix'] )], $args['dependencies'] ), |
|
296 | 296 | $this->addon->version, |
297 | 297 | ]; |
298 | - if ('js' === $extension && $args['in_footer']) { |
|
298 | + if( 'js' === $extension && $args['in_footer'] ) { |
|
299 | 299 | $funcArgs[] = true; // load script in the footer |
300 | 300 | } |
301 | 301 | return $funcArgs; |
@@ -305,13 +305,13 @@ discard block |
||
305 | 305 | * @param string $extension |
306 | 306 | * @return void |
307 | 307 | */ |
308 | - protected function enqueueAsset($extension, array $args = []) |
|
308 | + protected function enqueueAsset( $extension, array $args = [] ) |
|
309 | 309 | { |
310 | - if ($args = $this->buildAssetArgs($extension, $args)) { |
|
310 | + if( $args = $this->buildAssetArgs( $extension, $args ) ) { |
|
311 | 311 | $function = 'js' === $extension |
312 | 312 | ? 'wp_enqueue_script' |
313 | 313 | : 'wp_enqueue_style'; |
314 | - call_user_func_array($function, $args); |
|
314 | + call_user_func_array( $function, $args ); |
|
315 | 315 | } |
316 | 316 | } |
317 | 317 | |
@@ -319,13 +319,13 @@ discard block |
||
319 | 319 | * @param string $extension |
320 | 320 | * @return void |
321 | 321 | */ |
322 | - protected function registerAsset($extension, array $args = []) |
|
322 | + protected function registerAsset( $extension, array $args = [] ) |
|
323 | 323 | { |
324 | - if ($args = $this->buildAssetArgs($extension, $args)) { |
|
324 | + if( $args = $this->buildAssetArgs( $extension, $args ) ) { |
|
325 | 325 | $function = 'js' === $extension |
326 | 326 | ? 'wp_register_script' |
327 | 327 | : 'wp_register_style'; |
328 | - call_user_func_array($function, $args); |
|
328 | + call_user_func_array( $function, $args ); |
|
329 | 329 | } |
330 | 330 | } |
331 | 331 |
@@ -13,27 +13,27 @@ |
||
13 | 13 | */ |
14 | 14 | public function run() |
15 | 15 | { |
16 | - add_action('init', [$this->addon, 'update']); |
|
17 | - add_action('admin_enqueue_scripts', [$this->controller, 'enqueueAdminAssets']); |
|
18 | - add_action('enqueue_block_editor_assets', [$this->controller, 'enqueueBlockAssets']); |
|
19 | - add_action('wp_enqueue_scripts', [$this->controller, 'enqueuePublicAssets']); |
|
20 | - add_filter('plugin_action_links_'.$this->basename, [$this->controller, 'filterActionLinks']); |
|
21 | - add_filter('site-reviews/config', [$this->controller, 'filterConfigPath']); |
|
22 | - add_filter('site-reviews/addon/documentation', [$this->controller, 'filterDocumentation']); |
|
23 | - add_filter('site-reviews/gettext/site-reviews-images', [$this->controller, 'filterGettext'], 10, 2); |
|
24 | - add_filter('site-reviews/gettext_with_context/site-reviews-images', [$this->controller, 'filterGettextWithContext'], 10, 3); |
|
25 | - add_filter('site-reviews/ngettext/site-reviews-images', [$this->controller, 'filterNgettext'], 10, 4); |
|
26 | - add_filter('site-reviews/ngettext_with_context/site-reviews-images', [$this->controller, 'filterNgettextWithContext'], 10, 5); |
|
27 | - add_filter('site-reviews/path', [$this->controller, 'filterFilePaths'], 10, 2); |
|
28 | - add_filter('site-reviews/addon/settings', [$this->controller, 'filterSettings']); |
|
29 | - add_filter('site-reviews/addon/system-info', [$this->controller, 'filterSystemInfo']); |
|
30 | - add_filter('site-reviews/translation/entries', [$this->controller, 'filterTranslationEntries']); |
|
31 | - add_filter('site-reviews/translator/domains', [$this->controller, 'filterTranslatorDomains']); |
|
32 | - add_action('init', [$this->controller, 'registerBlocks']); |
|
33 | - add_action('plugins_loaded', [$this->controller, 'registerLanguages']); |
|
34 | - add_action('init', [$this->controller, 'registerShortcodes']); |
|
35 | - add_action('init', [$this->controller, 'registerTinymcePopups']); |
|
36 | - add_action('widgets_init', [$this->controller, 'registerWidgets']); |
|
37 | - add_action('site-reviews/addon/settings/'.$this->addon->slug, [$this->controller, 'renderSettings']); |
|
16 | + add_action( 'init', [$this->addon, 'update'] ); |
|
17 | + add_action( 'admin_enqueue_scripts', [$this->controller, 'enqueueAdminAssets'] ); |
|
18 | + add_action( 'enqueue_block_editor_assets', [$this->controller, 'enqueueBlockAssets'] ); |
|
19 | + add_action( 'wp_enqueue_scripts', [$this->controller, 'enqueuePublicAssets'] ); |
|
20 | + add_filter( 'plugin_action_links_'.$this->basename, [$this->controller, 'filterActionLinks'] ); |
|
21 | + add_filter( 'site-reviews/config', [$this->controller, 'filterConfigPath'] ); |
|
22 | + add_filter( 'site-reviews/addon/documentation', [$this->controller, 'filterDocumentation'] ); |
|
23 | + add_filter( 'site-reviews/gettext/site-reviews-images', [$this->controller, 'filterGettext'], 10, 2 ); |
|
24 | + add_filter( 'site-reviews/gettext_with_context/site-reviews-images', [$this->controller, 'filterGettextWithContext'], 10, 3 ); |
|
25 | + add_filter( 'site-reviews/ngettext/site-reviews-images', [$this->controller, 'filterNgettext'], 10, 4 ); |
|
26 | + add_filter( 'site-reviews/ngettext_with_context/site-reviews-images', [$this->controller, 'filterNgettextWithContext'], 10, 5 ); |
|
27 | + add_filter( 'site-reviews/path', [$this->controller, 'filterFilePaths'], 10, 2 ); |
|
28 | + add_filter( 'site-reviews/addon/settings', [$this->controller, 'filterSettings'] ); |
|
29 | + add_filter( 'site-reviews/addon/system-info', [$this->controller, 'filterSystemInfo'] ); |
|
30 | + add_filter( 'site-reviews/translation/entries', [$this->controller, 'filterTranslationEntries'] ); |
|
31 | + add_filter( 'site-reviews/translator/domains', [$this->controller, 'filterTranslatorDomains'] ); |
|
32 | + add_action( 'init', [$this->controller, 'registerBlocks'] ); |
|
33 | + add_action( 'plugins_loaded', [$this->controller, 'registerLanguages'] ); |
|
34 | + add_action( 'init', [$this->controller, 'registerShortcodes'] ); |
|
35 | + add_action( 'init', [$this->controller, 'registerTinymcePopups'] ); |
|
36 | + add_action( 'widgets_init', [$this->controller, 'registerWidgets'] ); |
|
37 | + add_action( 'site-reviews/addon/settings/'.$this->addon->slug, [$this->controller, 'renderSettings'] ); |
|
38 | 38 | } |
39 | 39 | } |
@@ -29,33 +29,33 @@ discard block |
||
29 | 29 | * @param string $apiUrl |
30 | 30 | * @param string $file |
31 | 31 | */ |
32 | - public function __construct($apiUrl, $file, array $data = []) |
|
32 | + public function __construct( $apiUrl, $file, array $data = [] ) |
|
33 | 33 | { |
34 | - if (!function_exists('get_plugin_data')) { |
|
34 | + if( !function_exists( 'get_plugin_data' ) ) { |
|
35 | 35 | require_once ABSPATH.WPINC.'/plugin.php'; |
36 | 36 | } |
37 | - $this->apiUrl = trailingslashit(apply_filters('site-reviews/addon/api-url', $apiUrl)); |
|
38 | - $this->data = wp_parse_args($data, get_plugin_data($file)); |
|
39 | - $this->plugin = plugin_basename($file); |
|
40 | - $this->transientName = Application::PREFIX.md5(Arr::get($data, 'TextDomain')); |
|
37 | + $this->apiUrl = trailingslashit( apply_filters( 'site-reviews/addon/api-url', $apiUrl ) ); |
|
38 | + $this->data = wp_parse_args( $data, get_plugin_data( $file ) ); |
|
39 | + $this->plugin = plugin_basename( $file ); |
|
40 | + $this->transientName = Application::PREFIX.md5( Arr::get( $data, 'TextDomain' ) ); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
44 | 44 | * @return object |
45 | 45 | */ |
46 | - public function activateLicense(array $data = []) |
|
46 | + public function activateLicense( array $data = [] ) |
|
47 | 47 | { |
48 | - return $this->request('activate_license', $data); |
|
48 | + return $this->request( 'activate_license', $data ); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @return object |
53 | 53 | */ |
54 | - public function checkLicense(array $data = []) |
|
54 | + public function checkLicense( array $data = [] ) |
|
55 | 55 | { |
56 | - $response = $this->request('check_license', $data); |
|
57 | - if ('valid' === Arr::get($response, 'license')) { |
|
58 | - $this->getPluginUpdate(true); |
|
56 | + $response = $this->request( 'check_license', $data ); |
|
57 | + if( 'valid' === Arr::get( $response, 'license' ) ) { |
|
58 | + $this->getPluginUpdate( true ); |
|
59 | 59 | } |
60 | 60 | return $response; |
61 | 61 | } |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | /** |
64 | 64 | * @return object |
65 | 65 | */ |
66 | - public function deactivateLicense(array $data = []) |
|
66 | + public function deactivateLicense( array $data = [] ) |
|
67 | 67 | { |
68 | - return $this->request('deactivate_license', $data); |
|
68 | + return $this->request( 'deactivate_license', $data ); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | * @param object $args |
75 | 75 | * @return mixed |
76 | 76 | */ |
77 | - public function filterPluginUpdateDetails($result, $action, $args) |
|
77 | + public function filterPluginUpdateDetails( $result, $action, $args ) |
|
78 | 78 | { |
79 | - if ('plugin_information' != $action |
|
80 | - || Arr::get($this->data, 'TextDomain') != Arr::get($args, 'slug')) { |
|
79 | + if( 'plugin_information' != $action |
|
80 | + || Arr::get( $this->data, 'TextDomain' ) != Arr::get( $args, 'slug' ) ) { |
|
81 | 81 | return $result; |
82 | 82 | } |
83 | - if ($updateInfo = $this->getPluginUpdate()) { |
|
84 | - return $this->modifyUpdateDetails($updateInfo); |
|
83 | + if( $updateInfo = $this->getPluginUpdate() ) { |
|
84 | + return $this->modifyUpdateDetails( $updateInfo ); |
|
85 | 85 | } |
86 | 86 | return $result; |
87 | 87 | } |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | * @param object $transient |
91 | 91 | * @return object |
92 | 92 | */ |
93 | - public function filterPluginUpdates($transient) |
|
93 | + public function filterPluginUpdates( $transient ) |
|
94 | 94 | { |
95 | - if ($updateInfo = $this->getPluginUpdate()) { |
|
96 | - return $this->modifyPluginUpdates($transient, $updateInfo); |
|
95 | + if( $updateInfo = $this->getPluginUpdate() ) { |
|
96 | + return $this->modifyPluginUpdates( $transient, $updateInfo ); |
|
97 | 97 | } |
98 | 98 | return $transient; |
99 | 99 | } |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | /** |
102 | 102 | * @return object |
103 | 103 | */ |
104 | - public function getVersion(array $data = []) |
|
104 | + public function getVersion( array $data = [] ) |
|
105 | 105 | { |
106 | - return $this->request('get_version', $data); |
|
106 | + return $this->request( 'get_version', $data ); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -111,13 +111,13 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function init() |
113 | 113 | { |
114 | - if ($this->apiUrl === trailingslashit(home_url())) { |
|
114 | + if( $this->apiUrl === trailingslashit( home_url() ) ) { |
|
115 | 115 | return; |
116 | 116 | } |
117 | - add_filter('plugins_api', [$this, 'filterPluginUpdateDetails'], 10, 3); |
|
118 | - add_filter('pre_set_site_transient_update_plugins', [$this, 'filterPluginUpdates'], 999); |
|
119 | - add_action('load-update-core.php', [$this, 'onForceUpdateCheck'], 9); |
|
120 | - add_action('in_plugin_update_message-'.$this->plugin, [$this, 'renderLicenseMissingLink']); |
|
117 | + add_filter( 'plugins_api', [$this, 'filterPluginUpdateDetails'], 10, 3 ); |
|
118 | + add_filter( 'pre_set_site_transient_update_plugins', [$this, 'filterPluginUpdates'], 999 ); |
|
119 | + add_action( 'load-update-core.php', [$this, 'onForceUpdateCheck'], 9 ); |
|
120 | + add_action( 'in_plugin_update_message-'.$this->plugin, [$this, 'renderLicenseMissingLink'] ); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | public function isLicenseValid() |
127 | 127 | { |
128 | 128 | $result = $this->checkLicense(); |
129 | - return 'valid' === Arr::get($result, 'license'); |
|
129 | + return 'valid' === Arr::get( $result, 'license' ); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -134,14 +134,14 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function onForceUpdateCheck() |
136 | 136 | { |
137 | - if (!filter_input(INPUT_GET, 'force-check')) { |
|
137 | + if( !filter_input( INPUT_GET, 'force-check' ) ) { |
|
138 | 138 | return; |
139 | 139 | } |
140 | - foreach (glsr()->addons as $addon) { |
|
140 | + foreach( glsr()->addons as $addon ) { |
|
141 | 141 | try { |
142 | - glsr($addon)->updater->getPluginUpdate(true); |
|
143 | - } catch (\Exception $e) { |
|
144 | - glsr_log()->error($e->getMessage()); |
|
142 | + glsr( $addon )->updater->getPluginUpdate( true ); |
|
143 | + } catch( \Exception $e ) { |
|
144 | + glsr_log()->error( $e->getMessage() ); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | } |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function renderLicenseMissingLink() |
153 | 153 | { |
154 | - if (!$this->isLicenseValid()) { |
|
155 | - glsr()->render('partials/addons/license-missing'); |
|
154 | + if( !$this->isLicenseValid() ) { |
|
155 | + glsr()->render( 'partials/addons/license-missing' ); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | |
@@ -161,22 +161,22 @@ discard block |
||
161 | 161 | */ |
162 | 162 | protected function getCachedVersion() |
163 | 163 | { |
164 | - return get_transient($this->transientName); |
|
164 | + return get_transient( $this->transientName ); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
168 | 168 | * @param bool $force |
169 | 169 | * @return false|object |
170 | 170 | */ |
171 | - protected function getPluginUpdate($force = false) |
|
171 | + protected function getPluginUpdate( $force = false ) |
|
172 | 172 | { |
173 | 173 | $version = $this->getCachedVersion(); |
174 | - if (false === $version || $force) { |
|
174 | + if( false === $version || $force ) { |
|
175 | 175 | $version = $this->getVersion(); |
176 | - $this->setCachedVersion($version); |
|
176 | + $this->setCachedVersion( $version ); |
|
177 | 177 | } |
178 | - if (isset($version->error)) { |
|
179 | - glsr_log()->error($version->error); |
|
178 | + if( isset($version->error) ) { |
|
179 | + glsr_log()->error( $version->error ); |
|
180 | 180 | return false; |
181 | 181 | } |
182 | 182 | return $version; |
@@ -187,15 +187,15 @@ discard block |
||
187 | 187 | * @param object $updateInfo |
188 | 188 | * @return object |
189 | 189 | */ |
190 | - protected function modifyPluginUpdates($transient, $updateInfo) |
|
190 | + protected function modifyPluginUpdates( $transient, $updateInfo ) |
|
191 | 191 | { |
192 | - $updateInfo->id = Application::ID.'/'.Arr::get($this->data, 'TextDomain'); |
|
192 | + $updateInfo->id = Application::ID.'/'.Arr::get( $this->data, 'TextDomain' ); |
|
193 | 193 | $updateInfo->plugin = $this->plugin; |
194 | - $updateInfo->requires_php = Arr::get($this->data, 'RequiresPHP'); |
|
195 | - $updateInfo->tested = Arr::get($this->data, 'testedTo'); |
|
196 | - $transient->checked[$this->plugin] = Arr::get($this->data, 'Version'); |
|
194 | + $updateInfo->requires_php = Arr::get( $this->data, 'RequiresPHP' ); |
|
195 | + $updateInfo->tested = Arr::get( $this->data, 'testedTo' ); |
|
196 | + $transient->checked[$this->plugin] = Arr::get( $this->data, 'Version' ); |
|
197 | 197 | $transient->last_checked = time(); |
198 | - if (Helper::isGreaterThan($updateInfo->new_version, Arr::get($this->data, 'Version'))) { |
|
198 | + if( Helper::isGreaterThan( $updateInfo->new_version, Arr::get( $this->data, 'Version' ) ) ) { |
|
199 | 199 | unset($transient->no_update[$this->plugin]); |
200 | 200 | $updateInfo->update = true; |
201 | 201 | $transient->response[$this->plugin] = $updateInfo; |
@@ -210,13 +210,13 @@ discard block |
||
210 | 210 | * @param object $updateInfo |
211 | 211 | * @return object |
212 | 212 | */ |
213 | - protected function modifyUpdateDetails($updateInfo) |
|
213 | + protected function modifyUpdateDetails( $updateInfo ) |
|
214 | 214 | { |
215 | - $updateInfo->author = Arr::get($this->data, 'Author'); |
|
216 | - $updateInfo->author_profile = Arr::get($this->data, 'AuthorURI'); |
|
217 | - $updateInfo->requires = Arr::get($this->data, 'RequiresWP'); |
|
218 | - $updateInfo->requires_php = Arr::get($this->data, 'RequiresPHP'); |
|
219 | - $updateInfo->tested = Arr::get($this->data, 'testedTo'); |
|
215 | + $updateInfo->author = Arr::get( $this->data, 'Author' ); |
|
216 | + $updateInfo->author_profile = Arr::get( $this->data, 'AuthorURI' ); |
|
217 | + $updateInfo->requires = Arr::get( $this->data, 'RequiresWP' ); |
|
218 | + $updateInfo->requires_php = Arr::get( $this->data, 'RequiresPHP' ); |
|
219 | + $updateInfo->tested = Arr::get( $this->data, 'testedTo' ); |
|
220 | 220 | $updateInfo->version = $updateInfo->new_version; |
221 | 221 | return $updateInfo; |
222 | 222 | } |
@@ -225,49 +225,49 @@ discard block |
||
225 | 225 | * @param \WP_Error|array $response |
226 | 226 | * @return object |
227 | 227 | */ |
228 | - protected function normalizeResponse($response) |
|
228 | + protected function normalizeResponse( $response ) |
|
229 | 229 | { |
230 | - $body = wp_remote_retrieve_body($response); |
|
231 | - if ($data = json_decode($body)) { |
|
232 | - $data = array_map('maybe_unserialize', (array) $data); |
|
233 | - return (object) $data; |
|
230 | + $body = wp_remote_retrieve_body( $response ); |
|
231 | + if( $data = json_decode( $body ) ) { |
|
232 | + $data = array_map( 'maybe_unserialize', (array)$data ); |
|
233 | + return (object)$data; |
|
234 | 234 | } |
235 | - $error = is_wp_error($response) |
|
235 | + $error = is_wp_error( $response ) |
|
236 | 236 | ? $response->get_error_message() |
237 | - : 'Update server not responding ('.Arr::get($this->data, 'TextDomain').')'; |
|
238 | - return (object) ['error' => $error]; |
|
237 | + : 'Update server not responding ('.Arr::get( $this->data, 'TextDomain' ).')'; |
|
238 | + return (object)['error' => $error]; |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
242 | 242 | * @param string $action activate_license|check_license|deactivate_license|get_version |
243 | 243 | * @return object |
244 | 244 | */ |
245 | - protected function request($action, array $data = []) |
|
245 | + protected function request( $action, array $data = [] ) |
|
246 | 246 | { |
247 | - $data = wp_parse_args($data, $this->data); |
|
248 | - $response = wp_remote_post($this->apiUrl, [ |
|
247 | + $data = wp_parse_args( $data, $this->data ); |
|
248 | + $response = wp_remote_post( $this->apiUrl, [ |
|
249 | 249 | 'body' => [ |
250 | 250 | 'edd_action' => $action, |
251 | - 'item_id' => Arr::get($data, 'item_id'), |
|
252 | - 'item_name' => Arr::get($data, 'Name'), |
|
253 | - 'license' => Arr::get($data, 'license'), |
|
254 | - 'slug' => Arr::get($data, 'TextDomain'), |
|
251 | + 'item_id' => Arr::get( $data, 'item_id' ), |
|
252 | + 'item_name' => Arr::get( $data, 'Name' ), |
|
253 | + 'license' => Arr::get( $data, 'license' ), |
|
254 | + 'slug' => Arr::get( $data, 'TextDomain' ), |
|
255 | 255 | 'url' => home_url(), |
256 | 256 | ], |
257 | - 'sslverify' => apply_filters('site-reviews/sslverify/post', false), |
|
257 | + 'sslverify' => apply_filters( 'site-reviews/sslverify/post', false ), |
|
258 | 258 | 'timeout' => 15, |
259 | - ]); |
|
260 | - return $this->normalizeResponse($response); |
|
259 | + ] ); |
|
260 | + return $this->normalizeResponse( $response ); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
264 | 264 | * @param object $version |
265 | 265 | * @return void |
266 | 266 | */ |
267 | - protected function setCachedVersion($version) |
|
267 | + protected function setCachedVersion( $version ) |
|
268 | 268 | { |
269 | - if (!isset($version->error)) { |
|
270 | - set_transient($this->transientName, $version, 3 * HOUR_IN_SECONDS); |
|
269 | + if( !isset($version->error) ) { |
|
270 | + set_transient( $this->transientName, $version, 3 * HOUR_IN_SECONDS ); |
|
271 | 271 | } |
272 | 272 | } |
273 | 273 | } |
@@ -39,20 +39,20 @@ discard block |
||
39 | 39 | /** |
40 | 40 | * @return string |
41 | 41 | */ |
42 | - public function render(array $attributes) |
|
42 | + public function render( array $attributes ) |
|
43 | 43 | { |
44 | 44 | $attributes['class'] = $attributes['className']; |
45 | - $shortcode = glsr(Shortcode::class); |
|
46 | - if ('edit' == filter_input(INPUT_GET, 'context')) { |
|
45 | + $shortcode = glsr( Shortcode::class ); |
|
46 | + if( 'edit' == filter_input( INPUT_GET, 'context' ) ) { |
|
47 | 47 | $this->filterBlockClass(); |
48 | 48 | $this->filterFormFields(); |
49 | 49 | $this->filterRatingField(); |
50 | 50 | $this->filterSubmitButton(); |
51 | - if (!$this->hasVisibleFields($shortcode, $attributes)) { |
|
51 | + if( !$this->hasVisibleFields( $shortcode, $attributes ) ) { |
|
52 | 52 | $this->filterInterpolation(); |
53 | 53 | } |
54 | 54 | } |
55 | - return $shortcode->buildBlock($attributes); |
|
55 | + return $shortcode->buildBlock( $attributes ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | */ |
61 | 61 | protected function filterFormFields() |
62 | 62 | { |
63 | - add_filter('site-reviews/config/forms/submission-form', function (array $config) { |
|
64 | - array_walk($config, function (&$field) { |
|
63 | + add_filter( 'site-reviews/config/forms/submission-form', function( array $config ) { |
|
64 | + array_walk( $config, function( &$field ) { |
|
65 | 65 | $field['disabled'] = true; |
66 | 66 | $field['tabindex'] = '-1'; |
67 | 67 | }); |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | */ |
75 | 75 | protected function filterInterpolation() |
76 | 76 | { |
77 | - add_filter('site-reviews/interpolate/reviews-form', function ($context) { |
|
77 | + add_filter( 'site-reviews/interpolate/reviews-form', function( $context ) { |
|
78 | 78 | $context['class'] = 'glsr-default glsr-block-disabled'; |
79 | - $context['fields'] = __('You have hidden all of the fields for this block.', 'site-reviews'); |
|
79 | + $context['fields'] = __( 'You have hidden all of the fields for this block.', 'site-reviews' ); |
|
80 | 80 | $context['response'] = ''; |
81 | 81 | $context['submit_button'] = ''; |
82 | 82 | return $context; |
@@ -88,15 +88,15 @@ discard block |
||
88 | 88 | */ |
89 | 89 | protected function filterRatingField() |
90 | 90 | { |
91 | - add_filter('site-reviews/rendered/field', function ($html, $type, $args) { |
|
92 | - if ('rating' == $args['path']) { |
|
91 | + add_filter( 'site-reviews/rendered/field', function( $html, $type, $args ) { |
|
92 | + if( 'rating' == $args['path'] ) { |
|
93 | 93 | $stars = '<span class="glsr-stars">'; |
94 | - $stars.= str_repeat('<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int) glsr()->constant('MAX_RATING', Rating::class)); |
|
95 | - $stars.= '</span>'; |
|
96 | - $html = preg_replace('/(.*)(<select.*)(<\/select>)(.*)/', '$1'.$stars.'$4', $html); |
|
94 | + $stars .= str_repeat( '<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int)glsr()->constant( 'MAX_RATING', Rating::class ) ); |
|
95 | + $stars .= '</span>'; |
|
96 | + $html = preg_replace( '/(.*)(<select.*)(<\/select>)(.*)/', '$1'.$stars.'$4', $html ); |
|
97 | 97 | } |
98 | 98 | return $html; |
99 | - }, 10, 3); |
|
99 | + }, 10, 3 ); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | */ |
105 | 105 | protected function filterSubmitButton() |
106 | 106 | { |
107 | - add_filter('site-reviews/rendered/template/form/submit-button', function ($template) { |
|
108 | - return str_replace('type="submit"', 'tabindex="-1"', $template); |
|
107 | + add_filter( 'site-reviews/rendered/template/form/submit-button', function( $template ) { |
|
108 | + return str_replace( 'type="submit"', 'tabindex="-1"', $template ); |
|
109 | 109 | }); |
110 | 110 | } |
111 | 111 | } |
@@ -62,21 +62,21 @@ discard block |
||
62 | 62 | /** |
63 | 63 | * @return string |
64 | 64 | */ |
65 | - public function render(array $attributes) |
|
65 | + public function render( array $attributes ) |
|
66 | 66 | { |
67 | 67 | $attributes['class'] = $attributes['className']; |
68 | - $shortcode = glsr(Shortcode::class); |
|
69 | - if ('edit' == filter_input(INPUT_GET, 'context')) { |
|
70 | - $attributes = $this->normalize($attributes); |
|
68 | + $shortcode = glsr( Shortcode::class ); |
|
69 | + if( 'edit' == filter_input( INPUT_GET, 'context' ) ) { |
|
70 | + $attributes = $this->normalize( $attributes ); |
|
71 | 71 | $this->filterBlockClass(); |
72 | 72 | $this->filterReviewLinks(); |
73 | - $this->filterShowMoreLinks('content'); |
|
74 | - $this->filterShowMoreLinks('response'); |
|
75 | - if (!$this->hasVisibleFields($shortcode, $attributes)) { |
|
73 | + $this->filterShowMoreLinks( 'content' ); |
|
74 | + $this->filterShowMoreLinks( 'response' ); |
|
75 | + if( !$this->hasVisibleFields( $shortcode, $attributes ) ) { |
|
76 | 76 | $this->filterInterpolation(); |
77 | 77 | } |
78 | 78 | } |
79 | - return $shortcode->buildBlock($attributes); |
|
79 | + return $shortcode->buildBlock( $attributes ); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | */ |
85 | 85 | protected function filterInterpolation() |
86 | 86 | { |
87 | - add_filter('site-reviews/interpolate/reviews', function ($context) { |
|
87 | + add_filter( 'site-reviews/interpolate/reviews', function( $context ) { |
|
88 | 88 | $context['class'] = 'glsr-default glsr-block-disabled'; |
89 | - $context['reviews'] = __('You have hidden all of the fields for this block.', 'site-reviews'); |
|
89 | + $context['reviews'] = __( 'You have hidden all of the fields for this block.', 'site-reviews' ); |
|
90 | 90 | return $context; |
91 | 91 | }); |
92 | 92 | } |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | */ |
97 | 97 | protected function filterReviewLinks() |
98 | 98 | { |
99 | - add_filter('site-reviews/rendered/template/reviews', function ($template) { |
|
100 | - return str_replace('<a', '<a tabindex="-1"', $template); |
|
99 | + add_filter( 'site-reviews/rendered/template/reviews', function( $template ) { |
|
100 | + return str_replace( '<a', '<a tabindex="-1"', $template ); |
|
101 | 101 | }); |
102 | 102 | } |
103 | 103 | |
@@ -105,12 +105,12 @@ discard block |
||
105 | 105 | * @param string $field |
106 | 106 | * @return void |
107 | 107 | */ |
108 | - protected function filterShowMoreLinks($field) |
|
108 | + protected function filterShowMoreLinks( $field ) |
|
109 | 109 | { |
110 | - add_filter('site-reviews/review/wrap/'.$field, function ($value) { |
|
110 | + add_filter( 'site-reviews/review/wrap/'.$field, function( $value ) { |
|
111 | 111 | $value = preg_replace( |
112 | 112 | '/(.*)(<span class="glsr-hidden)(.*)(<\/span>)(.*)/s', |
113 | - '$1... <a href="#" class="glsr-read-more" tabindex="-1">'.__('Show more', 'site-reviews').'</a>$5', |
|
113 | + '$1... <a href="#" class="glsr-read-more" tabindex="-1">'.__( 'Show more', 'site-reviews' ).'</a>$5', |
|
114 | 114 | $value |
115 | 115 | ); |
116 | 116 | return $value; |