@@ -1,4 +1,4 @@ |
||
1 | 1 | <div class="notice notice-info is-dismissible glsr-notice" data-dismiss="welcome"> |
2 | 2 | <p><?= $text; ?></p> |
3 | - <p><a class="button button-small" href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=welcome#tab-whatsnew'); ?>">See what's new</a></p> |
|
3 | + <p><a class="button button-small" href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=welcome#tab-whatsnew' ); ?>">See what's new</a></p> |
|
4 | 4 | </div> |
@@ -1,5 +1,5 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | -<strong><a href="<?= esc_url(admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-licenses')); ?>"> |
|
4 | - <?= __('Enter a valid license key for automatic updates.', 'site-reviews'); ?> |
|
3 | +<strong><a href="<?= esc_url( admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-licenses' ) ); ?>"> |
|
4 | + <?= __( 'Enter a valid license key for automatic updates.', 'site-reviews' ); ?> |
|
5 | 5 | </a></strong> |
@@ -8,66 +8,66 @@ |
||
8 | 8 | |
9 | 9 | class Migrate_4_5_0 |
10 | 10 | { |
11 | - /** |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function migrateOptions() |
|
15 | - { |
|
16 | - $isAccountVerified = glsr(OptionManager::class)->getWP('_glsr_rebusify', false); |
|
17 | - update_option('_glsr_trustalyze', $isAccountVerified); |
|
18 | - delete_option('_glsr_rebusify'); |
|
19 | - } |
|
11 | + /** |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function migrateOptions() |
|
15 | + { |
|
16 | + $isAccountVerified = glsr(OptionManager::class)->getWP('_glsr_rebusify', false); |
|
17 | + update_option('_glsr_trustalyze', $isAccountVerified); |
|
18 | + delete_option('_glsr_rebusify'); |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * @return void |
|
23 | - */ |
|
24 | - public function migrateSettings() |
|
25 | - { |
|
26 | - if ($settings = get_option(OptionManager::databaseKey(4))) { |
|
27 | - $settings = Arr::set($settings, 'settings.general.trustalyze', |
|
28 | - Arr::get($settings, 'settings.general.rebusify') |
|
29 | - ); |
|
30 | - $settings = Arr::set($settings, 'settings.general.trustalyze_email', |
|
31 | - Arr::get($settings, 'settings.general.rebusify_email') |
|
32 | - ); |
|
33 | - $settings = Arr::set($settings, 'settings.general.trustalyze_serial', |
|
34 | - Arr::get($settings, 'settings.general.rebusify_serial') |
|
35 | - ); |
|
36 | - unset($settings['settings']['general']['rebusify']); |
|
37 | - unset($settings['settings']['general']['rebusify_email']); |
|
38 | - unset($settings['settings']['general']['rebusify_serial']); |
|
39 | - update_option(OptionManager::databaseKey(4), $settings); |
|
40 | - } |
|
41 | - } |
|
21 | + /** |
|
22 | + * @return void |
|
23 | + */ |
|
24 | + public function migrateSettings() |
|
25 | + { |
|
26 | + if ($settings = get_option(OptionManager::databaseKey(4))) { |
|
27 | + $settings = Arr::set($settings, 'settings.general.trustalyze', |
|
28 | + Arr::get($settings, 'settings.general.rebusify') |
|
29 | + ); |
|
30 | + $settings = Arr::set($settings, 'settings.general.trustalyze_email', |
|
31 | + Arr::get($settings, 'settings.general.rebusify_email') |
|
32 | + ); |
|
33 | + $settings = Arr::set($settings, 'settings.general.trustalyze_serial', |
|
34 | + Arr::get($settings, 'settings.general.rebusify_serial') |
|
35 | + ); |
|
36 | + unset($settings['settings']['general']['rebusify']); |
|
37 | + unset($settings['settings']['general']['rebusify_email']); |
|
38 | + unset($settings['settings']['general']['rebusify_serial']); |
|
39 | + update_option(OptionManager::databaseKey(4), $settings); |
|
40 | + } |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return void |
|
45 | - */ |
|
46 | - public function migrateUserMeta() |
|
47 | - { |
|
48 | - $metaKey = NoticeController::USER_META_KEY; |
|
49 | - $userIds = get_users([ |
|
50 | - 'fields' => 'ID', |
|
51 | - 'meta_compare' => 'EXISTS', |
|
52 | - 'meta_key' => $metaKey, |
|
53 | - ]); |
|
54 | - foreach ($userIds as $userId) { |
|
55 | - $meta = (array) get_user_meta($userId, $metaKey, true); |
|
56 | - if (array_key_exists('rebusify', $meta)) { |
|
57 | - $meta['trustalyze'] = $meta['rebusify']; |
|
58 | - unset($meta['rebusify']); |
|
59 | - update_user_meta($userId, $metaKey, $meta); |
|
60 | - } |
|
61 | - } |
|
62 | - } |
|
43 | + /** |
|
44 | + * @return void |
|
45 | + */ |
|
46 | + public function migrateUserMeta() |
|
47 | + { |
|
48 | + $metaKey = NoticeController::USER_META_KEY; |
|
49 | + $userIds = get_users([ |
|
50 | + 'fields' => 'ID', |
|
51 | + 'meta_compare' => 'EXISTS', |
|
52 | + 'meta_key' => $metaKey, |
|
53 | + ]); |
|
54 | + foreach ($userIds as $userId) { |
|
55 | + $meta = (array) get_user_meta($userId, $metaKey, true); |
|
56 | + if (array_key_exists('rebusify', $meta)) { |
|
57 | + $meta['trustalyze'] = $meta['rebusify']; |
|
58 | + unset($meta['rebusify']); |
|
59 | + update_user_meta($userId, $metaKey, $meta); |
|
60 | + } |
|
61 | + } |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @return void |
|
66 | - */ |
|
67 | - public function run() |
|
68 | - { |
|
69 | - $this->migrateOptions(); |
|
70 | - $this->migrateSettings(); |
|
71 | - $this->migrateUserMeta(); |
|
72 | - } |
|
64 | + /** |
|
65 | + * @return void |
|
66 | + */ |
|
67 | + public function run() |
|
68 | + { |
|
69 | + $this->migrateOptions(); |
|
70 | + $this->migrateSettings(); |
|
71 | + $this->migrateUserMeta(); |
|
72 | + } |
|
73 | 73 | } |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | */ |
14 | 14 | public function migrateOptions() |
15 | 15 | { |
16 | - $isAccountVerified = glsr(OptionManager::class)->getWP('_glsr_rebusify', false); |
|
17 | - update_option('_glsr_trustalyze', $isAccountVerified); |
|
18 | - delete_option('_glsr_rebusify'); |
|
16 | + $isAccountVerified = glsr( OptionManager::class )->getWP( '_glsr_rebusify', false ); |
|
17 | + update_option( '_glsr_trustalyze', $isAccountVerified ); |
|
18 | + delete_option( '_glsr_rebusify' ); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -23,20 +23,20 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function migrateSettings() |
25 | 25 | { |
26 | - if ($settings = get_option(OptionManager::databaseKey(4))) { |
|
27 | - $settings = Arr::set($settings, 'settings.general.trustalyze', |
|
28 | - Arr::get($settings, 'settings.general.rebusify') |
|
26 | + if( $settings = get_option( OptionManager::databaseKey( 4 ) ) ) { |
|
27 | + $settings = Arr::set( $settings, 'settings.general.trustalyze', |
|
28 | + Arr::get( $settings, 'settings.general.rebusify' ) |
|
29 | 29 | ); |
30 | - $settings = Arr::set($settings, 'settings.general.trustalyze_email', |
|
31 | - Arr::get($settings, 'settings.general.rebusify_email') |
|
30 | + $settings = Arr::set( $settings, 'settings.general.trustalyze_email', |
|
31 | + Arr::get( $settings, 'settings.general.rebusify_email' ) |
|
32 | 32 | ); |
33 | - $settings = Arr::set($settings, 'settings.general.trustalyze_serial', |
|
34 | - Arr::get($settings, 'settings.general.rebusify_serial') |
|
33 | + $settings = Arr::set( $settings, 'settings.general.trustalyze_serial', |
|
34 | + Arr::get( $settings, 'settings.general.rebusify_serial' ) |
|
35 | 35 | ); |
36 | 36 | unset($settings['settings']['general']['rebusify']); |
37 | 37 | unset($settings['settings']['general']['rebusify_email']); |
38 | 38 | unset($settings['settings']['general']['rebusify_serial']); |
39 | - update_option(OptionManager::databaseKey(4), $settings); |
|
39 | + update_option( OptionManager::databaseKey( 4 ), $settings ); |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
@@ -46,17 +46,17 @@ discard block |
||
46 | 46 | public function migrateUserMeta() |
47 | 47 | { |
48 | 48 | $metaKey = NoticeController::USER_META_KEY; |
49 | - $userIds = get_users([ |
|
49 | + $userIds = get_users( [ |
|
50 | 50 | 'fields' => 'ID', |
51 | 51 | 'meta_compare' => 'EXISTS', |
52 | 52 | 'meta_key' => $metaKey, |
53 | - ]); |
|
54 | - foreach ($userIds as $userId) { |
|
55 | - $meta = (array) get_user_meta($userId, $metaKey, true); |
|
56 | - if (array_key_exists('rebusify', $meta)) { |
|
53 | + ] ); |
|
54 | + foreach( $userIds as $userId ) { |
|
55 | + $meta = (array)get_user_meta( $userId, $metaKey, true ); |
|
56 | + if( array_key_exists( 'rebusify', $meta ) ) { |
|
57 | 57 | $meta['trustalyze'] = $meta['rebusify']; |
58 | 58 | unset($meta['rebusify']); |
59 | - update_user_meta($userId, $metaKey, $meta); |
|
59 | + update_user_meta( $userId, $metaKey, $meta ); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | } |
@@ -1,10 +1,10 @@ discard block |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div id="support-01" class="glsr-card postbox"> |
4 | 4 | <div class="glsr-card-header"> |
5 | 5 | <h3>Basic Troubleshooting Steps</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> |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | <div class="glsr-card-header"> |
33 | 33 | <h3>Common Problems and Solutions</h3> |
34 | 34 | <button type="button" class="handlediv" aria-expanded="true"> |
35 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
35 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
36 | 36 | <span class="toggle-indicator" aria-hidden="true"></span> |
37 | 37 | </button> |
38 | 38 | </div> |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | <li> |
42 | 42 | <p class="glsr-heading">Email notifications are not working</p> |
43 | 43 | <p>Site Reviews uses the standard WordPress mail functions to send email. However, this does not guarantee that emails will send successfully as it still depends on your WordPress settings and server configuration being correct.</p> |
44 | - <p>To make sure that emails are correctly sent, please verify that the email you have saved in the "Email Address" setting of the <code><a href="<?= admin_url('options-general.php'); ?>">WordPress General Settings</a></code> page uses the same domain as that of your website. For example, if your website is <code>https://reviews.com</code> then the "Email Address" setting should end with, <code>@reviews.com</code>. If the email address you have saved in the WordPress General Settings does not share the same domain as your website, you will likely experience issues sending email from your WordPress site.</p> |
|
44 | + <p>To make sure that emails are correctly sent, please verify that the email you have saved in the "Email Address" setting of the <code><a href="<?= admin_url( 'options-general.php' ); ?>">WordPress General Settings</a></code> page uses the same domain as that of your website. For example, if your website is <code>https://reviews.com</code> then the "Email Address" setting should end with, <code>@reviews.com</code>. If the email address you have saved in the WordPress General Settings does not share the same domain as your website, you will likely experience issues sending email from your WordPress site.</p> |
|
45 | 45 | <p>If your email notifications are not sending, I recommend that you install the <a href="https://wordpress.org/plugins/check-email/">Check Email</a> plugin to verify that your website is able to correctly send email. See also, <a href="https://www.butlerblog.com/2013/12/12/easy-smtp-email-wordpress-wp_mail/">Easy SMTP email settings for WordPress</a>.</p> |
46 | 46 | </li> |
47 | 47 | <li> |
48 | 48 | <p class="glsr-heading">I only want my reviews to show on the page they were published or assigned to but they are showing on every page.</p> |
49 | - <p>All reviews are unassigned by default. If you want to assign reviews to specific pages, you will need to use the “assign_to” and “assigned_to” shortcode options. Please see the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes'); ?>">Shortcodes</a></code> documentation page for more information.</p> |
|
49 | + <p>All reviews are unassigned by default. If you want to assign reviews to specific pages, you will need to use the “assign_to” and “assigned_to” shortcode options. Please see the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes' ); ?>">Shortcodes</a></code> documentation page for more information.</p> |
|
50 | 50 | </li> |
51 | 51 | <li> |
52 | 52 | <p class="glsr-heading">My submission form is not assigning reviews to the page even though I have set the option to do so.</p> |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | <div class="glsr-card-header"> |
69 | 69 | <h3>Contact Support</h3> |
70 | 70 | <button type="button" class="handlediv" aria-expanded="true"> |
71 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
71 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
72 | 72 | <span class="toggle-indicator" aria-hidden="true"></span> |
73 | 73 | </button> |
74 | 74 | </div> |
@@ -77,32 +77,32 @@ discard block |
||
77 | 77 | <p>However, you may also contact us directly (expect a slower response time) after confirming the following:</p> |
78 | 78 | <p class="glsr-card-field"> |
79 | 79 | <input type="checkbox" id="step-1" class="glsr-support-step"> |
80 | - <label for="step-1">I have read the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-support'); ?>" data-expand="#support-02">Common Problems and Solutions</a></code> and it does not answer my question.</label> |
|
80 | + <label for="step-1">I have read the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-support' ); ?>" data-expand="#support-02">Common Problems and Solutions</a></code> and it does not answer my question.</label> |
|
81 | 81 | </p> |
82 | 82 | <p class="glsr-card-field"> |
83 | 83 | <input type="checkbox" id="step-2" class="glsr-support-step"> |
84 | - <label for="step-2">I have read the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-faq'); ?>">FAQ</a></code> page and it does not answer my question.</label> |
|
84 | + <label for="step-2">I have read the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-faq' ); ?>">FAQ</a></code> page and it does not answer my question.</label> |
|
85 | 85 | </p> |
86 | 86 | <p class="glsr-card-field"> |
87 | 87 | <input type="checkbox" id="step-3" class="glsr-support-step"> |
88 | - <label for="step-3">I have read the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes'); ?>">Shortcodes</a></code> page and it does not answer my question.</label> |
|
88 | + <label for="step-3">I have read the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes' ); ?>">Shortcodes</a></code> page and it does not answer my question.</label> |
|
89 | 89 | </p> |
90 | - <?php if (glsr()->hasPermission('documentation', 'hooks')) : ?> |
|
90 | + <?php if( glsr()->hasPermission( 'documentation', 'hooks' ) ) : ?> |
|
91 | 91 | <p class="glsr-card-field"> |
92 | 92 | <input type="checkbox" id="step-4" class="glsr-support-step"> |
93 | - <label for="step-4">I have read the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-hooks'); ?>">Hooks</a></code> page and it does not answer my question.</label> |
|
93 | + <label for="step-4">I have read the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-hooks' ); ?>">Hooks</a></code> page and it does not answer my question.</label> |
|
94 | 94 | </p> |
95 | 95 | <?php endif; ?> |
96 | 96 | <p class="glsr-card-field"> |
97 | 97 | <input type="checkbox" id="step-5" class="glsr-support-step"> |
98 | - <label for="step-5">I have completed the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-support'); ?>" data-expand="#support-01">Basic Troubleshooting Steps</a></code> provided above.</label> |
|
98 | + <label for="step-5">I have completed the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-support' ); ?>" data-expand="#support-01">Basic Troubleshooting Steps</a></code> provided above.</label> |
|
99 | 99 | </p> |
100 | 100 | <div class="glsr-card-result hidden"> |
101 | 101 | <p><strong>Please send an email to <a href="mailto:[email protected]?subject=Support%20request">[email protected]</a> and include the following details:</strong></p> |
102 | 102 | <ul> |
103 | 103 | <li>A detailed description of the problem you are having and steps to reproduce it.</li> |
104 | - <li>Download and attach the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=tools#tab-console'); ?>">Tools → Console</a></code> log file to the email.</li> |
|
105 | - <li>Download and attach the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=tools#tab-system-info'); ?>">Tools → System Info</a></code> report to the email.</li> |
|
104 | + <li>Download and attach the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=tools#tab-console' ); ?>">Tools → Console</a></code> log file to the email.</li> |
|
105 | + <li>Download and attach the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=tools#tab-system-info' ); ?>">Tools → System Info</a></code> report to the email.</li> |
|
106 | 106 | <li>Include screenshots if they will help explain the problem.</li> |
107 | 107 | </ul> |
108 | 108 | <p><span class="required">Please be aware that if your email does not include the System Info report and the Console log (as requested above), it will most likely be ignored. Thank you for understanding.</span></p> |
@@ -11,6 +11,6 @@ |
||
11 | 11 | */ |
12 | 12 | class Upgrader |
13 | 13 | { |
14 | - public function run() |
|
15 | - {} |
|
14 | + public function run() |
|
15 | + {} |
|
16 | 16 | } |
@@ -12,5 +12,6 @@ |
||
12 | 12 | class Upgrader |
13 | 13 | { |
14 | 14 | public function run() |
15 | - {} |
|
15 | + { |
|
16 | +} |
|
16 | 17 | } |
@@ -4,15 +4,15 @@ |
||
4 | 4 | |
5 | 5 | class SiteReviewsFormShortcode extends Shortcode |
6 | 6 | { |
7 | - protected function hideOptions() |
|
8 | - { |
|
9 | - return [ |
|
10 | - 'rating' => __('Hide the rating field', 'site-reviews'), |
|
11 | - 'title' => __('Hide the title field', 'site-reviews'), |
|
12 | - 'content' => __('Hide the review field', 'site-reviews'), |
|
13 | - 'name' => __('Hide the name field', 'site-reviews'), |
|
14 | - 'email' => __('Hide the email field', 'site-reviews'), |
|
15 | - 'terms' => __('Hide the terms field', 'site-reviews'), |
|
16 | - ]; |
|
17 | - } |
|
7 | + protected function hideOptions() |
|
8 | + { |
|
9 | + return [ |
|
10 | + 'rating' => __('Hide the rating field', 'site-reviews'), |
|
11 | + 'title' => __('Hide the title field', 'site-reviews'), |
|
12 | + 'content' => __('Hide the review field', 'site-reviews'), |
|
13 | + 'name' => __('Hide the name field', 'site-reviews'), |
|
14 | + 'email' => __('Hide the email field', 'site-reviews'), |
|
15 | + 'terms' => __('Hide the terms field', 'site-reviews'), |
|
16 | + ]; |
|
17 | + } |
|
18 | 18 | } |
@@ -7,12 +7,12 @@ |
||
7 | 7 | protected function hideOptions() |
8 | 8 | { |
9 | 9 | return [ |
10 | - 'rating' => __('Hide the rating field', 'site-reviews'), |
|
11 | - 'title' => __('Hide the title field', 'site-reviews'), |
|
12 | - 'content' => __('Hide the review field', 'site-reviews'), |
|
13 | - 'name' => __('Hide the name field', 'site-reviews'), |
|
14 | - 'email' => __('Hide the email field', 'site-reviews'), |
|
15 | - 'terms' => __('Hide the terms field', 'site-reviews'), |
|
10 | + 'rating' => __( 'Hide the rating field', 'site-reviews' ), |
|
11 | + 'title' => __( 'Hide the title field', 'site-reviews' ), |
|
12 | + 'content' => __( 'Hide the review field', 'site-reviews' ), |
|
13 | + 'name' => __( 'Hide the name field', 'site-reviews' ), |
|
14 | + 'email' => __( 'Hide the email field', 'site-reviews' ), |
|
15 | + 'terms' => __( 'Hide the terms field', 'site-reviews' ), |
|
16 | 16 | ]; |
17 | 17 | } |
18 | 18 | } |
@@ -10,197 +10,197 @@ |
||
10 | 10 | |
11 | 11 | class SiteReviewsSummary |
12 | 12 | { |
13 | - /** |
|
14 | - * @var array |
|
15 | - */ |
|
16 | - protected $args; |
|
17 | - |
|
18 | - /** |
|
19 | - * @var float |
|
20 | - */ |
|
21 | - protected $averageRating; |
|
22 | - |
|
23 | - /** |
|
24 | - * @var array |
|
25 | - */ |
|
26 | - protected $ratingCounts; |
|
27 | - |
|
28 | - /** |
|
29 | - * @return void|string |
|
30 | - */ |
|
31 | - public function build(array $args = []) |
|
32 | - { |
|
33 | - $this->args = $args; |
|
34 | - $this->ratingCounts = glsr(ReviewManager::class)->getRatingCounts($args); |
|
35 | - if (!array_sum($this->ratingCounts) && $this->isHidden('if_empty')) { |
|
36 | - return; |
|
37 | - } |
|
38 | - $this->averageRating = glsr(Rating::class)->getAverage($this->ratingCounts); |
|
39 | - $this->generateSchema(); |
|
40 | - return glsr(Template::class)->build('templates/reviews-summary', [ |
|
41 | - 'context' => [ |
|
42 | - 'assigned_to' => $this->args['assigned_to'], |
|
43 | - 'category' => $this->args['category'], |
|
44 | - 'class' => $this->getClass(), |
|
45 | - 'id' => $this->args['id'], |
|
46 | - 'percentages' => $this->buildPercentage(), |
|
47 | - 'rating' => $this->buildRating(), |
|
48 | - 'stars' => $this->buildStars(), |
|
49 | - 'text' => $this->buildText(), |
|
50 | - ], |
|
51 | - ]); |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * @return void|string |
|
56 | - */ |
|
57 | - protected function buildPercentage() |
|
58 | - { |
|
59 | - if ($this->isHidden('bars')) { |
|
60 | - return; |
|
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', |
|
67 | - $percentages[$level], |
|
68 | - $this->ratingCounts[$level] |
|
69 | - ); |
|
70 | - $percent = $this->buildPercentageCount($count); |
|
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), |
|
74 | - 'rating' => $level, |
|
75 | - ]); |
|
76 | - return $carry.glsr(Builder::class)->div($value, [ |
|
77 | - 'class' => 'glsr-bar', |
|
78 | - ]); |
|
79 | - }); |
|
80 | - return $this->wrap('percentage', $bars); |
|
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * @param string $percent |
|
85 | - * @return string |
|
86 | - */ |
|
87 | - protected function buildPercentageBackground($percent) |
|
88 | - { |
|
89 | - $backgroundPercent = glsr(Builder::class)->span([ |
|
90 | - 'class' => 'glsr-bar-background-percent', |
|
91 | - 'style' => 'width:'.$percent, |
|
92 | - ]); |
|
93 | - return '<span class="glsr-bar-background">'.$backgroundPercent.'</span>'; |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * @param string $count |
|
98 | - * @return string |
|
99 | - */ |
|
100 | - protected function buildPercentageCount($count) |
|
101 | - { |
|
102 | - return '<span class="glsr-bar-percent">'.$count.'</span>'; |
|
103 | - } |
|
104 | - |
|
105 | - /** |
|
106 | - * @param string $label |
|
107 | - * @return string |
|
108 | - */ |
|
109 | - protected function buildPercentageLabel($label) |
|
110 | - { |
|
111 | - return '<span class="glsr-bar-label">'.$label.'</span>'; |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * @return void|string |
|
116 | - */ |
|
117 | - protected function buildRating() |
|
118 | - { |
|
119 | - if ($this->isHidden('rating')) { |
|
120 | - return; |
|
121 | - } |
|
122 | - return $this->wrap('rating', '<span>'.$this->averageRating.'</span>'); |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * @return void|string |
|
127 | - */ |
|
128 | - protected function buildStars() |
|
129 | - { |
|
130 | - if ($this->isHidden('stars')) { |
|
131 | - return; |
|
132 | - } |
|
133 | - $stars = glsr_star_rating($this->averageRating); |
|
134 | - return $this->wrap('stars', $stars); |
|
135 | - } |
|
136 | - |
|
137 | - /** |
|
138 | - * @return void|string |
|
139 | - */ |
|
140 | - protected function buildText() |
|
141 | - { |
|
142 | - if ($this->isHidden('summary')) { |
|
143 | - return; |
|
144 | - } |
|
145 | - $count = intval(array_sum($this->ratingCounts)); |
|
146 | - if (empty($this->args['text'])) { |
|
147 | - // @todo document this change |
|
148 | - $this->args['text'] = _nx( |
|
149 | - '{rating} out of {max} stars (based on {num} review)', |
|
150 | - '{rating} out of {max} stars (based on {num} reviews)', |
|
151 | - $count, |
|
152 | - 'Do not translate {rating}, {max}, and {num}, they are template tags.', |
|
153 | - 'site-reviews' |
|
154 | - ); |
|
155 | - } |
|
156 | - $summary = str_replace( |
|
157 | - ['{rating}', '{max}', '{num}'], |
|
158 | - [$this->averageRating, glsr()->constant('MAX_RATING', Rating::class), $count], |
|
159 | - $this->args['text'] |
|
160 | - ); |
|
161 | - return $this->wrap('text', '<span>'.$summary.'</span>'); |
|
162 | - } |
|
163 | - |
|
164 | - /** |
|
165 | - * @return void |
|
166 | - */ |
|
167 | - protected function generateSchema() |
|
168 | - { |
|
169 | - if (!wp_validate_boolean($this->args['schema'])) { |
|
170 | - return; |
|
171 | - } |
|
172 | - glsr(Schema::class)->store( |
|
173 | - glsr(Schema::class)->buildSummary($this->args) |
|
174 | - ); |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * @return string |
|
179 | - */ |
|
180 | - protected function getClass() |
|
181 | - { |
|
182 | - return trim('glsr-summary glsr-default '.$this->args['class']); |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * @param string $key |
|
187 | - * @return bool |
|
188 | - */ |
|
189 | - protected function isHidden($key) |
|
190 | - { |
|
191 | - return in_array($key, $this->args['hide']); |
|
192 | - } |
|
193 | - |
|
194 | - /** |
|
195 | - * @param string $key |
|
196 | - * @param string $value |
|
197 | - * @return string |
|
198 | - */ |
|
199 | - protected function wrap($key, $value) |
|
200 | - { |
|
201 | - $value = apply_filters('site-reviews/summary/wrap/'.$key, $value, $this->args); |
|
202 | - return glsr(Builder::class)->div($value, [ |
|
203 | - 'class' => 'glsr-summary-'.$key, |
|
204 | - ]); |
|
205 | - } |
|
13 | + /** |
|
14 | + * @var array |
|
15 | + */ |
|
16 | + protected $args; |
|
17 | + |
|
18 | + /** |
|
19 | + * @var float |
|
20 | + */ |
|
21 | + protected $averageRating; |
|
22 | + |
|
23 | + /** |
|
24 | + * @var array |
|
25 | + */ |
|
26 | + protected $ratingCounts; |
|
27 | + |
|
28 | + /** |
|
29 | + * @return void|string |
|
30 | + */ |
|
31 | + public function build(array $args = []) |
|
32 | + { |
|
33 | + $this->args = $args; |
|
34 | + $this->ratingCounts = glsr(ReviewManager::class)->getRatingCounts($args); |
|
35 | + if (!array_sum($this->ratingCounts) && $this->isHidden('if_empty')) { |
|
36 | + return; |
|
37 | + } |
|
38 | + $this->averageRating = glsr(Rating::class)->getAverage($this->ratingCounts); |
|
39 | + $this->generateSchema(); |
|
40 | + return glsr(Template::class)->build('templates/reviews-summary', [ |
|
41 | + 'context' => [ |
|
42 | + 'assigned_to' => $this->args['assigned_to'], |
|
43 | + 'category' => $this->args['category'], |
|
44 | + 'class' => $this->getClass(), |
|
45 | + 'id' => $this->args['id'], |
|
46 | + 'percentages' => $this->buildPercentage(), |
|
47 | + 'rating' => $this->buildRating(), |
|
48 | + 'stars' => $this->buildStars(), |
|
49 | + 'text' => $this->buildText(), |
|
50 | + ], |
|
51 | + ]); |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * @return void|string |
|
56 | + */ |
|
57 | + protected function buildPercentage() |
|
58 | + { |
|
59 | + if ($this->isHidden('bars')) { |
|
60 | + return; |
|
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', |
|
67 | + $percentages[$level], |
|
68 | + $this->ratingCounts[$level] |
|
69 | + ); |
|
70 | + $percent = $this->buildPercentageCount($count); |
|
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), |
|
74 | + 'rating' => $level, |
|
75 | + ]); |
|
76 | + return $carry.glsr(Builder::class)->div($value, [ |
|
77 | + 'class' => 'glsr-bar', |
|
78 | + ]); |
|
79 | + }); |
|
80 | + return $this->wrap('percentage', $bars); |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * @param string $percent |
|
85 | + * @return string |
|
86 | + */ |
|
87 | + protected function buildPercentageBackground($percent) |
|
88 | + { |
|
89 | + $backgroundPercent = glsr(Builder::class)->span([ |
|
90 | + 'class' => 'glsr-bar-background-percent', |
|
91 | + 'style' => 'width:'.$percent, |
|
92 | + ]); |
|
93 | + return '<span class="glsr-bar-background">'.$backgroundPercent.'</span>'; |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * @param string $count |
|
98 | + * @return string |
|
99 | + */ |
|
100 | + protected function buildPercentageCount($count) |
|
101 | + { |
|
102 | + return '<span class="glsr-bar-percent">'.$count.'</span>'; |
|
103 | + } |
|
104 | + |
|
105 | + /** |
|
106 | + * @param string $label |
|
107 | + * @return string |
|
108 | + */ |
|
109 | + protected function buildPercentageLabel($label) |
|
110 | + { |
|
111 | + return '<span class="glsr-bar-label">'.$label.'</span>'; |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * @return void|string |
|
116 | + */ |
|
117 | + protected function buildRating() |
|
118 | + { |
|
119 | + if ($this->isHidden('rating')) { |
|
120 | + return; |
|
121 | + } |
|
122 | + return $this->wrap('rating', '<span>'.$this->averageRating.'</span>'); |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * @return void|string |
|
127 | + */ |
|
128 | + protected function buildStars() |
|
129 | + { |
|
130 | + if ($this->isHidden('stars')) { |
|
131 | + return; |
|
132 | + } |
|
133 | + $stars = glsr_star_rating($this->averageRating); |
|
134 | + return $this->wrap('stars', $stars); |
|
135 | + } |
|
136 | + |
|
137 | + /** |
|
138 | + * @return void|string |
|
139 | + */ |
|
140 | + protected function buildText() |
|
141 | + { |
|
142 | + if ($this->isHidden('summary')) { |
|
143 | + return; |
|
144 | + } |
|
145 | + $count = intval(array_sum($this->ratingCounts)); |
|
146 | + if (empty($this->args['text'])) { |
|
147 | + // @todo document this change |
|
148 | + $this->args['text'] = _nx( |
|
149 | + '{rating} out of {max} stars (based on {num} review)', |
|
150 | + '{rating} out of {max} stars (based on {num} reviews)', |
|
151 | + $count, |
|
152 | + 'Do not translate {rating}, {max}, and {num}, they are template tags.', |
|
153 | + 'site-reviews' |
|
154 | + ); |
|
155 | + } |
|
156 | + $summary = str_replace( |
|
157 | + ['{rating}', '{max}', '{num}'], |
|
158 | + [$this->averageRating, glsr()->constant('MAX_RATING', Rating::class), $count], |
|
159 | + $this->args['text'] |
|
160 | + ); |
|
161 | + return $this->wrap('text', '<span>'.$summary.'</span>'); |
|
162 | + } |
|
163 | + |
|
164 | + /** |
|
165 | + * @return void |
|
166 | + */ |
|
167 | + protected function generateSchema() |
|
168 | + { |
|
169 | + if (!wp_validate_boolean($this->args['schema'])) { |
|
170 | + return; |
|
171 | + } |
|
172 | + glsr(Schema::class)->store( |
|
173 | + glsr(Schema::class)->buildSummary($this->args) |
|
174 | + ); |
|
175 | + } |
|
176 | + |
|
177 | + /** |
|
178 | + * @return string |
|
179 | + */ |
|
180 | + protected function getClass() |
|
181 | + { |
|
182 | + return trim('glsr-summary glsr-default '.$this->args['class']); |
|
183 | + } |
|
184 | + |
|
185 | + /** |
|
186 | + * @param string $key |
|
187 | + * @return bool |
|
188 | + */ |
|
189 | + protected function isHidden($key) |
|
190 | + { |
|
191 | + return in_array($key, $this->args['hide']); |
|
192 | + } |
|
193 | + |
|
194 | + /** |
|
195 | + * @param string $key |
|
196 | + * @param string $value |
|
197 | + * @return string |
|
198 | + */ |
|
199 | + protected function wrap($key, $value) |
|
200 | + { |
|
201 | + $value = apply_filters('site-reviews/summary/wrap/'.$key, $value, $this->args); |
|
202 | + return glsr(Builder::class)->div($value, [ |
|
203 | + 'class' => 'glsr-summary-'.$key, |
|
204 | + ]); |
|
205 | + } |
|
206 | 206 | } |
@@ -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,86 +7,86 @@ |
||
7 | 7 | |
8 | 8 | class Template |
9 | 9 | { |
10 | - /** |
|
11 | - * @param string $templatePath |
|
12 | - * @return void|string |
|
13 | - */ |
|
14 | - public function build($templatePath, array $data = []) |
|
15 | - { |
|
16 | - $data = $this->normalize($data); |
|
17 | - $path = Str::removePrefix('templates/', $templatePath); |
|
18 | - $template = glsr()->build($templatePath, $data); |
|
19 | - $template = apply_filters('site-reviews/build/template/'.$path, $template, $data); |
|
20 | - $template = $this->interpolate($template, $data, $path); |
|
21 | - $template = apply_filters('site-reviews/rendered/template', $template, $templatePath, $data); |
|
22 | - $template = apply_filters('site-reviews/rendered/template/'.$path, $template, $data); |
|
23 | - return $template; |
|
24 | - } |
|
10 | + /** |
|
11 | + * @param string $templatePath |
|
12 | + * @return void|string |
|
13 | + */ |
|
14 | + public function build($templatePath, array $data = []) |
|
15 | + { |
|
16 | + $data = $this->normalize($data); |
|
17 | + $path = Str::removePrefix('templates/', $templatePath); |
|
18 | + $template = glsr()->build($templatePath, $data); |
|
19 | + $template = apply_filters('site-reviews/build/template/'.$path, $template, $data); |
|
20 | + $template = $this->interpolate($template, $data, $path); |
|
21 | + $template = apply_filters('site-reviews/rendered/template', $template, $templatePath, $data); |
|
22 | + $template = apply_filters('site-reviews/rendered/template/'.$path, $template, $data); |
|
23 | + return $template; |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * Interpolate context values into template placeholders. |
|
28 | - * @param string $template |
|
29 | - * @param string $templatePath |
|
30 | - * @return string |
|
31 | - */ |
|
32 | - public function interpolate($template, array $data = [], $templatePath) |
|
33 | - { |
|
34 | - $context = $this->normalizeContext(Arr::get($data, 'context', [])); |
|
35 | - $context = apply_filters('site-reviews/interpolate/'.$templatePath, $context, $template, $data); |
|
36 | - return $this->interpolateContext($template, $context); |
|
37 | - } |
|
26 | + /** |
|
27 | + * Interpolate context values into template placeholders. |
|
28 | + * @param string $template |
|
29 | + * @param string $templatePath |
|
30 | + * @return string |
|
31 | + */ |
|
32 | + public function interpolate($template, array $data = [], $templatePath) |
|
33 | + { |
|
34 | + $context = $this->normalizeContext(Arr::get($data, 'context', [])); |
|
35 | + $context = apply_filters('site-reviews/interpolate/'.$templatePath, $context, $template, $data); |
|
36 | + return $this->interpolateContext($template, $context); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * Interpolate context values into template placeholders. |
|
41 | - * @param string $text |
|
42 | - * @return string |
|
43 | - */ |
|
44 | - public function interpolateContext($text, array $context = []) |
|
45 | - { |
|
46 | - foreach ($context as $key => $value) { |
|
47 | - $text = strtr( |
|
48 | - $text, |
|
49 | - array_fill_keys(['{'.$key.'}', '{{ '.$key.' }}'], $value) |
|
50 | - ); |
|
51 | - } |
|
52 | - return trim($text); |
|
53 | - } |
|
39 | + /** |
|
40 | + * Interpolate context values into template placeholders. |
|
41 | + * @param string $text |
|
42 | + * @return string |
|
43 | + */ |
|
44 | + public function interpolateContext($text, array $context = []) |
|
45 | + { |
|
46 | + foreach ($context as $key => $value) { |
|
47 | + $text = strtr( |
|
48 | + $text, |
|
49 | + array_fill_keys(['{'.$key.'}', '{{ '.$key.' }}'], $value) |
|
50 | + ); |
|
51 | + } |
|
52 | + return trim($text); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * @param string $templatePath |
|
57 | - * @return void|string |
|
58 | - */ |
|
59 | - public function render($templatePath, array $data = []) |
|
60 | - { |
|
61 | - echo $this->build($templatePath, $data); |
|
62 | - } |
|
55 | + /** |
|
56 | + * @param string $templatePath |
|
57 | + * @return void|string |
|
58 | + */ |
|
59 | + public function render($templatePath, array $data = []) |
|
60 | + { |
|
61 | + echo $this->build($templatePath, $data); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @return array |
|
66 | - */ |
|
67 | - protected function normalize(array $data) |
|
68 | - { |
|
69 | - $arrayKeys = ['context', 'globals']; |
|
70 | - $data = wp_parse_args($data, array_fill_keys($arrayKeys, [])); |
|
71 | - foreach ($arrayKeys as $key) { |
|
72 | - if (is_array($data[$key])) { |
|
73 | - continue; |
|
74 | - } |
|
75 | - $data[$key] = []; |
|
76 | - } |
|
77 | - return $data; |
|
78 | - } |
|
64 | + /** |
|
65 | + * @return array |
|
66 | + */ |
|
67 | + protected function normalize(array $data) |
|
68 | + { |
|
69 | + $arrayKeys = ['context', 'globals']; |
|
70 | + $data = wp_parse_args($data, array_fill_keys($arrayKeys, [])); |
|
71 | + foreach ($arrayKeys as $key) { |
|
72 | + if (is_array($data[$key])) { |
|
73 | + continue; |
|
74 | + } |
|
75 | + $data[$key] = []; |
|
76 | + } |
|
77 | + return $data; |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * @return array |
|
82 | - */ |
|
83 | - protected function normalizeContext(array $context) |
|
84 | - { |
|
85 | - $context = array_filter($context, function ($value) { |
|
86 | - return !is_array($value) && !is_object($value); |
|
87 | - }); |
|
88 | - return array_map(function ($value) { |
|
89 | - return (string) $value; |
|
90 | - }, $context); |
|
91 | - } |
|
80 | + /** |
|
81 | + * @return array |
|
82 | + */ |
|
83 | + protected function normalizeContext(array $context) |
|
84 | + { |
|
85 | + $context = array_filter($context, function ($value) { |
|
86 | + return !is_array($value) && !is_object($value); |
|
87 | + }); |
|
88 | + return array_map(function ($value) { |
|
89 | + return (string) $value; |
|
90 | + }, $context); |
|
91 | + } |
|
92 | 92 | } |
@@ -11,15 +11,15 @@ discard block |
||
11 | 11 | * @param string $templatePath |
12 | 12 | * @return void|string |
13 | 13 | */ |
14 | - public function build($templatePath, array $data = []) |
|
14 | + public function build( $templatePath, array $data = [] ) |
|
15 | 15 | { |
16 | - $data = $this->normalize($data); |
|
17 | - $path = Str::removePrefix('templates/', $templatePath); |
|
18 | - $template = glsr()->build($templatePath, $data); |
|
19 | - $template = apply_filters('site-reviews/build/template/'.$path, $template, $data); |
|
20 | - $template = $this->interpolate($template, $data, $path); |
|
21 | - $template = apply_filters('site-reviews/rendered/template', $template, $templatePath, $data); |
|
22 | - $template = apply_filters('site-reviews/rendered/template/'.$path, $template, $data); |
|
16 | + $data = $this->normalize( $data ); |
|
17 | + $path = Str::removePrefix( 'templates/', $templatePath ); |
|
18 | + $template = glsr()->build( $templatePath, $data ); |
|
19 | + $template = apply_filters( 'site-reviews/build/template/'.$path, $template, $data ); |
|
20 | + $template = $this->interpolate( $template, $data, $path ); |
|
21 | + $template = apply_filters( 'site-reviews/rendered/template', $template, $templatePath, $data ); |
|
22 | + $template = apply_filters( 'site-reviews/rendered/template/'.$path, $template, $data ); |
|
23 | 23 | return $template; |
24 | 24 | } |
25 | 25 | |
@@ -29,11 +29,11 @@ discard block |
||
29 | 29 | * @param string $templatePath |
30 | 30 | * @return string |
31 | 31 | */ |
32 | - public function interpolate($template, array $data = [], $templatePath) |
|
32 | + public function interpolate( $template, array $data = [], $templatePath ) |
|
33 | 33 | { |
34 | - $context = $this->normalizeContext(Arr::get($data, 'context', [])); |
|
35 | - $context = apply_filters('site-reviews/interpolate/'.$templatePath, $context, $template, $data); |
|
36 | - return $this->interpolateContext($template, $context); |
|
34 | + $context = $this->normalizeContext( Arr::get( $data, 'context', [] ) ); |
|
35 | + $context = apply_filters( 'site-reviews/interpolate/'.$templatePath, $context, $template, $data ); |
|
36 | + return $this->interpolateContext( $template, $context ); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -41,35 +41,35 @@ discard block |
||
41 | 41 | * @param string $text |
42 | 42 | * @return string |
43 | 43 | */ |
44 | - public function interpolateContext($text, array $context = []) |
|
44 | + public function interpolateContext( $text, array $context = [] ) |
|
45 | 45 | { |
46 | - foreach ($context as $key => $value) { |
|
46 | + foreach( $context as $key => $value ) { |
|
47 | 47 | $text = strtr( |
48 | 48 | $text, |
49 | - array_fill_keys(['{'.$key.'}', '{{ '.$key.' }}'], $value) |
|
49 | + array_fill_keys( ['{'.$key.'}', '{{ '.$key.' }}'], $value ) |
|
50 | 50 | ); |
51 | 51 | } |
52 | - return trim($text); |
|
52 | + return trim( $text ); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
56 | 56 | * @param string $templatePath |
57 | 57 | * @return void|string |
58 | 58 | */ |
59 | - public function render($templatePath, array $data = []) |
|
59 | + public function render( $templatePath, array $data = [] ) |
|
60 | 60 | { |
61 | - echo $this->build($templatePath, $data); |
|
61 | + echo $this->build( $templatePath, $data ); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
65 | 65 | * @return array |
66 | 66 | */ |
67 | - protected function normalize(array $data) |
|
67 | + protected function normalize( array $data ) |
|
68 | 68 | { |
69 | 69 | $arrayKeys = ['context', 'globals']; |
70 | - $data = wp_parse_args($data, array_fill_keys($arrayKeys, [])); |
|
71 | - foreach ($arrayKeys as $key) { |
|
72 | - if (is_array($data[$key])) { |
|
70 | + $data = wp_parse_args( $data, array_fill_keys( $arrayKeys, [] ) ); |
|
71 | + foreach( $arrayKeys as $key ) { |
|
72 | + if( is_array( $data[$key] ) ) { |
|
73 | 73 | continue; |
74 | 74 | } |
75 | 75 | $data[$key] = []; |
@@ -80,13 +80,13 @@ discard block |
||
80 | 80 | /** |
81 | 81 | * @return array |
82 | 82 | */ |
83 | - protected function normalizeContext(array $context) |
|
83 | + protected function normalizeContext( array $context ) |
|
84 | 84 | { |
85 | - $context = array_filter($context, function ($value) { |
|
86 | - return !is_array($value) && !is_object($value); |
|
85 | + $context = array_filter( $context, function( $value ) { |
|
86 | + return !is_array( $value ) && !is_object( $value ); |
|
87 | 87 | }); |
88 | - return array_map(function ($value) { |
|
89 | - return (string) $value; |
|
90 | - }, $context); |
|
88 | + return array_map( function( $value ) { |
|
89 | + return (string)$value; |
|
90 | + }, $context ); |
|
91 | 91 | } |
92 | 92 | } |
@@ -1,42 +1,42 @@ discard block |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | -<?php if (glsr()->hasPermission('settings')) : ?> |
|
3 | +<?php if( glsr()->hasPermission( 'settings' ) ) : ?> |
|
4 | 4 | <div class="glsr-card card"> |
5 | 5 | <h3>Export Settings</h3> |
6 | 6 | <p>Export the Site Reviews settings for this site to a <code>*.json</code> file. This allows you to easily import the plugin settings into another site.</p> |
7 | - <p>To export your Site Reviews' reviews and categories, please use the WordPress <a href="<?= admin_url('export.php'); ?>">Export</a> tool.</p> |
|
7 | + <p>To export your Site Reviews' reviews and categories, please use the WordPress <a href="<?= admin_url( 'export.php' ); ?>">Export</a> tool.</p> |
|
8 | 8 | <form method="post"> |
9 | 9 | <input type="hidden" name="{{ id }}[_action]" value="export-settings"> |
10 | - <?php wp_nonce_field('export-settings'); ?> |
|
11 | - <?php submit_button(__('Export Settings', 'site-reviews'), 'secondary'); ?> |
|
10 | + <?php wp_nonce_field( 'export-settings' ); ?> |
|
11 | + <?php submit_button( __( 'Export Settings', 'site-reviews' ), 'secondary' ); ?> |
|
12 | 12 | </form> |
13 | 13 | </div> |
14 | 14 | <?php endif; ?> |
15 | 15 | |
16 | -<?php if (glsr()->hasPermission('settings')) : ?> |
|
16 | +<?php if( glsr()->hasPermission( 'settings' ) ) : ?> |
|
17 | 17 | <div class="glsr-card card"> |
18 | 18 | <h3>Import Settings</h3> |
19 | 19 | <p>Import the Site Reviews settings from a <code>*.json</code> file. This file can be obtained by exporting the settings on another site using the export tool below.</p> |
20 | - <p>To import your Site Reviews' reviews and categories from another website, please use the WordPress <a href="<?= admin_url('import.php'); ?>">Import</a> tool.</p> |
|
20 | + <p>To import your Site Reviews' reviews and categories from another website, please use the WordPress <a href="<?= admin_url( 'import.php' ); ?>">Import</a> tool.</p> |
|
21 | 21 | <form method="post" enctype="multipart/form-data"> |
22 | 22 | <input type="file" name="import-file"> |
23 | 23 | <input type="hidden" name="{{ id }}[_action]" value="import-settings"> |
24 | - <?php wp_nonce_field('import-settings'); ?> |
|
25 | - <?php submit_button(__('Import Settings', 'site-reviews'), 'secondary'); ?> |
|
24 | + <?php wp_nonce_field( 'import-settings' ); ?> |
|
25 | + <?php submit_button( __( 'Import Settings', 'site-reviews' ), 'secondary' ); ?> |
|
26 | 26 | </form> |
27 | 27 | </div> |
28 | 28 | <?php endif; ?> |
29 | 29 | |
30 | -<?php if (glsr()->hasPermission('settings')) : ?> |
|
30 | +<?php if( glsr()->hasPermission( 'settings' ) ) : ?> |
|
31 | 31 | <div class="glsr-card card"> |
32 | 32 | <h3>Migrate Plugin</h3> |
33 | 33 | <p>Run this tool if your reviews stopped working correctly after upgrading the plugin to the latest version (i.e. read-only reviews, zero-star ratings, missing role capabilities, etc.).</p> |
34 | 34 | <form method="post"> |
35 | 35 | <input type="hidden" name="{{ id }}[_action]" value="migrate-reviews"> |
36 | - <?php wp_nonce_field('migrate-reviews'); ?> |
|
36 | + <?php wp_nonce_field( 'migrate-reviews' ); ?> |
|
37 | 37 | <p class="submit"> |
38 | 38 | <button type="submit" class="glsr-button button" name="migrate-reviews" id="migrate-reviews"> |
39 | - <span data-loading="<?= __('Migrating Reviews, please wait...', 'site-reviews'); ?>"><?= __('Run Migration', 'site-reviews'); ?></span> |
|
39 | + <span data-loading="<?= __( 'Migrating Reviews, please wait...', 'site-reviews' ); ?>"><?= __( 'Run Migration', 'site-reviews' ); ?></span> |
|
40 | 40 | </button> |
41 | 41 | </p> |
42 | 42 | </form> |
@@ -49,26 +49,26 @@ discard block |
||
49 | 49 | <p>If you suspect that the rating counts are incorrect (perhaps you have cloned a page that had reviews assigned to it, or edited/deleted reviews directly from your database), you can recalculate them here.</p> |
50 | 50 | <form method="post"> |
51 | 51 | <input type="hidden" name="{{ id }}[_action]" value="count-reviews"> |
52 | - <?php wp_nonce_field('count-reviews'); ?> |
|
52 | + <?php wp_nonce_field( 'count-reviews' ); ?> |
|
53 | 53 | <p class="submit"> |
54 | 54 | <button type="submit" class="glsr-button button" name="count-reviews" id="count-reviews"> |
55 | - <span data-loading="<?= __('Recalculating Counts, please wait...', 'site-reviews'); ?>"><?= __('Recalculate Counts', 'site-reviews'); ?></span> |
|
55 | + <span data-loading="<?= __( 'Recalculating Counts, please wait...', 'site-reviews' ); ?>"><?= __( 'Recalculate Counts', 'site-reviews' ); ?></span> |
|
56 | 56 | </button> |
57 | 57 | </p> |
58 | 58 | </form> |
59 | 59 | </div> |
60 | 60 | |
61 | -<?php if (glsr()->hasPermission('settings')) : ?> |
|
61 | +<?php if( glsr()->hasPermission( 'settings' ) ) : ?> |
|
62 | 62 | <div class="glsr-card card"> |
63 | 63 | <h3>Reset Permissions</h3> |
64 | 64 | <p>Site Reviews provides custom post_type capabilities that mirror the capabilities of your posts by default. For example, if a user role has permission to edit others posts, then that role will also have permission to edit other users reviews.</p> |
65 | 65 | <p>If you have changed the capabilities of your user roles and you suspect that Site Reviews is not working correctly due to your changes, you may use this tool to reset the Site Reviews capabilities for your user roles.</p> |
66 | 66 | <form method="post"> |
67 | 67 | <input type="hidden" name="{{ id }}[_action]" value="reset-permissions"> |
68 | - <?php wp_nonce_field('reset-permissions'); ?> |
|
68 | + <?php wp_nonce_field( 'reset-permissions' ); ?> |
|
69 | 69 | <p class="submit"> |
70 | 70 | <button type="submit" class="glsr-button button" name="reset-permissions" id="reset-permissions"> |
71 | - <span data-loading="<?= __('Resetting Permissions, please wait...', 'site-reviews'); ?>"><?= __('Reset Permissions', 'site-reviews'); ?></span> |
|
71 | + <span data-loading="<?= __( 'Resetting Permissions, please wait...', 'site-reviews' ); ?>"><?= __( 'Reset Permissions', 'site-reviews' ); ?></span> |
|
72 | 72 | </button> |
73 | 73 | </p> |
74 | 74 | </form> |