@@ -1,25 +1,25 @@ 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 | <div class="glsr-card card"> |
| 15 | 15 | <h3>Import Settings</h3> |
| 16 | 16 | <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> |
| 17 | - <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> |
|
| 17 | + <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> |
|
| 18 | 18 | <form method="post" enctype="multipart/form-data"> |
| 19 | 19 | <input type="file" name="import-file"> |
| 20 | 20 | <input type="hidden" name="{{ id }}[_action]" value="import-settings"> |
| 21 | - <?php wp_nonce_field('import-settings'); ?> |
|
| 22 | - <?php submit_button(__('Import Settings', 'site-reviews'), 'secondary'); ?> |
|
| 21 | + <?php wp_nonce_field( 'import-settings' ); ?> |
|
| 22 | + <?php submit_button( __( 'Import Settings', 'site-reviews' ), 'secondary' ); ?> |
|
| 23 | 23 | </form> |
| 24 | 24 | </div> |
| 25 | 25 | <?php endif; ?> |
@@ -29,10 +29,10 @@ discard block |
||
| 29 | 29 | <p>Run this tool if your reviews stopped working correctly after upgrading the plugin to version 4 (i.e. read-only reviews, zero-star ratings, etc.).</p> |
| 30 | 30 | <form method="post"> |
| 31 | 31 | <input type="hidden" name="{{ id }}[_action]" value="migrate-reviews"> |
| 32 | - <?php wp_nonce_field('migrate-reviews'); ?> |
|
| 32 | + <?php wp_nonce_field( 'migrate-reviews' ); ?> |
|
| 33 | 33 | <p class="submit"> |
| 34 | 34 | <button type="submit" class="glsr-button button" name="migrate-reviews" id="migrate-reviews"> |
| 35 | - <span data-loading="<?= __('Migrating Reviews...', 'site-reviews'); ?>"><?= __('Run Migration', 'site-reviews'); ?></span> |
|
| 35 | + <span data-loading="<?= __( 'Migrating Reviews...', 'site-reviews' ); ?>"><?= __( 'Run Migration', 'site-reviews' ); ?></span> |
|
| 36 | 36 | </button> |
| 37 | 37 | </p> |
| 38 | 38 | </form> |
@@ -44,10 +44,10 @@ discard block |
||
| 44 | 44 | <p>If you suspect that the rating counts are incorrect (perhaps you have edited reviews directly in your database), you can recalculate them here.</p> |
| 45 | 45 | <form method="post"> |
| 46 | 46 | <input type="hidden" name="{{ id }}[_action]" value="count-reviews"> |
| 47 | - <?php wp_nonce_field('count-reviews'); ?> |
|
| 47 | + <?php wp_nonce_field( 'count-reviews' ); ?> |
|
| 48 | 48 | <p class="submit"> |
| 49 | 49 | <button type="submit" class="glsr-button button" name="count-reviews" id="count-reviews"> |
| 50 | - <span data-loading="<?= __('Recalculating Counts...', 'site-reviews'); ?>"><?= __('Recalculate Counts', 'site-reviews'); ?></span> |
|
| 50 | + <span data-loading="<?= __( 'Recalculating Counts...', 'site-reviews' ); ?>"><?= __( 'Recalculate Counts', 'site-reviews' ); ?></span> |
|
| 51 | 51 | </button> |
| 52 | 52 | </p> |
| 53 | 53 | </form> |
@@ -8,163 +8,163 @@ |
||
| 8 | 8 | |
| 9 | 9 | class Upgrade_3_0_0 |
| 10 | 10 | { |
| 11 | - const MAPPED_SETTINGS = [ |
|
| 12 | - 'settings.general.notification' => 'settings.general.notifications', // array |
|
| 13 | - 'settings.general.notification_email' => 'settings.general.notification_email', |
|
| 14 | - 'settings.general.notification_message' => 'settings.general.notification_message', |
|
| 15 | - 'settings.general.require.approval' => 'settings.general.require.approval', |
|
| 16 | - 'settings.general.require.login' => 'settings.general.require.login', |
|
| 17 | - 'settings.general.require.login_register' => 'settings.general.require.login_register', |
|
| 18 | - 'settings.general.webhook_url' => 'settings.general.notification_slack', |
|
| 19 | - 'settings.reviews-form.akismet' => 'settings.submissions.akismet', |
|
| 20 | - 'settings.reviews-form.blacklist.action' => 'settings.submissions.blacklist.action', |
|
| 21 | - 'settings.reviews-form.blacklist.entries' => 'settings.submissions.blacklist.entries', |
|
| 22 | - 'settings.reviews-form.recaptcha.integration' => 'settings.submissions.recaptcha.integration', |
|
| 23 | - 'settings.reviews-form.recaptcha.key' => 'settings.submissions.recaptcha.key', |
|
| 24 | - 'settings.reviews-form.recaptcha.position' => 'settings.submissions.recaptcha.position', |
|
| 25 | - 'settings.reviews-form.recaptcha.secret' => 'settings.submissions.recaptcha.secret', |
|
| 26 | - 'settings.reviews-form.required' => 'settings.submissions.required', // array |
|
| 27 | - 'settings.reviews.assigned_links.enabled' => 'settings.reviews.assigned_links', |
|
| 28 | - 'settings.reviews.avatars.enabled' => 'settings.reviews.avatars', |
|
| 29 | - 'settings.reviews.date.custom' => 'settings.reviews.date.custom', |
|
| 30 | - 'settings.reviews.date.format' => 'settings.reviews.date.format', |
|
| 31 | - 'settings.reviews.excerpt.enabled' => 'settings.reviews.excerpts', |
|
| 32 | - 'settings.reviews.excerpt.length' => 'settings.reviews.excerpts_length', |
|
| 33 | - 'settings.reviews.schema.address' => 'settings.schema.address', |
|
| 34 | - 'settings.reviews.schema.description.custom' => 'settings.schema.description.custom', |
|
| 35 | - 'settings.reviews.schema.description.default' => 'settings.schema.description.default', |
|
| 36 | - 'settings.reviews.schema.highprice' => 'settings.schema.highprice', |
|
| 37 | - 'settings.reviews.schema.image.custom' => 'settings.schema.image.custom', |
|
| 38 | - 'settings.reviews.schema.image.default' => 'settings.schema.image.default', |
|
| 39 | - 'settings.reviews.schema.lowprice' => 'settings.schema.lowprice', |
|
| 40 | - 'settings.reviews.schema.name.custom' => 'settings.schema.name.custom', |
|
| 41 | - 'settings.reviews.schema.name.default' => 'settings.schema.name.default', |
|
| 42 | - 'settings.reviews.schema.pricecurrency' => 'settings.schema.pricecurrency', |
|
| 43 | - 'settings.reviews.schema.pricerange' => 'settings.schema.pricerange', |
|
| 44 | - 'settings.reviews.schema.telephone' => 'settings.schema.telephone', |
|
| 45 | - 'settings.reviews.schema.type.custom' => 'settings.schema.type.custom', |
|
| 46 | - 'settings.reviews.schema.type.default' => 'settings.schema.type.default', |
|
| 47 | - 'settings.reviews.schema.url.custom' => 'settings.schema.url.custom', |
|
| 48 | - 'settings.reviews.schema.url.default' => 'settings.schema.url.default', |
|
| 49 | - 'version' => 'version_upgraded_from', |
|
| 50 | - ]; |
|
| 11 | + const MAPPED_SETTINGS = [ |
|
| 12 | + 'settings.general.notification' => 'settings.general.notifications', // array |
|
| 13 | + 'settings.general.notification_email' => 'settings.general.notification_email', |
|
| 14 | + 'settings.general.notification_message' => 'settings.general.notification_message', |
|
| 15 | + 'settings.general.require.approval' => 'settings.general.require.approval', |
|
| 16 | + 'settings.general.require.login' => 'settings.general.require.login', |
|
| 17 | + 'settings.general.require.login_register' => 'settings.general.require.login_register', |
|
| 18 | + 'settings.general.webhook_url' => 'settings.general.notification_slack', |
|
| 19 | + 'settings.reviews-form.akismet' => 'settings.submissions.akismet', |
|
| 20 | + 'settings.reviews-form.blacklist.action' => 'settings.submissions.blacklist.action', |
|
| 21 | + 'settings.reviews-form.blacklist.entries' => 'settings.submissions.blacklist.entries', |
|
| 22 | + 'settings.reviews-form.recaptcha.integration' => 'settings.submissions.recaptcha.integration', |
|
| 23 | + 'settings.reviews-form.recaptcha.key' => 'settings.submissions.recaptcha.key', |
|
| 24 | + 'settings.reviews-form.recaptcha.position' => 'settings.submissions.recaptcha.position', |
|
| 25 | + 'settings.reviews-form.recaptcha.secret' => 'settings.submissions.recaptcha.secret', |
|
| 26 | + 'settings.reviews-form.required' => 'settings.submissions.required', // array |
|
| 27 | + 'settings.reviews.assigned_links.enabled' => 'settings.reviews.assigned_links', |
|
| 28 | + 'settings.reviews.avatars.enabled' => 'settings.reviews.avatars', |
|
| 29 | + 'settings.reviews.date.custom' => 'settings.reviews.date.custom', |
|
| 30 | + 'settings.reviews.date.format' => 'settings.reviews.date.format', |
|
| 31 | + 'settings.reviews.excerpt.enabled' => 'settings.reviews.excerpts', |
|
| 32 | + 'settings.reviews.excerpt.length' => 'settings.reviews.excerpts_length', |
|
| 33 | + 'settings.reviews.schema.address' => 'settings.schema.address', |
|
| 34 | + 'settings.reviews.schema.description.custom' => 'settings.schema.description.custom', |
|
| 35 | + 'settings.reviews.schema.description.default' => 'settings.schema.description.default', |
|
| 36 | + 'settings.reviews.schema.highprice' => 'settings.schema.highprice', |
|
| 37 | + 'settings.reviews.schema.image.custom' => 'settings.schema.image.custom', |
|
| 38 | + 'settings.reviews.schema.image.default' => 'settings.schema.image.default', |
|
| 39 | + 'settings.reviews.schema.lowprice' => 'settings.schema.lowprice', |
|
| 40 | + 'settings.reviews.schema.name.custom' => 'settings.schema.name.custom', |
|
| 41 | + 'settings.reviews.schema.name.default' => 'settings.schema.name.default', |
|
| 42 | + 'settings.reviews.schema.pricecurrency' => 'settings.schema.pricecurrency', |
|
| 43 | + 'settings.reviews.schema.pricerange' => 'settings.schema.pricerange', |
|
| 44 | + 'settings.reviews.schema.telephone' => 'settings.schema.telephone', |
|
| 45 | + 'settings.reviews.schema.type.custom' => 'settings.schema.type.custom', |
|
| 46 | + 'settings.reviews.schema.type.default' => 'settings.schema.type.default', |
|
| 47 | + 'settings.reviews.schema.url.custom' => 'settings.schema.url.custom', |
|
| 48 | + 'settings.reviews.schema.url.default' => 'settings.schema.url.default', |
|
| 49 | + 'version' => 'version_upgraded_from', |
|
| 50 | + ]; |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * @var array |
|
| 54 | - */ |
|
| 55 | - protected $newSettings; |
|
| 52 | + /** |
|
| 53 | + * @var array |
|
| 54 | + */ |
|
| 55 | + protected $newSettings; |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * @var array |
|
| 59 | - */ |
|
| 60 | - protected $oldSettings; |
|
| 57 | + /** |
|
| 58 | + * @var array |
|
| 59 | + */ |
|
| 60 | + protected $oldSettings; |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * @return void |
|
| 64 | - */ |
|
| 65 | - public function migrateSettings() |
|
| 66 | - { |
|
| 67 | - $this->newSettings = $this->getNewSettings(); |
|
| 68 | - $this->oldSettings = $this->getOldSettings(); |
|
| 69 | - if (empty($this->oldSettings)) { |
|
| 70 | - return; |
|
| 71 | - } |
|
| 72 | - foreach (static::MAPPED_SETTINGS as $old => $new) { |
|
| 73 | - if (empty($this->oldSettings[$old])) { |
|
| 74 | - continue; |
|
| 75 | - } |
|
| 76 | - $this->newSettings[$new] = $this->oldSettings[$old]; |
|
| 77 | - } |
|
| 78 | - $this->migrateNotificationSettings(); |
|
| 79 | - $this->migrateRecaptchaSettings(); |
|
| 80 | - $this->migrateRequiredSettings(); |
|
| 81 | - $oldSettings = Arr::convertDotNotationArray($this->oldSettings); |
|
| 82 | - $newSettings = Arr::convertDotNotationArray($this->newSettings); |
|
| 83 | - if (isset($oldSettings['settings']['strings']) && is_array($oldSettings['settings']['strings'])) { |
|
| 84 | - $newSettings['settings']['strings'] = $oldSettings['settings']['strings']; |
|
| 85 | - } |
|
| 86 | - glsr(OptionManager::class)->set($newSettings); |
|
| 87 | - } |
|
| 62 | + /** |
|
| 63 | + * @return void |
|
| 64 | + */ |
|
| 65 | + public function migrateSettings() |
|
| 66 | + { |
|
| 67 | + $this->newSettings = $this->getNewSettings(); |
|
| 68 | + $this->oldSettings = $this->getOldSettings(); |
|
| 69 | + if (empty($this->oldSettings)) { |
|
| 70 | + return; |
|
| 71 | + } |
|
| 72 | + foreach (static::MAPPED_SETTINGS as $old => $new) { |
|
| 73 | + if (empty($this->oldSettings[$old])) { |
|
| 74 | + continue; |
|
| 75 | + } |
|
| 76 | + $this->newSettings[$new] = $this->oldSettings[$old]; |
|
| 77 | + } |
|
| 78 | + $this->migrateNotificationSettings(); |
|
| 79 | + $this->migrateRecaptchaSettings(); |
|
| 80 | + $this->migrateRequiredSettings(); |
|
| 81 | + $oldSettings = Arr::convertDotNotationArray($this->oldSettings); |
|
| 82 | + $newSettings = Arr::convertDotNotationArray($this->newSettings); |
|
| 83 | + if (isset($oldSettings['settings']['strings']) && is_array($oldSettings['settings']['strings'])) { |
|
| 84 | + $newSettings['settings']['strings'] = $oldSettings['settings']['strings']; |
|
| 85 | + } |
|
| 86 | + glsr(OptionManager::class)->set($newSettings); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * @return void |
|
| 91 | - */ |
|
| 92 | - public function run() |
|
| 93 | - { |
|
| 94 | - $this->migrateSettings(); |
|
| 95 | - } |
|
| 89 | + /** |
|
| 90 | + * @return void |
|
| 91 | + */ |
|
| 92 | + public function run() |
|
| 93 | + { |
|
| 94 | + $this->migrateSettings(); |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - /** |
|
| 98 | - * @return array |
|
| 99 | - */ |
|
| 100 | - protected function getNewSettings() |
|
| 101 | - { |
|
| 102 | - return wp_parse_args( |
|
| 103 | - Arr::flattenArray(glsr(OptionManager::class)->all()), |
|
| 104 | - glsr(DefaultsManager::class)->defaults() |
|
| 105 | - ); |
|
| 106 | - } |
|
| 97 | + /** |
|
| 98 | + * @return array |
|
| 99 | + */ |
|
| 100 | + protected function getNewSettings() |
|
| 101 | + { |
|
| 102 | + return wp_parse_args( |
|
| 103 | + Arr::flattenArray(glsr(OptionManager::class)->all()), |
|
| 104 | + glsr(DefaultsManager::class)->defaults() |
|
| 105 | + ); |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * @return array |
|
| 110 | - */ |
|
| 111 | - protected function getOldSettings() |
|
| 112 | - { |
|
| 113 | - $defaults = array_fill_keys(array_keys(static::MAPPED_SETTINGS), ''); |
|
| 114 | - $settings = Arr::flattenArray((array) get_option('geminilabs_site_reviews-v2', [])); |
|
| 115 | - if (!empty($settings)) { |
|
| 116 | - $settings = wp_parse_args($settings, $defaults); |
|
| 117 | - } |
|
| 118 | - return $settings; |
|
| 119 | - } |
|
| 108 | + /** |
|
| 109 | + * @return array |
|
| 110 | + */ |
|
| 111 | + protected function getOldSettings() |
|
| 112 | + { |
|
| 113 | + $defaults = array_fill_keys(array_keys(static::MAPPED_SETTINGS), ''); |
|
| 114 | + $settings = Arr::flattenArray((array) get_option('geminilabs_site_reviews-v2', [])); |
|
| 115 | + if (!empty($settings)) { |
|
| 116 | + $settings = wp_parse_args($settings, $defaults); |
|
| 117 | + } |
|
| 118 | + return $settings; |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - /** |
|
| 122 | - * @return void |
|
| 123 | - */ |
|
| 124 | - protected function migrateNotificationSettings() |
|
| 125 | - { |
|
| 126 | - $notifications = [ |
|
| 127 | - 'custom' => 'custom', |
|
| 128 | - 'default' => 'admin', |
|
| 129 | - 'webhook' => 'slack', |
|
| 130 | - ]; |
|
| 131 | - $this->newSettings['settings.general.notifications'] = []; |
|
| 132 | - foreach ($notifications as $old => $new) { |
|
| 133 | - if ($this->oldSettings['settings.general.notification'] != $old) { |
|
| 134 | - continue; |
|
| 135 | - } |
|
| 136 | - $this->newSettings['settings.general.notifications'][] = $new; |
|
| 137 | - } |
|
| 138 | - } |
|
| 121 | + /** |
|
| 122 | + * @return void |
|
| 123 | + */ |
|
| 124 | + protected function migrateNotificationSettings() |
|
| 125 | + { |
|
| 126 | + $notifications = [ |
|
| 127 | + 'custom' => 'custom', |
|
| 128 | + 'default' => 'admin', |
|
| 129 | + 'webhook' => 'slack', |
|
| 130 | + ]; |
|
| 131 | + $this->newSettings['settings.general.notifications'] = []; |
|
| 132 | + foreach ($notifications as $old => $new) { |
|
| 133 | + if ($this->oldSettings['settings.general.notification'] != $old) { |
|
| 134 | + continue; |
|
| 135 | + } |
|
| 136 | + $this->newSettings['settings.general.notifications'][] = $new; |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | - /** |
|
| 141 | - * @return void |
|
| 142 | - */ |
|
| 143 | - protected function migrateRecaptchaSettings() |
|
| 144 | - { |
|
| 145 | - $recaptcha = [ |
|
| 146 | - 'BadgePosition' => $this->oldSettings['settings.reviews-form.recaptcha.position'], |
|
| 147 | - 'SecretKey' => $this->oldSettings['settings.reviews-form.recaptcha.secret'], |
|
| 148 | - 'SiteKey' => $this->oldSettings['settings.reviews-form.recaptcha.key'], |
|
| 149 | - ]; |
|
| 150 | - if (in_array($this->oldSettings['settings.reviews-form.recaptcha.integration'], ['custom', 'invisible-recaptcha'])) { |
|
| 151 | - $this->newSettings['settings.submissions.recaptcha.integration'] = 'all'; |
|
| 152 | - } |
|
| 153 | - if ('invisible-recaptcha' == $this->oldSettings['settings.reviews-form.recaptcha.integration']) { |
|
| 154 | - $recaptcha = wp_parse_args((array) get_site_option('ic-settings', [], false), $recaptcha); |
|
| 155 | - } |
|
| 156 | - $this->newSettings['settings.submissions.recaptcha.key'] = $recaptcha['SiteKey']; |
|
| 157 | - $this->newSettings['settings.submissions.recaptcha.secret'] = $recaptcha['SecretKey']; |
|
| 158 | - $this->newSettings['settings.submissions.recaptcha.position'] = $recaptcha['BadgePosition']; |
|
| 159 | - } |
|
| 140 | + /** |
|
| 141 | + * @return void |
|
| 142 | + */ |
|
| 143 | + protected function migrateRecaptchaSettings() |
|
| 144 | + { |
|
| 145 | + $recaptcha = [ |
|
| 146 | + 'BadgePosition' => $this->oldSettings['settings.reviews-form.recaptcha.position'], |
|
| 147 | + 'SecretKey' => $this->oldSettings['settings.reviews-form.recaptcha.secret'], |
|
| 148 | + 'SiteKey' => $this->oldSettings['settings.reviews-form.recaptcha.key'], |
|
| 149 | + ]; |
|
| 150 | + if (in_array($this->oldSettings['settings.reviews-form.recaptcha.integration'], ['custom', 'invisible-recaptcha'])) { |
|
| 151 | + $this->newSettings['settings.submissions.recaptcha.integration'] = 'all'; |
|
| 152 | + } |
|
| 153 | + if ('invisible-recaptcha' == $this->oldSettings['settings.reviews-form.recaptcha.integration']) { |
|
| 154 | + $recaptcha = wp_parse_args((array) get_site_option('ic-settings', [], false), $recaptcha); |
|
| 155 | + } |
|
| 156 | + $this->newSettings['settings.submissions.recaptcha.key'] = $recaptcha['SiteKey']; |
|
| 157 | + $this->newSettings['settings.submissions.recaptcha.secret'] = $recaptcha['SecretKey']; |
|
| 158 | + $this->newSettings['settings.submissions.recaptcha.position'] = $recaptcha['BadgePosition']; |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | - /** |
|
| 162 | - * @return void |
|
| 163 | - */ |
|
| 164 | - protected function migrateRequiredSettings() |
|
| 165 | - { |
|
| 166 | - $this->newSettings['settings.submissions.required'] = array_filter((array) $this->oldSettings['settings.reviews-form.required']); |
|
| 167 | - $this->newSettings['settings.submissions.required'][] = 'rating'; |
|
| 168 | - $this->newSettings['settings.submissions.required'][] = 'terms'; |
|
| 169 | - } |
|
| 161 | + /** |
|
| 162 | + * @return void |
|
| 163 | + */ |
|
| 164 | + protected function migrateRequiredSettings() |
|
| 165 | + { |
|
| 166 | + $this->newSettings['settings.submissions.required'] = array_filter((array) $this->oldSettings['settings.reviews-form.required']); |
|
| 167 | + $this->newSettings['settings.submissions.required'][] = 'rating'; |
|
| 168 | + $this->newSettings['settings.submissions.required'][] = 'terms'; |
|
| 169 | + } |
|
| 170 | 170 | } |
@@ -9,70 +9,70 @@ |
||
| 9 | 9 | |
| 10 | 10 | class Upgrade_4_0_2 |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * @return void |
|
| 14 | - */ |
|
| 15 | - public function deleteSessions() |
|
| 16 | - { |
|
| 17 | - global $wpdb; |
|
| 18 | - $wpdb->query(" |
|
| 12 | + /** |
|
| 13 | + * @return void |
|
| 14 | + */ |
|
| 15 | + public function deleteSessions() |
|
| 16 | + { |
|
| 17 | + global $wpdb; |
|
| 18 | + $wpdb->query(" |
|
| 19 | 19 | DELETE |
| 20 | 20 | FROM {$wpdb->options} |
| 21 | 21 | WHERE option_name LIKE '_glsr_session%' |
| 22 | 22 | "); |
| 23 | - } |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @return void |
|
| 27 | - */ |
|
| 28 | - public function migrateSettings() |
|
| 29 | - { |
|
| 30 | - if ($settings = get_option(OptionManager::databaseKey(3))) { |
|
| 31 | - $multilingual = 'yes' == Arr::get($settings, 'settings.general.support.polylang') |
|
| 32 | - ? 'polylang' |
|
| 33 | - : ''; |
|
| 34 | - $settings = Arr::set($settings, 'settings.general.multilingual', $multilingual); |
|
| 35 | - $settings = Arr::set($settings, 'settings.general.rebusify', 'no'); |
|
| 36 | - $settings = Arr::set($settings, 'settings.general.rebusify_email', ''); |
|
| 37 | - $settings = Arr::set($settings, 'settings.general.rebusify_serial', ''); |
|
| 38 | - $settings = Arr::set($settings, 'settings.reviews.name.format', ''); |
|
| 39 | - $settings = Arr::set($settings, 'settings.reviews.name.initial', ''); |
|
| 40 | - $settings = Arr::set($settings, 'settings.submissions.blacklist.integration', ''); |
|
| 41 | - $settings = Arr::set($settings, 'settings.submissions.limit', ''); |
|
| 42 | - $settings = Arr::set($settings, 'settings.submissions.limit_whitelist.email', ''); |
|
| 43 | - $settings = Arr::set($settings, 'settings.submissions.limit_whitelist.ip_address', ''); |
|
| 44 | - $settings = Arr::set($settings, 'settings.submissions.limit_whitelist.username', ''); |
|
| 45 | - unset($settings['settings']['general']['support']); |
|
| 46 | - update_option(OptionManager::databaseKey(4), $settings); |
|
| 47 | - } |
|
| 48 | - } |
|
| 25 | + /** |
|
| 26 | + * @return void |
|
| 27 | + */ |
|
| 28 | + public function migrateSettings() |
|
| 29 | + { |
|
| 30 | + if ($settings = get_option(OptionManager::databaseKey(3))) { |
|
| 31 | + $multilingual = 'yes' == Arr::get($settings, 'settings.general.support.polylang') |
|
| 32 | + ? 'polylang' |
|
| 33 | + : ''; |
|
| 34 | + $settings = Arr::set($settings, 'settings.general.multilingual', $multilingual); |
|
| 35 | + $settings = Arr::set($settings, 'settings.general.rebusify', 'no'); |
|
| 36 | + $settings = Arr::set($settings, 'settings.general.rebusify_email', ''); |
|
| 37 | + $settings = Arr::set($settings, 'settings.general.rebusify_serial', ''); |
|
| 38 | + $settings = Arr::set($settings, 'settings.reviews.name.format', ''); |
|
| 39 | + $settings = Arr::set($settings, 'settings.reviews.name.initial', ''); |
|
| 40 | + $settings = Arr::set($settings, 'settings.submissions.blacklist.integration', ''); |
|
| 41 | + $settings = Arr::set($settings, 'settings.submissions.limit', ''); |
|
| 42 | + $settings = Arr::set($settings, 'settings.submissions.limit_whitelist.email', ''); |
|
| 43 | + $settings = Arr::set($settings, 'settings.submissions.limit_whitelist.ip_address', ''); |
|
| 44 | + $settings = Arr::set($settings, 'settings.submissions.limit_whitelist.username', ''); |
|
| 45 | + unset($settings['settings']['general']['support']); |
|
| 46 | + update_option(OptionManager::databaseKey(4), $settings); |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @return void |
|
| 52 | - */ |
|
| 53 | - public function protectMetaKeys() |
|
| 54 | - { |
|
| 55 | - global $wpdb; |
|
| 56 | - $keys = array_keys(glsr(CreateReviewDefaults::class)->defaults()); |
|
| 57 | - $keys = implode("','", $keys); |
|
| 58 | - $postType = Application::POST_TYPE; |
|
| 59 | - $wpdb->query(" |
|
| 50 | + /** |
|
| 51 | + * @return void |
|
| 52 | + */ |
|
| 53 | + public function protectMetaKeys() |
|
| 54 | + { |
|
| 55 | + global $wpdb; |
|
| 56 | + $keys = array_keys(glsr(CreateReviewDefaults::class)->defaults()); |
|
| 57 | + $keys = implode("','", $keys); |
|
| 58 | + $postType = Application::POST_TYPE; |
|
| 59 | + $wpdb->query(" |
|
| 60 | 60 | UPDATE {$wpdb->postmeta} pm |
| 61 | 61 | INNER JOIN {$wpdb->posts} p ON p.id = pm.post_id |
| 62 | 62 | SET pm.meta_key = CONCAT('_', pm.meta_key) |
| 63 | 63 | WHERE pm.meta_key IN ('{$keys}') |
| 64 | 64 | AND p.post_type = '{$postType}' |
| 65 | 65 | "); |
| 66 | - } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * @return void |
|
| 70 | - */ |
|
| 71 | - public function run() |
|
| 72 | - { |
|
| 73 | - $this->migrateSettings(); |
|
| 74 | - $this->protectMetaKeys(); |
|
| 75 | - $this->deleteSessions(); |
|
| 76 | - delete_transient(Application::ID.'_cloudflare_ips'); |
|
| 77 | - } |
|
| 68 | + /** |
|
| 69 | + * @return void |
|
| 70 | + */ |
|
| 71 | + public function run() |
|
| 72 | + { |
|
| 73 | + $this->migrateSettings(); |
|
| 74 | + $this->protectMetaKeys(); |
|
| 75 | + $this->deleteSessions(); |
|
| 76 | + delete_transient(Application::ID.'_cloudflare_ips'); |
|
| 77 | + } |
|
| 78 | 78 | } |
@@ -15,11 +15,11 @@ discard block |
||
| 15 | 15 | public function deleteSessions() |
| 16 | 16 | { |
| 17 | 17 | global $wpdb; |
| 18 | - $wpdb->query(" |
|
| 18 | + $wpdb->query( " |
|
| 19 | 19 | DELETE |
| 20 | 20 | FROM {$wpdb->options} |
| 21 | 21 | WHERE option_name LIKE '_glsr_session%' |
| 22 | - "); |
|
| 22 | + " ); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -27,23 +27,23 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | public function migrateSettings() |
| 29 | 29 | { |
| 30 | - if ($settings = get_option(OptionManager::databaseKey(3))) { |
|
| 31 | - $multilingual = 'yes' == Arr::get($settings, 'settings.general.support.polylang') |
|
| 30 | + if( $settings = get_option( OptionManager::databaseKey( 3 ) ) ) { |
|
| 31 | + $multilingual = 'yes' == Arr::get( $settings, 'settings.general.support.polylang' ) |
|
| 32 | 32 | ? 'polylang' |
| 33 | 33 | : ''; |
| 34 | - $settings = Arr::set($settings, 'settings.general.multilingual', $multilingual); |
|
| 35 | - $settings = Arr::set($settings, 'settings.general.rebusify', 'no'); |
|
| 36 | - $settings = Arr::set($settings, 'settings.general.rebusify_email', ''); |
|
| 37 | - $settings = Arr::set($settings, 'settings.general.rebusify_serial', ''); |
|
| 38 | - $settings = Arr::set($settings, 'settings.reviews.name.format', ''); |
|
| 39 | - $settings = Arr::set($settings, 'settings.reviews.name.initial', ''); |
|
| 40 | - $settings = Arr::set($settings, 'settings.submissions.blacklist.integration', ''); |
|
| 41 | - $settings = Arr::set($settings, 'settings.submissions.limit', ''); |
|
| 42 | - $settings = Arr::set($settings, 'settings.submissions.limit_whitelist.email', ''); |
|
| 43 | - $settings = Arr::set($settings, 'settings.submissions.limit_whitelist.ip_address', ''); |
|
| 44 | - $settings = Arr::set($settings, 'settings.submissions.limit_whitelist.username', ''); |
|
| 34 | + $settings = Arr::set( $settings, 'settings.general.multilingual', $multilingual ); |
|
| 35 | + $settings = Arr::set( $settings, 'settings.general.rebusify', 'no' ); |
|
| 36 | + $settings = Arr::set( $settings, 'settings.general.rebusify_email', '' ); |
|
| 37 | + $settings = Arr::set( $settings, 'settings.general.rebusify_serial', '' ); |
|
| 38 | + $settings = Arr::set( $settings, 'settings.reviews.name.format', '' ); |
|
| 39 | + $settings = Arr::set( $settings, 'settings.reviews.name.initial', '' ); |
|
| 40 | + $settings = Arr::set( $settings, 'settings.submissions.blacklist.integration', '' ); |
|
| 41 | + $settings = Arr::set( $settings, 'settings.submissions.limit', '' ); |
|
| 42 | + $settings = Arr::set( $settings, 'settings.submissions.limit_whitelist.email', '' ); |
|
| 43 | + $settings = Arr::set( $settings, 'settings.submissions.limit_whitelist.ip_address', '' ); |
|
| 44 | + $settings = Arr::set( $settings, 'settings.submissions.limit_whitelist.username', '' ); |
|
| 45 | 45 | unset($settings['settings']['general']['support']); |
| 46 | - update_option(OptionManager::databaseKey(4), $settings); |
|
| 46 | + update_option( OptionManager::databaseKey( 4 ), $settings ); |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | |
@@ -53,16 +53,16 @@ discard block |
||
| 53 | 53 | public function protectMetaKeys() |
| 54 | 54 | { |
| 55 | 55 | global $wpdb; |
| 56 | - $keys = array_keys(glsr(CreateReviewDefaults::class)->defaults()); |
|
| 57 | - $keys = implode("','", $keys); |
|
| 56 | + $keys = array_keys( glsr( CreateReviewDefaults::class )->defaults() ); |
|
| 57 | + $keys = implode( "','", $keys ); |
|
| 58 | 58 | $postType = Application::POST_TYPE; |
| 59 | - $wpdb->query(" |
|
| 59 | + $wpdb->query( " |
|
| 60 | 60 | UPDATE {$wpdb->postmeta} pm |
| 61 | 61 | INNER JOIN {$wpdb->posts} p ON p.id = pm.post_id |
| 62 | 62 | SET pm.meta_key = CONCAT('_', pm.meta_key) |
| 63 | 63 | WHERE pm.meta_key IN ('{$keys}') |
| 64 | 64 | AND p.post_type = '{$postType}' |
| 65 | - "); |
|
| 65 | + " ); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -73,6 +73,6 @@ discard block |
||
| 73 | 73 | $this->migrateSettings(); |
| 74 | 74 | $this->protectMetaKeys(); |
| 75 | 75 | $this->deleteSessions(); |
| 76 | - delete_transient(Application::ID.'_cloudflare_ips'); |
|
| 76 | + delete_transient( Application::ID.'_cloudflare_ips' ); |
|
| 77 | 77 | } |
| 78 | 78 | } |
@@ -8,95 +8,95 @@ |
||
| 8 | 8 | |
| 9 | 9 | class Upgrader |
| 10 | 10 | { |
| 11 | - /** |
|
| 12 | - * @return string |
|
| 13 | - */ |
|
| 14 | - public $currentVersion; |
|
| 11 | + /** |
|
| 12 | + * @return string |
|
| 13 | + */ |
|
| 14 | + public $currentVersion; |
|
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * @return void |
|
| 18 | - */ |
|
| 19 | - public function run() |
|
| 20 | - { |
|
| 21 | - $files = $this->getUpgraderFiles(); |
|
| 22 | - $this->currentVersion = $this->currentVersion(); |
|
| 23 | - array_walk($files, function ($file) { |
|
| 24 | - $className = str_replace('.php', '', $file); |
|
| 25 | - $upgradeFromVersion = str_replace(['Upgrade_', '_'], ['', '.'], $className); |
|
| 26 | - $suffix = preg_replace('/[\d.]+(.+)?/', '${1}', glsr()->version); // allow alpha/beta versions |
|
| 27 | - if (version_compare($this->currentVersion, $upgradeFromVersion.$suffix, '>=')) { |
|
| 28 | - return; |
|
| 29 | - } |
|
| 30 | - glsr('Modules\\Upgrader\\'.$className)->run(); |
|
| 31 | - glsr_log()->notice('Completed Upgrade for v'.$upgradeFromVersion.$suffix); |
|
| 32 | - }); |
|
| 33 | - $this->finish(); |
|
| 34 | - } |
|
| 16 | + /** |
|
| 17 | + * @return void |
|
| 18 | + */ |
|
| 19 | + public function run() |
|
| 20 | + { |
|
| 21 | + $files = $this->getUpgraderFiles(); |
|
| 22 | + $this->currentVersion = $this->currentVersion(); |
|
| 23 | + array_walk($files, function ($file) { |
|
| 24 | + $className = str_replace('.php', '', $file); |
|
| 25 | + $upgradeFromVersion = str_replace(['Upgrade_', '_'], ['', '.'], $className); |
|
| 26 | + $suffix = preg_replace('/[\d.]+(.+)?/', '${1}', glsr()->version); // allow alpha/beta versions |
|
| 27 | + if (version_compare($this->currentVersion, $upgradeFromVersion.$suffix, '>=')) { |
|
| 28 | + return; |
|
| 29 | + } |
|
| 30 | + glsr('Modules\\Upgrader\\'.$className)->run(); |
|
| 31 | + glsr_log()->notice('Completed Upgrade for v'.$upgradeFromVersion.$suffix); |
|
| 32 | + }); |
|
| 33 | + $this->finish(); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @return void |
|
| 38 | - */ |
|
| 39 | - public function finish() |
|
| 40 | - { |
|
| 41 | - if ($this->currentVersion !== glsr()->version) { |
|
| 42 | - $this->setReviewCounts(); |
|
| 43 | - $this->updateVersionFrom($this->currentVersion); |
|
| 44 | - } elseif (!glsr(OptionManager::class)->get('last_review_count', false)) { |
|
| 45 | - $this->setReviewCounts(); |
|
| 46 | - } |
|
| 47 | - } |
|
| 36 | + /** |
|
| 37 | + * @return void |
|
| 38 | + */ |
|
| 39 | + public function finish() |
|
| 40 | + { |
|
| 41 | + if ($this->currentVersion !== glsr()->version) { |
|
| 42 | + $this->setReviewCounts(); |
|
| 43 | + $this->updateVersionFrom($this->currentVersion); |
|
| 44 | + } elseif (!glsr(OptionManager::class)->get('last_review_count', false)) { |
|
| 45 | + $this->setReviewCounts(); |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * @return string |
|
| 51 | - */ |
|
| 52 | - protected function currentVersion() |
|
| 53 | - { |
|
| 54 | - $fallback = '0.0.0'; |
|
| 55 | - $majorVersions = [4, 3, 2]; |
|
| 56 | - foreach ($majorVersions as $majorVersion) { |
|
| 57 | - $settings = get_option(OptionManager::databaseKey($majorVersion)); |
|
| 58 | - $version = Arr::get($settings, 'version', $fallback); |
|
| 59 | - if (version_compare($version, $fallback, '>')) { |
|
| 60 | - return $version; |
|
| 61 | - } |
|
| 62 | - } |
|
| 63 | - return $fallback; |
|
| 64 | - } |
|
| 49 | + /** |
|
| 50 | + * @return string |
|
| 51 | + */ |
|
| 52 | + protected function currentVersion() |
|
| 53 | + { |
|
| 54 | + $fallback = '0.0.0'; |
|
| 55 | + $majorVersions = [4, 3, 2]; |
|
| 56 | + foreach ($majorVersions as $majorVersion) { |
|
| 57 | + $settings = get_option(OptionManager::databaseKey($majorVersion)); |
|
| 58 | + $version = Arr::get($settings, 'version', $fallback); |
|
| 59 | + if (version_compare($version, $fallback, '>')) { |
|
| 60 | + return $version; |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + return $fallback; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * @return array |
|
| 68 | - */ |
|
| 69 | - protected function getUpgraderFiles() |
|
| 70 | - { |
|
| 71 | - $files = []; |
|
| 72 | - $upgradeDir = dirname(__FILE__).'/Upgrades'; |
|
| 73 | - if (is_dir($upgradeDir)) { |
|
| 74 | - $iterator = new DirectoryIterator($upgradeDir); |
|
| 75 | - foreach ($iterator as $fileinfo) { |
|
| 76 | - if ($fileinfo->isFile()) { |
|
| 77 | - $files[] = $fileinfo->getFilename(); |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - natsort($files); |
|
| 81 | - } |
|
| 82 | - return $files; |
|
| 83 | - } |
|
| 66 | + /** |
|
| 67 | + * @return array |
|
| 68 | + */ |
|
| 69 | + protected function getUpgraderFiles() |
|
| 70 | + { |
|
| 71 | + $files = []; |
|
| 72 | + $upgradeDir = dirname(__FILE__).'/Upgrades'; |
|
| 73 | + if (is_dir($upgradeDir)) { |
|
| 74 | + $iterator = new DirectoryIterator($upgradeDir); |
|
| 75 | + foreach ($iterator as $fileinfo) { |
|
| 76 | + if ($fileinfo->isFile()) { |
|
| 77 | + $files[] = $fileinfo->getFilename(); |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + natsort($files); |
|
| 81 | + } |
|
| 82 | + return $files; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * @return void |
|
| 87 | - */ |
|
| 88 | - protected function setReviewCounts() |
|
| 89 | - { |
|
| 90 | - add_action('admin_init', 'glsr_calculate_ratings'); |
|
| 91 | - } |
|
| 85 | + /** |
|
| 86 | + * @return void |
|
| 87 | + */ |
|
| 88 | + protected function setReviewCounts() |
|
| 89 | + { |
|
| 90 | + add_action('admin_init', 'glsr_calculate_ratings'); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * @param string $previousVersion |
|
| 95 | - * @return void |
|
| 96 | - */ |
|
| 97 | - protected function updateVersionFrom($previousVersion) |
|
| 98 | - { |
|
| 99 | - glsr(OptionManager::class)->set('version', glsr()->version); |
|
| 100 | - glsr(OptionManager::class)->set('version_upgraded_from', $previousVersion); |
|
| 101 | - } |
|
| 93 | + /** |
|
| 94 | + * @param string $previousVersion |
|
| 95 | + * @return void |
|
| 96 | + */ |
|
| 97 | + protected function updateVersionFrom($previousVersion) |
|
| 98 | + { |
|
| 99 | + glsr(OptionManager::class)->set('version', glsr()->version); |
|
| 100 | + glsr(OptionManager::class)->set('version_upgraded_from', $previousVersion); |
|
| 101 | + } |
|
| 102 | 102 | } |
@@ -20,15 +20,15 @@ discard block |
||
| 20 | 20 | { |
| 21 | 21 | $files = $this->getUpgraderFiles(); |
| 22 | 22 | $this->currentVersion = $this->currentVersion(); |
| 23 | - array_walk($files, function ($file) { |
|
| 24 | - $className = str_replace('.php', '', $file); |
|
| 25 | - $upgradeFromVersion = str_replace(['Upgrade_', '_'], ['', '.'], $className); |
|
| 26 | - $suffix = preg_replace('/[\d.]+(.+)?/', '${1}', glsr()->version); // allow alpha/beta versions |
|
| 27 | - if (version_compare($this->currentVersion, $upgradeFromVersion.$suffix, '>=')) { |
|
| 23 | + array_walk( $files, function( $file ) { |
|
| 24 | + $className = str_replace( '.php', '', $file ); |
|
| 25 | + $upgradeFromVersion = str_replace( ['Upgrade_', '_'], ['', '.'], $className ); |
|
| 26 | + $suffix = preg_replace( '/[\d.]+(.+)?/', '${1}', glsr()->version ); // allow alpha/beta versions |
|
| 27 | + if( version_compare( $this->currentVersion, $upgradeFromVersion.$suffix, '>=' ) ) { |
|
| 28 | 28 | return; |
| 29 | 29 | } |
| 30 | - glsr('Modules\\Upgrader\\'.$className)->run(); |
|
| 31 | - glsr_log()->notice('Completed Upgrade for v'.$upgradeFromVersion.$suffix); |
|
| 30 | + glsr( 'Modules\\Upgrader\\'.$className )->run(); |
|
| 31 | + glsr_log()->notice( 'Completed Upgrade for v'.$upgradeFromVersion.$suffix ); |
|
| 32 | 32 | }); |
| 33 | 33 | $this->finish(); |
| 34 | 34 | } |
@@ -38,10 +38,10 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function finish() |
| 40 | 40 | { |
| 41 | - if ($this->currentVersion !== glsr()->version) { |
|
| 41 | + if( $this->currentVersion !== glsr()->version ) { |
|
| 42 | 42 | $this->setReviewCounts(); |
| 43 | - $this->updateVersionFrom($this->currentVersion); |
|
| 44 | - } elseif (!glsr(OptionManager::class)->get('last_review_count', false)) { |
|
| 43 | + $this->updateVersionFrom( $this->currentVersion ); |
|
| 44 | + } elseif( !glsr( OptionManager::class )->get( 'last_review_count', false ) ) { |
|
| 45 | 45 | $this->setReviewCounts(); |
| 46 | 46 | } |
| 47 | 47 | } |
@@ -53,10 +53,10 @@ discard block |
||
| 53 | 53 | { |
| 54 | 54 | $fallback = '0.0.0'; |
| 55 | 55 | $majorVersions = [4, 3, 2]; |
| 56 | - foreach ($majorVersions as $majorVersion) { |
|
| 57 | - $settings = get_option(OptionManager::databaseKey($majorVersion)); |
|
| 58 | - $version = Arr::get($settings, 'version', $fallback); |
|
| 59 | - if (version_compare($version, $fallback, '>')) { |
|
| 56 | + foreach( $majorVersions as $majorVersion ) { |
|
| 57 | + $settings = get_option( OptionManager::databaseKey( $majorVersion ) ); |
|
| 58 | + $version = Arr::get( $settings, 'version', $fallback ); |
|
| 59 | + if( version_compare( $version, $fallback, '>' ) ) { |
|
| 60 | 60 | return $version; |
| 61 | 61 | } |
| 62 | 62 | } |
@@ -69,15 +69,15 @@ discard block |
||
| 69 | 69 | protected function getUpgraderFiles() |
| 70 | 70 | { |
| 71 | 71 | $files = []; |
| 72 | - $upgradeDir = dirname(__FILE__).'/Upgrades'; |
|
| 73 | - if (is_dir($upgradeDir)) { |
|
| 74 | - $iterator = new DirectoryIterator($upgradeDir); |
|
| 75 | - foreach ($iterator as $fileinfo) { |
|
| 76 | - if ($fileinfo->isFile()) { |
|
| 72 | + $upgradeDir = dirname( __FILE__ ).'/Upgrades'; |
|
| 73 | + if( is_dir( $upgradeDir ) ) { |
|
| 74 | + $iterator = new DirectoryIterator( $upgradeDir ); |
|
| 75 | + foreach( $iterator as $fileinfo ) { |
|
| 76 | + if( $fileinfo->isFile() ) { |
|
| 77 | 77 | $files[] = $fileinfo->getFilename(); |
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | - natsort($files); |
|
| 80 | + natsort( $files ); |
|
| 81 | 81 | } |
| 82 | 82 | return $files; |
| 83 | 83 | } |
@@ -87,16 +87,16 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | protected function setReviewCounts() |
| 89 | 89 | { |
| 90 | - add_action('admin_init', 'glsr_calculate_ratings'); |
|
| 90 | + add_action( 'admin_init', 'glsr_calculate_ratings' ); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
| 94 | 94 | * @param string $previousVersion |
| 95 | 95 | * @return void |
| 96 | 96 | */ |
| 97 | - protected function updateVersionFrom($previousVersion) |
|
| 97 | + protected function updateVersionFrom( $previousVersion ) |
|
| 98 | 98 | { |
| 99 | - glsr(OptionManager::class)->set('version', glsr()->version); |
|
| 100 | - glsr(OptionManager::class)->set('version_upgraded_from', $previousVersion); |
|
| 99 | + glsr( OptionManager::class )->set( 'version', glsr()->version ); |
|
| 100 | + glsr( OptionManager::class )->set( 'version_upgraded_from', $previousVersion ); |
|
| 101 | 101 | } |
| 102 | 102 | } |
@@ -17,231 +17,231 @@ |
||
| 17 | 17 | |
| 18 | 18 | class AdminController extends Controller |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * @return void |
|
| 22 | - * @action admin_enqueue_scripts |
|
| 23 | - */ |
|
| 24 | - public function enqueueAssets() |
|
| 25 | - { |
|
| 26 | - $command = new EnqueueAdminAssets([ |
|
| 27 | - 'pointers' => [[ |
|
| 28 | - 'content' => __('You can pin exceptional reviews so that they are always shown first.', 'site-reviews'), |
|
| 29 | - 'id' => 'glsr-pointer-pinned', |
|
| 30 | - 'position' => [ |
|
| 31 | - 'edge' => 'right', |
|
| 32 | - 'align' => 'middle', |
|
| 33 | - ], |
|
| 34 | - 'screen' => Application::POST_TYPE, |
|
| 35 | - 'target' => '#misc-pub-pinned', |
|
| 36 | - 'title' => __('Pin Your Reviews', 'site-reviews'), |
|
| 37 | - ]], |
|
| 38 | - ]); |
|
| 39 | - $this->execute($command); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @return array |
|
| 44 | - * @filter plugin_action_links_site-reviews/site-reviews.php |
|
| 45 | - */ |
|
| 46 | - public function filterActionLinks(array $links) |
|
| 47 | - { |
|
| 48 | - $links['documentation'] = glsr(Builder::class)->a(__('Help', 'site-reviews'), [ |
|
| 49 | - 'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=documentation'), |
|
| 50 | - ]); |
|
| 51 | - $links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [ |
|
| 52 | - 'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=settings'), |
|
| 53 | - ]); |
|
| 54 | - return $links; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * @param array $capabilities |
|
| 59 | - * @param string $capability |
|
| 60 | - * @return array |
|
| 61 | - * @filter map_meta_cap |
|
| 62 | - */ |
|
| 63 | - public function filterCreateCapability($capabilities, $capability) |
|
| 64 | - { |
|
| 65 | - if ($capability == 'create_'.Application::POST_TYPE) { |
|
| 66 | - $capabilities[] = 'do_not_allow'; |
|
| 67 | - } |
|
| 68 | - return $capabilities; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * @param array $items |
|
| 73 | - * @return array |
|
| 74 | - * @filter dashboard_glance_items |
|
| 75 | - */ |
|
| 76 | - public function filterDashboardGlanceItems($items) |
|
| 77 | - { |
|
| 78 | - $postCount = wp_count_posts(Application::POST_TYPE); |
|
| 79 | - if (empty($postCount->publish)) { |
|
| 80 | - return $items; |
|
| 81 | - } |
|
| 82 | - $text = _n('%s Review', '%s Reviews', $postCount->publish, 'site-reviews'); |
|
| 83 | - $text = sprintf($text, number_format_i18n($postCount->publish)); |
|
| 84 | - $items = Arr::consolidateArray($items); |
|
| 85 | - $items[] = current_user_can(get_post_type_object(Application::POST_TYPE)->cap->edit_posts) |
|
| 86 | - ? glsr(Builder::class)->a($text, [ |
|
| 87 | - 'class' => 'glsr-review-count', |
|
| 88 | - 'href' => 'edit.php?post_type='.Application::POST_TYPE, |
|
| 89 | - ]) |
|
| 90 | - : glsr(Builder::class)->span($text, [ |
|
| 91 | - 'class' => 'glsr-review-count', |
|
| 92 | - ]); |
|
| 93 | - return $items; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * @param array $plugins |
|
| 98 | - * @return array |
|
| 99 | - * @filter mce_external_plugins |
|
| 100 | - */ |
|
| 101 | - public function filterTinymcePlugins($plugins) |
|
| 102 | - { |
|
| 103 | - if (current_user_can('edit_posts') || current_user_can('edit_pages')) { |
|
| 104 | - $plugins = Arr::consolidateArray($plugins); |
|
| 105 | - $plugins['glsr_shortcode'] = glsr()->url('assets/scripts/mce-plugin.js'); |
|
| 106 | - } |
|
| 107 | - return $plugins; |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * @return void |
|
| 112 | - * @action admin_init |
|
| 113 | - */ |
|
| 114 | - public function registerTinymcePopups() |
|
| 115 | - { |
|
| 116 | - $command = new RegisterTinymcePopups([ |
|
| 117 | - 'site_reviews' => esc_html__('Recent Reviews', 'site-reviews'), |
|
| 118 | - 'site_reviews_form' => esc_html__('Submit a Review', 'site-reviews'), |
|
| 119 | - 'site_reviews_summary' => esc_html__('Summary of Reviews', 'site-reviews'), |
|
| 120 | - ]); |
|
| 121 | - $this->execute($command); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * @param string $editorId |
|
| 126 | - * @return void|null |
|
| 127 | - * @action media_buttons |
|
| 128 | - */ |
|
| 129 | - public function renderTinymceButton($editorId) |
|
| 130 | - { |
|
| 131 | - $allowedEditors = apply_filters('site-reviews/tinymce/editor-ids', ['content'], $editorId); |
|
| 132 | - if ('post' != glsr_current_screen()->base || !in_array($editorId, $allowedEditors)) { |
|
| 133 | - return; |
|
| 134 | - } |
|
| 135 | - $shortcodes = []; |
|
| 136 | - foreach (glsr()->mceShortcodes as $shortcode => $values) { |
|
| 137 | - $shortcodes[$shortcode] = $values; |
|
| 138 | - } |
|
| 139 | - if (empty($shortcodes)) { |
|
| 140 | - return; |
|
| 141 | - } |
|
| 142 | - glsr()->render('partials/editor/tinymce', [ |
|
| 143 | - 'shortcodes' => $shortcodes, |
|
| 144 | - ]); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - /** |
|
| 148 | - * @return void |
|
| 149 | - */ |
|
| 150 | - public function routerClearConsole() |
|
| 151 | - { |
|
| 152 | - glsr(Console::class)->clear(); |
|
| 153 | - glsr(Notice::class)->addSuccess(__('Console cleared.', 'site-reviews')); |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * @return void |
|
| 158 | - */ |
|
| 159 | - public function routerFetchConsole() |
|
| 160 | - { |
|
| 161 | - glsr(Notice::class)->addSuccess(__('Console reloaded.', 'site-reviews')); |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * @param bool $showNotice |
|
| 166 | - * @return void |
|
| 167 | - */ |
|
| 168 | - public function routerCountReviews($showNotice = true) |
|
| 169 | - { |
|
| 170 | - glsr(CountsManager::class)->updateAll(); |
|
| 171 | - glsr(OptionManager::class)->set('last_review_count', current_time('timestamp')); |
|
| 172 | - if ($showNotice) { |
|
| 173 | - glsr(Notice::class)->clear()->addSuccess(__('Recalculated rating counts.', 'site-reviews')); |
|
| 174 | - } |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * @return void |
|
| 179 | - */ |
|
| 180 | - public function routerMigrateReviews() |
|
| 181 | - { |
|
| 182 | - glsr(Upgrade_4_0_2::class)->protectMetaKeys(); |
|
| 183 | - glsr(Notice::class)->clear()->addSuccess(__('All reviews have been migrated.', 'site-reviews')); |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * @return void |
|
| 188 | - */ |
|
| 189 | - public function routerDownloadConsole() |
|
| 190 | - { |
|
| 191 | - $this->download(Application::ID.'-console.txt', glsr(Console::class)->get()); |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - /** |
|
| 195 | - * @return void |
|
| 196 | - */ |
|
| 197 | - public function routerDownloadSystemInfo() |
|
| 198 | - { |
|
| 199 | - $this->download(Application::ID.'-system-info.txt', glsr(System::class)->get()); |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - /** |
|
| 203 | - * @return void |
|
| 204 | - */ |
|
| 205 | - public function routerExportSettings() |
|
| 206 | - { |
|
| 207 | - $this->download(Application::ID.'-settings.json', glsr(OptionManager::class)->json()); |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - /** |
|
| 211 | - * @return void |
|
| 212 | - */ |
|
| 213 | - public function routerImportSettings() |
|
| 214 | - { |
|
| 215 | - $file = $_FILES['import-file']; |
|
| 216 | - if (UPLOAD_ERR_OK !== $file['error']) { |
|
| 217 | - return glsr(Notice::class)->addError($this->getUploadError($file['error'])); |
|
| 218 | - } |
|
| 219 | - if ('application/json' !== $file['type'] || !Str::endsWith('.json', $file['name'])) { |
|
| 220 | - return glsr(Notice::class)->addError(__('Please use a valid Site Reviews settings file.', 'site-reviews')); |
|
| 221 | - } |
|
| 222 | - $settings = json_decode(file_get_contents($file['tmp_name']), true); |
|
| 223 | - if (empty($settings)) { |
|
| 224 | - return glsr(Notice::class)->addWarning(__('There were no settings found to import.', 'site-reviews')); |
|
| 225 | - } |
|
| 226 | - glsr(OptionManager::class)->set(glsr(OptionManager::class)->normalize($settings)); |
|
| 227 | - glsr(Notice::class)->addSuccess(__('Settings imported.', 'site-reviews')); |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * @param int $errorCode |
|
| 232 | - * @return string |
|
| 233 | - */ |
|
| 234 | - protected function getUploadError($errorCode) |
|
| 235 | - { |
|
| 236 | - $errors = [ |
|
| 237 | - UPLOAD_ERR_INI_SIZE => __('The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews'), |
|
| 238 | - UPLOAD_ERR_FORM_SIZE => __('The uploaded file is too big.', 'site-reviews'), |
|
| 239 | - UPLOAD_ERR_PARTIAL => __('The uploaded file was only partially uploaded.', 'site-reviews'), |
|
| 240 | - UPLOAD_ERR_NO_FILE => __('No file was uploaded.', 'site-reviews'), |
|
| 241 | - UPLOAD_ERR_NO_TMP_DIR => __('Missing a temporary folder.', 'site-reviews'), |
|
| 242 | - UPLOAD_ERR_CANT_WRITE => __('Failed to write file to disk.', 'site-reviews'), |
|
| 243 | - UPLOAD_ERR_EXTENSION => __('A PHP extension stopped the file upload.', 'site-reviews'), |
|
| 244 | - ]; |
|
| 245 | - return Arr::get($errors, $errorCode, __('Unknown upload error.', 'site-reviews')); |
|
| 246 | - } |
|
| 20 | + /** |
|
| 21 | + * @return void |
|
| 22 | + * @action admin_enqueue_scripts |
|
| 23 | + */ |
|
| 24 | + public function enqueueAssets() |
|
| 25 | + { |
|
| 26 | + $command = new EnqueueAdminAssets([ |
|
| 27 | + 'pointers' => [[ |
|
| 28 | + 'content' => __('You can pin exceptional reviews so that they are always shown first.', 'site-reviews'), |
|
| 29 | + 'id' => 'glsr-pointer-pinned', |
|
| 30 | + 'position' => [ |
|
| 31 | + 'edge' => 'right', |
|
| 32 | + 'align' => 'middle', |
|
| 33 | + ], |
|
| 34 | + 'screen' => Application::POST_TYPE, |
|
| 35 | + 'target' => '#misc-pub-pinned', |
|
| 36 | + 'title' => __('Pin Your Reviews', 'site-reviews'), |
|
| 37 | + ]], |
|
| 38 | + ]); |
|
| 39 | + $this->execute($command); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @return array |
|
| 44 | + * @filter plugin_action_links_site-reviews/site-reviews.php |
|
| 45 | + */ |
|
| 46 | + public function filterActionLinks(array $links) |
|
| 47 | + { |
|
| 48 | + $links['documentation'] = glsr(Builder::class)->a(__('Help', 'site-reviews'), [ |
|
| 49 | + 'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=documentation'), |
|
| 50 | + ]); |
|
| 51 | + $links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [ |
|
| 52 | + 'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=settings'), |
|
| 53 | + ]); |
|
| 54 | + return $links; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * @param array $capabilities |
|
| 59 | + * @param string $capability |
|
| 60 | + * @return array |
|
| 61 | + * @filter map_meta_cap |
|
| 62 | + */ |
|
| 63 | + public function filterCreateCapability($capabilities, $capability) |
|
| 64 | + { |
|
| 65 | + if ($capability == 'create_'.Application::POST_TYPE) { |
|
| 66 | + $capabilities[] = 'do_not_allow'; |
|
| 67 | + } |
|
| 68 | + return $capabilities; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * @param array $items |
|
| 73 | + * @return array |
|
| 74 | + * @filter dashboard_glance_items |
|
| 75 | + */ |
|
| 76 | + public function filterDashboardGlanceItems($items) |
|
| 77 | + { |
|
| 78 | + $postCount = wp_count_posts(Application::POST_TYPE); |
|
| 79 | + if (empty($postCount->publish)) { |
|
| 80 | + return $items; |
|
| 81 | + } |
|
| 82 | + $text = _n('%s Review', '%s Reviews', $postCount->publish, 'site-reviews'); |
|
| 83 | + $text = sprintf($text, number_format_i18n($postCount->publish)); |
|
| 84 | + $items = Arr::consolidateArray($items); |
|
| 85 | + $items[] = current_user_can(get_post_type_object(Application::POST_TYPE)->cap->edit_posts) |
|
| 86 | + ? glsr(Builder::class)->a($text, [ |
|
| 87 | + 'class' => 'glsr-review-count', |
|
| 88 | + 'href' => 'edit.php?post_type='.Application::POST_TYPE, |
|
| 89 | + ]) |
|
| 90 | + : glsr(Builder::class)->span($text, [ |
|
| 91 | + 'class' => 'glsr-review-count', |
|
| 92 | + ]); |
|
| 93 | + return $items; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * @param array $plugins |
|
| 98 | + * @return array |
|
| 99 | + * @filter mce_external_plugins |
|
| 100 | + */ |
|
| 101 | + public function filterTinymcePlugins($plugins) |
|
| 102 | + { |
|
| 103 | + if (current_user_can('edit_posts') || current_user_can('edit_pages')) { |
|
| 104 | + $plugins = Arr::consolidateArray($plugins); |
|
| 105 | + $plugins['glsr_shortcode'] = glsr()->url('assets/scripts/mce-plugin.js'); |
|
| 106 | + } |
|
| 107 | + return $plugins; |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * @return void |
|
| 112 | + * @action admin_init |
|
| 113 | + */ |
|
| 114 | + public function registerTinymcePopups() |
|
| 115 | + { |
|
| 116 | + $command = new RegisterTinymcePopups([ |
|
| 117 | + 'site_reviews' => esc_html__('Recent Reviews', 'site-reviews'), |
|
| 118 | + 'site_reviews_form' => esc_html__('Submit a Review', 'site-reviews'), |
|
| 119 | + 'site_reviews_summary' => esc_html__('Summary of Reviews', 'site-reviews'), |
|
| 120 | + ]); |
|
| 121 | + $this->execute($command); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * @param string $editorId |
|
| 126 | + * @return void|null |
|
| 127 | + * @action media_buttons |
|
| 128 | + */ |
|
| 129 | + public function renderTinymceButton($editorId) |
|
| 130 | + { |
|
| 131 | + $allowedEditors = apply_filters('site-reviews/tinymce/editor-ids', ['content'], $editorId); |
|
| 132 | + if ('post' != glsr_current_screen()->base || !in_array($editorId, $allowedEditors)) { |
|
| 133 | + return; |
|
| 134 | + } |
|
| 135 | + $shortcodes = []; |
|
| 136 | + foreach (glsr()->mceShortcodes as $shortcode => $values) { |
|
| 137 | + $shortcodes[$shortcode] = $values; |
|
| 138 | + } |
|
| 139 | + if (empty($shortcodes)) { |
|
| 140 | + return; |
|
| 141 | + } |
|
| 142 | + glsr()->render('partials/editor/tinymce', [ |
|
| 143 | + 'shortcodes' => $shortcodes, |
|
| 144 | + ]); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + /** |
|
| 148 | + * @return void |
|
| 149 | + */ |
|
| 150 | + public function routerClearConsole() |
|
| 151 | + { |
|
| 152 | + glsr(Console::class)->clear(); |
|
| 153 | + glsr(Notice::class)->addSuccess(__('Console cleared.', 'site-reviews')); |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * @return void |
|
| 158 | + */ |
|
| 159 | + public function routerFetchConsole() |
|
| 160 | + { |
|
| 161 | + glsr(Notice::class)->addSuccess(__('Console reloaded.', 'site-reviews')); |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * @param bool $showNotice |
|
| 166 | + * @return void |
|
| 167 | + */ |
|
| 168 | + public function routerCountReviews($showNotice = true) |
|
| 169 | + { |
|
| 170 | + glsr(CountsManager::class)->updateAll(); |
|
| 171 | + glsr(OptionManager::class)->set('last_review_count', current_time('timestamp')); |
|
| 172 | + if ($showNotice) { |
|
| 173 | + glsr(Notice::class)->clear()->addSuccess(__('Recalculated rating counts.', 'site-reviews')); |
|
| 174 | + } |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * @return void |
|
| 179 | + */ |
|
| 180 | + public function routerMigrateReviews() |
|
| 181 | + { |
|
| 182 | + glsr(Upgrade_4_0_2::class)->protectMetaKeys(); |
|
| 183 | + glsr(Notice::class)->clear()->addSuccess(__('All reviews have been migrated.', 'site-reviews')); |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * @return void |
|
| 188 | + */ |
|
| 189 | + public function routerDownloadConsole() |
|
| 190 | + { |
|
| 191 | + $this->download(Application::ID.'-console.txt', glsr(Console::class)->get()); |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + /** |
|
| 195 | + * @return void |
|
| 196 | + */ |
|
| 197 | + public function routerDownloadSystemInfo() |
|
| 198 | + { |
|
| 199 | + $this->download(Application::ID.'-system-info.txt', glsr(System::class)->get()); |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * @return void |
|
| 204 | + */ |
|
| 205 | + public function routerExportSettings() |
|
| 206 | + { |
|
| 207 | + $this->download(Application::ID.'-settings.json', glsr(OptionManager::class)->json()); |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + /** |
|
| 211 | + * @return void |
|
| 212 | + */ |
|
| 213 | + public function routerImportSettings() |
|
| 214 | + { |
|
| 215 | + $file = $_FILES['import-file']; |
|
| 216 | + if (UPLOAD_ERR_OK !== $file['error']) { |
|
| 217 | + return glsr(Notice::class)->addError($this->getUploadError($file['error'])); |
|
| 218 | + } |
|
| 219 | + if ('application/json' !== $file['type'] || !Str::endsWith('.json', $file['name'])) { |
|
| 220 | + return glsr(Notice::class)->addError(__('Please use a valid Site Reviews settings file.', 'site-reviews')); |
|
| 221 | + } |
|
| 222 | + $settings = json_decode(file_get_contents($file['tmp_name']), true); |
|
| 223 | + if (empty($settings)) { |
|
| 224 | + return glsr(Notice::class)->addWarning(__('There were no settings found to import.', 'site-reviews')); |
|
| 225 | + } |
|
| 226 | + glsr(OptionManager::class)->set(glsr(OptionManager::class)->normalize($settings)); |
|
| 227 | + glsr(Notice::class)->addSuccess(__('Settings imported.', 'site-reviews')); |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * @param int $errorCode |
|
| 232 | + * @return string |
|
| 233 | + */ |
|
| 234 | + protected function getUploadError($errorCode) |
|
| 235 | + { |
|
| 236 | + $errors = [ |
|
| 237 | + UPLOAD_ERR_INI_SIZE => __('The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews'), |
|
| 238 | + UPLOAD_ERR_FORM_SIZE => __('The uploaded file is too big.', 'site-reviews'), |
|
| 239 | + UPLOAD_ERR_PARTIAL => __('The uploaded file was only partially uploaded.', 'site-reviews'), |
|
| 240 | + UPLOAD_ERR_NO_FILE => __('No file was uploaded.', 'site-reviews'), |
|
| 241 | + UPLOAD_ERR_NO_TMP_DIR => __('Missing a temporary folder.', 'site-reviews'), |
|
| 242 | + UPLOAD_ERR_CANT_WRITE => __('Failed to write file to disk.', 'site-reviews'), |
|
| 243 | + UPLOAD_ERR_EXTENSION => __('A PHP extension stopped the file upload.', 'site-reviews'), |
|
| 244 | + ]; |
|
| 245 | + return Arr::get($errors, $errorCode, __('Unknown upload error.', 'site-reviews')); |
|
| 246 | + } |
|
| 247 | 247 | } |
@@ -23,9 +23,9 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public function enqueueAssets() |
| 25 | 25 | { |
| 26 | - $command = new EnqueueAdminAssets([ |
|
| 26 | + $command = new EnqueueAdminAssets( [ |
|
| 27 | 27 | 'pointers' => [[ |
| 28 | - 'content' => __('You can pin exceptional reviews so that they are always shown first.', 'site-reviews'), |
|
| 28 | + 'content' => __( 'You can pin exceptional reviews so that they are always shown first.', 'site-reviews' ), |
|
| 29 | 29 | 'id' => 'glsr-pointer-pinned', |
| 30 | 30 | 'position' => [ |
| 31 | 31 | 'edge' => 'right', |
@@ -33,24 +33,24 @@ discard block |
||
| 33 | 33 | ], |
| 34 | 34 | 'screen' => Application::POST_TYPE, |
| 35 | 35 | 'target' => '#misc-pub-pinned', |
| 36 | - 'title' => __('Pin Your Reviews', 'site-reviews'), |
|
| 36 | + 'title' => __( 'Pin Your Reviews', 'site-reviews' ), |
|
| 37 | 37 | ]], |
| 38 | - ]); |
|
| 39 | - $this->execute($command); |
|
| 38 | + ] ); |
|
| 39 | + $this->execute( $command ); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * @return array |
| 44 | 44 | * @filter plugin_action_links_site-reviews/site-reviews.php |
| 45 | 45 | */ |
| 46 | - public function filterActionLinks(array $links) |
|
| 46 | + public function filterActionLinks( array $links ) |
|
| 47 | 47 | { |
| 48 | - $links['documentation'] = glsr(Builder::class)->a(__('Help', 'site-reviews'), [ |
|
| 49 | - 'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=documentation'), |
|
| 50 | - ]); |
|
| 51 | - $links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [ |
|
| 52 | - 'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=settings'), |
|
| 53 | - ]); |
|
| 48 | + $links['documentation'] = glsr( Builder::class )->a( __( 'Help', 'site-reviews' ), [ |
|
| 49 | + 'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=documentation' ), |
|
| 50 | + ] ); |
|
| 51 | + $links['settings'] = glsr( Builder::class )->a( __( 'Settings', 'site-reviews' ), [ |
|
| 52 | + 'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=settings' ), |
|
| 53 | + ] ); |
|
| 54 | 54 | return $links; |
| 55 | 55 | } |
| 56 | 56 | |
@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | * @return array |
| 61 | 61 | * @filter map_meta_cap |
| 62 | 62 | */ |
| 63 | - public function filterCreateCapability($capabilities, $capability) |
|
| 63 | + public function filterCreateCapability( $capabilities, $capability ) |
|
| 64 | 64 | { |
| 65 | - if ($capability == 'create_'.Application::POST_TYPE) { |
|
| 65 | + if( $capability == 'create_'.Application::POST_TYPE ) { |
|
| 66 | 66 | $capabilities[] = 'do_not_allow'; |
| 67 | 67 | } |
| 68 | 68 | return $capabilities; |
@@ -73,23 +73,23 @@ discard block |
||
| 73 | 73 | * @return array |
| 74 | 74 | * @filter dashboard_glance_items |
| 75 | 75 | */ |
| 76 | - public function filterDashboardGlanceItems($items) |
|
| 76 | + public function filterDashboardGlanceItems( $items ) |
|
| 77 | 77 | { |
| 78 | - $postCount = wp_count_posts(Application::POST_TYPE); |
|
| 79 | - if (empty($postCount->publish)) { |
|
| 78 | + $postCount = wp_count_posts( Application::POST_TYPE ); |
|
| 79 | + if( empty($postCount->publish) ) { |
|
| 80 | 80 | return $items; |
| 81 | 81 | } |
| 82 | - $text = _n('%s Review', '%s Reviews', $postCount->publish, 'site-reviews'); |
|
| 83 | - $text = sprintf($text, number_format_i18n($postCount->publish)); |
|
| 84 | - $items = Arr::consolidateArray($items); |
|
| 85 | - $items[] = current_user_can(get_post_type_object(Application::POST_TYPE)->cap->edit_posts) |
|
| 86 | - ? glsr(Builder::class)->a($text, [ |
|
| 82 | + $text = _n( '%s Review', '%s Reviews', $postCount->publish, 'site-reviews' ); |
|
| 83 | + $text = sprintf( $text, number_format_i18n( $postCount->publish ) ); |
|
| 84 | + $items = Arr::consolidateArray( $items ); |
|
| 85 | + $items[] = current_user_can( get_post_type_object( Application::POST_TYPE )->cap->edit_posts ) |
|
| 86 | + ? glsr( Builder::class )->a( $text, [ |
|
| 87 | 87 | 'class' => 'glsr-review-count', |
| 88 | 88 | 'href' => 'edit.php?post_type='.Application::POST_TYPE, |
| 89 | - ]) |
|
| 90 | - : glsr(Builder::class)->span($text, [ |
|
| 89 | + ] ) |
|
| 90 | + : glsr( Builder::class )->span( $text, [ |
|
| 91 | 91 | 'class' => 'glsr-review-count', |
| 92 | - ]); |
|
| 92 | + ] ); |
|
| 93 | 93 | return $items; |
| 94 | 94 | } |
| 95 | 95 | |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | * @return array |
| 99 | 99 | * @filter mce_external_plugins |
| 100 | 100 | */ |
| 101 | - public function filterTinymcePlugins($plugins) |
|
| 101 | + public function filterTinymcePlugins( $plugins ) |
|
| 102 | 102 | { |
| 103 | - if (current_user_can('edit_posts') || current_user_can('edit_pages')) { |
|
| 104 | - $plugins = Arr::consolidateArray($plugins); |
|
| 105 | - $plugins['glsr_shortcode'] = glsr()->url('assets/scripts/mce-plugin.js'); |
|
| 103 | + if( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) { |
|
| 104 | + $plugins = Arr::consolidateArray( $plugins ); |
|
| 105 | + $plugins['glsr_shortcode'] = glsr()->url( 'assets/scripts/mce-plugin.js' ); |
|
| 106 | 106 | } |
| 107 | 107 | return $plugins; |
| 108 | 108 | } |
@@ -113,12 +113,12 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function registerTinymcePopups() |
| 115 | 115 | { |
| 116 | - $command = new RegisterTinymcePopups([ |
|
| 117 | - 'site_reviews' => esc_html__('Recent Reviews', 'site-reviews'), |
|
| 118 | - 'site_reviews_form' => esc_html__('Submit a Review', 'site-reviews'), |
|
| 119 | - 'site_reviews_summary' => esc_html__('Summary of Reviews', 'site-reviews'), |
|
| 120 | - ]); |
|
| 121 | - $this->execute($command); |
|
| 116 | + $command = new RegisterTinymcePopups( [ |
|
| 117 | + 'site_reviews' => esc_html__( 'Recent Reviews', 'site-reviews' ), |
|
| 118 | + 'site_reviews_form' => esc_html__( 'Submit a Review', 'site-reviews' ), |
|
| 119 | + 'site_reviews_summary' => esc_html__( 'Summary of Reviews', 'site-reviews' ), |
|
| 120 | + ] ); |
|
| 121 | + $this->execute( $command ); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -126,22 +126,22 @@ discard block |
||
| 126 | 126 | * @return void|null |
| 127 | 127 | * @action media_buttons |
| 128 | 128 | */ |
| 129 | - public function renderTinymceButton($editorId) |
|
| 129 | + public function renderTinymceButton( $editorId ) |
|
| 130 | 130 | { |
| 131 | - $allowedEditors = apply_filters('site-reviews/tinymce/editor-ids', ['content'], $editorId); |
|
| 132 | - if ('post' != glsr_current_screen()->base || !in_array($editorId, $allowedEditors)) { |
|
| 131 | + $allowedEditors = apply_filters( 'site-reviews/tinymce/editor-ids', ['content'], $editorId ); |
|
| 132 | + if( 'post' != glsr_current_screen()->base || !in_array( $editorId, $allowedEditors ) ) { |
|
| 133 | 133 | return; |
| 134 | 134 | } |
| 135 | 135 | $shortcodes = []; |
| 136 | - foreach (glsr()->mceShortcodes as $shortcode => $values) { |
|
| 136 | + foreach( glsr()->mceShortcodes as $shortcode => $values ) { |
|
| 137 | 137 | $shortcodes[$shortcode] = $values; |
| 138 | 138 | } |
| 139 | - if (empty($shortcodes)) { |
|
| 139 | + if( empty($shortcodes) ) { |
|
| 140 | 140 | return; |
| 141 | 141 | } |
| 142 | - glsr()->render('partials/editor/tinymce', [ |
|
| 142 | + glsr()->render( 'partials/editor/tinymce', [ |
|
| 143 | 143 | 'shortcodes' => $shortcodes, |
| 144 | - ]); |
|
| 144 | + ] ); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | /** |
@@ -149,8 +149,8 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | public function routerClearConsole() |
| 151 | 151 | { |
| 152 | - glsr(Console::class)->clear(); |
|
| 153 | - glsr(Notice::class)->addSuccess(__('Console cleared.', 'site-reviews')); |
|
| 152 | + glsr( Console::class )->clear(); |
|
| 153 | + glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ) ); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
@@ -158,19 +158,19 @@ discard block |
||
| 158 | 158 | */ |
| 159 | 159 | public function routerFetchConsole() |
| 160 | 160 | { |
| 161 | - glsr(Notice::class)->addSuccess(__('Console reloaded.', 'site-reviews')); |
|
| 161 | + glsr( Notice::class )->addSuccess( __( 'Console reloaded.', 'site-reviews' ) ); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
| 165 | 165 | * @param bool $showNotice |
| 166 | 166 | * @return void |
| 167 | 167 | */ |
| 168 | - public function routerCountReviews($showNotice = true) |
|
| 168 | + public function routerCountReviews( $showNotice = true ) |
|
| 169 | 169 | { |
| 170 | - glsr(CountsManager::class)->updateAll(); |
|
| 171 | - glsr(OptionManager::class)->set('last_review_count', current_time('timestamp')); |
|
| 172 | - if ($showNotice) { |
|
| 173 | - glsr(Notice::class)->clear()->addSuccess(__('Recalculated rating counts.', 'site-reviews')); |
|
| 170 | + glsr( CountsManager::class )->updateAll(); |
|
| 171 | + glsr( OptionManager::class )->set( 'last_review_count', current_time( 'timestamp' ) ); |
|
| 172 | + if( $showNotice ) { |
|
| 173 | + glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' ) ); |
|
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | 176 | |
@@ -179,8 +179,8 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | public function routerMigrateReviews() |
| 181 | 181 | { |
| 182 | - glsr(Upgrade_4_0_2::class)->protectMetaKeys(); |
|
| 183 | - glsr(Notice::class)->clear()->addSuccess(__('All reviews have been migrated.', 'site-reviews')); |
|
| 182 | + glsr( Upgrade_4_0_2::class )->protectMetaKeys(); |
|
| 183 | + glsr( Notice::class )->clear()->addSuccess( __( 'All reviews have been migrated.', 'site-reviews' ) ); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | public function routerDownloadConsole() |
| 190 | 190 | { |
| 191 | - $this->download(Application::ID.'-console.txt', glsr(Console::class)->get()); |
|
| 191 | + $this->download( Application::ID.'-console.txt', glsr( Console::class )->get() ); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | /** |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | */ |
| 197 | 197 | public function routerDownloadSystemInfo() |
| 198 | 198 | { |
| 199 | - $this->download(Application::ID.'-system-info.txt', glsr(System::class)->get()); |
|
| 199 | + $this->download( Application::ID.'-system-info.txt', glsr( System::class )->get() ); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | /** |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | */ |
| 205 | 205 | public function routerExportSettings() |
| 206 | 206 | { |
| 207 | - $this->download(Application::ID.'-settings.json', glsr(OptionManager::class)->json()); |
|
| 207 | + $this->download( Application::ID.'-settings.json', glsr( OptionManager::class )->json() ); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | /** |
@@ -213,35 +213,35 @@ discard block |
||
| 213 | 213 | public function routerImportSettings() |
| 214 | 214 | { |
| 215 | 215 | $file = $_FILES['import-file']; |
| 216 | - if (UPLOAD_ERR_OK !== $file['error']) { |
|
| 217 | - return glsr(Notice::class)->addError($this->getUploadError($file['error'])); |
|
| 216 | + if( UPLOAD_ERR_OK !== $file['error'] ) { |
|
| 217 | + return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ) ); |
|
| 218 | 218 | } |
| 219 | - if ('application/json' !== $file['type'] || !Str::endsWith('.json', $file['name'])) { |
|
| 220 | - return glsr(Notice::class)->addError(__('Please use a valid Site Reviews settings file.', 'site-reviews')); |
|
| 219 | + if( 'application/json' !== $file['type'] || !Str::endsWith( '.json', $file['name'] ) ) { |
|
| 220 | + return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ) ); |
|
| 221 | 221 | } |
| 222 | - $settings = json_decode(file_get_contents($file['tmp_name']), true); |
|
| 223 | - if (empty($settings)) { |
|
| 224 | - return glsr(Notice::class)->addWarning(__('There were no settings found to import.', 'site-reviews')); |
|
| 222 | + $settings = json_decode( file_get_contents( $file['tmp_name'] ), true ); |
|
| 223 | + if( empty($settings) ) { |
|
| 224 | + return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ) ); |
|
| 225 | 225 | } |
| 226 | - glsr(OptionManager::class)->set(glsr(OptionManager::class)->normalize($settings)); |
|
| 227 | - glsr(Notice::class)->addSuccess(__('Settings imported.', 'site-reviews')); |
|
| 226 | + glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ) ); |
|
| 227 | + glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ) ); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | /** |
| 231 | 231 | * @param int $errorCode |
| 232 | 232 | * @return string |
| 233 | 233 | */ |
| 234 | - protected function getUploadError($errorCode) |
|
| 234 | + protected function getUploadError( $errorCode ) |
|
| 235 | 235 | { |
| 236 | 236 | $errors = [ |
| 237 | - UPLOAD_ERR_INI_SIZE => __('The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews'), |
|
| 238 | - UPLOAD_ERR_FORM_SIZE => __('The uploaded file is too big.', 'site-reviews'), |
|
| 239 | - UPLOAD_ERR_PARTIAL => __('The uploaded file was only partially uploaded.', 'site-reviews'), |
|
| 240 | - UPLOAD_ERR_NO_FILE => __('No file was uploaded.', 'site-reviews'), |
|
| 241 | - UPLOAD_ERR_NO_TMP_DIR => __('Missing a temporary folder.', 'site-reviews'), |
|
| 242 | - UPLOAD_ERR_CANT_WRITE => __('Failed to write file to disk.', 'site-reviews'), |
|
| 243 | - UPLOAD_ERR_EXTENSION => __('A PHP extension stopped the file upload.', 'site-reviews'), |
|
| 237 | + UPLOAD_ERR_INI_SIZE => __( 'The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews' ), |
|
| 238 | + UPLOAD_ERR_FORM_SIZE => __( 'The uploaded file is too big.', 'site-reviews' ), |
|
| 239 | + UPLOAD_ERR_PARTIAL => __( 'The uploaded file was only partially uploaded.', 'site-reviews' ), |
|
| 240 | + UPLOAD_ERR_NO_FILE => __( 'No file was uploaded.', 'site-reviews' ), |
|
| 241 | + UPLOAD_ERR_NO_TMP_DIR => __( 'Missing a temporary folder.', 'site-reviews' ), |
|
| 242 | + UPLOAD_ERR_CANT_WRITE => __( 'Failed to write file to disk.', 'site-reviews' ), |
|
| 243 | + UPLOAD_ERR_EXTENSION => __( 'A PHP extension stopped the file upload.', 'site-reviews' ), |
|
| 244 | 244 | ]; |
| 245 | - return Arr::get($errors, $errorCode, __('Unknown upload error.', 'site-reviews')); |
|
| 245 | + return Arr::get( $errors, $errorCode, __( 'Unknown upload error.', 'site-reviews' ) ); |
|
| 246 | 246 | } |
| 247 | 247 | } |
@@ -14,180 +14,180 @@ |
||
| 14 | 14 | |
| 15 | 15 | class AjaxController extends Controller |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * @return void |
|
| 19 | - */ |
|
| 20 | - public function routerChangeStatus(array $request) |
|
| 21 | - { |
|
| 22 | - wp_send_json_success($this->execute(new ChangeStatus($request))); |
|
| 23 | - } |
|
| 17 | + /** |
|
| 18 | + * @return void |
|
| 19 | + */ |
|
| 20 | + public function routerChangeStatus(array $request) |
|
| 21 | + { |
|
| 22 | + wp_send_json_success($this->execute(new ChangeStatus($request))); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @return void |
|
| 27 | - */ |
|
| 28 | - public function routerClearConsole() |
|
| 29 | - { |
|
| 30 | - glsr(AdminController::class)->routerClearConsole(); |
|
| 31 | - wp_send_json_success([ |
|
| 32 | - 'console' => glsr(Console::class)->get(), |
|
| 33 | - 'notices' => glsr(Notice::class)->get(), |
|
| 34 | - ]); |
|
| 35 | - } |
|
| 25 | + /** |
|
| 26 | + * @return void |
|
| 27 | + */ |
|
| 28 | + public function routerClearConsole() |
|
| 29 | + { |
|
| 30 | + glsr(AdminController::class)->routerClearConsole(); |
|
| 31 | + wp_send_json_success([ |
|
| 32 | + 'console' => glsr(Console::class)->get(), |
|
| 33 | + 'notices' => glsr(Notice::class)->get(), |
|
| 34 | + ]); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @return void |
|
| 39 | - */ |
|
| 40 | - public function routerCountReviews() |
|
| 41 | - { |
|
| 42 | - glsr(AdminController::class)->routerCountReviews(); |
|
| 43 | - wp_send_json_success([ |
|
| 44 | - 'notices' => glsr(Notice::class)->get(), |
|
| 45 | - ]); |
|
| 46 | - } |
|
| 37 | + /** |
|
| 38 | + * @return void |
|
| 39 | + */ |
|
| 40 | + public function routerCountReviews() |
|
| 41 | + { |
|
| 42 | + glsr(AdminController::class)->routerCountReviews(); |
|
| 43 | + wp_send_json_success([ |
|
| 44 | + 'notices' => glsr(Notice::class)->get(), |
|
| 45 | + ]); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * @return void |
|
| 50 | - */ |
|
| 51 | - public function routerMigrateReviews() |
|
| 52 | - { |
|
| 53 | - glsr(AdminController::class)->routerMigrateReviews(); |
|
| 54 | - wp_send_json_success([ |
|
| 55 | - 'notices' => glsr(Notice::class)->get(), |
|
| 56 | - ]); |
|
| 57 | - } |
|
| 48 | + /** |
|
| 49 | + * @return void |
|
| 50 | + */ |
|
| 51 | + public function routerMigrateReviews() |
|
| 52 | + { |
|
| 53 | + glsr(AdminController::class)->routerMigrateReviews(); |
|
| 54 | + wp_send_json_success([ |
|
| 55 | + 'notices' => glsr(Notice::class)->get(), |
|
| 56 | + ]); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * @return void |
|
| 61 | - */ |
|
| 62 | - public function routerDismissNotice(array $request) |
|
| 63 | - { |
|
| 64 | - glsr(NoticeController::class)->routerDismissNotice($request); |
|
| 65 | - wp_send_json_success(); |
|
| 66 | - } |
|
| 59 | + /** |
|
| 60 | + * @return void |
|
| 61 | + */ |
|
| 62 | + public function routerDismissNotice(array $request) |
|
| 63 | + { |
|
| 64 | + glsr(NoticeController::class)->routerDismissNotice($request); |
|
| 65 | + wp_send_json_success(); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * @return void |
|
| 70 | - */ |
|
| 71 | - public function routerMceShortcode(array $request) |
|
| 72 | - { |
|
| 73 | - $shortcode = $request['shortcode']; |
|
| 74 | - $response = false; |
|
| 75 | - if (array_key_exists($shortcode, glsr()->mceShortcodes)) { |
|
| 76 | - $data = glsr()->mceShortcodes[$shortcode]; |
|
| 77 | - if (!empty($data['errors'])) { |
|
| 78 | - $data['btn_okay'] = [esc_html__('Okay', 'site-reviews')]; |
|
| 79 | - } |
|
| 80 | - $response = [ |
|
| 81 | - 'body' => $data['fields'], |
|
| 82 | - 'close' => $data['btn_close'], |
|
| 83 | - 'ok' => $data['btn_okay'], |
|
| 84 | - 'shortcode' => $shortcode, |
|
| 85 | - 'title' => $data['title'], |
|
| 86 | - ]; |
|
| 87 | - } |
|
| 88 | - wp_send_json_success($response); |
|
| 89 | - } |
|
| 68 | + /** |
|
| 69 | + * @return void |
|
| 70 | + */ |
|
| 71 | + public function routerMceShortcode(array $request) |
|
| 72 | + { |
|
| 73 | + $shortcode = $request['shortcode']; |
|
| 74 | + $response = false; |
|
| 75 | + if (array_key_exists($shortcode, glsr()->mceShortcodes)) { |
|
| 76 | + $data = glsr()->mceShortcodes[$shortcode]; |
|
| 77 | + if (!empty($data['errors'])) { |
|
| 78 | + $data['btn_okay'] = [esc_html__('Okay', 'site-reviews')]; |
|
| 79 | + } |
|
| 80 | + $response = [ |
|
| 81 | + 'body' => $data['fields'], |
|
| 82 | + 'close' => $data['btn_close'], |
|
| 83 | + 'ok' => $data['btn_okay'], |
|
| 84 | + 'shortcode' => $shortcode, |
|
| 85 | + 'title' => $data['title'], |
|
| 86 | + ]; |
|
| 87 | + } |
|
| 88 | + wp_send_json_success($response); |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * @return void |
|
| 93 | - */ |
|
| 94 | - public function routerFetchConsole() |
|
| 95 | - { |
|
| 96 | - glsr(AdminController::class)->routerFetchConsole(); |
|
| 97 | - wp_send_json_success([ |
|
| 98 | - 'console' => glsr(Console::class)->get(), |
|
| 99 | - 'notices' => glsr(Notice::class)->get(), |
|
| 100 | - ]); |
|
| 101 | - } |
|
| 91 | + /** |
|
| 92 | + * @return void |
|
| 93 | + */ |
|
| 94 | + public function routerFetchConsole() |
|
| 95 | + { |
|
| 96 | + glsr(AdminController::class)->routerFetchConsole(); |
|
| 97 | + wp_send_json_success([ |
|
| 98 | + 'console' => glsr(Console::class)->get(), |
|
| 99 | + 'notices' => glsr(Notice::class)->get(), |
|
| 100 | + ]); |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * @return void |
|
| 105 | - */ |
|
| 106 | - public function routerSearchPosts(array $request) |
|
| 107 | - { |
|
| 108 | - $results = glsr(Database::class)->searchPosts($request['search']); |
|
| 109 | - wp_send_json_success([ |
|
| 110 | - 'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>', |
|
| 111 | - 'items' => $results, |
|
| 112 | - ]); |
|
| 113 | - } |
|
| 103 | + /** |
|
| 104 | + * @return void |
|
| 105 | + */ |
|
| 106 | + public function routerSearchPosts(array $request) |
|
| 107 | + { |
|
| 108 | + $results = glsr(Database::class)->searchPosts($request['search']); |
|
| 109 | + wp_send_json_success([ |
|
| 110 | + 'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>', |
|
| 111 | + 'items' => $results, |
|
| 112 | + ]); |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - /** |
|
| 116 | - * @return void |
|
| 117 | - */ |
|
| 118 | - public function routerSearchTranslations(array $request) |
|
| 119 | - { |
|
| 120 | - if (empty($request['exclude'])) { |
|
| 121 | - $request['exclude'] = []; |
|
| 122 | - } |
|
| 123 | - $results = glsr(Translation::class) |
|
| 124 | - ->search($request['search']) |
|
| 125 | - ->exclude() |
|
| 126 | - ->exclude($request['exclude']) |
|
| 127 | - ->renderResults(); |
|
| 128 | - wp_send_json_success([ |
|
| 129 | - 'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>', |
|
| 130 | - 'items' => $results, |
|
| 131 | - ]); |
|
| 132 | - } |
|
| 115 | + /** |
|
| 116 | + * @return void |
|
| 117 | + */ |
|
| 118 | + public function routerSearchTranslations(array $request) |
|
| 119 | + { |
|
| 120 | + if (empty($request['exclude'])) { |
|
| 121 | + $request['exclude'] = []; |
|
| 122 | + } |
|
| 123 | + $results = glsr(Translation::class) |
|
| 124 | + ->search($request['search']) |
|
| 125 | + ->exclude() |
|
| 126 | + ->exclude($request['exclude']) |
|
| 127 | + ->renderResults(); |
|
| 128 | + wp_send_json_success([ |
|
| 129 | + 'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>', |
|
| 130 | + 'items' => $results, |
|
| 131 | + ]); |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - /** |
|
| 135 | - * @return void |
|
| 136 | - */ |
|
| 137 | - public function routerSubmitReview(array $request) |
|
| 138 | - { |
|
| 139 | - $command = glsr(PublicController::class)->routerSubmitReview($request); |
|
| 140 | - $redirect = trim(strval(get_post_meta($command->post_id, 'redirect_to', true))); |
|
| 141 | - $redirect = apply_filters('site-reviews/review/redirect', $redirect, $command); |
|
| 142 | - $data = [ |
|
| 143 | - 'errors' => glsr()->sessionGet($command->form_id.'errors', false), |
|
| 144 | - 'message' => glsr()->sessionGet($command->form_id.'message', ''), |
|
| 145 | - 'recaptcha' => glsr()->sessionGet($command->form_id.'recaptcha', false), |
|
| 146 | - 'redirect' => $redirect, |
|
| 147 | - ]; |
|
| 148 | - if (false === $data['errors']) { |
|
| 149 | - glsr()->sessionClear(); |
|
| 150 | - wp_send_json_success($data); |
|
| 151 | - } |
|
| 152 | - wp_send_json_error($data); |
|
| 153 | - } |
|
| 134 | + /** |
|
| 135 | + * @return void |
|
| 136 | + */ |
|
| 137 | + public function routerSubmitReview(array $request) |
|
| 138 | + { |
|
| 139 | + $command = glsr(PublicController::class)->routerSubmitReview($request); |
|
| 140 | + $redirect = trim(strval(get_post_meta($command->post_id, 'redirect_to', true))); |
|
| 141 | + $redirect = apply_filters('site-reviews/review/redirect', $redirect, $command); |
|
| 142 | + $data = [ |
|
| 143 | + 'errors' => glsr()->sessionGet($command->form_id.'errors', false), |
|
| 144 | + 'message' => glsr()->sessionGet($command->form_id.'message', ''), |
|
| 145 | + 'recaptcha' => glsr()->sessionGet($command->form_id.'recaptcha', false), |
|
| 146 | + 'redirect' => $redirect, |
|
| 147 | + ]; |
|
| 148 | + if (false === $data['errors']) { |
|
| 149 | + glsr()->sessionClear(); |
|
| 150 | + wp_send_json_success($data); |
|
| 151 | + } |
|
| 152 | + wp_send_json_error($data); |
|
| 153 | + } |
|
| 154 | 154 | |
| 155 | - /** |
|
| 156 | - * @return void |
|
| 157 | - */ |
|
| 158 | - public function routerFetchPagedReviews(array $request) |
|
| 159 | - { |
|
| 160 | - $homePath = untrailingslashit(parse_url(home_url(), PHP_URL_PATH)); |
|
| 161 | - $urlPath = untrailingslashit(parse_url(Arr::get($request, 'url'), PHP_URL_PATH)); |
|
| 162 | - $urlQuery = []; |
|
| 163 | - parse_str(parse_url(Arr::get($request, 'url'), PHP_URL_QUERY), $urlQuery); |
|
| 164 | - $pagedUrl = $homePath === $urlPath |
|
| 165 | - ? home_url() |
|
| 166 | - : home_url($urlPath); |
|
| 167 | - $args = [ |
|
| 168 | - 'paged' => (int) Arr::get($urlQuery, glsr()->constant('PAGED_QUERY_VAR'), 1), |
|
| 169 | - 'pagedUrl' => trailingslashit($pagedUrl), |
|
| 170 | - 'pagination' => 'ajax', |
|
| 171 | - 'schema' => false, |
|
| 172 | - ]; |
|
| 173 | - $atts = (array) json_decode(Arr::get($request, 'atts')); |
|
| 174 | - $atts = glsr(SiteReviewsShortcode::class)->normalizeAtts($atts); |
|
| 175 | - $html = glsr(SiteReviewsPartial::class)->build(wp_parse_args($args, $atts)); |
|
| 176 | - return wp_send_json_success([ |
|
| 177 | - 'pagination' => $html->getPagination(), |
|
| 178 | - 'reviews' => $html->getReviews(), |
|
| 179 | - ]); |
|
| 180 | - } |
|
| 155 | + /** |
|
| 156 | + * @return void |
|
| 157 | + */ |
|
| 158 | + public function routerFetchPagedReviews(array $request) |
|
| 159 | + { |
|
| 160 | + $homePath = untrailingslashit(parse_url(home_url(), PHP_URL_PATH)); |
|
| 161 | + $urlPath = untrailingslashit(parse_url(Arr::get($request, 'url'), PHP_URL_PATH)); |
|
| 162 | + $urlQuery = []; |
|
| 163 | + parse_str(parse_url(Arr::get($request, 'url'), PHP_URL_QUERY), $urlQuery); |
|
| 164 | + $pagedUrl = $homePath === $urlPath |
|
| 165 | + ? home_url() |
|
| 166 | + : home_url($urlPath); |
|
| 167 | + $args = [ |
|
| 168 | + 'paged' => (int) Arr::get($urlQuery, glsr()->constant('PAGED_QUERY_VAR'), 1), |
|
| 169 | + 'pagedUrl' => trailingslashit($pagedUrl), |
|
| 170 | + 'pagination' => 'ajax', |
|
| 171 | + 'schema' => false, |
|
| 172 | + ]; |
|
| 173 | + $atts = (array) json_decode(Arr::get($request, 'atts')); |
|
| 174 | + $atts = glsr(SiteReviewsShortcode::class)->normalizeAtts($atts); |
|
| 175 | + $html = glsr(SiteReviewsPartial::class)->build(wp_parse_args($args, $atts)); |
|
| 176 | + return wp_send_json_success([ |
|
| 177 | + 'pagination' => $html->getPagination(), |
|
| 178 | + 'reviews' => $html->getReviews(), |
|
| 179 | + ]); |
|
| 180 | + } |
|
| 181 | 181 | |
| 182 | - /** |
|
| 183 | - * @return void |
|
| 184 | - */ |
|
| 185 | - public function routerTogglePinned(array $request) |
|
| 186 | - { |
|
| 187 | - $isPinned = $this->execute(new TogglePinned($request)); |
|
| 188 | - wp_send_json_success([ |
|
| 189 | - 'notices' => glsr(Notice::class)->get(), |
|
| 190 | - 'pinned' => $isPinned, |
|
| 191 | - ]); |
|
| 192 | - } |
|
| 182 | + /** |
|
| 183 | + * @return void |
|
| 184 | + */ |
|
| 185 | + public function routerTogglePinned(array $request) |
|
| 186 | + { |
|
| 187 | + $isPinned = $this->execute(new TogglePinned($request)); |
|
| 188 | + wp_send_json_success([ |
|
| 189 | + 'notices' => glsr(Notice::class)->get(), |
|
| 190 | + 'pinned' => $isPinned, |
|
| 191 | + ]); |
|
| 192 | + } |
|
| 193 | 193 | } |
@@ -17,9 +17,9 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * @return void |
| 19 | 19 | */ |
| 20 | - public function routerChangeStatus(array $request) |
|
| 20 | + public function routerChangeStatus( array $request ) |
|
| 21 | 21 | { |
| 22 | - wp_send_json_success($this->execute(new ChangeStatus($request))); |
|
| 22 | + wp_send_json_success( $this->execute( new ChangeStatus( $request ) ) ); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -27,11 +27,11 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | public function routerClearConsole() |
| 29 | 29 | { |
| 30 | - glsr(AdminController::class)->routerClearConsole(); |
|
| 31 | - wp_send_json_success([ |
|
| 32 | - 'console' => glsr(Console::class)->get(), |
|
| 33 | - 'notices' => glsr(Notice::class)->get(), |
|
| 34 | - ]); |
|
| 30 | + glsr( AdminController::class )->routerClearConsole(); |
|
| 31 | + wp_send_json_success( [ |
|
| 32 | + 'console' => glsr( Console::class )->get(), |
|
| 33 | + 'notices' => glsr( Notice::class )->get(), |
|
| 34 | + ] ); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -39,10 +39,10 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public function routerCountReviews() |
| 41 | 41 | { |
| 42 | - glsr(AdminController::class)->routerCountReviews(); |
|
| 43 | - wp_send_json_success([ |
|
| 44 | - 'notices' => glsr(Notice::class)->get(), |
|
| 45 | - ]); |
|
| 42 | + glsr( AdminController::class )->routerCountReviews(); |
|
| 43 | + wp_send_json_success( [ |
|
| 44 | + 'notices' => glsr( Notice::class )->get(), |
|
| 45 | + ] ); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -50,32 +50,32 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function routerMigrateReviews() |
| 52 | 52 | { |
| 53 | - glsr(AdminController::class)->routerMigrateReviews(); |
|
| 54 | - wp_send_json_success([ |
|
| 55 | - 'notices' => glsr(Notice::class)->get(), |
|
| 56 | - ]); |
|
| 53 | + glsr( AdminController::class )->routerMigrateReviews(); |
|
| 54 | + wp_send_json_success( [ |
|
| 55 | + 'notices' => glsr( Notice::class )->get(), |
|
| 56 | + ] ); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * @return void |
| 61 | 61 | */ |
| 62 | - public function routerDismissNotice(array $request) |
|
| 62 | + public function routerDismissNotice( array $request ) |
|
| 63 | 63 | { |
| 64 | - glsr(NoticeController::class)->routerDismissNotice($request); |
|
| 64 | + glsr( NoticeController::class )->routerDismissNotice( $request ); |
|
| 65 | 65 | wp_send_json_success(); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
| 69 | 69 | * @return void |
| 70 | 70 | */ |
| 71 | - public function routerMceShortcode(array $request) |
|
| 71 | + public function routerMceShortcode( array $request ) |
|
| 72 | 72 | { |
| 73 | 73 | $shortcode = $request['shortcode']; |
| 74 | 74 | $response = false; |
| 75 | - if (array_key_exists($shortcode, glsr()->mceShortcodes)) { |
|
| 75 | + if( array_key_exists( $shortcode, glsr()->mceShortcodes ) ) { |
|
| 76 | 76 | $data = glsr()->mceShortcodes[$shortcode]; |
| 77 | - if (!empty($data['errors'])) { |
|
| 78 | - $data['btn_okay'] = [esc_html__('Okay', 'site-reviews')]; |
|
| 77 | + if( !empty($data['errors']) ) { |
|
| 78 | + $data['btn_okay'] = [esc_html__( 'Okay', 'site-reviews' )]; |
|
| 79 | 79 | } |
| 80 | 80 | $response = [ |
| 81 | 81 | 'body' => $data['fields'], |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | 'title' => $data['title'], |
| 86 | 86 | ]; |
| 87 | 87 | } |
| 88 | - wp_send_json_success($response); |
|
| 88 | + wp_send_json_success( $response ); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -93,101 +93,101 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function routerFetchConsole() |
| 95 | 95 | { |
| 96 | - glsr(AdminController::class)->routerFetchConsole(); |
|
| 97 | - wp_send_json_success([ |
|
| 98 | - 'console' => glsr(Console::class)->get(), |
|
| 99 | - 'notices' => glsr(Notice::class)->get(), |
|
| 100 | - ]); |
|
| 96 | + glsr( AdminController::class )->routerFetchConsole(); |
|
| 97 | + wp_send_json_success( [ |
|
| 98 | + 'console' => glsr( Console::class )->get(), |
|
| 99 | + 'notices' => glsr( Notice::class )->get(), |
|
| 100 | + ] ); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
| 104 | 104 | * @return void |
| 105 | 105 | */ |
| 106 | - public function routerSearchPosts(array $request) |
|
| 106 | + public function routerSearchPosts( array $request ) |
|
| 107 | 107 | { |
| 108 | - $results = glsr(Database::class)->searchPosts($request['search']); |
|
| 109 | - wp_send_json_success([ |
|
| 110 | - 'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>', |
|
| 108 | + $results = glsr( Database::class )->searchPosts( $request['search'] ); |
|
| 109 | + wp_send_json_success( [ |
|
| 110 | + 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
|
| 111 | 111 | 'items' => $results, |
| 112 | - ]); |
|
| 112 | + ] ); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
| 116 | 116 | * @return void |
| 117 | 117 | */ |
| 118 | - public function routerSearchTranslations(array $request) |
|
| 118 | + public function routerSearchTranslations( array $request ) |
|
| 119 | 119 | { |
| 120 | - if (empty($request['exclude'])) { |
|
| 120 | + if( empty($request['exclude']) ) { |
|
| 121 | 121 | $request['exclude'] = []; |
| 122 | 122 | } |
| 123 | - $results = glsr(Translation::class) |
|
| 124 | - ->search($request['search']) |
|
| 123 | + $results = glsr( Translation::class ) |
|
| 124 | + ->search( $request['search'] ) |
|
| 125 | 125 | ->exclude() |
| 126 | - ->exclude($request['exclude']) |
|
| 126 | + ->exclude( $request['exclude'] ) |
|
| 127 | 127 | ->renderResults(); |
| 128 | - wp_send_json_success([ |
|
| 129 | - 'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>', |
|
| 128 | + wp_send_json_success( [ |
|
| 129 | + 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
|
| 130 | 130 | 'items' => $results, |
| 131 | - ]); |
|
| 131 | + ] ); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
| 135 | 135 | * @return void |
| 136 | 136 | */ |
| 137 | - public function routerSubmitReview(array $request) |
|
| 137 | + public function routerSubmitReview( array $request ) |
|
| 138 | 138 | { |
| 139 | - $command = glsr(PublicController::class)->routerSubmitReview($request); |
|
| 140 | - $redirect = trim(strval(get_post_meta($command->post_id, 'redirect_to', true))); |
|
| 141 | - $redirect = apply_filters('site-reviews/review/redirect', $redirect, $command); |
|
| 139 | + $command = glsr( PublicController::class )->routerSubmitReview( $request ); |
|
| 140 | + $redirect = trim( strval( get_post_meta( $command->post_id, 'redirect_to', true ) ) ); |
|
| 141 | + $redirect = apply_filters( 'site-reviews/review/redirect', $redirect, $command ); |
|
| 142 | 142 | $data = [ |
| 143 | - 'errors' => glsr()->sessionGet($command->form_id.'errors', false), |
|
| 144 | - 'message' => glsr()->sessionGet($command->form_id.'message', ''), |
|
| 145 | - 'recaptcha' => glsr()->sessionGet($command->form_id.'recaptcha', false), |
|
| 143 | + 'errors' => glsr()->sessionGet( $command->form_id.'errors', false ), |
|
| 144 | + 'message' => glsr()->sessionGet( $command->form_id.'message', '' ), |
|
| 145 | + 'recaptcha' => glsr()->sessionGet( $command->form_id.'recaptcha', false ), |
|
| 146 | 146 | 'redirect' => $redirect, |
| 147 | 147 | ]; |
| 148 | - if (false === $data['errors']) { |
|
| 148 | + if( false === $data['errors'] ) { |
|
| 149 | 149 | glsr()->sessionClear(); |
| 150 | - wp_send_json_success($data); |
|
| 150 | + wp_send_json_success( $data ); |
|
| 151 | 151 | } |
| 152 | - wp_send_json_error($data); |
|
| 152 | + wp_send_json_error( $data ); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
| 156 | 156 | * @return void |
| 157 | 157 | */ |
| 158 | - public function routerFetchPagedReviews(array $request) |
|
| 158 | + public function routerFetchPagedReviews( array $request ) |
|
| 159 | 159 | { |
| 160 | - $homePath = untrailingslashit(parse_url(home_url(), PHP_URL_PATH)); |
|
| 161 | - $urlPath = untrailingslashit(parse_url(Arr::get($request, 'url'), PHP_URL_PATH)); |
|
| 160 | + $homePath = untrailingslashit( parse_url( home_url(), PHP_URL_PATH ) ); |
|
| 161 | + $urlPath = untrailingslashit( parse_url( Arr::get( $request, 'url' ), PHP_URL_PATH ) ); |
|
| 162 | 162 | $urlQuery = []; |
| 163 | - parse_str(parse_url(Arr::get($request, 'url'), PHP_URL_QUERY), $urlQuery); |
|
| 163 | + parse_str( parse_url( Arr::get( $request, 'url' ), PHP_URL_QUERY ), $urlQuery ); |
|
| 164 | 164 | $pagedUrl = $homePath === $urlPath |
| 165 | 165 | ? home_url() |
| 166 | - : home_url($urlPath); |
|
| 166 | + : home_url( $urlPath ); |
|
| 167 | 167 | $args = [ |
| 168 | - 'paged' => (int) Arr::get($urlQuery, glsr()->constant('PAGED_QUERY_VAR'), 1), |
|
| 169 | - 'pagedUrl' => trailingslashit($pagedUrl), |
|
| 168 | + 'paged' => (int)Arr::get( $urlQuery, glsr()->constant( 'PAGED_QUERY_VAR' ), 1 ), |
|
| 169 | + 'pagedUrl' => trailingslashit( $pagedUrl ), |
|
| 170 | 170 | 'pagination' => 'ajax', |
| 171 | 171 | 'schema' => false, |
| 172 | 172 | ]; |
| 173 | - $atts = (array) json_decode(Arr::get($request, 'atts')); |
|
| 174 | - $atts = glsr(SiteReviewsShortcode::class)->normalizeAtts($atts); |
|
| 175 | - $html = glsr(SiteReviewsPartial::class)->build(wp_parse_args($args, $atts)); |
|
| 176 | - return wp_send_json_success([ |
|
| 173 | + $atts = (array)json_decode( Arr::get( $request, 'atts' ) ); |
|
| 174 | + $atts = glsr( SiteReviewsShortcode::class )->normalizeAtts( $atts ); |
|
| 175 | + $html = glsr( SiteReviewsPartial::class )->build( wp_parse_args( $args, $atts ) ); |
|
| 176 | + return wp_send_json_success( [ |
|
| 177 | 177 | 'pagination' => $html->getPagination(), |
| 178 | 178 | 'reviews' => $html->getReviews(), |
| 179 | - ]); |
|
| 179 | + ] ); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
| 183 | 183 | * @return void |
| 184 | 184 | */ |
| 185 | - public function routerTogglePinned(array $request) |
|
| 185 | + public function routerTogglePinned( array $request ) |
|
| 186 | 186 | { |
| 187 | - $isPinned = $this->execute(new TogglePinned($request)); |
|
| 188 | - wp_send_json_success([ |
|
| 189 | - 'notices' => glsr(Notice::class)->get(), |
|
| 187 | + $isPinned = $this->execute( new TogglePinned( $request ) ); |
|
| 188 | + wp_send_json_success( [ |
|
| 189 | + 'notices' => glsr( Notice::class )->get(), |
|
| 190 | 190 | 'pinned' => $isPinned, |
| 191 | - ]); |
|
| 191 | + ] ); |
|
| 192 | 192 | } |
| 193 | 193 | } |