@@ -9,149 +9,149 @@ |
||
9 | 9 | |
10 | 10 | class EnqueuePublicAssets |
11 | 11 | { |
12 | - /** |
|
13 | - * @return void |
|
14 | - */ |
|
15 | - public function handle() |
|
16 | - { |
|
17 | - $this->enqueueAssets(); |
|
18 | - $this->enqueuePolyfillService(); |
|
19 | - $this->enqueueRecaptchaScript(); |
|
20 | - $this->inlineScript(); |
|
21 | - $this->inlineStyles(); |
|
22 | - } |
|
12 | + /** |
|
13 | + * @return void |
|
14 | + */ |
|
15 | + public function handle() |
|
16 | + { |
|
17 | + $this->enqueueAssets(); |
|
18 | + $this->enqueuePolyfillService(); |
|
19 | + $this->enqueueRecaptchaScript(); |
|
20 | + $this->inlineScript(); |
|
21 | + $this->inlineStyles(); |
|
22 | + } |
|
23 | 23 | |
24 | - /** |
|
25 | - * @return void |
|
26 | - */ |
|
27 | - public function enqueueAssets() |
|
28 | - { |
|
29 | - if (apply_filters('site-reviews/assets/css', true)) { |
|
30 | - wp_enqueue_style( |
|
31 | - Application::ID, |
|
32 | - $this->getStylesheet(), |
|
33 | - [], |
|
34 | - glsr()->version |
|
35 | - ); |
|
36 | - } |
|
37 | - if (apply_filters('site-reviews/assets/js', true)) { |
|
38 | - $dependencies = apply_filters('site-reviews/assets/polyfill', true) |
|
39 | - ? [Application::ID.'/polyfill'] |
|
40 | - : []; |
|
41 | - $dependencies = apply_filters('site-reviews/enqueue/public/dependencies', $dependencies); |
|
42 | - wp_enqueue_script( |
|
43 | - Application::ID, |
|
44 | - glsr()->url('assets/scripts/'.Application::ID.'.js'), |
|
45 | - $dependencies, |
|
46 | - glsr()->version, |
|
47 | - true |
|
48 | - ); |
|
49 | - } |
|
50 | - } |
|
24 | + /** |
|
25 | + * @return void |
|
26 | + */ |
|
27 | + public function enqueueAssets() |
|
28 | + { |
|
29 | + if (apply_filters('site-reviews/assets/css', true)) { |
|
30 | + wp_enqueue_style( |
|
31 | + Application::ID, |
|
32 | + $this->getStylesheet(), |
|
33 | + [], |
|
34 | + glsr()->version |
|
35 | + ); |
|
36 | + } |
|
37 | + if (apply_filters('site-reviews/assets/js', true)) { |
|
38 | + $dependencies = apply_filters('site-reviews/assets/polyfill', true) |
|
39 | + ? [Application::ID.'/polyfill'] |
|
40 | + : []; |
|
41 | + $dependencies = apply_filters('site-reviews/enqueue/public/dependencies', $dependencies); |
|
42 | + wp_enqueue_script( |
|
43 | + Application::ID, |
|
44 | + glsr()->url('assets/scripts/'.Application::ID.'.js'), |
|
45 | + $dependencies, |
|
46 | + glsr()->version, |
|
47 | + true |
|
48 | + ); |
|
49 | + } |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public function enqueuePolyfillService() |
|
56 | - { |
|
57 | - if (!apply_filters('site-reviews/assets/polyfill', true)) { |
|
58 | - return; |
|
59 | - } |
|
60 | - wp_enqueue_script(Application::ID.'/polyfill', add_query_arg([ |
|
61 | - 'features' => 'Array.prototype.findIndex,CustomEvent,Element.prototype.closest,Element.prototype.dataset,Event,XMLHttpRequest,MutationObserver', |
|
62 | - 'flags' => 'gated', |
|
63 | - ], 'https://polyfill.io/v3/polyfill.min.js')); |
|
64 | - } |
|
52 | + /** |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public function enqueuePolyfillService() |
|
56 | + { |
|
57 | + if (!apply_filters('site-reviews/assets/polyfill', true)) { |
|
58 | + return; |
|
59 | + } |
|
60 | + wp_enqueue_script(Application::ID.'/polyfill', add_query_arg([ |
|
61 | + 'features' => 'Array.prototype.findIndex,CustomEvent,Element.prototype.closest,Element.prototype.dataset,Event,XMLHttpRequest,MutationObserver', |
|
62 | + 'flags' => 'gated', |
|
63 | + ], 'https://polyfill.io/v3/polyfill.min.js')); |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @return void |
|
68 | - */ |
|
69 | - public function enqueueRecaptchaScript() |
|
70 | - { |
|
71 | - // wpforms-recaptcha |
|
72 | - // google-recaptcha |
|
73 | - // nf-google-recaptcha |
|
74 | - if (!glsr(OptionManager::class)->isRecaptchaEnabled()) { |
|
75 | - return; |
|
76 | - } |
|
77 | - $language = apply_filters('site-reviews/recaptcha/language', get_locale()); |
|
78 | - wp_enqueue_script(Application::ID.'/google-recaptcha', add_query_arg([ |
|
79 | - 'hl' => $language, |
|
80 | - 'render' => 'explicit', |
|
81 | - ], 'https://www.google.com/recaptcha/api.js')); |
|
82 | - } |
|
66 | + /** |
|
67 | + * @return void |
|
68 | + */ |
|
69 | + public function enqueueRecaptchaScript() |
|
70 | + { |
|
71 | + // wpforms-recaptcha |
|
72 | + // google-recaptcha |
|
73 | + // nf-google-recaptcha |
|
74 | + if (!glsr(OptionManager::class)->isRecaptchaEnabled()) { |
|
75 | + return; |
|
76 | + } |
|
77 | + $language = apply_filters('site-reviews/recaptcha/language', get_locale()); |
|
78 | + wp_enqueue_script(Application::ID.'/google-recaptcha', add_query_arg([ |
|
79 | + 'hl' => $language, |
|
80 | + 'render' => 'explicit', |
|
81 | + ], 'https://www.google.com/recaptcha/api.js')); |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * @return void |
|
86 | - */ |
|
87 | - public function inlineScript() |
|
88 | - { |
|
89 | - $variables = [ |
|
90 | - 'action' => Application::PREFIX.'action', |
|
91 | - 'ajaxpagination' => $this->getFixedSelectorsForPagination(), |
|
92 | - 'ajaxurl' => admin_url('admin-ajax.php'), |
|
93 | - 'nameprefix' => Application::ID, |
|
94 | - 'urlparameter' => glsr(OptionManager::class)->getBool('settings.reviews.pagination.url_parameter'), |
|
95 | - 'validationconfig' => glsr(Style::class)->validation, |
|
96 | - 'validationstrings' => glsr(ValidationStringsDefaults::class)->defaults(), |
|
97 | - ]; |
|
98 | - $variables = apply_filters('site-reviews/enqueue/public/localize', $variables); |
|
99 | - wp_add_inline_script(Application::ID, $this->buildInlineScript($variables), 'before'); |
|
100 | - } |
|
84 | + /** |
|
85 | + * @return void |
|
86 | + */ |
|
87 | + public function inlineScript() |
|
88 | + { |
|
89 | + $variables = [ |
|
90 | + 'action' => Application::PREFIX.'action', |
|
91 | + 'ajaxpagination' => $this->getFixedSelectorsForPagination(), |
|
92 | + 'ajaxurl' => admin_url('admin-ajax.php'), |
|
93 | + 'nameprefix' => Application::ID, |
|
94 | + 'urlparameter' => glsr(OptionManager::class)->getBool('settings.reviews.pagination.url_parameter'), |
|
95 | + 'validationconfig' => glsr(Style::class)->validation, |
|
96 | + 'validationstrings' => glsr(ValidationStringsDefaults::class)->defaults(), |
|
97 | + ]; |
|
98 | + $variables = apply_filters('site-reviews/enqueue/public/localize', $variables); |
|
99 | + wp_add_inline_script(Application::ID, $this->buildInlineScript($variables), 'before'); |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * @return void |
|
104 | - */ |
|
105 | - public function inlineStyles() |
|
106 | - { |
|
107 | - $inlineStylesheetPath = glsr()->path('assets/styles/inline-styles.css'); |
|
108 | - if (!apply_filters('site-reviews/assets/css', true)) { |
|
109 | - return; |
|
110 | - } |
|
111 | - if (!file_exists($inlineStylesheetPath)) { |
|
112 | - glsr_log()->error('Inline stylesheet is missing: '.$inlineStylesheetPath); |
|
113 | - return; |
|
114 | - } |
|
115 | - $inlineStylesheetValues = glsr()->config('inline-styles'); |
|
116 | - $stylesheet = str_replace( |
|
117 | - array_keys($inlineStylesheetValues), |
|
118 | - array_values($inlineStylesheetValues), |
|
119 | - file_get_contents($inlineStylesheetPath) |
|
120 | - ); |
|
121 | - wp_add_inline_style(Application::ID, $stylesheet); |
|
122 | - } |
|
102 | + /** |
|
103 | + * @return void |
|
104 | + */ |
|
105 | + public function inlineStyles() |
|
106 | + { |
|
107 | + $inlineStylesheetPath = glsr()->path('assets/styles/inline-styles.css'); |
|
108 | + if (!apply_filters('site-reviews/assets/css', true)) { |
|
109 | + return; |
|
110 | + } |
|
111 | + if (!file_exists($inlineStylesheetPath)) { |
|
112 | + glsr_log()->error('Inline stylesheet is missing: '.$inlineStylesheetPath); |
|
113 | + return; |
|
114 | + } |
|
115 | + $inlineStylesheetValues = glsr()->config('inline-styles'); |
|
116 | + $stylesheet = str_replace( |
|
117 | + array_keys($inlineStylesheetValues), |
|
118 | + array_values($inlineStylesheetValues), |
|
119 | + file_get_contents($inlineStylesheetPath) |
|
120 | + ); |
|
121 | + wp_add_inline_style(Application::ID, $stylesheet); |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * @return string |
|
126 | - */ |
|
127 | - protected function buildInlineScript(array $variables) |
|
128 | - { |
|
129 | - $script = 'window.hasOwnProperty("GLSR")||(window.GLSR={});'; |
|
130 | - foreach ($variables as $key => $value) { |
|
131 | - $script.= sprintf('GLSR.%s=%s;', $key, json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); |
|
132 | - } |
|
133 | - $pattern = '/\"([^ \-\"]+)\"(:[{\[\"])/'; // removes unnecessary quotes surrounding object keys |
|
134 | - $optimizedScript = preg_replace($pattern, '$1$2', $script); |
|
135 | - return apply_filters('site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables); |
|
136 | - } |
|
124 | + /** |
|
125 | + * @return string |
|
126 | + */ |
|
127 | + protected function buildInlineScript(array $variables) |
|
128 | + { |
|
129 | + $script = 'window.hasOwnProperty("GLSR")||(window.GLSR={});'; |
|
130 | + foreach ($variables as $key => $value) { |
|
131 | + $script.= sprintf('GLSR.%s=%s;', $key, json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); |
|
132 | + } |
|
133 | + $pattern = '/\"([^ \-\"]+)\"(:[{\[\"])/'; // removes unnecessary quotes surrounding object keys |
|
134 | + $optimizedScript = preg_replace($pattern, '$1$2', $script); |
|
135 | + return apply_filters('site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables); |
|
136 | + } |
|
137 | 137 | |
138 | - /** |
|
139 | - * @return array |
|
140 | - */ |
|
141 | - protected function getFixedSelectorsForPagination() |
|
142 | - { |
|
143 | - $selectors = ['#wpadminbar', '.site-navigation-fixed']; |
|
144 | - return apply_filters('site-reviews/enqueue/public/localize/ajax-pagination', $selectors); |
|
145 | - } |
|
138 | + /** |
|
139 | + * @return array |
|
140 | + */ |
|
141 | + protected function getFixedSelectorsForPagination() |
|
142 | + { |
|
143 | + $selectors = ['#wpadminbar', '.site-navigation-fixed']; |
|
144 | + return apply_filters('site-reviews/enqueue/public/localize/ajax-pagination', $selectors); |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * @return string |
|
149 | - */ |
|
150 | - protected function getStylesheet() |
|
151 | - { |
|
152 | - $currentStyle = glsr(Style::class)->style; |
|
153 | - return file_exists(glsr()->path('assets/styles/custom/'.$currentStyle.'.css')) |
|
154 | - ? glsr()->url('assets/styles/custom/'.$currentStyle.'.css') |
|
155 | - : glsr()->url('assets/styles/'.Application::ID.'.css'); |
|
156 | - } |
|
147 | + /** |
|
148 | + * @return string |
|
149 | + */ |
|
150 | + protected function getStylesheet() |
|
151 | + { |
|
152 | + $currentStyle = glsr(Style::class)->style; |
|
153 | + return file_exists(glsr()->path('assets/styles/custom/'.$currentStyle.'.css')) |
|
154 | + ? glsr()->url('assets/styles/custom/'.$currentStyle.'.css') |
|
155 | + : glsr()->url('assets/styles/'.Application::ID.'.css'); |
|
156 | + } |
|
157 | 157 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function enqueueAssets() |
28 | 28 | { |
29 | - if (apply_filters('site-reviews/assets/css', true)) { |
|
29 | + if( apply_filters( 'site-reviews/assets/css', true ) ) { |
|
30 | 30 | wp_enqueue_style( |
31 | 31 | Application::ID, |
32 | 32 | $this->getStylesheet(), |
@@ -34,14 +34,14 @@ discard block |
||
34 | 34 | glsr()->version |
35 | 35 | ); |
36 | 36 | } |
37 | - if (apply_filters('site-reviews/assets/js', true)) { |
|
38 | - $dependencies = apply_filters('site-reviews/assets/polyfill', true) |
|
37 | + if( apply_filters( 'site-reviews/assets/js', true ) ) { |
|
38 | + $dependencies = apply_filters( 'site-reviews/assets/polyfill', true ) |
|
39 | 39 | ? [Application::ID.'/polyfill'] |
40 | 40 | : []; |
41 | - $dependencies = apply_filters('site-reviews/enqueue/public/dependencies', $dependencies); |
|
41 | + $dependencies = apply_filters( 'site-reviews/enqueue/public/dependencies', $dependencies ); |
|
42 | 42 | wp_enqueue_script( |
43 | 43 | Application::ID, |
44 | - glsr()->url('assets/scripts/'.Application::ID.'.js'), |
|
44 | + glsr()->url( 'assets/scripts/'.Application::ID.'.js' ), |
|
45 | 45 | $dependencies, |
46 | 46 | glsr()->version, |
47 | 47 | true |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function enqueuePolyfillService() |
56 | 56 | { |
57 | - if (!apply_filters('site-reviews/assets/polyfill', true)) { |
|
57 | + if( !apply_filters( 'site-reviews/assets/polyfill', true ) ) { |
|
58 | 58 | return; |
59 | 59 | } |
60 | - wp_enqueue_script(Application::ID.'/polyfill', add_query_arg([ |
|
60 | + wp_enqueue_script( Application::ID.'/polyfill', add_query_arg( [ |
|
61 | 61 | 'features' => 'Array.prototype.findIndex,CustomEvent,Element.prototype.closest,Element.prototype.dataset,Event,XMLHttpRequest,MutationObserver', |
62 | 62 | 'flags' => 'gated', |
63 | - ], 'https://polyfill.io/v3/polyfill.min.js')); |
|
63 | + ], 'https://polyfill.io/v3/polyfill.min.js' ) ); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -71,14 +71,14 @@ discard block |
||
71 | 71 | // wpforms-recaptcha |
72 | 72 | // google-recaptcha |
73 | 73 | // nf-google-recaptcha |
74 | - if (!glsr(OptionManager::class)->isRecaptchaEnabled()) { |
|
74 | + if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) { |
|
75 | 75 | return; |
76 | 76 | } |
77 | - $language = apply_filters('site-reviews/recaptcha/language', get_locale()); |
|
78 | - wp_enqueue_script(Application::ID.'/google-recaptcha', add_query_arg([ |
|
77 | + $language = apply_filters( 'site-reviews/recaptcha/language', get_locale() ); |
|
78 | + wp_enqueue_script( Application::ID.'/google-recaptcha', add_query_arg( [ |
|
79 | 79 | 'hl' => $language, |
80 | 80 | 'render' => 'explicit', |
81 | - ], 'https://www.google.com/recaptcha/api.js')); |
|
81 | + ], 'https://www.google.com/recaptcha/api.js' ) ); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -89,14 +89,14 @@ discard block |
||
89 | 89 | $variables = [ |
90 | 90 | 'action' => Application::PREFIX.'action', |
91 | 91 | 'ajaxpagination' => $this->getFixedSelectorsForPagination(), |
92 | - 'ajaxurl' => admin_url('admin-ajax.php'), |
|
92 | + 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
|
93 | 93 | 'nameprefix' => Application::ID, |
94 | - 'urlparameter' => glsr(OptionManager::class)->getBool('settings.reviews.pagination.url_parameter'), |
|
95 | - 'validationconfig' => glsr(Style::class)->validation, |
|
96 | - 'validationstrings' => glsr(ValidationStringsDefaults::class)->defaults(), |
|
94 | + 'urlparameter' => glsr( OptionManager::class )->getBool( 'settings.reviews.pagination.url_parameter' ), |
|
95 | + 'validationconfig' => glsr( Style::class )->validation, |
|
96 | + 'validationstrings' => glsr( ValidationStringsDefaults::class )->defaults(), |
|
97 | 97 | ]; |
98 | - $variables = apply_filters('site-reviews/enqueue/public/localize', $variables); |
|
99 | - wp_add_inline_script(Application::ID, $this->buildInlineScript($variables), 'before'); |
|
98 | + $variables = apply_filters( 'site-reviews/enqueue/public/localize', $variables ); |
|
99 | + wp_add_inline_script( Application::ID, $this->buildInlineScript( $variables ), 'before' ); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -104,35 +104,35 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function inlineStyles() |
106 | 106 | { |
107 | - $inlineStylesheetPath = glsr()->path('assets/styles/inline-styles.css'); |
|
108 | - if (!apply_filters('site-reviews/assets/css', true)) { |
|
107 | + $inlineStylesheetPath = glsr()->path( 'assets/styles/inline-styles.css' ); |
|
108 | + if( !apply_filters( 'site-reviews/assets/css', true ) ) { |
|
109 | 109 | return; |
110 | 110 | } |
111 | - if (!file_exists($inlineStylesheetPath)) { |
|
112 | - glsr_log()->error('Inline stylesheet is missing: '.$inlineStylesheetPath); |
|
111 | + if( !file_exists( $inlineStylesheetPath ) ) { |
|
112 | + glsr_log()->error( 'Inline stylesheet is missing: '.$inlineStylesheetPath ); |
|
113 | 113 | return; |
114 | 114 | } |
115 | - $inlineStylesheetValues = glsr()->config('inline-styles'); |
|
115 | + $inlineStylesheetValues = glsr()->config( 'inline-styles' ); |
|
116 | 116 | $stylesheet = str_replace( |
117 | - array_keys($inlineStylesheetValues), |
|
118 | - array_values($inlineStylesheetValues), |
|
119 | - file_get_contents($inlineStylesheetPath) |
|
117 | + array_keys( $inlineStylesheetValues ), |
|
118 | + array_values( $inlineStylesheetValues ), |
|
119 | + file_get_contents( $inlineStylesheetPath ) |
|
120 | 120 | ); |
121 | - wp_add_inline_style(Application::ID, $stylesheet); |
|
121 | + wp_add_inline_style( Application::ID, $stylesheet ); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
125 | 125 | * @return string |
126 | 126 | */ |
127 | - protected function buildInlineScript(array $variables) |
|
127 | + protected function buildInlineScript( array $variables ) |
|
128 | 128 | { |
129 | 129 | $script = 'window.hasOwnProperty("GLSR")||(window.GLSR={});'; |
130 | - foreach ($variables as $key => $value) { |
|
131 | - $script.= sprintf('GLSR.%s=%s;', $key, json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); |
|
130 | + foreach( $variables as $key => $value ) { |
|
131 | + $script .= sprintf( 'GLSR.%s=%s;', $key, json_encode( $value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) ); |
|
132 | 132 | } |
133 | 133 | $pattern = '/\"([^ \-\"]+)\"(:[{\[\"])/'; // removes unnecessary quotes surrounding object keys |
134 | - $optimizedScript = preg_replace($pattern, '$1$2', $script); |
|
135 | - return apply_filters('site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables); |
|
134 | + $optimizedScript = preg_replace( $pattern, '$1$2', $script ); |
|
135 | + return apply_filters( 'site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables ); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | protected function getFixedSelectorsForPagination() |
142 | 142 | { |
143 | 143 | $selectors = ['#wpadminbar', '.site-navigation-fixed']; |
144 | - return apply_filters('site-reviews/enqueue/public/localize/ajax-pagination', $selectors); |
|
144 | + return apply_filters( 'site-reviews/enqueue/public/localize/ajax-pagination', $selectors ); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -149,9 +149,9 @@ discard block |
||
149 | 149 | */ |
150 | 150 | protected function getStylesheet() |
151 | 151 | { |
152 | - $currentStyle = glsr(Style::class)->style; |
|
153 | - return file_exists(glsr()->path('assets/styles/custom/'.$currentStyle.'.css')) |
|
154 | - ? glsr()->url('assets/styles/custom/'.$currentStyle.'.css') |
|
155 | - : glsr()->url('assets/styles/'.Application::ID.'.css'); |
|
152 | + $currentStyle = glsr( Style::class )->style; |
|
153 | + return file_exists( glsr()->path( 'assets/styles/custom/'.$currentStyle.'.css' ) ) |
|
154 | + ? glsr()->url( 'assets/styles/custom/'.$currentStyle.'.css' ) |
|
155 | + : glsr()->url( 'assets/styles/'.Application::ID.'.css' ); |
|
156 | 156 | } |
157 | 157 | } |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | return [ |
4 | - 'fields' => [ |
|
5 | - 'input' => 'input', |
|
6 | - 'input_checkbox' => 'input', |
|
7 | - 'input_radio' => 'input', |
|
8 | - 'label' => 'et_pb_contact_form_label', |
|
9 | - 'select' => 'et_pb_contact_select input', |
|
10 | - 'textarea' => 'et_pb_contact_message input', |
|
11 | - ], |
|
12 | - 'validation' => [ |
|
13 | - 'field_error_class' => 'et_contact_error', |
|
14 | - 'input_error_class' => 'et_contact_error', |
|
15 | - ], |
|
4 | + 'fields' => [ |
|
5 | + 'input' => 'input', |
|
6 | + 'input_checkbox' => 'input', |
|
7 | + 'input_radio' => 'input', |
|
8 | + 'label' => 'et_pb_contact_form_label', |
|
9 | + 'select' => 'et_pb_contact_select input', |
|
10 | + 'textarea' => 'et_pb_contact_message input', |
|
11 | + ], |
|
12 | + 'validation' => [ |
|
13 | + 'field_error_class' => 'et_contact_error', |
|
14 | + 'input_error_class' => 'et_contact_error', |
|
15 | + ], |
|
16 | 16 | ]; |
@@ -13,378 +13,378 @@ |
||
13 | 13 | |
14 | 14 | class System |
15 | 15 | { |
16 | - const PAD = 40; |
|
16 | + const PAD = 40; |
|
17 | 17 | |
18 | - /** |
|
19 | - * @return string |
|
20 | - */ |
|
21 | - public function __toString() |
|
22 | - { |
|
23 | - return $this->get(); |
|
24 | - } |
|
18 | + /** |
|
19 | + * @return string |
|
20 | + */ |
|
21 | + public function __toString() |
|
22 | + { |
|
23 | + return $this->get(); |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * @return string |
|
28 | - */ |
|
29 | - public function get() |
|
30 | - { |
|
31 | - $details = [ |
|
32 | - 'plugin' => 'Plugin Details', |
|
33 | - 'addon' => 'Addon Details', |
|
34 | - 'browser' => 'Browser Details', |
|
35 | - 'server' => 'Server Details', |
|
36 | - 'php' => 'PHP Configuration', |
|
37 | - 'wordpress' => 'WordPress Configuration', |
|
38 | - 'mu-plugin' => 'Must-Use Plugins', |
|
39 | - 'multisite-plugin' => 'Network Active Plugins', |
|
40 | - 'active-plugin' => 'Active Plugins', |
|
41 | - 'inactive-plugin' => 'Inactive Plugins', |
|
42 | - 'setting' => 'Plugin Settings', |
|
43 | - 'reviews' => 'Review Counts', |
|
44 | - ]; |
|
45 | - $systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) { |
|
46 | - $methodName = Helper::buildMethodName('get-'.$key.'-details'); |
|
47 | - if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) { |
|
48 | - return $carry.$this->implode( |
|
49 | - strtoupper($details[$key]), |
|
50 | - apply_filters('site-reviews/system/'.$key, $systemDetails) |
|
51 | - ); |
|
52 | - } |
|
53 | - return $carry; |
|
54 | - }); |
|
55 | - return trim($systemInfo); |
|
56 | - } |
|
26 | + /** |
|
27 | + * @return string |
|
28 | + */ |
|
29 | + public function get() |
|
30 | + { |
|
31 | + $details = [ |
|
32 | + 'plugin' => 'Plugin Details', |
|
33 | + 'addon' => 'Addon Details', |
|
34 | + 'browser' => 'Browser Details', |
|
35 | + 'server' => 'Server Details', |
|
36 | + 'php' => 'PHP Configuration', |
|
37 | + 'wordpress' => 'WordPress Configuration', |
|
38 | + 'mu-plugin' => 'Must-Use Plugins', |
|
39 | + 'multisite-plugin' => 'Network Active Plugins', |
|
40 | + 'active-plugin' => 'Active Plugins', |
|
41 | + 'inactive-plugin' => 'Inactive Plugins', |
|
42 | + 'setting' => 'Plugin Settings', |
|
43 | + 'reviews' => 'Review Counts', |
|
44 | + ]; |
|
45 | + $systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) { |
|
46 | + $methodName = Helper::buildMethodName('get-'.$key.'-details'); |
|
47 | + if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) { |
|
48 | + return $carry.$this->implode( |
|
49 | + strtoupper($details[$key]), |
|
50 | + apply_filters('site-reviews/system/'.$key, $systemDetails) |
|
51 | + ); |
|
52 | + } |
|
53 | + return $carry; |
|
54 | + }); |
|
55 | + return trim($systemInfo); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @return array |
|
60 | - */ |
|
61 | - public function getActivePluginDetails() |
|
62 | - { |
|
63 | - $plugins = get_plugins(); |
|
64 | - $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array'); |
|
65 | - $inactive = array_diff_key($plugins, array_flip($activePlugins)); |
|
66 | - return $this->normalizePluginList(array_diff_key($plugins, $inactive)); |
|
67 | - } |
|
58 | + /** |
|
59 | + * @return array |
|
60 | + */ |
|
61 | + public function getActivePluginDetails() |
|
62 | + { |
|
63 | + $plugins = get_plugins(); |
|
64 | + $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array'); |
|
65 | + $inactive = array_diff_key($plugins, array_flip($activePlugins)); |
|
66 | + return $this->normalizePluginList(array_diff_key($plugins, $inactive)); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @return array |
|
71 | - */ |
|
72 | - public function getAddonDetails() |
|
73 | - { |
|
74 | - $details = apply_filters('site-reviews/addon/system-info', []); |
|
75 | - ksort($details); |
|
76 | - return $details; |
|
77 | - } |
|
69 | + /** |
|
70 | + * @return array |
|
71 | + */ |
|
72 | + public function getAddonDetails() |
|
73 | + { |
|
74 | + $details = apply_filters('site-reviews/addon/system-info', []); |
|
75 | + ksort($details); |
|
76 | + return $details; |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * @return array |
|
81 | - */ |
|
82 | - public function getBrowserDetails() |
|
83 | - { |
|
84 | - $browser = new Browser(); |
|
85 | - $name = esc_attr($browser->getName()); |
|
86 | - $userAgent = esc_attr($browser->getUserAgent()->getUserAgentString()); |
|
87 | - $version = esc_attr($browser->getVersion()); |
|
88 | - return [ |
|
89 | - 'Browser Name' => sprintf('%s %s', $name, $version), |
|
90 | - 'Browser UA' => $userAgent, |
|
91 | - ]; |
|
92 | - } |
|
79 | + /** |
|
80 | + * @return array |
|
81 | + */ |
|
82 | + public function getBrowserDetails() |
|
83 | + { |
|
84 | + $browser = new Browser(); |
|
85 | + $name = esc_attr($browser->getName()); |
|
86 | + $userAgent = esc_attr($browser->getUserAgent()->getUserAgentString()); |
|
87 | + $version = esc_attr($browser->getVersion()); |
|
88 | + return [ |
|
89 | + 'Browser Name' => sprintf('%s %s', $name, $version), |
|
90 | + 'Browser UA' => $userAgent, |
|
91 | + ]; |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * @return array |
|
96 | - */ |
|
97 | - public function getInactivePluginDetails() |
|
98 | - { |
|
99 | - $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array'); |
|
100 | - $inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins))); |
|
101 | - $multisitePlugins = $this->getMultisitePluginDetails(); |
|
102 | - return empty($multisitePlugins) |
|
103 | - ? $inactivePlugins |
|
104 | - : array_diff($inactivePlugins, $multisitePlugins); |
|
105 | - } |
|
94 | + /** |
|
95 | + * @return array |
|
96 | + */ |
|
97 | + public function getInactivePluginDetails() |
|
98 | + { |
|
99 | + $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array'); |
|
100 | + $inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins))); |
|
101 | + $multisitePlugins = $this->getMultisitePluginDetails(); |
|
102 | + return empty($multisitePlugins) |
|
103 | + ? $inactivePlugins |
|
104 | + : array_diff($inactivePlugins, $multisitePlugins); |
|
105 | + } |
|
106 | 106 | |
107 | - /** |
|
108 | - * @return array |
|
109 | - */ |
|
110 | - public function getMuPluginDetails() |
|
111 | - { |
|
112 | - if (empty($plugins = get_mu_plugins())) { |
|
113 | - return []; |
|
114 | - } |
|
115 | - return $this->normalizePluginList($plugins); |
|
116 | - } |
|
107 | + /** |
|
108 | + * @return array |
|
109 | + */ |
|
110 | + public function getMuPluginDetails() |
|
111 | + { |
|
112 | + if (empty($plugins = get_mu_plugins())) { |
|
113 | + return []; |
|
114 | + } |
|
115 | + return $this->normalizePluginList($plugins); |
|
116 | + } |
|
117 | 117 | |
118 | - /** |
|
119 | - * @return array |
|
120 | - */ |
|
121 | - public function getMultisitePluginDetails() |
|
122 | - { |
|
123 | - $activePlugins = (array) get_site_option('active_sitewide_plugins', []); |
|
124 | - if (!is_multisite() || empty($activePlugins)) { |
|
125 | - return []; |
|
126 | - } |
|
127 | - return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins)); |
|
128 | - } |
|
118 | + /** |
|
119 | + * @return array |
|
120 | + */ |
|
121 | + public function getMultisitePluginDetails() |
|
122 | + { |
|
123 | + $activePlugins = (array) get_site_option('active_sitewide_plugins', []); |
|
124 | + if (!is_multisite() || empty($activePlugins)) { |
|
125 | + return []; |
|
126 | + } |
|
127 | + return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins)); |
|
128 | + } |
|
129 | 129 | |
130 | - /** |
|
131 | - * @return array |
|
132 | - */ |
|
133 | - public function getPhpDetails() |
|
134 | - { |
|
135 | - $displayErrors = $this->getINI('display_errors', null) |
|
136 | - ? 'On ('.$this->getINI('display_errors').')' |
|
137 | - : 'N/A'; |
|
138 | - $intlSupport = extension_loaded('intl') |
|
139 | - ? phpversion('intl') |
|
140 | - : 'false'; |
|
141 | - return [ |
|
142 | - 'cURL' => var_export(function_exists('curl_init'), true), |
|
143 | - 'Default Charset' => $this->getINI('default_charset'), |
|
144 | - 'Display Errors' => $displayErrors, |
|
145 | - 'fsockopen' => var_export(function_exists('fsockopen'), true), |
|
146 | - 'Intl' => $intlSupport, |
|
147 | - 'IPv6' => var_export(defined('AF_INET6'), true), |
|
148 | - 'Max Execution Time' => $this->getINI('max_execution_time'), |
|
149 | - 'Max Input Nesting Level' => $this->getINI('max_input_nesting_level'), |
|
150 | - 'Max Input Vars' => $this->getINI('max_input_vars'), |
|
151 | - 'Memory Limit' => $this->getINI('memory_limit'), |
|
152 | - 'Post Max Size' => $this->getINI('post_max_size'), |
|
153 | - 'Sendmail Path' => $this->getINI('sendmail_path'), |
|
154 | - 'Session Cookie Path' => esc_html($this->getINI('session.cookie_path')), |
|
155 | - 'Session Name' => esc_html($this->getINI('session.name')), |
|
156 | - 'Session Save Path' => esc_html($this->getINI('session.save_path')), |
|
157 | - 'Session Use Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_cookies', false)), true), |
|
158 | - 'Session Use Only Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_only_cookies', false)), true), |
|
159 | - 'Upload Max Filesize' => $this->getINI('upload_max_filesize'), |
|
160 | - ]; |
|
161 | - } |
|
130 | + /** |
|
131 | + * @return array |
|
132 | + */ |
|
133 | + public function getPhpDetails() |
|
134 | + { |
|
135 | + $displayErrors = $this->getINI('display_errors', null) |
|
136 | + ? 'On ('.$this->getINI('display_errors').')' |
|
137 | + : 'N/A'; |
|
138 | + $intlSupport = extension_loaded('intl') |
|
139 | + ? phpversion('intl') |
|
140 | + : 'false'; |
|
141 | + return [ |
|
142 | + 'cURL' => var_export(function_exists('curl_init'), true), |
|
143 | + 'Default Charset' => $this->getINI('default_charset'), |
|
144 | + 'Display Errors' => $displayErrors, |
|
145 | + 'fsockopen' => var_export(function_exists('fsockopen'), true), |
|
146 | + 'Intl' => $intlSupport, |
|
147 | + 'IPv6' => var_export(defined('AF_INET6'), true), |
|
148 | + 'Max Execution Time' => $this->getINI('max_execution_time'), |
|
149 | + 'Max Input Nesting Level' => $this->getINI('max_input_nesting_level'), |
|
150 | + 'Max Input Vars' => $this->getINI('max_input_vars'), |
|
151 | + 'Memory Limit' => $this->getINI('memory_limit'), |
|
152 | + 'Post Max Size' => $this->getINI('post_max_size'), |
|
153 | + 'Sendmail Path' => $this->getINI('sendmail_path'), |
|
154 | + 'Session Cookie Path' => esc_html($this->getINI('session.cookie_path')), |
|
155 | + 'Session Name' => esc_html($this->getINI('session.name')), |
|
156 | + 'Session Save Path' => esc_html($this->getINI('session.save_path')), |
|
157 | + 'Session Use Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_cookies', false)), true), |
|
158 | + 'Session Use Only Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_only_cookies', false)), true), |
|
159 | + 'Upload Max Filesize' => $this->getINI('upload_max_filesize'), |
|
160 | + ]; |
|
161 | + } |
|
162 | 162 | |
163 | - /** |
|
164 | - * @return array |
|
165 | - */ |
|
166 | - public function getReviewsDetails() |
|
167 | - { |
|
168 | - $counts = glsr(CountsManager::class)->getCounts(); |
|
169 | - $counts = Arr::flattenArray($counts); |
|
170 | - array_walk($counts, function (&$ratings) use ($counts) { |
|
171 | - if (is_array($ratings)) { |
|
172 | - $ratings = array_sum($ratings).' ('.implode(', ', $ratings).')'; |
|
173 | - return; |
|
174 | - } |
|
175 | - glsr_log() |
|
176 | - ->error('$ratings is not an array, possibly due to incorrectly imported reviews.') |
|
177 | - ->debug($ratings) |
|
178 | - ->debug($counts); |
|
179 | - }); |
|
180 | - ksort($counts); |
|
181 | - return $counts; |
|
182 | - } |
|
163 | + /** |
|
164 | + * @return array |
|
165 | + */ |
|
166 | + public function getReviewsDetails() |
|
167 | + { |
|
168 | + $counts = glsr(CountsManager::class)->getCounts(); |
|
169 | + $counts = Arr::flattenArray($counts); |
|
170 | + array_walk($counts, function (&$ratings) use ($counts) { |
|
171 | + if (is_array($ratings)) { |
|
172 | + $ratings = array_sum($ratings).' ('.implode(', ', $ratings).')'; |
|
173 | + return; |
|
174 | + } |
|
175 | + glsr_log() |
|
176 | + ->error('$ratings is not an array, possibly due to incorrectly imported reviews.') |
|
177 | + ->debug($ratings) |
|
178 | + ->debug($counts); |
|
179 | + }); |
|
180 | + ksort($counts); |
|
181 | + return $counts; |
|
182 | + } |
|
183 | 183 | |
184 | - /** |
|
185 | - * @return array |
|
186 | - */ |
|
187 | - public function getServerDetails() |
|
188 | - { |
|
189 | - global $wpdb; |
|
190 | - return [ |
|
191 | - 'Host Name' => $this->getHostName(), |
|
192 | - 'MySQL Version' => $wpdb->db_version(), |
|
193 | - 'PHP Version' => PHP_VERSION, |
|
194 | - 'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'), |
|
195 | - ]; |
|
196 | - } |
|
184 | + /** |
|
185 | + * @return array |
|
186 | + */ |
|
187 | + public function getServerDetails() |
|
188 | + { |
|
189 | + global $wpdb; |
|
190 | + return [ |
|
191 | + 'Host Name' => $this->getHostName(), |
|
192 | + 'MySQL Version' => $wpdb->db_version(), |
|
193 | + 'PHP Version' => PHP_VERSION, |
|
194 | + 'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'), |
|
195 | + ]; |
|
196 | + } |
|
197 | 197 | |
198 | - /** |
|
199 | - * @return array |
|
200 | - */ |
|
201 | - public function getSettingDetails() |
|
202 | - { |
|
203 | - $settings = glsr(OptionManager::class)->get('settings', []); |
|
204 | - $settings = Arr::flattenArray($settings, true); |
|
205 | - $settings = $this->purgeSensitiveData($settings); |
|
206 | - ksort($settings); |
|
207 | - $details = []; |
|
208 | - foreach ($settings as $key => $value) { |
|
209 | - if (Str::startsWith('strings', $key) && Str::endsWith('id', $key)) { |
|
210 | - continue; |
|
211 | - } |
|
212 | - $value = htmlspecialchars(trim(preg_replace('/\s\s+/u', '\\n', $value)), ENT_QUOTES, 'UTF-8'); |
|
213 | - $details[$key] = $value; |
|
214 | - } |
|
215 | - return $details; |
|
216 | - } |
|
198 | + /** |
|
199 | + * @return array |
|
200 | + */ |
|
201 | + public function getSettingDetails() |
|
202 | + { |
|
203 | + $settings = glsr(OptionManager::class)->get('settings', []); |
|
204 | + $settings = Arr::flattenArray($settings, true); |
|
205 | + $settings = $this->purgeSensitiveData($settings); |
|
206 | + ksort($settings); |
|
207 | + $details = []; |
|
208 | + foreach ($settings as $key => $value) { |
|
209 | + if (Str::startsWith('strings', $key) && Str::endsWith('id', $key)) { |
|
210 | + continue; |
|
211 | + } |
|
212 | + $value = htmlspecialchars(trim(preg_replace('/\s\s+/u', '\\n', $value)), ENT_QUOTES, 'UTF-8'); |
|
213 | + $details[$key] = $value; |
|
214 | + } |
|
215 | + return $details; |
|
216 | + } |
|
217 | 217 | |
218 | - /** |
|
219 | - * @return array |
|
220 | - */ |
|
221 | - public function getPluginDetails() |
|
222 | - { |
|
223 | - return [ |
|
224 | - 'Console level' => glsr(Console::class)->humanLevel(), |
|
225 | - 'Console size' => glsr(Console::class)->humanSize('0'), |
|
226 | - 'Last Migration Run' => glsr(Date::class)->localized(glsr(OptionManager::class)->get('last_migration_run'), 'unknown'), |
|
227 | - 'Last Rating Count' => glsr(Date::class)->localized(glsr(OptionManager::class)->get('last_review_count'), 'unknown'), |
|
228 | - 'Version (current)' => glsr()->version, |
|
229 | - 'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'), |
|
230 | - ]; |
|
231 | - } |
|
218 | + /** |
|
219 | + * @return array |
|
220 | + */ |
|
221 | + public function getPluginDetails() |
|
222 | + { |
|
223 | + return [ |
|
224 | + 'Console level' => glsr(Console::class)->humanLevel(), |
|
225 | + 'Console size' => glsr(Console::class)->humanSize('0'), |
|
226 | + 'Last Migration Run' => glsr(Date::class)->localized(glsr(OptionManager::class)->get('last_migration_run'), 'unknown'), |
|
227 | + 'Last Rating Count' => glsr(Date::class)->localized(glsr(OptionManager::class)->get('last_review_count'), 'unknown'), |
|
228 | + 'Version (current)' => glsr()->version, |
|
229 | + 'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'), |
|
230 | + ]; |
|
231 | + } |
|
232 | 232 | |
233 | - /** |
|
234 | - * @return array |
|
235 | - */ |
|
236 | - public function getWordpressDetails() |
|
237 | - { |
|
238 | - global $wpdb; |
|
239 | - $theme = wp_get_theme(); |
|
240 | - return [ |
|
241 | - 'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version), |
|
242 | - 'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1), |
|
243 | - 'Home URL' => home_url(), |
|
244 | - 'Language' => get_locale(), |
|
245 | - 'Memory Limit' => WP_MEMORY_LIMIT, |
|
246 | - 'Multisite' => var_export(is_multisite(), true), |
|
247 | - 'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'), |
|
248 | - 'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'), |
|
249 | - 'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'), |
|
250 | - 'Post Stati' => implode(', ', get_post_stati()), |
|
251 | - 'Remote Post' => glsr(Cache::class)->getRemotePostTest(), |
|
252 | - 'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'), |
|
253 | - 'Site URL' => site_url(), |
|
254 | - 'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', $this->getINI('date.timezone').' (PHP)'), |
|
255 | - 'Version' => get_bloginfo('version'), |
|
256 | - 'WP Debug' => var_export(defined('WP_DEBUG'), true), |
|
257 | - 'WP Max Upload Size' => size_format(wp_max_upload_size()), |
|
258 | - 'WP Memory Limit' => WP_MEMORY_LIMIT, |
|
259 | - ]; |
|
260 | - } |
|
233 | + /** |
|
234 | + * @return array |
|
235 | + */ |
|
236 | + public function getWordpressDetails() |
|
237 | + { |
|
238 | + global $wpdb; |
|
239 | + $theme = wp_get_theme(); |
|
240 | + return [ |
|
241 | + 'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version), |
|
242 | + 'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1), |
|
243 | + 'Home URL' => home_url(), |
|
244 | + 'Language' => get_locale(), |
|
245 | + 'Memory Limit' => WP_MEMORY_LIMIT, |
|
246 | + 'Multisite' => var_export(is_multisite(), true), |
|
247 | + 'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'), |
|
248 | + 'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'), |
|
249 | + 'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'), |
|
250 | + 'Post Stati' => implode(', ', get_post_stati()), |
|
251 | + 'Remote Post' => glsr(Cache::class)->getRemotePostTest(), |
|
252 | + 'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'), |
|
253 | + 'Site URL' => site_url(), |
|
254 | + 'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', $this->getINI('date.timezone').' (PHP)'), |
|
255 | + 'Version' => get_bloginfo('version'), |
|
256 | + 'WP Debug' => var_export(defined('WP_DEBUG'), true), |
|
257 | + 'WP Max Upload Size' => size_format(wp_max_upload_size()), |
|
258 | + 'WP Memory Limit' => WP_MEMORY_LIMIT, |
|
259 | + ]; |
|
260 | + } |
|
261 | 261 | |
262 | - /** |
|
263 | - * @return string |
|
264 | - */ |
|
265 | - protected function detectWebhostProvider() |
|
266 | - { |
|
267 | - $checks = [ |
|
268 | - '.accountservergroup.com' => 'Site5', |
|
269 | - '.gridserver.com' => 'MediaTemple Grid', |
|
270 | - '.inmotionhosting.com' => 'InMotion Hosting', |
|
271 | - '.ovh.net' => 'OVH', |
|
272 | - '.pair.com' => 'pair Networks', |
|
273 | - '.stabletransit.com' => 'Rackspace Cloud', |
|
274 | - '.stratoserver.net' => 'STRATO', |
|
275 | - '.sysfix.eu' => 'SysFix.eu Power Hosting', |
|
276 | - 'bluehost.com' => 'Bluehost', |
|
277 | - 'DH_USER' => 'DreamHost', |
|
278 | - 'Flywheel' => 'Flywheel', |
|
279 | - 'ipagemysql.com' => 'iPage', |
|
280 | - 'ipowermysql.com' => 'IPower', |
|
281 | - 'localhost:/tmp/mysql5.sock' => 'ICDSoft', |
|
282 | - 'mysqlv5' => 'NetworkSolutions', |
|
283 | - 'PAGELYBIN' => 'Pagely', |
|
284 | - 'secureserver.net' => 'GoDaddy', |
|
285 | - 'WPE_APIKEY' => 'WP Engine', |
|
286 | - ]; |
|
287 | - foreach ($checks as $key => $value) { |
|
288 | - if (!$this->isWebhostCheckValid($key)) { |
|
289 | - continue; |
|
290 | - } |
|
291 | - return $value; |
|
292 | - } |
|
293 | - return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')])); |
|
294 | - } |
|
262 | + /** |
|
263 | + * @return string |
|
264 | + */ |
|
265 | + protected function detectWebhostProvider() |
|
266 | + { |
|
267 | + $checks = [ |
|
268 | + '.accountservergroup.com' => 'Site5', |
|
269 | + '.gridserver.com' => 'MediaTemple Grid', |
|
270 | + '.inmotionhosting.com' => 'InMotion Hosting', |
|
271 | + '.ovh.net' => 'OVH', |
|
272 | + '.pair.com' => 'pair Networks', |
|
273 | + '.stabletransit.com' => 'Rackspace Cloud', |
|
274 | + '.stratoserver.net' => 'STRATO', |
|
275 | + '.sysfix.eu' => 'SysFix.eu Power Hosting', |
|
276 | + 'bluehost.com' => 'Bluehost', |
|
277 | + 'DH_USER' => 'DreamHost', |
|
278 | + 'Flywheel' => 'Flywheel', |
|
279 | + 'ipagemysql.com' => 'iPage', |
|
280 | + 'ipowermysql.com' => 'IPower', |
|
281 | + 'localhost:/tmp/mysql5.sock' => 'ICDSoft', |
|
282 | + 'mysqlv5' => 'NetworkSolutions', |
|
283 | + 'PAGELYBIN' => 'Pagely', |
|
284 | + 'secureserver.net' => 'GoDaddy', |
|
285 | + 'WPE_APIKEY' => 'WP Engine', |
|
286 | + ]; |
|
287 | + foreach ($checks as $key => $value) { |
|
288 | + if (!$this->isWebhostCheckValid($key)) { |
|
289 | + continue; |
|
290 | + } |
|
291 | + return $value; |
|
292 | + } |
|
293 | + return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')])); |
|
294 | + } |
|
295 | 295 | |
296 | - /** |
|
297 | - * @return string |
|
298 | - */ |
|
299 | - protected function getHostName() |
|
300 | - { |
|
301 | - return sprintf('%s (%s)', |
|
302 | - $this->detectWebhostProvider(), |
|
303 | - Helper::getIpAddress() |
|
304 | - ); |
|
305 | - } |
|
296 | + /** |
|
297 | + * @return string |
|
298 | + */ |
|
299 | + protected function getHostName() |
|
300 | + { |
|
301 | + return sprintf('%s (%s)', |
|
302 | + $this->detectWebhostProvider(), |
|
303 | + Helper::getIpAddress() |
|
304 | + ); |
|
305 | + } |
|
306 | 306 | |
307 | - protected function getINI($name, $disabledValue = 'ini_get() is disabled.') |
|
308 | - { |
|
309 | - return function_exists('ini_get') |
|
310 | - ? ini_get($name) |
|
311 | - : $disabledValue; |
|
312 | - } |
|
307 | + protected function getINI($name, $disabledValue = 'ini_get() is disabled.') |
|
308 | + { |
|
309 | + return function_exists('ini_get') |
|
310 | + ? ini_get($name) |
|
311 | + : $disabledValue; |
|
312 | + } |
|
313 | 313 | |
314 | - /** |
|
315 | - * @return array |
|
316 | - */ |
|
317 | - protected function getWordpressPlugins() |
|
318 | - { |
|
319 | - $plugins = get_plugins(); |
|
320 | - $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array'); |
|
321 | - $inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins))); |
|
322 | - $active = $this->normalizePluginList(array_diff_key($plugins, $inactive)); |
|
323 | - return $active + $inactive; |
|
324 | - } |
|
314 | + /** |
|
315 | + * @return array |
|
316 | + */ |
|
317 | + protected function getWordpressPlugins() |
|
318 | + { |
|
319 | + $plugins = get_plugins(); |
|
320 | + $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array'); |
|
321 | + $inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins))); |
|
322 | + $active = $this->normalizePluginList(array_diff_key($plugins, $inactive)); |
|
323 | + return $active + $inactive; |
|
324 | + } |
|
325 | 325 | |
326 | - /** |
|
327 | - * @param string $title |
|
328 | - * @return string |
|
329 | - */ |
|
330 | - protected function implode($title, array $details) |
|
331 | - { |
|
332 | - $strings = ['['.$title.']']; |
|
333 | - $padding = max(array_map('strlen', array_keys($details))); |
|
334 | - $padding = max([$padding, static::PAD]); |
|
335 | - foreach ($details as $key => $value) { |
|
336 | - $strings[] = is_string($key) |
|
337 | - ? sprintf('%s : %s', str_pad($key, $padding, '.'), $value) |
|
338 | - : ' - '.$value; |
|
339 | - } |
|
340 | - return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL; |
|
341 | - } |
|
326 | + /** |
|
327 | + * @param string $title |
|
328 | + * @return string |
|
329 | + */ |
|
330 | + protected function implode($title, array $details) |
|
331 | + { |
|
332 | + $strings = ['['.$title.']']; |
|
333 | + $padding = max(array_map('strlen', array_keys($details))); |
|
334 | + $padding = max([$padding, static::PAD]); |
|
335 | + foreach ($details as $key => $value) { |
|
336 | + $strings[] = is_string($key) |
|
337 | + ? sprintf('%s : %s', str_pad($key, $padding, '.'), $value) |
|
338 | + : ' - '.$value; |
|
339 | + } |
|
340 | + return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL; |
|
341 | + } |
|
342 | 342 | |
343 | - /** |
|
344 | - * @param string $key |
|
345 | - * @return bool |
|
346 | - */ |
|
347 | - protected function isWebhostCheckValid($key) |
|
348 | - { |
|
349 | - return defined($key) |
|
350 | - || filter_input(INPUT_SERVER, $key) |
|
351 | - || Str::contains(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key) |
|
352 | - || Str::contains(DB_HOST, $key) |
|
353 | - || Str::contains(php_uname(), $key); |
|
354 | - } |
|
343 | + /** |
|
344 | + * @param string $key |
|
345 | + * @return bool |
|
346 | + */ |
|
347 | + protected function isWebhostCheckValid($key) |
|
348 | + { |
|
349 | + return defined($key) |
|
350 | + || filter_input(INPUT_SERVER, $key) |
|
351 | + || Str::contains(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key) |
|
352 | + || Str::contains(DB_HOST, $key) |
|
353 | + || Str::contains(php_uname(), $key); |
|
354 | + } |
|
355 | 355 | |
356 | - /** |
|
357 | - * @return array |
|
358 | - */ |
|
359 | - protected function normalizePluginList(array $plugins) |
|
360 | - { |
|
361 | - $plugins = array_map(function ($plugin) { |
|
362 | - return sprintf('%s v%s', Arr::get($plugin, 'Name'), Arr::get($plugin, 'Version')); |
|
363 | - }, $plugins); |
|
364 | - natcasesort($plugins); |
|
365 | - return array_flip($plugins); |
|
366 | - } |
|
356 | + /** |
|
357 | + * @return array |
|
358 | + */ |
|
359 | + protected function normalizePluginList(array $plugins) |
|
360 | + { |
|
361 | + $plugins = array_map(function ($plugin) { |
|
362 | + return sprintf('%s v%s', Arr::get($plugin, 'Name'), Arr::get($plugin, 'Version')); |
|
363 | + }, $plugins); |
|
364 | + natcasesort($plugins); |
|
365 | + return array_flip($plugins); |
|
366 | + } |
|
367 | 367 | |
368 | - /** |
|
369 | - * @return array |
|
370 | - */ |
|
371 | - protected function purgeSensitiveData(array $settings) |
|
372 | - { |
|
373 | - $keys = [ |
|
374 | - 'general.trustalyze_serial', |
|
375 | - 'licenses.', |
|
376 | - 'submissions.recaptcha.key', |
|
377 | - 'submissions.recaptcha.secret', |
|
378 | - ]; |
|
379 | - array_walk($settings, function (&$value, $setting) use ($keys) { |
|
380 | - foreach ($keys as $key) { |
|
381 | - if (!Str::startsWith($key, $setting) || empty($value)) { |
|
382 | - continue; |
|
383 | - } |
|
384 | - $value = str_repeat('•', 13); |
|
385 | - return; |
|
386 | - } |
|
387 | - }); |
|
388 | - return $settings; |
|
389 | - } |
|
368 | + /** |
|
369 | + * @return array |
|
370 | + */ |
|
371 | + protected function purgeSensitiveData(array $settings) |
|
372 | + { |
|
373 | + $keys = [ |
|
374 | + 'general.trustalyze_serial', |
|
375 | + 'licenses.', |
|
376 | + 'submissions.recaptcha.key', |
|
377 | + 'submissions.recaptcha.secret', |
|
378 | + ]; |
|
379 | + array_walk($settings, function (&$value, $setting) use ($keys) { |
|
380 | + foreach ($keys as $key) { |
|
381 | + if (!Str::startsWith($key, $setting) || empty($value)) { |
|
382 | + continue; |
|
383 | + } |
|
384 | + $value = str_repeat('•', 13); |
|
385 | + return; |
|
386 | + } |
|
387 | + }); |
|
388 | + return $settings; |
|
389 | + } |
|
390 | 390 | } |
@@ -42,17 +42,17 @@ discard block |
||
42 | 42 | 'setting' => 'Plugin Settings', |
43 | 43 | 'reviews' => 'Review Counts', |
44 | 44 | ]; |
45 | - $systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) { |
|
46 | - $methodName = Helper::buildMethodName('get-'.$key.'-details'); |
|
47 | - if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) { |
|
45 | + $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use ($details) { |
|
46 | + $methodName = Helper::buildMethodName( 'get-'.$key.'-details' ); |
|
47 | + if( method_exists( $this, $methodName ) && $systemDetails = $this->$methodName() ) { |
|
48 | 48 | return $carry.$this->implode( |
49 | - strtoupper($details[$key]), |
|
50 | - apply_filters('site-reviews/system/'.$key, $systemDetails) |
|
49 | + strtoupper( $details[$key] ), |
|
50 | + apply_filters( 'site-reviews/system/'.$key, $systemDetails ) |
|
51 | 51 | ); |
52 | 52 | } |
53 | 53 | return $carry; |
54 | 54 | }); |
55 | - return trim($systemInfo); |
|
55 | + return trim( $systemInfo ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | public function getActivePluginDetails() |
62 | 62 | { |
63 | 63 | $plugins = get_plugins(); |
64 | - $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array'); |
|
65 | - $inactive = array_diff_key($plugins, array_flip($activePlugins)); |
|
66 | - return $this->normalizePluginList(array_diff_key($plugins, $inactive)); |
|
64 | + $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' ); |
|
65 | + $inactive = array_diff_key( $plugins, array_flip( $activePlugins ) ); |
|
66 | + return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function getAddonDetails() |
73 | 73 | { |
74 | - $details = apply_filters('site-reviews/addon/system-info', []); |
|
75 | - ksort($details); |
|
74 | + $details = apply_filters( 'site-reviews/addon/system-info', [] ); |
|
75 | + ksort( $details ); |
|
76 | 76 | return $details; |
77 | 77 | } |
78 | 78 | |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | public function getBrowserDetails() |
83 | 83 | { |
84 | 84 | $browser = new Browser(); |
85 | - $name = esc_attr($browser->getName()); |
|
86 | - $userAgent = esc_attr($browser->getUserAgent()->getUserAgentString()); |
|
87 | - $version = esc_attr($browser->getVersion()); |
|
85 | + $name = esc_attr( $browser->getName() ); |
|
86 | + $userAgent = esc_attr( $browser->getUserAgent()->getUserAgentString() ); |
|
87 | + $version = esc_attr( $browser->getVersion() ); |
|
88 | 88 | return [ |
89 | - 'Browser Name' => sprintf('%s %s', $name, $version), |
|
89 | + 'Browser Name' => sprintf( '%s %s', $name, $version ), |
|
90 | 90 | 'Browser UA' => $userAgent, |
91 | 91 | ]; |
92 | 92 | } |
@@ -96,12 +96,12 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function getInactivePluginDetails() |
98 | 98 | { |
99 | - $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array'); |
|
100 | - $inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins))); |
|
99 | + $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' ); |
|
100 | + $inactivePlugins = $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) ); |
|
101 | 101 | $multisitePlugins = $this->getMultisitePluginDetails(); |
102 | 102 | return empty($multisitePlugins) |
103 | 103 | ? $inactivePlugins |
104 | - : array_diff($inactivePlugins, $multisitePlugins); |
|
104 | + : array_diff( $inactivePlugins, $multisitePlugins ); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function getMuPluginDetails() |
111 | 111 | { |
112 | - if (empty($plugins = get_mu_plugins())) { |
|
112 | + if( empty($plugins = get_mu_plugins()) ) { |
|
113 | 113 | return []; |
114 | 114 | } |
115 | - return $this->normalizePluginList($plugins); |
|
115 | + return $this->normalizePluginList( $plugins ); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function getMultisitePluginDetails() |
122 | 122 | { |
123 | - $activePlugins = (array) get_site_option('active_sitewide_plugins', []); |
|
124 | - if (!is_multisite() || empty($activePlugins)) { |
|
123 | + $activePlugins = (array)get_site_option( 'active_sitewide_plugins', [] ); |
|
124 | + if( !is_multisite() || empty($activePlugins) ) { |
|
125 | 125 | return []; |
126 | 126 | } |
127 | - return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins)); |
|
127 | + return $this->normalizePluginList( array_intersect_key( get_plugins(), $activePlugins ) ); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -132,31 +132,31 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function getPhpDetails() |
134 | 134 | { |
135 | - $displayErrors = $this->getINI('display_errors', null) |
|
136 | - ? 'On ('.$this->getINI('display_errors').')' |
|
135 | + $displayErrors = $this->getINI( 'display_errors', null ) |
|
136 | + ? 'On ('.$this->getINI( 'display_errors' ).')' |
|
137 | 137 | : 'N/A'; |
138 | - $intlSupport = extension_loaded('intl') |
|
139 | - ? phpversion('intl') |
|
138 | + $intlSupport = extension_loaded( 'intl' ) |
|
139 | + ? phpversion( 'intl' ) |
|
140 | 140 | : 'false'; |
141 | 141 | return [ |
142 | - 'cURL' => var_export(function_exists('curl_init'), true), |
|
143 | - 'Default Charset' => $this->getINI('default_charset'), |
|
142 | + 'cURL' => var_export( function_exists( 'curl_init' ), true ), |
|
143 | + 'Default Charset' => $this->getINI( 'default_charset' ), |
|
144 | 144 | 'Display Errors' => $displayErrors, |
145 | - 'fsockopen' => var_export(function_exists('fsockopen'), true), |
|
145 | + 'fsockopen' => var_export( function_exists( 'fsockopen' ), true ), |
|
146 | 146 | 'Intl' => $intlSupport, |
147 | - 'IPv6' => var_export(defined('AF_INET6'), true), |
|
148 | - 'Max Execution Time' => $this->getINI('max_execution_time'), |
|
149 | - 'Max Input Nesting Level' => $this->getINI('max_input_nesting_level'), |
|
150 | - 'Max Input Vars' => $this->getINI('max_input_vars'), |
|
151 | - 'Memory Limit' => $this->getINI('memory_limit'), |
|
152 | - 'Post Max Size' => $this->getINI('post_max_size'), |
|
153 | - 'Sendmail Path' => $this->getINI('sendmail_path'), |
|
154 | - 'Session Cookie Path' => esc_html($this->getINI('session.cookie_path')), |
|
155 | - 'Session Name' => esc_html($this->getINI('session.name')), |
|
156 | - 'Session Save Path' => esc_html($this->getINI('session.save_path')), |
|
157 | - 'Session Use Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_cookies', false)), true), |
|
158 | - 'Session Use Only Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_only_cookies', false)), true), |
|
159 | - 'Upload Max Filesize' => $this->getINI('upload_max_filesize'), |
|
147 | + 'IPv6' => var_export( defined( 'AF_INET6' ), true ), |
|
148 | + 'Max Execution Time' => $this->getINI( 'max_execution_time' ), |
|
149 | + 'Max Input Nesting Level' => $this->getINI( 'max_input_nesting_level' ), |
|
150 | + 'Max Input Vars' => $this->getINI( 'max_input_vars' ), |
|
151 | + 'Memory Limit' => $this->getINI( 'memory_limit' ), |
|
152 | + 'Post Max Size' => $this->getINI( 'post_max_size' ), |
|
153 | + 'Sendmail Path' => $this->getINI( 'sendmail_path' ), |
|
154 | + 'Session Cookie Path' => esc_html( $this->getINI( 'session.cookie_path' ) ), |
|
155 | + 'Session Name' => esc_html( $this->getINI( 'session.name' ) ), |
|
156 | + 'Session Save Path' => esc_html( $this->getINI( 'session.save_path' ) ), |
|
157 | + 'Session Use Cookies' => var_export( wp_validate_boolean( $this->getINI( 'session.use_cookies', false ) ), true ), |
|
158 | + 'Session Use Only Cookies' => var_export( wp_validate_boolean( $this->getINI( 'session.use_only_cookies', false ) ), true ), |
|
159 | + 'Upload Max Filesize' => $this->getINI( 'upload_max_filesize' ), |
|
160 | 160 | ]; |
161 | 161 | } |
162 | 162 | |
@@ -165,19 +165,19 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function getReviewsDetails() |
167 | 167 | { |
168 | - $counts = glsr(CountsManager::class)->getCounts(); |
|
169 | - $counts = Arr::flattenArray($counts); |
|
170 | - array_walk($counts, function (&$ratings) use ($counts) { |
|
171 | - if (is_array($ratings)) { |
|
172 | - $ratings = array_sum($ratings).' ('.implode(', ', $ratings).')'; |
|
168 | + $counts = glsr( CountsManager::class )->getCounts(); |
|
169 | + $counts = Arr::flattenArray( $counts ); |
|
170 | + array_walk( $counts, function( &$ratings ) use ($counts) { |
|
171 | + if( is_array( $ratings ) ) { |
|
172 | + $ratings = array_sum( $ratings ).' ('.implode( ', ', $ratings ).')'; |
|
173 | 173 | return; |
174 | 174 | } |
175 | 175 | glsr_log() |
176 | - ->error('$ratings is not an array, possibly due to incorrectly imported reviews.') |
|
177 | - ->debug($ratings) |
|
178 | - ->debug($counts); |
|
176 | + ->error( '$ratings is not an array, possibly due to incorrectly imported reviews.' ) |
|
177 | + ->debug( $ratings ) |
|
178 | + ->debug( $counts ); |
|
179 | 179 | }); |
180 | - ksort($counts); |
|
180 | + ksort( $counts ); |
|
181 | 181 | return $counts; |
182 | 182 | } |
183 | 183 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | 'Host Name' => $this->getHostName(), |
192 | 192 | 'MySQL Version' => $wpdb->db_version(), |
193 | 193 | 'PHP Version' => PHP_VERSION, |
194 | - 'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'), |
|
194 | + 'Server Software' => filter_input( INPUT_SERVER, 'SERVER_SOFTWARE' ), |
|
195 | 195 | ]; |
196 | 196 | } |
197 | 197 | |
@@ -200,16 +200,16 @@ discard block |
||
200 | 200 | */ |
201 | 201 | public function getSettingDetails() |
202 | 202 | { |
203 | - $settings = glsr(OptionManager::class)->get('settings', []); |
|
204 | - $settings = Arr::flattenArray($settings, true); |
|
205 | - $settings = $this->purgeSensitiveData($settings); |
|
206 | - ksort($settings); |
|
203 | + $settings = glsr( OptionManager::class )->get( 'settings', [] ); |
|
204 | + $settings = Arr::flattenArray( $settings, true ); |
|
205 | + $settings = $this->purgeSensitiveData( $settings ); |
|
206 | + ksort( $settings ); |
|
207 | 207 | $details = []; |
208 | - foreach ($settings as $key => $value) { |
|
209 | - if (Str::startsWith('strings', $key) && Str::endsWith('id', $key)) { |
|
208 | + foreach( $settings as $key => $value ) { |
|
209 | + if( Str::startsWith( 'strings', $key ) && Str::endsWith( 'id', $key ) ) { |
|
210 | 210 | continue; |
211 | 211 | } |
212 | - $value = htmlspecialchars(trim(preg_replace('/\s\s+/u', '\\n', $value)), ENT_QUOTES, 'UTF-8'); |
|
212 | + $value = htmlspecialchars( trim( preg_replace( '/\s\s+/u', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' ); |
|
213 | 213 | $details[$key] = $value; |
214 | 214 | } |
215 | 215 | return $details; |
@@ -221,12 +221,12 @@ discard block |
||
221 | 221 | public function getPluginDetails() |
222 | 222 | { |
223 | 223 | return [ |
224 | - 'Console level' => glsr(Console::class)->humanLevel(), |
|
225 | - 'Console size' => glsr(Console::class)->humanSize('0'), |
|
226 | - 'Last Migration Run' => glsr(Date::class)->localized(glsr(OptionManager::class)->get('last_migration_run'), 'unknown'), |
|
227 | - 'Last Rating Count' => glsr(Date::class)->localized(glsr(OptionManager::class)->get('last_review_count'), 'unknown'), |
|
224 | + 'Console level' => glsr( Console::class )->humanLevel(), |
|
225 | + 'Console size' => glsr( Console::class )->humanSize( '0' ), |
|
226 | + 'Last Migration Run' => glsr( Date::class )->localized( glsr( OptionManager::class )->get( 'last_migration_run' ), 'unknown' ), |
|
227 | + 'Last Rating Count' => glsr( Date::class )->localized( glsr( OptionManager::class )->get( 'last_review_count' ), 'unknown' ), |
|
228 | 228 | 'Version (current)' => glsr()->version, |
229 | - 'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'), |
|
229 | + 'Version (previous)' => glsr( OptionManager::class )->get( 'version_upgraded_from' ), |
|
230 | 230 | ]; |
231 | 231 | } |
232 | 232 | |
@@ -238,23 +238,23 @@ discard block |
||
238 | 238 | global $wpdb; |
239 | 239 | $theme = wp_get_theme(); |
240 | 240 | return [ |
241 | - 'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version), |
|
242 | - 'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1), |
|
241 | + 'Active Theme' => sprintf( '%s v%s', (string)$theme->Name, (string)$theme->Version ), |
|
242 | + 'Email Domain' => substr( strrchr( glsr( OptionManager::class )->getWP( 'admin_email' ), '@' ), 1 ), |
|
243 | 243 | 'Home URL' => home_url(), |
244 | 244 | 'Language' => get_locale(), |
245 | 245 | 'Memory Limit' => WP_MEMORY_LIMIT, |
246 | - 'Multisite' => var_export(is_multisite(), true), |
|
247 | - 'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'), |
|
248 | - 'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'), |
|
249 | - 'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'), |
|
250 | - 'Post Stati' => implode(', ', get_post_stati()), |
|
251 | - 'Remote Post' => glsr(Cache::class)->getRemotePostTest(), |
|
252 | - 'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'), |
|
246 | + 'Multisite' => var_export( is_multisite(), true ), |
|
247 | + 'Page For Posts ID' => glsr( OptionManager::class )->getWP( 'page_for_posts' ), |
|
248 | + 'Page On Front ID' => glsr( OptionManager::class )->getWP( 'page_on_front' ), |
|
249 | + 'Permalink Structure' => glsr( OptionManager::class )->getWP( 'permalink_structure', 'default' ), |
|
250 | + 'Post Stati' => implode( ', ', get_post_stati() ), |
|
251 | + 'Remote Post' => glsr( Cache::class )->getRemotePostTest(), |
|
252 | + 'Show On Front' => glsr( OptionManager::class )->getWP( 'show_on_front' ), |
|
253 | 253 | 'Site URL' => site_url(), |
254 | - 'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', $this->getINI('date.timezone').' (PHP)'), |
|
255 | - 'Version' => get_bloginfo('version'), |
|
256 | - 'WP Debug' => var_export(defined('WP_DEBUG'), true), |
|
257 | - 'WP Max Upload Size' => size_format(wp_max_upload_size()), |
|
254 | + 'Timezone' => glsr( OptionManager::class )->getWP( 'timezone_string', $this->getINI( 'date.timezone' ).' (PHP)' ), |
|
255 | + 'Version' => get_bloginfo( 'version' ), |
|
256 | + 'WP Debug' => var_export( defined( 'WP_DEBUG' ), true ), |
|
257 | + 'WP Max Upload Size' => size_format( wp_max_upload_size() ), |
|
258 | 258 | 'WP Memory Limit' => WP_MEMORY_LIMIT, |
259 | 259 | ]; |
260 | 260 | } |
@@ -284,13 +284,13 @@ discard block |
||
284 | 284 | 'secureserver.net' => 'GoDaddy', |
285 | 285 | 'WPE_APIKEY' => 'WP Engine', |
286 | 286 | ]; |
287 | - foreach ($checks as $key => $value) { |
|
288 | - if (!$this->isWebhostCheckValid($key)) { |
|
287 | + foreach( $checks as $key => $value ) { |
|
288 | + if( !$this->isWebhostCheckValid( $key ) ) { |
|
289 | 289 | continue; |
290 | 290 | } |
291 | 291 | return $value; |
292 | 292 | } |
293 | - return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')])); |
|
293 | + return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ) ); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -298,16 +298,16 @@ discard block |
||
298 | 298 | */ |
299 | 299 | protected function getHostName() |
300 | 300 | { |
301 | - return sprintf('%s (%s)', |
|
301 | + return sprintf( '%s (%s)', |
|
302 | 302 | $this->detectWebhostProvider(), |
303 | 303 | Helper::getIpAddress() |
304 | 304 | ); |
305 | 305 | } |
306 | 306 | |
307 | - protected function getINI($name, $disabledValue = 'ini_get() is disabled.') |
|
307 | + protected function getINI( $name, $disabledValue = 'ini_get() is disabled.' ) |
|
308 | 308 | { |
309 | - return function_exists('ini_get') |
|
310 | - ? ini_get($name) |
|
309 | + return function_exists( 'ini_get' ) |
|
310 | + ? ini_get( $name ) |
|
311 | 311 | : $disabledValue; |
312 | 312 | } |
313 | 313 | |
@@ -317,9 +317,9 @@ discard block |
||
317 | 317 | protected function getWordpressPlugins() |
318 | 318 | { |
319 | 319 | $plugins = get_plugins(); |
320 | - $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array'); |
|
321 | - $inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins))); |
|
322 | - $active = $this->normalizePluginList(array_diff_key($plugins, $inactive)); |
|
320 | + $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' ); |
|
321 | + $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) ); |
|
322 | + $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
323 | 323 | return $active + $inactive; |
324 | 324 | } |
325 | 325 | |
@@ -327,48 +327,48 @@ discard block |
||
327 | 327 | * @param string $title |
328 | 328 | * @return string |
329 | 329 | */ |
330 | - protected function implode($title, array $details) |
|
330 | + protected function implode( $title, array $details ) |
|
331 | 331 | { |
332 | 332 | $strings = ['['.$title.']']; |
333 | - $padding = max(array_map('strlen', array_keys($details))); |
|
334 | - $padding = max([$padding, static::PAD]); |
|
335 | - foreach ($details as $key => $value) { |
|
336 | - $strings[] = is_string($key) |
|
337 | - ? sprintf('%s : %s', str_pad($key, $padding, '.'), $value) |
|
333 | + $padding = max( array_map( 'strlen', array_keys( $details ) ) ); |
|
334 | + $padding = max( [$padding, static::PAD] ); |
|
335 | + foreach( $details as $key => $value ) { |
|
336 | + $strings[] = is_string( $key ) |
|
337 | + ? sprintf( '%s : %s', str_pad( $key, $padding, '.' ), $value ) |
|
338 | 338 | : ' - '.$value; |
339 | 339 | } |
340 | - return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL; |
|
340 | + return implode( PHP_EOL, $strings ).PHP_EOL.PHP_EOL; |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
344 | 344 | * @param string $key |
345 | 345 | * @return bool |
346 | 346 | */ |
347 | - protected function isWebhostCheckValid($key) |
|
347 | + protected function isWebhostCheckValid( $key ) |
|
348 | 348 | { |
349 | - return defined($key) |
|
350 | - || filter_input(INPUT_SERVER, $key) |
|
351 | - || Str::contains(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key) |
|
352 | - || Str::contains(DB_HOST, $key) |
|
353 | - || Str::contains(php_uname(), $key); |
|
349 | + return defined( $key ) |
|
350 | + || filter_input( INPUT_SERVER, $key ) |
|
351 | + || Str::contains( filter_input( INPUT_SERVER, 'SERVER_NAME' ), $key ) |
|
352 | + || Str::contains( DB_HOST, $key ) |
|
353 | + || Str::contains( php_uname(), $key ); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
357 | 357 | * @return array |
358 | 358 | */ |
359 | - protected function normalizePluginList(array $plugins) |
|
359 | + protected function normalizePluginList( array $plugins ) |
|
360 | 360 | { |
361 | - $plugins = array_map(function ($plugin) { |
|
362 | - return sprintf('%s v%s', Arr::get($plugin, 'Name'), Arr::get($plugin, 'Version')); |
|
363 | - }, $plugins); |
|
364 | - natcasesort($plugins); |
|
365 | - return array_flip($plugins); |
|
361 | + $plugins = array_map( function( $plugin ) { |
|
362 | + return sprintf( '%s v%s', Arr::get( $plugin, 'Name' ), Arr::get( $plugin, 'Version' ) ); |
|
363 | + }, $plugins ); |
|
364 | + natcasesort( $plugins ); |
|
365 | + return array_flip( $plugins ); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | /** |
369 | 369 | * @return array |
370 | 370 | */ |
371 | - protected function purgeSensitiveData(array $settings) |
|
371 | + protected function purgeSensitiveData( array $settings ) |
|
372 | 372 | { |
373 | 373 | $keys = [ |
374 | 374 | 'general.trustalyze_serial', |
@@ -376,12 +376,12 @@ discard block |
||
376 | 376 | 'submissions.recaptcha.key', |
377 | 377 | 'submissions.recaptcha.secret', |
378 | 378 | ]; |
379 | - array_walk($settings, function (&$value, $setting) use ($keys) { |
|
380 | - foreach ($keys as $key) { |
|
381 | - if (!Str::startsWith($key, $setting) || empty($value)) { |
|
379 | + array_walk( $settings, function( &$value, $setting ) use ($keys) { |
|
380 | + foreach( $keys as $key ) { |
|
381 | + if( !Str::startsWith( $key, $setting ) || empty($value) ) { |
|
382 | 382 | continue; |
383 | 383 | } |
384 | - $value = str_repeat('•', 13); |
|
384 | + $value = str_repeat( '•', 13 ); |
|
385 | 385 | return; |
386 | 386 | } |
387 | 387 | }); |
@@ -7,106 +7,106 @@ |
||
7 | 7 | |
8 | 8 | class Labels |
9 | 9 | { |
10 | - /** |
|
11 | - * @param string $translation |
|
12 | - * @param string $test |
|
13 | - * @return string |
|
14 | - */ |
|
15 | - public function filterPostStatusLabels($translation, $text) |
|
16 | - { |
|
17 | - $replacements = $this->getStatusLabels(); |
|
18 | - return array_key_exists($text, $replacements) |
|
19 | - ? $replacements[$text] |
|
20 | - : $translation; |
|
21 | - } |
|
10 | + /** |
|
11 | + * @param string $translation |
|
12 | + * @param string $test |
|
13 | + * @return string |
|
14 | + */ |
|
15 | + public function filterPostStatusLabels($translation, $text) |
|
16 | + { |
|
17 | + $replacements = $this->getStatusLabels(); |
|
18 | + return array_key_exists($text, $replacements) |
|
19 | + ? $replacements[$text] |
|
20 | + : $translation; |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * @return array |
|
25 | - */ |
|
26 | - public function filterUpdateMessages(array $messages) |
|
27 | - { |
|
28 | - $post = get_post(); |
|
29 | - if (!($post instanceof WP_Post)) { |
|
30 | - return; |
|
31 | - } |
|
32 | - $strings = $this->getReviewLabels(); |
|
33 | - $restored = filter_input(INPUT_GET, 'revision'); |
|
34 | - if ($revisionTitle = wp_post_revision_title(intval($restored), false)) { |
|
35 | - $restored = sprintf($strings['restored'], $revisionTitle); |
|
36 | - } |
|
37 | - $scheduled_date = date_i18n('M j, Y @ H:i', strtotime($post->post_date)); |
|
38 | - $messages[Application::POST_TYPE] = [ |
|
39 | - 1 => $strings['updated'], |
|
40 | - 4 => $strings['updated'], |
|
41 | - 5 => $restored, |
|
42 | - 6 => $strings['published'], |
|
43 | - 7 => $strings['saved'], |
|
44 | - 8 => $strings['submitted'], |
|
45 | - 9 => sprintf($strings['scheduled'], '<strong>'.$scheduled_date.'</strong>'), |
|
46 | - 10 => $strings['draft_updated'], |
|
47 | - 50 => $strings['approved'], |
|
48 | - 51 => $strings['unapproved'], |
|
49 | - 52 => $strings['reverted'], |
|
50 | - ]; |
|
51 | - return $messages; |
|
52 | - } |
|
23 | + /** |
|
24 | + * @return array |
|
25 | + */ |
|
26 | + public function filterUpdateMessages(array $messages) |
|
27 | + { |
|
28 | + $post = get_post(); |
|
29 | + if (!($post instanceof WP_Post)) { |
|
30 | + return; |
|
31 | + } |
|
32 | + $strings = $this->getReviewLabels(); |
|
33 | + $restored = filter_input(INPUT_GET, 'revision'); |
|
34 | + if ($revisionTitle = wp_post_revision_title(intval($restored), false)) { |
|
35 | + $restored = sprintf($strings['restored'], $revisionTitle); |
|
36 | + } |
|
37 | + $scheduled_date = date_i18n('M j, Y @ H:i', strtotime($post->post_date)); |
|
38 | + $messages[Application::POST_TYPE] = [ |
|
39 | + 1 => $strings['updated'], |
|
40 | + 4 => $strings['updated'], |
|
41 | + 5 => $restored, |
|
42 | + 6 => $strings['published'], |
|
43 | + 7 => $strings['saved'], |
|
44 | + 8 => $strings['submitted'], |
|
45 | + 9 => sprintf($strings['scheduled'], '<strong>'.$scheduled_date.'</strong>'), |
|
46 | + 10 => $strings['draft_updated'], |
|
47 | + 50 => $strings['approved'], |
|
48 | + 51 => $strings['unapproved'], |
|
49 | + 52 => $strings['reverted'], |
|
50 | + ]; |
|
51 | + return $messages; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @return void |
|
56 | - */ |
|
57 | - public function translatePostStatusLabels() |
|
58 | - { |
|
59 | - global $wp_scripts; |
|
60 | - $strings = [ |
|
61 | - 'savePending' => __('Save as Unapproved', 'site-reviews'), |
|
62 | - 'published' => __('Approved', 'site-reviews'), |
|
63 | - ]; |
|
64 | - if (isset($wp_scripts->registered['post']->extra['data'])) { |
|
65 | - $l10n = &$wp_scripts->registered['post']->extra['data']; |
|
66 | - foreach ($strings as $search => $replace) { |
|
67 | - $l10n = preg_replace('/("'.$search.'":")([^"]+)/u', '$1'.$replace, $l10n); |
|
68 | - } |
|
69 | - } |
|
70 | - } |
|
54 | + /** |
|
55 | + * @return void |
|
56 | + */ |
|
57 | + public function translatePostStatusLabels() |
|
58 | + { |
|
59 | + global $wp_scripts; |
|
60 | + $strings = [ |
|
61 | + 'savePending' => __('Save as Unapproved', 'site-reviews'), |
|
62 | + 'published' => __('Approved', 'site-reviews'), |
|
63 | + ]; |
|
64 | + if (isset($wp_scripts->registered['post']->extra['data'])) { |
|
65 | + $l10n = &$wp_scripts->registered['post']->extra['data']; |
|
66 | + foreach ($strings as $search => $replace) { |
|
67 | + $l10n = preg_replace('/("'.$search.'":")([^"]+)/u', '$1'.$replace, $l10n); |
|
68 | + } |
|
69 | + } |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @return array |
|
74 | - */ |
|
75 | - protected function getReviewLabels() |
|
76 | - { |
|
77 | - return [ |
|
78 | - 'approved' => __('Review has been approved and published.', 'site-reviews'), |
|
79 | - 'draft_updated' => __('Review draft updated.', 'site-reviews'), |
|
80 | - 'preview' => __('Preview review', 'site-reviews'), |
|
81 | - 'published' => __('Review approved and published.', 'site-reviews'), |
|
82 | - 'restored' => __('Review restored to revision from %s.', 'site-reviews'), |
|
83 | - 'reverted' => __('Review has been reverted to its original submission state (title, content, and submission date).', 'site-reviews'), |
|
84 | - 'saved' => __('Review saved.', 'site-reviews'), |
|
85 | - 'scheduled' => __('Review scheduled for: %s.', 'site-reviews'), |
|
86 | - 'submitted' => __('Review submitted.', 'site-reviews'), |
|
87 | - 'unapproved' => __('Review has been unapproved and is now pending.', 'site-reviews'), |
|
88 | - 'updated' => __('Review updated.', 'site-reviews'), |
|
89 | - 'view' => __('View review', 'site-reviews'), |
|
90 | - ]; |
|
91 | - } |
|
72 | + /** |
|
73 | + * @return array |
|
74 | + */ |
|
75 | + protected function getReviewLabels() |
|
76 | + { |
|
77 | + return [ |
|
78 | + 'approved' => __('Review has been approved and published.', 'site-reviews'), |
|
79 | + 'draft_updated' => __('Review draft updated.', 'site-reviews'), |
|
80 | + 'preview' => __('Preview review', 'site-reviews'), |
|
81 | + 'published' => __('Review approved and published.', 'site-reviews'), |
|
82 | + 'restored' => __('Review restored to revision from %s.', 'site-reviews'), |
|
83 | + 'reverted' => __('Review has been reverted to its original submission state (title, content, and submission date).', 'site-reviews'), |
|
84 | + 'saved' => __('Review saved.', 'site-reviews'), |
|
85 | + 'scheduled' => __('Review scheduled for: %s.', 'site-reviews'), |
|
86 | + 'submitted' => __('Review submitted.', 'site-reviews'), |
|
87 | + 'unapproved' => __('Review has been unapproved and is now pending.', 'site-reviews'), |
|
88 | + 'updated' => __('Review updated.', 'site-reviews'), |
|
89 | + 'view' => __('View review', 'site-reviews'), |
|
90 | + ]; |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * Store the labels to avoid unnecessary loops. |
|
95 | - * @return array |
|
96 | - */ |
|
97 | - protected function getStatusLabels() |
|
98 | - { |
|
99 | - static $labels; |
|
100 | - if (empty($labels)) { |
|
101 | - $labels = [ |
|
102 | - 'Pending' => __('Unapproved', 'site-reviews'), |
|
103 | - 'Pending Review' => __('Unapproved', 'site-reviews'), |
|
104 | - 'Privately Published' => __('Privately Approved', 'site-reviews'), |
|
105 | - 'Publish' => __('Approve', 'site-reviews'), |
|
106 | - 'Published' => __('Approved', 'site-reviews'), |
|
107 | - 'Save as Pending' => __('Save as Unapproved', 'site-reviews'), |
|
108 | - ]; |
|
109 | - } |
|
110 | - return $labels; |
|
111 | - } |
|
93 | + /** |
|
94 | + * Store the labels to avoid unnecessary loops. |
|
95 | + * @return array |
|
96 | + */ |
|
97 | + protected function getStatusLabels() |
|
98 | + { |
|
99 | + static $labels; |
|
100 | + if (empty($labels)) { |
|
101 | + $labels = [ |
|
102 | + 'Pending' => __('Unapproved', 'site-reviews'), |
|
103 | + 'Pending Review' => __('Unapproved', 'site-reviews'), |
|
104 | + 'Privately Published' => __('Privately Approved', 'site-reviews'), |
|
105 | + 'Publish' => __('Approve', 'site-reviews'), |
|
106 | + 'Published' => __('Approved', 'site-reviews'), |
|
107 | + 'Save as Pending' => __('Save as Unapproved', 'site-reviews'), |
|
108 | + ]; |
|
109 | + } |
|
110 | + return $labels; |
|
111 | + } |
|
112 | 112 | } |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | * @param string $test |
13 | 13 | * @return string |
14 | 14 | */ |
15 | - public function filterPostStatusLabels($translation, $text) |
|
15 | + public function filterPostStatusLabels( $translation, $text ) |
|
16 | 16 | { |
17 | 17 | $replacements = $this->getStatusLabels(); |
18 | - return array_key_exists($text, $replacements) |
|
18 | + return array_key_exists( $text, $replacements ) |
|
19 | 19 | ? $replacements[$text] |
20 | 20 | : $translation; |
21 | 21 | } |
@@ -23,18 +23,18 @@ discard block |
||
23 | 23 | /** |
24 | 24 | * @return array |
25 | 25 | */ |
26 | - public function filterUpdateMessages(array $messages) |
|
26 | + public function filterUpdateMessages( array $messages ) |
|
27 | 27 | { |
28 | 28 | $post = get_post(); |
29 | - if (!($post instanceof WP_Post)) { |
|
29 | + if( !($post instanceof WP_Post) ) { |
|
30 | 30 | return; |
31 | 31 | } |
32 | 32 | $strings = $this->getReviewLabels(); |
33 | - $restored = filter_input(INPUT_GET, 'revision'); |
|
34 | - if ($revisionTitle = wp_post_revision_title(intval($restored), false)) { |
|
35 | - $restored = sprintf($strings['restored'], $revisionTitle); |
|
33 | + $restored = filter_input( INPUT_GET, 'revision' ); |
|
34 | + if( $revisionTitle = wp_post_revision_title( intval( $restored ), false ) ) { |
|
35 | + $restored = sprintf( $strings['restored'], $revisionTitle ); |
|
36 | 36 | } |
37 | - $scheduled_date = date_i18n('M j, Y @ H:i', strtotime($post->post_date)); |
|
37 | + $scheduled_date = date_i18n( 'M j, Y @ H:i', strtotime( $post->post_date ) ); |
|
38 | 38 | $messages[Application::POST_TYPE] = [ |
39 | 39 | 1 => $strings['updated'], |
40 | 40 | 4 => $strings['updated'], |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | 6 => $strings['published'], |
43 | 43 | 7 => $strings['saved'], |
44 | 44 | 8 => $strings['submitted'], |
45 | - 9 => sprintf($strings['scheduled'], '<strong>'.$scheduled_date.'</strong>'), |
|
45 | + 9 => sprintf( $strings['scheduled'], '<strong>'.$scheduled_date.'</strong>' ), |
|
46 | 46 | 10 => $strings['draft_updated'], |
47 | 47 | 50 => $strings['approved'], |
48 | 48 | 51 => $strings['unapproved'], |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | { |
59 | 59 | global $wp_scripts; |
60 | 60 | $strings = [ |
61 | - 'savePending' => __('Save as Unapproved', 'site-reviews'), |
|
62 | - 'published' => __('Approved', 'site-reviews'), |
|
61 | + 'savePending' => __( 'Save as Unapproved', 'site-reviews' ), |
|
62 | + 'published' => __( 'Approved', 'site-reviews' ), |
|
63 | 63 | ]; |
64 | - if (isset($wp_scripts->registered['post']->extra['data'])) { |
|
64 | + if( isset($wp_scripts->registered['post']->extra['data']) ) { |
|
65 | 65 | $l10n = &$wp_scripts->registered['post']->extra['data']; |
66 | - foreach ($strings as $search => $replace) { |
|
67 | - $l10n = preg_replace('/("'.$search.'":")([^"]+)/u', '$1'.$replace, $l10n); |
|
66 | + foreach( $strings as $search => $replace ) { |
|
67 | + $l10n = preg_replace( '/("'.$search.'":")([^"]+)/u', '$1'.$replace, $l10n ); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | } |
@@ -75,18 +75,18 @@ discard block |
||
75 | 75 | protected function getReviewLabels() |
76 | 76 | { |
77 | 77 | return [ |
78 | - 'approved' => __('Review has been approved and published.', 'site-reviews'), |
|
79 | - 'draft_updated' => __('Review draft updated.', 'site-reviews'), |
|
80 | - 'preview' => __('Preview review', 'site-reviews'), |
|
81 | - 'published' => __('Review approved and published.', 'site-reviews'), |
|
82 | - 'restored' => __('Review restored to revision from %s.', 'site-reviews'), |
|
83 | - 'reverted' => __('Review has been reverted to its original submission state (title, content, and submission date).', 'site-reviews'), |
|
84 | - 'saved' => __('Review saved.', 'site-reviews'), |
|
85 | - 'scheduled' => __('Review scheduled for: %s.', 'site-reviews'), |
|
86 | - 'submitted' => __('Review submitted.', 'site-reviews'), |
|
87 | - 'unapproved' => __('Review has been unapproved and is now pending.', 'site-reviews'), |
|
88 | - 'updated' => __('Review updated.', 'site-reviews'), |
|
89 | - 'view' => __('View review', 'site-reviews'), |
|
78 | + 'approved' => __( 'Review has been approved and published.', 'site-reviews' ), |
|
79 | + 'draft_updated' => __( 'Review draft updated.', 'site-reviews' ), |
|
80 | + 'preview' => __( 'Preview review', 'site-reviews' ), |
|
81 | + 'published' => __( 'Review approved and published.', 'site-reviews' ), |
|
82 | + 'restored' => __( 'Review restored to revision from %s.', 'site-reviews' ), |
|
83 | + 'reverted' => __( 'Review has been reverted to its original submission state (title, content, and submission date).', 'site-reviews' ), |
|
84 | + 'saved' => __( 'Review saved.', 'site-reviews' ), |
|
85 | + 'scheduled' => __( 'Review scheduled for: %s.', 'site-reviews' ), |
|
86 | + 'submitted' => __( 'Review submitted.', 'site-reviews' ), |
|
87 | + 'unapproved' => __( 'Review has been unapproved and is now pending.', 'site-reviews' ), |
|
88 | + 'updated' => __( 'Review updated.', 'site-reviews' ), |
|
89 | + 'view' => __( 'View review', 'site-reviews' ), |
|
90 | 90 | ]; |
91 | 91 | } |
92 | 92 | |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | protected function getStatusLabels() |
98 | 98 | { |
99 | 99 | static $labels; |
100 | - if (empty($labels)) { |
|
100 | + if( empty($labels) ) { |
|
101 | 101 | $labels = [ |
102 | - 'Pending' => __('Unapproved', 'site-reviews'), |
|
103 | - 'Pending Review' => __('Unapproved', 'site-reviews'), |
|
104 | - 'Privately Published' => __('Privately Approved', 'site-reviews'), |
|
105 | - 'Publish' => __('Approve', 'site-reviews'), |
|
106 | - 'Published' => __('Approved', 'site-reviews'), |
|
107 | - 'Save as Pending' => __('Save as Unapproved', 'site-reviews'), |
|
102 | + 'Pending' => __( 'Unapproved', 'site-reviews' ), |
|
103 | + 'Pending Review' => __( 'Unapproved', 'site-reviews' ), |
|
104 | + 'Privately Published' => __( 'Privately Approved', 'site-reviews' ), |
|
105 | + 'Publish' => __( 'Approve', 'site-reviews' ), |
|
106 | + 'Published' => __( 'Approved', 'site-reviews' ), |
|
107 | + 'Save as Pending' => __( 'Save as Unapproved', 'site-reviews' ), |
|
108 | 108 | ]; |
109 | 109 | } |
110 | 110 | return $labels; |
@@ -7,115 +7,115 @@ |
||
7 | 7 | |
8 | 8 | class SiteReviewsFormBlock extends BlockGenerator |
9 | 9 | { |
10 | - /** |
|
11 | - * @return array |
|
12 | - */ |
|
13 | - public function attributes() |
|
14 | - { |
|
15 | - return [ |
|
16 | - 'assign_to' => [ |
|
17 | - 'default' => '', |
|
18 | - 'type' => 'string', |
|
19 | - ], |
|
20 | - 'category' => [ |
|
21 | - 'default' => '', |
|
22 | - 'type' => 'string', |
|
23 | - ], |
|
24 | - 'className' => [ |
|
25 | - 'default' => '', |
|
26 | - 'type' => 'string', |
|
27 | - ], |
|
28 | - 'hide' => [ |
|
29 | - 'default' => '', |
|
30 | - 'type' => 'string', |
|
31 | - ], |
|
32 | - 'id' => [ |
|
33 | - 'default' => '', |
|
34 | - 'type' => 'string', |
|
35 | - ], |
|
36 | - ]; |
|
37 | - } |
|
10 | + /** |
|
11 | + * @return array |
|
12 | + */ |
|
13 | + public function attributes() |
|
14 | + { |
|
15 | + return [ |
|
16 | + 'assign_to' => [ |
|
17 | + 'default' => '', |
|
18 | + 'type' => 'string', |
|
19 | + ], |
|
20 | + 'category' => [ |
|
21 | + 'default' => '', |
|
22 | + 'type' => 'string', |
|
23 | + ], |
|
24 | + 'className' => [ |
|
25 | + 'default' => '', |
|
26 | + 'type' => 'string', |
|
27 | + ], |
|
28 | + 'hide' => [ |
|
29 | + 'default' => '', |
|
30 | + 'type' => 'string', |
|
31 | + ], |
|
32 | + 'id' => [ |
|
33 | + 'default' => '', |
|
34 | + 'type' => 'string', |
|
35 | + ], |
|
36 | + ]; |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - public function render(array $attributes) |
|
43 | - { |
|
44 | - $attributes['class'] = $attributes['className']; |
|
45 | - $shortcode = glsr(Shortcode::class); |
|
46 | - if ('edit' == filter_input(INPUT_GET, 'context')) { |
|
47 | - $this->filterFormFields(); |
|
48 | - $this->filterRatingField(); |
|
49 | - $this->filterShortcodeClass(); |
|
50 | - $this->filterSubmitButton(); |
|
51 | - if (!$this->hasVisibleFields($shortcode, $attributes)) { |
|
52 | - $this->filterInterpolation(); |
|
53 | - } |
|
54 | - } |
|
55 | - return $shortcode->buildShortcode($attributes); |
|
56 | - } |
|
39 | + /** |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + public function render(array $attributes) |
|
43 | + { |
|
44 | + $attributes['class'] = $attributes['className']; |
|
45 | + $shortcode = glsr(Shortcode::class); |
|
46 | + if ('edit' == filter_input(INPUT_GET, 'context')) { |
|
47 | + $this->filterFormFields(); |
|
48 | + $this->filterRatingField(); |
|
49 | + $this->filterShortcodeClass(); |
|
50 | + $this->filterSubmitButton(); |
|
51 | + if (!$this->hasVisibleFields($shortcode, $attributes)) { |
|
52 | + $this->filterInterpolation(); |
|
53 | + } |
|
54 | + } |
|
55 | + return $shortcode->buildShortcode($attributes); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @return void |
|
60 | - */ |
|
61 | - protected function filterFormFields() |
|
62 | - { |
|
63 | - add_filter('site-reviews/config/forms/submission-form', function (array $config) { |
|
64 | - array_walk($config, function (&$field) { |
|
65 | - $field['disabled'] = true; |
|
66 | - $field['tabindex'] = '-1'; |
|
67 | - }); |
|
68 | - return $config; |
|
69 | - }); |
|
70 | - } |
|
58 | + /** |
|
59 | + * @return void |
|
60 | + */ |
|
61 | + protected function filterFormFields() |
|
62 | + { |
|
63 | + add_filter('site-reviews/config/forms/submission-form', function (array $config) { |
|
64 | + array_walk($config, function (&$field) { |
|
65 | + $field['disabled'] = true; |
|
66 | + $field['tabindex'] = '-1'; |
|
67 | + }); |
|
68 | + return $config; |
|
69 | + }); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @return void |
|
74 | - */ |
|
75 | - protected function filterInterpolation() |
|
76 | - { |
|
77 | - add_filter('site-reviews/interpolate/reviews-form', function ($context) { |
|
78 | - $context['class'] = 'glsr-default glsr-block-disabled'; |
|
79 | - $context['fields'] = __('You have hidden all of the fields for this block.', 'site-reviews'); |
|
80 | - $context['response'] = ''; |
|
81 | - $context['submit_button'] = ''; |
|
82 | - return $context; |
|
83 | - }); |
|
84 | - } |
|
72 | + /** |
|
73 | + * @return void |
|
74 | + */ |
|
75 | + protected function filterInterpolation() |
|
76 | + { |
|
77 | + add_filter('site-reviews/interpolate/reviews-form', function ($context) { |
|
78 | + $context['class'] = 'glsr-default glsr-block-disabled'; |
|
79 | + $context['fields'] = __('You have hidden all of the fields for this block.', 'site-reviews'); |
|
80 | + $context['response'] = ''; |
|
81 | + $context['submit_button'] = ''; |
|
82 | + return $context; |
|
83 | + }); |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * @return void |
|
88 | - */ |
|
89 | - protected function filterRatingField() |
|
90 | - { |
|
91 | - add_filter('site-reviews/rendered/field', function ($html, $type, $args) { |
|
92 | - if ('rating' == $args['path']) { |
|
93 | - $stars = '<span class="glsr-stars">'; |
|
94 | - $stars.= str_repeat('<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int) glsr()->constant('MAX_RATING', Rating::class)); |
|
95 | - $stars.= '</span>'; |
|
96 | - $html = preg_replace('/(.*)(<select.*)(<\/select>)(.*)/u', '$1'.$stars.'$4', $html); |
|
97 | - } |
|
98 | - return $html; |
|
99 | - }, 10, 3); |
|
100 | - } |
|
86 | + /** |
|
87 | + * @return void |
|
88 | + */ |
|
89 | + protected function filterRatingField() |
|
90 | + { |
|
91 | + add_filter('site-reviews/rendered/field', function ($html, $type, $args) { |
|
92 | + if ('rating' == $args['path']) { |
|
93 | + $stars = '<span class="glsr-stars">'; |
|
94 | + $stars.= str_repeat('<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int) glsr()->constant('MAX_RATING', Rating::class)); |
|
95 | + $stars.= '</span>'; |
|
96 | + $html = preg_replace('/(.*)(<select.*)(<\/select>)(.*)/u', '$1'.$stars.'$4', $html); |
|
97 | + } |
|
98 | + return $html; |
|
99 | + }, 10, 3); |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * @return void |
|
104 | - */ |
|
105 | - protected function filterShortcodeClass() |
|
106 | - { |
|
107 | - add_filter('site-reviews/style', function () { |
|
108 | - return 'default'; |
|
109 | - }); |
|
110 | - } |
|
102 | + /** |
|
103 | + * @return void |
|
104 | + */ |
|
105 | + protected function filterShortcodeClass() |
|
106 | + { |
|
107 | + add_filter('site-reviews/style', function () { |
|
108 | + return 'default'; |
|
109 | + }); |
|
110 | + } |
|
111 | 111 | |
112 | - /** |
|
113 | - * @return void |
|
114 | - */ |
|
115 | - protected function filterSubmitButton() |
|
116 | - { |
|
117 | - add_filter('site-reviews/rendered/template/form/submit-button', function ($template) { |
|
118 | - return str_replace('type="submit"', 'tabindex="-1"', $template); |
|
119 | - }); |
|
120 | - } |
|
112 | + /** |
|
113 | + * @return void |
|
114 | + */ |
|
115 | + protected function filterSubmitButton() |
|
116 | + { |
|
117 | + add_filter('site-reviews/rendered/template/form/submit-button', function ($template) { |
|
118 | + return str_replace('type="submit"', 'tabindex="-1"', $template); |
|
119 | + }); |
|
120 | + } |
|
121 | 121 | } |
@@ -39,20 +39,20 @@ discard block |
||
39 | 39 | /** |
40 | 40 | * @return string |
41 | 41 | */ |
42 | - public function render(array $attributes) |
|
42 | + public function render( array $attributes ) |
|
43 | 43 | { |
44 | 44 | $attributes['class'] = $attributes['className']; |
45 | - $shortcode = glsr(Shortcode::class); |
|
46 | - if ('edit' == filter_input(INPUT_GET, 'context')) { |
|
45 | + $shortcode = glsr( Shortcode::class ); |
|
46 | + if( 'edit' == filter_input( INPUT_GET, 'context' ) ) { |
|
47 | 47 | $this->filterFormFields(); |
48 | 48 | $this->filterRatingField(); |
49 | 49 | $this->filterShortcodeClass(); |
50 | 50 | $this->filterSubmitButton(); |
51 | - if (!$this->hasVisibleFields($shortcode, $attributes)) { |
|
51 | + if( !$this->hasVisibleFields( $shortcode, $attributes ) ) { |
|
52 | 52 | $this->filterInterpolation(); |
53 | 53 | } |
54 | 54 | } |
55 | - return $shortcode->buildShortcode($attributes); |
|
55 | + return $shortcode->buildShortcode( $attributes ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | */ |
61 | 61 | protected function filterFormFields() |
62 | 62 | { |
63 | - add_filter('site-reviews/config/forms/submission-form', function (array $config) { |
|
64 | - array_walk($config, function (&$field) { |
|
63 | + add_filter( 'site-reviews/config/forms/submission-form', function( array $config ) { |
|
64 | + array_walk( $config, function( &$field ) { |
|
65 | 65 | $field['disabled'] = true; |
66 | 66 | $field['tabindex'] = '-1'; |
67 | 67 | }); |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | */ |
75 | 75 | protected function filterInterpolation() |
76 | 76 | { |
77 | - add_filter('site-reviews/interpolate/reviews-form', function ($context) { |
|
77 | + add_filter( 'site-reviews/interpolate/reviews-form', function( $context ) { |
|
78 | 78 | $context['class'] = 'glsr-default glsr-block-disabled'; |
79 | - $context['fields'] = __('You have hidden all of the fields for this block.', 'site-reviews'); |
|
79 | + $context['fields'] = __( 'You have hidden all of the fields for this block.', 'site-reviews' ); |
|
80 | 80 | $context['response'] = ''; |
81 | 81 | $context['submit_button'] = ''; |
82 | 82 | return $context; |
@@ -88,15 +88,15 @@ discard block |
||
88 | 88 | */ |
89 | 89 | protected function filterRatingField() |
90 | 90 | { |
91 | - add_filter('site-reviews/rendered/field', function ($html, $type, $args) { |
|
92 | - if ('rating' == $args['path']) { |
|
91 | + add_filter( 'site-reviews/rendered/field', function( $html, $type, $args ) { |
|
92 | + if( 'rating' == $args['path'] ) { |
|
93 | 93 | $stars = '<span class="glsr-stars">'; |
94 | - $stars.= str_repeat('<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int) glsr()->constant('MAX_RATING', Rating::class)); |
|
95 | - $stars.= '</span>'; |
|
96 | - $html = preg_replace('/(.*)(<select.*)(<\/select>)(.*)/u', '$1'.$stars.'$4', $html); |
|
94 | + $stars .= str_repeat( '<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int)glsr()->constant( 'MAX_RATING', Rating::class ) ); |
|
95 | + $stars .= '</span>'; |
|
96 | + $html = preg_replace( '/(.*)(<select.*)(<\/select>)(.*)/u', '$1'.$stars.'$4', $html ); |
|
97 | 97 | } |
98 | 98 | return $html; |
99 | - }, 10, 3); |
|
99 | + }, 10, 3 ); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | protected function filterShortcodeClass() |
106 | 106 | { |
107 | - add_filter('site-reviews/style', function () { |
|
107 | + add_filter( 'site-reviews/style', function() { |
|
108 | 108 | return 'default'; |
109 | 109 | }); |
110 | 110 | } |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | */ |
115 | 115 | protected function filterSubmitButton() |
116 | 116 | { |
117 | - add_filter('site-reviews/rendered/template/form/submit-button', function ($template) { |
|
118 | - return str_replace('type="submit"', 'tabindex="-1"', $template); |
|
117 | + add_filter( 'site-reviews/rendered/template/form/submit-button', function( $template ) { |
|
118 | + return str_replace( 'type="submit"', 'tabindex="-1"', $template ); |
|
119 | 119 | }); |
120 | 120 | } |
121 | 121 | } |
@@ -6,124 +6,124 @@ |
||
6 | 6 | |
7 | 7 | class SiteReviewsBlock extends BlockGenerator |
8 | 8 | { |
9 | - /** |
|
10 | - * @return array |
|
11 | - */ |
|
12 | - public function attributes() |
|
13 | - { |
|
14 | - return [ |
|
15 | - 'assigned_to' => [ |
|
16 | - 'default' => '', |
|
17 | - 'type' => 'string', |
|
18 | - ], |
|
19 | - 'category' => [ |
|
20 | - 'default' => '', |
|
21 | - 'type' => 'string', |
|
22 | - ], |
|
23 | - 'className' => [ |
|
24 | - 'default' => '', |
|
25 | - 'type' => 'string', |
|
26 | - ], |
|
27 | - 'display' => [ |
|
28 | - 'default' => 5, |
|
29 | - 'type' => 'number', |
|
30 | - ], |
|
31 | - 'hide' => [ |
|
32 | - 'default' => '', |
|
33 | - 'type' => 'string', |
|
34 | - ], |
|
35 | - 'id' => [ |
|
36 | - 'default' => '', |
|
37 | - 'type' => 'string', |
|
38 | - ], |
|
39 | - 'pagination' => [ |
|
40 | - 'default' => '', |
|
41 | - 'type' => 'string', |
|
42 | - ], |
|
43 | - 'post_id' => [ |
|
44 | - 'default' => '', |
|
45 | - 'type' => 'string', |
|
46 | - ], |
|
47 | - 'rating' => [ |
|
48 | - 'default' => 0, |
|
49 | - 'type' => 'number', |
|
50 | - ], |
|
51 | - 'schema' => [ |
|
52 | - 'default' => false, |
|
53 | - 'type' => 'boolean', |
|
54 | - ], |
|
55 | - 'type' => [ |
|
56 | - 'default' => 'local', |
|
57 | - 'type' => 'string', |
|
58 | - ], |
|
59 | - ]; |
|
60 | - } |
|
9 | + /** |
|
10 | + * @return array |
|
11 | + */ |
|
12 | + public function attributes() |
|
13 | + { |
|
14 | + return [ |
|
15 | + 'assigned_to' => [ |
|
16 | + 'default' => '', |
|
17 | + 'type' => 'string', |
|
18 | + ], |
|
19 | + 'category' => [ |
|
20 | + 'default' => '', |
|
21 | + 'type' => 'string', |
|
22 | + ], |
|
23 | + 'className' => [ |
|
24 | + 'default' => '', |
|
25 | + 'type' => 'string', |
|
26 | + ], |
|
27 | + 'display' => [ |
|
28 | + 'default' => 5, |
|
29 | + 'type' => 'number', |
|
30 | + ], |
|
31 | + 'hide' => [ |
|
32 | + 'default' => '', |
|
33 | + 'type' => 'string', |
|
34 | + ], |
|
35 | + 'id' => [ |
|
36 | + 'default' => '', |
|
37 | + 'type' => 'string', |
|
38 | + ], |
|
39 | + 'pagination' => [ |
|
40 | + 'default' => '', |
|
41 | + 'type' => 'string', |
|
42 | + ], |
|
43 | + 'post_id' => [ |
|
44 | + 'default' => '', |
|
45 | + 'type' => 'string', |
|
46 | + ], |
|
47 | + 'rating' => [ |
|
48 | + 'default' => 0, |
|
49 | + 'type' => 'number', |
|
50 | + ], |
|
51 | + 'schema' => [ |
|
52 | + 'default' => false, |
|
53 | + 'type' => 'boolean', |
|
54 | + ], |
|
55 | + 'type' => [ |
|
56 | + 'default' => 'local', |
|
57 | + 'type' => 'string', |
|
58 | + ], |
|
59 | + ]; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @return string |
|
64 | - */ |
|
65 | - public function render(array $attributes) |
|
66 | - { |
|
67 | - $attributes['class'] = $attributes['className']; |
|
68 | - $shortcode = glsr(Shortcode::class); |
|
69 | - if ('edit' == filter_input(INPUT_GET, 'context')) { |
|
70 | - $attributes = $this->normalize($attributes); |
|
71 | - $this->filterReviewLinks(); |
|
72 | - $this->filterShortcodeClass(); |
|
73 | - $this->filterShowMoreLinks('content'); |
|
74 | - $this->filterShowMoreLinks('response'); |
|
75 | - if (!$this->hasVisibleFields($shortcode, $attributes)) { |
|
76 | - $this->filterInterpolation(); |
|
77 | - } |
|
78 | - } |
|
79 | - return $shortcode->buildShortcode($attributes); |
|
80 | - } |
|
62 | + /** |
|
63 | + * @return string |
|
64 | + */ |
|
65 | + public function render(array $attributes) |
|
66 | + { |
|
67 | + $attributes['class'] = $attributes['className']; |
|
68 | + $shortcode = glsr(Shortcode::class); |
|
69 | + if ('edit' == filter_input(INPUT_GET, 'context')) { |
|
70 | + $attributes = $this->normalize($attributes); |
|
71 | + $this->filterReviewLinks(); |
|
72 | + $this->filterShortcodeClass(); |
|
73 | + $this->filterShowMoreLinks('content'); |
|
74 | + $this->filterShowMoreLinks('response'); |
|
75 | + if (!$this->hasVisibleFields($shortcode, $attributes)) { |
|
76 | + $this->filterInterpolation(); |
|
77 | + } |
|
78 | + } |
|
79 | + return $shortcode->buildShortcode($attributes); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @return void |
|
84 | - */ |
|
85 | - protected function filterInterpolation() |
|
86 | - { |
|
87 | - add_filter('site-reviews/interpolate/reviews', function ($context) { |
|
88 | - $context['class'] = 'glsr-default glsr-block-disabled'; |
|
89 | - $context['reviews'] = __('You have hidden all of the fields for this block.', 'site-reviews'); |
|
90 | - return $context; |
|
91 | - }); |
|
92 | - } |
|
82 | + /** |
|
83 | + * @return void |
|
84 | + */ |
|
85 | + protected function filterInterpolation() |
|
86 | + { |
|
87 | + add_filter('site-reviews/interpolate/reviews', function ($context) { |
|
88 | + $context['class'] = 'glsr-default glsr-block-disabled'; |
|
89 | + $context['reviews'] = __('You have hidden all of the fields for this block.', 'site-reviews'); |
|
90 | + return $context; |
|
91 | + }); |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * @return void |
|
96 | - */ |
|
97 | - protected function filterReviewLinks() |
|
98 | - { |
|
99 | - add_filter('site-reviews/rendered/template/reviews', function ($template) { |
|
100 | - return str_replace('<a', '<a tabindex="-1"', $template); |
|
101 | - }); |
|
102 | - } |
|
94 | + /** |
|
95 | + * @return void |
|
96 | + */ |
|
97 | + protected function filterReviewLinks() |
|
98 | + { |
|
99 | + add_filter('site-reviews/rendered/template/reviews', function ($template) { |
|
100 | + return str_replace('<a', '<a tabindex="-1"', $template); |
|
101 | + }); |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * @return void |
|
106 | - */ |
|
107 | - protected function filterShortcodeClass() |
|
108 | - { |
|
109 | - add_filter('site-reviews/style', function () { |
|
110 | - return 'default'; |
|
111 | - }); |
|
112 | - } |
|
104 | + /** |
|
105 | + * @return void |
|
106 | + */ |
|
107 | + protected function filterShortcodeClass() |
|
108 | + { |
|
109 | + add_filter('site-reviews/style', function () { |
|
110 | + return 'default'; |
|
111 | + }); |
|
112 | + } |
|
113 | 113 | |
114 | - /** |
|
115 | - * @param string $field |
|
116 | - * @return void |
|
117 | - */ |
|
118 | - protected function filterShowMoreLinks($field) |
|
119 | - { |
|
120 | - add_filter('site-reviews/review/wrap/'.$field, function ($value) { |
|
121 | - $value = preg_replace( |
|
122 | - '/(.*)(<span class="glsr-hidden)(.*)(<\/span>)(.*)/us', |
|
123 | - '$1... <a href="#" class="glsr-read-more" tabindex="-1">'.__('Show more', 'site-reviews').'</a>$5', |
|
124 | - $value |
|
125 | - ); |
|
126 | - return $value; |
|
127 | - }); |
|
128 | - } |
|
114 | + /** |
|
115 | + * @param string $field |
|
116 | + * @return void |
|
117 | + */ |
|
118 | + protected function filterShowMoreLinks($field) |
|
119 | + { |
|
120 | + add_filter('site-reviews/review/wrap/'.$field, function ($value) { |
|
121 | + $value = preg_replace( |
|
122 | + '/(.*)(<span class="glsr-hidden)(.*)(<\/span>)(.*)/us', |
|
123 | + '$1... <a href="#" class="glsr-read-more" tabindex="-1">'.__('Show more', 'site-reviews').'</a>$5', |
|
124 | + $value |
|
125 | + ); |
|
126 | + return $value; |
|
127 | + }); |
|
128 | + } |
|
129 | 129 | } |
@@ -62,21 +62,21 @@ discard block |
||
62 | 62 | /** |
63 | 63 | * @return string |
64 | 64 | */ |
65 | - public function render(array $attributes) |
|
65 | + public function render( array $attributes ) |
|
66 | 66 | { |
67 | 67 | $attributes['class'] = $attributes['className']; |
68 | - $shortcode = glsr(Shortcode::class); |
|
69 | - if ('edit' == filter_input(INPUT_GET, 'context')) { |
|
70 | - $attributes = $this->normalize($attributes); |
|
68 | + $shortcode = glsr( Shortcode::class ); |
|
69 | + if( 'edit' == filter_input( INPUT_GET, 'context' ) ) { |
|
70 | + $attributes = $this->normalize( $attributes ); |
|
71 | 71 | $this->filterReviewLinks(); |
72 | 72 | $this->filterShortcodeClass(); |
73 | - $this->filterShowMoreLinks('content'); |
|
74 | - $this->filterShowMoreLinks('response'); |
|
75 | - if (!$this->hasVisibleFields($shortcode, $attributes)) { |
|
73 | + $this->filterShowMoreLinks( 'content' ); |
|
74 | + $this->filterShowMoreLinks( 'response' ); |
|
75 | + if( !$this->hasVisibleFields( $shortcode, $attributes ) ) { |
|
76 | 76 | $this->filterInterpolation(); |
77 | 77 | } |
78 | 78 | } |
79 | - return $shortcode->buildShortcode($attributes); |
|
79 | + return $shortcode->buildShortcode( $attributes ); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | */ |
85 | 85 | protected function filterInterpolation() |
86 | 86 | { |
87 | - add_filter('site-reviews/interpolate/reviews', function ($context) { |
|
87 | + add_filter( 'site-reviews/interpolate/reviews', function( $context ) { |
|
88 | 88 | $context['class'] = 'glsr-default glsr-block-disabled'; |
89 | - $context['reviews'] = __('You have hidden all of the fields for this block.', 'site-reviews'); |
|
89 | + $context['reviews'] = __( 'You have hidden all of the fields for this block.', 'site-reviews' ); |
|
90 | 90 | return $context; |
91 | 91 | }); |
92 | 92 | } |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | */ |
97 | 97 | protected function filterReviewLinks() |
98 | 98 | { |
99 | - add_filter('site-reviews/rendered/template/reviews', function ($template) { |
|
100 | - return str_replace('<a', '<a tabindex="-1"', $template); |
|
99 | + add_filter( 'site-reviews/rendered/template/reviews', function( $template ) { |
|
100 | + return str_replace( '<a', '<a tabindex="-1"', $template ); |
|
101 | 101 | }); |
102 | 102 | } |
103 | 103 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | protected function filterShortcodeClass() |
108 | 108 | { |
109 | - add_filter('site-reviews/style', function () { |
|
109 | + add_filter( 'site-reviews/style', function() { |
|
110 | 110 | return 'default'; |
111 | 111 | }); |
112 | 112 | } |
@@ -115,12 +115,12 @@ discard block |
||
115 | 115 | * @param string $field |
116 | 116 | * @return void |
117 | 117 | */ |
118 | - protected function filterShowMoreLinks($field) |
|
118 | + protected function filterShowMoreLinks( $field ) |
|
119 | 119 | { |
120 | - add_filter('site-reviews/review/wrap/'.$field, function ($value) { |
|
120 | + add_filter( 'site-reviews/review/wrap/'.$field, function( $value ) { |
|
121 | 121 | $value = preg_replace( |
122 | 122 | '/(.*)(<span class="glsr-hidden)(.*)(<\/span>)(.*)/us', |
123 | - '$1... <a href="#" class="glsr-read-more" tabindex="-1">'.__('Show more', 'site-reviews').'</a>$5', |
|
123 | + '$1... <a href="#" class="glsr-read-more" tabindex="-1">'.__( 'Show more', 'site-reviews' ).'</a>$5', |
|
124 | 124 | $value |
125 | 125 | ); |
126 | 126 | return $value; |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <div class="notice is-dismissible glsr-notice" data-dismiss="trustalyze"> |
2 | 2 | <div class="glsr-notice-icon"> |
3 | - <img width="96" height="96" src="<?= glsr()->url('assets/images/trustalyze-badge.png'); ?>"> |
|
3 | + <img width="96" height="96" src="<?= glsr()->url( 'assets/images/trustalyze-badge.png' ); ?>"> |
|
4 | 4 | </div> |
5 | 5 | <div class="glsr-notice-content"> |
6 | 6 | <h3>Validate Your Reviews on the Blockchain With the Trustalyze Confidence System</h3> |
7 | 7 | <p>Site Reviews integrates with the <a href="https://trustalyze.com/plans?ref=105">Trustalyze Confidence System</a>, a service which uses blockchain technology to verify to your visitors and customers that your reviews are authentic.</p> |
8 | - <a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general'); ?>" class="button">Enable the integration</a> |
|
8 | + <a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general' ); ?>" class="button">Enable the integration</a> |
|
9 | 9 | </div> |
10 | 10 | </div> |
@@ -12,210 +12,210 @@ |
||
12 | 12 | |
13 | 13 | class TrustalyzeController extends Controller |
14 | 14 | { |
15 | - protected $apiKey = 'settings.general.trustalyze_serial'; |
|
16 | - protected $emailKey = 'settings.general.trustalyze_email'; |
|
17 | - protected $enabledKey = 'settings.general.trustalyze'; |
|
18 | - protected $trustalyzeKey = '_glsr_trustalyze'; |
|
19 | - |
|
20 | - /** |
|
21 | - * @return array |
|
22 | - * @filter site-reviews/settings/callback |
|
23 | - */ |
|
24 | - public function filterSettingsCallback(array $settings) |
|
25 | - { |
|
26 | - if ('yes' !== Arr::get($settings, $this->enabledKey)) { |
|
27 | - return $settings; |
|
28 | - } |
|
29 | - $isApiKeyModified = $this->isEmptyOrModified($this->apiKey, $settings); |
|
30 | - $isEmailModified = $this->isEmptyOrModified($this->emailKey, $settings); |
|
31 | - $isAccountVerified = glsr(OptionManager::class)->getWP($this->trustalyzeKey, false); |
|
32 | - if (!$isAccountVerified || $isApiKeyModified || $isEmailModified) { |
|
33 | - $settings = $this->sanitizeTrustalyzeSettings($settings); |
|
34 | - } |
|
35 | - return $settings; |
|
36 | - } |
|
37 | - |
|
38 | - /** |
|
39 | - * @param string $template |
|
40 | - * @return array |
|
41 | - * @filter site-reviews/interpolate/partials/form/table-row-multiple |
|
42 | - */ |
|
43 | - public function filterSettingsTableRow(array $context, $template, array $data) |
|
44 | - { |
|
45 | - if ($this->enabledKey !== Arr::get($data, 'field.path')) { |
|
46 | - return $context; |
|
47 | - } |
|
48 | - $isAccountValidated = !empty(glsr(OptionManager::class)->getWP($this->trustalyzeKey)); |
|
49 | - $isIntegrationEnabled = glsr(OptionManager::class)->getBool('settings.general.trustalyze'); |
|
50 | - if ($isAccountValidated && $isIntegrationEnabled) { |
|
51 | - return $context; |
|
52 | - } |
|
53 | - $context['field'].= $this->buildCreateButton(); |
|
54 | - return $context; |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * Triggered when a review is created. |
|
59 | - * @return void |
|
60 | - * @action site-reviews/review/created |
|
61 | - */ |
|
62 | - public function onCreated(Review $review) |
|
63 | - { |
|
64 | - if (!$this->canPostReview($review)) { |
|
65 | - return; |
|
66 | - } |
|
67 | - $trustalyze = glsr(Trustalyze::class)->sendReview($review); |
|
68 | - if ($trustalyze->success) { |
|
69 | - glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id); |
|
70 | - } |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * Triggered when a review is reverted to its original title/content/date_timestamp. |
|
75 | - * @return void |
|
76 | - * @action site-reviews/review/reverted |
|
77 | - */ |
|
78 | - public function onReverted(Review $review) |
|
79 | - { |
|
80 | - if (!$this->canPostReview($review)) { |
|
81 | - return; |
|
82 | - } |
|
83 | - $trustalyze = glsr(Trustalyze::class)->sendReview($review); |
|
84 | - if ($trustalyze->success) { |
|
85 | - glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id); |
|
86 | - } |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * Triggered when an existing review is updated. |
|
91 | - * @return void |
|
92 | - * @action site-reviews/review/saved |
|
93 | - */ |
|
94 | - public function onSaved(Review $review) |
|
95 | - { |
|
96 | - if (!$this->canPostReview($review)) { |
|
97 | - return; |
|
98 | - } |
|
99 | - $trustalyze = glsr(Trustalyze::class)->sendReview($review); |
|
100 | - if ($trustalyze->success) { |
|
101 | - glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id); |
|
102 | - } |
|
103 | - } |
|
104 | - |
|
105 | - /** |
|
106 | - * Triggered when a review's response is added or updated. |
|
107 | - * @param int $metaId |
|
108 | - * @param int $postId |
|
109 | - * @param string $metaKey |
|
110 | - * @return void |
|
111 | - * @action updated_postmeta |
|
112 | - */ |
|
113 | - public function onUpdatedMeta($metaId, $postId, $metaKey) |
|
114 | - { |
|
115 | - $review = glsr_get_review($postId); |
|
116 | - if (!$this->canPostResponse($review) || '_response' !== $metaKey) { |
|
117 | - return; |
|
118 | - } |
|
119 | - $trustalyze = glsr(Trustalyze::class)->sendReviewResponse($review); |
|
120 | - if ($trustalyze->success) { |
|
121 | - glsr(Database::class)->set($review->ID, 'trustalyze_response', true); |
|
122 | - } |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * @return string |
|
127 | - */ |
|
128 | - protected function buildCreateButton() |
|
129 | - { |
|
130 | - return glsr(Builder::class)->a(__('Create Your Trustalyze Account', 'site-reviews'), [ |
|
131 | - 'class' => 'button', |
|
132 | - 'href' => Trustalyze::WEB_URL, |
|
133 | - 'target' => '_blank', |
|
134 | - ]); |
|
135 | - } |
|
136 | - |
|
137 | - /** |
|
138 | - * @return bool |
|
139 | - */ |
|
140 | - protected function canPostResponse(Review $review) |
|
141 | - { |
|
142 | - $requiredValues = [ |
|
143 | - glsr(Database::class)->get($review->ID, 'trustalyze'), |
|
144 | - $review->response, |
|
145 | - $review->review_id, |
|
146 | - ]; |
|
147 | - return $this->canProceed($review, 'trustalyze_response') |
|
148 | - && 'publish' === $review->status |
|
149 | - && 3 === count(array_filter($requiredValues)); |
|
150 | - } |
|
151 | - |
|
152 | - /** |
|
153 | - * @return bool |
|
154 | - */ |
|
155 | - protected function canPostReview(Review $review) |
|
156 | - { |
|
157 | - $requiredValues = [ |
|
158 | - $review->author, |
|
159 | - $review->content, |
|
160 | - $review->rating, |
|
161 | - $review->review_id, |
|
162 | - $review->title, |
|
163 | - ]; |
|
164 | - return $this->canProceed($review) |
|
165 | - && 'publish' === $review->status |
|
166 | - && 5 === count(array_filter($requiredValues)); |
|
167 | - } |
|
168 | - |
|
169 | - /** |
|
170 | - * @param string $metaKey |
|
171 | - * @return bool |
|
172 | - */ |
|
173 | - protected function canProceed(Review $review, $metaKey = 'trustalyze') |
|
174 | - { |
|
175 | - return glsr(OptionManager::class)->getBool($this->enabledKey) |
|
176 | - && $this->isReviewPostId($review->ID) |
|
177 | - && !$this->hasMetaKey($review, $metaKey); |
|
178 | - } |
|
179 | - |
|
180 | - /** |
|
181 | - * @param string $metaKey |
|
182 | - * @return bool |
|
183 | - */ |
|
184 | - protected function hasMetaKey(Review $review, $metaKey = 'trustalyze') |
|
185 | - { |
|
186 | - return '' !== glsr(Database::class)->get($review->ID, $metaKey); |
|
187 | - } |
|
188 | - |
|
189 | - /** |
|
190 | - * @param string $key |
|
191 | - * @return bool |
|
192 | - */ |
|
193 | - protected function isEmptyOrModified($key, array $settings) |
|
194 | - { |
|
195 | - $oldValue = glsr_get_option($key); |
|
196 | - $newValue = Arr::get($settings, $key); |
|
197 | - return empty($newValue) || $newValue !== $oldValue; |
|
198 | - } |
|
199 | - |
|
200 | - /** |
|
201 | - * @return array |
|
202 | - */ |
|
203 | - protected function sanitizeTrustalyzeSettings(array $settings) |
|
204 | - { |
|
205 | - $trustalyze = glsr(Trustalyze::class)->activateKey( |
|
206 | - Arr::get($settings, $this->apiKey), |
|
207 | - Arr::get($settings, $this->emailKey) |
|
208 | - ); |
|
209 | - if ($trustalyze->success) { |
|
210 | - update_option($this->trustalyzeKey, Arr::get($trustalyze->response, 'producttype')); |
|
211 | - } else { |
|
212 | - delete_option($this->trustalyzeKey); |
|
213 | - $settings = Arr::set($settings, $this->enabledKey, 'no'); |
|
214 | - glsr(Notice::class)->addError(sprintf( |
|
215 | - __('Your Trustalyze account details could not be verified, please try again. %s', 'site-reviews'), |
|
216 | - '('.$trustalyze->message.')' |
|
217 | - )); |
|
218 | - } |
|
219 | - return $settings; |
|
220 | - } |
|
15 | + protected $apiKey = 'settings.general.trustalyze_serial'; |
|
16 | + protected $emailKey = 'settings.general.trustalyze_email'; |
|
17 | + protected $enabledKey = 'settings.general.trustalyze'; |
|
18 | + protected $trustalyzeKey = '_glsr_trustalyze'; |
|
19 | + |
|
20 | + /** |
|
21 | + * @return array |
|
22 | + * @filter site-reviews/settings/callback |
|
23 | + */ |
|
24 | + public function filterSettingsCallback(array $settings) |
|
25 | + { |
|
26 | + if ('yes' !== Arr::get($settings, $this->enabledKey)) { |
|
27 | + return $settings; |
|
28 | + } |
|
29 | + $isApiKeyModified = $this->isEmptyOrModified($this->apiKey, $settings); |
|
30 | + $isEmailModified = $this->isEmptyOrModified($this->emailKey, $settings); |
|
31 | + $isAccountVerified = glsr(OptionManager::class)->getWP($this->trustalyzeKey, false); |
|
32 | + if (!$isAccountVerified || $isApiKeyModified || $isEmailModified) { |
|
33 | + $settings = $this->sanitizeTrustalyzeSettings($settings); |
|
34 | + } |
|
35 | + return $settings; |
|
36 | + } |
|
37 | + |
|
38 | + /** |
|
39 | + * @param string $template |
|
40 | + * @return array |
|
41 | + * @filter site-reviews/interpolate/partials/form/table-row-multiple |
|
42 | + */ |
|
43 | + public function filterSettingsTableRow(array $context, $template, array $data) |
|
44 | + { |
|
45 | + if ($this->enabledKey !== Arr::get($data, 'field.path')) { |
|
46 | + return $context; |
|
47 | + } |
|
48 | + $isAccountValidated = !empty(glsr(OptionManager::class)->getWP($this->trustalyzeKey)); |
|
49 | + $isIntegrationEnabled = glsr(OptionManager::class)->getBool('settings.general.trustalyze'); |
|
50 | + if ($isAccountValidated && $isIntegrationEnabled) { |
|
51 | + return $context; |
|
52 | + } |
|
53 | + $context['field'].= $this->buildCreateButton(); |
|
54 | + return $context; |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * Triggered when a review is created. |
|
59 | + * @return void |
|
60 | + * @action site-reviews/review/created |
|
61 | + */ |
|
62 | + public function onCreated(Review $review) |
|
63 | + { |
|
64 | + if (!$this->canPostReview($review)) { |
|
65 | + return; |
|
66 | + } |
|
67 | + $trustalyze = glsr(Trustalyze::class)->sendReview($review); |
|
68 | + if ($trustalyze->success) { |
|
69 | + glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id); |
|
70 | + } |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * Triggered when a review is reverted to its original title/content/date_timestamp. |
|
75 | + * @return void |
|
76 | + * @action site-reviews/review/reverted |
|
77 | + */ |
|
78 | + public function onReverted(Review $review) |
|
79 | + { |
|
80 | + if (!$this->canPostReview($review)) { |
|
81 | + return; |
|
82 | + } |
|
83 | + $trustalyze = glsr(Trustalyze::class)->sendReview($review); |
|
84 | + if ($trustalyze->success) { |
|
85 | + glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id); |
|
86 | + } |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * Triggered when an existing review is updated. |
|
91 | + * @return void |
|
92 | + * @action site-reviews/review/saved |
|
93 | + */ |
|
94 | + public function onSaved(Review $review) |
|
95 | + { |
|
96 | + if (!$this->canPostReview($review)) { |
|
97 | + return; |
|
98 | + } |
|
99 | + $trustalyze = glsr(Trustalyze::class)->sendReview($review); |
|
100 | + if ($trustalyze->success) { |
|
101 | + glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id); |
|
102 | + } |
|
103 | + } |
|
104 | + |
|
105 | + /** |
|
106 | + * Triggered when a review's response is added or updated. |
|
107 | + * @param int $metaId |
|
108 | + * @param int $postId |
|
109 | + * @param string $metaKey |
|
110 | + * @return void |
|
111 | + * @action updated_postmeta |
|
112 | + */ |
|
113 | + public function onUpdatedMeta($metaId, $postId, $metaKey) |
|
114 | + { |
|
115 | + $review = glsr_get_review($postId); |
|
116 | + if (!$this->canPostResponse($review) || '_response' !== $metaKey) { |
|
117 | + return; |
|
118 | + } |
|
119 | + $trustalyze = glsr(Trustalyze::class)->sendReviewResponse($review); |
|
120 | + if ($trustalyze->success) { |
|
121 | + glsr(Database::class)->set($review->ID, 'trustalyze_response', true); |
|
122 | + } |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * @return string |
|
127 | + */ |
|
128 | + protected function buildCreateButton() |
|
129 | + { |
|
130 | + return glsr(Builder::class)->a(__('Create Your Trustalyze Account', 'site-reviews'), [ |
|
131 | + 'class' => 'button', |
|
132 | + 'href' => Trustalyze::WEB_URL, |
|
133 | + 'target' => '_blank', |
|
134 | + ]); |
|
135 | + } |
|
136 | + |
|
137 | + /** |
|
138 | + * @return bool |
|
139 | + */ |
|
140 | + protected function canPostResponse(Review $review) |
|
141 | + { |
|
142 | + $requiredValues = [ |
|
143 | + glsr(Database::class)->get($review->ID, 'trustalyze'), |
|
144 | + $review->response, |
|
145 | + $review->review_id, |
|
146 | + ]; |
|
147 | + return $this->canProceed($review, 'trustalyze_response') |
|
148 | + && 'publish' === $review->status |
|
149 | + && 3 === count(array_filter($requiredValues)); |
|
150 | + } |
|
151 | + |
|
152 | + /** |
|
153 | + * @return bool |
|
154 | + */ |
|
155 | + protected function canPostReview(Review $review) |
|
156 | + { |
|
157 | + $requiredValues = [ |
|
158 | + $review->author, |
|
159 | + $review->content, |
|
160 | + $review->rating, |
|
161 | + $review->review_id, |
|
162 | + $review->title, |
|
163 | + ]; |
|
164 | + return $this->canProceed($review) |
|
165 | + && 'publish' === $review->status |
|
166 | + && 5 === count(array_filter($requiredValues)); |
|
167 | + } |
|
168 | + |
|
169 | + /** |
|
170 | + * @param string $metaKey |
|
171 | + * @return bool |
|
172 | + */ |
|
173 | + protected function canProceed(Review $review, $metaKey = 'trustalyze') |
|
174 | + { |
|
175 | + return glsr(OptionManager::class)->getBool($this->enabledKey) |
|
176 | + && $this->isReviewPostId($review->ID) |
|
177 | + && !$this->hasMetaKey($review, $metaKey); |
|
178 | + } |
|
179 | + |
|
180 | + /** |
|
181 | + * @param string $metaKey |
|
182 | + * @return bool |
|
183 | + */ |
|
184 | + protected function hasMetaKey(Review $review, $metaKey = 'trustalyze') |
|
185 | + { |
|
186 | + return '' !== glsr(Database::class)->get($review->ID, $metaKey); |
|
187 | + } |
|
188 | + |
|
189 | + /** |
|
190 | + * @param string $key |
|
191 | + * @return bool |
|
192 | + */ |
|
193 | + protected function isEmptyOrModified($key, array $settings) |
|
194 | + { |
|
195 | + $oldValue = glsr_get_option($key); |
|
196 | + $newValue = Arr::get($settings, $key); |
|
197 | + return empty($newValue) || $newValue !== $oldValue; |
|
198 | + } |
|
199 | + |
|
200 | + /** |
|
201 | + * @return array |
|
202 | + */ |
|
203 | + protected function sanitizeTrustalyzeSettings(array $settings) |
|
204 | + { |
|
205 | + $trustalyze = glsr(Trustalyze::class)->activateKey( |
|
206 | + Arr::get($settings, $this->apiKey), |
|
207 | + Arr::get($settings, $this->emailKey) |
|
208 | + ); |
|
209 | + if ($trustalyze->success) { |
|
210 | + update_option($this->trustalyzeKey, Arr::get($trustalyze->response, 'producttype')); |
|
211 | + } else { |
|
212 | + delete_option($this->trustalyzeKey); |
|
213 | + $settings = Arr::set($settings, $this->enabledKey, 'no'); |
|
214 | + glsr(Notice::class)->addError(sprintf( |
|
215 | + __('Your Trustalyze account details could not be verified, please try again. %s', 'site-reviews'), |
|
216 | + '('.$trustalyze->message.')' |
|
217 | + )); |
|
218 | + } |
|
219 | + return $settings; |
|
220 | + } |
|
221 | 221 | } |
@@ -21,16 +21,16 @@ discard block |
||
21 | 21 | * @return array |
22 | 22 | * @filter site-reviews/settings/callback |
23 | 23 | */ |
24 | - public function filterSettingsCallback(array $settings) |
|
24 | + public function filterSettingsCallback( array $settings ) |
|
25 | 25 | { |
26 | - if ('yes' !== Arr::get($settings, $this->enabledKey)) { |
|
26 | + if( 'yes' !== Arr::get( $settings, $this->enabledKey ) ) { |
|
27 | 27 | return $settings; |
28 | 28 | } |
29 | - $isApiKeyModified = $this->isEmptyOrModified($this->apiKey, $settings); |
|
30 | - $isEmailModified = $this->isEmptyOrModified($this->emailKey, $settings); |
|
31 | - $isAccountVerified = glsr(OptionManager::class)->getWP($this->trustalyzeKey, false); |
|
32 | - if (!$isAccountVerified || $isApiKeyModified || $isEmailModified) { |
|
33 | - $settings = $this->sanitizeTrustalyzeSettings($settings); |
|
29 | + $isApiKeyModified = $this->isEmptyOrModified( $this->apiKey, $settings ); |
|
30 | + $isEmailModified = $this->isEmptyOrModified( $this->emailKey, $settings ); |
|
31 | + $isAccountVerified = glsr( OptionManager::class )->getWP( $this->trustalyzeKey, false ); |
|
32 | + if( !$isAccountVerified || $isApiKeyModified || $isEmailModified ) { |
|
33 | + $settings = $this->sanitizeTrustalyzeSettings( $settings ); |
|
34 | 34 | } |
35 | 35 | return $settings; |
36 | 36 | } |
@@ -40,17 +40,17 @@ discard block |
||
40 | 40 | * @return array |
41 | 41 | * @filter site-reviews/interpolate/partials/form/table-row-multiple |
42 | 42 | */ |
43 | - public function filterSettingsTableRow(array $context, $template, array $data) |
|
43 | + public function filterSettingsTableRow( array $context, $template, array $data ) |
|
44 | 44 | { |
45 | - if ($this->enabledKey !== Arr::get($data, 'field.path')) { |
|
45 | + if( $this->enabledKey !== Arr::get( $data, 'field.path' ) ) { |
|
46 | 46 | return $context; |
47 | 47 | } |
48 | - $isAccountValidated = !empty(glsr(OptionManager::class)->getWP($this->trustalyzeKey)); |
|
49 | - $isIntegrationEnabled = glsr(OptionManager::class)->getBool('settings.general.trustalyze'); |
|
50 | - if ($isAccountValidated && $isIntegrationEnabled) { |
|
48 | + $isAccountValidated = !empty(glsr( OptionManager::class )->getWP( $this->trustalyzeKey )); |
|
49 | + $isIntegrationEnabled = glsr( OptionManager::class )->getBool( 'settings.general.trustalyze' ); |
|
50 | + if( $isAccountValidated && $isIntegrationEnabled ) { |
|
51 | 51 | return $context; |
52 | 52 | } |
53 | - $context['field'].= $this->buildCreateButton(); |
|
53 | + $context['field'] .= $this->buildCreateButton(); |
|
54 | 54 | return $context; |
55 | 55 | } |
56 | 56 | |
@@ -59,14 +59,14 @@ discard block |
||
59 | 59 | * @return void |
60 | 60 | * @action site-reviews/review/created |
61 | 61 | */ |
62 | - public function onCreated(Review $review) |
|
62 | + public function onCreated( Review $review ) |
|
63 | 63 | { |
64 | - if (!$this->canPostReview($review)) { |
|
64 | + if( !$this->canPostReview( $review ) ) { |
|
65 | 65 | return; |
66 | 66 | } |
67 | - $trustalyze = glsr(Trustalyze::class)->sendReview($review); |
|
68 | - if ($trustalyze->success) { |
|
69 | - glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id); |
|
67 | + $trustalyze = glsr( Trustalyze::class )->sendReview( $review ); |
|
68 | + if( $trustalyze->success ) { |
|
69 | + glsr( Database::class )->set( $review->ID, 'trustalyze', $trustalyze->review_id ); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
@@ -75,14 +75,14 @@ discard block |
||
75 | 75 | * @return void |
76 | 76 | * @action site-reviews/review/reverted |
77 | 77 | */ |
78 | - public function onReverted(Review $review) |
|
78 | + public function onReverted( Review $review ) |
|
79 | 79 | { |
80 | - if (!$this->canPostReview($review)) { |
|
80 | + if( !$this->canPostReview( $review ) ) { |
|
81 | 81 | return; |
82 | 82 | } |
83 | - $trustalyze = glsr(Trustalyze::class)->sendReview($review); |
|
84 | - if ($trustalyze->success) { |
|
85 | - glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id); |
|
83 | + $trustalyze = glsr( Trustalyze::class )->sendReview( $review ); |
|
84 | + if( $trustalyze->success ) { |
|
85 | + glsr( Database::class )->set( $review->ID, 'trustalyze', $trustalyze->review_id ); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
@@ -91,14 +91,14 @@ discard block |
||
91 | 91 | * @return void |
92 | 92 | * @action site-reviews/review/saved |
93 | 93 | */ |
94 | - public function onSaved(Review $review) |
|
94 | + public function onSaved( Review $review ) |
|
95 | 95 | { |
96 | - if (!$this->canPostReview($review)) { |
|
96 | + if( !$this->canPostReview( $review ) ) { |
|
97 | 97 | return; |
98 | 98 | } |
99 | - $trustalyze = glsr(Trustalyze::class)->sendReview($review); |
|
100 | - if ($trustalyze->success) { |
|
101 | - glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id); |
|
99 | + $trustalyze = glsr( Trustalyze::class )->sendReview( $review ); |
|
100 | + if( $trustalyze->success ) { |
|
101 | + glsr( Database::class )->set( $review->ID, 'trustalyze', $trustalyze->review_id ); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
@@ -110,15 +110,15 @@ discard block |
||
110 | 110 | * @return void |
111 | 111 | * @action updated_postmeta |
112 | 112 | */ |
113 | - public function onUpdatedMeta($metaId, $postId, $metaKey) |
|
113 | + public function onUpdatedMeta( $metaId, $postId, $metaKey ) |
|
114 | 114 | { |
115 | - $review = glsr_get_review($postId); |
|
116 | - if (!$this->canPostResponse($review) || '_response' !== $metaKey) { |
|
115 | + $review = glsr_get_review( $postId ); |
|
116 | + if( !$this->canPostResponse( $review ) || '_response' !== $metaKey ) { |
|
117 | 117 | return; |
118 | 118 | } |
119 | - $trustalyze = glsr(Trustalyze::class)->sendReviewResponse($review); |
|
120 | - if ($trustalyze->success) { |
|
121 | - glsr(Database::class)->set($review->ID, 'trustalyze_response', true); |
|
119 | + $trustalyze = glsr( Trustalyze::class )->sendReviewResponse( $review ); |
|
120 | + if( $trustalyze->success ) { |
|
121 | + glsr( Database::class )->set( $review->ID, 'trustalyze_response', true ); |
|
122 | 122 | } |
123 | 123 | } |
124 | 124 | |
@@ -127,32 +127,32 @@ discard block |
||
127 | 127 | */ |
128 | 128 | protected function buildCreateButton() |
129 | 129 | { |
130 | - return glsr(Builder::class)->a(__('Create Your Trustalyze Account', 'site-reviews'), [ |
|
130 | + return glsr( Builder::class )->a( __( 'Create Your Trustalyze Account', 'site-reviews' ), [ |
|
131 | 131 | 'class' => 'button', |
132 | 132 | 'href' => Trustalyze::WEB_URL, |
133 | 133 | 'target' => '_blank', |
134 | - ]); |
|
134 | + ] ); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
138 | 138 | * @return bool |
139 | 139 | */ |
140 | - protected function canPostResponse(Review $review) |
|
140 | + protected function canPostResponse( Review $review ) |
|
141 | 141 | { |
142 | 142 | $requiredValues = [ |
143 | - glsr(Database::class)->get($review->ID, 'trustalyze'), |
|
143 | + glsr( Database::class )->get( $review->ID, 'trustalyze' ), |
|
144 | 144 | $review->response, |
145 | 145 | $review->review_id, |
146 | 146 | ]; |
147 | - return $this->canProceed($review, 'trustalyze_response') |
|
147 | + return $this->canProceed( $review, 'trustalyze_response' ) |
|
148 | 148 | && 'publish' === $review->status |
149 | - && 3 === count(array_filter($requiredValues)); |
|
149 | + && 3 === count( array_filter( $requiredValues ) ); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
153 | 153 | * @return bool |
154 | 154 | */ |
155 | - protected function canPostReview(Review $review) |
|
155 | + protected function canPostReview( Review $review ) |
|
156 | 156 | { |
157 | 157 | $requiredValues = [ |
158 | 158 | $review->author, |
@@ -161,60 +161,60 @@ discard block |
||
161 | 161 | $review->review_id, |
162 | 162 | $review->title, |
163 | 163 | ]; |
164 | - return $this->canProceed($review) |
|
164 | + return $this->canProceed( $review ) |
|
165 | 165 | && 'publish' === $review->status |
166 | - && 5 === count(array_filter($requiredValues)); |
|
166 | + && 5 === count( array_filter( $requiredValues ) ); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
170 | 170 | * @param string $metaKey |
171 | 171 | * @return bool |
172 | 172 | */ |
173 | - protected function canProceed(Review $review, $metaKey = 'trustalyze') |
|
173 | + protected function canProceed( Review $review, $metaKey = 'trustalyze' ) |
|
174 | 174 | { |
175 | - return glsr(OptionManager::class)->getBool($this->enabledKey) |
|
176 | - && $this->isReviewPostId($review->ID) |
|
177 | - && !$this->hasMetaKey($review, $metaKey); |
|
175 | + return glsr( OptionManager::class )->getBool( $this->enabledKey ) |
|
176 | + && $this->isReviewPostId( $review->ID ) |
|
177 | + && !$this->hasMetaKey( $review, $metaKey ); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
181 | 181 | * @param string $metaKey |
182 | 182 | * @return bool |
183 | 183 | */ |
184 | - protected function hasMetaKey(Review $review, $metaKey = 'trustalyze') |
|
184 | + protected function hasMetaKey( Review $review, $metaKey = 'trustalyze' ) |
|
185 | 185 | { |
186 | - return '' !== glsr(Database::class)->get($review->ID, $metaKey); |
|
186 | + return '' !== glsr( Database::class )->get( $review->ID, $metaKey ); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
190 | 190 | * @param string $key |
191 | 191 | * @return bool |
192 | 192 | */ |
193 | - protected function isEmptyOrModified($key, array $settings) |
|
193 | + protected function isEmptyOrModified( $key, array $settings ) |
|
194 | 194 | { |
195 | - $oldValue = glsr_get_option($key); |
|
196 | - $newValue = Arr::get($settings, $key); |
|
195 | + $oldValue = glsr_get_option( $key ); |
|
196 | + $newValue = Arr::get( $settings, $key ); |
|
197 | 197 | return empty($newValue) || $newValue !== $oldValue; |
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
201 | 201 | * @return array |
202 | 202 | */ |
203 | - protected function sanitizeTrustalyzeSettings(array $settings) |
|
203 | + protected function sanitizeTrustalyzeSettings( array $settings ) |
|
204 | 204 | { |
205 | - $trustalyze = glsr(Trustalyze::class)->activateKey( |
|
206 | - Arr::get($settings, $this->apiKey), |
|
207 | - Arr::get($settings, $this->emailKey) |
|
205 | + $trustalyze = glsr( Trustalyze::class )->activateKey( |
|
206 | + Arr::get( $settings, $this->apiKey ), |
|
207 | + Arr::get( $settings, $this->emailKey ) |
|
208 | 208 | ); |
209 | - if ($trustalyze->success) { |
|
210 | - update_option($this->trustalyzeKey, Arr::get($trustalyze->response, 'producttype')); |
|
209 | + if( $trustalyze->success ) { |
|
210 | + update_option( $this->trustalyzeKey, Arr::get( $trustalyze->response, 'producttype' ) ); |
|
211 | 211 | } else { |
212 | - delete_option($this->trustalyzeKey); |
|
213 | - $settings = Arr::set($settings, $this->enabledKey, 'no'); |
|
214 | - glsr(Notice::class)->addError(sprintf( |
|
215 | - __('Your Trustalyze account details could not be verified, please try again. %s', 'site-reviews'), |
|
212 | + delete_option( $this->trustalyzeKey ); |
|
213 | + $settings = Arr::set( $settings, $this->enabledKey, 'no' ); |
|
214 | + glsr( Notice::class )->addError( sprintf( |
|
215 | + __( 'Your Trustalyze account details could not be verified, please try again. %s', 'site-reviews' ), |
|
216 | 216 | '('.$trustalyze->message.')' |
217 | - )); |
|
217 | + ) ); |
|
218 | 218 | } |
219 | 219 | return $settings; |
220 | 220 | } |
@@ -208,7 +208,8 @@ |
||
208 | 208 | ); |
209 | 209 | if ($trustalyze->success) { |
210 | 210 | update_option($this->trustalyzeKey, Arr::get($trustalyze->response, 'producttype')); |
211 | - } else { |
|
211 | + } |
|
212 | + else { |
|
212 | 213 | delete_option($this->trustalyzeKey); |
213 | 214 | $settings = Arr::set($settings, $this->enabledKey, 'no'); |
214 | 215 | glsr(Notice::class)->addError(sprintf( |
@@ -11,247 +11,247 @@ |
||
11 | 11 | |
12 | 12 | class TranslationController |
13 | 13 | { |
14 | - /** |
|
15 | - * @var Translator |
|
16 | - */ |
|
17 | - public $translator; |
|
14 | + /** |
|
15 | + * @var Translator |
|
16 | + */ |
|
17 | + public $translator; |
|
18 | 18 | |
19 | - public function __construct(Translator $translator) |
|
20 | - { |
|
21 | - $this->translator = $translator; |
|
22 | - } |
|
19 | + public function __construct(Translator $translator) |
|
20 | + { |
|
21 | + $this->translator = $translator; |
|
22 | + } |
|
23 | 23 | |
24 | - /** |
|
25 | - * @return void |
|
26 | - * @action plugins_loaded |
|
27 | - */ |
|
28 | - public function addTranslationFilters() |
|
29 | - { |
|
30 | - if (empty(glsr(Translation::class)->translations())) { |
|
31 | - return; |
|
32 | - } |
|
33 | - add_filter('gettext', [$this, 'filterGettext'], 9, 3); |
|
34 | - add_filter('site-reviews/gettext/site-reviews', [$this, 'filterGettextSiteReviews'], 10, 2); |
|
35 | - add_filter('gettext_with_context', [$this, 'filterGettextWithContext'], 9, 4); |
|
36 | - add_filter('site-reviews/gettext_with_context/site-reviews', [$this, 'filterGettextWithContextSiteReviews'], 10, 3); |
|
37 | - add_filter('ngettext', [$this, 'filterNgettext'], 9, 5); |
|
38 | - add_filter('site-reviews/ngettext/site-reviews', [$this, 'filterNgettextSiteReviews'], 10, 4); |
|
39 | - add_filter('ngettext_with_context', [$this, 'filterNgettextWithContext'], 9, 6); |
|
40 | - add_filter('site-reviews/ngettext_with_context/site-reviews', [$this, 'filterNgettextWithContextSiteReviews'], 10, 5); |
|
41 | - } |
|
24 | + /** |
|
25 | + * @return void |
|
26 | + * @action plugins_loaded |
|
27 | + */ |
|
28 | + public function addTranslationFilters() |
|
29 | + { |
|
30 | + if (empty(glsr(Translation::class)->translations())) { |
|
31 | + return; |
|
32 | + } |
|
33 | + add_filter('gettext', [$this, 'filterGettext'], 9, 3); |
|
34 | + add_filter('site-reviews/gettext/site-reviews', [$this, 'filterGettextSiteReviews'], 10, 2); |
|
35 | + add_filter('gettext_with_context', [$this, 'filterGettextWithContext'], 9, 4); |
|
36 | + add_filter('site-reviews/gettext_with_context/site-reviews', [$this, 'filterGettextWithContextSiteReviews'], 10, 3); |
|
37 | + add_filter('ngettext', [$this, 'filterNgettext'], 9, 5); |
|
38 | + add_filter('site-reviews/ngettext/site-reviews', [$this, 'filterNgettextSiteReviews'], 10, 4); |
|
39 | + add_filter('ngettext_with_context', [$this, 'filterNgettextWithContext'], 9, 6); |
|
40 | + add_filter('site-reviews/ngettext_with_context/site-reviews', [$this, 'filterNgettextWithContextSiteReviews'], 10, 5); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param array $messages |
|
45 | - * @return array |
|
46 | - * @filter bulk_post_updated_messages |
|
47 | - */ |
|
48 | - public function filterBulkUpdateMessages($messages, array $counts) |
|
49 | - { |
|
50 | - $messages = Arr::consolidateArray($messages); |
|
51 | - $messages[Application::POST_TYPE] = [ |
|
52 | - 'updated' => _n('%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews'), |
|
53 | - 'locked' => _n('%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews'), |
|
54 | - 'deleted' => _n('%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews'), |
|
55 | - 'trashed' => _n('%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews'), |
|
56 | - 'untrashed' => _n('%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews'), |
|
57 | - ]; |
|
58 | - return $messages; |
|
59 | - } |
|
43 | + /** |
|
44 | + * @param array $messages |
|
45 | + * @return array |
|
46 | + * @filter bulk_post_updated_messages |
|
47 | + */ |
|
48 | + public function filterBulkUpdateMessages($messages, array $counts) |
|
49 | + { |
|
50 | + $messages = Arr::consolidateArray($messages); |
|
51 | + $messages[Application::POST_TYPE] = [ |
|
52 | + 'updated' => _n('%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews'), |
|
53 | + 'locked' => _n('%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews'), |
|
54 | + 'deleted' => _n('%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews'), |
|
55 | + 'trashed' => _n('%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews'), |
|
56 | + 'untrashed' => _n('%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews'), |
|
57 | + ]; |
|
58 | + return $messages; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @param string $translation |
|
63 | - * @param string $text |
|
64 | - * @param string $domain |
|
65 | - * @return string |
|
66 | - * @filter gettext |
|
67 | - */ |
|
68 | - public function filterGettext($translation, $text, $domain) |
|
69 | - { |
|
70 | - return apply_filters('site-reviews/gettext/'.$domain, $translation, $text); |
|
71 | - } |
|
61 | + /** |
|
62 | + * @param string $translation |
|
63 | + * @param string $text |
|
64 | + * @param string $domain |
|
65 | + * @return string |
|
66 | + * @filter gettext |
|
67 | + */ |
|
68 | + public function filterGettext($translation, $text, $domain) |
|
69 | + { |
|
70 | + return apply_filters('site-reviews/gettext/'.$domain, $translation, $text); |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * @param string $translation |
|
75 | - * @param string $text |
|
76 | - * @return string |
|
77 | - * @filter site-reviews/gettext/site-reviews |
|
78 | - */ |
|
79 | - public function filterGettextSiteReviews($translation, $text) |
|
80 | - { |
|
81 | - return $this->translator->translate($translation, Application::ID, [ |
|
82 | - 'single' => $text, |
|
83 | - ]); |
|
84 | - } |
|
73 | + /** |
|
74 | + * @param string $translation |
|
75 | + * @param string $text |
|
76 | + * @return string |
|
77 | + * @filter site-reviews/gettext/site-reviews |
|
78 | + */ |
|
79 | + public function filterGettextSiteReviews($translation, $text) |
|
80 | + { |
|
81 | + return $this->translator->translate($translation, Application::ID, [ |
|
82 | + 'single' => $text, |
|
83 | + ]); |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * @param string $translation |
|
88 | - * @param string $text |
|
89 | - * @param string $context |
|
90 | - * @param string $domain |
|
91 | - * @return string |
|
92 | - * @filter gettext_with_context |
|
93 | - */ |
|
94 | - public function filterGettextWithContext($translation, $text, $context, $domain) |
|
95 | - { |
|
96 | - return apply_filters('site-reviews/gettext_with_context/'.$domain, $translation, $text, $context); |
|
97 | - } |
|
86 | + /** |
|
87 | + * @param string $translation |
|
88 | + * @param string $text |
|
89 | + * @param string $context |
|
90 | + * @param string $domain |
|
91 | + * @return string |
|
92 | + * @filter gettext_with_context |
|
93 | + */ |
|
94 | + public function filterGettextWithContext($translation, $text, $context, $domain) |
|
95 | + { |
|
96 | + return apply_filters('site-reviews/gettext_with_context/'.$domain, $translation, $text, $context); |
|
97 | + } |
|
98 | 98 | |
99 | - /** |
|
100 | - * @param string $translation |
|
101 | - * @param string $text |
|
102 | - * @param string $context |
|
103 | - * @return string |
|
104 | - * @filter site-reviews/gettext_with_context/site-reviews |
|
105 | - */ |
|
106 | - public function filterGettextWithContextSiteReviews($translation, $text, $context) |
|
107 | - { |
|
108 | - return $this->translator->translate($translation, Application::ID, [ |
|
109 | - 'context' => $context, |
|
110 | - 'single' => $text, |
|
111 | - ]); |
|
112 | - } |
|
99 | + /** |
|
100 | + * @param string $translation |
|
101 | + * @param string $text |
|
102 | + * @param string $context |
|
103 | + * @return string |
|
104 | + * @filter site-reviews/gettext_with_context/site-reviews |
|
105 | + */ |
|
106 | + public function filterGettextWithContextSiteReviews($translation, $text, $context) |
|
107 | + { |
|
108 | + return $this->translator->translate($translation, Application::ID, [ |
|
109 | + 'context' => $context, |
|
110 | + 'single' => $text, |
|
111 | + ]); |
|
112 | + } |
|
113 | 113 | |
114 | - /** |
|
115 | - * @param string $translation |
|
116 | - * @param string $single |
|
117 | - * @param string $plural |
|
118 | - * @param int $number |
|
119 | - * @param string $domain |
|
120 | - * @return string |
|
121 | - * @filter ngettext |
|
122 | - */ |
|
123 | - public function filterNgettext($translation, $single, $plural, $number, $domain) |
|
124 | - { |
|
125 | - return apply_filters('site-reviews/ngettext/'.$domain, $translation, $single, $plural, $number); |
|
126 | - } |
|
114 | + /** |
|
115 | + * @param string $translation |
|
116 | + * @param string $single |
|
117 | + * @param string $plural |
|
118 | + * @param int $number |
|
119 | + * @param string $domain |
|
120 | + * @return string |
|
121 | + * @filter ngettext |
|
122 | + */ |
|
123 | + public function filterNgettext($translation, $single, $plural, $number, $domain) |
|
124 | + { |
|
125 | + return apply_filters('site-reviews/ngettext/'.$domain, $translation, $single, $plural, $number); |
|
126 | + } |
|
127 | 127 | |
128 | - /** |
|
129 | - * @param string $translation |
|
130 | - * @param string $single |
|
131 | - * @param string $plural |
|
132 | - * @param int $number |
|
133 | - * @return string |
|
134 | - * @filter site-reviews/ngettext/site-reviews |
|
135 | - */ |
|
136 | - public function filterNgettextSiteReviews($translation, $single, $plural, $number) |
|
137 | - { |
|
138 | - return $this->translator->translate($translation, Application::ID, [ |
|
139 | - 'number' => $number, |
|
140 | - 'plural' => $plural, |
|
141 | - 'single' => $single, |
|
142 | - ]); |
|
143 | - } |
|
128 | + /** |
|
129 | + * @param string $translation |
|
130 | + * @param string $single |
|
131 | + * @param string $plural |
|
132 | + * @param int $number |
|
133 | + * @return string |
|
134 | + * @filter site-reviews/ngettext/site-reviews |
|
135 | + */ |
|
136 | + public function filterNgettextSiteReviews($translation, $single, $plural, $number) |
|
137 | + { |
|
138 | + return $this->translator->translate($translation, Application::ID, [ |
|
139 | + 'number' => $number, |
|
140 | + 'plural' => $plural, |
|
141 | + 'single' => $single, |
|
142 | + ]); |
|
143 | + } |
|
144 | 144 | |
145 | - /** |
|
146 | - * @param string $translation |
|
147 | - * @param string $single |
|
148 | - * @param string $plural |
|
149 | - * @param int $number |
|
150 | - * @param string $context |
|
151 | - * @param string $domain |
|
152 | - * @return string |
|
153 | - * @filter ngettext_with_context |
|
154 | - */ |
|
155 | - public function filterNgettextWithContext($translation, $single, $plural, $number, $context, $domain) |
|
156 | - { |
|
157 | - return apply_filters('site-reviews/ngettext_with_context/'.$domain, $translation, $single, $plural, $number, $context); |
|
158 | - } |
|
145 | + /** |
|
146 | + * @param string $translation |
|
147 | + * @param string $single |
|
148 | + * @param string $plural |
|
149 | + * @param int $number |
|
150 | + * @param string $context |
|
151 | + * @param string $domain |
|
152 | + * @return string |
|
153 | + * @filter ngettext_with_context |
|
154 | + */ |
|
155 | + public function filterNgettextWithContext($translation, $single, $plural, $number, $context, $domain) |
|
156 | + { |
|
157 | + return apply_filters('site-reviews/ngettext_with_context/'.$domain, $translation, $single, $plural, $number, $context); |
|
158 | + } |
|
159 | 159 | |
160 | - /** |
|
161 | - * @param string $translation |
|
162 | - * @param string $single |
|
163 | - * @param string $plural |
|
164 | - * @param int $number |
|
165 | - * @param string $context |
|
166 | - * @return string |
|
167 | - * @filter site-reviews/ngettext_with_context/site-reviews |
|
168 | - */ |
|
169 | - public function filterNgettextWithContextSiteReviews($translation, $single, $plural, $number, $context) |
|
170 | - { |
|
171 | - return $this->translator->translate($translation, Application::ID, [ |
|
172 | - 'context' => $context, |
|
173 | - 'number' => $number, |
|
174 | - 'plural' => $plural, |
|
175 | - 'single' => $single, |
|
176 | - ]); |
|
177 | - } |
|
160 | + /** |
|
161 | + * @param string $translation |
|
162 | + * @param string $single |
|
163 | + * @param string $plural |
|
164 | + * @param int $number |
|
165 | + * @param string $context |
|
166 | + * @return string |
|
167 | + * @filter site-reviews/ngettext_with_context/site-reviews |
|
168 | + */ |
|
169 | + public function filterNgettextWithContextSiteReviews($translation, $single, $plural, $number, $context) |
|
170 | + { |
|
171 | + return $this->translator->translate($translation, Application::ID, [ |
|
172 | + 'context' => $context, |
|
173 | + 'number' => $number, |
|
174 | + 'plural' => $plural, |
|
175 | + 'single' => $single, |
|
176 | + ]); |
|
177 | + } |
|
178 | 178 | |
179 | - /** |
|
180 | - * @param array $postStates |
|
181 | - * @param \WP_Post $post |
|
182 | - * @return array |
|
183 | - * @filter display_post_states |
|
184 | - */ |
|
185 | - public function filterPostStates($postStates, $post) |
|
186 | - { |
|
187 | - $postStates = Arr::consolidateArray($postStates); |
|
188 | - if (Application::POST_TYPE == Arr::get($post, 'post_type') && array_key_exists('pending', $postStates)) { |
|
189 | - $postStates['pending'] = __('Unapproved', 'site-reviews'); |
|
190 | - } |
|
191 | - return $postStates; |
|
192 | - } |
|
179 | + /** |
|
180 | + * @param array $postStates |
|
181 | + * @param \WP_Post $post |
|
182 | + * @return array |
|
183 | + * @filter display_post_states |
|
184 | + */ |
|
185 | + public function filterPostStates($postStates, $post) |
|
186 | + { |
|
187 | + $postStates = Arr::consolidateArray($postStates); |
|
188 | + if (Application::POST_TYPE == Arr::get($post, 'post_type') && array_key_exists('pending', $postStates)) { |
|
189 | + $postStates['pending'] = __('Unapproved', 'site-reviews'); |
|
190 | + } |
|
191 | + return $postStates; |
|
192 | + } |
|
193 | 193 | |
194 | - /** |
|
195 | - * @param string $translation |
|
196 | - * @param string $text |
|
197 | - * @return string |
|
198 | - * @filter site-reviews/gettext/default |
|
199 | - * @filter site-reviews/gettext_with_context/default |
|
200 | - */ |
|
201 | - public function filterPostStatusLabels($translation, $text) |
|
202 | - { |
|
203 | - return $this->canModifyTranslation() |
|
204 | - ? glsr(Labels::class)->filterPostStatusLabels($translation, $text) |
|
205 | - : $translation; |
|
206 | - } |
|
194 | + /** |
|
195 | + * @param string $translation |
|
196 | + * @param string $text |
|
197 | + * @return string |
|
198 | + * @filter site-reviews/gettext/default |
|
199 | + * @filter site-reviews/gettext_with_context/default |
|
200 | + */ |
|
201 | + public function filterPostStatusLabels($translation, $text) |
|
202 | + { |
|
203 | + return $this->canModifyTranslation() |
|
204 | + ? glsr(Labels::class)->filterPostStatusLabels($translation, $text) |
|
205 | + : $translation; |
|
206 | + } |
|
207 | 207 | |
208 | - /** |
|
209 | - * @param string $translation |
|
210 | - * @param string $single |
|
211 | - * @param string $plural |
|
212 | - * @param int $number |
|
213 | - * @return string |
|
214 | - * @filter site-reviews/ngettext/default |
|
215 | - */ |
|
216 | - public function filterPostStatusText($translation, $single, $plural, $number) |
|
217 | - { |
|
218 | - if ($this->canModifyTranslation()) { |
|
219 | - $strings = [ |
|
220 | - 'Published' => __('Approved', 'site-reviews'), |
|
221 | - 'Pending' => __('Unapproved', 'site-reviews'), |
|
222 | - ]; |
|
223 | - foreach ($strings as $search => $replace) { |
|
224 | - if (!Str::contains($single, $search)) { |
|
225 | - continue; |
|
226 | - } |
|
227 | - return $this->translator->getTranslation([ |
|
228 | - 'number' => $number, |
|
229 | - 'plural' => str_replace($search, $replace, $plural), |
|
230 | - 'single' => str_replace($search, $replace, $single), |
|
231 | - ]); |
|
232 | - } |
|
233 | - } |
|
234 | - return $translation; |
|
235 | - } |
|
208 | + /** |
|
209 | + * @param string $translation |
|
210 | + * @param string $single |
|
211 | + * @param string $plural |
|
212 | + * @param int $number |
|
213 | + * @return string |
|
214 | + * @filter site-reviews/ngettext/default |
|
215 | + */ |
|
216 | + public function filterPostStatusText($translation, $single, $plural, $number) |
|
217 | + { |
|
218 | + if ($this->canModifyTranslation()) { |
|
219 | + $strings = [ |
|
220 | + 'Published' => __('Approved', 'site-reviews'), |
|
221 | + 'Pending' => __('Unapproved', 'site-reviews'), |
|
222 | + ]; |
|
223 | + foreach ($strings as $search => $replace) { |
|
224 | + if (!Str::contains($single, $search)) { |
|
225 | + continue; |
|
226 | + } |
|
227 | + return $this->translator->getTranslation([ |
|
228 | + 'number' => $number, |
|
229 | + 'plural' => str_replace($search, $replace, $plural), |
|
230 | + 'single' => str_replace($search, $replace, $single), |
|
231 | + ]); |
|
232 | + } |
|
233 | + } |
|
234 | + return $translation; |
|
235 | + } |
|
236 | 236 | |
237 | - /** |
|
238 | - * @return void |
|
239 | - * @action admin_enqueue_scripts |
|
240 | - */ |
|
241 | - public function translatePostStatusLabels() |
|
242 | - { |
|
243 | - if ($this->canModifyTranslation()) { |
|
244 | - glsr(Labels::class)->translatePostStatusLabels(); |
|
245 | - } |
|
246 | - } |
|
237 | + /** |
|
238 | + * @return void |
|
239 | + * @action admin_enqueue_scripts |
|
240 | + */ |
|
241 | + public function translatePostStatusLabels() |
|
242 | + { |
|
243 | + if ($this->canModifyTranslation()) { |
|
244 | + glsr(Labels::class)->translatePostStatusLabels(); |
|
245 | + } |
|
246 | + } |
|
247 | 247 | |
248 | - /** |
|
249 | - * @return bool |
|
250 | - */ |
|
251 | - protected function canModifyTranslation() |
|
252 | - { |
|
253 | - $screen = glsr_current_screen(); |
|
254 | - return Application::POST_TYPE == $screen->post_type |
|
255 | - && in_array($screen->base, ['edit', 'post']); |
|
256 | - } |
|
248 | + /** |
|
249 | + * @return bool |
|
250 | + */ |
|
251 | + protected function canModifyTranslation() |
|
252 | + { |
|
253 | + $screen = glsr_current_screen(); |
|
254 | + return Application::POST_TYPE == $screen->post_type |
|
255 | + && in_array($screen->base, ['edit', 'post']); |
|
256 | + } |
|
257 | 257 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | */ |
17 | 17 | public $translator; |
18 | 18 | |
19 | - public function __construct(Translator $translator) |
|
19 | + public function __construct( Translator $translator ) |
|
20 | 20 | { |
21 | 21 | $this->translator = $translator; |
22 | 22 | } |
@@ -27,17 +27,17 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function addTranslationFilters() |
29 | 29 | { |
30 | - if (empty(glsr(Translation::class)->translations())) { |
|
30 | + if( empty(glsr( Translation::class )->translations()) ) { |
|
31 | 31 | return; |
32 | 32 | } |
33 | - add_filter('gettext', [$this, 'filterGettext'], 9, 3); |
|
34 | - add_filter('site-reviews/gettext/site-reviews', [$this, 'filterGettextSiteReviews'], 10, 2); |
|
35 | - add_filter('gettext_with_context', [$this, 'filterGettextWithContext'], 9, 4); |
|
36 | - add_filter('site-reviews/gettext_with_context/site-reviews', [$this, 'filterGettextWithContextSiteReviews'], 10, 3); |
|
37 | - add_filter('ngettext', [$this, 'filterNgettext'], 9, 5); |
|
38 | - add_filter('site-reviews/ngettext/site-reviews', [$this, 'filterNgettextSiteReviews'], 10, 4); |
|
39 | - add_filter('ngettext_with_context', [$this, 'filterNgettextWithContext'], 9, 6); |
|
40 | - add_filter('site-reviews/ngettext_with_context/site-reviews', [$this, 'filterNgettextWithContextSiteReviews'], 10, 5); |
|
33 | + add_filter( 'gettext', [$this, 'filterGettext'], 9, 3 ); |
|
34 | + add_filter( 'site-reviews/gettext/site-reviews', [$this, 'filterGettextSiteReviews'], 10, 2 ); |
|
35 | + add_filter( 'gettext_with_context', [$this, 'filterGettextWithContext'], 9, 4 ); |
|
36 | + add_filter( 'site-reviews/gettext_with_context/site-reviews', [$this, 'filterGettextWithContextSiteReviews'], 10, 3 ); |
|
37 | + add_filter( 'ngettext', [$this, 'filterNgettext'], 9, 5 ); |
|
38 | + add_filter( 'site-reviews/ngettext/site-reviews', [$this, 'filterNgettextSiteReviews'], 10, 4 ); |
|
39 | + add_filter( 'ngettext_with_context', [$this, 'filterNgettextWithContext'], 9, 6 ); |
|
40 | + add_filter( 'site-reviews/ngettext_with_context/site-reviews', [$this, 'filterNgettextWithContextSiteReviews'], 10, 5 ); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -45,15 +45,15 @@ discard block |
||
45 | 45 | * @return array |
46 | 46 | * @filter bulk_post_updated_messages |
47 | 47 | */ |
48 | - public function filterBulkUpdateMessages($messages, array $counts) |
|
48 | + public function filterBulkUpdateMessages( $messages, array $counts ) |
|
49 | 49 | { |
50 | - $messages = Arr::consolidateArray($messages); |
|
50 | + $messages = Arr::consolidateArray( $messages ); |
|
51 | 51 | $messages[Application::POST_TYPE] = [ |
52 | - 'updated' => _n('%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews'), |
|
53 | - 'locked' => _n('%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews'), |
|
54 | - 'deleted' => _n('%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews'), |
|
55 | - 'trashed' => _n('%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews'), |
|
56 | - 'untrashed' => _n('%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews'), |
|
52 | + 'updated' => _n( '%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews' ), |
|
53 | + 'locked' => _n( '%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews' ), |
|
54 | + 'deleted' => _n( '%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews' ), |
|
55 | + 'trashed' => _n( '%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews' ), |
|
56 | + 'untrashed' => _n( '%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews' ), |
|
57 | 57 | ]; |
58 | 58 | return $messages; |
59 | 59 | } |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | * @return string |
66 | 66 | * @filter gettext |
67 | 67 | */ |
68 | - public function filterGettext($translation, $text, $domain) |
|
68 | + public function filterGettext( $translation, $text, $domain ) |
|
69 | 69 | { |
70 | - return apply_filters('site-reviews/gettext/'.$domain, $translation, $text); |
|
70 | + return apply_filters( 'site-reviews/gettext/'.$domain, $translation, $text ); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | * @return string |
77 | 77 | * @filter site-reviews/gettext/site-reviews |
78 | 78 | */ |
79 | - public function filterGettextSiteReviews($translation, $text) |
|
79 | + public function filterGettextSiteReviews( $translation, $text ) |
|
80 | 80 | { |
81 | - return $this->translator->translate($translation, Application::ID, [ |
|
81 | + return $this->translator->translate( $translation, Application::ID, [ |
|
82 | 82 | 'single' => $text, |
83 | - ]); |
|
83 | + ] ); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | * @return string |
92 | 92 | * @filter gettext_with_context |
93 | 93 | */ |
94 | - public function filterGettextWithContext($translation, $text, $context, $domain) |
|
94 | + public function filterGettextWithContext( $translation, $text, $context, $domain ) |
|
95 | 95 | { |
96 | - return apply_filters('site-reviews/gettext_with_context/'.$domain, $translation, $text, $context); |
|
96 | + return apply_filters( 'site-reviews/gettext_with_context/'.$domain, $translation, $text, $context ); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -103,12 +103,12 @@ discard block |
||
103 | 103 | * @return string |
104 | 104 | * @filter site-reviews/gettext_with_context/site-reviews |
105 | 105 | */ |
106 | - public function filterGettextWithContextSiteReviews($translation, $text, $context) |
|
106 | + public function filterGettextWithContextSiteReviews( $translation, $text, $context ) |
|
107 | 107 | { |
108 | - return $this->translator->translate($translation, Application::ID, [ |
|
108 | + return $this->translator->translate( $translation, Application::ID, [ |
|
109 | 109 | 'context' => $context, |
110 | 110 | 'single' => $text, |
111 | - ]); |
|
111 | + ] ); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | * @return string |
121 | 121 | * @filter ngettext |
122 | 122 | */ |
123 | - public function filterNgettext($translation, $single, $plural, $number, $domain) |
|
123 | + public function filterNgettext( $translation, $single, $plural, $number, $domain ) |
|
124 | 124 | { |
125 | - return apply_filters('site-reviews/ngettext/'.$domain, $translation, $single, $plural, $number); |
|
125 | + return apply_filters( 'site-reviews/ngettext/'.$domain, $translation, $single, $plural, $number ); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -133,13 +133,13 @@ discard block |
||
133 | 133 | * @return string |
134 | 134 | * @filter site-reviews/ngettext/site-reviews |
135 | 135 | */ |
136 | - public function filterNgettextSiteReviews($translation, $single, $plural, $number) |
|
136 | + public function filterNgettextSiteReviews( $translation, $single, $plural, $number ) |
|
137 | 137 | { |
138 | - return $this->translator->translate($translation, Application::ID, [ |
|
138 | + return $this->translator->translate( $translation, Application::ID, [ |
|
139 | 139 | 'number' => $number, |
140 | 140 | 'plural' => $plural, |
141 | 141 | 'single' => $single, |
142 | - ]); |
|
142 | + ] ); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | * @return string |
153 | 153 | * @filter ngettext_with_context |
154 | 154 | */ |
155 | - public function filterNgettextWithContext($translation, $single, $plural, $number, $context, $domain) |
|
155 | + public function filterNgettextWithContext( $translation, $single, $plural, $number, $context, $domain ) |
|
156 | 156 | { |
157 | - return apply_filters('site-reviews/ngettext_with_context/'.$domain, $translation, $single, $plural, $number, $context); |
|
157 | + return apply_filters( 'site-reviews/ngettext_with_context/'.$domain, $translation, $single, $plural, $number, $context ); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -166,14 +166,14 @@ discard block |
||
166 | 166 | * @return string |
167 | 167 | * @filter site-reviews/ngettext_with_context/site-reviews |
168 | 168 | */ |
169 | - public function filterNgettextWithContextSiteReviews($translation, $single, $plural, $number, $context) |
|
169 | + public function filterNgettextWithContextSiteReviews( $translation, $single, $plural, $number, $context ) |
|
170 | 170 | { |
171 | - return $this->translator->translate($translation, Application::ID, [ |
|
171 | + return $this->translator->translate( $translation, Application::ID, [ |
|
172 | 172 | 'context' => $context, |
173 | 173 | 'number' => $number, |
174 | 174 | 'plural' => $plural, |
175 | 175 | 'single' => $single, |
176 | - ]); |
|
176 | + ] ); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
@@ -182,11 +182,11 @@ discard block |
||
182 | 182 | * @return array |
183 | 183 | * @filter display_post_states |
184 | 184 | */ |
185 | - public function filterPostStates($postStates, $post) |
|
185 | + public function filterPostStates( $postStates, $post ) |
|
186 | 186 | { |
187 | - $postStates = Arr::consolidateArray($postStates); |
|
188 | - if (Application::POST_TYPE == Arr::get($post, 'post_type') && array_key_exists('pending', $postStates)) { |
|
189 | - $postStates['pending'] = __('Unapproved', 'site-reviews'); |
|
187 | + $postStates = Arr::consolidateArray( $postStates ); |
|
188 | + if( Application::POST_TYPE == Arr::get( $post, 'post_type' ) && array_key_exists( 'pending', $postStates ) ) { |
|
189 | + $postStates['pending'] = __( 'Unapproved', 'site-reviews' ); |
|
190 | 190 | } |
191 | 191 | return $postStates; |
192 | 192 | } |
@@ -198,10 +198,10 @@ discard block |
||
198 | 198 | * @filter site-reviews/gettext/default |
199 | 199 | * @filter site-reviews/gettext_with_context/default |
200 | 200 | */ |
201 | - public function filterPostStatusLabels($translation, $text) |
|
201 | + public function filterPostStatusLabels( $translation, $text ) |
|
202 | 202 | { |
203 | 203 | return $this->canModifyTranslation() |
204 | - ? glsr(Labels::class)->filterPostStatusLabels($translation, $text) |
|
204 | + ? glsr( Labels::class )->filterPostStatusLabels( $translation, $text ) |
|
205 | 205 | : $translation; |
206 | 206 | } |
207 | 207 | |
@@ -213,22 +213,22 @@ discard block |
||
213 | 213 | * @return string |
214 | 214 | * @filter site-reviews/ngettext/default |
215 | 215 | */ |
216 | - public function filterPostStatusText($translation, $single, $plural, $number) |
|
216 | + public function filterPostStatusText( $translation, $single, $plural, $number ) |
|
217 | 217 | { |
218 | - if ($this->canModifyTranslation()) { |
|
218 | + if( $this->canModifyTranslation() ) { |
|
219 | 219 | $strings = [ |
220 | - 'Published' => __('Approved', 'site-reviews'), |
|
221 | - 'Pending' => __('Unapproved', 'site-reviews'), |
|
220 | + 'Published' => __( 'Approved', 'site-reviews' ), |
|
221 | + 'Pending' => __( 'Unapproved', 'site-reviews' ), |
|
222 | 222 | ]; |
223 | - foreach ($strings as $search => $replace) { |
|
224 | - if (!Str::contains($single, $search)) { |
|
223 | + foreach( $strings as $search => $replace ) { |
|
224 | + if( !Str::contains( $single, $search ) ) { |
|
225 | 225 | continue; |
226 | 226 | } |
227 | - return $this->translator->getTranslation([ |
|
227 | + return $this->translator->getTranslation( [ |
|
228 | 228 | 'number' => $number, |
229 | - 'plural' => str_replace($search, $replace, $plural), |
|
230 | - 'single' => str_replace($search, $replace, $single), |
|
231 | - ]); |
|
229 | + 'plural' => str_replace( $search, $replace, $plural ), |
|
230 | + 'single' => str_replace( $search, $replace, $single ), |
|
231 | + ] ); |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | return $translation; |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | */ |
241 | 241 | public function translatePostStatusLabels() |
242 | 242 | { |
243 | - if ($this->canModifyTranslation()) { |
|
244 | - glsr(Labels::class)->translatePostStatusLabels(); |
|
243 | + if( $this->canModifyTranslation() ) { |
|
244 | + glsr( Labels::class )->translatePostStatusLabels(); |
|
245 | 245 | } |
246 | 246 | } |
247 | 247 | |
@@ -252,6 +252,6 @@ discard block |
||
252 | 252 | { |
253 | 253 | $screen = glsr_current_screen(); |
254 | 254 | return Application::POST_TYPE == $screen->post_type |
255 | - && in_array($screen->base, ['edit', 'post']); |
|
255 | + && in_array( $screen->base, ['edit', 'post'] ); |
|
256 | 256 | } |
257 | 257 | } |