@@ -16,35 +16,35 @@ discard block |
||
16 | 16 | */ |
17 | 17 | public function registerPostType() |
18 | 18 | { |
19 | - if (!glsr()->hasPermission()) { |
|
19 | + if( !glsr()->hasPermission() ) { |
|
20 | 20 | return; |
21 | 21 | } |
22 | - $command = new RegisterPostType([ |
|
22 | + $command = new RegisterPostType( [ |
|
23 | 23 | 'capabilities' => ['create_posts' => 'create_'.Application::POST_TYPE], |
24 | 24 | 'capability_type' => Application::POST_TYPE, |
25 | 25 | 'columns' => [ |
26 | 26 | 'title' => '', |
27 | 27 | 'category' => '', |
28 | - 'assigned_to' => __('Assigned To', 'site-reviews'), |
|
29 | - 'reviewer' => __('Author', 'site-reviews'), |
|
30 | - 'email' => __('Email', 'site-reviews'), |
|
31 | - 'ip_address' => __('IP Address', 'site-reviews'), |
|
32 | - 'response' => __('Response', 'site-reviews'), |
|
33 | - 'review_type' => __('Type', 'site-reviews'), |
|
34 | - 'rating' => __('Rating', 'site-reviews'), |
|
35 | - 'pinned' => __('Pinned', 'site-reviews'), |
|
28 | + 'assigned_to' => __( 'Assigned To', 'site-reviews' ), |
|
29 | + 'reviewer' => __( 'Author', 'site-reviews' ), |
|
30 | + 'email' => __( 'Email', 'site-reviews' ), |
|
31 | + 'ip_address' => __( 'IP Address', 'site-reviews' ), |
|
32 | + 'response' => __( 'Response', 'site-reviews' ), |
|
33 | + 'review_type' => __( 'Type', 'site-reviews' ), |
|
34 | + 'rating' => __( 'Rating', 'site-reviews' ), |
|
35 | + 'pinned' => __( 'Pinned', 'site-reviews' ), |
|
36 | 36 | 'date' => '', |
37 | 37 | ], |
38 | 38 | 'menu_icon' => 'dashicons-star-half', |
39 | 39 | 'menu_name' => glsr()->name, |
40 | 40 | 'map_meta_cap' => true, |
41 | - 'plural' => __('Reviews', 'site-reviews'), |
|
41 | + 'plural' => __( 'Reviews', 'site-reviews' ), |
|
42 | 42 | 'post_type' => Application::POST_TYPE, |
43 | 43 | 'rest_controller_class' => RestReviewController::class, |
44 | 44 | 'show_in_rest' => true, |
45 | - 'single' => __('Review', 'site-reviews'), |
|
46 | - ]); |
|
47 | - $this->execute($command); |
|
45 | + 'single' => __( 'Review', 'site-reviews' ), |
|
46 | + ] ); |
|
47 | + $this->execute( $command ); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function registerShortcodes() |
55 | 55 | { |
56 | - $command = new RegisterShortcodes([ |
|
56 | + $command = new RegisterShortcodes( [ |
|
57 | 57 | 'site_reviews', |
58 | 58 | 'site_reviews_form', |
59 | 59 | 'site_reviews_summary', |
60 | - ]); |
|
61 | - $this->execute($command); |
|
60 | + ] ); |
|
61 | + $this->execute( $command ); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -67,16 +67,16 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function registerTaxonomy() |
69 | 69 | { |
70 | - $command = new RegisterTaxonomy([ |
|
70 | + $command = new RegisterTaxonomy( [ |
|
71 | 71 | 'hierarchical' => true, |
72 | - 'meta_box_cb' => [glsr(EditorController::class), 'renderTaxonomyMetabox'], |
|
72 | + 'meta_box_cb' => [glsr( EditorController::class ), 'renderTaxonomyMetabox'], |
|
73 | 73 | 'public' => false, |
74 | 74 | 'rest_controller_class' => RestCategoryController::class, |
75 | 75 | 'show_admin_column' => true, |
76 | 76 | 'show_in_rest' => true, |
77 | 77 | 'show_ui' => true, |
78 | - ]); |
|
79 | - $this->execute($command); |
|
78 | + ] ); |
|
79 | + $this->execute( $command ); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function registerWidgets() |
87 | 87 | { |
88 | - $command = new RegisterWidgets([ |
|
88 | + $command = new RegisterWidgets( [ |
|
89 | 89 | 'site-reviews', |
90 | 90 | 'site-reviews-form', |
91 | 91 | 'site-reviews-summary', |
92 | - ]); |
|
93 | - $this->execute($command); |
|
92 | + ] ); |
|
93 | + $this->execute( $command ); |
|
94 | 94 | } |
95 | 95 | } |
@@ -1,21 +1,21 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="wrap"> |
4 | - <h1 class="wp-heading-inline"><?= esc_html(get_admin_page_title()); ?></h1> |
|
4 | + <h1 class="wp-heading-inline"><?= esc_html( get_admin_page_title() ); ?></h1> |
|
5 | 5 | <?= $notices; ?> |
6 | - <p><?= __('Add-ons extend the functionality of Site Reviews.', 'site-reviews'); ?></p> |
|
6 | + <p><?= __( 'Add-ons extend the functionality of Site Reviews.', 'site-reviews' ); ?></p> |
|
7 | 7 | <div class="glsr-addons wp-clearfix"> |
8 | 8 | <?php |
9 | - $template->render('partials/addons/addon', [ |
|
9 | + $template->render( 'partials/addons/addon', [ |
|
10 | 10 | 'beta' => true, |
11 | 11 | 'context' => [ |
12 | - 'description' => __('This add-on allows your site visitors to submit images with their reviews. Apply now to test the unreleased beta version.', 'site-reviews'), |
|
12 | + 'description' => __( 'This add-on allows your site visitors to submit images with their reviews. Apply now to test the unreleased beta version.', 'site-reviews' ), |
|
13 | 13 | 'link' => 'https://niftyplugins.com/plugins/images/', |
14 | 14 | 'slug' => 'images', |
15 | 15 | 'title' => 'Images', |
16 | 16 | ], |
17 | 17 | 'plugin' => 'site-reviews-images/site-reviews-images.php', |
18 | - ]); |
|
18 | + ] ); |
|
19 | 19 | ?> |
20 | 20 | </div> |
21 | 21 | </div> |
@@ -42,17 +42,17 @@ discard block |
||
42 | 42 | 'setting' => 'Plugin Settings', |
43 | 43 | 'reviews' => 'Review Counts', |
44 | 44 | ]; |
45 | - $systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) { |
|
46 | - $methodName = Helper::buildMethodName('get-'.$key.'-details'); |
|
47 | - if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) { |
|
45 | + $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use ($details) { |
|
46 | + $methodName = Helper::buildMethodName( 'get-'.$key.'-details' ); |
|
47 | + if( method_exists( $this, $methodName ) && $systemDetails = $this->$methodName() ) { |
|
48 | 48 | return $carry.$this->implode( |
49 | - strtoupper($details[$key]), |
|
50 | - apply_filters('site-reviews/system/'.$key, $systemDetails) |
|
49 | + strtoupper( $details[$key] ), |
|
50 | + apply_filters( 'site-reviews/system/'.$key, $systemDetails ) |
|
51 | 51 | ); |
52 | 52 | } |
53 | 53 | return $carry; |
54 | 54 | }); |
55 | - return trim($systemInfo); |
|
55 | + return trim( $systemInfo ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | public function getActivePluginDetails() |
62 | 62 | { |
63 | 63 | $plugins = get_plugins(); |
64 | - $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array'); |
|
65 | - $inactive = array_diff_key($plugins, array_flip($activePlugins)); |
|
66 | - return $this->normalizePluginList(array_diff_key($plugins, $inactive)); |
|
64 | + $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' ); |
|
65 | + $inactive = array_diff_key( $plugins, array_flip( $activePlugins ) ); |
|
66 | + return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function getAddonDetails() |
73 | 73 | { |
74 | - $details = apply_filters('site-reviews/addon/system-info', []); |
|
75 | - ksort($details); |
|
74 | + $details = apply_filters( 'site-reviews/addon/system-info', [] ); |
|
75 | + ksort( $details ); |
|
76 | 76 | return $details; |
77 | 77 | } |
78 | 78 | |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | public function getBrowserDetails() |
83 | 83 | { |
84 | 84 | $browser = new Browser(); |
85 | - $name = esc_attr($browser->getName()); |
|
86 | - $userAgent = esc_attr($browser->getUserAgent()->getUserAgentString()); |
|
87 | - $version = esc_attr($browser->getVersion()); |
|
85 | + $name = esc_attr( $browser->getName() ); |
|
86 | + $userAgent = esc_attr( $browser->getUserAgent()->getUserAgentString() ); |
|
87 | + $version = esc_attr( $browser->getVersion() ); |
|
88 | 88 | return [ |
89 | - 'Browser Name' => sprintf('%s %s', $name, $version), |
|
89 | + 'Browser Name' => sprintf( '%s %s', $name, $version ), |
|
90 | 90 | 'Browser UA' => $userAgent, |
91 | 91 | ]; |
92 | 92 | } |
@@ -96,12 +96,12 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function getInactivePluginDetails() |
98 | 98 | { |
99 | - $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array'); |
|
100 | - $inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins))); |
|
99 | + $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' ); |
|
100 | + $inactivePlugins = $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) ); |
|
101 | 101 | $multisitePlugins = $this->getMultisitePluginDetails(); |
102 | 102 | return empty($multisitePlugins) |
103 | 103 | ? $inactivePlugins |
104 | - : array_diff($inactivePlugins, $multisitePlugins); |
|
104 | + : array_diff( $inactivePlugins, $multisitePlugins ); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function getMuPluginDetails() |
111 | 111 | { |
112 | - if (empty($plugins = get_mu_plugins())) { |
|
112 | + if( empty($plugins = get_mu_plugins()) ) { |
|
113 | 113 | return []; |
114 | 114 | } |
115 | - return $this->normalizePluginList($plugins); |
|
115 | + return $this->normalizePluginList( $plugins ); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function getMultisitePluginDetails() |
122 | 122 | { |
123 | - $activePlugins = (array) get_site_option('active_sitewide_plugins', []); |
|
124 | - if (!is_multisite() || empty($activePlugins)) { |
|
123 | + $activePlugins = (array)get_site_option( 'active_sitewide_plugins', [] ); |
|
124 | + if( !is_multisite() || empty($activePlugins) ) { |
|
125 | 125 | return []; |
126 | 126 | } |
127 | - return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins)); |
|
127 | + return $this->normalizePluginList( array_intersect_key( get_plugins(), $activePlugins ) ); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -132,31 +132,31 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function getPhpDetails() |
134 | 134 | { |
135 | - $displayErrors = $this->getINI('display_errors', null) |
|
136 | - ? 'On ('.$this->getINI('display_errors').')' |
|
135 | + $displayErrors = $this->getINI( 'display_errors', null ) |
|
136 | + ? 'On ('.$this->getINI( 'display_errors' ).')' |
|
137 | 137 | : 'N/A'; |
138 | - $intlSupport = extension_loaded('intl') |
|
139 | - ? phpversion('intl') |
|
138 | + $intlSupport = extension_loaded( 'intl' ) |
|
139 | + ? phpversion( 'intl' ) |
|
140 | 140 | : 'false'; |
141 | 141 | return [ |
142 | - 'cURL' => var_export(function_exists('curl_init'), true), |
|
143 | - 'Default Charset' => $this->getINI('default_charset'), |
|
142 | + 'cURL' => var_export( function_exists( 'curl_init' ), true ), |
|
143 | + 'Default Charset' => $this->getINI( 'default_charset' ), |
|
144 | 144 | 'Display Errors' => $displayErrors, |
145 | - 'fsockopen' => var_export(function_exists('fsockopen'), true), |
|
145 | + 'fsockopen' => var_export( function_exists( 'fsockopen' ), true ), |
|
146 | 146 | 'Intl' => $intlSupport, |
147 | - 'IPv6' => var_export(defined('AF_INET6'), true), |
|
148 | - 'Max Execution Time' => $this->getINI('max_execution_time'), |
|
149 | - 'Max Input Nesting Level' => $this->getINI('max_input_nesting_level'), |
|
150 | - 'Max Input Vars' => $this->getINI('max_input_vars'), |
|
151 | - 'Memory Limit' => $this->getINI('memory_limit'), |
|
152 | - 'Post Max Size' => $this->getINI('post_max_size'), |
|
153 | - 'Sendmail Path' => $this->getINI('sendmail_path'), |
|
154 | - 'Session Cookie Path' => esc_html($this->getINI('session.cookie_path')), |
|
155 | - 'Session Name' => esc_html($this->getINI('session.name')), |
|
156 | - 'Session Save Path' => esc_html($this->getINI('session.save_path')), |
|
157 | - 'Session Use Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_cookies', false)), true), |
|
158 | - 'Session Use Only Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_only_cookies', false)), true), |
|
159 | - 'Upload Max Filesize' => $this->getINI('upload_max_filesize'), |
|
147 | + 'IPv6' => var_export( defined( 'AF_INET6' ), true ), |
|
148 | + 'Max Execution Time' => $this->getINI( 'max_execution_time' ), |
|
149 | + 'Max Input Nesting Level' => $this->getINI( 'max_input_nesting_level' ), |
|
150 | + 'Max Input Vars' => $this->getINI( 'max_input_vars' ), |
|
151 | + 'Memory Limit' => $this->getINI( 'memory_limit' ), |
|
152 | + 'Post Max Size' => $this->getINI( 'post_max_size' ), |
|
153 | + 'Sendmail Path' => $this->getINI( 'sendmail_path' ), |
|
154 | + 'Session Cookie Path' => esc_html( $this->getINI( 'session.cookie_path' ) ), |
|
155 | + 'Session Name' => esc_html( $this->getINI( 'session.name' ) ), |
|
156 | + 'Session Save Path' => esc_html( $this->getINI( 'session.save_path' ) ), |
|
157 | + 'Session Use Cookies' => var_export( wp_validate_boolean( $this->getINI( 'session.use_cookies', false ) ), true ), |
|
158 | + 'Session Use Only Cookies' => var_export( wp_validate_boolean( $this->getINI( 'session.use_only_cookies', false ) ), true ), |
|
159 | + 'Upload Max Filesize' => $this->getINI( 'upload_max_filesize' ), |
|
160 | 160 | ]; |
161 | 161 | } |
162 | 162 | |
@@ -165,19 +165,19 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function getReviewsDetails() |
167 | 167 | { |
168 | - $counts = glsr(CountsManager::class)->getCounts(); |
|
169 | - $counts = Arr::flattenArray($counts); |
|
170 | - array_walk($counts, function (&$ratings) use ($counts) { |
|
171 | - if (is_array($ratings)) { |
|
172 | - $ratings = array_sum($ratings).' ('.implode(', ', $ratings).')'; |
|
168 | + $counts = glsr( CountsManager::class )->getCounts(); |
|
169 | + $counts = Arr::flattenArray( $counts ); |
|
170 | + array_walk( $counts, function( &$ratings ) use ($counts) { |
|
171 | + if( is_array( $ratings ) ) { |
|
172 | + $ratings = array_sum( $ratings ).' ('.implode( ', ', $ratings ).')'; |
|
173 | 173 | return; |
174 | 174 | } |
175 | 175 | glsr_log() |
176 | - ->error('$ratings is not an array, possibly due to incorrectly imported reviews.') |
|
177 | - ->debug($ratings) |
|
178 | - ->debug($counts); |
|
176 | + ->error( '$ratings is not an array, possibly due to incorrectly imported reviews.' ) |
|
177 | + ->debug( $ratings ) |
|
178 | + ->debug( $counts ); |
|
179 | 179 | }); |
180 | - ksort($counts); |
|
180 | + ksort( $counts ); |
|
181 | 181 | return $counts; |
182 | 182 | } |
183 | 183 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | 'Host Name' => $this->getHostName(), |
192 | 192 | 'MySQL Version' => $wpdb->db_version(), |
193 | 193 | 'PHP Version' => PHP_VERSION, |
194 | - 'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'), |
|
194 | + 'Server Software' => filter_input( INPUT_SERVER, 'SERVER_SOFTWARE' ), |
|
195 | 195 | ]; |
196 | 196 | } |
197 | 197 | |
@@ -200,16 +200,16 @@ discard block |
||
200 | 200 | */ |
201 | 201 | public function getSettingDetails() |
202 | 202 | { |
203 | - $settings = glsr(OptionManager::class)->get('settings', []); |
|
204 | - $settings = Arr::flattenArray($settings, true); |
|
205 | - $settings = $this->purgeSensitiveData($settings); |
|
206 | - ksort($settings); |
|
203 | + $settings = glsr( OptionManager::class )->get( 'settings', [] ); |
|
204 | + $settings = Arr::flattenArray( $settings, true ); |
|
205 | + $settings = $this->purgeSensitiveData( $settings ); |
|
206 | + ksort( $settings ); |
|
207 | 207 | $details = []; |
208 | - foreach ($settings as $key => $value) { |
|
209 | - if (Str::startsWith('strings', $key) && Str::endsWith('id', $key)) { |
|
208 | + foreach( $settings as $key => $value ) { |
|
209 | + if( Str::startsWith( 'strings', $key ) && Str::endsWith( 'id', $key ) ) { |
|
210 | 210 | continue; |
211 | 211 | } |
212 | - $value = htmlspecialchars(trim(preg_replace('/\s\s+/', '\\n', $value)), ENT_QUOTES, 'UTF-8'); |
|
212 | + $value = htmlspecialchars( trim( preg_replace( '/\s\s+/', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' ); |
|
213 | 213 | $details[$key] = $value; |
214 | 214 | } |
215 | 215 | return $details; |
@@ -221,12 +221,12 @@ discard block |
||
221 | 221 | public function getPluginDetails() |
222 | 222 | { |
223 | 223 | return [ |
224 | - 'Console level' => glsr(Console::class)->humanLevel(), |
|
225 | - 'Console size' => glsr(Console::class)->humanSize('0'), |
|
226 | - 'Last Migration Run' => glsr(Date::class)->localized(glsr(OptionManager::class)->get('last_migration_run'), 'unknown'), |
|
227 | - 'Last Rating Count' => glsr(Date::class)->localized(glsr(OptionManager::class)->get('last_review_count'), 'unknown'), |
|
224 | + 'Console level' => glsr( Console::class )->humanLevel(), |
|
225 | + 'Console size' => glsr( Console::class )->humanSize( '0' ), |
|
226 | + 'Last Migration Run' => glsr( Date::class )->localized( glsr( OptionManager::class )->get( 'last_migration_run' ), 'unknown' ), |
|
227 | + 'Last Rating Count' => glsr( Date::class )->localized( glsr( OptionManager::class )->get( 'last_review_count' ), 'unknown' ), |
|
228 | 228 | 'Version (current)' => glsr()->version, |
229 | - 'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'), |
|
229 | + 'Version (previous)' => glsr( OptionManager::class )->get( 'version_upgraded_from' ), |
|
230 | 230 | ]; |
231 | 231 | } |
232 | 232 | |
@@ -238,23 +238,23 @@ discard block |
||
238 | 238 | global $wpdb; |
239 | 239 | $theme = wp_get_theme(); |
240 | 240 | return [ |
241 | - 'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version), |
|
242 | - 'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1), |
|
241 | + 'Active Theme' => sprintf( '%s v%s', (string)$theme->Name, (string)$theme->Version ), |
|
242 | + 'Email Domain' => substr( strrchr( glsr( OptionManager::class )->getWP( 'admin_email' ), '@' ), 1 ), |
|
243 | 243 | 'Home URL' => home_url(), |
244 | 244 | 'Language' => get_locale(), |
245 | 245 | 'Memory Limit' => WP_MEMORY_LIMIT, |
246 | - 'Multisite' => var_export(is_multisite(), true), |
|
247 | - 'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'), |
|
248 | - 'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'), |
|
249 | - 'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'), |
|
250 | - 'Post Stati' => implode(', ', get_post_stati()), |
|
251 | - 'Remote Post' => glsr(Cache::class)->getRemotePostTest(), |
|
252 | - 'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'), |
|
246 | + 'Multisite' => var_export( is_multisite(), true ), |
|
247 | + 'Page For Posts ID' => glsr( OptionManager::class )->getWP( 'page_for_posts' ), |
|
248 | + 'Page On Front ID' => glsr( OptionManager::class )->getWP( 'page_on_front' ), |
|
249 | + 'Permalink Structure' => glsr( OptionManager::class )->getWP( 'permalink_structure', 'default' ), |
|
250 | + 'Post Stati' => implode( ', ', get_post_stati() ), |
|
251 | + 'Remote Post' => glsr( Cache::class )->getRemotePostTest(), |
|
252 | + 'Show On Front' => glsr( OptionManager::class )->getWP( 'show_on_front' ), |
|
253 | 253 | 'Site URL' => site_url(), |
254 | - 'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', $this->getINI('date.timezone').' (PHP)'), |
|
255 | - 'Version' => get_bloginfo('version'), |
|
256 | - 'WP Debug' => var_export(defined('WP_DEBUG'), true), |
|
257 | - 'WP Max Upload Size' => size_format(wp_max_upload_size()), |
|
254 | + 'Timezone' => glsr( OptionManager::class )->getWP( 'timezone_string', $this->getINI( 'date.timezone' ).' (PHP)' ), |
|
255 | + 'Version' => get_bloginfo( 'version' ), |
|
256 | + 'WP Debug' => var_export( defined( 'WP_DEBUG' ), true ), |
|
257 | + 'WP Max Upload Size' => size_format( wp_max_upload_size() ), |
|
258 | 258 | 'WP Memory Limit' => WP_MEMORY_LIMIT, |
259 | 259 | ]; |
260 | 260 | } |
@@ -284,13 +284,13 @@ discard block |
||
284 | 284 | 'secureserver.net' => 'GoDaddy', |
285 | 285 | 'WPE_APIKEY' => 'WP Engine', |
286 | 286 | ]; |
287 | - foreach ($checks as $key => $value) { |
|
288 | - if (!$this->isWebhostCheckValid($key)) { |
|
287 | + foreach( $checks as $key => $value ) { |
|
288 | + if( !$this->isWebhostCheckValid( $key ) ) { |
|
289 | 289 | continue; |
290 | 290 | } |
291 | 291 | return $value; |
292 | 292 | } |
293 | - return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')])); |
|
293 | + return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ) ); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -298,16 +298,16 @@ discard block |
||
298 | 298 | */ |
299 | 299 | protected function getHostName() |
300 | 300 | { |
301 | - return sprintf('%s (%s)', |
|
301 | + return sprintf( '%s (%s)', |
|
302 | 302 | $this->detectWebhostProvider(), |
303 | 303 | Helper::getIpAddress() |
304 | 304 | ); |
305 | 305 | } |
306 | 306 | |
307 | - protected function getINI($name, $disabledValue = 'ini_get() is disabled.') |
|
307 | + protected function getINI( $name, $disabledValue = 'ini_get() is disabled.' ) |
|
308 | 308 | { |
309 | - return function_exists('ini_get') |
|
310 | - ? ini_get($name) |
|
309 | + return function_exists( 'ini_get' ) |
|
310 | + ? ini_get( $name ) |
|
311 | 311 | : $disabledValue; |
312 | 312 | } |
313 | 313 | |
@@ -317,9 +317,9 @@ discard block |
||
317 | 317 | protected function getWordpressPlugins() |
318 | 318 | { |
319 | 319 | $plugins = get_plugins(); |
320 | - $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array'); |
|
321 | - $inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins))); |
|
322 | - $active = $this->normalizePluginList(array_diff_key($plugins, $inactive)); |
|
320 | + $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' ); |
|
321 | + $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) ); |
|
322 | + $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
323 | 323 | return $active + $inactive; |
324 | 324 | } |
325 | 325 | |
@@ -327,48 +327,48 @@ discard block |
||
327 | 327 | * @param string $title |
328 | 328 | * @return string |
329 | 329 | */ |
330 | - protected function implode($title, array $details) |
|
330 | + protected function implode( $title, array $details ) |
|
331 | 331 | { |
332 | 332 | $strings = ['['.$title.']']; |
333 | - $padding = max(array_map('strlen', array_keys($details))); |
|
334 | - $padding = max([$padding, static::PAD]); |
|
335 | - foreach ($details as $key => $value) { |
|
336 | - $strings[] = is_string($key) |
|
337 | - ? sprintf('%s : %s', str_pad($key, $padding, '.'), $value) |
|
333 | + $padding = max( array_map( 'strlen', array_keys( $details ) ) ); |
|
334 | + $padding = max( [$padding, static::PAD] ); |
|
335 | + foreach( $details as $key => $value ) { |
|
336 | + $strings[] = is_string( $key ) |
|
337 | + ? sprintf( '%s : %s', str_pad( $key, $padding, '.' ), $value ) |
|
338 | 338 | : ' - '.$value; |
339 | 339 | } |
340 | - return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL; |
|
340 | + return implode( PHP_EOL, $strings ).PHP_EOL.PHP_EOL; |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
344 | 344 | * @param string $key |
345 | 345 | * @return bool |
346 | 346 | */ |
347 | - protected function isWebhostCheckValid($key) |
|
347 | + protected function isWebhostCheckValid( $key ) |
|
348 | 348 | { |
349 | - return defined($key) |
|
350 | - || filter_input(INPUT_SERVER, $key) |
|
351 | - || Str::contains(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key) |
|
352 | - || Str::contains(DB_HOST, $key) |
|
353 | - || Str::contains(php_uname(), $key); |
|
349 | + return defined( $key ) |
|
350 | + || filter_input( INPUT_SERVER, $key ) |
|
351 | + || Str::contains( filter_input( INPUT_SERVER, 'SERVER_NAME' ), $key ) |
|
352 | + || Str::contains( DB_HOST, $key ) |
|
353 | + || Str::contains( php_uname(), $key ); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
357 | 357 | * @return array |
358 | 358 | */ |
359 | - protected function normalizePluginList(array $plugins) |
|
359 | + protected function normalizePluginList( array $plugins ) |
|
360 | 360 | { |
361 | - $plugins = array_map(function ($plugin) { |
|
362 | - return sprintf('%s v%s', Arr::get($plugin, 'Name'), Arr::get($plugin, 'Version')); |
|
363 | - }, $plugins); |
|
364 | - natcasesort($plugins); |
|
365 | - return array_flip($plugins); |
|
361 | + $plugins = array_map( function( $plugin ) { |
|
362 | + return sprintf( '%s v%s', Arr::get( $plugin, 'Name' ), Arr::get( $plugin, 'Version' ) ); |
|
363 | + }, $plugins ); |
|
364 | + natcasesort( $plugins ); |
|
365 | + return array_flip( $plugins ); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | /** |
369 | 369 | * @return array |
370 | 370 | */ |
371 | - protected function purgeSensitiveData(array $settings) |
|
371 | + protected function purgeSensitiveData( array $settings ) |
|
372 | 372 | { |
373 | 373 | $keys = [ |
374 | 374 | 'general.trustalyze_serial', |
@@ -376,12 +376,12 @@ discard block |
||
376 | 376 | 'submissions.recaptcha.key', |
377 | 377 | 'submissions.recaptcha.secret', |
378 | 378 | ]; |
379 | - array_walk($settings, function (&$value, $setting) use ($keys) { |
|
380 | - foreach ($keys as $key) { |
|
381 | - if (!Str::startsWith($key, $setting) || empty($value)) { |
|
379 | + array_walk( $settings, function( &$value, $setting ) use ($keys) { |
|
380 | + foreach( $keys as $key ) { |
|
381 | + if( !Str::startsWith( $key, $setting ) || empty($value) ) { |
|
382 | 382 | continue; |
383 | 383 | } |
384 | - $value = str_repeat('•', 13); |
|
384 | + $value = str_repeat( '•', 13 ); |
|
385 | 385 | return; |
386 | 386 | } |
387 | 387 | }); |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <p>This page shows all of the available shortcode options with examples of how to use them. You can use multiple options in the same shortcode.</p> |
4 | 4 | |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | <div class="glsr-card-header"> |
7 | 7 | <h3>[site_reviews]</h3> |
8 | 8 | <button type="button" class="handlediv" aria-expanded="true"> |
9 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
9 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
10 | 10 | <span class="toggle-indicator" aria-hidden="true"></span> |
11 | 11 | </button> |
12 | 12 | </div> |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | <div class="glsr-card-header"> |
81 | 81 | <h3>[site_reviews_form]</h3> |
82 | 82 | <button type="button" class="handlediv" aria-expanded="true"> |
83 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
83 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
84 | 84 | <span class="toggle-indicator" aria-hidden="true"></span> |
85 | 85 | </button> |
86 | 86 | </div> |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | <div class="glsr-card-header"> |
129 | 129 | <h3>[site_reviews_summary]</h3> |
130 | 130 | <button type="button" class="handlediv" aria-expanded="true"> |
131 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
131 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
132 | 132 | <span class="toggle-indicator" aria-hidden="true"></span> |
133 | 133 | </button> |
134 | 134 | </div> |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | <pre><code>[site_reviews_summary hide="bars,if_empty,rating,stars,summary"]</code></pre> |
159 | 159 | |
160 | 160 | <p class="glsr-heading">labels</p> |
161 | - <p>The "labels" attribute allows you to enter custom labels for the percentage bar levels (from high to low), each level should be separated with a comma. However, rather than using this attribute to change the labels it's recommended to instead create a custom translation for them in the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-translations'); ?>">Settings → Translations</a></code> page.</p> |
|
161 | + <p>The "labels" attribute allows you to enter custom labels for the percentage bar levels (from high to low), each level should be separated with a comma. However, rather than using this attribute to change the labels it's recommended to instead create a custom translation for them in the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-translations' ); ?>">Settings → Translations</a></code> page.</p> |
|
162 | 162 | <p>The default labels value is: <code>"Excellent,Very good,Average,Poor,Terrible"</code></p> |
163 | 163 | <pre><code>[site_reviews_summary labels="5 star,4 star,3 star,2 star,1 star"]</code></pre> |
164 | 164 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | <pre><code>[site_reviews_summary schema="true"]</code></pre> |
176 | 176 | |
177 | 177 | <p class="glsr-heading">text</p> |
178 | - <p>The "text" attribute allows you to change the summary text. Available template tags to use are, "{rating}" which represents the calculated average rating, "{max}" which represents the maximum star rating available, and "{num}" which represents the total number of reviews. However, rather than using this attribute to change the summary text it's recommended to instead create a custom translation for it in the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-translations'); ?>">Settings → Translations</a></code> page. That way, you will be able to customize both the singular (1 review) and plural (2 reviews) summary texts.</p> |
|
178 | + <p>The "text" attribute allows you to change the summary text. Available template tags to use are, "{rating}" which represents the calculated average rating, "{max}" which represents the maximum star rating available, and "{num}" which represents the total number of reviews. However, rather than using this attribute to change the summary text it's recommended to instead create a custom translation for it in the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-translations' ); ?>">Settings → Translations</a></code> page. That way, you will be able to customize both the singular (1 review) and plural (2 reviews) summary texts.</p> |
|
179 | 179 | <p>The default text value is: <code>"{rating} out of {max} stars (based on {num} reviews)"</code></p> |
180 | 180 | <pre><code>[site_reviews_summary text="{num} customer reviews"]</code></pre> |
181 | 181 |
@@ -1,15 +1,15 @@ discard block |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div id="faq-01" class="glsr-card postbox"> |
4 | 4 | <div class="glsr-card-header"> |
5 | 5 | <h3>How do I add additional values to the schema?</h3> |
6 | 6 | <button type="button" class="handlediv" aria-expanded="true"> |
7 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
7 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
8 | 8 | <span class="toggle-indicator" aria-hidden="true"></span> |
9 | 9 | </button> |
10 | 10 | </div> |
11 | 11 | <div class="inside"> |
12 | - <p>To add additional values to the generated schema, use the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-hooks'); ?>" data-expand="#hooks-07">site-reviews/schema/[SCHEMA_TYPE]</a></code> hook in your theme's functions.php file.</p> |
|
12 | + <p>To add additional values to the generated schema, use the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-hooks' ); ?>" data-expand="#hooks-07">site-reviews/schema/[SCHEMA_TYPE]</a></code> hook in your theme's functions.php file.</p> |
|
13 | 13 | <p>Make sure to use Google's <a href="https://search.google.com/structured-data/testing-tool">Structured Data Testing Tool</a> to test the schema after any custom modifications have been made.</p> |
14 | 14 | <pre><code class="php">/** |
15 | 15 | * Modifies the schema created by Site Reviews. |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | <div class="glsr-card-header"> |
35 | 35 | <h3>How do I add pagination to my reviews?</h3> |
36 | 36 | <button type="button" class="handlediv" aria-expanded="true"> |
37 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
37 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
38 | 38 | <span class="toggle-indicator" aria-hidden="true"></span> |
39 | 39 | </button> |
40 | 40 | </div> |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | <p>If you are using the shortcodes, then use the <code>pagination</code> and <code>count</code> options.</p> |
44 | 44 | <p>For example, this will paginate reviews to 10 reviews per-page:</p> |
45 | 45 | <pre><code class="php">[site_reviews pagination=ajax count=10]</code></pre> |
46 | - <p>To lean more about the available shortcode options and how to use them, please see the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes'); ?>">Documentation > Shortcodes</a></code> page.</p> |
|
46 | + <p>To lean more about the available shortcode options and how to use them, please see the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes' ); ?>">Documentation > Shortcodes</a></code> page.</p> |
|
47 | 47 | </div> |
48 | 48 | </div> |
49 | 49 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | <div class="glsr-card-header"> |
52 | 52 | <h3>How do I assign reviews to a page?</h3> |
53 | 53 | <button type="button" class="handlediv" aria-expanded="true"> |
54 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
54 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
55 | 55 | <span class="toggle-indicator" aria-hidden="true"></span> |
56 | 56 | </button> |
57 | 57 | </div> |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | <p>If you use <code>post_id</code> as the value, then Site Reviews will know to automatically use the Page ID of the current page.</p> |
70 | 70 | <p>If you use <code>parent_id</code> as the value, then Site Reviews will know to automatically use the Page ID of the current page's Parent.</p> |
71 | 71 | <p>You can, of course, also directly enter the numerical WordPress Page ID of the page instead if your prefer.</p> |
72 | - <p>To lean more about the available shortcode options and how to use them, please see the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes'); ?>">Documentation > Shortcodes</a></code> page.</p> |
|
72 | + <p>To lean more about the available shortcode options and how to use them, please see the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes' ); ?>">Documentation > Shortcodes</a></code> page.</p> |
|
73 | 73 | </div> |
74 | 74 | </div> |
75 | 75 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | <div class="glsr-card-header"> |
78 | 78 | <h3>How do I change the font?</h3> |
79 | 79 | <button type="button" class="handlediv" aria-expanded="true"> |
80 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
80 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
81 | 81 | <span class="toggle-indicator" aria-hidden="true"></span> |
82 | 82 | </button> |
83 | 83 | </div> |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | <div class="glsr-card-header"> |
94 | 94 | <h3>How do I change the order of the review fields?</h3> |
95 | 95 | <button type="button" class="handlediv" aria-expanded="true"> |
96 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
96 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
97 | 97 | <span class="toggle-indicator" aria-hidden="true"></span> |
98 | 98 | </button> |
99 | 99 | </div> |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | <div class="glsr-card-header"> |
122 | 122 | <h3>How do I change the order of the reviews summary fields?</h3> |
123 | 123 | <button type="button" class="handlediv" aria-expanded="true"> |
124 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
124 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
125 | 125 | <span class="toggle-indicator" aria-hidden="true"></span> |
126 | 126 | </button> |
127 | 127 | </div> |
@@ -147,12 +147,12 @@ discard block |
||
147 | 147 | <div class="glsr-card-header"> |
148 | 148 | <h3>How do I change the order of the submission form fields?</h3> |
149 | 149 | <button type="button" class="handlediv" aria-expanded="true"> |
150 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
150 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
151 | 151 | <span class="toggle-indicator" aria-hidden="true"></span> |
152 | 152 | </button> |
153 | 153 | </div> |
154 | 154 | <div class="inside"> |
155 | - <p>To customise the order of the fields in the review submission form, use the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-hooks'); ?>" data-expand="#hooks-01">site-reviews/submission-form/order</a></code> filter hook in your theme's <code>functions.php</code> file.</p> |
|
155 | + <p>To customise the order of the fields in the review submission form, use the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-hooks' ); ?>" data-expand="#hooks-01">site-reviews/submission-form/order</a></code> filter hook in your theme's <code>functions.php</code> file.</p> |
|
156 | 156 | <pre><code class="php">/** |
157 | 157 | * Customises the order of the fields used in the Site Reviews submission form. |
158 | 158 | * Paste this in your active theme's functions.php file. |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | 'terms', |
172 | 172 | ]; |
173 | 173 | });</code></pre> |
174 | - <p>If you have used the example above and the submission-form fields are not working correctly, check the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=tools#tab-console'); ?>">Tools → Console</a></code> for errors.</p> |
|
174 | + <p>If you have used the example above and the submission-form fields are not working correctly, check the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=tools#tab-console' ); ?>">Tools → Console</a></code> for errors.</p> |
|
175 | 175 | </div> |
176 | 176 | </div> |
177 | 177 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | <div class="glsr-card-header"> |
180 | 180 | <h3>How do I change the pagination query string?</h3> |
181 | 181 | <button type="button" class="handlediv" aria-expanded="true"> |
182 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
182 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
183 | 183 | <span class="toggle-indicator" aria-hidden="true"></span> |
184 | 184 | </button> |
185 | 185 | </div> |
@@ -201,12 +201,12 @@ discard block |
||
201 | 201 | <div class="glsr-card-header"> |
202 | 202 | <h3>How do I change the text of...?</h3> |
203 | 203 | <button type="button" class="handlediv" aria-expanded="true"> |
204 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
204 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
205 | 205 | <span class="toggle-indicator" aria-hidden="true"></span> |
206 | 206 | </button> |
207 | 207 | </div> |
208 | 208 | <div class="inside"> |
209 | - <p>You can change any text in the plugin on the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-translations'); ?>">Settings → Translations</a></code> page.</p> |
|
209 | + <p>You can change any text in the plugin on the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-translations' ); ?>">Settings → Translations</a></code> page.</p> |
|
210 | 210 | </div> |
211 | 211 | </div> |
212 | 212 | |
@@ -214,12 +214,12 @@ discard block |
||
214 | 214 | <div class="glsr-card-header"> |
215 | 215 | <h3>How do I create a review programmatically?</h3> |
216 | 216 | <button type="button" class="handlediv" aria-expanded="true"> |
217 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
217 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
218 | 218 | <span class="toggle-indicator" aria-hidden="true"></span> |
219 | 219 | </button> |
220 | 220 | </div> |
221 | 221 | <div class="inside"> |
222 | - <p>Site Reviews provides a <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-functions'); ?>" data-expand="#functions-02">glsr_create_review()</a></code> helper function to easily create a review.</p> |
|
222 | + <p>Site Reviews provides a <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-functions' ); ?>" data-expand="#functions-02">glsr_create_review()</a></code> helper function to easily create a review.</p> |
|
223 | 223 | <p>Here is an example:</p> |
224 | 224 | <pre><code class="php">if (function_exists('glsr_create_review')) { |
225 | 225 | $review = glsr_create_review([ |
@@ -239,12 +239,12 @@ discard block |
||
239 | 239 | <div class="glsr-card-header"> |
240 | 240 | <h3>How do I customise the stars?</h3> |
241 | 241 | <button type="button" class="handlediv" aria-expanded="true"> |
242 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
242 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
243 | 243 | <span class="toggle-indicator" aria-hidden="true"></span> |
244 | 244 | </button> |
245 | 245 | </div> |
246 | 246 | <div class="inside"> |
247 | - <p>To customise the star images used by the plugin, use the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-hooks'); ?>" data-expand="#hooks-02">site-reviews/config/inline-styles</a></code> filter hook in your theme's <code>functions.php</code> file.</p> |
|
247 | + <p>To customise the star images used by the plugin, use the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-hooks' ); ?>" data-expand="#hooks-02">site-reviews/config/inline-styles</a></code> filter hook in your theme's <code>functions.php</code> file.</p> |
|
248 | 248 | <p>Here is an example:</p> |
249 | 249 | <pre><code class="php">/** |
250 | 250 | * Customises the stars used by Site Reviews. |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | <li>Open the SVG images that you copied with a text editor</li> |
267 | 267 | <li>Change the <a target="_blank" href="https://www.hexcolortool.com">hex colour code</a> to the one you want</li> |
268 | 268 | <li>Install and activate the <a target="_blank" href="https://wordpress.org/plugins/safe-svg/">Safe SVG</a> plugin</li> |
269 | - <li>Upload the edited SVG images to your <a href="<?= admin_url('upload.php'); ?>">Media Library</a></li> |
|
269 | + <li>Upload the edited SVG images to your <a href="<?= admin_url( 'upload.php' ); ?>">Media Library</a></li> |
|
270 | 270 | <li>Copy the File URL of the uploaded SVG images and paste them into the snippet above</li> |
271 | 271 | </ol> |
272 | 272 | </div> |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | <div class="glsr-card-header"> |
277 | 277 | <h3>How do I hide the form after a review is submitted?</h3> |
278 | 278 | <button type="button" class="handlediv" aria-expanded="true"> |
279 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
279 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
280 | 280 | <span class="toggle-indicator" aria-hidden="true"></span> |
281 | 281 | </button> |
282 | 282 | </div> |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | });"; |
299 | 299 | });</code></pre> |
300 | 300 | <p>You can also hide the form from registered users who have already submitted a review.</p> |
301 | - <p>To do this, you will need to first make sure that the "Limit Reviews" setting on the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-submissions'); ?>">Settings → Submissions</a></code> page is set to "By Username". Once that is done, you can use the following code snippet:</p> |
|
301 | + <p>To do this, you will need to first make sure that the "Limit Reviews" setting on the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-submissions' ); ?>">Settings → Submissions</a></code> page is set to "By Username". Once that is done, you can use the following code snippet:</p> |
|
302 | 302 | <pre><code class="php">/** |
303 | 303 | * Hides the submission form from registered users who have already submitted a review |
304 | 304 | * Paste this in your active theme's functions.php file |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | <div class="glsr-card-header"> |
320 | 320 | <h3>How do I limit the submitted review length?</h3> |
321 | 321 | <button type="button" class="handlediv" aria-expanded="true"> |
322 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
322 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
323 | 323 | <span class="toggle-indicator" aria-hidden="true"></span> |
324 | 324 | </button> |
325 | 325 | </div> |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | <div class="glsr-card-header"> |
358 | 358 | <h3>How do I order pages with assigned reviews by rating or ranking?</h3> |
359 | 359 | <button type="button" class="handlediv" aria-expanded="true"> |
360 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
360 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
361 | 361 | <span class="toggle-indicator" aria-hidden="true"></span> |
362 | 362 | </button> |
363 | 363 | </div> |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | <div class="glsr-card-header"> |
414 | 414 | <h3>How do I prevent search engines from indexing paginated reviews?</h3> |
415 | 415 | <button type="button" class="handlediv" aria-expanded="true"> |
416 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
416 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
417 | 417 | <span class="toggle-indicator" aria-hidden="true"></span> |
418 | 418 | </button> |
419 | 419 | </div> |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | <p>Here is how to prevent search engines from indexing your paginated reviews:</p> |
423 | 423 | <ol> |
424 | 424 | <li>Install and activate the <a href="https://wordpress.org/plugins/robots-txt-editor/">Robots.txt Editor</a> plugin.</li> |
425 | - <li>Go to the <code><a href="<?= admin_url('options-reading.php'); ?>">WordPress > Settings > Reading</a></code> page.</li> |
|
425 | + <li>Go to the <code><a href="<?= admin_url( 'options-reading.php' ); ?>">WordPress > Settings > Reading</a></code> page.</li> |
|
426 | 426 | <li>Make sure that the Robots.txt starts with: <code>User-Agent: *</code></li> |
427 | 427 | <li>Add the following lines: |
428 | 428 | <pre><code>Disallow: /*?reviews-page=* |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | <div class="glsr-card-header"> |
444 | 444 | <h3>How do I redirect to a custom URL after a form is submitted?</h3> |
445 | 445 | <button type="button" class="handlediv" aria-expanded="true"> |
446 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
446 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
447 | 447 | <span class="toggle-indicator" aria-hidden="true"></span> |
448 | 448 | </button> |
449 | 449 | </div> |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | <div class="glsr-card-header"> |
457 | 457 | <h3>How do I remove the dash in front of the author's name?</h3> |
458 | 458 | <button type="button" class="handlediv" aria-expanded="true"> |
459 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
459 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
460 | 460 | <span class="toggle-indicator" aria-hidden="true"></span> |
461 | 461 | </button> |
462 | 462 | </div> |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | <div class="glsr-card-header"> |
473 | 473 | <h3>How do I use the plugin templates in my theme?</h3> |
474 | 474 | <button type="button" class="handlediv" aria-expanded="true"> |
475 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
475 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
476 | 476 | <span class="toggle-indicator" aria-hidden="true"></span> |
477 | 477 | </button> |
478 | 478 | </div> |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | <div class="glsr-card-header"> |
491 | 491 | <h3>Why are the IP Addresses being detected as 127.0.0.1?</h3> |
492 | 492 | <button type="button" class="handlediv" aria-expanded="true"> |
493 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
493 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
494 | 494 | <span class="toggle-indicator" aria-hidden="true"></span> |
495 | 495 | </button> |
496 | 496 | </div> |
@@ -33,15 +33,15 @@ discard block |
||
33 | 33 | * @param string $type |
34 | 34 | * @return string |
35 | 35 | */ |
36 | - public function build($atts, array $args = [], $type = 'shortcode') |
|
36 | + public function build( $atts, array $args = [], $type = 'shortcode' ) |
|
37 | 37 | { |
38 | - $args = $this->normalizeArgs($args, $type); |
|
39 | - $atts = $this->normalizeAtts($atts, $type); |
|
40 | - $partial = glsr(Partial::class)->build($this->partialName, $atts); |
|
38 | + $args = $this->normalizeArgs( $args, $type ); |
|
39 | + $atts = $this->normalizeAtts( $atts, $type ); |
|
40 | + $partial = glsr( Partial::class )->build( $this->partialName, $atts ); |
|
41 | 41 | $title = !empty($atts['title']) |
42 | 42 | ? $args['before_title'].$atts['title'].$args['after_title'] |
43 | 43 | : ''; |
44 | - $debug = sprintf('<glsr-%1$s hidden data-atts=\'%2$s\'></glsr-%1$s>', $type, $atts['json']); |
|
44 | + $debug = sprintf( '<glsr-%1$s hidden data-atts=\'%2$s\'></glsr-%1$s>', $type, $atts['json'] ); |
|
45 | 45 | return $args['before_widget'].$title.$partial.$debug.$args['after_widget']; |
46 | 46 | } |
47 | 47 | |
@@ -49,17 +49,17 @@ discard block |
||
49 | 49 | * @param string|array $atts |
50 | 50 | * @return string |
51 | 51 | */ |
52 | - public function buildShortcode($atts = []) |
|
52 | + public function buildShortcode( $atts = [] ) |
|
53 | 53 | { |
54 | - return $this->build($atts); |
|
54 | + return $this->build( $atts ); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * @return array |
59 | 59 | */ |
60 | - public function getDefaults($atts) |
|
60 | + public function getDefaults( $atts ) |
|
61 | 61 | { |
62 | - return glsr($this->getShortcodeDefaultsClassName())->restrict(wp_parse_args($atts)); |
|
62 | + return glsr( $this->getShortcodeDefaultsClassName() )->restrict( wp_parse_args( $atts ) ); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -68,15 +68,15 @@ discard block |
||
68 | 68 | public function getHideOptions() |
69 | 69 | { |
70 | 70 | $options = $this->hideOptions(); |
71 | - return apply_filters('site-reviews/shortcode/hide-options', $options, $this->shortcodeName); |
|
71 | + return apply_filters( 'site-reviews/shortcode/hide-options', $options, $this->shortcodeName ); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
75 | 75 | * @return string |
76 | 76 | */ |
77 | - public function getShortcodeClassName($replace = '', $search = 'Shortcode') |
|
77 | + public function getShortcodeClassName( $replace = '', $search = 'Shortcode' ) |
|
78 | 78 | { |
79 | - return str_replace($search, $replace, (new ReflectionClass($this))->getShortName()); |
|
79 | + return str_replace( $search, $replace, (new ReflectionClass( $this ))->getShortName() ); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | public function getShortcodeDefaultsClassName() |
86 | 86 | { |
87 | 87 | return Helper::buildClassName( |
88 | - $this->getShortcodeClassName('Defaults'), |
|
88 | + $this->getShortcodeClassName( 'Defaults' ), |
|
89 | 89 | 'Defaults' |
90 | 90 | ); |
91 | 91 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function getShortcodeName() |
97 | 97 | { |
98 | - return Str::snakeCase($this->getShortcodeClassName()); |
|
98 | + return Str::snakeCase( $this->getShortcodeClassName() ); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function getShortcodePartialName() |
105 | 105 | { |
106 | - return Str::dashCase($this->getShortcodeClassName()); |
|
106 | + return Str::dashCase( $this->getShortcodeClassName() ); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -111,15 +111,15 @@ discard block |
||
111 | 111 | * @param string $type |
112 | 112 | * @return array |
113 | 113 | */ |
114 | - public function normalizeArgs($args, $type = 'shortcode') |
|
114 | + public function normalizeArgs( $args, $type = 'shortcode' ) |
|
115 | 115 | { |
116 | - $args = wp_parse_args($args, [ |
|
116 | + $args = wp_parse_args( $args, [ |
|
117 | 117 | 'before_widget' => '<div class="glsr-'.$type.' '.$type.'-'.$this->partialName.'">', |
118 | 118 | 'after_widget' => '</div>', |
119 | 119 | 'before_title' => '<h3 class="glsr-'.$type.'-title">', |
120 | 120 | 'after_title' => '</h3>', |
121 | - ]); |
|
122 | - return apply_filters('site-reviews/shortcode/args', $args, $type, $this->partialName); |
|
121 | + ] ); |
|
122 | + return apply_filters( 'site-reviews/shortcode/args', $args, $type, $this->partialName ); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -127,18 +127,18 @@ discard block |
||
127 | 127 | * @param string $type |
128 | 128 | * @return array |
129 | 129 | */ |
130 | - public function normalizeAtts($atts, $type = 'shortcode') |
|
130 | + public function normalizeAtts( $atts, $type = 'shortcode' ) |
|
131 | 131 | { |
132 | - $atts = apply_filters('site-reviews/shortcode/atts', $atts, $type, $this->partialName); |
|
133 | - $atts = $this->getDefaults($atts); |
|
134 | - array_walk($atts, function (&$value, $key) { |
|
135 | - $methodName = Helper::buildMethodName($key, 'normalize'); |
|
136 | - if (!method_exists($this, $methodName)) { |
|
132 | + $atts = apply_filters( 'site-reviews/shortcode/atts', $atts, $type, $this->partialName ); |
|
133 | + $atts = $this->getDefaults( $atts ); |
|
134 | + array_walk( $atts, function( &$value, $key ) { |
|
135 | + $methodName = Helper::buildMethodName( $key, 'normalize' ); |
|
136 | + if( !method_exists( $this, $methodName ) ) { |
|
137 | 137 | return; |
138 | 138 | } |
139 | - $value = $this->$methodName($value); |
|
139 | + $value = $this->$methodName( $value ); |
|
140 | 140 | }); |
141 | - $this->setId($atts); |
|
141 | + $this->setId( $atts ); |
|
142 | 142 | return $atts; |
143 | 143 | } |
144 | 144 | |
@@ -151,12 +151,12 @@ discard block |
||
151 | 151 | * @param string $postId |
152 | 152 | * @return int|string |
153 | 153 | */ |
154 | - protected function normalizeAssignedTo($postId) |
|
154 | + protected function normalizeAssignedTo( $postId ) |
|
155 | 155 | { |
156 | - if ('parent_id' == $postId) { |
|
157 | - $postId = intval(wp_get_post_parent_id(intval(get_the_ID()))); |
|
158 | - } elseif ('post_id' == $postId) { |
|
159 | - $postId = intval(get_the_ID()); |
|
156 | + if( 'parent_id' == $postId ) { |
|
157 | + $postId = intval( wp_get_post_parent_id( intval( get_the_ID() ) ) ); |
|
158 | + } elseif( 'post_id' == $postId ) { |
|
159 | + $postId = intval( get_the_ID() ); |
|
160 | 160 | } |
161 | 161 | return $postId; |
162 | 162 | } |
@@ -165,23 +165,23 @@ discard block |
||
165 | 165 | * @param string $postId |
166 | 166 | * @return int|string |
167 | 167 | */ |
168 | - protected function normalizeAssignTo($postId) |
|
168 | + protected function normalizeAssignTo( $postId ) |
|
169 | 169 | { |
170 | - return $this->normalizeAssignedTo($postId); |
|
170 | + return $this->normalizeAssignedTo( $postId ); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
174 | 174 | * @param string|array $hide |
175 | 175 | * @return array |
176 | 176 | */ |
177 | - protected function normalizeHide($hide) |
|
177 | + protected function normalizeHide( $hide ) |
|
178 | 178 | { |
179 | - if (is_string($hide)) { |
|
180 | - $hide = explode(',', $hide); |
|
179 | + if( is_string( $hide ) ) { |
|
180 | + $hide = explode( ',', $hide ); |
|
181 | 181 | } |
182 | - $hideKeys = array_keys($this->getHideOptions()); |
|
183 | - return array_filter(array_map('trim', $hide), function ($value) use ($hideKeys) { |
|
184 | - return in_array($value, $hideKeys); |
|
182 | + $hideKeys = array_keys( $this->getHideOptions() ); |
|
183 | + return array_filter( array_map( 'trim', $hide ), function( $value ) use ($hideKeys) { |
|
184 | + return in_array( $value, $hideKeys ); |
|
185 | 185 | }); |
186 | 186 | } |
187 | 187 | |
@@ -189,61 +189,61 @@ discard block |
||
189 | 189 | * @param string $id |
190 | 190 | * @return string |
191 | 191 | */ |
192 | - protected function normalizeId($id) |
|
192 | + protected function normalizeId( $id ) |
|
193 | 193 | { |
194 | - return sanitize_title($id); |
|
194 | + return sanitize_title( $id ); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
198 | 198 | * @param string $labels |
199 | 199 | * @return array |
200 | 200 | */ |
201 | - protected function normalizeLabels($labels) |
|
201 | + protected function normalizeLabels( $labels ) |
|
202 | 202 | { |
203 | 203 | $defaults = [ |
204 | - __('Excellent', 'site-reviews'), |
|
205 | - __('Very good', 'site-reviews'), |
|
206 | - __('Average', 'site-reviews'), |
|
207 | - __('Poor', 'site-reviews'), |
|
208 | - __('Terrible', 'site-reviews'), |
|
204 | + __( 'Excellent', 'site-reviews' ), |
|
205 | + __( 'Very good', 'site-reviews' ), |
|
206 | + __( 'Average', 'site-reviews' ), |
|
207 | + __( 'Poor', 'site-reviews' ), |
|
208 | + __( 'Terrible', 'site-reviews' ), |
|
209 | 209 | ]; |
210 | - $maxRating = (int) glsr()->constant('MAX_RATING', Rating::class); |
|
211 | - $defaults = array_pad(array_slice($defaults, 0, $maxRating), $maxRating, ''); |
|
212 | - $labels = array_map('trim', explode(',', $labels)); |
|
213 | - foreach ($defaults as $i => $label) { |
|
214 | - if (empty($labels[$i])) { |
|
210 | + $maxRating = (int)glsr()->constant( 'MAX_RATING', Rating::class ); |
|
211 | + $defaults = array_pad( array_slice( $defaults, 0, $maxRating ), $maxRating, '' ); |
|
212 | + $labels = array_map( 'trim', explode( ',', $labels ) ); |
|
213 | + foreach( $defaults as $i => $label ) { |
|
214 | + if( empty($labels[$i]) ) { |
|
215 | 215 | continue; |
216 | 216 | } |
217 | 217 | $defaults[$i] = $labels[$i]; |
218 | 218 | } |
219 | - return array_combine(range($maxRating, 1), $defaults); |
|
219 | + return array_combine( range( $maxRating, 1 ), $defaults ); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
223 | 223 | * @param string $schema |
224 | 224 | * @return bool |
225 | 225 | */ |
226 | - protected function normalizeSchema($schema) |
|
226 | + protected function normalizeSchema( $schema ) |
|
227 | 227 | { |
228 | - return wp_validate_boolean($schema); |
|
228 | + return wp_validate_boolean( $schema ); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
232 | 232 | * @param string $text |
233 | 233 | * @return string |
234 | 234 | */ |
235 | - protected function normalizeText($text) |
|
235 | + protected function normalizeText( $text ) |
|
236 | 236 | { |
237 | - return trim($text); |
|
237 | + return trim( $text ); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
241 | 241 | * @return void |
242 | 242 | */ |
243 | - protected function setId(array &$atts) |
|
243 | + protected function setId( array &$atts ) |
|
244 | 244 | { |
245 | - if (empty($atts['id'])) { |
|
246 | - $atts['id'] = Application::PREFIX.substr(md5(serialize($atts)), 0, 8); |
|
245 | + if( empty($atts['id']) ) { |
|
246 | + $atts['id'] = Application::PREFIX.substr( md5( serialize( $atts ) ), 0, 8 ); |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | } |
@@ -28,16 +28,16 @@ discard block |
||
28 | 28 | /** |
29 | 29 | * @return void|string |
30 | 30 | */ |
31 | - public function build(array $args = []) |
|
31 | + public function build( array $args = [] ) |
|
32 | 32 | { |
33 | 33 | $this->args = $args; |
34 | - $this->ratingCounts = glsr(ReviewManager::class)->getRatingCounts($args); |
|
35 | - if (!array_sum($this->ratingCounts) && $this->isHidden('if_empty')) { |
|
34 | + $this->ratingCounts = glsr( ReviewManager::class )->getRatingCounts( $args ); |
|
35 | + if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ) ) { |
|
36 | 36 | return; |
37 | 37 | } |
38 | - $this->averageRating = glsr(Rating::class)->getAverage($this->ratingCounts); |
|
38 | + $this->averageRating = glsr( Rating::class )->getAverage( $this->ratingCounts ); |
|
39 | 39 | $this->generateSchema(); |
40 | - return glsr(Template::class)->build('templates/reviews-summary', [ |
|
40 | + return glsr( Template::class )->build( 'templates/reviews-summary', [ |
|
41 | 41 | 'context' => [ |
42 | 42 | 'assigned_to' => $this->args['assigned_to'], |
43 | 43 | 'category' => $this->args['category'], |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | 'stars' => $this->buildStars(), |
49 | 49 | 'text' => $this->buildText(), |
50 | 50 | ], |
51 | - ]); |
|
51 | + ] ); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -56,40 +56,40 @@ discard block |
||
56 | 56 | */ |
57 | 57 | protected function buildPercentage() |
58 | 58 | { |
59 | - if ($this->isHidden('bars')) { |
|
59 | + if( $this->isHidden( 'bars' ) ) { |
|
60 | 60 | return; |
61 | 61 | } |
62 | - $percentages = preg_filter('/$/', '%', glsr(Rating::class)->getPercentages($this->ratingCounts)); |
|
63 | - $bars = array_reduce(range(glsr()->constant('MAX_RATING', Rating::class), 1), function ($carry, $level) use ($percentages) { |
|
64 | - $label = $this->buildPercentageLabel($this->args['labels'][$level]); |
|
65 | - $background = $this->buildPercentageBackground($percentages[$level]); |
|
66 | - $count = apply_filters('site-reviews/summary/counts', |
|
62 | + $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts ) ); |
|
63 | + $bars = array_reduce( range( glsr()->constant( 'MAX_RATING', Rating::class ), 1 ), function( $carry, $level ) use ($percentages) { |
|
64 | + $label = $this->buildPercentageLabel( $this->args['labels'][$level] ); |
|
65 | + $background = $this->buildPercentageBackground( $percentages[$level] ); |
|
66 | + $count = apply_filters( 'site-reviews/summary/counts', |
|
67 | 67 | $percentages[$level], |
68 | 68 | $this->ratingCounts[$level] |
69 | 69 | ); |
70 | - $percent = $this->buildPercentageCount($count); |
|
70 | + $percent = $this->buildPercentageCount( $count ); |
|
71 | 71 | $value = $label.$background.$percent; |
72 | - $value = apply_filters('site-reviews/summary/wrap/bar', $value, $this->args, [ |
|
73 | - 'percent' => wp_strip_all_tags($count, true), |
|
72 | + $value = apply_filters( 'site-reviews/summary/wrap/bar', $value, $this->args, [ |
|
73 | + 'percent' => wp_strip_all_tags( $count, true ), |
|
74 | 74 | 'rating' => $level, |
75 | - ]); |
|
76 | - return $carry.glsr(Builder::class)->div($value, [ |
|
75 | + ] ); |
|
76 | + return $carry.glsr( Builder::class )->div( $value, [ |
|
77 | 77 | 'class' => 'glsr-bar', |
78 | - ]); |
|
78 | + ] ); |
|
79 | 79 | }); |
80 | - return $this->wrap('percentage', $bars); |
|
80 | + return $this->wrap( 'percentage', $bars ); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
84 | 84 | * @param string $percent |
85 | 85 | * @return string |
86 | 86 | */ |
87 | - protected function buildPercentageBackground($percent) |
|
87 | + protected function buildPercentageBackground( $percent ) |
|
88 | 88 | { |
89 | - $backgroundPercent = glsr(Builder::class)->span([ |
|
89 | + $backgroundPercent = glsr( Builder::class )->span( [ |
|
90 | 90 | 'class' => 'glsr-bar-background-percent', |
91 | 91 | 'style' => 'width:'.$percent, |
92 | - ]); |
|
92 | + ] ); |
|
93 | 93 | return '<span class="glsr-bar-background">'.$backgroundPercent.'</span>'; |
94 | 94 | } |
95 | 95 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @param string $count |
98 | 98 | * @return string |
99 | 99 | */ |
100 | - protected function buildPercentageCount($count) |
|
100 | + protected function buildPercentageCount( $count ) |
|
101 | 101 | { |
102 | 102 | return '<span class="glsr-bar-percent">'.$count.'</span>'; |
103 | 103 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @param string $label |
107 | 107 | * @return string |
108 | 108 | */ |
109 | - protected function buildPercentageLabel($label) |
|
109 | + protected function buildPercentageLabel( $label ) |
|
110 | 110 | { |
111 | 111 | return '<span class="glsr-bar-label">'.$label.'</span>'; |
112 | 112 | } |
@@ -116,10 +116,10 @@ discard block |
||
116 | 116 | */ |
117 | 117 | protected function buildRating() |
118 | 118 | { |
119 | - if ($this->isHidden('rating')) { |
|
119 | + if( $this->isHidden( 'rating' ) ) { |
|
120 | 120 | return; |
121 | 121 | } |
122 | - return $this->wrap('rating', '<span>'.$this->averageRating.'</span>'); |
|
122 | + return $this->wrap( 'rating', '<span>'.$this->averageRating.'</span>' ); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -127,11 +127,11 @@ discard block |
||
127 | 127 | */ |
128 | 128 | protected function buildStars() |
129 | 129 | { |
130 | - if ($this->isHidden('stars')) { |
|
130 | + if( $this->isHidden( 'stars' ) ) { |
|
131 | 131 | return; |
132 | 132 | } |
133 | - $stars = glsr_star_rating($this->averageRating); |
|
134 | - return $this->wrap('stars', $stars); |
|
133 | + $stars = glsr_star_rating( $this->averageRating ); |
|
134 | + return $this->wrap( 'stars', $stars ); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | */ |
140 | 140 | protected function buildText() |
141 | 141 | { |
142 | - if ($this->isHidden('summary')) { |
|
142 | + if( $this->isHidden( 'summary' ) ) { |
|
143 | 143 | return; |
144 | 144 | } |
145 | - $count = intval(array_sum($this->ratingCounts)); |
|
146 | - if (empty($this->args['text'])) { |
|
145 | + $count = intval( array_sum( $this->ratingCounts ) ); |
|
146 | + if( empty($this->args['text']) ) { |
|
147 | 147 | // @todo document this change |
148 | 148 | $this->args['text'] = _nx( |
149 | 149 | '{rating} out of {max} stars (based on {num} review)', |
@@ -155,10 +155,10 @@ discard block |
||
155 | 155 | } |
156 | 156 | $summary = str_replace( |
157 | 157 | ['{rating}', '{max}', '{num}'], |
158 | - [$this->averageRating, glsr()->constant('MAX_RATING', Rating::class), $count], |
|
158 | + [$this->averageRating, glsr()->constant( 'MAX_RATING', Rating::class ), $count], |
|
159 | 159 | $this->args['text'] |
160 | 160 | ); |
161 | - return $this->wrap('text', '<span>'.$summary.'</span>'); |
|
161 | + return $this->wrap( 'text', '<span>'.$summary.'</span>' ); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -166,11 +166,11 @@ discard block |
||
166 | 166 | */ |
167 | 167 | protected function generateSchema() |
168 | 168 | { |
169 | - if (!wp_validate_boolean($this->args['schema'])) { |
|
169 | + if( !wp_validate_boolean( $this->args['schema'] ) ) { |
|
170 | 170 | return; |
171 | 171 | } |
172 | - glsr(Schema::class)->store( |
|
173 | - glsr(Schema::class)->buildSummary($this->args) |
|
172 | + glsr( Schema::class )->store( |
|
173 | + glsr( Schema::class )->buildSummary( $this->args ) |
|
174 | 174 | ); |
175 | 175 | } |
176 | 176 | |
@@ -179,16 +179,16 @@ discard block |
||
179 | 179 | */ |
180 | 180 | protected function getClass() |
181 | 181 | { |
182 | - return trim('glsr-summary glsr-default '.$this->args['class']); |
|
182 | + return trim( 'glsr-summary glsr-default '.$this->args['class'] ); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
186 | 186 | * @param string $key |
187 | 187 | * @return bool |
188 | 188 | */ |
189 | - protected function isHidden($key) |
|
189 | + protected function isHidden( $key ) |
|
190 | 190 | { |
191 | - return in_array($key, $this->args['hide']); |
|
191 | + return in_array( $key, $this->args['hide'] ); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -196,11 +196,11 @@ discard block |
||
196 | 196 | * @param string $value |
197 | 197 | * @return string |
198 | 198 | */ |
199 | - protected function wrap($key, $value) |
|
199 | + protected function wrap( $key, $value ) |
|
200 | 200 | { |
201 | - $value = apply_filters('site-reviews/summary/wrap/'.$key, $value, $this->args); |
|
202 | - return glsr(Builder::class)->div($value, [ |
|
201 | + $value = apply_filters( 'site-reviews/summary/wrap/'.$key, $value, $this->args ); |
|
202 | + return glsr( Builder::class )->div( $value, [ |
|
203 | 203 | 'class' => 'glsr-summary-'.$key, |
204 | - ]); |
|
204 | + ] ); |
|
205 | 205 | } |
206 | 206 | } |
@@ -7,10 +7,10 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * @return bool |
9 | 9 | */ |
10 | - public static function compareArrays(array $arr1, array $arr2) |
|
10 | + public static function compareArrays( array $arr1, array $arr2 ) |
|
11 | 11 | { |
12 | - sort($arr1); |
|
13 | - sort($arr2); |
|
12 | + sort( $arr1 ); |
|
13 | + sort( $arr2 ); |
|
14 | 14 | return $arr1 == $arr2; |
15 | 15 | } |
16 | 16 | |
@@ -18,21 +18,21 @@ discard block |
||
18 | 18 | * @param mixed $array |
19 | 19 | * @return array |
20 | 20 | */ |
21 | - public static function consolidateArray($array) |
|
21 | + public static function consolidateArray( $array ) |
|
22 | 22 | { |
23 | - return is_array($array) || is_object($array) |
|
24 | - ? (array) $array |
|
23 | + return is_array( $array ) || is_object( $array ) |
|
24 | + ? (array)$array |
|
25 | 25 | : []; |
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
29 | 29 | * @return array |
30 | 30 | */ |
31 | - public static function convertDotNotationArray(array $array) |
|
31 | + public static function convertDotNotationArray( array $array ) |
|
32 | 32 | { |
33 | 33 | $results = []; |
34 | - foreach ($array as $path => $value) { |
|
35 | - $results = static::set($results, $path, $value); |
|
34 | + foreach( $array as $path => $value ) { |
|
35 | + $results = static::set( $results, $path, $value ); |
|
36 | 36 | } |
37 | 37 | return $results; |
38 | 38 | } |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | * @param mixed $callback |
43 | 43 | * @return array |
44 | 44 | */ |
45 | - public static function convertStringToArray($string, $callback = null) |
|
45 | + public static function convertStringToArray( $string, $callback = null ) |
|
46 | 46 | { |
47 | - $array = array_map('trim', explode(',', $string)); |
|
47 | + $array = array_map( 'trim', explode( ',', $string ) ); |
|
48 | 48 | return $callback |
49 | - ? array_filter($array, $callback) |
|
50 | - : array_filter($array); |
|
49 | + ? array_filter( $array, $callback ) |
|
50 | + : array_filter( $array ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -55,17 +55,17 @@ discard block |
||
55 | 55 | * @param string $prefix |
56 | 56 | * @return array |
57 | 57 | */ |
58 | - public static function flattenArray(array $array, $flattenValue = false, $prefix = '') |
|
58 | + public static function flattenArray( array $array, $flattenValue = false, $prefix = '' ) |
|
59 | 59 | { |
60 | 60 | $result = []; |
61 | - foreach ($array as $key => $value) { |
|
62 | - $newKey = ltrim($prefix.'.'.$key, '.'); |
|
63 | - if (static::isIndexedFlatArray($value)) { |
|
64 | - if ($flattenValue) { |
|
65 | - $value = '['.implode(', ', $value).']'; |
|
61 | + foreach( $array as $key => $value ) { |
|
62 | + $newKey = ltrim( $prefix.'.'.$key, '.' ); |
|
63 | + if( static::isIndexedFlatArray( $value ) ) { |
|
64 | + if( $flattenValue ) { |
|
65 | + $value = '['.implode( ', ', $value ).']'; |
|
66 | 66 | } |
67 | - } elseif (is_array($value)) { |
|
68 | - $result = array_merge($result, static::flattenArray($value, $flattenValue, $newKey)); |
|
67 | + } elseif( is_array( $value ) ) { |
|
68 | + $result = array_merge( $result, static::flattenArray( $value, $flattenValue, $newKey ) ); |
|
69 | 69 | continue; |
70 | 70 | } |
71 | 71 | $result[$newKey] = $value; |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | * @param mixed $fallback |
81 | 81 | * @return mixed |
82 | 82 | */ |
83 | - public static function get($data, $path = '', $fallback = '') |
|
83 | + public static function get( $data, $path = '', $fallback = '' ) |
|
84 | 84 | { |
85 | - $data = static::consolidateArray($data); |
|
86 | - $keys = explode('.', $path); |
|
87 | - foreach ($keys as $key) { |
|
88 | - if (!isset($data[$key])) { |
|
85 | + $data = static::consolidateArray( $data ); |
|
86 | + $keys = explode( '.', $path ); |
|
87 | + foreach( $keys as $key ) { |
|
88 | + if( !isset($data[$key]) ) { |
|
89 | 89 | return $fallback; |
90 | 90 | } |
91 | 91 | $data = $data[$key]; |
@@ -97,18 +97,18 @@ discard block |
||
97 | 97 | * @param string $key |
98 | 98 | * @return array |
99 | 99 | */ |
100 | - public static function insertAfter($key, array $array, array $insert) |
|
100 | + public static function insertAfter( $key, array $array, array $insert ) |
|
101 | 101 | { |
102 | - return static::insertInArray($array, $insert, $key, 'after'); |
|
102 | + return static::insertInArray( $array, $insert, $key, 'after' ); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
106 | 106 | * @param string $key |
107 | 107 | * @return array |
108 | 108 | */ |
109 | - public static function insertBefore($key, array $array, array $insert) |
|
109 | + public static function insertBefore( $key, array $array, array $insert ) |
|
110 | 110 | { |
111 | - return static::insertInArray($array, $insert, $key, 'before'); |
|
111 | + return static::insertInArray( $array, $insert, $key, 'before' ); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -116,47 +116,47 @@ discard block |
||
116 | 116 | * @param string $position |
117 | 117 | * @return array |
118 | 118 | */ |
119 | - public static function insertInArray(array $array, array $insert, $key, $position = 'before') |
|
119 | + public static function insertInArray( array $array, array $insert, $key, $position = 'before' ) |
|
120 | 120 | { |
121 | - $keyPosition = intval(array_search($key, array_keys($array))); |
|
122 | - if ('after' == $position) { |
|
121 | + $keyPosition = intval( array_search( $key, array_keys( $array ) ) ); |
|
122 | + if( 'after' == $position ) { |
|
123 | 123 | ++$keyPosition; |
124 | 124 | } |
125 | - if (false !== $keyPosition) { |
|
126 | - $result = array_slice($array, 0, $keyPosition); |
|
127 | - $result = array_merge($result, $insert); |
|
128 | - return array_merge($result, array_slice($array, $keyPosition)); |
|
125 | + if( false !== $keyPosition ) { |
|
126 | + $result = array_slice( $array, 0, $keyPosition ); |
|
127 | + $result = array_merge( $result, $insert ); |
|
128 | + return array_merge( $result, array_slice( $array, $keyPosition ) ); |
|
129 | 129 | } |
130 | - return array_merge($array, $insert); |
|
130 | + return array_merge( $array, $insert ); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
134 | 134 | * @param mixed $array |
135 | 135 | * @return bool |
136 | 136 | */ |
137 | - public static function isIndexedFlatArray($array) |
|
137 | + public static function isIndexedFlatArray( $array ) |
|
138 | 138 | { |
139 | - if (!is_array($array) || array_filter($array, 'is_array')) { |
|
139 | + if( !is_array( $array ) || array_filter( $array, 'is_array' ) ) { |
|
140 | 140 | return false; |
141 | 141 | } |
142 | - return wp_is_numeric_array($array); |
|
142 | + return wp_is_numeric_array( $array ); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
146 | 146 | * @param bool $prefixed |
147 | 147 | * @return array |
148 | 148 | */ |
149 | - public static function prefixArrayKeys(array $values, $prefixed = true) |
|
149 | + public static function prefixArrayKeys( array $values, $prefixed = true ) |
|
150 | 150 | { |
151 | 151 | $trim = '_'; |
152 | 152 | $prefix = $prefixed |
153 | 153 | ? $trim |
154 | 154 | : ''; |
155 | 155 | $prefixed = []; |
156 | - foreach ($values as $key => $value) { |
|
157 | - $key = trim($key); |
|
158 | - if (0 === strpos($key, $trim)) { |
|
159 | - $key = substr($key, strlen($trim)); |
|
156 | + foreach( $values as $key => $value ) { |
|
157 | + $key = trim( $key ); |
|
158 | + if( 0 === strpos( $key, $trim ) ) { |
|
159 | + $key = substr( $key, strlen( $trim ) ); |
|
160 | 160 | } |
161 | 161 | $prefixed[$prefix.$key] = $value; |
162 | 162 | } |
@@ -166,15 +166,15 @@ discard block |
||
166 | 166 | /** |
167 | 167 | * @return array |
168 | 168 | */ |
169 | - public static function removeEmptyArrayValues(array $array) |
|
169 | + public static function removeEmptyArrayValues( array $array ) |
|
170 | 170 | { |
171 | 171 | $result = []; |
172 | - foreach ($array as $key => $value) { |
|
173 | - if (!$value) { |
|
172 | + foreach( $array as $key => $value ) { |
|
173 | + if( !$value ) { |
|
174 | 174 | continue; |
175 | 175 | } |
176 | - $result[$key] = is_array($value) |
|
177 | - ? static::removeEmptyArrayValues($value) |
|
176 | + $result[$key] = is_array( $value ) |
|
177 | + ? static::removeEmptyArrayValues( $value ) |
|
178 | 178 | : $value; |
179 | 179 | } |
180 | 180 | return $result; |
@@ -187,14 +187,14 @@ discard block |
||
187 | 187 | * @param mixed $value |
188 | 188 | * @return array |
189 | 189 | */ |
190 | - public static function set(array $data, $path, $value) |
|
190 | + public static function set( array $data, $path, $value ) |
|
191 | 191 | { |
192 | - $token = strtok($path, '.'); |
|
192 | + $token = strtok( $path, '.' ); |
|
193 | 193 | $ref = &$data; |
194 | - while (false !== $token) { |
|
195 | - $ref = static::consolidateArray($ref); |
|
194 | + while( false !== $token ) { |
|
195 | + $ref = static::consolidateArray( $ref ); |
|
196 | 196 | $ref = &$ref[$token]; |
197 | - $token = strtok('.'); |
|
197 | + $token = strtok( '.' ); |
|
198 | 198 | } |
199 | 199 | $ref = $value; |
200 | 200 | return $data; |
@@ -203,16 +203,16 @@ discard block |
||
203 | 203 | /** |
204 | 204 | * @return array |
205 | 205 | */ |
206 | - public static function unique(array $values) |
|
206 | + public static function unique( array $values ) |
|
207 | 207 | { |
208 | - return array_filter(array_unique($values)); |
|
208 | + return array_filter( array_unique( $values ) ); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
212 | 212 | * @return array |
213 | 213 | */ |
214 | - public static function unprefixArrayKeys(array $values) |
|
214 | + public static function unprefixArrayKeys( array $values ) |
|
215 | 215 | { |
216 | - return static::prefixArrayKeys($values, false); |
|
216 | + return static::prefixArrayKeys( $values, false ); |
|
217 | 217 | } |
218 | 218 | } |