@@ -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 | } |
@@ -17,9 +17,9 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * @return void |
19 | 19 | */ |
20 | - public function routerChangeStatus(array $request) |
|
20 | + public function routerChangeStatus( array $request ) |
|
21 | 21 | { |
22 | - wp_send_json_success($this->execute(new ChangeStatus($request))); |
|
22 | + wp_send_json_success( $this->execute( new ChangeStatus( $request ) ) ); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function routerClearConsole() |
29 | 29 | { |
30 | - glsr(AdminController::class)->routerClearConsole(); |
|
31 | - wp_send_json_success([ |
|
32 | - 'console' => glsr(Console::class)->get(), |
|
33 | - 'notices' => glsr(Notice::class)->get(), |
|
34 | - ]); |
|
30 | + glsr( AdminController::class )->routerClearConsole(); |
|
31 | + wp_send_json_success( [ |
|
32 | + 'console' => glsr( Console::class )->get(), |
|
33 | + 'notices' => glsr( Notice::class )->get(), |
|
34 | + ] ); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -39,32 +39,32 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function routerCountReviews() |
41 | 41 | { |
42 | - glsr(AdminController::class)->routerCountReviews(); |
|
43 | - wp_send_json_success([ |
|
44 | - 'notices' => glsr(Notice::class)->get(), |
|
45 | - ]); |
|
42 | + glsr( AdminController::class )->routerCountReviews(); |
|
43 | + wp_send_json_success( [ |
|
44 | + 'notices' => glsr( Notice::class )->get(), |
|
45 | + ] ); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
49 | 49 | * @return void |
50 | 50 | */ |
51 | - public function routerDismissNotice(array $request) |
|
51 | + public function routerDismissNotice( array $request ) |
|
52 | 52 | { |
53 | - glsr(NoticeController::class)->routerDismissNotice($request); |
|
53 | + glsr( NoticeController::class )->routerDismissNotice( $request ); |
|
54 | 54 | wp_send_json_success(); |
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * @return void |
59 | 59 | */ |
60 | - public function routerMceShortcode(array $request) |
|
60 | + public function routerMceShortcode( array $request ) |
|
61 | 61 | { |
62 | 62 | $shortcode = $request['shortcode']; |
63 | 63 | $response = false; |
64 | - if (array_key_exists($shortcode, glsr()->mceShortcodes)) { |
|
64 | + if( array_key_exists( $shortcode, glsr()->mceShortcodes ) ) { |
|
65 | 65 | $data = glsr()->mceShortcodes[$shortcode]; |
66 | - if (!empty($data['errors'])) { |
|
67 | - $data['btn_okay'] = [esc_html__('Okay', 'site-reviews')]; |
|
66 | + if( !empty($data['errors']) ) { |
|
67 | + $data['btn_okay'] = [esc_html__( 'Okay', 'site-reviews' )]; |
|
68 | 68 | } |
69 | 69 | $response = [ |
70 | 70 | 'body' => $data['fields'], |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | 'title' => $data['title'], |
75 | 75 | ]; |
76 | 76 | } |
77 | - wp_send_json_success($response); |
|
77 | + wp_send_json_success( $response ); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -82,96 +82,96 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function routerFetchConsole() |
84 | 84 | { |
85 | - glsr(AdminController::class)->routerFetchConsole(); |
|
86 | - wp_send_json_success([ |
|
87 | - 'console' => glsr(Console::class)->get(), |
|
88 | - 'notices' => glsr(Notice::class)->get(), |
|
89 | - ]); |
|
85 | + glsr( AdminController::class )->routerFetchConsole(); |
|
86 | + wp_send_json_success( [ |
|
87 | + 'console' => glsr( Console::class )->get(), |
|
88 | + 'notices' => glsr( Notice::class )->get(), |
|
89 | + ] ); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
93 | 93 | * @return void |
94 | 94 | */ |
95 | - public function routerSearchPosts(array $request) |
|
95 | + public function routerSearchPosts( array $request ) |
|
96 | 96 | { |
97 | - $results = glsr(Database::class)->searchPosts($request['search']); |
|
98 | - wp_send_json_success([ |
|
99 | - 'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>', |
|
97 | + $results = glsr( Database::class )->searchPosts( $request['search'] ); |
|
98 | + wp_send_json_success( [ |
|
99 | + 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
|
100 | 100 | 'items' => $results, |
101 | - ]); |
|
101 | + ] ); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
105 | 105 | * @return void |
106 | 106 | */ |
107 | - public function routerSearchTranslations(array $request) |
|
107 | + public function routerSearchTranslations( array $request ) |
|
108 | 108 | { |
109 | - if (empty($request['exclude'])) { |
|
109 | + if( empty($request['exclude']) ) { |
|
110 | 110 | $request['exclude'] = []; |
111 | 111 | } |
112 | - $results = glsr(Translation::class) |
|
113 | - ->search($request['search']) |
|
112 | + $results = glsr( Translation::class ) |
|
113 | + ->search( $request['search'] ) |
|
114 | 114 | ->exclude() |
115 | - ->exclude($request['exclude']) |
|
115 | + ->exclude( $request['exclude'] ) |
|
116 | 116 | ->renderResults(); |
117 | - wp_send_json_success([ |
|
118 | - 'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>', |
|
117 | + wp_send_json_success( [ |
|
118 | + 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
|
119 | 119 | 'items' => $results, |
120 | - ]); |
|
120 | + ] ); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
124 | 124 | * @return void |
125 | 125 | */ |
126 | - public function routerSubmitReview(array $request) |
|
126 | + public function routerSubmitReview( array $request ) |
|
127 | 127 | { |
128 | - $command = glsr(PublicController::class)->routerSubmitReview($request); |
|
129 | - $redirect = trim(strval(get_post_meta($command->post_id, 'redirect_to', true))); |
|
130 | - $redirect = apply_filters('site-reviews/review/redirect', $redirect, $command); |
|
128 | + $command = glsr( PublicController::class )->routerSubmitReview( $request ); |
|
129 | + $redirect = trim( strval( get_post_meta( $command->post_id, 'redirect_to', true ) ) ); |
|
130 | + $redirect = apply_filters( 'site-reviews/review/redirect', $redirect, $command ); |
|
131 | 131 | $data = [ |
132 | - 'errors' => glsr()->sessionGet($command->form_id.'errors', false), |
|
133 | - 'message' => glsr()->sessionGet($command->form_id.'message', ''), |
|
134 | - 'recaptcha' => glsr()->sessionGet($command->form_id.'recaptcha', false), |
|
132 | + 'errors' => glsr()->sessionGet( $command->form_id.'errors', false ), |
|
133 | + 'message' => glsr()->sessionGet( $command->form_id.'message', '' ), |
|
134 | + 'recaptcha' => glsr()->sessionGet( $command->form_id.'recaptcha', false ), |
|
135 | 135 | 'redirect' => $redirect, |
136 | 136 | ]; |
137 | - if (false === $data['errors']) { |
|
137 | + if( false === $data['errors'] ) { |
|
138 | 138 | glsr()->sessionClear(); |
139 | - wp_send_json_success($data); |
|
139 | + wp_send_json_success( $data ); |
|
140 | 140 | } |
141 | - wp_send_json_error($data); |
|
141 | + wp_send_json_error( $data ); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
145 | 145 | * @return void |
146 | 146 | */ |
147 | - public function routerFetchPagedReviews(array $request) |
|
147 | + public function routerFetchPagedReviews( array $request ) |
|
148 | 148 | { |
149 | 149 | $urlQuery = []; |
150 | - parse_str(parse_url(Arr::get($request, 'url'), PHP_URL_QUERY), $urlQuery); |
|
150 | + parse_str( parse_url( Arr::get( $request, 'url' ), PHP_URL_QUERY ), $urlQuery ); |
|
151 | 151 | $args = [ |
152 | - 'paged' => Arr::get($urlQuery, glsr()->constant('PAGED_QUERY_VAR'), 1), |
|
153 | - 'pagedUrl' => home_url(parse_url(Arr::get($request, 'url'), PHP_URL_PATH)), |
|
152 | + 'paged' => Arr::get( $urlQuery, glsr()->constant( 'PAGED_QUERY_VAR' ), 1 ), |
|
153 | + 'pagedUrl' => home_url( parse_url( Arr::get( $request, 'url' ), PHP_URL_PATH ) ), |
|
154 | 154 | 'pagination' => 'ajax', |
155 | 155 | 'schema' => false, |
156 | 156 | ]; |
157 | - $atts = (array) json_decode(Arr::get($request, 'atts')); |
|
158 | - $atts = glsr(SiteReviewsShortcode::class)->normalizeAtts($atts); |
|
159 | - $html = glsr(SiteReviewsPartial::class)->build(wp_parse_args($args, $atts)); |
|
160 | - return wp_send_json_success([ |
|
157 | + $atts = (array)json_decode( Arr::get( $request, 'atts' ) ); |
|
158 | + $atts = glsr( SiteReviewsShortcode::class )->normalizeAtts( $atts ); |
|
159 | + $html = glsr( SiteReviewsPartial::class )->build( wp_parse_args( $args, $atts ) ); |
|
160 | + return wp_send_json_success( [ |
|
161 | 161 | 'pagination' => $html->getPagination(), |
162 | 162 | 'reviews' => $html->getReviews(), |
163 | - ]); |
|
163 | + ] ); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
167 | 167 | * @return void |
168 | 168 | */ |
169 | - public function routerTogglePinned(array $request) |
|
169 | + public function routerTogglePinned( array $request ) |
|
170 | 170 | { |
171 | - $isPinned = $this->execute(new TogglePinned($request)); |
|
172 | - wp_send_json_success([ |
|
173 | - 'notices' => glsr(Notice::class)->get(), |
|
171 | + $isPinned = $this->execute( new TogglePinned( $request ) ); |
|
172 | + wp_send_json_success( [ |
|
173 | + 'notices' => glsr( Notice::class )->get(), |
|
174 | 174 | 'pinned' => $isPinned, |
175 | - ]); |
|
175 | + ] ); |
|
176 | 176 | } |
177 | 177 | } |
@@ -16,19 +16,19 @@ discard block |
||
16 | 16 | * Build a WP_Query meta_query/tax_query. |
17 | 17 | * @return array |
18 | 18 | */ |
19 | - public function buildQuery(array $keys = [], array $values = []) |
|
19 | + public function buildQuery( array $keys = [], array $values = [] ) |
|
20 | 20 | { |
21 | 21 | $queries = []; |
22 | - foreach ($keys as $key) { |
|
23 | - if (!array_key_exists($key, $values)) { |
|
22 | + foreach( $keys as $key ) { |
|
23 | + if( !array_key_exists( $key, $values ) ) { |
|
24 | 24 | continue; |
25 | 25 | } |
26 | - $methodName = Helper::buildMethodName($key, __FUNCTION__); |
|
27 | - if (!method_exists($this, $methodName)) { |
|
26 | + $methodName = Helper::buildMethodName( $key, __FUNCTION__ ); |
|
27 | + if( !method_exists( $this, $methodName ) ) { |
|
28 | 28 | continue; |
29 | 29 | } |
30 | - $query = call_user_func([$this, $methodName], $values[$key]); |
|
31 | - if (is_array($query)) { |
|
30 | + $query = call_user_func( [$this, $methodName], $values[$key] ); |
|
31 | + if( is_array( $query ) ) { |
|
32 | 32 | $queries[] = $query; |
33 | 33 | } |
34 | 34 | } |
@@ -38,17 +38,17 @@ discard block |
||
38 | 38 | /** |
39 | 39 | * @return string |
40 | 40 | */ |
41 | - public function buildSqlLines(array $values, array $conditions) |
|
41 | + public function buildSqlLines( array $values, array $conditions ) |
|
42 | 42 | { |
43 | 43 | $string = ''; |
44 | - $values = array_filter($values); |
|
45 | - foreach ($conditions as $key => $value) { |
|
46 | - if (!isset($values[$key])) { |
|
44 | + $values = array_filter( $values ); |
|
45 | + foreach( $conditions as $key => $value ) { |
|
46 | + if( !isset($values[$key]) ) { |
|
47 | 47 | continue; |
48 | 48 | } |
49 | - $values[$key] = implode(',', (array) $values[$key]); |
|
50 | - $string.= Str::contains($value, '%s') |
|
51 | - ? sprintf($value, strval($values[$key])) |
|
49 | + $values[$key] = implode( ',', (array)$values[$key] ); |
|
50 | + $string .= Str::contains( $value, '%s' ) |
|
51 | + ? sprintf( $value, strval( $values[$key] ) ) |
|
52 | 52 | : $value; |
53 | 53 | } |
54 | 54 | return $string; |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | * @param string $sprintfFormat |
61 | 61 | * @return string |
62 | 62 | */ |
63 | - public function buildSqlOr($values, $sprintfFormat) |
|
63 | + public function buildSqlOr( $values, $sprintfFormat ) |
|
64 | 64 | { |
65 | - if (!is_array($values)) { |
|
66 | - $values = explode(',', $values); |
|
65 | + if( !is_array( $values ) ) { |
|
66 | + $values = explode( ',', $values ); |
|
67 | 67 | } |
68 | - $values = array_filter(array_map('trim', (array) $values)); |
|
69 | - $values = array_map(function ($value) use ($sprintfFormat) { |
|
70 | - return sprintf($sprintfFormat, $value); |
|
71 | - }, $values); |
|
72 | - return implode(' OR ', $values); |
|
68 | + $values = array_filter( array_map( 'trim', (array)$values ) ); |
|
69 | + $values = array_map( function( $value ) use ($sprintfFormat) { |
|
70 | + return sprintf( $sprintfFormat, $value ); |
|
71 | + }, $values ); |
|
72 | + return implode( ' OR ', $values ); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -79,23 +79,23 @@ discard block |
||
79 | 79 | * @return string |
80 | 80 | * @filter posts_search |
81 | 81 | */ |
82 | - public function filterSearchByTitle($search, WP_Query $query) |
|
82 | + public function filterSearchByTitle( $search, WP_Query $query ) |
|
83 | 83 | { |
84 | - if (empty($search) || empty($query->get('search_terms'))) { |
|
84 | + if( empty($search) || empty($query->get( 'search_terms' )) ) { |
|
85 | 85 | return $search; |
86 | 86 | } |
87 | 87 | global $wpdb; |
88 | - $n = empty($query->get('exact')) |
|
88 | + $n = empty($query->get( 'exact' )) |
|
89 | 89 | ? '%' |
90 | 90 | : ''; |
91 | 91 | $search = []; |
92 | - foreach ((array) $query->get('search_terms') as $term) { |
|
93 | - $search[] = $wpdb->prepare("{$wpdb->posts}.post_title LIKE %s", $n.$wpdb->esc_like($term).$n); |
|
92 | + foreach( (array)$query->get( 'search_terms' ) as $term ) { |
|
93 | + $search[] = $wpdb->prepare( "{$wpdb->posts}.post_title LIKE %s", $n.$wpdb->esc_like( $term ).$n ); |
|
94 | 94 | } |
95 | - if (!is_user_logged_in()) { |
|
95 | + if( !is_user_logged_in() ) { |
|
96 | 96 | $search[] = "{$wpdb->posts}.post_password = ''"; |
97 | 97 | } |
98 | - return ' AND '.implode(' AND ', $search); |
|
98 | + return ' AND '.implode( ' AND ', $search ); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -103,10 +103,10 @@ discard block |
||
103 | 103 | * @param bool $isEnabled |
104 | 104 | * @return int |
105 | 105 | */ |
106 | - public function getPaged($isEnabled = true) |
|
106 | + public function getPaged( $isEnabled = true ) |
|
107 | 107 | { |
108 | 108 | return $isEnabled |
109 | - ? max(1, intval(filter_input(INPUT_GET, glsr()->constant('PAGED_QUERY_VAR')))) |
|
109 | + ? max( 1, intval( filter_input( INPUT_GET, glsr()->constant( 'PAGED_QUERY_VAR' ) ) ) ) |
|
110 | 110 | : 1; |
111 | 111 | } |
112 | 112 | |
@@ -114,14 +114,14 @@ discard block |
||
114 | 114 | * @param string $value |
115 | 115 | * @return void|array |
116 | 116 | */ |
117 | - protected function buildQueryAssignedTo($value) |
|
117 | + protected function buildQueryAssignedTo( $value ) |
|
118 | 118 | { |
119 | - if (!empty($value)) { |
|
120 | - $postIds = Arr::convertStringToArray($value, 'is_numeric'); |
|
119 | + if( !empty($value) ) { |
|
120 | + $postIds = Arr::convertStringToArray( $value, 'is_numeric' ); |
|
121 | 121 | return [ |
122 | 122 | 'compare' => 'IN', |
123 | 123 | 'key' => '_assigned_to', |
124 | - 'value' => glsr(Polylang::class)->getPostIds($postIds), |
|
124 | + 'value' => glsr( Polylang::class )->getPostIds( $postIds ), |
|
125 | 125 | ]; |
126 | 126 | } |
127 | 127 | } |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | * @param array $value |
131 | 131 | * @return void|array |
132 | 132 | */ |
133 | - protected function buildQueryCategory($value) |
|
133 | + protected function buildQueryCategory( $value ) |
|
134 | 134 | { |
135 | - if (!empty($value)) { |
|
135 | + if( !empty($value) ) { |
|
136 | 136 | return [ |
137 | 137 | 'field' => 'term_id', |
138 | 138 | 'taxonomy' => Application::TAXONOMY, |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | * @param string $value |
146 | 146 | * @return void|array |
147 | 147 | */ |
148 | - protected function buildQueryRating($value) |
|
148 | + protected function buildQueryRating( $value ) |
|
149 | 149 | { |
150 | - if (is_numeric($value) |
|
151 | - && in_array(intval($value), range(1, glsr()->constant('MAX_RATING', Rating::class)))) { |
|
150 | + if( is_numeric( $value ) |
|
151 | + && in_array( intval( $value ), range( 1, glsr()->constant( 'MAX_RATING', Rating::class ) ) ) ) { |
|
152 | 152 | return [ |
153 | 153 | 'compare' => '>=', |
154 | 154 | 'key' => '_rating', |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | * @param string $value |
162 | 162 | * @return void|array |
163 | 163 | */ |
164 | - protected function buildQueryType($value) |
|
164 | + protected function buildQueryType( $value ) |
|
165 | 165 | { |
166 | - if (!in_array($value, ['', 'all'])) { |
|
166 | + if( !in_array( $value, ['', 'all'] ) ) { |
|
167 | 167 | return [ |
168 | 168 | 'key' => '_review_type', |
169 | 169 | 'value' => $value, |
@@ -1,20 +1,20 @@ discard block |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="glsr-strings-form"> |
4 | 4 | <div class="glsr-search-box" id="glsr-search-translations"> |
5 | - <span class="screen-reader-text"><?= __('Search for translatable text', 'site-reviews'); ?></span> |
|
5 | + <span class="screen-reader-text"><?= __( 'Search for translatable text', 'site-reviews' ); ?></span> |
|
6 | 6 | <div class="glsr-spinner"> |
7 | 7 | <span class="spinner"></span> |
8 | 8 | </div> |
9 | - <input type="search" class="glsr-search-input" autocomplete="off" placeholder="<?= __('Search here for text to translate...', 'site-reviews'); ?>"> |
|
10 | - <?php wp_nonce_field('search-translations', '_search_nonce', false); ?> |
|
9 | + <input type="search" class="glsr-search-input" autocomplete="off" placeholder="<?= __( 'Search here for text to translate...', 'site-reviews' ); ?>"> |
|
10 | + <?php wp_nonce_field( 'search-translations', '_search_nonce', false ); ?> |
|
11 | 11 | <div class="glsr-search-results" data-prefix="{{ database_key }}"></div> |
12 | 12 | </div> |
13 | 13 | <table class="glsr-strings-table wp-list-table widefat striped {{ class }}"> |
14 | 14 | <thead> |
15 | 15 | <tr> |
16 | - <th scope="col" class="manage-column column-primary"><?= __('Original Text', 'site-reviews'); ?></th> |
|
17 | - <th scope="col" class="manage-column"><?= __('Custom Translation', 'site-reviews'); ?></th> |
|
16 | + <th scope="col" class="manage-column column-primary"><?= __( 'Original Text', 'site-reviews' ); ?></th> |
|
17 | + <th scope="col" class="manage-column"><?= __( 'Custom Translation', 'site-reviews' ); ?></th> |
|
18 | 18 | </tr> |
19 | 19 | </thead> |
20 | 20 | <tbody>{{ translations }}</tbody> |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | </div> |
24 | 24 | |
25 | 25 | <script type="text/html" id="tmpl-glsr-string-plural"> |
26 | -<?php include glsr()->path('views/partials/translations/plural.php'); ?> |
|
26 | +<?php include glsr()->path( 'views/partials/translations/plural.php' ); ?> |
|
27 | 27 | </script> |
28 | 28 | <script type="text/html" id="tmpl-glsr-string-single"> |
29 | -<?php include glsr()->path('views/partials/translations/single.php'); ?> |
|
29 | +<?php include glsr()->path( 'views/partials/translations/single.php' ); ?> |
|
30 | 30 | </script> |
@@ -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 | } |
@@ -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->rebusifyKey, false); |
|
32 | - if (!$isAccountVerified || $isApiKeyModified || $isEmailModified) { |
|
33 | - $settings = $this->sanitizeRebusifySettings($settings); |
|
29 | + $isApiKeyModified = $this->isEmptyOrModified( $this->apiKey, $settings ); |
|
30 | + $isEmailModified = $this->isEmptyOrModified( $this->emailKey, $settings ); |
|
31 | + $isAccountVerified = glsr( OptionManager::class )->getWP( $this->rebusifyKey, false ); |
|
32 | + if( !$isAccountVerified || $isApiKeyModified || $isEmailModified ) { |
|
33 | + $settings = $this->sanitizeRebusifySettings( $settings ); |
|
34 | 34 | } |
35 | 35 | return $settings; |
36 | 36 | } |
@@ -40,21 +40,21 @@ 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 | - $rebusifyProductType = glsr(OptionManager::class)->getWP($this->rebusifyKey); |
|
49 | - if ('P' === $rebusifyProductType) { |
|
48 | + $rebusifyProductType = glsr( OptionManager::class )->getWP( $this->rebusifyKey ); |
|
49 | + if( 'P' === $rebusifyProductType ) { |
|
50 | 50 | return $context; |
51 | 51 | } |
52 | - if ('F' === $rebusifyProductType && 'yes' === glsr_get_option('general.rebusify')) { |
|
52 | + if( 'F' === $rebusifyProductType && 'yes' === glsr_get_option( 'general.rebusify' ) ) { |
|
53 | 53 | $button = $this->buildUpgradeButton(); |
54 | 54 | } else { |
55 | 55 | $button = $this->buildCreateButton(); |
56 | 56 | } |
57 | - $context['field'].= $button; |
|
57 | + $context['field'] .= $button; |
|
58 | 58 | return $context; |
59 | 59 | } |
60 | 60 | |
@@ -63,14 +63,14 @@ discard block |
||
63 | 63 | * @return void |
64 | 64 | * @action site-reviews/review/created |
65 | 65 | */ |
66 | - public function onCreated(Review $review) |
|
66 | + public function onCreated( Review $review ) |
|
67 | 67 | { |
68 | - if (!$this->canPostReview($review)) { |
|
68 | + if( !$this->canPostReview( $review ) ) { |
|
69 | 69 | return; |
70 | 70 | } |
71 | - $rebusify = glsr(Rebusify::class)->sendReview($review); |
|
72 | - if ($rebusify->success) { |
|
73 | - glsr(Database::class)->set($review->ID, 'rebusify', $rebusify->review_id); |
|
71 | + $rebusify = glsr( Rebusify::class )->sendReview( $review ); |
|
72 | + if( $rebusify->success ) { |
|
73 | + glsr( Database::class )->set( $review->ID, 'rebusify', $rebusify->review_id ); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | * @return void |
80 | 80 | * @action site-reviews/review/reverted |
81 | 81 | */ |
82 | - public function onReverted(Review $review) |
|
82 | + public function onReverted( Review $review ) |
|
83 | 83 | { |
84 | - if (!$this->canPostReview($review)) { |
|
84 | + if( !$this->canPostReview( $review ) ) { |
|
85 | 85 | return; |
86 | 86 | } |
87 | - $rebusify = glsr(Rebusify::class)->sendReview($review); |
|
88 | - if ($rebusify->success) { |
|
89 | - glsr(Database::class)->set($review->ID, 'rebusify', $rebusify->review_id); |
|
87 | + $rebusify = glsr( Rebusify::class )->sendReview( $review ); |
|
88 | + if( $rebusify->success ) { |
|
89 | + glsr( Database::class )->set( $review->ID, 'rebusify', $rebusify->review_id ); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
@@ -95,14 +95,14 @@ discard block |
||
95 | 95 | * @return void |
96 | 96 | * @action site-reviews/review/saved |
97 | 97 | */ |
98 | - public function onSaved(Review $review) |
|
98 | + public function onSaved( Review $review ) |
|
99 | 99 | { |
100 | - if (!$this->canPostReview($review)) { |
|
100 | + if( !$this->canPostReview( $review ) ) { |
|
101 | 101 | return; |
102 | 102 | } |
103 | - $rebusify = glsr(Rebusify::class)->sendReview($review); |
|
104 | - if ($rebusify->success) { |
|
105 | - glsr(Database::class)->set($review->ID, 'rebusify', $rebusify->review_id); |
|
103 | + $rebusify = glsr( Rebusify::class )->sendReview( $review ); |
|
104 | + if( $rebusify->success ) { |
|
105 | + glsr( Database::class )->set( $review->ID, 'rebusify', $rebusify->review_id ); |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
@@ -114,15 +114,15 @@ discard block |
||
114 | 114 | * @return void |
115 | 115 | * @action updated_postmeta |
116 | 116 | */ |
117 | - public function onUpdatedMeta($metaId, $postId, $metaKey) |
|
117 | + public function onUpdatedMeta( $metaId, $postId, $metaKey ) |
|
118 | 118 | { |
119 | - $review = glsr_get_review($postId); |
|
120 | - if (!$this->canPostResponse($review) || '_response' !== $metaKey) { |
|
119 | + $review = glsr_get_review( $postId ); |
|
120 | + if( !$this->canPostResponse( $review ) || '_response' !== $metaKey ) { |
|
121 | 121 | return; |
122 | 122 | } |
123 | - $rebusify = glsr(Rebusify::class)->sendReviewResponse($review); |
|
124 | - if ($rebusify->success) { |
|
125 | - glsr(Database::class)->set($review->ID, 'rebusify_response', true); |
|
123 | + $rebusify = glsr( Rebusify::class )->sendReviewResponse( $review ); |
|
124 | + if( $rebusify->success ) { |
|
125 | + glsr( Database::class )->set( $review->ID, 'rebusify_response', true ); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
@@ -131,11 +131,11 @@ discard block |
||
131 | 131 | */ |
132 | 132 | protected function buildCreateButton() |
133 | 133 | { |
134 | - return glsr(Builder::class)->a(__('Create Your Rebusify Account', 'site-reviews'), [ |
|
134 | + return glsr( Builder::class )->a( __( 'Create Your Rebusify Account', 'site-reviews' ), [ |
|
135 | 135 | 'class' => 'button', |
136 | 136 | 'href' => Rebusify::WEB_URL, |
137 | 137 | 'target' => '_blank', |
138 | - ]); |
|
138 | + ] ); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -143,37 +143,37 @@ discard block |
||
143 | 143 | */ |
144 | 144 | protected function buildUpgradeButton() |
145 | 145 | { |
146 | - $build = glsr(Builder::class); |
|
147 | - $notice = $build->p(__('Free Rebusify accounts are limited to 500 blockchain transactions per year.', 'site-reviews')); |
|
148 | - $button = $build->a(__('Upgrade Your Rebusify Plan', 'site-reviews'), [ |
|
146 | + $build = glsr( Builder::class ); |
|
147 | + $notice = $build->p( __( 'Free Rebusify accounts are limited to 500 blockchain transactions per year.', 'site-reviews' ) ); |
|
148 | + $button = $build->a( __( 'Upgrade Your Rebusify Plan', 'site-reviews' ), [ |
|
149 | 149 | 'class' => 'button', |
150 | 150 | 'href' => Rebusify::WEB_URL, |
151 | 151 | 'target' => '_blank', |
152 | - ]); |
|
153 | - return $build->div($notice.$button, [ |
|
152 | + ] ); |
|
153 | + return $build->div( $notice.$button, [ |
|
154 | 154 | 'class' => 'glsr-notice-inline notice inline notice-info', |
155 | - ]); |
|
155 | + ] ); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
159 | 159 | * @return bool |
160 | 160 | */ |
161 | - protected function canPostResponse(Review $review) |
|
161 | + protected function canPostResponse( Review $review ) |
|
162 | 162 | { |
163 | 163 | $requiredValues = [ |
164 | - glsr(Database::class)->get($review->ID, 'rebusify'), |
|
164 | + glsr( Database::class )->get( $review->ID, 'rebusify' ), |
|
165 | 165 | $review->response, |
166 | 166 | $review->review_id, |
167 | 167 | ]; |
168 | - return $this->canProceed($review, 'rebusify_response') |
|
168 | + return $this->canProceed( $review, 'rebusify_response' ) |
|
169 | 169 | && 'publish' === $review->status |
170 | - && 3 === count(array_filter($requiredValues)); |
|
170 | + && 3 === count( array_filter( $requiredValues ) ); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
174 | 174 | * @return bool |
175 | 175 | */ |
176 | - protected function canPostReview(Review $review) |
|
176 | + protected function canPostReview( Review $review ) |
|
177 | 177 | { |
178 | 178 | $requiredValues = [ |
179 | 179 | $review->author, |
@@ -182,60 +182,60 @@ discard block |
||
182 | 182 | $review->review_id, |
183 | 183 | $review->title, |
184 | 184 | ]; |
185 | - return $this->canProceed($review) |
|
185 | + return $this->canProceed( $review ) |
|
186 | 186 | && 'publish' === $review->status |
187 | - && 5 === count(array_filter($requiredValues)); |
|
187 | + && 5 === count( array_filter( $requiredValues ) ); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
191 | 191 | * @param string $metaKey |
192 | 192 | * @return bool |
193 | 193 | */ |
194 | - protected function canProceed(Review $review, $metaKey = 'rebusify') |
|
194 | + protected function canProceed( Review $review, $metaKey = 'rebusify' ) |
|
195 | 195 | { |
196 | - return glsr(OptionManager::class)->getBool($this->enabledKey) |
|
197 | - && $this->isReviewPostId($review->ID) |
|
198 | - && !$this->hasMetaKey($review, $metaKey); |
|
196 | + return glsr( OptionManager::class )->getBool( $this->enabledKey ) |
|
197 | + && $this->isReviewPostId( $review->ID ) |
|
198 | + && !$this->hasMetaKey( $review, $metaKey ); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
202 | 202 | * @param string $metaKey |
203 | 203 | * @return bool |
204 | 204 | */ |
205 | - protected function hasMetaKey(Review $review, $metaKey = 'rebusify') |
|
205 | + protected function hasMetaKey( Review $review, $metaKey = 'rebusify' ) |
|
206 | 206 | { |
207 | - return '' !== glsr(Database::class)->get($review->ID, $metaKey); |
|
207 | + return '' !== glsr( Database::class )->get( $review->ID, $metaKey ); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
211 | 211 | * @param string $key |
212 | 212 | * @return bool |
213 | 213 | */ |
214 | - protected function isEmptyOrModified($key, array $settings) |
|
214 | + protected function isEmptyOrModified( $key, array $settings ) |
|
215 | 215 | { |
216 | - $oldValue = glsr_get_option($key); |
|
217 | - $newValue = Arr::get($settings, $key); |
|
216 | + $oldValue = glsr_get_option( $key ); |
|
217 | + $newValue = Arr::get( $settings, $key ); |
|
218 | 218 | return empty($newValue) || $newValue !== $oldValue; |
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
222 | 222 | * @return array |
223 | 223 | */ |
224 | - protected function sanitizeRebusifySettings(array $settings) |
|
224 | + protected function sanitizeRebusifySettings( array $settings ) |
|
225 | 225 | { |
226 | - $rebusify = glsr(Rebusify::class)->activateKey( |
|
227 | - Arr::get($settings, $this->apiKey), |
|
228 | - Arr::get($settings, $this->emailKey) |
|
226 | + $rebusify = glsr( Rebusify::class )->activateKey( |
|
227 | + Arr::get( $settings, $this->apiKey ), |
|
228 | + Arr::get( $settings, $this->emailKey ) |
|
229 | 229 | ); |
230 | - if ($rebusify->success) { |
|
231 | - update_option($this->rebusifyKey, Arr::get($rebusify->response, 'producttype')); |
|
230 | + if( $rebusify->success ) { |
|
231 | + update_option( $this->rebusifyKey, Arr::get( $rebusify->response, 'producttype' ) ); |
|
232 | 232 | } else { |
233 | - delete_option($this->rebusifyKey); |
|
234 | - $settings = Arr::set($settings, $this->enabledKey, 'no'); |
|
235 | - glsr(Notice::class)->addError(sprintf( |
|
236 | - __('Your Rebusify account details could not be verified, please try again. %s', 'site-reviews'), |
|
233 | + delete_option( $this->rebusifyKey ); |
|
234 | + $settings = Arr::set( $settings, $this->enabledKey, 'no' ); |
|
235 | + glsr( Notice::class )->addError( sprintf( |
|
236 | + __( 'Your Rebusify account details could not be verified, please try again. %s', 'site-reviews' ), |
|
237 | 237 | '('.$rebusify->message.')' |
238 | - )); |
|
238 | + ) ); |
|
239 | 239 | } |
240 | 240 | return $settings; |
241 | 241 | } |
@@ -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' => '', |
@@ -58,20 +58,20 @@ discard block |
||
58 | 58 | /** |
59 | 59 | * @return static |
60 | 60 | */ |
61 | - public function validate(array $request) |
|
61 | + public function validate( array $request ) |
|
62 | 62 | { |
63 | 63 | $request['ip_address'] = Helper::getIpAddress(); // required for Akismet and Blacklist validation |
64 | 64 | $this->form_id = $request['form_id']; |
65 | - $this->options = glsr(OptionManager::class)->all(); |
|
66 | - $this->request = $this->validateRequest($request); |
|
65 | + $this->options = glsr( OptionManager::class )->all(); |
|
66 | + $this->request = $this->validateRequest( $request ); |
|
67 | 67 | $this->validateCustom(); |
68 | 68 | $this->validateHoneyPot(); |
69 | 69 | $this->validateReviewLimits(); |
70 | 70 | $this->validateBlacklist(); |
71 | 71 | $this->validateAkismet(); |
72 | 72 | $this->validateRecaptcha(); |
73 | - if (!empty($this->error)) { |
|
74 | - $this->setSessionValues('message', $this->error); |
|
73 | + if( !empty($this->error) ) { |
|
74 | + $this->setSessionValues( 'message', $this->error ); |
|
75 | 75 | } |
76 | 76 | return $this; |
77 | 77 | } |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | * @param mixed $fallback |
82 | 82 | * @return mixed |
83 | 83 | */ |
84 | - protected function getOption($path, $fallback = '') |
|
84 | + protected function getOption( $path, $fallback = '' ) |
|
85 | 85 | { |
86 | - return Arr::get($this->options, $path, $fallback); |
|
86 | + return Arr::get( $this->options, $path, $fallback ); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | */ |
92 | 92 | protected function getRecaptchaStatus() |
93 | 93 | { |
94 | - if (!glsr(OptionManager::class)->isRecaptchaEnabled()) { |
|
94 | + if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) { |
|
95 | 95 | return static::RECAPTCHA_DISABLED; |
96 | 96 | } |
97 | - if (empty($this->request['_recaptcha-token'])) { |
|
98 | - return $this->request['_counter'] < intval(apply_filters('site-reviews/recaptcha/timeout', 5)) |
|
97 | + if( empty($this->request['_recaptcha-token']) ) { |
|
98 | + return $this->request['_counter'] < intval( apply_filters( 'site-reviews/recaptcha/timeout', 5 ) ) |
|
99 | 99 | ? static::RECAPTCHA_EMPTY |
100 | 100 | : static::RECAPTCHA_FAILED; |
101 | 101 | } |
@@ -107,23 +107,23 @@ discard block |
||
107 | 107 | */ |
108 | 108 | protected function getRecaptchaTokenStatus() |
109 | 109 | { |
110 | - $endpoint = add_query_arg([ |
|
110 | + $endpoint = add_query_arg( [ |
|
111 | 111 | 'remoteip' => Helper::getIpAddress(), |
112 | 112 | 'response' => $this->request['_recaptcha-token'], |
113 | - 'secret' => $this->getOption('settings.submissions.recaptcha.secret'), |
|
114 | - ], static::RECAPTCHA_ENDPOINT); |
|
115 | - if (is_wp_error($response = wp_remote_get($endpoint))) { |
|
116 | - glsr_log()->error($response->get_error_message()); |
|
113 | + 'secret' => $this->getOption( 'settings.submissions.recaptcha.secret' ), |
|
114 | + ], static::RECAPTCHA_ENDPOINT ); |
|
115 | + if( is_wp_error( $response = wp_remote_get( $endpoint ) ) ) { |
|
116 | + glsr_log()->error( $response->get_error_message() ); |
|
117 | 117 | return static::RECAPTCHA_FAILED; |
118 | 118 | } |
119 | - $response = json_decode(wp_remote_retrieve_body($response)); |
|
120 | - if (!empty($response->success)) { |
|
121 | - return boolval($response->success) |
|
119 | + $response = json_decode( wp_remote_retrieve_body( $response ) ); |
|
120 | + if( !empty($response->success) ) { |
|
121 | + return boolval( $response->success ) |
|
122 | 122 | ? static::RECAPTCHA_VALID |
123 | 123 | : static::RECAPTCHA_INVALID; |
124 | 124 | } |
125 | - foreach ($response->{'error-codes'} as $error) { |
|
126 | - glsr_log()->error('reCAPTCHA error: '.$error); |
|
125 | + foreach( $response->{'error-codes'} as $error ) { |
|
126 | + glsr_log()->error( 'reCAPTCHA error: '.$error ); |
|
127 | 127 | } |
128 | 128 | return static::RECAPTCHA_INVALID; |
129 | 129 | } |
@@ -131,35 +131,35 @@ discard block |
||
131 | 131 | /** |
132 | 132 | * @return array |
133 | 133 | */ |
134 | - protected function getValidationRules(array $request) |
|
134 | + protected function getValidationRules( array $request ) |
|
135 | 135 | { |
136 | 136 | $rules = array_intersect_key( |
137 | - apply_filters('site-reviews/validation/rules', static::VALIDATION_RULES, $request), |
|
138 | - array_flip($this->getOption('settings.submissions.required', [])) |
|
137 | + apply_filters( 'site-reviews/validation/rules', static::VALIDATION_RULES, $request ), |
|
138 | + array_flip( $this->getOption( 'settings.submissions.required', [] ) ) |
|
139 | 139 | ); |
140 | - $excluded = explode(',', Arr::get($request, 'excluded')); |
|
141 | - return array_diff_key($rules, array_flip($excluded)); |
|
140 | + $excluded = explode( ',', Arr::get( $request, 'excluded' ) ); |
|
141 | + return array_diff_key( $rules, array_flip( $excluded ) ); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
145 | 145 | * @return bool |
146 | 146 | */ |
147 | - protected function isRequestValid(array $request) |
|
147 | + protected function isRequestValid( array $request ) |
|
148 | 148 | { |
149 | - $rules = $this->getValidationRules($request); |
|
150 | - $errors = glsr(Validator::class)->validate($request, $rules); |
|
151 | - if (empty($errors)) { |
|
149 | + $rules = $this->getValidationRules( $request ); |
|
150 | + $errors = glsr( Validator::class )->validate( $request, $rules ); |
|
151 | + if( empty($errors) ) { |
|
152 | 152 | return true; |
153 | 153 | } |
154 | - $this->error = __('Please fix the submission errors.', 'site-reviews'); |
|
155 | - $this->setSessionValues('errors', $errors); |
|
156 | - $this->setSessionValues('values', $request); |
|
154 | + $this->error = __( 'Please fix the submission errors.', 'site-reviews' ); |
|
155 | + $this->setSessionValues( 'errors', $errors ); |
|
156 | + $this->setSessionValues( 'values', $request ); |
|
157 | 157 | return false; |
158 | 158 | } |
159 | 159 | |
160 | - protected function setError($message, $loggedMessage = '') |
|
160 | + protected function setError( $message, $loggedMessage = '' ) |
|
161 | 161 | { |
162 | - $this->setSessionValues('errors', [], $loggedMessage); |
|
162 | + $this->setSessionValues( 'errors', [], $loggedMessage ); |
|
163 | 163 | $this->error = $message; |
164 | 164 | } |
165 | 165 | |
@@ -169,11 +169,11 @@ discard block |
||
169 | 169 | * @param string $loggedMessage |
170 | 170 | * @return void |
171 | 171 | */ |
172 | - protected function setSessionValues($type, $value, $loggedMessage = '') |
|
172 | + protected function setSessionValues( $type, $value, $loggedMessage = '' ) |
|
173 | 173 | { |
174 | - glsr()->sessionSet($this->form_id.$type, $value); |
|
175 | - if (!empty($loggedMessage)) { |
|
176 | - glsr_log()->warning($loggedMessage)->debug($this->request); |
|
174 | + glsr()->sessionSet( $this->form_id.$type, $value ); |
|
175 | + if( !empty($loggedMessage) ) { |
|
176 | + glsr_log()->warning( $loggedMessage )->debug( $this->request ); |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 | |
@@ -182,11 +182,11 @@ discard block |
||
182 | 182 | */ |
183 | 183 | protected function validateAkismet() |
184 | 184 | { |
185 | - if (!empty($this->error)) { |
|
185 | + if( !empty($this->error) ) { |
|
186 | 186 | return; |
187 | 187 | } |
188 | - if (glsr(Akismet::class)->isSpam($this->request)) { |
|
189 | - $this->setError(__('This review has been flagged as possible spam and cannot be submitted.', 'site-reviews'), |
|
188 | + if( glsr( Akismet::class )->isSpam( $this->request ) ) { |
|
189 | + $this->setError( __( 'This review has been flagged as possible spam and cannot be submitted.', 'site-reviews' ), |
|
190 | 190 | 'Akismet caught a spam submission (consider adding the IP address to the blacklist):' |
191 | 191 | ); |
192 | 192 | } |
@@ -197,18 +197,18 @@ discard block |
||
197 | 197 | */ |
198 | 198 | protected function validateBlacklist() |
199 | 199 | { |
200 | - if (!empty($this->error)) { |
|
200 | + if( !empty($this->error) ) { |
|
201 | 201 | return; |
202 | 202 | } |
203 | - if (!glsr(Blacklist::class)->isBlacklisted($this->request)) { |
|
203 | + if( !glsr( Blacklist::class )->isBlacklisted( $this->request ) ) { |
|
204 | 204 | return; |
205 | 205 | } |
206 | - $blacklistAction = $this->getOption('settings.submissions.blacklist.action'); |
|
207 | - if ('reject' != $blacklistAction) { |
|
206 | + $blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' ); |
|
207 | + if( 'reject' != $blacklistAction ) { |
|
208 | 208 | $this->request['blacklisted'] = true; |
209 | 209 | return; |
210 | 210 | } |
211 | - $this->setError(__('Your review cannot be submitted at this time.', 'site-reviews'), |
|
211 | + $this->setError( __( 'Your review cannot be submitted at this time.', 'site-reviews' ), |
|
212 | 212 | 'Blacklisted submission detected:' |
213 | 213 | ); |
214 | 214 | } |
@@ -218,18 +218,18 @@ discard block |
||
218 | 218 | */ |
219 | 219 | protected function validateCustom() |
220 | 220 | { |
221 | - if (!empty($this->error)) { |
|
221 | + if( !empty($this->error) ) { |
|
222 | 222 | return; |
223 | 223 | } |
224 | - $validated = apply_filters('site-reviews/validate/custom', true, $this->request); |
|
225 | - if (true === $validated) { |
|
224 | + $validated = apply_filters( 'site-reviews/validate/custom', true, $this->request ); |
|
225 | + if( true === $validated ) { |
|
226 | 226 | return; |
227 | 227 | } |
228 | - $errorMessage = is_string($validated) |
|
228 | + $errorMessage = is_string( $validated ) |
|
229 | 229 | ? $validated |
230 | - : __('The review submission failed. Please notify the site administrator.', 'site-reviews'); |
|
231 | - $this->setError($errorMessage); |
|
232 | - $this->setSessionValues('values', $this->request); |
|
230 | + : __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ); |
|
231 | + $this->setError( $errorMessage ); |
|
232 | + $this->setSessionValues( 'values', $this->request ); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
@@ -237,11 +237,11 @@ discard block |
||
237 | 237 | */ |
238 | 238 | protected function validateHoneyPot() |
239 | 239 | { |
240 | - if (!empty($this->error)) { |
|
240 | + if( !empty($this->error) ) { |
|
241 | 241 | return; |
242 | 242 | } |
243 | - if (!empty($this->request['gotcha'])) { |
|
244 | - $this->setError(__('The review submission failed. Please notify the site administrator.', 'site-reviews'), |
|
243 | + if( !empty($this->request['gotcha']) ) { |
|
244 | + $this->setError( __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ), |
|
245 | 245 | 'The Honeypot caught a bad submission:' |
246 | 246 | ); |
247 | 247 | } |
@@ -252,11 +252,11 @@ discard block |
||
252 | 252 | */ |
253 | 253 | protected function validateReviewLimits() |
254 | 254 | { |
255 | - if (!empty($this->error)) { |
|
255 | + if( !empty($this->error) ) { |
|
256 | 256 | return; |
257 | 257 | } |
258 | - if (glsr(ReviewLimits::class)->hasReachedLimit($this->request)) { |
|
259 | - $this->setError(__('You have already submitted a review.', 'site-reviews')); |
|
258 | + if( glsr( ReviewLimits::class )->hasReachedLimit( $this->request ) ) { |
|
259 | + $this->setError( __( 'You have already submitted a review.', 'site-reviews' ) ); |
|
260 | 260 | } |
261 | 261 | } |
262 | 262 | |
@@ -265,33 +265,33 @@ discard block |
||
265 | 265 | */ |
266 | 266 | protected function validateRecaptcha() |
267 | 267 | { |
268 | - if (!empty($this->error)) { |
|
268 | + if( !empty($this->error) ) { |
|
269 | 269 | return; |
270 | 270 | } |
271 | 271 | $status = $this->getRecaptchaStatus(); |
272 | - if (in_array($status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID])) { |
|
272 | + if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ) ) { |
|
273 | 273 | return; |
274 | 274 | } |
275 | - if (static::RECAPTCHA_EMPTY === $status) { |
|
276 | - $this->setSessionValues('recaptcha', 'unset'); |
|
275 | + if( static::RECAPTCHA_EMPTY === $status ) { |
|
276 | + $this->setSessionValues( 'recaptcha', 'unset' ); |
|
277 | 277 | $this->recaptchaIsUnset = true; |
278 | 278 | return; |
279 | 279 | } |
280 | - $this->setSessionValues('recaptcha', 'reset'); |
|
280 | + $this->setSessionValues( 'recaptcha', 'reset' ); |
|
281 | 281 | $errors = [ |
282 | - static::RECAPTCHA_FAILED => __('The reCAPTCHA failed to load, please refresh the page and try again.', 'site-reviews'), |
|
283 | - static::RECAPTCHA_INVALID => __('The reCAPTCHA verification failed, please try again.', 'site-reviews'), |
|
282 | + static::RECAPTCHA_FAILED => __( 'The reCAPTCHA failed to load, please refresh the page and try again.', 'site-reviews' ), |
|
283 | + static::RECAPTCHA_INVALID => __( 'The reCAPTCHA verification failed, please try again.', 'site-reviews' ), |
|
284 | 284 | ]; |
285 | - $this->setError($errors[$status]); |
|
285 | + $this->setError( $errors[$status] ); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
289 | 289 | * @return array |
290 | 290 | */ |
291 | - protected function validateRequest(array $request) |
|
291 | + protected function validateRequest( array $request ) |
|
292 | 292 | { |
293 | - return $this->isRequestValid($request) |
|
294 | - ? array_merge(glsr(ValidateReviewDefaults::class)->defaults(), $request) |
|
293 | + return $this->isRequestValid( $request ) |
|
294 | + ? array_merge( glsr( ValidateReviewDefaults::class )->defaults(), $request ) |
|
295 | 295 | : $request; |
296 | 296 | } |
297 | 297 | } |
@@ -41,17 +41,17 @@ discard block |
||
41 | 41 | 'setting' => 'Plugin Settings', |
42 | 42 | 'reviews' => 'Review Counts', |
43 | 43 | ]; |
44 | - $systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) { |
|
45 | - $methodName = Helper::buildMethodName('get-'.$key.'-details'); |
|
46 | - if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) { |
|
44 | + $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use ($details) { |
|
45 | + $methodName = Helper::buildMethodName( 'get-'.$key.'-details' ); |
|
46 | + if( method_exists( $this, $methodName ) && $systemDetails = $this->$methodName() ) { |
|
47 | 47 | return $carry.$this->implode( |
48 | - strtoupper($details[$key]), |
|
49 | - apply_filters('site-reviews/system/'.$key, $systemDetails) |
|
48 | + strtoupper( $details[$key] ), |
|
49 | + apply_filters( 'site-reviews/system/'.$key, $systemDetails ) |
|
50 | 50 | ); |
51 | 51 | } |
52 | 52 | return $carry; |
53 | 53 | }); |
54 | - return trim($systemInfo); |
|
54 | + return trim( $systemInfo ); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | public function getActivePluginDetails() |
61 | 61 | { |
62 | 62 | $plugins = get_plugins(); |
63 | - $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array'); |
|
64 | - $inactive = array_diff_key($plugins, array_flip($activePlugins)); |
|
65 | - return $this->normalizePluginList(array_diff_key($plugins, $inactive)); |
|
63 | + $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' ); |
|
64 | + $inactive = array_diff_key( $plugins, array_flip( $activePlugins ) ); |
|
65 | + return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function getAddonDetails() |
72 | 72 | { |
73 | - $details = apply_filters('site-reviews/addon/system-info', []); |
|
74 | - ksort($details); |
|
73 | + $details = apply_filters( 'site-reviews/addon/system-info', [] ); |
|
74 | + ksort( $details ); |
|
75 | 75 | return $details; |
76 | 76 | } |
77 | 77 | |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | public function getBrowserDetails() |
82 | 82 | { |
83 | 83 | $browser = new Browser(); |
84 | - $name = esc_attr($browser->getName()); |
|
85 | - $userAgent = esc_attr($browser->getUserAgent()->getUserAgentString()); |
|
86 | - $version = esc_attr($browser->getVersion()); |
|
84 | + $name = esc_attr( $browser->getName() ); |
|
85 | + $userAgent = esc_attr( $browser->getUserAgent()->getUserAgentString() ); |
|
86 | + $version = esc_attr( $browser->getVersion() ); |
|
87 | 87 | return [ |
88 | - 'Browser Name' => sprintf('%s %s', $name, $version), |
|
88 | + 'Browser Name' => sprintf( '%s %s', $name, $version ), |
|
89 | 89 | 'Browser UA' => $userAgent, |
90 | 90 | ]; |
91 | 91 | } |
@@ -95,12 +95,12 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function getInactivePluginDetails() |
97 | 97 | { |
98 | - $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array'); |
|
99 | - $inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins))); |
|
98 | + $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' ); |
|
99 | + $inactivePlugins = $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) ); |
|
100 | 100 | $multisitePlugins = $this->getMultisitePluginDetails(); |
101 | 101 | return empty($multisitePlugins) |
102 | 102 | ? $inactivePlugins |
103 | - : array_diff($inactivePlugins, $multisitePlugins); |
|
103 | + : array_diff( $inactivePlugins, $multisitePlugins ); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -108,10 +108,10 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function getMuPluginDetails() |
110 | 110 | { |
111 | - if (empty($plugins = get_mu_plugins())) { |
|
111 | + if( empty($plugins = get_mu_plugins()) ) { |
|
112 | 112 | return []; |
113 | 113 | } |
114 | - return $this->normalizePluginList($plugins); |
|
114 | + return $this->normalizePluginList( $plugins ); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function getMultisitePluginDetails() |
121 | 121 | { |
122 | - $activePlugins = (array) get_site_option('active_sitewide_plugins', []); |
|
123 | - if (!is_multisite() || empty($activePlugins)) { |
|
122 | + $activePlugins = (array)get_site_option( 'active_sitewide_plugins', [] ); |
|
123 | + if( !is_multisite() || empty($activePlugins) ) { |
|
124 | 124 | return []; |
125 | 125 | } |
126 | - return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins)); |
|
126 | + return $this->normalizePluginList( array_intersect_key( get_plugins(), $activePlugins ) ); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -131,31 +131,31 @@ discard block |
||
131 | 131 | */ |
132 | 132 | public function getPhpDetails() |
133 | 133 | { |
134 | - $displayErrors = $this->getINI('display_errors', null) |
|
135 | - ? 'On ('.$this->getINI('display_errors').')' |
|
134 | + $displayErrors = $this->getINI( 'display_errors', null ) |
|
135 | + ? 'On ('.$this->getINI( 'display_errors' ).')' |
|
136 | 136 | : 'N/A'; |
137 | - $intlSupport = extension_loaded('intl') |
|
138 | - ? phpversion('intl') |
|
137 | + $intlSupport = extension_loaded( 'intl' ) |
|
138 | + ? phpversion( 'intl' ) |
|
139 | 139 | : 'false'; |
140 | 140 | return [ |
141 | - 'cURL' => var_export(function_exists('curl_init'), true), |
|
142 | - 'Default Charset' => $this->getINI('default_charset'), |
|
141 | + 'cURL' => var_export( function_exists( 'curl_init' ), true ), |
|
142 | + 'Default Charset' => $this->getINI( 'default_charset' ), |
|
143 | 143 | 'Display Errors' => $displayErrors, |
144 | - 'fsockopen' => var_export(function_exists('fsockopen'), true), |
|
144 | + 'fsockopen' => var_export( function_exists( 'fsockopen' ), true ), |
|
145 | 145 | 'Intl' => $intlSupport, |
146 | - 'IPv6' => var_export(defined('AF_INET6'), true), |
|
147 | - 'Max Execution Time' => $this->getINI('max_execution_time'), |
|
148 | - 'Max Input Nesting Level' => $this->getINI('max_input_nesting_level'), |
|
149 | - 'Max Input Vars' => $this->getINI('max_input_vars'), |
|
150 | - 'Memory Limit' => $this->getINI('memory_limit'), |
|
151 | - 'Post Max Size' => $this->getINI('post_max_size'), |
|
152 | - 'Sendmail Path' => $this->getINI('sendmail_path'), |
|
153 | - 'Session Cookie Path' => esc_html($this->getINI('session.cookie_path')), |
|
154 | - 'Session Name' => esc_html($this->getINI('session.name')), |
|
155 | - 'Session Save Path' => esc_html($this->getINI('session.save_path')), |
|
156 | - 'Session Use Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_cookies', false)), true), |
|
157 | - 'Session Use Only Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_only_cookies', false)), true), |
|
158 | - 'Upload Max Filesize' => $this->getINI('upload_max_filesize'), |
|
146 | + 'IPv6' => var_export( defined( 'AF_INET6' ), true ), |
|
147 | + 'Max Execution Time' => $this->getINI( 'max_execution_time' ), |
|
148 | + 'Max Input Nesting Level' => $this->getINI( 'max_input_nesting_level' ), |
|
149 | + 'Max Input Vars' => $this->getINI( 'max_input_vars' ), |
|
150 | + 'Memory Limit' => $this->getINI( 'memory_limit' ), |
|
151 | + 'Post Max Size' => $this->getINI( 'post_max_size' ), |
|
152 | + 'Sendmail Path' => $this->getINI( 'sendmail_path' ), |
|
153 | + 'Session Cookie Path' => esc_html( $this->getINI( 'session.cookie_path' ) ), |
|
154 | + 'Session Name' => esc_html( $this->getINI( 'session.name' ) ), |
|
155 | + 'Session Save Path' => esc_html( $this->getINI( 'session.save_path' ) ), |
|
156 | + 'Session Use Cookies' => var_export( wp_validate_boolean( $this->getINI( 'session.use_cookies', false ) ), true ), |
|
157 | + 'Session Use Only Cookies' => var_export( wp_validate_boolean( $this->getINI( 'session.use_only_cookies', false ) ), true ), |
|
158 | + 'Upload Max Filesize' => $this->getINI( 'upload_max_filesize' ), |
|
159 | 159 | ]; |
160 | 160 | } |
161 | 161 | |
@@ -164,19 +164,19 @@ discard block |
||
164 | 164 | */ |
165 | 165 | public function getReviewsDetails() |
166 | 166 | { |
167 | - $counts = glsr(CountsManager::class)->getCounts(); |
|
168 | - $counts = Arr::flattenArray($counts); |
|
169 | - array_walk($counts, function (&$ratings) use ($counts) { |
|
170 | - if (!is_array($ratings)) { |
|
167 | + $counts = glsr( CountsManager::class )->getCounts(); |
|
168 | + $counts = Arr::flattenArray( $counts ); |
|
169 | + array_walk( $counts, function( &$ratings ) use ($counts) { |
|
170 | + if( !is_array( $ratings ) ) { |
|
171 | 171 | glsr_log() |
172 | - ->error('$ratings is not an array, possibly due to incorrectly imported reviews.') |
|
173 | - ->debug($ratings) |
|
174 | - ->debug($counts); |
|
172 | + ->error( '$ratings is not an array, possibly due to incorrectly imported reviews.' ) |
|
173 | + ->debug( $ratings ) |
|
174 | + ->debug( $counts ); |
|
175 | 175 | return; |
176 | 176 | } |
177 | - $ratings = array_sum($ratings).' ('.implode(', ', $ratings).')'; |
|
177 | + $ratings = array_sum( $ratings ).' ('.implode( ', ', $ratings ).')'; |
|
178 | 178 | }); |
179 | - ksort($counts); |
|
179 | + ksort( $counts ); |
|
180 | 180 | return $counts; |
181 | 181 | } |
182 | 182 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | 'Host Name' => $this->getHostName(), |
191 | 191 | 'MySQL Version' => $wpdb->db_version(), |
192 | 192 | 'PHP Version' => PHP_VERSION, |
193 | - 'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'), |
|
193 | + 'Server Software' => filter_input( INPUT_SERVER, 'SERVER_SOFTWARE' ), |
|
194 | 194 | ]; |
195 | 195 | } |
196 | 196 | |
@@ -199,16 +199,16 @@ discard block |
||
199 | 199 | */ |
200 | 200 | public function getSettingDetails() |
201 | 201 | { |
202 | - $settings = glsr(OptionManager::class)->get('settings', []); |
|
203 | - $settings = Arr::flattenArray($settings, true); |
|
204 | - $settings = $this->purgeSensitiveData($settings); |
|
205 | - ksort($settings); |
|
202 | + $settings = glsr( OptionManager::class )->get( 'settings', [] ); |
|
203 | + $settings = Arr::flattenArray( $settings, true ); |
|
204 | + $settings = $this->purgeSensitiveData( $settings ); |
|
205 | + ksort( $settings ); |
|
206 | 206 | $details = []; |
207 | - foreach ($settings as $key => $value) { |
|
208 | - if (Str::startsWith('strings', $key) && Str::endsWith('id', $key)) { |
|
207 | + foreach( $settings as $key => $value ) { |
|
208 | + if( Str::startsWith( 'strings', $key ) && Str::endsWith( 'id', $key ) ) { |
|
209 | 209 | continue; |
210 | 210 | } |
211 | - $value = htmlspecialchars(trim(preg_replace('/\s\s+/', '\\n', $value)), ENT_QUOTES, 'UTF-8'); |
|
211 | + $value = htmlspecialchars( trim( preg_replace( '/\s\s+/', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' ); |
|
212 | 212 | $details[$key] = $value; |
213 | 213 | } |
214 | 214 | return $details; |
@@ -220,11 +220,11 @@ discard block |
||
220 | 220 | public function getPluginDetails() |
221 | 221 | { |
222 | 222 | return [ |
223 | - 'Console level' => glsr(Console::class)->humanLevel(), |
|
224 | - 'Console size' => glsr(Console::class)->humanSize('0'), |
|
225 | - 'Last Rating Count' => date_i18n('Y-m-d H:i', glsr(OptionManager::class)->get('last_review_count')), |
|
223 | + 'Console level' => glsr( Console::class )->humanLevel(), |
|
224 | + 'Console size' => glsr( Console::class )->humanSize( '0' ), |
|
225 | + 'Last Rating Count' => date_i18n( 'Y-m-d H:i', glsr( OptionManager::class )->get( 'last_review_count' ) ), |
|
226 | 226 | 'Version (current)' => glsr()->version, |
227 | - 'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'), |
|
227 | + 'Version (previous)' => glsr( OptionManager::class )->get( 'version_upgraded_from' ), |
|
228 | 228 | ]; |
229 | 229 | } |
230 | 230 | |
@@ -236,23 +236,23 @@ discard block |
||
236 | 236 | global $wpdb; |
237 | 237 | $theme = wp_get_theme(); |
238 | 238 | return [ |
239 | - 'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version), |
|
240 | - 'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1), |
|
239 | + 'Active Theme' => sprintf( '%s v%s', (string)$theme->Name, (string)$theme->Version ), |
|
240 | + 'Email Domain' => substr( strrchr( glsr( OptionManager::class )->getWP( 'admin_email' ), '@' ), 1 ), |
|
241 | 241 | 'Home URL' => home_url(), |
242 | 242 | 'Language' => get_locale(), |
243 | 243 | 'Memory Limit' => WP_MEMORY_LIMIT, |
244 | - 'Multisite' => var_export(is_multisite(), true), |
|
245 | - 'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'), |
|
246 | - 'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'), |
|
247 | - 'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'), |
|
248 | - 'Post Stati' => implode(', ', get_post_stati()), |
|
249 | - 'Remote Post' => glsr(Cache::class)->getRemotePostTest(), |
|
250 | - 'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'), |
|
244 | + 'Multisite' => var_export( is_multisite(), true ), |
|
245 | + 'Page For Posts ID' => glsr( OptionManager::class )->getWP( 'page_for_posts' ), |
|
246 | + 'Page On Front ID' => glsr( OptionManager::class )->getWP( 'page_on_front' ), |
|
247 | + 'Permalink Structure' => glsr( OptionManager::class )->getWP( 'permalink_structure', 'default' ), |
|
248 | + 'Post Stati' => implode( ', ', get_post_stati() ), |
|
249 | + 'Remote Post' => glsr( Cache::class )->getRemotePostTest(), |
|
250 | + 'Show On Front' => glsr( OptionManager::class )->getWP( 'show_on_front' ), |
|
251 | 251 | 'Site URL' => site_url(), |
252 | - 'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', $this->getINI('date.timezone').' (PHP)'), |
|
253 | - 'Version' => get_bloginfo('version'), |
|
254 | - 'WP Debug' => var_export(defined('WP_DEBUG'), true), |
|
255 | - 'WP Max Upload Size' => size_format(wp_max_upload_size()), |
|
252 | + 'Timezone' => glsr( OptionManager::class )->getWP( 'timezone_string', $this->getINI( 'date.timezone' ).' (PHP)' ), |
|
253 | + 'Version' => get_bloginfo( 'version' ), |
|
254 | + 'WP Debug' => var_export( defined( 'WP_DEBUG' ), true ), |
|
255 | + 'WP Max Upload Size' => size_format( wp_max_upload_size() ), |
|
256 | 256 | 'WP Memory Limit' => WP_MEMORY_LIMIT, |
257 | 257 | ]; |
258 | 258 | } |
@@ -282,13 +282,13 @@ discard block |
||
282 | 282 | 'secureserver.net' => 'GoDaddy', |
283 | 283 | 'WPE_APIKEY' => 'WP Engine', |
284 | 284 | ]; |
285 | - foreach ($checks as $key => $value) { |
|
286 | - if (!$this->isWebhostCheckValid($key)) { |
|
285 | + foreach( $checks as $key => $value ) { |
|
286 | + if( !$this->isWebhostCheckValid( $key ) ) { |
|
287 | 287 | continue; |
288 | 288 | } |
289 | 289 | return $value; |
290 | 290 | } |
291 | - return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')])); |
|
291 | + return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ) ); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | /** |
@@ -296,16 +296,16 @@ discard block |
||
296 | 296 | */ |
297 | 297 | protected function getHostName() |
298 | 298 | { |
299 | - return sprintf('%s (%s)', |
|
299 | + return sprintf( '%s (%s)', |
|
300 | 300 | $this->detectWebhostProvider(), |
301 | 301 | Helper::getIpAddress() |
302 | 302 | ); |
303 | 303 | } |
304 | 304 | |
305 | - protected function getINI($name, $disabledValue = 'ini_get() is disabled.') |
|
305 | + protected function getINI( $name, $disabledValue = 'ini_get() is disabled.' ) |
|
306 | 306 | { |
307 | - return function_exists('ini_get') |
|
308 | - ? ini_get($name) |
|
307 | + return function_exists( 'ini_get' ) |
|
308 | + ? ini_get( $name ) |
|
309 | 309 | : $disabledValue; |
310 | 310 | } |
311 | 311 | |
@@ -315,9 +315,9 @@ discard block |
||
315 | 315 | protected function getWordpressPlugins() |
316 | 316 | { |
317 | 317 | $plugins = get_plugins(); |
318 | - $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array'); |
|
319 | - $inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins))); |
|
320 | - $active = $this->normalizePluginList(array_diff_key($plugins, $inactive)); |
|
318 | + $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' ); |
|
319 | + $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) ); |
|
320 | + $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
321 | 321 | return $active + $inactive; |
322 | 322 | } |
323 | 323 | |
@@ -325,48 +325,48 @@ discard block |
||
325 | 325 | * @param string $title |
326 | 326 | * @return string |
327 | 327 | */ |
328 | - protected function implode($title, array $details) |
|
328 | + protected function implode( $title, array $details ) |
|
329 | 329 | { |
330 | 330 | $strings = ['['.$title.']']; |
331 | - $padding = max(array_map('strlen', array_keys($details))); |
|
332 | - $padding = max([$padding, static::PAD]); |
|
333 | - foreach ($details as $key => $value) { |
|
334 | - $strings[] = is_string($key) |
|
335 | - ? sprintf('%s : %s', str_pad($key, $padding, '.'), $value) |
|
331 | + $padding = max( array_map( 'strlen', array_keys( $details ) ) ); |
|
332 | + $padding = max( [$padding, static::PAD] ); |
|
333 | + foreach( $details as $key => $value ) { |
|
334 | + $strings[] = is_string( $key ) |
|
335 | + ? sprintf( '%s : %s', str_pad( $key, $padding, '.' ), $value ) |
|
336 | 336 | : ' - '.$value; |
337 | 337 | } |
338 | - return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL; |
|
338 | + return implode( PHP_EOL, $strings ).PHP_EOL.PHP_EOL; |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
342 | 342 | * @param string $key |
343 | 343 | * @return bool |
344 | 344 | */ |
345 | - protected function isWebhostCheckValid($key) |
|
345 | + protected function isWebhostCheckValid( $key ) |
|
346 | 346 | { |
347 | - return defined($key) |
|
348 | - || filter_input(INPUT_SERVER, $key) |
|
349 | - || Str::contains(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key) |
|
350 | - || Str::contains(DB_HOST, $key) |
|
351 | - || Str::contains(php_uname(), $key); |
|
347 | + return defined( $key ) |
|
348 | + || filter_input( INPUT_SERVER, $key ) |
|
349 | + || Str::contains( filter_input( INPUT_SERVER, 'SERVER_NAME' ), $key ) |
|
350 | + || Str::contains( DB_HOST, $key ) |
|
351 | + || Str::contains( php_uname(), $key ); |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | /** |
355 | 355 | * @return array |
356 | 356 | */ |
357 | - protected function normalizePluginList(array $plugins) |
|
357 | + protected function normalizePluginList( array $plugins ) |
|
358 | 358 | { |
359 | - $plugins = array_map(function ($plugin) { |
|
360 | - return sprintf('%s v%s', Arr::get($plugin, 'Name'), Arr::get($plugin, 'Version')); |
|
361 | - }, $plugins); |
|
362 | - natcasesort($plugins); |
|
363 | - return array_flip($plugins); |
|
359 | + $plugins = array_map( function( $plugin ) { |
|
360 | + return sprintf( '%s v%s', Arr::get( $plugin, 'Name' ), Arr::get( $plugin, 'Version' ) ); |
|
361 | + }, $plugins ); |
|
362 | + natcasesort( $plugins ); |
|
363 | + return array_flip( $plugins ); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | /** |
367 | 367 | * @return array |
368 | 368 | */ |
369 | - protected function purgeSensitiveData(array $settings) |
|
369 | + protected function purgeSensitiveData( array $settings ) |
|
370 | 370 | { |
371 | 371 | $keys = [ |
372 | 372 | 'general.rebusify_serial', |
@@ -374,12 +374,12 @@ discard block |
||
374 | 374 | 'submissions.recaptcha.key', |
375 | 375 | 'submissions.recaptcha.secret', |
376 | 376 | ]; |
377 | - array_walk($settings, function (&$value, $setting) use ($keys) { |
|
378 | - foreach ($keys as $key) { |
|
379 | - if (!Str::startsWith($key, $setting) || empty($value)) { |
|
377 | + array_walk( $settings, function( &$value, $setting ) use ($keys) { |
|
378 | + foreach( $keys as $key ) { |
|
379 | + if( !Str::startsWith( $key, $setting ) || empty($value) ) { |
|
380 | 380 | continue; |
381 | 381 | } |
382 | - $value = str_repeat('•', 13); |
|
382 | + $value = str_repeat( '•', 13 ); |
|
383 | 383 | return; |
384 | 384 | } |
385 | 385 | }); |