@@ -1,23 +1,23 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="glsr-welcome wrap about-wrap about-wrap-content"> |
4 | 4 | <h1>Welcome to <?= glsr()->name; ?></h1> |
5 | 5 | <div class="about-text">Site Reviews is a free WordPress review plugin with advanced features that makes it easy to manage reviews on your website. Follow the instructions below to get started!</div> |
6 | 6 | <div class="wp-badge">Version <?= glsr()->version; ?></div> |
7 | 7 | <p class="about-buttons"> |
8 | - <a class="button" href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation'); ?>">Documentation</a> |
|
8 | + <a class="button" href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation' ); ?>">Documentation</a> |
|
9 | 9 | <a class="button" href="https://wordpress.org/support/plugin/site-reviews/">Support</a> |
10 | 10 | <a target="_blank" class="button" href="https://www.facebook.com/sharer/sharer.php?u=https%3A//geminilabs.io/site-reviews"><span class="dashicons dashicons-facebook-alt"></span> Share</a> |
11 | 11 | <a target="_blank" class="button" href="https://twitter.com/intent/tweet?text=Site Reviews is a fantastic WordPress review plugin with advanced features that makes it easy to manage reviews on your website.&url=https://geminilabs.io/site-reviews&hashtags=WordPress,reviewplugins,"><span class="dashicons dashicons-twitter"></span> Tweet</a> |
12 | 12 | </p> |
13 | 13 | <nav class="glsr-nav-tab-wrapper nav-tab-wrapper"> |
14 | - <?php foreach ($tabs as $id => $title) : ?> |
|
14 | + <?php foreach( $tabs as $id => $title ) : ?> |
|
15 | 15 | <a class="glsr-nav-tab nav-tab" href="#<?= $id; ?>"><?= $title; ?></a> |
16 | 16 | <?php endforeach; ?> |
17 | 17 | </nav> |
18 | - <?php foreach ($tabs as $id => $title) : ?> |
|
18 | + <?php foreach( $tabs as $id => $title ) : ?> |
|
19 | 19 | <div class="glsr-nav-view ui-tabs-hide" id="<?= $id; ?>"> |
20 | - <?php $template->render('pages/welcome/'.$id, $data); ?> |
|
20 | + <?php $template->render( 'pages/welcome/'.$id, $data ); ?> |
|
21 | 21 | </div> |
22 | 22 | <?php endforeach; ?> |
23 | 23 | <input type="hidden" name="_active_tab"> |
@@ -12,160 +12,160 @@ |
||
12 | 12 | |
13 | 13 | class SettingsController extends Controller |
14 | 14 | { |
15 | - /** |
|
16 | - * @param mixed $input |
|
17 | - * @return array |
|
18 | - * @callback register_setting |
|
19 | - */ |
|
20 | - public function callbackRegisterSettings($input) |
|
21 | - { |
|
22 | - $settings = Arr::consolidateArray($input); |
|
23 | - if (1 === count($settings) && array_key_exists('settings', $settings)) { |
|
24 | - $options = array_replace_recursive(glsr(OptionManager::class)->all(), $input); |
|
25 | - $options = $this->sanitizeGeneral($input, $options); |
|
26 | - $options = $this->sanitizeLicenses($input, $options); |
|
27 | - $options = $this->sanitizeSubmissions($input, $options); |
|
28 | - $options = $this->sanitizeTranslations($input, $options); |
|
29 | - $options = apply_filters('site-reviews/settings/callback', $options, $settings); |
|
30 | - if (filter_input(INPUT_POST, 'option_page') == Application::ID.'-settings') { |
|
31 | - glsr(Notice::class)->addSuccess(__('Settings updated.', 'site-reviews')); |
|
32 | - } |
|
33 | - return $options; |
|
34 | - } |
|
35 | - return $input; |
|
36 | - } |
|
15 | + /** |
|
16 | + * @param mixed $input |
|
17 | + * @return array |
|
18 | + * @callback register_setting |
|
19 | + */ |
|
20 | + public function callbackRegisterSettings($input) |
|
21 | + { |
|
22 | + $settings = Arr::consolidateArray($input); |
|
23 | + if (1 === count($settings) && array_key_exists('settings', $settings)) { |
|
24 | + $options = array_replace_recursive(glsr(OptionManager::class)->all(), $input); |
|
25 | + $options = $this->sanitizeGeneral($input, $options); |
|
26 | + $options = $this->sanitizeLicenses($input, $options); |
|
27 | + $options = $this->sanitizeSubmissions($input, $options); |
|
28 | + $options = $this->sanitizeTranslations($input, $options); |
|
29 | + $options = apply_filters('site-reviews/settings/callback', $options, $settings); |
|
30 | + if (filter_input(INPUT_POST, 'option_page') == Application::ID.'-settings') { |
|
31 | + glsr(Notice::class)->addSuccess(__('Settings updated.', 'site-reviews')); |
|
32 | + } |
|
33 | + return $options; |
|
34 | + } |
|
35 | + return $input; |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * @return void |
|
40 | - * @action admin_init |
|
41 | - */ |
|
42 | - public function registerSettings() |
|
43 | - { |
|
44 | - register_setting(Application::ID.'-settings', OptionManager::databaseKey(), [ |
|
45 | - 'sanitize_callback' => [$this, 'callbackRegisterSettings'], |
|
46 | - ]); |
|
47 | - } |
|
38 | + /** |
|
39 | + * @return void |
|
40 | + * @action admin_init |
|
41 | + */ |
|
42 | + public function registerSettings() |
|
43 | + { |
|
44 | + register_setting(Application::ID.'-settings', OptionManager::databaseKey(), [ |
|
45 | + 'sanitize_callback' => [$this, 'callbackRegisterSettings'], |
|
46 | + ]); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @return array |
|
51 | - */ |
|
52 | - protected function sanitizeGeneral(array $input, array $options) |
|
53 | - { |
|
54 | - $key = 'settings.general'; |
|
55 | - $inputForm = Arr::get($input, $key); |
|
56 | - if (!$this->hasMultilingualIntegration(Arr::get($inputForm, 'multilingual'))) { |
|
57 | - $options = Arr::set($options, $key.'.multilingual', ''); |
|
58 | - } |
|
59 | - if ('' == trim(Arr::get($inputForm, 'notification_message'))) { |
|
60 | - $defaultValue = Arr::get(glsr()->defaults, $key.'.notification_message'); |
|
61 | - $options = Arr::set($options, $key.'.notification_message', $defaultValue); |
|
62 | - } |
|
63 | - $defaultValue = Arr::get($inputForm, 'notifications', []); |
|
64 | - $options = Arr::set($options, $key.'.notifications', $defaultValue); |
|
65 | - return $options; |
|
66 | - } |
|
49 | + /** |
|
50 | + * @return array |
|
51 | + */ |
|
52 | + protected function sanitizeGeneral(array $input, array $options) |
|
53 | + { |
|
54 | + $key = 'settings.general'; |
|
55 | + $inputForm = Arr::get($input, $key); |
|
56 | + if (!$this->hasMultilingualIntegration(Arr::get($inputForm, 'multilingual'))) { |
|
57 | + $options = Arr::set($options, $key.'.multilingual', ''); |
|
58 | + } |
|
59 | + if ('' == trim(Arr::get($inputForm, 'notification_message'))) { |
|
60 | + $defaultValue = Arr::get(glsr()->defaults, $key.'.notification_message'); |
|
61 | + $options = Arr::set($options, $key.'.notification_message', $defaultValue); |
|
62 | + } |
|
63 | + $defaultValue = Arr::get($inputForm, 'notifications', []); |
|
64 | + $options = Arr::set($options, $key.'.notifications', $defaultValue); |
|
65 | + return $options; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @return array |
|
70 | - */ |
|
71 | - protected function sanitizeLicenses(array $input, array $options) |
|
72 | - { |
|
73 | - $key = 'settings.licenses'; |
|
74 | - $licenses = Arr::consolidateArray(Arr::get($input, $key)); |
|
75 | - foreach ($licenses as $slug => &$license) { |
|
76 | - $license = $this->verifyLicense($license, $slug); |
|
77 | - } |
|
78 | - $options = Arr::set($options, $key, $licenses); |
|
79 | - return $options; |
|
80 | - } |
|
68 | + /** |
|
69 | + * @return array |
|
70 | + */ |
|
71 | + protected function sanitizeLicenses(array $input, array $options) |
|
72 | + { |
|
73 | + $key = 'settings.licenses'; |
|
74 | + $licenses = Arr::consolidateArray(Arr::get($input, $key)); |
|
75 | + foreach ($licenses as $slug => &$license) { |
|
76 | + $license = $this->verifyLicense($license, $slug); |
|
77 | + } |
|
78 | + $options = Arr::set($options, $key, $licenses); |
|
79 | + return $options; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @return array |
|
84 | - */ |
|
85 | - protected function sanitizeSubmissions(array $input, array $options) |
|
86 | - { |
|
87 | - $key = 'settings.submissions'; |
|
88 | - $inputForm = Arr::get($input, $key); |
|
89 | - $defaultValue = isset($inputForm['required']) |
|
90 | - ? $inputForm['required'] |
|
91 | - : []; |
|
92 | - $options = Arr::set($options, $key.'.required', $defaultValue); |
|
93 | - return $options; |
|
94 | - } |
|
82 | + /** |
|
83 | + * @return array |
|
84 | + */ |
|
85 | + protected function sanitizeSubmissions(array $input, array $options) |
|
86 | + { |
|
87 | + $key = 'settings.submissions'; |
|
88 | + $inputForm = Arr::get($input, $key); |
|
89 | + $defaultValue = isset($inputForm['required']) |
|
90 | + ? $inputForm['required'] |
|
91 | + : []; |
|
92 | + $options = Arr::set($options, $key.'.required', $defaultValue); |
|
93 | + return $options; |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * @return array |
|
98 | - */ |
|
99 | - protected function sanitizeTranslations(array $input, array $options) |
|
100 | - { |
|
101 | - $key = 'settings.strings'; |
|
102 | - $inputForm = Arr::consolidateArray(Arr::get($input, $key)); |
|
103 | - if (!empty($inputForm)) { |
|
104 | - $options = Arr::set($options, $key, array_values(array_filter($inputForm))); |
|
105 | - $allowedTags = [ |
|
106 | - 'a' => ['class' => [], 'href' => [], 'target' => []], |
|
107 | - 'span' => ['class' => []], |
|
108 | - ]; |
|
109 | - array_walk($options['settings']['strings'], function (&$string) use ($allowedTags) { |
|
110 | - if (isset($string['s2'])) { |
|
111 | - $string['s2'] = wp_kses($string['s2'], $allowedTags); |
|
112 | - } |
|
113 | - if (isset($string['p2'])) { |
|
114 | - $string['p2'] = wp_kses($string['p2'], $allowedTags); |
|
115 | - } |
|
116 | - }); |
|
117 | - } |
|
118 | - return $options; |
|
119 | - } |
|
96 | + /** |
|
97 | + * @return array |
|
98 | + */ |
|
99 | + protected function sanitizeTranslations(array $input, array $options) |
|
100 | + { |
|
101 | + $key = 'settings.strings'; |
|
102 | + $inputForm = Arr::consolidateArray(Arr::get($input, $key)); |
|
103 | + if (!empty($inputForm)) { |
|
104 | + $options = Arr::set($options, $key, array_values(array_filter($inputForm))); |
|
105 | + $allowedTags = [ |
|
106 | + 'a' => ['class' => [], 'href' => [], 'target' => []], |
|
107 | + 'span' => ['class' => []], |
|
108 | + ]; |
|
109 | + array_walk($options['settings']['strings'], function (&$string) use ($allowedTags) { |
|
110 | + if (isset($string['s2'])) { |
|
111 | + $string['s2'] = wp_kses($string['s2'], $allowedTags); |
|
112 | + } |
|
113 | + if (isset($string['p2'])) { |
|
114 | + $string['p2'] = wp_kses($string['p2'], $allowedTags); |
|
115 | + } |
|
116 | + }); |
|
117 | + } |
|
118 | + return $options; |
|
119 | + } |
|
120 | 120 | |
121 | - /** |
|
122 | - * @param string $integrationSlug |
|
123 | - * @return bool |
|
124 | - */ |
|
125 | - protected function hasMultilingualIntegration($integrationSlug) |
|
126 | - { |
|
127 | - $integration = glsr(Multilingual::class)->getIntegration($integrationSlug); |
|
128 | - if (!$integration) { |
|
129 | - return false; |
|
130 | - } |
|
131 | - if (!$integration->isActive()) { |
|
132 | - glsr(Notice::class)->addError(sprintf( |
|
133 | - __('Please install/activate the %s plugin to enable integration.', 'site-reviews'), |
|
134 | - $integration->pluginName |
|
135 | - )); |
|
136 | - return false; |
|
137 | - } elseif (!$integration->isSupported()) { |
|
138 | - glsr(Notice::class)->addError(sprintf( |
|
139 | - __('Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews'), |
|
140 | - $integration->pluginName, |
|
141 | - $integration->supportedVersion |
|
142 | - )); |
|
143 | - return false; |
|
144 | - } |
|
145 | - return true; |
|
146 | - } |
|
121 | + /** |
|
122 | + * @param string $integrationSlug |
|
123 | + * @return bool |
|
124 | + */ |
|
125 | + protected function hasMultilingualIntegration($integrationSlug) |
|
126 | + { |
|
127 | + $integration = glsr(Multilingual::class)->getIntegration($integrationSlug); |
|
128 | + if (!$integration) { |
|
129 | + return false; |
|
130 | + } |
|
131 | + if (!$integration->isActive()) { |
|
132 | + glsr(Notice::class)->addError(sprintf( |
|
133 | + __('Please install/activate the %s plugin to enable integration.', 'site-reviews'), |
|
134 | + $integration->pluginName |
|
135 | + )); |
|
136 | + return false; |
|
137 | + } elseif (!$integration->isSupported()) { |
|
138 | + glsr(Notice::class)->addError(sprintf( |
|
139 | + __('Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews'), |
|
140 | + $integration->pluginName, |
|
141 | + $integration->supportedVersion |
|
142 | + )); |
|
143 | + return false; |
|
144 | + } |
|
145 | + return true; |
|
146 | + } |
|
147 | 147 | |
148 | - /** |
|
149 | - * @param string $license |
|
150 | - * @param string $slug |
|
151 | - * @return string |
|
152 | - */ |
|
153 | - protected function verifyLicense($license, $slug) |
|
154 | - { |
|
155 | - try { |
|
156 | - $addon = glsr($slug); |
|
157 | - $updater = new Updater($addon->update_url, $addon->file, [ |
|
158 | - 'license' => $license, |
|
159 | - 'testedTo' => $addon->testedTo, |
|
160 | - ]); |
|
161 | - if (!$updater->isLicenseValid()) { |
|
162 | - throw new Exception('Invalid license: '.$license.' ('.$addon->id.')'); |
|
163 | - } |
|
164 | - } catch (Exception $e) { |
|
165 | - $license = ''; |
|
166 | - glsr_log()->debug($e->getMessage()); |
|
167 | - glsr(Notice::class)->addError(__('A license you entered was invalid.', 'site-reviews')); |
|
168 | - } |
|
169 | - return $license; |
|
170 | - } |
|
148 | + /** |
|
149 | + * @param string $license |
|
150 | + * @param string $slug |
|
151 | + * @return string |
|
152 | + */ |
|
153 | + protected function verifyLicense($license, $slug) |
|
154 | + { |
|
155 | + try { |
|
156 | + $addon = glsr($slug); |
|
157 | + $updater = new Updater($addon->update_url, $addon->file, [ |
|
158 | + 'license' => $license, |
|
159 | + 'testedTo' => $addon->testedTo, |
|
160 | + ]); |
|
161 | + if (!$updater->isLicenseValid()) { |
|
162 | + throw new Exception('Invalid license: '.$license.' ('.$addon->id.')'); |
|
163 | + } |
|
164 | + } catch (Exception $e) { |
|
165 | + $license = ''; |
|
166 | + glsr_log()->debug($e->getMessage()); |
|
167 | + glsr(Notice::class)->addError(__('A license you entered was invalid.', 'site-reviews')); |
|
168 | + } |
|
169 | + return $license; |
|
170 | + } |
|
171 | 171 | } |
@@ -17,18 +17,18 @@ discard block |
||
17 | 17 | * @return array |
18 | 18 | * @callback register_setting |
19 | 19 | */ |
20 | - public function callbackRegisterSettings($input) |
|
20 | + public function callbackRegisterSettings( $input ) |
|
21 | 21 | { |
22 | - $settings = Arr::consolidateArray($input); |
|
23 | - if (1 === count($settings) && array_key_exists('settings', $settings)) { |
|
24 | - $options = array_replace_recursive(glsr(OptionManager::class)->all(), $input); |
|
25 | - $options = $this->sanitizeGeneral($input, $options); |
|
26 | - $options = $this->sanitizeLicenses($input, $options); |
|
27 | - $options = $this->sanitizeSubmissions($input, $options); |
|
28 | - $options = $this->sanitizeTranslations($input, $options); |
|
29 | - $options = apply_filters('site-reviews/settings/callback', $options, $settings); |
|
30 | - if (filter_input(INPUT_POST, 'option_page') == Application::ID.'-settings') { |
|
31 | - glsr(Notice::class)->addSuccess(__('Settings updated.', 'site-reviews')); |
|
22 | + $settings = Arr::consolidateArray( $input ); |
|
23 | + if( 1 === count( $settings ) && array_key_exists( 'settings', $settings ) ) { |
|
24 | + $options = array_replace_recursive( glsr( OptionManager::class )->all(), $input ); |
|
25 | + $options = $this->sanitizeGeneral( $input, $options ); |
|
26 | + $options = $this->sanitizeLicenses( $input, $options ); |
|
27 | + $options = $this->sanitizeSubmissions( $input, $options ); |
|
28 | + $options = $this->sanitizeTranslations( $input, $options ); |
|
29 | + $options = apply_filters( 'site-reviews/settings/callback', $options, $settings ); |
|
30 | + if( filter_input( INPUT_POST, 'option_page' ) == Application::ID.'-settings' ) { |
|
31 | + glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' ) ); |
|
32 | 32 | } |
33 | 33 | return $options; |
34 | 34 | } |
@@ -41,77 +41,77 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function registerSettings() |
43 | 43 | { |
44 | - register_setting(Application::ID.'-settings', OptionManager::databaseKey(), [ |
|
44 | + register_setting( Application::ID.'-settings', OptionManager::databaseKey(), [ |
|
45 | 45 | 'sanitize_callback' => [$this, 'callbackRegisterSettings'], |
46 | - ]); |
|
46 | + ] ); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @return array |
51 | 51 | */ |
52 | - protected function sanitizeGeneral(array $input, array $options) |
|
52 | + protected function sanitizeGeneral( array $input, array $options ) |
|
53 | 53 | { |
54 | 54 | $key = 'settings.general'; |
55 | - $inputForm = Arr::get($input, $key); |
|
56 | - if (!$this->hasMultilingualIntegration(Arr::get($inputForm, 'multilingual'))) { |
|
57 | - $options = Arr::set($options, $key.'.multilingual', ''); |
|
55 | + $inputForm = Arr::get( $input, $key ); |
|
56 | + if( !$this->hasMultilingualIntegration( Arr::get( $inputForm, 'multilingual' ) ) ) { |
|
57 | + $options = Arr::set( $options, $key.'.multilingual', '' ); |
|
58 | 58 | } |
59 | - if ('' == trim(Arr::get($inputForm, 'notification_message'))) { |
|
60 | - $defaultValue = Arr::get(glsr()->defaults, $key.'.notification_message'); |
|
61 | - $options = Arr::set($options, $key.'.notification_message', $defaultValue); |
|
59 | + if( '' == trim( Arr::get( $inputForm, 'notification_message' ) ) ) { |
|
60 | + $defaultValue = Arr::get( glsr()->defaults, $key.'.notification_message' ); |
|
61 | + $options = Arr::set( $options, $key.'.notification_message', $defaultValue ); |
|
62 | 62 | } |
63 | - $defaultValue = Arr::get($inputForm, 'notifications', []); |
|
64 | - $options = Arr::set($options, $key.'.notifications', $defaultValue); |
|
63 | + $defaultValue = Arr::get( $inputForm, 'notifications', [] ); |
|
64 | + $options = Arr::set( $options, $key.'.notifications', $defaultValue ); |
|
65 | 65 | return $options; |
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
69 | 69 | * @return array |
70 | 70 | */ |
71 | - protected function sanitizeLicenses(array $input, array $options) |
|
71 | + protected function sanitizeLicenses( array $input, array $options ) |
|
72 | 72 | { |
73 | 73 | $key = 'settings.licenses'; |
74 | - $licenses = Arr::consolidateArray(Arr::get($input, $key)); |
|
75 | - foreach ($licenses as $slug => &$license) { |
|
76 | - $license = $this->verifyLicense($license, $slug); |
|
74 | + $licenses = Arr::consolidateArray( Arr::get( $input, $key ) ); |
|
75 | + foreach( $licenses as $slug => &$license ) { |
|
76 | + $license = $this->verifyLicense( $license, $slug ); |
|
77 | 77 | } |
78 | - $options = Arr::set($options, $key, $licenses); |
|
78 | + $options = Arr::set( $options, $key, $licenses ); |
|
79 | 79 | return $options; |
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
83 | 83 | * @return array |
84 | 84 | */ |
85 | - protected function sanitizeSubmissions(array $input, array $options) |
|
85 | + protected function sanitizeSubmissions( array $input, array $options ) |
|
86 | 86 | { |
87 | 87 | $key = 'settings.submissions'; |
88 | - $inputForm = Arr::get($input, $key); |
|
88 | + $inputForm = Arr::get( $input, $key ); |
|
89 | 89 | $defaultValue = isset($inputForm['required']) |
90 | 90 | ? $inputForm['required'] |
91 | 91 | : []; |
92 | - $options = Arr::set($options, $key.'.required', $defaultValue); |
|
92 | + $options = Arr::set( $options, $key.'.required', $defaultValue ); |
|
93 | 93 | return $options; |
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
97 | 97 | * @return array |
98 | 98 | */ |
99 | - protected function sanitizeTranslations(array $input, array $options) |
|
99 | + protected function sanitizeTranslations( array $input, array $options ) |
|
100 | 100 | { |
101 | 101 | $key = 'settings.strings'; |
102 | - $inputForm = Arr::consolidateArray(Arr::get($input, $key)); |
|
103 | - if (!empty($inputForm)) { |
|
104 | - $options = Arr::set($options, $key, array_values(array_filter($inputForm))); |
|
102 | + $inputForm = Arr::consolidateArray( Arr::get( $input, $key ) ); |
|
103 | + if( !empty($inputForm) ) { |
|
104 | + $options = Arr::set( $options, $key, array_values( array_filter( $inputForm ) ) ); |
|
105 | 105 | $allowedTags = [ |
106 | 106 | 'a' => ['class' => [], 'href' => [], 'target' => []], |
107 | 107 | 'span' => ['class' => []], |
108 | 108 | ]; |
109 | - array_walk($options['settings']['strings'], function (&$string) use ($allowedTags) { |
|
110 | - if (isset($string['s2'])) { |
|
111 | - $string['s2'] = wp_kses($string['s2'], $allowedTags); |
|
109 | + array_walk( $options['settings']['strings'], function( &$string ) use ($allowedTags) { |
|
110 | + if( isset($string['s2']) ) { |
|
111 | + $string['s2'] = wp_kses( $string['s2'], $allowedTags ); |
|
112 | 112 | } |
113 | - if (isset($string['p2'])) { |
|
114 | - $string['p2'] = wp_kses($string['p2'], $allowedTags); |
|
113 | + if( isset($string['p2']) ) { |
|
114 | + $string['p2'] = wp_kses( $string['p2'], $allowedTags ); |
|
115 | 115 | } |
116 | 116 | }); |
117 | 117 | } |
@@ -122,24 +122,24 @@ discard block |
||
122 | 122 | * @param string $integrationSlug |
123 | 123 | * @return bool |
124 | 124 | */ |
125 | - protected function hasMultilingualIntegration($integrationSlug) |
|
125 | + protected function hasMultilingualIntegration( $integrationSlug ) |
|
126 | 126 | { |
127 | - $integration = glsr(Multilingual::class)->getIntegration($integrationSlug); |
|
128 | - if (!$integration) { |
|
127 | + $integration = glsr( Multilingual::class )->getIntegration( $integrationSlug ); |
|
128 | + if( !$integration ) { |
|
129 | 129 | return false; |
130 | 130 | } |
131 | - if (!$integration->isActive()) { |
|
132 | - glsr(Notice::class)->addError(sprintf( |
|
133 | - __('Please install/activate the %s plugin to enable integration.', 'site-reviews'), |
|
131 | + if( !$integration->isActive() ) { |
|
132 | + glsr( Notice::class )->addError( sprintf( |
|
133 | + __( 'Please install/activate the %s plugin to enable integration.', 'site-reviews' ), |
|
134 | 134 | $integration->pluginName |
135 | - )); |
|
135 | + ) ); |
|
136 | 136 | return false; |
137 | - } elseif (!$integration->isSupported()) { |
|
138 | - glsr(Notice::class)->addError(sprintf( |
|
139 | - __('Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews'), |
|
137 | + } elseif( !$integration->isSupported() ) { |
|
138 | + glsr( Notice::class )->addError( sprintf( |
|
139 | + __( 'Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews' ), |
|
140 | 140 | $integration->pluginName, |
141 | 141 | $integration->supportedVersion |
142 | - )); |
|
142 | + ) ); |
|
143 | 143 | return false; |
144 | 144 | } |
145 | 145 | return true; |
@@ -150,21 +150,21 @@ discard block |
||
150 | 150 | * @param string $slug |
151 | 151 | * @return string |
152 | 152 | */ |
153 | - protected function verifyLicense($license, $slug) |
|
153 | + protected function verifyLicense( $license, $slug ) |
|
154 | 154 | { |
155 | 155 | try { |
156 | - $addon = glsr($slug); |
|
157 | - $updater = new Updater($addon->update_url, $addon->file, [ |
|
156 | + $addon = glsr( $slug ); |
|
157 | + $updater = new Updater( $addon->update_url, $addon->file, [ |
|
158 | 158 | 'license' => $license, |
159 | 159 | 'testedTo' => $addon->testedTo, |
160 | - ]); |
|
161 | - if (!$updater->isLicenseValid()) { |
|
162 | - throw new Exception('Invalid license: '.$license.' ('.$addon->id.')'); |
|
160 | + ] ); |
|
161 | + if( !$updater->isLicenseValid() ) { |
|
162 | + throw new Exception( 'Invalid license: '.$license.' ('.$addon->id.')' ); |
|
163 | 163 | } |
164 | - } catch (Exception $e) { |
|
164 | + } catch( Exception $e ) { |
|
165 | 165 | $license = ''; |
166 | - glsr_log()->debug($e->getMessage()); |
|
167 | - glsr(Notice::class)->addError(__('A license you entered was invalid.', 'site-reviews')); |
|
166 | + glsr_log()->debug( $e->getMessage() ); |
|
167 | + glsr( Notice::class )->addError( __( 'A license you entered was invalid.', 'site-reviews' ) ); |
|
168 | 168 | } |
169 | 169 | return $license; |
170 | 170 | } |
@@ -134,7 +134,8 @@ discard block |
||
134 | 134 | $integration->pluginName |
135 | 135 | )); |
136 | 136 | return false; |
137 | - } elseif (!$integration->isSupported()) { |
|
137 | + } |
|
138 | + elseif (!$integration->isSupported()) { |
|
138 | 139 | glsr(Notice::class)->addError(sprintf( |
139 | 140 | __('Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews'), |
140 | 141 | $integration->pluginName, |
@@ -161,7 +162,8 @@ discard block |
||
161 | 162 | if (!$updater->isLicenseValid()) { |
162 | 163 | throw new Exception('Invalid license: '.$license.' ('.$addon->id.')'); |
163 | 164 | } |
164 | - } catch (Exception $e) { |
|
165 | + } |
|
166 | + catch (Exception $e) { |
|
165 | 167 | $license = ''; |
166 | 168 | glsr_log()->debug($e->getMessage()); |
167 | 169 | glsr(Notice::class)->addError(__('A license you entered was invalid.', 'site-reviews')); |
@@ -9,65 +9,65 @@ |
||
9 | 9 | |
10 | 10 | class Reviews extends ArrayObject |
11 | 11 | { |
12 | - /** |
|
13 | - * @var array |
|
14 | - */ |
|
15 | - public $args; |
|
12 | + /** |
|
13 | + * @var array |
|
14 | + */ |
|
15 | + public $args; |
|
16 | 16 | |
17 | - /** |
|
18 | - * @var int |
|
19 | - */ |
|
20 | - public $max_num_pages; |
|
17 | + /** |
|
18 | + * @var int |
|
19 | + */ |
|
20 | + public $max_num_pages; |
|
21 | 21 | |
22 | - /** |
|
23 | - * @var array |
|
24 | - */ |
|
25 | - public $reviews; |
|
22 | + /** |
|
23 | + * @var array |
|
24 | + */ |
|
25 | + public $reviews; |
|
26 | 26 | |
27 | - public function __construct(array $reviews, $maxPageCount, array $args) |
|
28 | - { |
|
29 | - $this->args = $args; |
|
30 | - $this->max_num_pages = $maxPageCount; |
|
31 | - $this->reviews = $reviews; |
|
32 | - parent::__construct($reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS); |
|
33 | - } |
|
27 | + public function __construct(array $reviews, $maxPageCount, array $args) |
|
28 | + { |
|
29 | + $this->args = $args; |
|
30 | + $this->max_num_pages = $maxPageCount; |
|
31 | + $this->reviews = $reviews; |
|
32 | + parent::__construct($reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * @return string |
|
37 | - */ |
|
38 | - public function __toString() |
|
39 | - { |
|
40 | - return (string) $this->build(); |
|
41 | - } |
|
35 | + /** |
|
36 | + * @return string |
|
37 | + */ |
|
38 | + public function __toString() |
|
39 | + { |
|
40 | + return (string) $this->build(); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return ReviewsHtml |
|
45 | - */ |
|
46 | - public function build() |
|
47 | - { |
|
48 | - $args = glsr(SiteReviewsDefaults::class)->merge($this->args); |
|
49 | - return glsr(SiteReviewsPartial::class)->build($args, $this); |
|
50 | - } |
|
43 | + /** |
|
44 | + * @return ReviewsHtml |
|
45 | + */ |
|
46 | + public function build() |
|
47 | + { |
|
48 | + $args = glsr(SiteReviewsDefaults::class)->merge($this->args); |
|
49 | + return glsr(SiteReviewsPartial::class)->build($args, $this); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @param mixed $key |
|
54 | - * @return mixed |
|
55 | - */ |
|
56 | - public function offsetGet($key) |
|
57 | - { |
|
58 | - if (array_key_exists($key, $this->reviews)) { |
|
59 | - return $this->reviews[$key]; |
|
60 | - } |
|
61 | - return property_exists($this, $key) |
|
62 | - ? $this->$key |
|
63 | - : null; |
|
64 | - } |
|
52 | + /** |
|
53 | + * @param mixed $key |
|
54 | + * @return mixed |
|
55 | + */ |
|
56 | + public function offsetGet($key) |
|
57 | + { |
|
58 | + if (array_key_exists($key, $this->reviews)) { |
|
59 | + return $this->reviews[$key]; |
|
60 | + } |
|
61 | + return property_exists($this, $key) |
|
62 | + ? $this->$key |
|
63 | + : null; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @return void |
|
68 | - */ |
|
69 | - public function render() |
|
70 | - { |
|
71 | - echo $this->build(); |
|
72 | - } |
|
66 | + /** |
|
67 | + * @return void |
|
68 | + */ |
|
69 | + public function render() |
|
70 | + { |
|
71 | + echo $this->build(); |
|
72 | + } |
|
73 | 73 | } |
@@ -24,12 +24,12 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public $reviews; |
26 | 26 | |
27 | - public function __construct(array $reviews, $maxPageCount, array $args) |
|
27 | + public function __construct( array $reviews, $maxPageCount, array $args ) |
|
28 | 28 | { |
29 | 29 | $this->args = $args; |
30 | 30 | $this->max_num_pages = $maxPageCount; |
31 | 31 | $this->reviews = $reviews; |
32 | - parent::__construct($reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS); |
|
32 | + parent::__construct( $reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS ); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function __toString() |
39 | 39 | { |
40 | - return (string) $this->build(); |
|
40 | + return (string)$this->build(); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -45,20 +45,20 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function build() |
47 | 47 | { |
48 | - $args = glsr(SiteReviewsDefaults::class)->merge($this->args); |
|
49 | - return glsr(SiteReviewsPartial::class)->build($args, $this); |
|
48 | + $args = glsr( SiteReviewsDefaults::class )->merge( $this->args ); |
|
49 | + return glsr( SiteReviewsPartial::class )->build( $args, $this ); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @param mixed $key |
54 | 54 | * @return mixed |
55 | 55 | */ |
56 | - public function offsetGet($key) |
|
56 | + public function offsetGet( $key ) |
|
57 | 57 | { |
58 | - if (array_key_exists($key, $this->reviews)) { |
|
58 | + if( array_key_exists( $key, $this->reviews ) ) { |
|
59 | 59 | return $this->reviews[$key]; |
60 | 60 | } |
61 | - return property_exists($this, $key) |
|
61 | + return property_exists( $this, $key ) |
|
62 | 62 | ? $this->$key |
63 | 63 | : null; |
64 | 64 | } |
@@ -207,7 +207,8 @@ |
||
207 | 207 | $this->bind($id, $addon); |
208 | 208 | $addon->init(); |
209 | 209 | } |
210 | - } catch(\ReflectionException $e) { |
|
210 | + } |
|
211 | + catch(\ReflectionException $e) { |
|
211 | 212 | glsr_log()->error('Attempted to register an invalid addon.'); |
212 | 213 | } |
213 | 214 | } |
@@ -17,356 +17,356 @@ |
||
17 | 17 | */ |
18 | 18 | final class Application extends Container |
19 | 19 | { |
20 | - const CAPABILITY = 'edit_others_posts'; |
|
21 | - const CRON_EVENT = 'site-reviews/schedule/session/purge'; |
|
22 | - const ID = 'site-reviews'; |
|
23 | - const PAGED_QUERY_VAR = 'reviews-page'; |
|
24 | - const POST_TYPE = 'site-review'; |
|
25 | - const PREFIX = 'glsr_'; |
|
26 | - const TAXONOMY = 'site-review-category'; |
|
20 | + const CAPABILITY = 'edit_others_posts'; |
|
21 | + const CRON_EVENT = 'site-reviews/schedule/session/purge'; |
|
22 | + const ID = 'site-reviews'; |
|
23 | + const PAGED_QUERY_VAR = 'reviews-page'; |
|
24 | + const POST_TYPE = 'site-review'; |
|
25 | + const PREFIX = 'glsr_'; |
|
26 | + const TAXONOMY = 'site-review-category'; |
|
27 | 27 | |
28 | - public $addons = []; |
|
29 | - public $defaults; |
|
30 | - public $deprecated = []; |
|
31 | - public $file; |
|
32 | - public $languages; |
|
33 | - public $mceShortcodes = []; //defined elsewhere |
|
34 | - public $name; |
|
35 | - public $postTypeColumns = []; // defined elsewhere |
|
36 | - public $reviewTypes; |
|
37 | - public $schemas = []; //defined elsewhere |
|
38 | - public $version; |
|
28 | + public $addons = []; |
|
29 | + public $defaults; |
|
30 | + public $deprecated = []; |
|
31 | + public $file; |
|
32 | + public $languages; |
|
33 | + public $mceShortcodes = []; //defined elsewhere |
|
34 | + public $name; |
|
35 | + public $postTypeColumns = []; // defined elsewhere |
|
36 | + public $reviewTypes; |
|
37 | + public $schemas = []; //defined elsewhere |
|
38 | + public $version; |
|
39 | 39 | |
40 | - public function __construct() |
|
41 | - { |
|
42 | - static::$instance = $this; |
|
43 | - $this->file = realpath(trailingslashit(dirname(__DIR__)).static::ID.'.php'); |
|
44 | - $plugin = get_file_data($this->file, [ |
|
45 | - 'languages' => 'Domain Path', |
|
46 | - 'name' => 'Plugin Name', |
|
47 | - 'version' => 'Version', |
|
48 | - ], 'plugin'); |
|
49 | - array_walk($plugin, function ($value, $key) { |
|
50 | - $this->$key = $value; |
|
51 | - }); |
|
52 | - } |
|
40 | + public function __construct() |
|
41 | + { |
|
42 | + static::$instance = $this; |
|
43 | + $this->file = realpath(trailingslashit(dirname(__DIR__)).static::ID.'.php'); |
|
44 | + $plugin = get_file_data($this->file, [ |
|
45 | + 'languages' => 'Domain Path', |
|
46 | + 'name' => 'Plugin Name', |
|
47 | + 'version' => 'Version', |
|
48 | + ], 'plugin'); |
|
49 | + array_walk($plugin, function ($value, $key) { |
|
50 | + $this->$key = $value; |
|
51 | + }); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @return void |
|
56 | - */ |
|
57 | - public function activate() |
|
58 | - { |
|
59 | - $this->scheduleCronJob(); |
|
60 | - add_option(static::PREFIX.'activated', true); |
|
61 | - } |
|
54 | + /** |
|
55 | + * @return void |
|
56 | + */ |
|
57 | + public function activate() |
|
58 | + { |
|
59 | + $this->scheduleCronJob(); |
|
60 | + add_option(static::PREFIX.'activated', true); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @param string $view |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public function build($view, array $data = []) |
|
68 | - { |
|
69 | - ob_start(); |
|
70 | - $this->render($view, $data); |
|
71 | - return ob_get_clean(); |
|
72 | - } |
|
63 | + /** |
|
64 | + * @param string $view |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public function build($view, array $data = []) |
|
68 | + { |
|
69 | + ob_start(); |
|
70 | + $this->render($view, $data); |
|
71 | + return ob_get_clean(); |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @param string $capability |
|
76 | - * @return bool |
|
77 | - */ |
|
78 | - public function can($capability) |
|
79 | - { |
|
80 | - return $this->make(Role::class)->can($capability); |
|
81 | - } |
|
74 | + /** |
|
75 | + * @param string $capability |
|
76 | + * @return bool |
|
77 | + */ |
|
78 | + public function can($capability) |
|
79 | + { |
|
80 | + return $this->make(Role::class)->can($capability); |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * @return void |
|
85 | - */ |
|
86 | - public function catchFatalError() |
|
87 | - { |
|
88 | - $error = error_get_last(); |
|
89 | - if (E_ERROR !== $error['type'] || !Str::contains($error['message'], $this->path())) { |
|
90 | - return; |
|
91 | - } |
|
92 | - glsr_log()->error($error['message']); |
|
93 | - } |
|
83 | + /** |
|
84 | + * @return void |
|
85 | + */ |
|
86 | + public function catchFatalError() |
|
87 | + { |
|
88 | + $error = error_get_last(); |
|
89 | + if (E_ERROR !== $error['type'] || !Str::contains($error['message'], $this->path())) { |
|
90 | + return; |
|
91 | + } |
|
92 | + glsr_log()->error($error['message']); |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * @param string $name |
|
97 | - * @return array |
|
98 | - */ |
|
99 | - public function config($name) |
|
100 | - { |
|
101 | - $configFile = $this->path('config/'.$name.'.php'); |
|
102 | - $config = file_exists($configFile) |
|
103 | - ? include $configFile |
|
104 | - : []; |
|
105 | - return apply_filters('site-reviews/config/'.$name, $config); |
|
106 | - } |
|
95 | + /** |
|
96 | + * @param string $name |
|
97 | + * @return array |
|
98 | + */ |
|
99 | + public function config($name) |
|
100 | + { |
|
101 | + $configFile = $this->path('config/'.$name.'.php'); |
|
102 | + $config = file_exists($configFile) |
|
103 | + ? include $configFile |
|
104 | + : []; |
|
105 | + return apply_filters('site-reviews/config/'.$name, $config); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * @param string $property |
|
110 | - * @return string |
|
111 | - */ |
|
112 | - public function constant($property, $className = 'static') |
|
113 | - { |
|
114 | - $constant = $className.'::'.$property; |
|
115 | - return defined($constant) |
|
116 | - ? apply_filters('site-reviews/const/'.$property, constant($constant)) |
|
117 | - : ''; |
|
118 | - } |
|
108 | + /** |
|
109 | + * @param string $property |
|
110 | + * @return string |
|
111 | + */ |
|
112 | + public function constant($property, $className = 'static') |
|
113 | + { |
|
114 | + $constant = $className.'::'.$property; |
|
115 | + return defined($constant) |
|
116 | + ? apply_filters('site-reviews/const/'.$property, constant($constant)) |
|
117 | + : ''; |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * @return void |
|
122 | - */ |
|
123 | - public function deactivate() |
|
124 | - { |
|
125 | - $this->unscheduleCronJob(); |
|
126 | - } |
|
120 | + /** |
|
121 | + * @return void |
|
122 | + */ |
|
123 | + public function deactivate() |
|
124 | + { |
|
125 | + $this->unscheduleCronJob(); |
|
126 | + } |
|
127 | 127 | |
128 | - /** |
|
129 | - * @param string $view |
|
130 | - * @return void|string |
|
131 | - */ |
|
132 | - public function file($view) |
|
133 | - { |
|
134 | - $view.= '.php'; |
|
135 | - $filePaths = []; |
|
136 | - if (Str::startsWith('templates/', $view)) { |
|
137 | - $filePaths[] = $this->themePath(Str::removePrefix('templates/', $view)); |
|
138 | - } |
|
139 | - $filePaths[] = $this->path($view); |
|
140 | - $filePaths[] = $this->path('views/'.$view); |
|
141 | - foreach ($filePaths as $file) { |
|
142 | - if (!file_exists($file)) { |
|
143 | - continue; |
|
144 | - } |
|
145 | - return $file; |
|
146 | - } |
|
147 | - } |
|
128 | + /** |
|
129 | + * @param string $view |
|
130 | + * @return void|string |
|
131 | + */ |
|
132 | + public function file($view) |
|
133 | + { |
|
134 | + $view.= '.php'; |
|
135 | + $filePaths = []; |
|
136 | + if (Str::startsWith('templates/', $view)) { |
|
137 | + $filePaths[] = $this->themePath(Str::removePrefix('templates/', $view)); |
|
138 | + } |
|
139 | + $filePaths[] = $this->path($view); |
|
140 | + $filePaths[] = $this->path('views/'.$view); |
|
141 | + foreach ($filePaths as $file) { |
|
142 | + if (!file_exists($file)) { |
|
143 | + continue; |
|
144 | + } |
|
145 | + return $file; |
|
146 | + } |
|
147 | + } |
|
148 | 148 | |
149 | - /** |
|
150 | - * @return array |
|
151 | - */ |
|
152 | - public function getDefaults() |
|
153 | - { |
|
154 | - if (empty($this->defaults)) { |
|
155 | - $this->defaults = $this->make(DefaultsManager::class)->get(); |
|
156 | - } |
|
157 | - return apply_filters('site-reviews/get/defaults', $this->defaults); |
|
158 | - } |
|
149 | + /** |
|
150 | + * @return array |
|
151 | + */ |
|
152 | + public function getDefaults() |
|
153 | + { |
|
154 | + if (empty($this->defaults)) { |
|
155 | + $this->defaults = $this->make(DefaultsManager::class)->get(); |
|
156 | + } |
|
157 | + return apply_filters('site-reviews/get/defaults', $this->defaults); |
|
158 | + } |
|
159 | 159 | |
160 | - /** |
|
161 | - * @param string $page |
|
162 | - * @param string $tab |
|
163 | - * @return string |
|
164 | - */ |
|
165 | - public function getPermission($page = '', $tab = 'index') |
|
166 | - { |
|
167 | - $fallback = 'edit_posts'; |
|
168 | - $permissions = [ |
|
169 | - 'addons' => 'install_plugins', |
|
170 | - 'documentation' => [ |
|
171 | - 'faq' => 'edit_others_posts', |
|
172 | - 'functions' => 'manage_options', |
|
173 | - 'hooks' => 'edit_others_posts', |
|
174 | - 'index' => 'edit_posts', |
|
175 | - 'support' => 'edit_others_posts', |
|
176 | - ], |
|
177 | - 'settings' => 'manage_options', |
|
178 | - 'tools' => [ |
|
179 | - 'console' => 'edit_others_posts', |
|
180 | - 'general' => 'edit_others_posts', |
|
181 | - 'index' => 'edit_others_posts', |
|
182 | - 'sync' => 'manage_options', |
|
183 | - 'system-info' => 'edit_others_posts', |
|
184 | - ] |
|
185 | - ]; |
|
186 | - $permission = Arr::get($permissions, $page, $fallback); |
|
187 | - if (is_array($permission)) { |
|
188 | - $permission = Arr::get($permission, $tab, $fallback); |
|
189 | - } |
|
190 | - return empty($permission) || !is_string($permission) |
|
191 | - ? $fallback |
|
192 | - : $permission; |
|
193 | - } |
|
160 | + /** |
|
161 | + * @param string $page |
|
162 | + * @param string $tab |
|
163 | + * @return string |
|
164 | + */ |
|
165 | + public function getPermission($page = '', $tab = 'index') |
|
166 | + { |
|
167 | + $fallback = 'edit_posts'; |
|
168 | + $permissions = [ |
|
169 | + 'addons' => 'install_plugins', |
|
170 | + 'documentation' => [ |
|
171 | + 'faq' => 'edit_others_posts', |
|
172 | + 'functions' => 'manage_options', |
|
173 | + 'hooks' => 'edit_others_posts', |
|
174 | + 'index' => 'edit_posts', |
|
175 | + 'support' => 'edit_others_posts', |
|
176 | + ], |
|
177 | + 'settings' => 'manage_options', |
|
178 | + 'tools' => [ |
|
179 | + 'console' => 'edit_others_posts', |
|
180 | + 'general' => 'edit_others_posts', |
|
181 | + 'index' => 'edit_others_posts', |
|
182 | + 'sync' => 'manage_options', |
|
183 | + 'system-info' => 'edit_others_posts', |
|
184 | + ] |
|
185 | + ]; |
|
186 | + $permission = Arr::get($permissions, $page, $fallback); |
|
187 | + if (is_array($permission)) { |
|
188 | + $permission = Arr::get($permission, $tab, $fallback); |
|
189 | + } |
|
190 | + return empty($permission) || !is_string($permission) |
|
191 | + ? $fallback |
|
192 | + : $permission; |
|
193 | + } |
|
194 | 194 | |
195 | - /** |
|
196 | - * @param string $page |
|
197 | - * @param string $tab |
|
198 | - * @return bool |
|
199 | - */ |
|
200 | - public function hasPermission($page = '', $tab = 'index') |
|
201 | - { |
|
202 | - $isAdmin = $this->isAdmin(); |
|
203 | - return !$isAdmin || ($isAdmin && $this->can($this->getPermission($page, $tab))); |
|
204 | - } |
|
195 | + /** |
|
196 | + * @param string $page |
|
197 | + * @param string $tab |
|
198 | + * @return bool |
|
199 | + */ |
|
200 | + public function hasPermission($page = '', $tab = 'index') |
|
201 | + { |
|
202 | + $isAdmin = $this->isAdmin(); |
|
203 | + return !$isAdmin || ($isAdmin && $this->can($this->getPermission($page, $tab))); |
|
204 | + } |
|
205 | 205 | |
206 | - /** |
|
207 | - * @return void |
|
208 | - */ |
|
209 | - public function init() |
|
210 | - { |
|
211 | - $this->make(Actions::class)->run(); |
|
212 | - $this->make(Filters::class)->run(); |
|
213 | - } |
|
206 | + /** |
|
207 | + * @return void |
|
208 | + */ |
|
209 | + public function init() |
|
210 | + { |
|
211 | + $this->make(Actions::class)->run(); |
|
212 | + $this->make(Filters::class)->run(); |
|
213 | + } |
|
214 | 214 | |
215 | - /** |
|
216 | - * @return bool |
|
217 | - */ |
|
218 | - public function isAdmin() |
|
219 | - { |
|
220 | - return is_admin() && !wp_doing_ajax(); |
|
221 | - } |
|
215 | + /** |
|
216 | + * @return bool |
|
217 | + */ |
|
218 | + public function isAdmin() |
|
219 | + { |
|
220 | + return is_admin() && !wp_doing_ajax(); |
|
221 | + } |
|
222 | 222 | |
223 | - /** |
|
224 | - * @param string $file |
|
225 | - * @return string |
|
226 | - */ |
|
227 | - public function path($file = '', $realpath = true) |
|
228 | - { |
|
229 | - $path = plugin_dir_path($this->file); |
|
230 | - if (!$realpath) { |
|
231 | - $path = trailingslashit(WP_PLUGIN_DIR).basename(dirname($this->file)); |
|
232 | - } |
|
233 | - $path = trailingslashit($path).ltrim(trim($file), '/'); |
|
234 | - return apply_filters('site-reviews/path', $path, $file); |
|
235 | - } |
|
223 | + /** |
|
224 | + * @param string $file |
|
225 | + * @return string |
|
226 | + */ |
|
227 | + public function path($file = '', $realpath = true) |
|
228 | + { |
|
229 | + $path = plugin_dir_path($this->file); |
|
230 | + if (!$realpath) { |
|
231 | + $path = trailingslashit(WP_PLUGIN_DIR).basename(dirname($this->file)); |
|
232 | + } |
|
233 | + $path = trailingslashit($path).ltrim(trim($file), '/'); |
|
234 | + return apply_filters('site-reviews/path', $path, $file); |
|
235 | + } |
|
236 | 236 | |
237 | - /** |
|
238 | - * @param object $addon |
|
239 | - * @return void |
|
240 | - */ |
|
241 | - public function register($addon) |
|
242 | - { |
|
243 | - try { |
|
244 | - $reflection = new \ReflectionClass($addon); |
|
245 | - if ($id = $reflection->getConstant('ID')) { |
|
246 | - $this->addons[] = $id; |
|
247 | - $this->bind($id, $addon); |
|
248 | - $addon->init(); |
|
249 | - } |
|
250 | - } catch(\ReflectionException $e) { |
|
251 | - glsr_log()->error('Attempted to register an invalid addon.'); |
|
252 | - } |
|
253 | - } |
|
237 | + /** |
|
238 | + * @param object $addon |
|
239 | + * @return void |
|
240 | + */ |
|
241 | + public function register($addon) |
|
242 | + { |
|
243 | + try { |
|
244 | + $reflection = new \ReflectionClass($addon); |
|
245 | + if ($id = $reflection->getConstant('ID')) { |
|
246 | + $this->addons[] = $id; |
|
247 | + $this->bind($id, $addon); |
|
248 | + $addon->init(); |
|
249 | + } |
|
250 | + } catch(\ReflectionException $e) { |
|
251 | + glsr_log()->error('Attempted to register an invalid addon.'); |
|
252 | + } |
|
253 | + } |
|
254 | 254 | |
255 | - /** |
|
256 | - * @return void |
|
257 | - */ |
|
258 | - public function registerAddons() |
|
259 | - { |
|
260 | - do_action('site-reviews/addon/register', $this); |
|
261 | - } |
|
255 | + /** |
|
256 | + * @return void |
|
257 | + */ |
|
258 | + public function registerAddons() |
|
259 | + { |
|
260 | + do_action('site-reviews/addon/register', $this); |
|
261 | + } |
|
262 | 262 | |
263 | - /** |
|
264 | - * @return void |
|
265 | - */ |
|
266 | - public function registerLanguages() |
|
267 | - { |
|
268 | - load_plugin_textdomain(static::ID, false, |
|
269 | - trailingslashit(plugin_basename($this->path()).'/'.$this->languages) |
|
270 | - ); |
|
271 | - } |
|
263 | + /** |
|
264 | + * @return void |
|
265 | + */ |
|
266 | + public function registerLanguages() |
|
267 | + { |
|
268 | + load_plugin_textdomain(static::ID, false, |
|
269 | + trailingslashit(plugin_basename($this->path()).'/'.$this->languages) |
|
270 | + ); |
|
271 | + } |
|
272 | 272 | |
273 | - /** |
|
274 | - * @return void |
|
275 | - */ |
|
276 | - public function registerReviewTypes() |
|
277 | - { |
|
278 | - $types = apply_filters('site-reviews/addon/types', []); |
|
279 | - $this->reviewTypes = wp_parse_args($types, [ |
|
280 | - 'local' => __('Local', 'site-reviews'), |
|
281 | - ]); |
|
282 | - } |
|
273 | + /** |
|
274 | + * @return void |
|
275 | + */ |
|
276 | + public function registerReviewTypes() |
|
277 | + { |
|
278 | + $types = apply_filters('site-reviews/addon/types', []); |
|
279 | + $this->reviewTypes = wp_parse_args($types, [ |
|
280 | + 'local' => __('Local', 'site-reviews'), |
|
281 | + ]); |
|
282 | + } |
|
283 | 283 | |
284 | - /** |
|
285 | - * @param string $view |
|
286 | - * @return void |
|
287 | - */ |
|
288 | - public function render($view, array $data = []) |
|
289 | - { |
|
290 | - $view = apply_filters('site-reviews/render/view', $view, $data); |
|
291 | - $file = apply_filters('site-reviews/views/file', $this->file($view), $view, $data); |
|
292 | - if (!file_exists($file)) { |
|
293 | - glsr_log()->error('File not found: '.$file); |
|
294 | - return; |
|
295 | - } |
|
296 | - $data = apply_filters('site-reviews/views/data', $data, $view); |
|
297 | - extract($data); |
|
298 | - include $file; |
|
299 | - } |
|
284 | + /** |
|
285 | + * @param string $view |
|
286 | + * @return void |
|
287 | + */ |
|
288 | + public function render($view, array $data = []) |
|
289 | + { |
|
290 | + $view = apply_filters('site-reviews/render/view', $view, $data); |
|
291 | + $file = apply_filters('site-reviews/views/file', $this->file($view), $view, $data); |
|
292 | + if (!file_exists($file)) { |
|
293 | + glsr_log()->error('File not found: '.$file); |
|
294 | + return; |
|
295 | + } |
|
296 | + $data = apply_filters('site-reviews/views/data', $data, $view); |
|
297 | + extract($data); |
|
298 | + include $file; |
|
299 | + } |
|
300 | 300 | |
301 | - /** |
|
302 | - * @return void |
|
303 | - */ |
|
304 | - public function scheduleCronJob() |
|
305 | - { |
|
306 | - if (false === wp_next_scheduled(static::CRON_EVENT)) { |
|
307 | - wp_schedule_event(time(), 'twicedaily', static::CRON_EVENT); |
|
308 | - } |
|
309 | - } |
|
301 | + /** |
|
302 | + * @return void |
|
303 | + */ |
|
304 | + public function scheduleCronJob() |
|
305 | + { |
|
306 | + if (false === wp_next_scheduled(static::CRON_EVENT)) { |
|
307 | + wp_schedule_event(time(), 'twicedaily', static::CRON_EVENT); |
|
308 | + } |
|
309 | + } |
|
310 | 310 | |
311 | - /** |
|
312 | - * @return void |
|
313 | - */ |
|
314 | - public function setDefaults() |
|
315 | - { |
|
316 | - if (get_option(static::PREFIX.'activated')) { |
|
317 | - $this->make(DefaultsManager::class)->set(); |
|
318 | - delete_option(static::PREFIX.'activated'); |
|
319 | - } |
|
320 | - } |
|
311 | + /** |
|
312 | + * @return void |
|
313 | + */ |
|
314 | + public function setDefaults() |
|
315 | + { |
|
316 | + if (get_option(static::PREFIX.'activated')) { |
|
317 | + $this->make(DefaultsManager::class)->set(); |
|
318 | + delete_option(static::PREFIX.'activated'); |
|
319 | + } |
|
320 | + } |
|
321 | 321 | |
322 | - /** |
|
323 | - * @param string $file |
|
324 | - * @return string |
|
325 | - */ |
|
326 | - public function themePath($file = '') |
|
327 | - { |
|
328 | - return get_stylesheet_directory().'/'.static::ID.'/'.ltrim(trim($file), '/'); |
|
329 | - } |
|
322 | + /** |
|
323 | + * @param string $file |
|
324 | + * @return string |
|
325 | + */ |
|
326 | + public function themePath($file = '') |
|
327 | + { |
|
328 | + return get_stylesheet_directory().'/'.static::ID.'/'.ltrim(trim($file), '/'); |
|
329 | + } |
|
330 | 330 | |
331 | - /** |
|
332 | - * @return void |
|
333 | - */ |
|
334 | - public function unscheduleCronJob() |
|
335 | - { |
|
336 | - wp_unschedule_event(intval(wp_next_scheduled(static::CRON_EVENT)), static::CRON_EVENT); |
|
337 | - } |
|
331 | + /** |
|
332 | + * @return void |
|
333 | + */ |
|
334 | + public function unscheduleCronJob() |
|
335 | + { |
|
336 | + wp_unschedule_event(intval(wp_next_scheduled(static::CRON_EVENT)), static::CRON_EVENT); |
|
337 | + } |
|
338 | 338 | |
339 | - /** |
|
340 | - * @param string $path |
|
341 | - * @return string |
|
342 | - */ |
|
343 | - public function url($path = '') |
|
344 | - { |
|
345 | - $url = esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/')); |
|
346 | - return apply_filters('site-reviews/url', $url, $path); |
|
347 | - } |
|
339 | + /** |
|
340 | + * @param string $path |
|
341 | + * @return string |
|
342 | + */ |
|
343 | + public function url($path = '') |
|
344 | + { |
|
345 | + $url = esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/')); |
|
346 | + return apply_filters('site-reviews/url', $url, $path); |
|
347 | + } |
|
348 | 348 | |
349 | - /** |
|
350 | - * @param string $versionLevel |
|
351 | - * @return string |
|
352 | - */ |
|
353 | - public function version($versionLevel = '') |
|
354 | - { |
|
355 | - $pattern = '/^v?(\d{1,5})(\.\d++)?(\.\d++)?(.+)?$/i'; |
|
356 | - preg_match($pattern, $this->version, $matches); |
|
357 | - switch ($versionLevel) { |
|
358 | - case 'major': |
|
359 | - $version = Arr::get($matches, 1); |
|
360 | - break; |
|
361 | - case 'minor': |
|
362 | - $version = Arr::get($matches, 1).Arr::get($matches, 2); |
|
363 | - break; |
|
364 | - case 'patch': |
|
365 | - $version = Arr::get($matches, 1).Arr::get($matches, 2).Arr::get($matches, 3); |
|
366 | - break; |
|
367 | - } |
|
368 | - return empty($version) |
|
369 | - ? $this->version |
|
370 | - : $version; |
|
371 | - } |
|
349 | + /** |
|
350 | + * @param string $versionLevel |
|
351 | + * @return string |
|
352 | + */ |
|
353 | + public function version($versionLevel = '') |
|
354 | + { |
|
355 | + $pattern = '/^v?(\d{1,5})(\.\d++)?(\.\d++)?(.+)?$/i'; |
|
356 | + preg_match($pattern, $this->version, $matches); |
|
357 | + switch ($versionLevel) { |
|
358 | + case 'major': |
|
359 | + $version = Arr::get($matches, 1); |
|
360 | + break; |
|
361 | + case 'minor': |
|
362 | + $version = Arr::get($matches, 1).Arr::get($matches, 2); |
|
363 | + break; |
|
364 | + case 'patch': |
|
365 | + $version = Arr::get($matches, 1).Arr::get($matches, 2).Arr::get($matches, 3); |
|
366 | + break; |
|
367 | + } |
|
368 | + return empty($version) |
|
369 | + ? $this->version |
|
370 | + : $version; |
|
371 | + } |
|
372 | 372 | } |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | public function __construct() |
41 | 41 | { |
42 | 42 | static::$instance = $this; |
43 | - $this->file = realpath(trailingslashit(dirname(__DIR__)).static::ID.'.php'); |
|
44 | - $plugin = get_file_data($this->file, [ |
|
43 | + $this->file = realpath( trailingslashit( dirname( __DIR__ ) ).static::ID.'.php' ); |
|
44 | + $plugin = get_file_data( $this->file, [ |
|
45 | 45 | 'languages' => 'Domain Path', |
46 | 46 | 'name' => 'Plugin Name', |
47 | 47 | 'version' => 'Version', |
48 | - ], 'plugin'); |
|
49 | - array_walk($plugin, function ($value, $key) { |
|
48 | + ], 'plugin' ); |
|
49 | + array_walk( $plugin, function( $value, $key ) { |
|
50 | 50 | $this->$key = $value; |
51 | 51 | }); |
52 | 52 | } |
@@ -57,17 +57,17 @@ discard block |
||
57 | 57 | public function activate() |
58 | 58 | { |
59 | 59 | $this->scheduleCronJob(); |
60 | - add_option(static::PREFIX.'activated', true); |
|
60 | + add_option( static::PREFIX.'activated', true ); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
64 | 64 | * @param string $view |
65 | 65 | * @return string |
66 | 66 | */ |
67 | - public function build($view, array $data = []) |
|
67 | + public function build( $view, array $data = [] ) |
|
68 | 68 | { |
69 | 69 | ob_start(); |
70 | - $this->render($view, $data); |
|
70 | + $this->render( $view, $data ); |
|
71 | 71 | return ob_get_clean(); |
72 | 72 | } |
73 | 73 | |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | * @param string $capability |
76 | 76 | * @return bool |
77 | 77 | */ |
78 | - public function can($capability) |
|
78 | + public function can( $capability ) |
|
79 | 79 | { |
80 | - return $this->make(Role::class)->can($capability); |
|
80 | + return $this->make( Role::class )->can( $capability ); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -86,34 +86,34 @@ discard block |
||
86 | 86 | public function catchFatalError() |
87 | 87 | { |
88 | 88 | $error = error_get_last(); |
89 | - if (E_ERROR !== $error['type'] || !Str::contains($error['message'], $this->path())) { |
|
89 | + if( E_ERROR !== $error['type'] || !Str::contains( $error['message'], $this->path() ) ) { |
|
90 | 90 | return; |
91 | 91 | } |
92 | - glsr_log()->error($error['message']); |
|
92 | + glsr_log()->error( $error['message'] ); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
96 | 96 | * @param string $name |
97 | 97 | * @return array |
98 | 98 | */ |
99 | - public function config($name) |
|
99 | + public function config( $name ) |
|
100 | 100 | { |
101 | - $configFile = $this->path('config/'.$name.'.php'); |
|
102 | - $config = file_exists($configFile) |
|
101 | + $configFile = $this->path( 'config/'.$name.'.php' ); |
|
102 | + $config = file_exists( $configFile ) |
|
103 | 103 | ? include $configFile |
104 | 104 | : []; |
105 | - return apply_filters('site-reviews/config/'.$name, $config); |
|
105 | + return apply_filters( 'site-reviews/config/'.$name, $config ); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
109 | 109 | * @param string $property |
110 | 110 | * @return string |
111 | 111 | */ |
112 | - public function constant($property, $className = 'static') |
|
112 | + public function constant( $property, $className = 'static' ) |
|
113 | 113 | { |
114 | 114 | $constant = $className.'::'.$property; |
115 | - return defined($constant) |
|
116 | - ? apply_filters('site-reviews/const/'.$property, constant($constant)) |
|
115 | + return defined( $constant ) |
|
116 | + ? apply_filters( 'site-reviews/const/'.$property, constant( $constant ) ) |
|
117 | 117 | : ''; |
118 | 118 | } |
119 | 119 | |
@@ -129,17 +129,17 @@ discard block |
||
129 | 129 | * @param string $view |
130 | 130 | * @return void|string |
131 | 131 | */ |
132 | - public function file($view) |
|
132 | + public function file( $view ) |
|
133 | 133 | { |
134 | - $view.= '.php'; |
|
134 | + $view .= '.php'; |
|
135 | 135 | $filePaths = []; |
136 | - if (Str::startsWith('templates/', $view)) { |
|
137 | - $filePaths[] = $this->themePath(Str::removePrefix('templates/', $view)); |
|
136 | + if( Str::startsWith( 'templates/', $view ) ) { |
|
137 | + $filePaths[] = $this->themePath( Str::removePrefix( 'templates/', $view ) ); |
|
138 | 138 | } |
139 | - $filePaths[] = $this->path($view); |
|
140 | - $filePaths[] = $this->path('views/'.$view); |
|
141 | - foreach ($filePaths as $file) { |
|
142 | - if (!file_exists($file)) { |
|
139 | + $filePaths[] = $this->path( $view ); |
|
140 | + $filePaths[] = $this->path( 'views/'.$view ); |
|
141 | + foreach( $filePaths as $file ) { |
|
142 | + if( !file_exists( $file ) ) { |
|
143 | 143 | continue; |
144 | 144 | } |
145 | 145 | return $file; |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function getDefaults() |
153 | 153 | { |
154 | - if (empty($this->defaults)) { |
|
155 | - $this->defaults = $this->make(DefaultsManager::class)->get(); |
|
154 | + if( empty($this->defaults) ) { |
|
155 | + $this->defaults = $this->make( DefaultsManager::class )->get(); |
|
156 | 156 | } |
157 | - return apply_filters('site-reviews/get/defaults', $this->defaults); |
|
157 | + return apply_filters( 'site-reviews/get/defaults', $this->defaults ); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * @param string $tab |
163 | 163 | * @return string |
164 | 164 | */ |
165 | - public function getPermission($page = '', $tab = 'index') |
|
165 | + public function getPermission( $page = '', $tab = 'index' ) |
|
166 | 166 | { |
167 | 167 | $fallback = 'edit_posts'; |
168 | 168 | $permissions = [ |
@@ -183,11 +183,11 @@ discard block |
||
183 | 183 | 'system-info' => 'edit_others_posts', |
184 | 184 | ] |
185 | 185 | ]; |
186 | - $permission = Arr::get($permissions, $page, $fallback); |
|
187 | - if (is_array($permission)) { |
|
188 | - $permission = Arr::get($permission, $tab, $fallback); |
|
186 | + $permission = Arr::get( $permissions, $page, $fallback ); |
|
187 | + if( is_array( $permission ) ) { |
|
188 | + $permission = Arr::get( $permission, $tab, $fallback ); |
|
189 | 189 | } |
190 | - return empty($permission) || !is_string($permission) |
|
190 | + return empty($permission) || !is_string( $permission ) |
|
191 | 191 | ? $fallback |
192 | 192 | : $permission; |
193 | 193 | } |
@@ -197,10 +197,10 @@ discard block |
||
197 | 197 | * @param string $tab |
198 | 198 | * @return bool |
199 | 199 | */ |
200 | - public function hasPermission($page = '', $tab = 'index') |
|
200 | + public function hasPermission( $page = '', $tab = 'index' ) |
|
201 | 201 | { |
202 | 202 | $isAdmin = $this->isAdmin(); |
203 | - return !$isAdmin || ($isAdmin && $this->can($this->getPermission($page, $tab))); |
|
203 | + return !$isAdmin || ($isAdmin && $this->can( $this->getPermission( $page, $tab ) )); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | */ |
209 | 209 | public function init() |
210 | 210 | { |
211 | - $this->make(Actions::class)->run(); |
|
212 | - $this->make(Filters::class)->run(); |
|
211 | + $this->make( Actions::class )->run(); |
|
212 | + $this->make( Filters::class )->run(); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -224,31 +224,31 @@ discard block |
||
224 | 224 | * @param string $file |
225 | 225 | * @return string |
226 | 226 | */ |
227 | - public function path($file = '', $realpath = true) |
|
227 | + public function path( $file = '', $realpath = true ) |
|
228 | 228 | { |
229 | - $path = plugin_dir_path($this->file); |
|
230 | - if (!$realpath) { |
|
231 | - $path = trailingslashit(WP_PLUGIN_DIR).basename(dirname($this->file)); |
|
229 | + $path = plugin_dir_path( $this->file ); |
|
230 | + if( !$realpath ) { |
|
231 | + $path = trailingslashit( WP_PLUGIN_DIR ).basename( dirname( $this->file ) ); |
|
232 | 232 | } |
233 | - $path = trailingslashit($path).ltrim(trim($file), '/'); |
|
234 | - return apply_filters('site-reviews/path', $path, $file); |
|
233 | + $path = trailingslashit( $path ).ltrim( trim( $file ), '/' ); |
|
234 | + return apply_filters( 'site-reviews/path', $path, $file ); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
238 | 238 | * @param object $addon |
239 | 239 | * @return void |
240 | 240 | */ |
241 | - public function register($addon) |
|
241 | + public function register( $addon ) |
|
242 | 242 | { |
243 | 243 | try { |
244 | - $reflection = new \ReflectionClass($addon); |
|
245 | - if ($id = $reflection->getConstant('ID')) { |
|
244 | + $reflection = new \ReflectionClass( $addon ); |
|
245 | + if( $id = $reflection->getConstant( 'ID' ) ) { |
|
246 | 246 | $this->addons[] = $id; |
247 | - $this->bind($id, $addon); |
|
247 | + $this->bind( $id, $addon ); |
|
248 | 248 | $addon->init(); |
249 | 249 | } |
250 | - } catch(\ReflectionException $e) { |
|
251 | - glsr_log()->error('Attempted to register an invalid addon.'); |
|
250 | + } catch( \ReflectionException $e ) { |
|
251 | + glsr_log()->error( 'Attempted to register an invalid addon.' ); |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | */ |
258 | 258 | public function registerAddons() |
259 | 259 | { |
260 | - do_action('site-reviews/addon/register', $this); |
|
260 | + do_action( 'site-reviews/addon/register', $this ); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | */ |
266 | 266 | public function registerLanguages() |
267 | 267 | { |
268 | - load_plugin_textdomain(static::ID, false, |
|
269 | - trailingslashit(plugin_basename($this->path()).'/'.$this->languages) |
|
268 | + load_plugin_textdomain( static::ID, false, |
|
269 | + trailingslashit( plugin_basename( $this->path() ).'/'.$this->languages ) |
|
270 | 270 | ); |
271 | 271 | } |
272 | 272 | |
@@ -275,26 +275,26 @@ discard block |
||
275 | 275 | */ |
276 | 276 | public function registerReviewTypes() |
277 | 277 | { |
278 | - $types = apply_filters('site-reviews/addon/types', []); |
|
279 | - $this->reviewTypes = wp_parse_args($types, [ |
|
280 | - 'local' => __('Local', 'site-reviews'), |
|
281 | - ]); |
|
278 | + $types = apply_filters( 'site-reviews/addon/types', [] ); |
|
279 | + $this->reviewTypes = wp_parse_args( $types, [ |
|
280 | + 'local' => __( 'Local', 'site-reviews' ), |
|
281 | + ] ); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
285 | 285 | * @param string $view |
286 | 286 | * @return void |
287 | 287 | */ |
288 | - public function render($view, array $data = []) |
|
288 | + public function render( $view, array $data = [] ) |
|
289 | 289 | { |
290 | - $view = apply_filters('site-reviews/render/view', $view, $data); |
|
291 | - $file = apply_filters('site-reviews/views/file', $this->file($view), $view, $data); |
|
292 | - if (!file_exists($file)) { |
|
293 | - glsr_log()->error('File not found: '.$file); |
|
290 | + $view = apply_filters( 'site-reviews/render/view', $view, $data ); |
|
291 | + $file = apply_filters( 'site-reviews/views/file', $this->file( $view ), $view, $data ); |
|
292 | + if( !file_exists( $file ) ) { |
|
293 | + glsr_log()->error( 'File not found: '.$file ); |
|
294 | 294 | return; |
295 | 295 | } |
296 | - $data = apply_filters('site-reviews/views/data', $data, $view); |
|
297 | - extract($data); |
|
296 | + $data = apply_filters( 'site-reviews/views/data', $data, $view ); |
|
297 | + extract( $data ); |
|
298 | 298 | include $file; |
299 | 299 | } |
300 | 300 | |
@@ -303,8 +303,8 @@ discard block |
||
303 | 303 | */ |
304 | 304 | public function scheduleCronJob() |
305 | 305 | { |
306 | - if (false === wp_next_scheduled(static::CRON_EVENT)) { |
|
307 | - wp_schedule_event(time(), 'twicedaily', static::CRON_EVENT); |
|
306 | + if( false === wp_next_scheduled( static::CRON_EVENT ) ) { |
|
307 | + wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT ); |
|
308 | 308 | } |
309 | 309 | } |
310 | 310 | |
@@ -313,9 +313,9 @@ discard block |
||
313 | 313 | */ |
314 | 314 | public function setDefaults() |
315 | 315 | { |
316 | - if (get_option(static::PREFIX.'activated')) { |
|
317 | - $this->make(DefaultsManager::class)->set(); |
|
318 | - delete_option(static::PREFIX.'activated'); |
|
316 | + if( get_option( static::PREFIX.'activated' ) ) { |
|
317 | + $this->make( DefaultsManager::class )->set(); |
|
318 | + delete_option( static::PREFIX.'activated' ); |
|
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
@@ -323,9 +323,9 @@ discard block |
||
323 | 323 | * @param string $file |
324 | 324 | * @return string |
325 | 325 | */ |
326 | - public function themePath($file = '') |
|
326 | + public function themePath( $file = '' ) |
|
327 | 327 | { |
328 | - return get_stylesheet_directory().'/'.static::ID.'/'.ltrim(trim($file), '/'); |
|
328 | + return get_stylesheet_directory().'/'.static::ID.'/'.ltrim( trim( $file ), '/' ); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | /** |
@@ -333,36 +333,36 @@ discard block |
||
333 | 333 | */ |
334 | 334 | public function unscheduleCronJob() |
335 | 335 | { |
336 | - wp_unschedule_event(intval(wp_next_scheduled(static::CRON_EVENT)), static::CRON_EVENT); |
|
336 | + wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT ) ), static::CRON_EVENT ); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
340 | 340 | * @param string $path |
341 | 341 | * @return string |
342 | 342 | */ |
343 | - public function url($path = '') |
|
343 | + public function url( $path = '' ) |
|
344 | 344 | { |
345 | - $url = esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/')); |
|
346 | - return apply_filters('site-reviews/url', $url, $path); |
|
345 | + $url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) ); |
|
346 | + return apply_filters( 'site-reviews/url', $url, $path ); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | /** |
350 | 350 | * @param string $versionLevel |
351 | 351 | * @return string |
352 | 352 | */ |
353 | - public function version($versionLevel = '') |
|
353 | + public function version( $versionLevel = '' ) |
|
354 | 354 | { |
355 | 355 | $pattern = '/^v?(\d{1,5})(\.\d++)?(\.\d++)?(.+)?$/i'; |
356 | - preg_match($pattern, $this->version, $matches); |
|
357 | - switch ($versionLevel) { |
|
356 | + preg_match( $pattern, $this->version, $matches ); |
|
357 | + switch( $versionLevel ) { |
|
358 | 358 | case 'major': |
359 | - $version = Arr::get($matches, 1); |
|
359 | + $version = Arr::get( $matches, 1 ); |
|
360 | 360 | break; |
361 | 361 | case 'minor': |
362 | - $version = Arr::get($matches, 1).Arr::get($matches, 2); |
|
362 | + $version = Arr::get( $matches, 1 ).Arr::get( $matches, 2 ); |
|
363 | 363 | break; |
364 | 364 | case 'patch': |
365 | - $version = Arr::get($matches, 1).Arr::get($matches, 2).Arr::get($matches, 3); |
|
365 | + $version = Arr::get( $matches, 1 ).Arr::get( $matches, 2 ).Arr::get( $matches, 3 ); |
|
366 | 366 | break; |
367 | 367 | } |
368 | 368 | return empty($version) |
@@ -10,52 +10,52 @@ |
||
10 | 10 | |
11 | 11 | class Pagination implements PartialContract |
12 | 12 | { |
13 | - /** |
|
14 | - * @var array |
|
15 | - */ |
|
16 | - protected $args; |
|
13 | + /** |
|
14 | + * @var array |
|
15 | + */ |
|
16 | + protected $args; |
|
17 | 17 | |
18 | - /** |
|
19 | - * @return string |
|
20 | - */ |
|
21 | - public function build(array $args = []) |
|
22 | - { |
|
23 | - $this->args = $this->normalize($args); |
|
24 | - if ($this->args['total'] < 2) { |
|
25 | - return ''; |
|
26 | - } |
|
27 | - return glsr(Template::class)->build('templates/pagination', [ |
|
28 | - 'context' => [ |
|
29 | - 'links' => apply_filters('site-reviews/paginate_links', $this->buildLinks(), $this->args), |
|
30 | - 'loader' => '<div class="glsr-loader"></div>', |
|
31 | - 'screen_reader_text' => __('Site Reviews navigation', 'site-reviews'), |
|
32 | - ], |
|
33 | - ]); |
|
34 | - } |
|
18 | + /** |
|
19 | + * @return string |
|
20 | + */ |
|
21 | + public function build(array $args = []) |
|
22 | + { |
|
23 | + $this->args = $this->normalize($args); |
|
24 | + if ($this->args['total'] < 2) { |
|
25 | + return ''; |
|
26 | + } |
|
27 | + return glsr(Template::class)->build('templates/pagination', [ |
|
28 | + 'context' => [ |
|
29 | + 'links' => apply_filters('site-reviews/paginate_links', $this->buildLinks(), $this->args), |
|
30 | + 'loader' => '<div class="glsr-loader"></div>', |
|
31 | + 'screen_reader_text' => __('Site Reviews navigation', 'site-reviews'), |
|
32 | + ], |
|
33 | + ]); |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - protected function buildLinks() |
|
40 | - { |
|
41 | - $args = glsr(Style::class)->paginationArgs($this->args); |
|
42 | - if ('array' == $args['type']) { |
|
43 | - $args['type'] = 'plain'; |
|
44 | - } |
|
45 | - return paginate_links($args); |
|
46 | - } |
|
36 | + /** |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + protected function buildLinks() |
|
40 | + { |
|
41 | + $args = glsr(Style::class)->paginationArgs($this->args); |
|
42 | + if ('array' == $args['type']) { |
|
43 | + $args['type'] = 'plain'; |
|
44 | + } |
|
45 | + return paginate_links($args); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @return array |
|
50 | - */ |
|
51 | - protected function normalize(array $args) |
|
52 | - { |
|
53 | - if ($baseUrl = Arr::get($args, 'baseUrl')) { |
|
54 | - $args['base'] = $baseUrl.'%_%'; |
|
55 | - } |
|
56 | - return wp_parse_args(array_filter($args), [ |
|
57 | - 'current' => glsr(QueryBuilder::class)->getPaged(), |
|
58 | - 'total' => 1, |
|
59 | - ]); |
|
60 | - } |
|
48 | + /** |
|
49 | + * @return array |
|
50 | + */ |
|
51 | + protected function normalize(array $args) |
|
52 | + { |
|
53 | + if ($baseUrl = Arr::get($args, 'baseUrl')) { |
|
54 | + $args['base'] = $baseUrl.'%_%'; |
|
55 | + } |
|
56 | + return wp_parse_args(array_filter($args), [ |
|
57 | + 'current' => glsr(QueryBuilder::class)->getPaged(), |
|
58 | + 'total' => 1, |
|
59 | + ]); |
|
60 | + } |
|
61 | 61 | } |
@@ -18,19 +18,19 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * @return string |
20 | 20 | */ |
21 | - public function build(array $args = []) |
|
21 | + public function build( array $args = [] ) |
|
22 | 22 | { |
23 | - $this->args = $this->normalize($args); |
|
24 | - if ($this->args['total'] < 2) { |
|
23 | + $this->args = $this->normalize( $args ); |
|
24 | + if( $this->args['total'] < 2 ) { |
|
25 | 25 | return ''; |
26 | 26 | } |
27 | - return glsr(Template::class)->build('templates/pagination', [ |
|
27 | + return glsr( Template::class )->build( 'templates/pagination', [ |
|
28 | 28 | 'context' => [ |
29 | - 'links' => apply_filters('site-reviews/paginate_links', $this->buildLinks(), $this->args), |
|
29 | + 'links' => apply_filters( 'site-reviews/paginate_links', $this->buildLinks(), $this->args ), |
|
30 | 30 | 'loader' => '<div class="glsr-loader"></div>', |
31 | - 'screen_reader_text' => __('Site Reviews navigation', 'site-reviews'), |
|
31 | + 'screen_reader_text' => __( 'Site Reviews navigation', 'site-reviews' ), |
|
32 | 32 | ], |
33 | - ]); |
|
33 | + ] ); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -38,24 +38,24 @@ discard block |
||
38 | 38 | */ |
39 | 39 | protected function buildLinks() |
40 | 40 | { |
41 | - $args = glsr(Style::class)->paginationArgs($this->args); |
|
42 | - if ('array' == $args['type']) { |
|
41 | + $args = glsr( Style::class )->paginationArgs( $this->args ); |
|
42 | + if( 'array' == $args['type'] ) { |
|
43 | 43 | $args['type'] = 'plain'; |
44 | 44 | } |
45 | - return paginate_links($args); |
|
45 | + return paginate_links( $args ); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
49 | 49 | * @return array |
50 | 50 | */ |
51 | - protected function normalize(array $args) |
|
51 | + protected function normalize( array $args ) |
|
52 | 52 | { |
53 | - if ($baseUrl = Arr::get($args, 'baseUrl')) { |
|
53 | + if( $baseUrl = Arr::get( $args, 'baseUrl' ) ) { |
|
54 | 54 | $args['base'] = $baseUrl.'%_%'; |
55 | 55 | } |
56 | - return wp_parse_args(array_filter($args), [ |
|
57 | - 'current' => glsr(QueryBuilder::class)->getPaged(), |
|
56 | + return wp_parse_args( array_filter( $args ), [ |
|
57 | + 'current' => glsr( QueryBuilder::class )->getPaged(), |
|
58 | 58 | 'total' => 1, |
59 | - ]); |
|
59 | + ] ); |
|
60 | 60 | } |
61 | 61 | } |
@@ -7,48 +7,48 @@ |
||
7 | 7 | |
8 | 8 | class ReviewHtml extends ArrayObject |
9 | 9 | { |
10 | - /** |
|
11 | - * @var Review |
|
12 | - */ |
|
13 | - public $review; |
|
10 | + /** |
|
11 | + * @var Review |
|
12 | + */ |
|
13 | + public $review; |
|
14 | 14 | |
15 | - /** |
|
16 | - * @var array |
|
17 | - */ |
|
18 | - public $values; |
|
15 | + /** |
|
16 | + * @var array |
|
17 | + */ |
|
18 | + public $values; |
|
19 | 19 | |
20 | - public function __construct(Review $review, array $values = []) |
|
21 | - { |
|
22 | - $this->review = $review; |
|
23 | - $this->values = $values; |
|
24 | - parent::__construct($values, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS); |
|
25 | - } |
|
20 | + public function __construct(Review $review, array $values = []) |
|
21 | + { |
|
22 | + $this->review = $review; |
|
23 | + $this->values = $values; |
|
24 | + parent::__construct($values, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS); |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * @return string|void |
|
29 | - */ |
|
30 | - public function __toString() |
|
31 | - { |
|
32 | - if (empty($this->values)) { |
|
33 | - return; |
|
34 | - } |
|
35 | - return glsr(Template::class)->build('templates/review', [ |
|
36 | - 'context' => $this->values, |
|
37 | - 'review' => $this->review, |
|
38 | - ]); |
|
39 | - } |
|
27 | + /** |
|
28 | + * @return string|void |
|
29 | + */ |
|
30 | + public function __toString() |
|
31 | + { |
|
32 | + if (empty($this->values)) { |
|
33 | + return; |
|
34 | + } |
|
35 | + return glsr(Template::class)->build('templates/review', [ |
|
36 | + 'context' => $this->values, |
|
37 | + 'review' => $this->review, |
|
38 | + ]); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param mixed $key |
|
43 | - * @return mixed |
|
44 | - */ |
|
45 | - public function offsetGet($key) |
|
46 | - { |
|
47 | - if (array_key_exists($key, $this->values)) { |
|
48 | - return $this->values[$key]; |
|
49 | - } |
|
50 | - return property_exists($this, $key) |
|
51 | - ? $this->$key |
|
52 | - : null; |
|
53 | - } |
|
41 | + /** |
|
42 | + * @param mixed $key |
|
43 | + * @return mixed |
|
44 | + */ |
|
45 | + public function offsetGet($key) |
|
46 | + { |
|
47 | + if (array_key_exists($key, $this->values)) { |
|
48 | + return $this->values[$key]; |
|
49 | + } |
|
50 | + return property_exists($this, $key) |
|
51 | + ? $this->$key |
|
52 | + : null; |
|
53 | + } |
|
54 | 54 | } |
@@ -17,11 +17,11 @@ discard block |
||
17 | 17 | */ |
18 | 18 | public $values; |
19 | 19 | |
20 | - public function __construct(Review $review, array $values = []) |
|
20 | + public function __construct( Review $review, array $values = [] ) |
|
21 | 21 | { |
22 | 22 | $this->review = $review; |
23 | 23 | $this->values = $values; |
24 | - parent::__construct($values, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS); |
|
24 | + parent::__construct( $values, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS ); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -29,25 +29,25 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function __toString() |
31 | 31 | { |
32 | - if (empty($this->values)) { |
|
32 | + if( empty($this->values) ) { |
|
33 | 33 | return; |
34 | 34 | } |
35 | - return glsr(Template::class)->build('templates/review', [ |
|
35 | + return glsr( Template::class )->build( 'templates/review', [ |
|
36 | 36 | 'context' => $this->values, |
37 | 37 | 'review' => $this->review, |
38 | - ]); |
|
38 | + ] ); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @param mixed $key |
43 | 43 | * @return mixed |
44 | 44 | */ |
45 | - public function offsetGet($key) |
|
45 | + public function offsetGet( $key ) |
|
46 | 46 | { |
47 | - if (array_key_exists($key, $this->values)) { |
|
47 | + if( array_key_exists( $key, $this->values ) ) { |
|
48 | 48 | return $this->values[$key]; |
49 | 49 | } |
50 | - return property_exists($this, $key) |
|
50 | + return property_exists( $this, $key ) |
|
51 | 51 | ? $this->$key |
52 | 52 | : null; |
53 | 53 | } |
@@ -8,135 +8,135 @@ |
||
8 | 8 | |
9 | 9 | class ReviewsHtml extends ArrayObject |
10 | 10 | { |
11 | - /** |
|
12 | - * @var array |
|
13 | - */ |
|
14 | - public $args; |
|
11 | + /** |
|
12 | + * @var array |
|
13 | + */ |
|
14 | + public $args; |
|
15 | 15 | |
16 | - /** |
|
17 | - * @var int |
|
18 | - */ |
|
19 | - public $max_num_pages; |
|
16 | + /** |
|
17 | + * @var int |
|
18 | + */ |
|
19 | + public $max_num_pages; |
|
20 | 20 | |
21 | - /** |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - public $pagination; |
|
21 | + /** |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + public $pagination; |
|
25 | 25 | |
26 | - /** |
|
27 | - * @var array |
|
28 | - */ |
|
29 | - public $reviews; |
|
26 | + /** |
|
27 | + * @var array |
|
28 | + */ |
|
29 | + public $reviews; |
|
30 | 30 | |
31 | - public function __construct(array $renderedReviews, $maxPageCount, array $args) |
|
32 | - { |
|
33 | - $this->args = $args; |
|
34 | - $this->max_num_pages = $maxPageCount; |
|
35 | - $this->reviews = $renderedReviews; |
|
36 | - $this->pagination = $this->buildPagination(); |
|
37 | - parent::__construct($renderedReviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS); |
|
38 | - } |
|
31 | + public function __construct(array $renderedReviews, $maxPageCount, array $args) |
|
32 | + { |
|
33 | + $this->args = $args; |
|
34 | + $this->max_num_pages = $maxPageCount; |
|
35 | + $this->reviews = $renderedReviews; |
|
36 | + $this->pagination = $this->buildPagination(); |
|
37 | + parent::__construct($renderedReviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @return string |
|
42 | - */ |
|
43 | - public function __toString() |
|
44 | - { |
|
45 | - return glsr(Template::class)->build('templates/reviews', [ |
|
46 | - 'args' => $this->args, |
|
47 | - 'context' => [ |
|
48 | - 'assigned_to' => $this->args['assigned_to'], |
|
49 | - 'category' => $this->args['category'], |
|
50 | - 'class' => $this->getClass(), |
|
51 | - 'id' => $this->args['id'], |
|
52 | - 'pagination' => $this->getPagination(), |
|
53 | - 'reviews' => $this->getReviews(), |
|
54 | - ], |
|
55 | - ]); |
|
56 | - } |
|
40 | + /** |
|
41 | + * @return string |
|
42 | + */ |
|
43 | + public function __toString() |
|
44 | + { |
|
45 | + return glsr(Template::class)->build('templates/reviews', [ |
|
46 | + 'args' => $this->args, |
|
47 | + 'context' => [ |
|
48 | + 'assigned_to' => $this->args['assigned_to'], |
|
49 | + 'category' => $this->args['category'], |
|
50 | + 'class' => $this->getClass(), |
|
51 | + 'id' => $this->args['id'], |
|
52 | + 'pagination' => $this->getPagination(), |
|
53 | + 'reviews' => $this->getReviews(), |
|
54 | + ], |
|
55 | + ]); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @return string |
|
60 | - */ |
|
61 | - public function getPagination() |
|
62 | - { |
|
63 | - return wp_validate_boolean($this->args['pagination']) |
|
64 | - ? $this->pagination |
|
65 | - : ''; |
|
66 | - } |
|
58 | + /** |
|
59 | + * @return string |
|
60 | + */ |
|
61 | + public function getPagination() |
|
62 | + { |
|
63 | + return wp_validate_boolean($this->args['pagination']) |
|
64 | + ? $this->pagination |
|
65 | + : ''; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @return string |
|
70 | - */ |
|
71 | - public function getReviews() |
|
72 | - { |
|
73 | - $html = empty($this->reviews) |
|
74 | - ? $this->getReviewsFallback() |
|
75 | - : implode(PHP_EOL, $this->reviews); |
|
76 | - $wrapper = '<div class="glsr-reviews">%s</div>'; |
|
77 | - $wrapper = apply_filters('site-reviews/reviews/reviews-wrapper', $wrapper); |
|
78 | - return sprintf($wrapper, $html); |
|
79 | - } |
|
68 | + /** |
|
69 | + * @return string |
|
70 | + */ |
|
71 | + public function getReviews() |
|
72 | + { |
|
73 | + $html = empty($this->reviews) |
|
74 | + ? $this->getReviewsFallback() |
|
75 | + : implode(PHP_EOL, $this->reviews); |
|
76 | + $wrapper = '<div class="glsr-reviews">%s</div>'; |
|
77 | + $wrapper = apply_filters('site-reviews/reviews/reviews-wrapper', $wrapper); |
|
78 | + return sprintf($wrapper, $html); |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * @param mixed $key |
|
83 | - * @return mixed |
|
84 | - */ |
|
85 | - public function offsetGet($key) |
|
86 | - { |
|
87 | - if ('navigation' == $key) { |
|
88 | - glsr()->deprecated[] = 'The $reviewsHtml->navigation property has been been deprecated. Please use the $reviewsHtml->pagination property instead.'; |
|
89 | - return $this->pagination; |
|
90 | - } |
|
91 | - if (array_key_exists($key, $this->reviews)) { |
|
92 | - return $this->reviews[$key]; |
|
93 | - } |
|
94 | - return property_exists($this, $key) |
|
95 | - ? $this->$key |
|
96 | - : null; |
|
97 | - } |
|
81 | + /** |
|
82 | + * @param mixed $key |
|
83 | + * @return mixed |
|
84 | + */ |
|
85 | + public function offsetGet($key) |
|
86 | + { |
|
87 | + if ('navigation' == $key) { |
|
88 | + glsr()->deprecated[] = 'The $reviewsHtml->navigation property has been been deprecated. Please use the $reviewsHtml->pagination property instead.'; |
|
89 | + return $this->pagination; |
|
90 | + } |
|
91 | + if (array_key_exists($key, $this->reviews)) { |
|
92 | + return $this->reviews[$key]; |
|
93 | + } |
|
94 | + return property_exists($this, $key) |
|
95 | + ? $this->$key |
|
96 | + : null; |
|
97 | + } |
|
98 | 98 | |
99 | - /** |
|
100 | - * @return string |
|
101 | - */ |
|
102 | - protected function buildPagination() |
|
103 | - { |
|
104 | - $html = glsr(Partial::class)->build('pagination', [ |
|
105 | - 'baseUrl' => Arr::get($this->args, 'pagedUrl'), |
|
106 | - 'current' => Arr::get($this->args, 'paged'), |
|
107 | - 'total' => $this->max_num_pages, |
|
108 | - ]); |
|
109 | - $html.= sprintf('<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json']); |
|
110 | - $wrapper = '<div class="glsr-pagination">%s</div>'; |
|
111 | - $wrapper = apply_filters('site-reviews/reviews/pagination-wrapper', $wrapper); |
|
112 | - return sprintf($wrapper, $html); |
|
113 | - } |
|
99 | + /** |
|
100 | + * @return string |
|
101 | + */ |
|
102 | + protected function buildPagination() |
|
103 | + { |
|
104 | + $html = glsr(Partial::class)->build('pagination', [ |
|
105 | + 'baseUrl' => Arr::get($this->args, 'pagedUrl'), |
|
106 | + 'current' => Arr::get($this->args, 'paged'), |
|
107 | + 'total' => $this->max_num_pages, |
|
108 | + ]); |
|
109 | + $html.= sprintf('<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json']); |
|
110 | + $wrapper = '<div class="glsr-pagination">%s</div>'; |
|
111 | + $wrapper = apply_filters('site-reviews/reviews/pagination-wrapper', $wrapper); |
|
112 | + return sprintf($wrapper, $html); |
|
113 | + } |
|
114 | 114 | |
115 | - /** |
|
116 | - * @return string |
|
117 | - */ |
|
118 | - protected function getClass() |
|
119 | - { |
|
120 | - $defaults = [ |
|
121 | - 'glsr-default', |
|
122 | - ]; |
|
123 | - if ('ajax' == $this->args['pagination']) { |
|
124 | - $defaults[] = 'glsr-ajax-pagination'; |
|
125 | - } |
|
126 | - $classes = explode(' ', $this->args['class']); |
|
127 | - $classes = array_unique(array_merge($defaults, array_filter($classes))); |
|
128 | - return implode(' ', $classes); |
|
129 | - } |
|
115 | + /** |
|
116 | + * @return string |
|
117 | + */ |
|
118 | + protected function getClass() |
|
119 | + { |
|
120 | + $defaults = [ |
|
121 | + 'glsr-default', |
|
122 | + ]; |
|
123 | + if ('ajax' == $this->args['pagination']) { |
|
124 | + $defaults[] = 'glsr-ajax-pagination'; |
|
125 | + } |
|
126 | + $classes = explode(' ', $this->args['class']); |
|
127 | + $classes = array_unique(array_merge($defaults, array_filter($classes))); |
|
128 | + return implode(' ', $classes); |
|
129 | + } |
|
130 | 130 | |
131 | - /** |
|
132 | - * @return string |
|
133 | - */ |
|
134 | - protected function getReviewsFallback() |
|
135 | - { |
|
136 | - if (empty($this->args['fallback']) && glsr(OptionManager::class)->getBool('settings.reviews.fallback')) { |
|
137 | - $this->args['fallback'] = __('There are no reviews yet. Be the first one to write one.', 'site-reviews'); |
|
138 | - } |
|
139 | - $fallback = '<p class="glsr-no-margins">'.$this->args['fallback'].'</p>'; |
|
140 | - return apply_filters('site-reviews/reviews/fallback', $fallback, $this->args); |
|
141 | - } |
|
131 | + /** |
|
132 | + * @return string |
|
133 | + */ |
|
134 | + protected function getReviewsFallback() |
|
135 | + { |
|
136 | + if (empty($this->args['fallback']) && glsr(OptionManager::class)->getBool('settings.reviews.fallback')) { |
|
137 | + $this->args['fallback'] = __('There are no reviews yet. Be the first one to write one.', 'site-reviews'); |
|
138 | + } |
|
139 | + $fallback = '<p class="glsr-no-margins">'.$this->args['fallback'].'</p>'; |
|
140 | + return apply_filters('site-reviews/reviews/fallback', $fallback, $this->args); |
|
141 | + } |
|
142 | 142 | } |
@@ -28,13 +28,13 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public $reviews; |
30 | 30 | |
31 | - public function __construct(array $renderedReviews, $maxPageCount, array $args) |
|
31 | + public function __construct( array $renderedReviews, $maxPageCount, array $args ) |
|
32 | 32 | { |
33 | 33 | $this->args = $args; |
34 | 34 | $this->max_num_pages = $maxPageCount; |
35 | 35 | $this->reviews = $renderedReviews; |
36 | 36 | $this->pagination = $this->buildPagination(); |
37 | - parent::__construct($renderedReviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS); |
|
37 | + parent::__construct( $renderedReviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS ); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function __toString() |
44 | 44 | { |
45 | - return glsr(Template::class)->build('templates/reviews', [ |
|
45 | + return glsr( Template::class )->build( 'templates/reviews', [ |
|
46 | 46 | 'args' => $this->args, |
47 | 47 | 'context' => [ |
48 | 48 | 'assigned_to' => $this->args['assigned_to'], |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | 'pagination' => $this->getPagination(), |
53 | 53 | 'reviews' => $this->getReviews(), |
54 | 54 | ], |
55 | - ]); |
|
55 | + ] ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function getPagination() |
62 | 62 | { |
63 | - return wp_validate_boolean($this->args['pagination']) |
|
63 | + return wp_validate_boolean( $this->args['pagination'] ) |
|
64 | 64 | ? $this->pagination |
65 | 65 | : ''; |
66 | 66 | } |
@@ -72,26 +72,26 @@ discard block |
||
72 | 72 | { |
73 | 73 | $html = empty($this->reviews) |
74 | 74 | ? $this->getReviewsFallback() |
75 | - : implode(PHP_EOL, $this->reviews); |
|
75 | + : implode( PHP_EOL, $this->reviews ); |
|
76 | 76 | $wrapper = '<div class="glsr-reviews">%s</div>'; |
77 | - $wrapper = apply_filters('site-reviews/reviews/reviews-wrapper', $wrapper); |
|
78 | - return sprintf($wrapper, $html); |
|
77 | + $wrapper = apply_filters( 'site-reviews/reviews/reviews-wrapper', $wrapper ); |
|
78 | + return sprintf( $wrapper, $html ); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
82 | 82 | * @param mixed $key |
83 | 83 | * @return mixed |
84 | 84 | */ |
85 | - public function offsetGet($key) |
|
85 | + public function offsetGet( $key ) |
|
86 | 86 | { |
87 | - if ('navigation' == $key) { |
|
87 | + if( 'navigation' == $key ) { |
|
88 | 88 | glsr()->deprecated[] = 'The $reviewsHtml->navigation property has been been deprecated. Please use the $reviewsHtml->pagination property instead.'; |
89 | 89 | return $this->pagination; |
90 | 90 | } |
91 | - if (array_key_exists($key, $this->reviews)) { |
|
91 | + if( array_key_exists( $key, $this->reviews ) ) { |
|
92 | 92 | return $this->reviews[$key]; |
93 | 93 | } |
94 | - return property_exists($this, $key) |
|
94 | + return property_exists( $this, $key ) |
|
95 | 95 | ? $this->$key |
96 | 96 | : null; |
97 | 97 | } |
@@ -101,15 +101,15 @@ discard block |
||
101 | 101 | */ |
102 | 102 | protected function buildPagination() |
103 | 103 | { |
104 | - $html = glsr(Partial::class)->build('pagination', [ |
|
105 | - 'baseUrl' => Arr::get($this->args, 'pagedUrl'), |
|
106 | - 'current' => Arr::get($this->args, 'paged'), |
|
104 | + $html = glsr( Partial::class )->build( 'pagination', [ |
|
105 | + 'baseUrl' => Arr::get( $this->args, 'pagedUrl' ), |
|
106 | + 'current' => Arr::get( $this->args, 'paged' ), |
|
107 | 107 | 'total' => $this->max_num_pages, |
108 | - ]); |
|
109 | - $html.= sprintf('<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json']); |
|
108 | + ] ); |
|
109 | + $html .= sprintf( '<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json'] ); |
|
110 | 110 | $wrapper = '<div class="glsr-pagination">%s</div>'; |
111 | - $wrapper = apply_filters('site-reviews/reviews/pagination-wrapper', $wrapper); |
|
112 | - return sprintf($wrapper, $html); |
|
111 | + $wrapper = apply_filters( 'site-reviews/reviews/pagination-wrapper', $wrapper ); |
|
112 | + return sprintf( $wrapper, $html ); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -120,12 +120,12 @@ discard block |
||
120 | 120 | $defaults = [ |
121 | 121 | 'glsr-default', |
122 | 122 | ]; |
123 | - if ('ajax' == $this->args['pagination']) { |
|
123 | + if( 'ajax' == $this->args['pagination'] ) { |
|
124 | 124 | $defaults[] = 'glsr-ajax-pagination'; |
125 | 125 | } |
126 | - $classes = explode(' ', $this->args['class']); |
|
127 | - $classes = array_unique(array_merge($defaults, array_filter($classes))); |
|
128 | - return implode(' ', $classes); |
|
126 | + $classes = explode( ' ', $this->args['class'] ); |
|
127 | + $classes = array_unique( array_merge( $defaults, array_filter( $classes ) ) ); |
|
128 | + return implode( ' ', $classes ); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -133,10 +133,10 @@ discard block |
||
133 | 133 | */ |
134 | 134 | protected function getReviewsFallback() |
135 | 135 | { |
136 | - if (empty($this->args['fallback']) && glsr(OptionManager::class)->getBool('settings.reviews.fallback')) { |
|
137 | - $this->args['fallback'] = __('There are no reviews yet. Be the first one to write one.', 'site-reviews'); |
|
136 | + if( empty($this->args['fallback']) && glsr( OptionManager::class )->getBool( 'settings.reviews.fallback' ) ) { |
|
137 | + $this->args['fallback'] = __( 'There are no reviews yet. Be the first one to write one.', 'site-reviews' ); |
|
138 | 138 | } |
139 | 139 | $fallback = '<p class="glsr-no-margins">'.$this->args['fallback'].'</p>'; |
140 | - return apply_filters('site-reviews/reviews/fallback', $fallback, $this->args); |
|
140 | + return apply_filters( 'site-reviews/reviews/fallback', $fallback, $this->args ); |
|
141 | 141 | } |
142 | 142 | } |
@@ -4,8 +4,8 @@ |
||
4 | 4 | |
5 | 5 | interface PartialContract |
6 | 6 | { |
7 | - /** |
|
8 | - * @return string |
|
9 | - */ |
|
10 | - public function build(array $args = []); |
|
7 | + /** |
|
8 | + * @return string |
|
9 | + */ |
|
10 | + public function build(array $args = []); |
|
11 | 11 | } |
@@ -7,5 +7,5 @@ |
||
7 | 7 | /** |
8 | 8 | * @return string |
9 | 9 | */ |
10 | - public function build(array $args = []); |
|
10 | + public function build( array $args = [] ); |
|
11 | 11 | } |
@@ -6,7 +6,7 @@ |
||
6 | 6 | require_once $file; |
7 | 7 | |
8 | 8 | if (!(new GL_Plugin_Check_v4($file))->isValid()) { |
9 | - return; |
|
9 | + return; |
|
10 | 10 | } |
11 | 11 | delete_option(GeminiLabs\SiteReviews\Database\OptionManager::databaseKey(3)); |
12 | 12 | delete_option(GeminiLabs\SiteReviews\Database\OptionManager::databaseKey(4)); |
@@ -1,23 +1,23 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -defined('WP_UNINSTALL_PLUGIN') || die; |
|
3 | +defined( 'WP_UNINSTALL_PLUGIN' ) || die; |
|
4 | 4 | |
5 | 5 | $file = __DIR__.'/site-reviews.php'; |
6 | 6 | require_once $file; |
7 | 7 | |
8 | -if (!(new GL_Plugin_Check_v4($file))->isValid()) { |
|
8 | +if( !(new GL_Plugin_Check_v4( $file ))->isValid() ) { |
|
9 | 9 | return; |
10 | 10 | } |
11 | -delete_option(GeminiLabs\SiteReviews\Database\OptionManager::databaseKey(3)); |
|
12 | -delete_option(GeminiLabs\SiteReviews\Database\OptionManager::databaseKey(4)); |
|
13 | -delete_option('_glsr_trustalyze'); |
|
14 | -delete_option('widget_'.glsr()->id.'_site-reviews'); |
|
15 | -delete_option('widget_'.glsr()->id.'_site-reviews-form'); |
|
16 | -delete_option('widget_'.glsr()->id.'_site-reviews-summary'); |
|
17 | -delete_transient(glsr()->id.'_cloudflare_ips'); |
|
18 | -delete_transient(glsr()->id.'_remote_post_test'); |
|
19 | -wp_cache_delete(glsr()->id); |
|
11 | +delete_option( GeminiLabs\SiteReviews\Database\OptionManager::databaseKey( 3 ) ); |
|
12 | +delete_option( GeminiLabs\SiteReviews\Database\OptionManager::databaseKey( 4 ) ); |
|
13 | +delete_option( '_glsr_trustalyze' ); |
|
14 | +delete_option( 'widget_'.glsr()->id.'_site-reviews' ); |
|
15 | +delete_option( 'widget_'.glsr()->id.'_site-reviews-form' ); |
|
16 | +delete_option( 'widget_'.glsr()->id.'_site-reviews-summary' ); |
|
17 | +delete_transient( glsr()->id.'_cloudflare_ips' ); |
|
18 | +delete_transient( glsr()->id.'_remote_post_test' ); |
|
19 | +wp_cache_delete( glsr()->id ); |
|
20 | 20 | |
21 | 21 | global $wpdb; |
22 | 22 | |
23 | -$wpdb->query("DELETE FROM {$wpdb->usermeta} WHERE meta_key = '_glsr_notices'"); |
|
23 | +$wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key = '_glsr_notices'" ); |