@@ -11,31 +11,31 @@ discard block |
||
11 | 11 | * @param string $domain |
12 | 12 | * @return string |
13 | 13 | */ |
14 | - public function translate($original, $domain, array $args) |
|
14 | + public function translate( $original, $domain, array $args ) |
|
15 | 15 | { |
16 | - $domains = apply_filters('site-reviews/translator/domains', [Application::ID]); |
|
17 | - if (!in_array($domain, $domains)) { |
|
16 | + $domains = apply_filters( 'site-reviews/translator/domains', [Application::ID] ); |
|
17 | + if( !in_array( $domain, $domains ) ) { |
|
18 | 18 | return $original; |
19 | 19 | } |
20 | - $args = $this->normalizeTranslationArgs($args); |
|
21 | - $strings = $this->getTranslationStrings($args['single'], $args['plural']); |
|
22 | - if (empty($strings)) { |
|
20 | + $args = $this->normalizeTranslationArgs( $args ); |
|
21 | + $strings = $this->getTranslationStrings( $args['single'], $args['plural'] ); |
|
22 | + if( empty($strings) ) { |
|
23 | 23 | return $original; |
24 | 24 | } |
25 | - $string = current($strings); |
|
25 | + $string = current( $strings ); |
|
26 | 26 | return 'plural' == $string['type'] |
27 | - ? $this->translatePlural($domain, $string, $args) |
|
28 | - : $this->translateSingle($domain, $string, $args); |
|
27 | + ? $this->translatePlural( $domain, $string, $args ) |
|
28 | + : $this->translateSingle( $domain, $string, $args ); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Used when search/replacing a default text-domain translation |
33 | 33 | * @return string |
34 | 34 | */ |
35 | - public function getTranslation(array $args) |
|
35 | + public function getTranslation( array $args ) |
|
36 | 36 | { |
37 | - $args = $this->normalizeTranslationArgs($args); |
|
38 | - return get_translations_for_domain(Application::ID)->translate_plural($args['single'], $args['plural'], $args['number']); |
|
37 | + $args = $this->normalizeTranslationArgs( $args ); |
|
38 | + return get_translations_for_domain( Application::ID )->translate_plural( $args['single'], $args['plural'], $args['number'] ); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -43,18 +43,18 @@ discard block |
||
43 | 43 | * @param string $plural |
44 | 44 | * @return array |
45 | 45 | */ |
46 | - protected function getTranslationStrings($single, $plural) |
|
46 | + protected function getTranslationStrings( $single, $plural ) |
|
47 | 47 | { |
48 | - return array_filter(glsr(Translation::class)->translations(), function ($string) use ($single, $plural) { |
|
49 | - return $string['s1'] == html_entity_decode($single, ENT_COMPAT, 'UTF-8') |
|
50 | - && $string['p1'] == html_entity_decode($plural, ENT_COMPAT, 'UTF-8'); |
|
48 | + return array_filter( glsr( Translation::class )->translations(), function( $string ) use ($single, $plural) { |
|
49 | + return $string['s1'] == html_entity_decode( $single, ENT_COMPAT, 'UTF-8' ) |
|
50 | + && $string['p1'] == html_entity_decode( $plural, ENT_COMPAT, 'UTF-8' ); |
|
51 | 51 | }); |
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
55 | 55 | * @return array |
56 | 56 | */ |
57 | - protected function normalizeTranslationArgs(array $args) |
|
57 | + protected function normalizeTranslationArgs( array $args ) |
|
58 | 58 | { |
59 | 59 | $defaults = [ |
60 | 60 | 'context' => '', |
@@ -62,22 +62,22 @@ discard block |
||
62 | 62 | 'plural' => '', |
63 | 63 | 'single' => '', |
64 | 64 | ]; |
65 | - return shortcode_atts($defaults, $args); |
|
65 | + return shortcode_atts( $defaults, $args ); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
69 | 69 | * @param string $domain |
70 | 70 | * @return string |
71 | 71 | */ |
72 | - protected function translatePlural($domain, array $string, array $args) |
|
72 | + protected function translatePlural( $domain, array $string, array $args ) |
|
73 | 73 | { |
74 | - if (!empty($string['s2'])) { |
|
74 | + if( !empty($string['s2']) ) { |
|
75 | 75 | $args['single'] = $string['s2']; |
76 | 76 | } |
77 | - if (!empty($string['p2'])) { |
|
77 | + if( !empty($string['p2']) ) { |
|
78 | 78 | $args['plural'] = $string['p2']; |
79 | 79 | } |
80 | - return get_translations_for_domain($domain)->translate_plural( |
|
80 | + return get_translations_for_domain( $domain )->translate_plural( |
|
81 | 81 | $args['single'], |
82 | 82 | $args['plural'], |
83 | 83 | $args['number'], |
@@ -89,12 +89,12 @@ discard block |
||
89 | 89 | * @param string $domain |
90 | 90 | * @return string |
91 | 91 | */ |
92 | - protected function translateSingle($domain, array $string, array $args) |
|
92 | + protected function translateSingle( $domain, array $string, array $args ) |
|
93 | 93 | { |
94 | - if (!empty($string['s2'])) { |
|
94 | + if( !empty($string['s2']) ) { |
|
95 | 95 | $args['single'] = $string['s2']; |
96 | 96 | } |
97 | - return get_translations_for_domain($domain)->translate( |
|
97 | + return get_translations_for_domain( $domain )->translate( |
|
98 | 98 | $args['single'], |
99 | 99 | $args['context'] |
100 | 100 | ); |
@@ -28,14 +28,14 @@ discard block |
||
28 | 28 | * @return string |
29 | 29 | * @filter script_loader_tag |
30 | 30 | */ |
31 | - public function filterEnqueuedScripts($tag, $handle) |
|
31 | + public function filterEnqueuedScripts( $tag, $handle ) |
|
32 | 32 | { |
33 | 33 | $scripts = [Application::ID.'/google-recaptcha']; |
34 | - if (in_array($handle, apply_filters('site-reviews/async-scripts', $scripts))) { |
|
35 | - $tag = str_replace(' src=', ' async src=', $tag); |
|
34 | + if( in_array( $handle, apply_filters( 'site-reviews/async-scripts', $scripts ) ) ) { |
|
35 | + $tag = str_replace( ' src=', ' async src=', $tag ); |
|
36 | 36 | } |
37 | - if (in_array($handle, apply_filters('site-reviews/defer-scripts', $scripts))) { |
|
38 | - $tag = str_replace(' src=', ' defer src=', $tag); |
|
37 | + if( in_array( $handle, apply_filters( 'site-reviews/defer-scripts', $scripts ) ) ) { |
|
38 | + $tag = str_replace( ' src=', ' defer src=', $tag ); |
|
39 | 39 | } |
40 | 40 | return $tag; |
41 | 41 | } |
@@ -44,10 +44,10 @@ discard block |
||
44 | 44 | * @return array |
45 | 45 | * @filter site-reviews/config/forms/submission-form |
46 | 46 | */ |
47 | - public function filterFieldOrder(array $config) |
|
47 | + public function filterFieldOrder( array $config ) |
|
48 | 48 | { |
49 | - $order = (array) apply_filters('site-reviews/submission-form/order', array_keys($config)); |
|
50 | - return array_intersect_key(array_merge(array_flip($order), $config), $config); |
|
49 | + $order = (array)apply_filters( 'site-reviews/submission-form/order', array_keys( $config ) ); |
|
50 | + return array_intersect_key( array_merge( array_flip( $order ), $config ), $config ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -55,18 +55,18 @@ discard block |
||
55 | 55 | * @return string |
56 | 56 | * @filter site-reviews/render/view |
57 | 57 | */ |
58 | - public function filterRenderView($view) |
|
58 | + public function filterRenderView( $view ) |
|
59 | 59 | { |
60 | - return glsr(Style::class)->filterView($view); |
|
60 | + return glsr( Style::class )->filterView( $view ); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
64 | 64 | * @return void |
65 | 65 | * @action site-reviews/builder |
66 | 66 | */ |
67 | - public function modifyBuilder(Builder $instance) |
|
67 | + public function modifyBuilder( Builder $instance ) |
|
68 | 68 | { |
69 | - call_user_func_array([glsr(Style::class), 'modifyField'], [$instance]); |
|
69 | + call_user_func_array( [glsr( Style::class ), 'modifyField'], [$instance] ); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -75,18 +75,18 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function renderSchema() |
77 | 77 | { |
78 | - glsr(Schema::class)->render(); |
|
78 | + glsr( Schema::class )->render(); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
82 | 82 | * @return CreateReview |
83 | 83 | */ |
84 | - public function routerSubmitReview(array $request) |
|
84 | + public function routerSubmitReview( array $request ) |
|
85 | 85 | { |
86 | - $validated = glsr(ValidateReview::class)->validate($request); |
|
87 | - $command = new CreateReview($validated->request); |
|
88 | - if (empty($validated->error) && !$validated->recaptchaIsUnset) { |
|
89 | - $this->execute($command); |
|
86 | + $validated = glsr( ValidateReview::class )->validate( $request ); |
|
87 | + $command = new CreateReview( $validated->request ); |
|
88 | + if( empty($validated->error) && !$validated->recaptchaIsUnset ) { |
|
89 | + $this->execute( $command ); |
|
90 | 90 | } |
91 | 91 | return $command; |
92 | 92 | } |
@@ -11,24 +11,24 @@ discard block |
||
11 | 11 | */ |
12 | 12 | public function getCloudflareIps() |
13 | 13 | { |
14 | - if (false === ($ipAddresses = get_transient(Application::ID.'_cloudflare_ips'))) { |
|
15 | - $ipAddresses = array_fill_keys(['v4', 'v6'], []); |
|
16 | - foreach (array_keys($ipAddresses) as $version) { |
|
14 | + if( false === ($ipAddresses = get_transient( Application::ID.'_cloudflare_ips' )) ) { |
|
15 | + $ipAddresses = array_fill_keys( ['v4', 'v6'], [] ); |
|
16 | + foreach( array_keys( $ipAddresses ) as $version ) { |
|
17 | 17 | $url = 'https://www.cloudflare.com/ips-'.$version; |
18 | - $response = wp_remote_get($url, ['sslverify' => false]); |
|
19 | - if (is_wp_error($response)) { |
|
20 | - glsr_log()->error($response->get_error_message()); |
|
18 | + $response = wp_remote_get( $url, ['sslverify' => false] ); |
|
19 | + if( is_wp_error( $response ) ) { |
|
20 | + glsr_log()->error( $response->get_error_message() ); |
|
21 | 21 | continue; |
22 | 22 | } |
23 | - if ('200' != ($statusCode = wp_remote_retrieve_response_code($response))) { |
|
24 | - glsr_log()->error('Unable to connect to '.$url.' ['.$statusCode.']'); |
|
23 | + if( '200' != ($statusCode = wp_remote_retrieve_response_code( $response )) ) { |
|
24 | + glsr_log()->error( 'Unable to connect to '.$url.' ['.$statusCode.']' ); |
|
25 | 25 | continue; |
26 | 26 | } |
27 | 27 | $ipAddresses[$version] = array_filter( |
28 | - (array) preg_split('/\R/', wp_remote_retrieve_body($response)) |
|
28 | + (array)preg_split( '/\R/', wp_remote_retrieve_body( $response ) ) |
|
29 | 29 | ); |
30 | 30 | } |
31 | - set_transient(Application::ID.'_cloudflare_ips', $ipAddresses, WEEK_IN_SECONDS); |
|
31 | + set_transient( Application::ID.'_cloudflare_ips', $ipAddresses, WEEK_IN_SECONDS ); |
|
32 | 32 | } |
33 | 33 | return $ipAddresses; |
34 | 34 | } |
@@ -37,16 +37,16 @@ discard block |
||
37 | 37 | * @param string $metaKey |
38 | 38 | * @return array |
39 | 39 | */ |
40 | - public function getReviewCountsFor($metaKey) |
|
40 | + public function getReviewCountsFor( $metaKey ) |
|
41 | 41 | { |
42 | - $counts = wp_cache_get(Application::ID, $metaKey.'_count'); |
|
43 | - if (false === $counts) { |
|
42 | + $counts = wp_cache_get( Application::ID, $metaKey.'_count' ); |
|
43 | + if( false === $counts ) { |
|
44 | 44 | $counts = []; |
45 | - $results = glsr(SqlQueries::class)->getReviewCountsFor($metaKey); |
|
46 | - foreach ($results as $result) { |
|
45 | + $results = glsr( SqlQueries::class )->getReviewCountsFor( $metaKey ); |
|
46 | + foreach( $results as $result ) { |
|
47 | 47 | $counts[$result->name] = $result->num_posts; |
48 | 48 | } |
49 | - wp_cache_set(Application::ID, $counts, $metaKey.'_count'); |
|
49 | + wp_cache_set( Application::ID, $counts, $metaKey.'_count' ); |
|
50 | 50 | } |
51 | 51 | return $counts; |
52 | 52 | } |
@@ -56,12 +56,12 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public function getRemotePostTest() |
58 | 58 | { |
59 | - if (false === ($test = get_transient(Application::ID.'_remote_post_test'))) { |
|
60 | - $response = wp_remote_post('https://api.wordpress.org/stats/php/1.0/'); |
|
61 | - $test = !is_wp_error($response) && in_array($response['response']['code'], range(200, 299)) |
|
59 | + if( false === ($test = get_transient( Application::ID.'_remote_post_test' )) ) { |
|
60 | + $response = wp_remote_post( 'https://api.wordpress.org/stats/php/1.0/' ); |
|
61 | + $test = !is_wp_error( $response ) && in_array( $response['response']['code'], range( 200, 299 ) ) |
|
62 | 62 | ? 'Works' |
63 | 63 | : 'Does not work'; |
64 | - set_transient(Application::ID.'_remote_post_test', $test, WEEK_IN_SECONDS); |
|
64 | + set_transient( Application::ID.'_remote_post_test', $test, WEEK_IN_SECONDS ); |
|
65 | 65 | } |
66 | 66 | return $test; |
67 | 67 | } |
@@ -37,7 +37,7 @@ |
||
37 | 37 | 'pinned' => false, |
38 | 38 | 'rating' => '', |
39 | 39 | 'response' => '', |
40 | - 'review_id' => md5(time().mt_rand()), |
|
40 | + 'review_id' => md5( time().mt_rand() ), |
|
41 | 41 | 'review_type' => 'local', |
42 | 42 | 'title' => '', |
43 | 43 | 'url' => '', |
@@ -10,13 +10,13 @@ discard block |
||
10 | 10 | |
11 | 11 | class Console |
12 | 12 | { |
13 | - const DEBUG = 0; // Detailed debug information |
|
14 | - const INFO = 1; // Interesting events |
|
15 | - const NOTICE = 2; // Normal but significant events |
|
16 | - const WARNING = 4; // Exceptional occurrences that are not errors |
|
17 | - const ERROR = 8; // Runtime errors that do not require immediate action |
|
18 | - const CRITICAL = 16; // Critical conditions |
|
19 | - const ALERT = 32; // Action must be taken immediately |
|
13 | + const DEBUG = 0; // Detailed debug information |
|
14 | + const INFO = 1; // Interesting events |
|
15 | + const NOTICE = 2; // Normal but significant events |
|
16 | + const WARNING = 4; // Exceptional occurrences that are not errors |
|
17 | + const ERROR = 8; // Runtime errors that do not require immediate action |
|
18 | + const CRITICAL = 16; // Critical conditions |
|
19 | + const ALERT = 32; // Action must be taken immediately |
|
20 | 20 | const EMERGENCY = 64; // System is unusable |
21 | 21 | |
22 | 22 | protected $file; |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | |
26 | 26 | public function __construct() |
27 | 27 | { |
28 | - $this->file = glsr()->path('console.log'); |
|
29 | - $this->log = file_exists($this->file) |
|
30 | - ? file_get_contents($this->file) |
|
28 | + $this->file = glsr()->path( 'console.log' ); |
|
29 | + $this->log = file_exists( $this->file ) |
|
30 | + ? file_get_contents( $this->file ) |
|
31 | 31 | : ''; |
32 | 32 | $this->reset(); |
33 | 33 | } |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | * @param array $context |
48 | 48 | * @return static |
49 | 49 | */ |
50 | - public function alert($message, array $context = []) |
|
50 | + public function alert( $message, array $context = [] ) |
|
51 | 51 | { |
52 | - return $this->log(static::ALERT, $message, $context); |
|
52 | + return $this->log( static::ALERT, $message, $context ); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | public function clear() |
59 | 59 | { |
60 | 60 | $this->log = ''; |
61 | - file_put_contents($this->file, $this->log); |
|
61 | + file_put_contents( $this->file, $this->log ); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | * @param array $context |
69 | 69 | * @return static |
70 | 70 | */ |
71 | - public function critical($message, array $context = []) |
|
71 | + public function critical( $message, array $context = [] ) |
|
72 | 72 | { |
73 | - return $this->log(static::CRITICAL, $message, $context); |
|
73 | + return $this->log( static::CRITICAL, $message, $context ); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | * @param array $context |
80 | 80 | * @return static |
81 | 81 | */ |
82 | - public function debug($message, array $context = []) |
|
82 | + public function debug( $message, array $context = [] ) |
|
83 | 83 | { |
84 | - return $this->log(static::DEBUG, $message, $context); |
|
84 | + return $this->log( static::DEBUG, $message, $context ); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | * @param array $context |
91 | 91 | * @return static |
92 | 92 | */ |
93 | - public function emergency($message, array $context = []) |
|
93 | + public function emergency( $message, array $context = [] ) |
|
94 | 94 | { |
95 | - return $this->log(static::EMERGENCY, $message, $context); |
|
95 | + return $this->log( static::EMERGENCY, $message, $context ); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | * @param array $context |
102 | 102 | * @return static |
103 | 103 | */ |
104 | - public function error($message, array $context = []) |
|
104 | + public function error( $message, array $context = [] ) |
|
105 | 105 | { |
106 | - return $this->log(static::ERROR, $message, $context); |
|
106 | + return $this->log( static::ERROR, $message, $context ); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | public function get() |
113 | 113 | { |
114 | 114 | return empty($this->log) |
115 | - ? __('Console is empty', 'site-reviews') |
|
115 | + ? __( 'Console is empty', 'site-reviews' ) |
|
116 | 116 | : $this->log; |
117 | 117 | } |
118 | 118 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function getLevel() |
123 | 123 | { |
124 | - return intval(apply_filters('site-reviews/console/level', static::INFO)); |
|
124 | + return intval( apply_filters( 'site-reviews/console/level', static::INFO ) ); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function getLevels() |
131 | 131 | { |
132 | - $constants = (new ReflectionClass(__CLASS__))->getConstants(); |
|
133 | - return array_map('strtolower', array_flip($constants)); |
|
132 | + $constants = (new ReflectionClass( __CLASS__ ))->getConstants(); |
|
133 | + return array_map( 'strtolower', array_flip( $constants ) ); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -139,21 +139,21 @@ discard block |
||
139 | 139 | public function humanLevel() |
140 | 140 | { |
141 | 141 | $level = $this->getLevel(); |
142 | - return sprintf('%s (%d)', strtoupper(Arr::get($this->getLevels(), $level, 'unknown')), $level); |
|
142 | + return sprintf( '%s (%d)', strtoupper( Arr::get( $this->getLevels(), $level, 'unknown' ) ), $level ); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
146 | 146 | * @param string|null $valueIfEmpty |
147 | 147 | * @return string |
148 | 148 | */ |
149 | - public function humanSize($valueIfEmpty = null) |
|
149 | + public function humanSize( $valueIfEmpty = null ) |
|
150 | 150 | { |
151 | 151 | $bytes = $this->size(); |
152 | - if (empty($bytes) && is_string($valueIfEmpty)) { |
|
152 | + if( empty($bytes) && is_string( $valueIfEmpty ) ) { |
|
153 | 153 | return $valueIfEmpty; |
154 | 154 | } |
155 | - $exponent = floor(log(max($bytes, 1), 1024)); |
|
156 | - return round($bytes / pow(1024, $exponent), 2).' '.['bytes', 'KB', 'MB', 'GB'][$exponent]; |
|
155 | + $exponent = floor( log( max( $bytes, 1 ), 1024 ) ); |
|
156 | + return round( $bytes / pow( 1024, $exponent ), 2 ).' '.['bytes', 'KB', 'MB', 'GB'][$exponent]; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | * @param array $context |
164 | 164 | * @return static |
165 | 165 | */ |
166 | - public function info($message, array $context = []) |
|
166 | + public function info( $message, array $context = [] ) |
|
167 | 167 | { |
168 | - return $this->log(static::INFO, $message, $context); |
|
168 | + return $this->log( static::INFO, $message, $context ); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -175,19 +175,19 @@ discard block |
||
175 | 175 | * @param string $backtraceLine |
176 | 176 | * @return static |
177 | 177 | */ |
178 | - public function log($level, $message, $context = [], $backtraceLine = '') |
|
178 | + public function log( $level, $message, $context = [], $backtraceLine = '' ) |
|
179 | 179 | { |
180 | - if (empty($backtraceLine)) { |
|
180 | + if( empty($backtraceLine) ) { |
|
181 | 181 | $backtraceLine = $this->getBacktraceLine(); |
182 | 182 | } |
183 | - if ($this->canLogEntry($level, $backtraceLine)) { |
|
184 | - $levelName = Arr::get($this->getLevels(), $level); |
|
185 | - $context = Arr::consolidateArray($context); |
|
186 | - $backtraceLine = $this->normalizeBacktraceLine($backtraceLine); |
|
187 | - $message = $this->interpolate($message, $context); |
|
188 | - $entry = $this->buildLogEntry($levelName, $message, $backtraceLine); |
|
189 | - file_put_contents($this->file, $entry.PHP_EOL, FILE_APPEND | LOCK_EX); |
|
190 | - apply_filters('console', $message, $levelName, $backtraceLine); // Show in Blackbar plugin if installed |
|
183 | + if( $this->canLogEntry( $level, $backtraceLine ) ) { |
|
184 | + $levelName = Arr::get( $this->getLevels(), $level ); |
|
185 | + $context = Arr::consolidateArray( $context ); |
|
186 | + $backtraceLine = $this->normalizeBacktraceLine( $backtraceLine ); |
|
187 | + $message = $this->interpolate( $message, $context ); |
|
188 | + $entry = $this->buildLogEntry( $levelName, $message, $backtraceLine ); |
|
189 | + file_put_contents( $this->file, $entry.PHP_EOL, FILE_APPEND | LOCK_EX ); |
|
190 | + apply_filters( 'console', $message, $levelName, $backtraceLine ); // Show in Blackbar plugin if installed |
|
191 | 191 | $this->reset(); |
192 | 192 | } |
193 | 193 | return $this; |
@@ -198,17 +198,17 @@ discard block |
||
198 | 198 | */ |
199 | 199 | public function logOnce() |
200 | 200 | { |
201 | - $once = Arr::consolidateArray(glsr()->{$this->logOnceKey}); |
|
201 | + $once = Arr::consolidateArray( glsr()->{$this->logOnceKey}); |
|
202 | 202 | $levels = $this->getLevels(); |
203 | - foreach ($once as $entry) { |
|
204 | - $levelName = Arr::get($entry, 'level'); |
|
205 | - if (!in_array($levelName, $levels)) { |
|
203 | + foreach( $once as $entry ) { |
|
204 | + $levelName = Arr::get( $entry, 'level' ); |
|
205 | + if( !in_array( $levelName, $levels ) ) { |
|
206 | 206 | continue; |
207 | 207 | } |
208 | - $level = Arr::get(array_flip($levels), $levelName); |
|
209 | - $message = Arr::get($entry, 'message'); |
|
210 | - $backtraceLine = Arr::get($entry, 'backtrace'); |
|
211 | - $this->log($level, $message, [], $backtraceLine); |
|
208 | + $level = Arr::get( array_flip( $levels ), $levelName ); |
|
209 | + $message = Arr::get( $entry, 'message' ); |
|
210 | + $backtraceLine = Arr::get( $entry, 'backtrace' ); |
|
211 | + $this->log( $level, $message, [], $backtraceLine ); |
|
212 | 212 | } |
213 | 213 | glsr()->{$this->logOnceKey} = []; |
214 | 214 | } |
@@ -219,9 +219,9 @@ discard block |
||
219 | 219 | * @param array $context |
220 | 220 | * @return static |
221 | 221 | */ |
222 | - public function notice($message, array $context = []) |
|
222 | + public function notice( $message, array $context = [] ) |
|
223 | 223 | { |
224 | - return $this->log(static::NOTICE, $message, $context); |
|
224 | + return $this->log( static::NOTICE, $message, $context ); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -230,21 +230,21 @@ discard block |
||
230 | 230 | * @param mixed $data |
231 | 231 | * @return void |
232 | 232 | */ |
233 | - public function once($levelName, $handle, $data) |
|
233 | + public function once( $levelName, $handle, $data ) |
|
234 | 234 | { |
235 | - $once = Arr::consolidateArray(glsr()->{$this->logOnceKey}); |
|
236 | - $filtered = array_filter($once, function ($entry) use ($levelName, $handle) { |
|
237 | - return Arr::get($entry, 'level') == $levelName |
|
238 | - && Arr::get($entry, 'handle') == $handle; |
|
235 | + $once = Arr::consolidateArray( glsr()->{$this->logOnceKey}); |
|
236 | + $filtered = array_filter( $once, function( $entry ) use ($levelName, $handle) { |
|
237 | + return Arr::get( $entry, 'level' ) == $levelName |
|
238 | + && Arr::get( $entry, 'handle' ) == $handle; |
|
239 | 239 | }); |
240 | - if (!empty($filtered)) { |
|
240 | + if( !empty($filtered) ) { |
|
241 | 241 | return; |
242 | 242 | } |
243 | 243 | $once[] = [ |
244 | - 'backtrace' => $this->getBacktraceLineFromData($data), |
|
244 | + 'backtrace' => $this->getBacktraceLineFromData( $data ), |
|
245 | 245 | 'handle' => $handle, |
246 | 246 | 'level' => $levelName, |
247 | - 'message' => '[RECURRING] '.$this->getMessageFromData($data), |
|
247 | + 'message' => '[RECURRING] '.$this->getMessageFromData( $data ), |
|
248 | 248 | ]; |
249 | 249 | glsr()->{$this->logOnceKey} = $once; |
250 | 250 | } |
@@ -254,8 +254,8 @@ discard block |
||
254 | 254 | */ |
255 | 255 | public function size() |
256 | 256 | { |
257 | - return file_exists($this->file) |
|
258 | - ? filesize($this->file) |
|
257 | + return file_exists( $this->file ) |
|
258 | + ? filesize( $this->file ) |
|
259 | 259 | : 0; |
260 | 260 | } |
261 | 261 | |
@@ -266,9 +266,9 @@ discard block |
||
266 | 266 | * @param array $context |
267 | 267 | * @return static |
268 | 268 | */ |
269 | - public function warning($message, array $context = []) |
|
269 | + public function warning( $message, array $context = [] ) |
|
270 | 270 | { |
271 | - return $this->log(static::WARNING, $message, $context); |
|
271 | + return $this->log( static::WARNING, $message, $context ); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -276,11 +276,11 @@ discard block |
||
276 | 276 | * @param int $index |
277 | 277 | * @return string |
278 | 278 | */ |
279 | - protected function buildBacktraceLine($backtrace, $index) |
|
279 | + protected function buildBacktraceLine( $backtrace, $index ) |
|
280 | 280 | { |
281 | - return sprintf('%s:%s', |
|
282 | - Arr::get($backtrace, $index.'.file'), // realpath |
|
283 | - Arr::get($backtrace, $index.'.line') |
|
281 | + return sprintf( '%s:%s', |
|
282 | + Arr::get( $backtrace, $index.'.file' ), // realpath |
|
283 | + Arr::get( $backtrace, $index.'.line' ) |
|
284 | 284 | ); |
285 | 285 | } |
286 | 286 | |
@@ -290,11 +290,11 @@ discard block |
||
290 | 290 | * @param string $backtraceLine |
291 | 291 | * @return string |
292 | 292 | */ |
293 | - protected function buildLogEntry($levelName, $message, $backtraceLine = '') |
|
293 | + protected function buildLogEntry( $levelName, $message, $backtraceLine = '' ) |
|
294 | 294 | { |
295 | - return sprintf('[%s] %s [%s] %s', |
|
296 | - current_time('mysql'), |
|
297 | - strtoupper($levelName), |
|
295 | + return sprintf( '[%s] %s [%s] %s', |
|
296 | + current_time( 'mysql' ), |
|
297 | + strtoupper( $levelName ), |
|
298 | 298 | $backtraceLine, |
299 | 299 | $message |
300 | 300 | ); |
@@ -304,10 +304,10 @@ discard block |
||
304 | 304 | * @param int $level |
305 | 305 | * @return bool |
306 | 306 | */ |
307 | - protected function canLogEntry($level, $backtraceLine) |
|
307 | + protected function canLogEntry( $level, $backtraceLine ) |
|
308 | 308 | { |
309 | - $levelExists = array_key_exists($level, $this->getLevels()); |
|
310 | - if (!Str::contains($backtraceLine, glsr()->path())) { |
|
309 | + $levelExists = array_key_exists( $level, $this->getLevels() ); |
|
310 | + if( !Str::contains( $backtraceLine, glsr()->path() ) ) { |
|
311 | 311 | return $levelExists; // ignore level restriction if triggered outside of the plugin |
312 | 312 | } |
313 | 313 | return $levelExists && $level >= $this->getLevel(); |
@@ -318,17 +318,17 @@ discard block |
||
318 | 318 | */ |
319 | 319 | protected function getBacktraceLine() |
320 | 320 | { |
321 | - $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 6); |
|
322 | - $search = array_search('glsr_log', glsr_array_column($backtrace, 'function')); |
|
323 | - if (false !== $search) { |
|
324 | - return $this->buildBacktraceLine($backtrace, (int) $search); |
|
321 | + $backtrace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 6 ); |
|
322 | + $search = array_search( 'glsr_log', glsr_array_column( $backtrace, 'function' ) ); |
|
323 | + if( false !== $search ) { |
|
324 | + return $this->buildBacktraceLine( $backtrace, (int)$search ); |
|
325 | 325 | } |
326 | - $search = array_search('log', glsr_array_column($backtrace, 'function')); |
|
327 | - if (false !== $search) { |
|
328 | - $index = '{closure}' == Arr::get($backtrace, ($search + 2).'.function') |
|
326 | + $search = array_search( 'log', glsr_array_column( $backtrace, 'function' ) ); |
|
327 | + if( false !== $search ) { |
|
328 | + $index = '{closure}' == Arr::get( $backtrace, ($search + 2).'.function' ) |
|
329 | 329 | ? $search + 4 |
330 | 330 | : $search + 1; |
331 | - return $this->buildBacktraceLine($backtrace, $index); |
|
331 | + return $this->buildBacktraceLine( $backtrace, $index ); |
|
332 | 332 | } |
333 | 333 | return 'Unknown'; |
334 | 334 | } |
@@ -337,23 +337,23 @@ discard block |
||
337 | 337 | * @param mixed $data |
338 | 338 | * @return string |
339 | 339 | */ |
340 | - protected function getBacktraceLineFromData($data) |
|
340 | + protected function getBacktraceLineFromData( $data ) |
|
341 | 341 | { |
342 | 342 | $backtrace = $data instanceof Throwable |
343 | 343 | ? $data->getTrace() |
344 | - : debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1); |
|
345 | - return $this->buildBacktraceLine($backtrace, 0); |
|
344 | + : debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 1 ); |
|
345 | + return $this->buildBacktraceLine( $backtrace, 0 ); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
349 | 349 | * @param mixed $data |
350 | 350 | * @return string |
351 | 351 | */ |
352 | - protected function getMessageFromData($data) |
|
352 | + protected function getMessageFromData( $data ) |
|
353 | 353 | { |
354 | 354 | return $data instanceof Throwable |
355 | - ? $this->normalizeThrowableMessage($data->getMessage()) |
|
356 | - : print_r($data, 1); |
|
355 | + ? $this->normalizeThrowableMessage( $data->getMessage() ) |
|
356 | + : print_r( $data, 1 ); |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | /** |
@@ -362,53 +362,53 @@ discard block |
||
362 | 362 | * @param array $context |
363 | 363 | * @return string |
364 | 364 | */ |
365 | - protected function interpolate($message, $context = []) |
|
365 | + protected function interpolate( $message, $context = [] ) |
|
366 | 366 | { |
367 | - if ($this->isObjectOrArray($message) || !is_array($context)) { |
|
368 | - return print_r($message, true); |
|
367 | + if( $this->isObjectOrArray( $message ) || !is_array( $context ) ) { |
|
368 | + return print_r( $message, true ); |
|
369 | 369 | } |
370 | 370 | $replace = []; |
371 | - foreach ($context as $key => $value) { |
|
372 | - $replace['{'.$key.'}'] = $this->normalizeValue($value); |
|
371 | + foreach( $context as $key => $value ) { |
|
372 | + $replace['{'.$key.'}'] = $this->normalizeValue( $value ); |
|
373 | 373 | } |
374 | - return strtr($message, $replace); |
|
374 | + return strtr( $message, $replace ); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | /** |
378 | 378 | * @param mixed $value |
379 | 379 | * @return bool |
380 | 380 | */ |
381 | - protected function isObjectOrArray($value) |
|
381 | + protected function isObjectOrArray( $value ) |
|
382 | 382 | { |
383 | - return is_object($value) || is_array($value); |
|
383 | + return is_object( $value ) || is_array( $value ); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | /** |
387 | 387 | * @param string $backtraceLine |
388 | 388 | * @return string |
389 | 389 | */ |
390 | - protected function normalizeBacktraceLine($backtraceLine) |
|
390 | + protected function normalizeBacktraceLine( $backtraceLine ) |
|
391 | 391 | { |
392 | 392 | $search = [ |
393 | - glsr()->path('plugin/'), |
|
394 | - glsr()->path('plugin/', false), |
|
395 | - trailingslashit(glsr()->path()), |
|
396 | - trailingslashit(glsr()->path('', false)), |
|
393 | + glsr()->path( 'plugin/' ), |
|
394 | + glsr()->path( 'plugin/', false ), |
|
395 | + trailingslashit( glsr()->path() ), |
|
396 | + trailingslashit( glsr()->path( '', false ) ), |
|
397 | 397 | WP_CONTENT_DIR, |
398 | 398 | ABSPATH, |
399 | 399 | ]; |
400 | - return str_replace(array_unique($search), '', $backtraceLine); |
|
400 | + return str_replace( array_unique( $search ), '', $backtraceLine ); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | /** |
404 | 404 | * @param string $message |
405 | 405 | * @return string |
406 | 406 | */ |
407 | - protected function normalizeThrowableMessage($message) |
|
407 | + protected function normalizeThrowableMessage( $message ) |
|
408 | 408 | { |
409 | - $calledIn = strpos($message, ', called in'); |
|
409 | + $calledIn = strpos( $message, ', called in' ); |
|
410 | 410 | return false !== $calledIn |
411 | - ? substr($message, 0, $calledIn) |
|
411 | + ? substr( $message, 0, $calledIn ) |
|
412 | 412 | : $message; |
413 | 413 | } |
414 | 414 | |
@@ -416,14 +416,14 @@ discard block |
||
416 | 416 | * @param mixed $value |
417 | 417 | * @return string |
418 | 418 | */ |
419 | - protected function normalizeValue($value) |
|
419 | + protected function normalizeValue( $value ) |
|
420 | 420 | { |
421 | - if ($value instanceof DateTime) { |
|
422 | - $value = $value->format('Y-m-d H:i:s'); |
|
423 | - } elseif ($this->isObjectOrArray($value)) { |
|
424 | - $value = json_encode($value); |
|
421 | + if( $value instanceof DateTime ) { |
|
422 | + $value = $value->format( 'Y-m-d H:i:s' ); |
|
423 | + } elseif( $this->isObjectOrArray( $value ) ) { |
|
424 | + $value = json_encode( $value ); |
|
425 | 425 | } |
426 | - return (string) $value; |
|
426 | + return (string)$value; |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | /** |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | */ |
432 | 432 | protected function reset() |
433 | 433 | { |
434 | - if ($this->size() <= pow(1024, 2) / 8) { |
|
434 | + if( $this->size() <= pow( 1024, 2 ) / 8 ) { |
|
435 | 435 | return; |
436 | 436 | } |
437 | 437 | $this->clear(); |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | $this->file, |
440 | 440 | $this->buildLogEntry( |
441 | 441 | static::NOTICE, |
442 | - __('Console was automatically cleared (128 KB maximum size)', 'site-reviews') |
|
442 | + __( 'Console was automatically cleared (128 KB maximum size)', 'site-reviews' ) |
|
443 | 443 | ) |
444 | 444 | ); |
445 | 445 | } |
@@ -1,136 +1,136 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -defined('WPINC') || die; |
|
3 | +defined( 'WPINC' ) || die; |
|
4 | 4 | |
5 | -if (apply_filters('site-reviews/support/deprecated/v4', true)) { |
|
5 | +if( apply_filters( 'site-reviews/support/deprecated/v4', true ) ) { |
|
6 | 6 | // Unprotected review meta has been deprecated |
7 | - add_filter('get_post_metadata', function ($data, $postId, $metaKey, $single) { |
|
8 | - $metaKeys = array_keys(glsr('Defaults\CreateReviewDefaults')->defaults()); |
|
9 | - if (!in_array($metaKey, $metaKeys) || glsr()->post_type != get_post_type($postId)) { |
|
7 | + add_filter( 'get_post_metadata', function( $data, $postId, $metaKey, $single ) { |
|
8 | + $metaKeys = array_keys( glsr( 'Defaults\CreateReviewDefaults' )->defaults() ); |
|
9 | + if( !in_array( $metaKey, $metaKeys ) || glsr()->post_type != get_post_type( $postId ) ) { |
|
10 | 10 | return $data; |
11 | 11 | } |
12 | 12 | glsr()->deprecated[] = sprintf( |
13 | 13 | 'The "%1$s" meta_key has been deprecated for Reviews. Please use the protected "_%1$s" meta_key instead.', |
14 | 14 | $metaKey |
15 | 15 | ); |
16 | - return get_post_meta($postId, '_'.$metaKey, $single); |
|
17 | - }, 10, 4); |
|
16 | + return get_post_meta( $postId, '_'.$metaKey, $single ); |
|
17 | + }, 10, 4 ); |
|
18 | 18 | |
19 | 19 | // Modules/Html/Template.php |
20 | - add_filter('site-reviews/interpolate/reviews', function ($context, $template) { |
|
20 | + add_filter( 'site-reviews/interpolate/reviews', function( $context, $template ) { |
|
21 | 21 | $search = '{{ navigation }}'; |
22 | - if (false !== strpos($template, $search)) { |
|
22 | + if( false !== strpos( $template, $search ) ) { |
|
23 | 23 | $context['navigation'] = $context['pagination']; |
24 | 24 | glsr()->deprecated[] = 'The {{ navigation }} template key in "YOUR_THEME/site-reviews/reviews.php" has been deprecated. Please use the {{ pagination }} template key instead.'; |
25 | 25 | } |
26 | 26 | return $context; |
27 | - }, 10, 2); |
|
27 | + }, 10, 2 ); |
|
28 | 28 | |
29 | 29 | // Database/ReviewManager.php |
30 | - add_action('site-reviews/review/created', function ($review) { |
|
31 | - if (has_action('site-reviews/local/review/create')) { |
|
30 | + add_action( 'site-reviews/review/created', function( $review ) { |
|
31 | + if( has_action( 'site-reviews/local/review/create' ) ) { |
|
32 | 32 | glsr()->deprecated[] = 'The "site-reviews/local/review/create" hook has been deprecated. Please use the "site-reviews/review/created" hook instead.'; |
33 | - do_action('site-reviews/local/review/create', (array) get_post($review->ID), (array) $review, $review->ID); |
|
33 | + do_action( 'site-reviews/local/review/create', (array)get_post( $review->ID ), (array)$review, $review->ID ); |
|
34 | 34 | } |
35 | - }, 9); |
|
35 | + }, 9 ); |
|
36 | 36 | |
37 | 37 | // Handlers/CreateReview.php |
38 | - add_action('site-reviews/review/submitted', function ($review) { |
|
39 | - if (has_action('site-reviews/local/review/submitted')) { |
|
38 | + add_action( 'site-reviews/review/submitted', function( $review ) { |
|
39 | + if( has_action( 'site-reviews/local/review/submitted' ) ) { |
|
40 | 40 | glsr()->deprecated[] = 'The "site-reviews/local/review/submitted" hook has been deprecated. Please use the "site-reviews/review/submitted" hook instead.'; |
41 | - do_action('site-reviews/local/review/submitted', null, $review); |
|
41 | + do_action( 'site-reviews/local/review/submitted', null, $review ); |
|
42 | 42 | } |
43 | - if (has_filter('site-reviews/local/review/submitted/message')) { |
|
43 | + if( has_filter( 'site-reviews/local/review/submitted/message' ) ) { |
|
44 | 44 | glsr()->deprecated[] = 'The "site-reviews/local/review/submitted/message" hook has been deprecated.'; |
45 | 45 | } |
46 | - }, 9); |
|
46 | + }, 9 ); |
|
47 | 47 | |
48 | 48 | // Database/ReviewManager.php |
49 | - add_filter('site-reviews/create/review-values', function ($values, $command) { |
|
50 | - if (has_filter('site-reviews/local/review')) { |
|
49 | + add_filter( 'site-reviews/create/review-values', function( $values, $command ) { |
|
50 | + if( has_filter( 'site-reviews/local/review' ) ) { |
|
51 | 51 | glsr()->deprecated[] = 'The "site-reviews/local/review" hook has been deprecated. Please use the "site-reviews/create/review-values" hook instead.'; |
52 | - return apply_filters('site-reviews/local/review', $values, $command); |
|
52 | + return apply_filters( 'site-reviews/local/review', $values, $command ); |
|
53 | 53 | } |
54 | 54 | return $values; |
55 | - }, 9, 2); |
|
55 | + }, 9, 2 ); |
|
56 | 56 | |
57 | 57 | // Handlers/EnqueuePublicAssets.php |
58 | - add_filter('site-reviews/enqueue/public/localize', function ($variables) { |
|
59 | - if (has_filter('site-reviews/enqueue/localize')) { |
|
58 | + add_filter( 'site-reviews/enqueue/public/localize', function( $variables ) { |
|
59 | + if( has_filter( 'site-reviews/enqueue/localize' ) ) { |
|
60 | 60 | glsr()->deprecated[] = 'The "site-reviews/enqueue/localize" hook has been deprecated. Please use the "site-reviews/enqueue/public/localize" hook instead.'; |
61 | - return apply_filters('site-reviews/enqueue/localize', $variables); |
|
61 | + return apply_filters( 'site-reviews/enqueue/localize', $variables ); |
|
62 | 62 | } |
63 | 63 | return $variables; |
64 | - }, 9); |
|
64 | + }, 9 ); |
|
65 | 65 | |
66 | 66 | // Modules/Rating.php |
67 | - add_filter('site-reviews/rating/average', function ($average) { |
|
68 | - if (has_filter('site-reviews/average/rating')) { |
|
67 | + add_filter( 'site-reviews/rating/average', function( $average ) { |
|
68 | + if( has_filter( 'site-reviews/average/rating' ) ) { |
|
69 | 69 | glsr()->deprecated[] = 'The "site-reviews/average/rating" hook has been deprecated. Please use the "site-reviews/rating/average" hook instead.'; |
70 | 70 | } |
71 | 71 | return $average; |
72 | - }, 9); |
|
72 | + }, 9 ); |
|
73 | 73 | |
74 | 74 | // Modules/Rating.php |
75 | - add_filter('site-reviews/rating/ranking', function ($ranking) { |
|
76 | - if (has_filter('site-reviews/bayesian/ranking')) { |
|
75 | + add_filter( 'site-reviews/rating/ranking', function( $ranking ) { |
|
76 | + if( has_filter( 'site-reviews/bayesian/ranking' ) ) { |
|
77 | 77 | glsr()->deprecated[] = 'The "site-reviews/bayesian/ranking" hook has been deprecated. Please use the "site-reviews/rating/ranking" hook instead.'; |
78 | 78 | } |
79 | 79 | return $ranking; |
80 | - }, 9); |
|
80 | + }, 9 ); |
|
81 | 81 | |
82 | 82 | // Modules/Html/Partials/SiteReviews.php |
83 | - add_filter('site-reviews/review/build/after', function ($renderedFields) { |
|
84 | - if (has_filter('site-reviews/reviews/review/text')) { |
|
83 | + add_filter( 'site-reviews/review/build/after', function( $renderedFields ) { |
|
84 | + if( has_filter( 'site-reviews/reviews/review/text' ) ) { |
|
85 | 85 | glsr()->deprecated[] = 'The "site-reviews/reviews/review/text" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.'; |
86 | 86 | } |
87 | - if (has_filter('site-reviews/reviews/review/title')) { |
|
87 | + if( has_filter( 'site-reviews/reviews/review/title' ) ) { |
|
88 | 88 | glsr()->deprecated[] = 'The "site-reviews/reviews/review/title" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.'; |
89 | 89 | } |
90 | 90 | return $renderedFields; |
91 | - }, 9); |
|
91 | + }, 9 ); |
|
92 | 92 | |
93 | 93 | // Modules/Html/Partials/SiteReviews.php |
94 | - add_filter('site-reviews/review/build/before', function ($review) { |
|
95 | - if (has_filter('site-reviews/rendered/review')) { |
|
94 | + add_filter( 'site-reviews/review/build/before', function( $review ) { |
|
95 | + if( has_filter( 'site-reviews/rendered/review' ) ) { |
|
96 | 96 | glsr()->deprecated[] = 'The "site-reviews/rendered/review" hook has been deprecated. Please either use a custom "review.php" template (refer to the documentation), or use the "site-reviews/review/build/after" hook instead.'; |
97 | 97 | } |
98 | - if (has_filter('site-reviews/rendered/review/meta/order')) { |
|
98 | + if( has_filter( 'site-reviews/rendered/review/meta/order' ) ) { |
|
99 | 99 | glsr()->deprecated[] = 'The "site-reviews/rendered/review/meta/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).'; |
100 | 100 | } |
101 | - if (has_filter('site-reviews/rendered/review/order')) { |
|
101 | + if( has_filter( 'site-reviews/rendered/review/order' ) ) { |
|
102 | 102 | glsr()->deprecated[] = 'The "site-reviews/rendered/review/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).'; |
103 | 103 | } |
104 | - if (has_filter('site-reviews/rendered/review-form/login-register')) { |
|
104 | + if( has_filter( 'site-reviews/rendered/review-form/login-register' ) ) { |
|
105 | 105 | glsr()->deprecated[] = 'The "site-reviews/rendered/review-form/login-register" hook has been deprecated. Please use a custom "login-register.php" template instead (refer to the documentation).'; |
106 | 106 | } |
107 | - if (has_filter('site-reviews/reviews/navigation_links')) { |
|
107 | + if( has_filter( 'site-reviews/reviews/navigation_links' ) ) { |
|
108 | 108 | glsr()->deprecated[] = 'The "site-reviews/reviews/navigation_links" hook has been deprecated. Please use a custom "pagination.php" template instead (refer to the documentation).'; |
109 | 109 | } |
110 | 110 | return $review; |
111 | - }, 9); |
|
111 | + }, 9 ); |
|
112 | 112 | |
113 | - add_filter('site-reviews/validate/custom', function ($result, $request) { |
|
114 | - if (has_filter('site-reviews/validate/review/submission')) { |
|
115 | - glsr_log()->warning('The "site-reviews/validate/review/submission" hook has been deprecated. Please use the "site-reviews/validate/custom" hook instead.'); |
|
116 | - return apply_filters('site-reviews/validate/review/submission', $result, $request); |
|
113 | + add_filter( 'site-reviews/validate/custom', function( $result, $request ) { |
|
114 | + if( has_filter( 'site-reviews/validate/review/submission' ) ) { |
|
115 | + glsr_log()->warning( 'The "site-reviews/validate/review/submission" hook has been deprecated. Please use the "site-reviews/validate/custom" hook instead.' ); |
|
116 | + return apply_filters( 'site-reviews/validate/review/submission', $result, $request ); |
|
117 | 117 | } |
118 | 118 | return $result; |
119 | - }, 9, 2); |
|
119 | + }, 9, 2 ); |
|
120 | 120 | |
121 | - add_filter('site-reviews/views/file', function ($file, $view, $data) { |
|
122 | - if (has_filter('site-reviews/addon/views/file')) { |
|
121 | + add_filter( 'site-reviews/views/file', function( $file, $view, $data ) { |
|
122 | + if( has_filter( 'site-reviews/addon/views/file' ) ) { |
|
123 | 123 | glsr()->deprecated[] = 'The "site-reviews/addon/views/file" hook has been deprecated. Please use the "site-reviews/views/file" hook instead.'; |
124 | - $file = apply_filters('site-reviews/addon/views/file', $file, $view, $data); |
|
124 | + $file = apply_filters( 'site-reviews/addon/views/file', $file, $view, $data ); |
|
125 | 125 | } |
126 | 126 | return $file; |
127 | - }, 9, 3); |
|
127 | + }, 9, 3 ); |
|
128 | 128 | } |
129 | 129 | |
130 | -add_action('wp_footer', function () { |
|
131 | - $notices = array_keys(array_flip(glsr()->deprecated)); |
|
132 | - natsort($notices); |
|
133 | - foreach ($notices as $notice) { |
|
134 | - glsr_log()->warning($notice); |
|
130 | +add_action( 'wp_footer', function() { |
|
131 | + $notices = array_keys( array_flip( glsr()->deprecated ) ); |
|
132 | + natsort( $notices ); |
|
133 | + foreach( $notices as $notice ) { |
|
134 | + glsr_log()->warning( $notice ); |
|
135 | 135 | } |
136 | 136 | }); |
@@ -1,26 +1,26 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div id="titlediv"> |
4 | - <input type="text" id="title" value="<?= $post->post_title ? esc_attr($post->post_title) : sprintf('(%s)', __('no title', 'site-reviews')); ?>" readonly> |
|
4 | + <input type="text" id="title" value="<?= $post->post_title ? esc_attr( $post->post_title ) : sprintf( '(%s)', __( 'no title', 'site-reviews' ) ); ?>" readonly> |
|
5 | 5 | </div> |
6 | 6 | |
7 | 7 | <div id="contentdiv" class="wp-editor-container"> |
8 | - <textarea readonly><?= esc_attr($post->post_content); ?></textarea> |
|
8 | + <textarea readonly><?= esc_attr( $post->post_content ); ?></textarea> |
|
9 | 9 | </div> |
10 | 10 | |
11 | -<?php if (empty($response)) { |
|
11 | +<?php if( empty($response) ) { |
|
12 | 12 | return; |
13 | 13 | } ?> |
14 | 14 | |
15 | 15 | <div class="postbox glsr-response-postbox"> |
16 | 16 | <button type="button" class="handlediv" aria-expanded="true"> |
17 | - <span class="screen-reader-text"><?= __('Toggle panel: Public Response', 'site-reviews'); ?></span> |
|
17 | + <span class="screen-reader-text"><?= __( 'Toggle panel: Public Response', 'site-reviews' ); ?></span> |
|
18 | 18 | <span class="toggle-indicator" aria-hidden="true"></span> |
19 | 19 | </button> |
20 | 20 | <h2 class="hndle"> |
21 | - <span><?= __('Public Response', 'site-reviews'); ?></span> |
|
21 | + <span><?= __( 'Public Response', 'site-reviews' ); ?></span> |
|
22 | 22 | </h2> |
23 | 23 | <div class="inside"> |
24 | - <?= wpautop(esc_attr($response)); ?> |
|
24 | + <?= wpautop( esc_attr( $response ) ); ?> |
|
25 | 25 | </div> |
26 | 26 | </div> |
@@ -1,22 +1,22 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <textarea id="log-file" class="large-text code glsr-code glsr-code-large" rows="20" readonly>{{ console }}</textarea> |
4 | 4 | <form method="post" class="glsr-float-left"> |
5 | 5 | <input type="hidden" name="{{ id }}[_action]" value="download-console"> |
6 | - <?php wp_nonce_field('download-console'); ?> |
|
7 | - <?php submit_button(__('Download Console', 'site-reviews'), 'primary', '', false); ?> |
|
6 | + <?php wp_nonce_field( 'download-console' ); ?> |
|
7 | + <?php submit_button( __( 'Download Console', 'site-reviews' ), 'primary', '', false ); ?> |
|
8 | 8 | </form> |
9 | 9 | <form method="post" class="glsr-float-left"> |
10 | 10 | <input type="hidden" name="{{ id }}[_action]" value="fetch-console"> |
11 | - <?php wp_nonce_field('fetch-console'); ?> |
|
11 | + <?php wp_nonce_field( 'fetch-console' ); ?> |
|
12 | 12 | <button type="submit" class="glsr-button button" id="fetch-console"> |
13 | - <span data-loading="<?= __('Reloading...', 'site-reviews'); ?>"><?= __('Reload', 'site-reviews'); ?></span> |
|
13 | + <span data-loading="<?= __( 'Reloading...', 'site-reviews' ); ?>"><?= __( 'Reload', 'site-reviews' ); ?></span> |
|
14 | 14 | </button> |
15 | 15 | </form> |
16 | 16 | <form method="post"> |
17 | 17 | <input type="hidden" name="{{ id }}[_action]" value="clear-console"> |
18 | - <?php wp_nonce_field('clear-console'); ?> |
|
18 | + <?php wp_nonce_field( 'clear-console' ); ?> |
|
19 | 19 | <button type="submit" class="glsr-button button" id="clear-console"> |
20 | - <span data-loading="<?= __('Clearing...', 'site-reviews'); ?>"><?= __('Clear', 'site-reviews'); ?></span> |
|
20 | + <span data-loading="<?= __( 'Clearing...', 'site-reviews' ); ?>"><?= __( 'Clear', 'site-reviews' ); ?></span> |
|
21 | 21 | </button> |
22 | 22 | </form> |
@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * @return void |
20 | 20 | */ |
21 | - public function handle(Command $command) |
|
21 | + public function handle( Command $command ) |
|
22 | 22 | { |
23 | - $this->generatePointers($command->pointers); |
|
23 | + $this->generatePointers( $command->pointers ); |
|
24 | 24 | $this->enqueueAssets(); |
25 | 25 | $this->localizeAssets(); |
26 | 26 | } |
@@ -30,25 +30,25 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function enqueueAssets() |
32 | 32 | { |
33 | - if (!$this->isCurrentScreen()) { |
|
33 | + if( !$this->isCurrentScreen() ) { |
|
34 | 34 | return; |
35 | 35 | } |
36 | 36 | wp_enqueue_style( |
37 | 37 | Application::ID, |
38 | - glsr()->url('assets/styles/'.Application::ID.'-admin.css'), |
|
38 | + glsr()->url( 'assets/styles/'.Application::ID.'-admin.css' ), |
|
39 | 39 | [], |
40 | 40 | glsr()->version |
41 | 41 | ); |
42 | 42 | wp_enqueue_script( |
43 | 43 | Application::ID, |
44 | - glsr()->url('assets/scripts/'.Application::ID.'-admin.js'), |
|
44 | + glsr()->url( 'assets/scripts/'.Application::ID.'-admin.js' ), |
|
45 | 45 | $this->getDependencies(), |
46 | 46 | glsr()->version, |
47 | 47 | true |
48 | 48 | ); |
49 | - if (!empty($this->pointers)) { |
|
50 | - wp_enqueue_style('wp-pointer'); |
|
51 | - wp_enqueue_script('wp-pointer'); |
|
49 | + if( !empty($this->pointers) ) { |
|
50 | + wp_enqueue_style( 'wp-pointer' ); |
|
51 | + wp_enqueue_script( 'wp-pointer' ); |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
@@ -60,33 +60,33 @@ discard block |
||
60 | 60 | $variables = [ |
61 | 61 | 'action' => Application::PREFIX.'action', |
62 | 62 | 'addons' => [], |
63 | - 'ajaxurl' => admin_url('admin-ajax.php'), |
|
63 | + 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
|
64 | 64 | 'hideoptions' => [ |
65 | - 'site_reviews' => glsr(SiteReviewsShortcode::class)->getHideOptions(), |
|
66 | - 'site_reviews_form' => glsr(SiteReviewsFormShortcode::class)->getHideOptions(), |
|
67 | - 'site_reviews_summary' => glsr(SiteReviewsSummaryShortcode::class)->getHideOptions(), |
|
65 | + 'site_reviews' => glsr( SiteReviewsShortcode::class )->getHideOptions(), |
|
66 | + 'site_reviews_form' => glsr( SiteReviewsFormShortcode::class )->getHideOptions(), |
|
67 | + 'site_reviews_summary' => glsr( SiteReviewsSummaryShortcode::class )->getHideOptions(), |
|
68 | 68 | ], |
69 | 69 | 'nameprefix' => Application::ID, |
70 | 70 | 'nonce' => [ |
71 | - 'change-status' => wp_create_nonce('change-status'), |
|
72 | - 'clear-console' => wp_create_nonce('clear-console'), |
|
73 | - 'count-reviews' => wp_create_nonce('count-reviews'), |
|
74 | - 'fetch-console' => wp_create_nonce('fetch-console'), |
|
75 | - 'mce-shortcode' => wp_create_nonce('mce-shortcode'), |
|
76 | - 'sync-reviews' => wp_create_nonce('sync-reviews'), |
|
77 | - 'toggle-pinned' => wp_create_nonce('toggle-pinned'), |
|
71 | + 'change-status' => wp_create_nonce( 'change-status' ), |
|
72 | + 'clear-console' => wp_create_nonce( 'clear-console' ), |
|
73 | + 'count-reviews' => wp_create_nonce( 'count-reviews' ), |
|
74 | + 'fetch-console' => wp_create_nonce( 'fetch-console' ), |
|
75 | + 'mce-shortcode' => wp_create_nonce( 'mce-shortcode' ), |
|
76 | + 'sync-reviews' => wp_create_nonce( 'sync-reviews' ), |
|
77 | + 'toggle-pinned' => wp_create_nonce( 'toggle-pinned' ), |
|
78 | 78 | ], |
79 | 79 | 'pointers' => $this->pointers, |
80 | 80 | 'shortcodes' => [], |
81 | 81 | 'tinymce' => [ |
82 | - 'glsr_shortcode' => glsr()->url('assets/scripts/mce-plugin.js'), |
|
82 | + 'glsr_shortcode' => glsr()->url( 'assets/scripts/mce-plugin.js' ), |
|
83 | 83 | ], |
84 | 84 | ]; |
85 | - if (user_can_richedit()) { |
|
85 | + if( user_can_richedit() ) { |
|
86 | 86 | $variables['shortcodes'] = $this->localizeShortcodes(); |
87 | 87 | } |
88 | - $variables = apply_filters('site-reviews/enqueue/admin/localize', $variables); |
|
89 | - wp_localize_script(Application::ID, 'GLSR', $variables); |
|
88 | + $variables = apply_filters( 'site-reviews/enqueue/admin/localize', $variables ); |
|
89 | + wp_localize_script( Application::ID, 'GLSR', $variables ); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -94,17 +94,17 @@ discard block |
||
94 | 94 | */ |
95 | 95 | protected function getDependencies() |
96 | 96 | { |
97 | - $dependencies = apply_filters('site-reviews/enqueue/admin/dependencies', []); |
|
98 | - $dependencies = array_merge($dependencies, [ |
|
97 | + $dependencies = apply_filters( 'site-reviews/enqueue/admin/dependencies', [] ); |
|
98 | + $dependencies = array_merge( $dependencies, [ |
|
99 | 99 | 'jquery', 'jquery-ui-sortable', 'underscore', 'wp-util', |
100 | - ]); |
|
100 | + ] ); |
|
101 | 101 | return $dependencies; |
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
105 | 105 | * @return array |
106 | 106 | */ |
107 | - protected function generatePointer(array $pointer) |
|
107 | + protected function generatePointer( array $pointer ) |
|
108 | 108 | { |
109 | 109 | return [ |
110 | 110 | 'id' => $pointer['id'], |
@@ -120,19 +120,19 @@ discard block |
||
120 | 120 | /** |
121 | 121 | * @return void |
122 | 122 | */ |
123 | - protected function generatePointers(array $pointers) |
|
123 | + protected function generatePointers( array $pointers ) |
|
124 | 124 | { |
125 | - $dismissedPointers = get_user_meta(get_current_user_id(), 'dismissed_wp_pointers', true); |
|
126 | - $dismissedPointers = explode(',', (string) $dismissedPointers); |
|
125 | + $dismissedPointers = get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ); |
|
126 | + $dismissedPointers = explode( ',', (string)$dismissedPointers ); |
|
127 | 127 | $generatedPointers = []; |
128 | - foreach ($pointers as $pointer) { |
|
129 | - if ($pointer['screen'] != glsr_current_screen()->id) { |
|
128 | + foreach( $pointers as $pointer ) { |
|
129 | + if( $pointer['screen'] != glsr_current_screen()->id ) { |
|
130 | 130 | continue; |
131 | 131 | } |
132 | - if (in_array($pointer['id'], $dismissedPointers)) { |
|
132 | + if( in_array( $pointer['id'], $dismissedPointers ) ) { |
|
133 | 133 | continue; |
134 | 134 | } |
135 | - $generatedPointers[] = $this->generatePointer($pointer); |
|
135 | + $generatedPointers[] = $this->generatePointer( $pointer ); |
|
136 | 136 | } |
137 | 137 | $this->pointers = $generatedPointers; |
138 | 138 | } |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | protected function localizeShortcodes() |
157 | 157 | { |
158 | 158 | $variables = []; |
159 | - foreach (glsr()->mceShortcodes as $tag => $args) { |
|
160 | - if (empty($args['required'])) { |
|
159 | + foreach( glsr()->mceShortcodes as $tag => $args ) { |
|
160 | + if( empty($args['required']) ) { |
|
161 | 161 | continue; |
162 | 162 | } |
163 | 163 | $variables[$tag] = $args['required']; |