@@ -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,101 +82,101 @@ 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 | - $homePath = untrailingslashit(parse_url(home_url(), PHP_URL_PATH)); |
|
150 | - $urlPath = untrailingslashit(parse_url(Arr::get($request, 'url'), PHP_URL_PATH)); |
|
149 | + $homePath = untrailingslashit( parse_url( home_url(), PHP_URL_PATH ) ); |
|
150 | + $urlPath = untrailingslashit( parse_url( Arr::get( $request, 'url' ), PHP_URL_PATH ) ); |
|
151 | 151 | $urlQuery = []; |
152 | - parse_str(parse_url(Arr::get($request, 'url'), PHP_URL_QUERY), $urlQuery); |
|
152 | + parse_str( parse_url( Arr::get( $request, 'url' ), PHP_URL_QUERY ), $urlQuery ); |
|
153 | 153 | $pagedUrl = $homePath === $urlPath |
154 | 154 | ? home_url() |
155 | - : home_url($urlPath); |
|
155 | + : home_url( $urlPath ); |
|
156 | 156 | $args = [ |
157 | - 'paged' => (int) Arr::get($urlQuery, glsr()->constant('PAGED_QUERY_VAR'), 1), |
|
158 | - 'pagedUrl' => trailingslashit($pagedUrl), |
|
157 | + 'paged' => (int)Arr::get( $urlQuery, glsr()->constant( 'PAGED_QUERY_VAR' ), 1 ), |
|
158 | + 'pagedUrl' => trailingslashit( $pagedUrl ), |
|
159 | 159 | 'pagination' => 'ajax', |
160 | 160 | 'schema' => false, |
161 | 161 | ]; |
162 | - $atts = (array) json_decode(Arr::get($request, 'atts')); |
|
163 | - $atts = glsr(SiteReviewsShortcode::class)->normalizeAtts($atts); |
|
164 | - $html = glsr(SiteReviewsPartial::class)->build(wp_parse_args($args, $atts)); |
|
165 | - return wp_send_json_success([ |
|
162 | + $atts = (array)json_decode( Arr::get( $request, 'atts' ) ); |
|
163 | + $atts = glsr( SiteReviewsShortcode::class )->normalizeAtts( $atts ); |
|
164 | + $html = glsr( SiteReviewsPartial::class )->build( wp_parse_args( $args, $atts ) ); |
|
165 | + return wp_send_json_success( [ |
|
166 | 166 | 'pagination' => $html->getPagination(), |
167 | 167 | 'reviews' => $html->getReviews(), |
168 | - ]); |
|
168 | + ] ); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
172 | 172 | * @return void |
173 | 173 | */ |
174 | - public function routerTogglePinned(array $request) |
|
174 | + public function routerTogglePinned( array $request ) |
|
175 | 175 | { |
176 | - $isPinned = $this->execute(new TogglePinned($request)); |
|
177 | - wp_send_json_success([ |
|
178 | - 'notices' => glsr(Notice::class)->get(), |
|
176 | + $isPinned = $this->execute( new TogglePinned( $request ) ); |
|
177 | + wp_send_json_success( [ |
|
178 | + 'notices' => glsr( Notice::class )->get(), |
|
179 | 179 | 'pinned' => $isPinned, |
180 | - ]); |
|
180 | + ] ); |
|
181 | 181 | } |
182 | 182 | } |