@@ -15,192 +15,192 @@ |
||
15 | 15 | |
16 | 16 | class AjaxController extends Controller |
17 | 17 | { |
18 | - /** |
|
19 | - * @return void |
|
20 | - */ |
|
21 | - public function routerChangeStatus(array $request) |
|
22 | - { |
|
23 | - wp_send_json_success($this->execute(new ChangeStatus($request))); |
|
24 | - } |
|
18 | + /** |
|
19 | + * @return void |
|
20 | + */ |
|
21 | + public function routerChangeStatus(array $request) |
|
22 | + { |
|
23 | + wp_send_json_success($this->execute(new ChangeStatus($request))); |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * @return void |
|
28 | - */ |
|
29 | - public function routerClearConsole() |
|
30 | - { |
|
31 | - glsr(AdminController::class)->routerClearConsole(); |
|
32 | - wp_send_json_success([ |
|
33 | - 'console' => glsr(Console::class)->get(), |
|
34 | - 'notices' => glsr(Notice::class)->get(), |
|
35 | - ]); |
|
36 | - } |
|
26 | + /** |
|
27 | + * @return void |
|
28 | + */ |
|
29 | + public function routerClearConsole() |
|
30 | + { |
|
31 | + glsr(AdminController::class)->routerClearConsole(); |
|
32 | + wp_send_json_success([ |
|
33 | + 'console' => glsr(Console::class)->get(), |
|
34 | + 'notices' => glsr(Notice::class)->get(), |
|
35 | + ]); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * @return void |
|
40 | - */ |
|
41 | - public function routerCountReviews() |
|
42 | - { |
|
43 | - glsr(AdminController::class)->routerCountReviews(); |
|
44 | - wp_send_json_success([ |
|
45 | - 'notices' => glsr(Notice::class)->get(), |
|
46 | - ]); |
|
47 | - } |
|
38 | + /** |
|
39 | + * @return void |
|
40 | + */ |
|
41 | + public function routerCountReviews() |
|
42 | + { |
|
43 | + glsr(AdminController::class)->routerCountReviews(); |
|
44 | + wp_send_json_success([ |
|
45 | + 'notices' => glsr(Notice::class)->get(), |
|
46 | + ]); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @return void |
|
51 | - */ |
|
52 | - public function routerMigrateReviews() |
|
53 | - { |
|
54 | - glsr(AdminController::class)->routerMigrateReviews(); |
|
55 | - wp_send_json_success([ |
|
56 | - 'notices' => glsr(Notice::class)->get(), |
|
57 | - ]); |
|
58 | - } |
|
49 | + /** |
|
50 | + * @return void |
|
51 | + */ |
|
52 | + public function routerMigrateReviews() |
|
53 | + { |
|
54 | + glsr(AdminController::class)->routerMigrateReviews(); |
|
55 | + wp_send_json_success([ |
|
56 | + 'notices' => glsr(Notice::class)->get(), |
|
57 | + ]); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @return void |
|
62 | - */ |
|
63 | - public function routerDismissNotice(array $request) |
|
64 | - { |
|
65 | - glsr(NoticeController::class)->routerDismissNotice($request); |
|
66 | - wp_send_json_success(); |
|
67 | - } |
|
60 | + /** |
|
61 | + * @return void |
|
62 | + */ |
|
63 | + public function routerDismissNotice(array $request) |
|
64 | + { |
|
65 | + glsr(NoticeController::class)->routerDismissNotice($request); |
|
66 | + wp_send_json_success(); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @return void |
|
71 | - */ |
|
72 | - public function routerMceShortcode(array $request) |
|
73 | - { |
|
74 | - $shortcode = $request['shortcode']; |
|
75 | - $response = false; |
|
76 | - if (array_key_exists($shortcode, glsr()->mceShortcodes)) { |
|
77 | - $data = glsr()->mceShortcodes[$shortcode]; |
|
78 | - if (!empty($data['errors'])) { |
|
79 | - $data['btn_okay'] = [esc_html__('Okay', 'site-reviews')]; |
|
80 | - } |
|
81 | - $response = [ |
|
82 | - 'body' => $data['fields'], |
|
83 | - 'close' => $data['btn_close'], |
|
84 | - 'ok' => $data['btn_okay'], |
|
85 | - 'shortcode' => $shortcode, |
|
86 | - 'title' => $data['title'], |
|
87 | - ]; |
|
88 | - } |
|
89 | - wp_send_json_success($response); |
|
90 | - } |
|
69 | + /** |
|
70 | + * @return void |
|
71 | + */ |
|
72 | + public function routerMceShortcode(array $request) |
|
73 | + { |
|
74 | + $shortcode = $request['shortcode']; |
|
75 | + $response = false; |
|
76 | + if (array_key_exists($shortcode, glsr()->mceShortcodes)) { |
|
77 | + $data = glsr()->mceShortcodes[$shortcode]; |
|
78 | + if (!empty($data['errors'])) { |
|
79 | + $data['btn_okay'] = [esc_html__('Okay', 'site-reviews')]; |
|
80 | + } |
|
81 | + $response = [ |
|
82 | + 'body' => $data['fields'], |
|
83 | + 'close' => $data['btn_close'], |
|
84 | + 'ok' => $data['btn_okay'], |
|
85 | + 'shortcode' => $shortcode, |
|
86 | + 'title' => $data['title'], |
|
87 | + ]; |
|
88 | + } |
|
89 | + wp_send_json_success($response); |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * @return void |
|
94 | - */ |
|
95 | - public function routerFetchConsole() |
|
96 | - { |
|
97 | - glsr(AdminController::class)->routerFetchConsole(); |
|
98 | - wp_send_json_success([ |
|
99 | - 'console' => glsr(Console::class)->get(), |
|
100 | - 'notices' => glsr(Notice::class)->get(), |
|
101 | - ]); |
|
102 | - } |
|
92 | + /** |
|
93 | + * @return void |
|
94 | + */ |
|
95 | + public function routerFetchConsole() |
|
96 | + { |
|
97 | + glsr(AdminController::class)->routerFetchConsole(); |
|
98 | + wp_send_json_success([ |
|
99 | + 'console' => glsr(Console::class)->get(), |
|
100 | + 'notices' => glsr(Notice::class)->get(), |
|
101 | + ]); |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * @return void |
|
106 | - */ |
|
107 | - public function routerResetPermissions() |
|
108 | - { |
|
109 | - glsr(Role::class)->resetAll(); |
|
110 | - glsr(Notice::class)->clear()->addSuccess(__('The permissions have been reset, please reload the page for them to take effect.', 'site-reviews')); |
|
111 | - wp_send_json_success([ |
|
112 | - 'notices' => glsr(Notice::class)->get(), |
|
113 | - ]); |
|
114 | - } |
|
104 | + /** |
|
105 | + * @return void |
|
106 | + */ |
|
107 | + public function routerResetPermissions() |
|
108 | + { |
|
109 | + glsr(Role::class)->resetAll(); |
|
110 | + glsr(Notice::class)->clear()->addSuccess(__('The permissions have been reset, please reload the page for them to take effect.', 'site-reviews')); |
|
111 | + wp_send_json_success([ |
|
112 | + 'notices' => glsr(Notice::class)->get(), |
|
113 | + ]); |
|
114 | + } |
|
115 | 115 | |
116 | - /** |
|
117 | - * @return void |
|
118 | - */ |
|
119 | - public function routerSearchPosts(array $request) |
|
120 | - { |
|
121 | - $results = glsr(Database::class)->searchPosts($request['search']); |
|
122 | - wp_send_json_success([ |
|
123 | - 'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>', |
|
124 | - 'items' => $results, |
|
125 | - ]); |
|
126 | - } |
|
116 | + /** |
|
117 | + * @return void |
|
118 | + */ |
|
119 | + public function routerSearchPosts(array $request) |
|
120 | + { |
|
121 | + $results = glsr(Database::class)->searchPosts($request['search']); |
|
122 | + wp_send_json_success([ |
|
123 | + 'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>', |
|
124 | + 'items' => $results, |
|
125 | + ]); |
|
126 | + } |
|
127 | 127 | |
128 | - /** |
|
129 | - * @return void |
|
130 | - */ |
|
131 | - public function routerSearchTranslations(array $request) |
|
132 | - { |
|
133 | - if (empty($request['exclude'])) { |
|
134 | - $request['exclude'] = []; |
|
135 | - } |
|
136 | - $results = glsr(Translation::class) |
|
137 | - ->search($request['search']) |
|
138 | - ->exclude() |
|
139 | - ->exclude($request['exclude']) |
|
140 | - ->renderResults(); |
|
141 | - wp_send_json_success([ |
|
142 | - 'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>', |
|
143 | - 'items' => $results, |
|
144 | - ]); |
|
145 | - } |
|
128 | + /** |
|
129 | + * @return void |
|
130 | + */ |
|
131 | + public function routerSearchTranslations(array $request) |
|
132 | + { |
|
133 | + if (empty($request['exclude'])) { |
|
134 | + $request['exclude'] = []; |
|
135 | + } |
|
136 | + $results = glsr(Translation::class) |
|
137 | + ->search($request['search']) |
|
138 | + ->exclude() |
|
139 | + ->exclude($request['exclude']) |
|
140 | + ->renderResults(); |
|
141 | + wp_send_json_success([ |
|
142 | + 'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>', |
|
143 | + 'items' => $results, |
|
144 | + ]); |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * @return void |
|
149 | - */ |
|
150 | - public function routerSubmitReview(array $request) |
|
151 | - { |
|
152 | - $command = glsr(PublicController::class)->routerSubmitReview($request); |
|
153 | - $redirect = trim(strval(get_post_meta($command->post_id, 'redirect_to', true))); |
|
154 | - $redirect = apply_filters('site-reviews/review/redirect', $redirect, $command); |
|
155 | - $data = [ |
|
156 | - 'errors' => glsr()->sessionGet($command->form_id.'errors', false), |
|
157 | - 'message' => glsr()->sessionGet($command->form_id.'message', ''), |
|
158 | - 'recaptcha' => glsr()->sessionGet($command->form_id.'recaptcha', false), |
|
159 | - 'redirect' => $redirect, |
|
160 | - ]; |
|
161 | - if (false === $data['errors']) { |
|
162 | - glsr()->sessionClear(); |
|
163 | - wp_send_json_success($data); |
|
164 | - } |
|
165 | - wp_send_json_error($data); |
|
166 | - } |
|
147 | + /** |
|
148 | + * @return void |
|
149 | + */ |
|
150 | + public function routerSubmitReview(array $request) |
|
151 | + { |
|
152 | + $command = glsr(PublicController::class)->routerSubmitReview($request); |
|
153 | + $redirect = trim(strval(get_post_meta($command->post_id, 'redirect_to', true))); |
|
154 | + $redirect = apply_filters('site-reviews/review/redirect', $redirect, $command); |
|
155 | + $data = [ |
|
156 | + 'errors' => glsr()->sessionGet($command->form_id.'errors', false), |
|
157 | + 'message' => glsr()->sessionGet($command->form_id.'message', ''), |
|
158 | + 'recaptcha' => glsr()->sessionGet($command->form_id.'recaptcha', false), |
|
159 | + 'redirect' => $redirect, |
|
160 | + ]; |
|
161 | + if (false === $data['errors']) { |
|
162 | + glsr()->sessionClear(); |
|
163 | + wp_send_json_success($data); |
|
164 | + } |
|
165 | + wp_send_json_error($data); |
|
166 | + } |
|
167 | 167 | |
168 | - /** |
|
169 | - * @return void |
|
170 | - */ |
|
171 | - public function routerFetchPagedReviews(array $request) |
|
172 | - { |
|
173 | - $homePath = untrailingslashit(parse_url(home_url(), PHP_URL_PATH)); |
|
174 | - $urlPath = untrailingslashit(parse_url(Arr::get($request, 'url'), PHP_URL_PATH)); |
|
175 | - $urlQuery = []; |
|
176 | - parse_str(parse_url(Arr::get($request, 'url'), PHP_URL_QUERY), $urlQuery); |
|
177 | - $pagedUrl = $homePath === $urlPath |
|
178 | - ? home_url() |
|
179 | - : home_url($urlPath); |
|
180 | - $args = [ |
|
181 | - 'paged' => (int) Arr::get($urlQuery, glsr()->constant('PAGED_QUERY_VAR'), 1), |
|
182 | - 'pagedUrl' => trailingslashit($pagedUrl), |
|
183 | - 'pagination' => 'ajax', |
|
184 | - 'schema' => false, |
|
185 | - ]; |
|
186 | - $atts = (array) json_decode(Arr::get($request, 'atts')); |
|
187 | - $atts = glsr(SiteReviewsShortcode::class)->normalizeAtts($atts); |
|
188 | - $html = glsr(SiteReviewsPartial::class)->build(wp_parse_args($args, $atts)); |
|
189 | - return wp_send_json_success([ |
|
190 | - 'pagination' => $html->getPagination(), |
|
191 | - 'reviews' => $html->getReviews(), |
|
192 | - ]); |
|
193 | - } |
|
168 | + /** |
|
169 | + * @return void |
|
170 | + */ |
|
171 | + public function routerFetchPagedReviews(array $request) |
|
172 | + { |
|
173 | + $homePath = untrailingslashit(parse_url(home_url(), PHP_URL_PATH)); |
|
174 | + $urlPath = untrailingslashit(parse_url(Arr::get($request, 'url'), PHP_URL_PATH)); |
|
175 | + $urlQuery = []; |
|
176 | + parse_str(parse_url(Arr::get($request, 'url'), PHP_URL_QUERY), $urlQuery); |
|
177 | + $pagedUrl = $homePath === $urlPath |
|
178 | + ? home_url() |
|
179 | + : home_url($urlPath); |
|
180 | + $args = [ |
|
181 | + 'paged' => (int) Arr::get($urlQuery, glsr()->constant('PAGED_QUERY_VAR'), 1), |
|
182 | + 'pagedUrl' => trailingslashit($pagedUrl), |
|
183 | + 'pagination' => 'ajax', |
|
184 | + 'schema' => false, |
|
185 | + ]; |
|
186 | + $atts = (array) json_decode(Arr::get($request, 'atts')); |
|
187 | + $atts = glsr(SiteReviewsShortcode::class)->normalizeAtts($atts); |
|
188 | + $html = glsr(SiteReviewsPartial::class)->build(wp_parse_args($args, $atts)); |
|
189 | + return wp_send_json_success([ |
|
190 | + 'pagination' => $html->getPagination(), |
|
191 | + 'reviews' => $html->getReviews(), |
|
192 | + ]); |
|
193 | + } |
|
194 | 194 | |
195 | - /** |
|
196 | - * @return void |
|
197 | - */ |
|
198 | - public function routerTogglePinned(array $request) |
|
199 | - { |
|
200 | - $isPinned = $this->execute(new TogglePinned($request)); |
|
201 | - wp_send_json_success([ |
|
202 | - 'notices' => glsr(Notice::class)->get(), |
|
203 | - 'pinned' => $isPinned, |
|
204 | - ]); |
|
205 | - } |
|
195 | + /** |
|
196 | + * @return void |
|
197 | + */ |
|
198 | + public function routerTogglePinned(array $request) |
|
199 | + { |
|
200 | + $isPinned = $this->execute(new TogglePinned($request)); |
|
201 | + wp_send_json_success([ |
|
202 | + 'notices' => glsr(Notice::class)->get(), |
|
203 | + 'pinned' => $isPinned, |
|
204 | + ]); |
|
205 | + } |
|
206 | 206 | } |
@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * @return void |
20 | 20 | */ |
21 | - public function routerChangeStatus(array $request) |
|
21 | + public function routerChangeStatus( array $request ) |
|
22 | 22 | { |
23 | - wp_send_json_success($this->execute(new ChangeStatus($request))); |
|
23 | + wp_send_json_success( $this->execute( new ChangeStatus( $request ) ) ); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -28,11 +28,11 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function routerClearConsole() |
30 | 30 | { |
31 | - glsr(AdminController::class)->routerClearConsole(); |
|
32 | - wp_send_json_success([ |
|
33 | - 'console' => glsr(Console::class)->get(), |
|
34 | - 'notices' => glsr(Notice::class)->get(), |
|
35 | - ]); |
|
31 | + glsr( AdminController::class )->routerClearConsole(); |
|
32 | + wp_send_json_success( [ |
|
33 | + 'console' => glsr( Console::class )->get(), |
|
34 | + 'notices' => glsr( Notice::class )->get(), |
|
35 | + ] ); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function routerCountReviews() |
42 | 42 | { |
43 | - glsr(AdminController::class)->routerCountReviews(); |
|
44 | - wp_send_json_success([ |
|
45 | - 'notices' => glsr(Notice::class)->get(), |
|
46 | - ]); |
|
43 | + glsr( AdminController::class )->routerCountReviews(); |
|
44 | + wp_send_json_success( [ |
|
45 | + 'notices' => glsr( Notice::class )->get(), |
|
46 | + ] ); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -51,32 +51,32 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function routerMigrateReviews() |
53 | 53 | { |
54 | - glsr(AdminController::class)->routerMigrateReviews(); |
|
55 | - wp_send_json_success([ |
|
56 | - 'notices' => glsr(Notice::class)->get(), |
|
57 | - ]); |
|
54 | + glsr( AdminController::class )->routerMigrateReviews(); |
|
55 | + wp_send_json_success( [ |
|
56 | + 'notices' => glsr( Notice::class )->get(), |
|
57 | + ] ); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
61 | 61 | * @return void |
62 | 62 | */ |
63 | - public function routerDismissNotice(array $request) |
|
63 | + public function routerDismissNotice( array $request ) |
|
64 | 64 | { |
65 | - glsr(NoticeController::class)->routerDismissNotice($request); |
|
65 | + glsr( NoticeController::class )->routerDismissNotice( $request ); |
|
66 | 66 | wp_send_json_success(); |
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
70 | 70 | * @return void |
71 | 71 | */ |
72 | - public function routerMceShortcode(array $request) |
|
72 | + public function routerMceShortcode( array $request ) |
|
73 | 73 | { |
74 | 74 | $shortcode = $request['shortcode']; |
75 | 75 | $response = false; |
76 | - if (array_key_exists($shortcode, glsr()->mceShortcodes)) { |
|
76 | + if( array_key_exists( $shortcode, glsr()->mceShortcodes ) ) { |
|
77 | 77 | $data = glsr()->mceShortcodes[$shortcode]; |
78 | - if (!empty($data['errors'])) { |
|
79 | - $data['btn_okay'] = [esc_html__('Okay', 'site-reviews')]; |
|
78 | + if( !empty($data['errors']) ) { |
|
79 | + $data['btn_okay'] = [esc_html__( 'Okay', 'site-reviews' )]; |
|
80 | 80 | } |
81 | 81 | $response = [ |
82 | 82 | 'body' => $data['fields'], |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | 'title' => $data['title'], |
87 | 87 | ]; |
88 | 88 | } |
89 | - wp_send_json_success($response); |
|
89 | + wp_send_json_success( $response ); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function routerFetchConsole() |
96 | 96 | { |
97 | - glsr(AdminController::class)->routerFetchConsole(); |
|
98 | - wp_send_json_success([ |
|
99 | - 'console' => glsr(Console::class)->get(), |
|
100 | - 'notices' => glsr(Notice::class)->get(), |
|
101 | - ]); |
|
97 | + glsr( AdminController::class )->routerFetchConsole(); |
|
98 | + wp_send_json_success( [ |
|
99 | + 'console' => glsr( Console::class )->get(), |
|
100 | + 'notices' => glsr( Notice::class )->get(), |
|
101 | + ] ); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -106,101 +106,101 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function routerResetPermissions() |
108 | 108 | { |
109 | - glsr(Role::class)->resetAll(); |
|
110 | - glsr(Notice::class)->clear()->addSuccess(__('The permissions have been reset, please reload the page for them to take effect.', 'site-reviews')); |
|
111 | - wp_send_json_success([ |
|
112 | - 'notices' => glsr(Notice::class)->get(), |
|
113 | - ]); |
|
109 | + glsr( Role::class )->resetAll(); |
|
110 | + glsr( Notice::class )->clear()->addSuccess( __( 'The permissions have been reset, please reload the page for them to take effect.', 'site-reviews' ) ); |
|
111 | + wp_send_json_success( [ |
|
112 | + 'notices' => glsr( Notice::class )->get(), |
|
113 | + ] ); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
117 | 117 | * @return void |
118 | 118 | */ |
119 | - public function routerSearchPosts(array $request) |
|
119 | + public function routerSearchPosts( array $request ) |
|
120 | 120 | { |
121 | - $results = glsr(Database::class)->searchPosts($request['search']); |
|
122 | - wp_send_json_success([ |
|
123 | - 'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>', |
|
121 | + $results = glsr( Database::class )->searchPosts( $request['search'] ); |
|
122 | + wp_send_json_success( [ |
|
123 | + 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
|
124 | 124 | 'items' => $results, |
125 | - ]); |
|
125 | + ] ); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
129 | 129 | * @return void |
130 | 130 | */ |
131 | - public function routerSearchTranslations(array $request) |
|
131 | + public function routerSearchTranslations( array $request ) |
|
132 | 132 | { |
133 | - if (empty($request['exclude'])) { |
|
133 | + if( empty($request['exclude']) ) { |
|
134 | 134 | $request['exclude'] = []; |
135 | 135 | } |
136 | - $results = glsr(Translation::class) |
|
137 | - ->search($request['search']) |
|
136 | + $results = glsr( Translation::class ) |
|
137 | + ->search( $request['search'] ) |
|
138 | 138 | ->exclude() |
139 | - ->exclude($request['exclude']) |
|
139 | + ->exclude( $request['exclude'] ) |
|
140 | 140 | ->renderResults(); |
141 | - wp_send_json_success([ |
|
142 | - 'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>', |
|
141 | + wp_send_json_success( [ |
|
142 | + 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
|
143 | 143 | 'items' => $results, |
144 | - ]); |
|
144 | + ] ); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
148 | 148 | * @return void |
149 | 149 | */ |
150 | - public function routerSubmitReview(array $request) |
|
150 | + public function routerSubmitReview( array $request ) |
|
151 | 151 | { |
152 | - $command = glsr(PublicController::class)->routerSubmitReview($request); |
|
153 | - $redirect = trim(strval(get_post_meta($command->post_id, 'redirect_to', true))); |
|
154 | - $redirect = apply_filters('site-reviews/review/redirect', $redirect, $command); |
|
152 | + $command = glsr( PublicController::class )->routerSubmitReview( $request ); |
|
153 | + $redirect = trim( strval( get_post_meta( $command->post_id, 'redirect_to', true ) ) ); |
|
154 | + $redirect = apply_filters( 'site-reviews/review/redirect', $redirect, $command ); |
|
155 | 155 | $data = [ |
156 | - 'errors' => glsr()->sessionGet($command->form_id.'errors', false), |
|
157 | - 'message' => glsr()->sessionGet($command->form_id.'message', ''), |
|
158 | - 'recaptcha' => glsr()->sessionGet($command->form_id.'recaptcha', false), |
|
156 | + 'errors' => glsr()->sessionGet( $command->form_id.'errors', false ), |
|
157 | + 'message' => glsr()->sessionGet( $command->form_id.'message', '' ), |
|
158 | + 'recaptcha' => glsr()->sessionGet( $command->form_id.'recaptcha', false ), |
|
159 | 159 | 'redirect' => $redirect, |
160 | 160 | ]; |
161 | - if (false === $data['errors']) { |
|
161 | + if( false === $data['errors'] ) { |
|
162 | 162 | glsr()->sessionClear(); |
163 | - wp_send_json_success($data); |
|
163 | + wp_send_json_success( $data ); |
|
164 | 164 | } |
165 | - wp_send_json_error($data); |
|
165 | + wp_send_json_error( $data ); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
169 | 169 | * @return void |
170 | 170 | */ |
171 | - public function routerFetchPagedReviews(array $request) |
|
171 | + public function routerFetchPagedReviews( array $request ) |
|
172 | 172 | { |
173 | - $homePath = untrailingslashit(parse_url(home_url(), PHP_URL_PATH)); |
|
174 | - $urlPath = untrailingslashit(parse_url(Arr::get($request, 'url'), PHP_URL_PATH)); |
|
173 | + $homePath = untrailingslashit( parse_url( home_url(), PHP_URL_PATH ) ); |
|
174 | + $urlPath = untrailingslashit( parse_url( Arr::get( $request, 'url' ), PHP_URL_PATH ) ); |
|
175 | 175 | $urlQuery = []; |
176 | - parse_str(parse_url(Arr::get($request, 'url'), PHP_URL_QUERY), $urlQuery); |
|
176 | + parse_str( parse_url( Arr::get( $request, 'url' ), PHP_URL_QUERY ), $urlQuery ); |
|
177 | 177 | $pagedUrl = $homePath === $urlPath |
178 | 178 | ? home_url() |
179 | - : home_url($urlPath); |
|
179 | + : home_url( $urlPath ); |
|
180 | 180 | $args = [ |
181 | - 'paged' => (int) Arr::get($urlQuery, glsr()->constant('PAGED_QUERY_VAR'), 1), |
|
182 | - 'pagedUrl' => trailingslashit($pagedUrl), |
|
181 | + 'paged' => (int)Arr::get( $urlQuery, glsr()->constant( 'PAGED_QUERY_VAR' ), 1 ), |
|
182 | + 'pagedUrl' => trailingslashit( $pagedUrl ), |
|
183 | 183 | 'pagination' => 'ajax', |
184 | 184 | 'schema' => false, |
185 | 185 | ]; |
186 | - $atts = (array) json_decode(Arr::get($request, 'atts')); |
|
187 | - $atts = glsr(SiteReviewsShortcode::class)->normalizeAtts($atts); |
|
188 | - $html = glsr(SiteReviewsPartial::class)->build(wp_parse_args($args, $atts)); |
|
189 | - return wp_send_json_success([ |
|
186 | + $atts = (array)json_decode( Arr::get( $request, 'atts' ) ); |
|
187 | + $atts = glsr( SiteReviewsShortcode::class )->normalizeAtts( $atts ); |
|
188 | + $html = glsr( SiteReviewsPartial::class )->build( wp_parse_args( $args, $atts ) ); |
|
189 | + return wp_send_json_success( [ |
|
190 | 190 | 'pagination' => $html->getPagination(), |
191 | 191 | 'reviews' => $html->getReviews(), |
192 | - ]); |
|
192 | + ] ); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
196 | 196 | * @return void |
197 | 197 | */ |
198 | - public function routerTogglePinned(array $request) |
|
198 | + public function routerTogglePinned( array $request ) |
|
199 | 199 | { |
200 | - $isPinned = $this->execute(new TogglePinned($request)); |
|
201 | - wp_send_json_success([ |
|
202 | - 'notices' => glsr(Notice::class)->get(), |
|
200 | + $isPinned = $this->execute( new TogglePinned( $request ) ); |
|
201 | + wp_send_json_success( [ |
|
202 | + 'notices' => glsr( Notice::class )->get(), |
|
203 | 203 | 'pinned' => $isPinned, |
204 | - ]); |
|
204 | + ] ); |
|
205 | 205 | } |
206 | 206 | } |
@@ -10,86 +10,86 @@ |
||
10 | 10 | |
11 | 11 | class MainController extends Controller |
12 | 12 | { |
13 | - /** |
|
14 | - * @return void |
|
15 | - * @action init |
|
16 | - */ |
|
17 | - public function registerPostType() |
|
18 | - { |
|
19 | - if (!glsr()->hasPermission()) { |
|
20 | - return; |
|
21 | - } |
|
22 | - $command = new RegisterPostType([ |
|
23 | - 'capabilities' => ['create_posts' => 'create_'.Application::POST_TYPE], |
|
24 | - 'capability_type' => Application::POST_TYPE, |
|
25 | - 'columns' => [ |
|
26 | - 'title' => '', |
|
27 | - 'category' => '', |
|
28 | - 'assigned_to' => __('Assigned To', 'site-reviews'), |
|
29 | - 'reviewer' => __('Author', 'site-reviews'), |
|
30 | - 'email' => __('Email', 'site-reviews'), |
|
31 | - 'ip_address' => __('IP Address', 'site-reviews'), |
|
32 | - 'response' => __('Response', 'site-reviews'), |
|
33 | - 'review_type' => __('Type', 'site-reviews'), |
|
34 | - 'rating' => __('Rating', 'site-reviews'), |
|
35 | - 'pinned' => __('Pinned', 'site-reviews'), |
|
36 | - 'date' => '', |
|
37 | - ], |
|
38 | - 'menu_icon' => 'dashicons-star-half', |
|
39 | - 'menu_name' => glsr()->name, |
|
40 | - 'map_meta_cap' => true, |
|
41 | - 'plural' => __('Reviews', 'site-reviews'), |
|
42 | - 'post_type' => Application::POST_TYPE, |
|
43 | - 'rest_controller_class' => RestReviewController::class, |
|
44 | - 'show_in_rest' => true, |
|
45 | - 'single' => __('Review', 'site-reviews'), |
|
46 | - ]); |
|
47 | - $this->execute($command); |
|
48 | - } |
|
13 | + /** |
|
14 | + * @return void |
|
15 | + * @action init |
|
16 | + */ |
|
17 | + public function registerPostType() |
|
18 | + { |
|
19 | + if (!glsr()->hasPermission()) { |
|
20 | + return; |
|
21 | + } |
|
22 | + $command = new RegisterPostType([ |
|
23 | + 'capabilities' => ['create_posts' => 'create_'.Application::POST_TYPE], |
|
24 | + 'capability_type' => Application::POST_TYPE, |
|
25 | + 'columns' => [ |
|
26 | + 'title' => '', |
|
27 | + 'category' => '', |
|
28 | + 'assigned_to' => __('Assigned To', 'site-reviews'), |
|
29 | + 'reviewer' => __('Author', 'site-reviews'), |
|
30 | + 'email' => __('Email', 'site-reviews'), |
|
31 | + 'ip_address' => __('IP Address', 'site-reviews'), |
|
32 | + 'response' => __('Response', 'site-reviews'), |
|
33 | + 'review_type' => __('Type', 'site-reviews'), |
|
34 | + 'rating' => __('Rating', 'site-reviews'), |
|
35 | + 'pinned' => __('Pinned', 'site-reviews'), |
|
36 | + 'date' => '', |
|
37 | + ], |
|
38 | + 'menu_icon' => 'dashicons-star-half', |
|
39 | + 'menu_name' => glsr()->name, |
|
40 | + 'map_meta_cap' => true, |
|
41 | + 'plural' => __('Reviews', 'site-reviews'), |
|
42 | + 'post_type' => Application::POST_TYPE, |
|
43 | + 'rest_controller_class' => RestReviewController::class, |
|
44 | + 'show_in_rest' => true, |
|
45 | + 'single' => __('Review', 'site-reviews'), |
|
46 | + ]); |
|
47 | + $this->execute($command); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @return void |
|
52 | - * @action init |
|
53 | - */ |
|
54 | - public function registerShortcodes() |
|
55 | - { |
|
56 | - $command = new RegisterShortcodes([ |
|
57 | - 'site_reviews', |
|
58 | - 'site_reviews_form', |
|
59 | - 'site_reviews_summary', |
|
60 | - ]); |
|
61 | - $this->execute($command); |
|
62 | - } |
|
50 | + /** |
|
51 | + * @return void |
|
52 | + * @action init |
|
53 | + */ |
|
54 | + public function registerShortcodes() |
|
55 | + { |
|
56 | + $command = new RegisterShortcodes([ |
|
57 | + 'site_reviews', |
|
58 | + 'site_reviews_form', |
|
59 | + 'site_reviews_summary', |
|
60 | + ]); |
|
61 | + $this->execute($command); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @return void |
|
66 | - * @action init |
|
67 | - */ |
|
68 | - public function registerTaxonomy() |
|
69 | - { |
|
70 | - $command = new RegisterTaxonomy([ |
|
71 | - 'hierarchical' => true, |
|
72 | - 'meta_box_cb' => [glsr(EditorController::class), 'renderTaxonomyMetabox'], |
|
73 | - 'public' => false, |
|
74 | - 'rest_controller_class' => RestCategoryController::class, |
|
75 | - 'show_admin_column' => true, |
|
76 | - 'show_in_rest' => true, |
|
77 | - 'show_ui' => true, |
|
78 | - ]); |
|
79 | - $this->execute($command); |
|
80 | - } |
|
64 | + /** |
|
65 | + * @return void |
|
66 | + * @action init |
|
67 | + */ |
|
68 | + public function registerTaxonomy() |
|
69 | + { |
|
70 | + $command = new RegisterTaxonomy([ |
|
71 | + 'hierarchical' => true, |
|
72 | + 'meta_box_cb' => [glsr(EditorController::class), 'renderTaxonomyMetabox'], |
|
73 | + 'public' => false, |
|
74 | + 'rest_controller_class' => RestCategoryController::class, |
|
75 | + 'show_admin_column' => true, |
|
76 | + 'show_in_rest' => true, |
|
77 | + 'show_ui' => true, |
|
78 | + ]); |
|
79 | + $this->execute($command); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @return void |
|
84 | - * @action widgets_init |
|
85 | - */ |
|
86 | - public function registerWidgets() |
|
87 | - { |
|
88 | - $command = new RegisterWidgets([ |
|
89 | - 'site-reviews', |
|
90 | - 'site-reviews-form', |
|
91 | - 'site-reviews-summary', |
|
92 | - ]); |
|
93 | - $this->execute($command); |
|
94 | - } |
|
82 | + /** |
|
83 | + * @return void |
|
84 | + * @action widgets_init |
|
85 | + */ |
|
86 | + public function registerWidgets() |
|
87 | + { |
|
88 | + $command = new RegisterWidgets([ |
|
89 | + 'site-reviews', |
|
90 | + 'site-reviews-form', |
|
91 | + 'site-reviews-summary', |
|
92 | + ]); |
|
93 | + $this->execute($command); |
|
94 | + } |
|
95 | 95 | } |
@@ -16,35 +16,35 @@ discard block |
||
16 | 16 | */ |
17 | 17 | public function registerPostType() |
18 | 18 | { |
19 | - if (!glsr()->hasPermission()) { |
|
19 | + if( !glsr()->hasPermission() ) { |
|
20 | 20 | return; |
21 | 21 | } |
22 | - $command = new RegisterPostType([ |
|
22 | + $command = new RegisterPostType( [ |
|
23 | 23 | 'capabilities' => ['create_posts' => 'create_'.Application::POST_TYPE], |
24 | 24 | 'capability_type' => Application::POST_TYPE, |
25 | 25 | 'columns' => [ |
26 | 26 | 'title' => '', |
27 | 27 | 'category' => '', |
28 | - 'assigned_to' => __('Assigned To', 'site-reviews'), |
|
29 | - 'reviewer' => __('Author', 'site-reviews'), |
|
30 | - 'email' => __('Email', 'site-reviews'), |
|
31 | - 'ip_address' => __('IP Address', 'site-reviews'), |
|
32 | - 'response' => __('Response', 'site-reviews'), |
|
33 | - 'review_type' => __('Type', 'site-reviews'), |
|
34 | - 'rating' => __('Rating', 'site-reviews'), |
|
35 | - 'pinned' => __('Pinned', 'site-reviews'), |
|
28 | + 'assigned_to' => __( 'Assigned To', 'site-reviews' ), |
|
29 | + 'reviewer' => __( 'Author', 'site-reviews' ), |
|
30 | + 'email' => __( 'Email', 'site-reviews' ), |
|
31 | + 'ip_address' => __( 'IP Address', 'site-reviews' ), |
|
32 | + 'response' => __( 'Response', 'site-reviews' ), |
|
33 | + 'review_type' => __( 'Type', 'site-reviews' ), |
|
34 | + 'rating' => __( 'Rating', 'site-reviews' ), |
|
35 | + 'pinned' => __( 'Pinned', 'site-reviews' ), |
|
36 | 36 | 'date' => '', |
37 | 37 | ], |
38 | 38 | 'menu_icon' => 'dashicons-star-half', |
39 | 39 | 'menu_name' => glsr()->name, |
40 | 40 | 'map_meta_cap' => true, |
41 | - 'plural' => __('Reviews', 'site-reviews'), |
|
41 | + 'plural' => __( 'Reviews', 'site-reviews' ), |
|
42 | 42 | 'post_type' => Application::POST_TYPE, |
43 | 43 | 'rest_controller_class' => RestReviewController::class, |
44 | 44 | 'show_in_rest' => true, |
45 | - 'single' => __('Review', 'site-reviews'), |
|
46 | - ]); |
|
47 | - $this->execute($command); |
|
45 | + 'single' => __( 'Review', 'site-reviews' ), |
|
46 | + ] ); |
|
47 | + $this->execute( $command ); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function registerShortcodes() |
55 | 55 | { |
56 | - $command = new RegisterShortcodes([ |
|
56 | + $command = new RegisterShortcodes( [ |
|
57 | 57 | 'site_reviews', |
58 | 58 | 'site_reviews_form', |
59 | 59 | 'site_reviews_summary', |
60 | - ]); |
|
61 | - $this->execute($command); |
|
60 | + ] ); |
|
61 | + $this->execute( $command ); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -67,16 +67,16 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function registerTaxonomy() |
69 | 69 | { |
70 | - $command = new RegisterTaxonomy([ |
|
70 | + $command = new RegisterTaxonomy( [ |
|
71 | 71 | 'hierarchical' => true, |
72 | - 'meta_box_cb' => [glsr(EditorController::class), 'renderTaxonomyMetabox'], |
|
72 | + 'meta_box_cb' => [glsr( EditorController::class ), 'renderTaxonomyMetabox'], |
|
73 | 73 | 'public' => false, |
74 | 74 | 'rest_controller_class' => RestCategoryController::class, |
75 | 75 | 'show_admin_column' => true, |
76 | 76 | 'show_in_rest' => true, |
77 | 77 | 'show_ui' => true, |
78 | - ]); |
|
79 | - $this->execute($command); |
|
78 | + ] ); |
|
79 | + $this->execute( $command ); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function registerWidgets() |
87 | 87 | { |
88 | - $command = new RegisterWidgets([ |
|
88 | + $command = new RegisterWidgets( [ |
|
89 | 89 | 'site-reviews', |
90 | 90 | 'site-reviews-form', |
91 | 91 | 'site-reviews-summary', |
92 | - ]); |
|
93 | - $this->execute($command); |
|
92 | + ] ); |
|
93 | + $this->execute( $command ); |
|
94 | 94 | } |
95 | 95 | } |
@@ -6,11 +6,11 @@ |
||
6 | 6 | |
7 | 7 | class Migrate_4_4_0 |
8 | 8 | { |
9 | - /** |
|
10 | - * @return void |
|
11 | - */ |
|
12 | - public function run() |
|
13 | - { |
|
14 | - glsr(Role::class)->resetAll(); |
|
15 | - } |
|
9 | + /** |
|
10 | + * @return void |
|
11 | + */ |
|
12 | + public function run() |
|
13 | + { |
|
14 | + glsr(Role::class)->resetAll(); |
|
15 | + } |
|
16 | 16 | } |
@@ -11,6 +11,6 @@ |
||
11 | 11 | */ |
12 | 12 | public function run() |
13 | 13 | { |
14 | - glsr(Role::class)->resetAll(); |
|
14 | + glsr( Role::class )->resetAll(); |
|
15 | 15 | } |
16 | 16 | } |
@@ -6,16 +6,16 @@ |
||
6 | 6 | <p><?= __('Add-ons extend the functionality of Site Reviews.', 'site-reviews'); ?></p> |
7 | 7 | <div class="glsr-addons wp-clearfix"> |
8 | 8 | <?php |
9 | - $template->render('partials/addons/addon', [ |
|
10 | - 'beta' => true, |
|
11 | - 'context' => [ |
|
12 | - 'description' => __('This add-on allows your site visitors to submit images with their reviews. Apply now to test the unreleased beta version.', 'site-reviews'), |
|
13 | - 'link' => 'https://niftyplugins.com/plugins/images/', |
|
14 | - 'slug' => 'images', |
|
15 | - 'title' => 'Images', |
|
16 | - ], |
|
17 | - 'plugin' => 'site-reviews-images/site-reviews-images.php', |
|
18 | - ]); |
|
19 | - ?> |
|
9 | + $template->render('partials/addons/addon', [ |
|
10 | + 'beta' => true, |
|
11 | + 'context' => [ |
|
12 | + 'description' => __('This add-on allows your site visitors to submit images with their reviews. Apply now to test the unreleased beta version.', 'site-reviews'), |
|
13 | + 'link' => 'https://niftyplugins.com/plugins/images/', |
|
14 | + 'slug' => 'images', |
|
15 | + 'title' => 'Images', |
|
16 | + ], |
|
17 | + 'plugin' => 'site-reviews-images/site-reviews-images.php', |
|
18 | + ]); |
|
19 | + ?> |
|
20 | 20 | </div> |
21 | 21 | </div> |
@@ -1,21 +1,21 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="wrap"> |
4 | - <h1 class="wp-heading-inline"><?= esc_html(get_admin_page_title()); ?></h1> |
|
4 | + <h1 class="wp-heading-inline"><?= esc_html( get_admin_page_title() ); ?></h1> |
|
5 | 5 | <?= $notices; ?> |
6 | - <p><?= __('Add-ons extend the functionality of Site Reviews.', 'site-reviews'); ?></p> |
|
6 | + <p><?= __( 'Add-ons extend the functionality of Site Reviews.', 'site-reviews' ); ?></p> |
|
7 | 7 | <div class="glsr-addons wp-clearfix"> |
8 | 8 | <?php |
9 | - $template->render('partials/addons/addon', [ |
|
9 | + $template->render( 'partials/addons/addon', [ |
|
10 | 10 | 'beta' => true, |
11 | 11 | 'context' => [ |
12 | - 'description' => __('This add-on allows your site visitors to submit images with their reviews. Apply now to test the unreleased beta version.', 'site-reviews'), |
|
12 | + 'description' => __( 'This add-on allows your site visitors to submit images with their reviews. Apply now to test the unreleased beta version.', 'site-reviews' ), |
|
13 | 13 | 'link' => 'https://niftyplugins.com/plugins/images/', |
14 | 14 | 'slug' => 'images', |
15 | 15 | 'title' => 'Images', |
16 | 16 | ], |
17 | 17 | 'plugin' => 'site-reviews-images/site-reviews-images.php', |
18 | - ]); |
|
18 | + ] ); |
|
19 | 19 | ?> |
20 | 20 | </div> |
21 | 21 | </div> |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="glsr-addon-wrap"> |
4 | 4 | <div class="glsr-addon"> |
@@ -10,23 +10,23 @@ discard block |
||
10 | 10 | <p>{{ description }}</p> |
11 | 11 | </div> |
12 | 12 | <div class="glsr-addon-footer"> |
13 | - <?php if (!is_wp_error(validate_plugin($plugin))) : ?> |
|
14 | - <?php if (is_plugin_active($plugin)) : ?> |
|
13 | + <?php if( !is_wp_error( validate_plugin( $plugin ) ) ) : ?> |
|
14 | + <?php if( is_plugin_active( $plugin ) ) : ?> |
|
15 | 15 | <span class="glsr-addon-link button button-secondary" disabled> |
16 | - <?= __('Installed', 'site-reviews'); ?> |
|
16 | + <?= __( 'Installed', 'site-reviews' ); ?> |
|
17 | 17 | </span> |
18 | 18 | <?php else: ?> |
19 | - <a href="<?= wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin='.$plugin), 'activate-plugin_'.$plugin); ?>" class="glsr-addon-link button button-secondary"> |
|
20 | - <?= __('Activate', 'site-reviews'); ?> |
|
19 | + <a href="<?= wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin='.$plugin ), 'activate-plugin_'.$plugin ); ?>" class="glsr-addon-link button button-secondary"> |
|
20 | + <?= __( 'Activate', 'site-reviews' ); ?> |
|
21 | 21 | </a> |
22 | 22 | <?php endif; ?> |
23 | - <?php elseif (!empty($beta)): ?> |
|
23 | + <?php elseif( !empty($beta) ): ?> |
|
24 | 24 | <a href="mailto:[email protected]?subject=I%20would%20like%20to%20become%20a%20beta%20tester%20({{ slug }})" class="glsr-addon-link glsr-external button button-secondary"> |
25 | - <?= __('Try the beta', 'site-reviews'); ?> |
|
25 | + <?= __( 'Try the beta', 'site-reviews' ); ?> |
|
26 | 26 | </a> |
27 | 27 | <?php else: ?> |
28 | 28 | <a href="{{ link }}" class="glsr-addon-link glsr-external button button-secondary"> |
29 | - <?= __('More Info', 'site-reviews'); ?> |
|
29 | + <?= __( 'More Info', 'site-reviews' ); ?> |
|
30 | 30 | </a> |
31 | 31 | <?php endif; ?> |
32 | 32 | </div> |
@@ -15,8 +15,11 @@ discard block |
||
15 | 15 | <span class="glsr-addon-link button button-secondary" disabled> |
16 | 16 | <?= __('Installed', 'site-reviews'); ?> |
17 | 17 | </span> |
18 | - <?php else: ?> |
|
19 | - <a href="<?= wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin='.$plugin), 'activate-plugin_'.$plugin); ?>" class="glsr-addon-link button button-secondary"> |
|
18 | + <?php else { |
|
19 | + : ?> |
|
20 | + <a href="<?= wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin='.$plugin), 'activate-plugin_'.$plugin); |
|
21 | +} |
|
22 | +?>" class="glsr-addon-link button button-secondary"> |
|
20 | 23 | <?= __('Activate', 'site-reviews'); ?> |
21 | 24 | </a> |
22 | 25 | <?php endif; ?> |
@@ -24,9 +27,12 @@ discard block |
||
24 | 27 | <a href="mailto:[email protected]?subject=I%20would%20like%20to%20become%20a%20beta%20tester%20({{ slug }})" class="glsr-addon-link glsr-external button button-secondary"> |
25 | 28 | <?= __('Try the beta', 'site-reviews'); ?> |
26 | 29 | </a> |
27 | - <?php else: ?> |
|
30 | + <?php else { |
|
31 | + : ?> |
|
28 | 32 | <a href="{{ link }}" class="glsr-addon-link glsr-external button button-secondary"> |
29 | - <?= __('More Info', 'site-reviews'); ?> |
|
33 | + <?= __('More Info', 'site-reviews'); |
|
34 | +} |
|
35 | +?> |
|
30 | 36 | </a> |
31 | 37 | <?php endif; ?> |
32 | 38 | </div> |
@@ -21,111 +21,111 @@ |
||
21 | 21 | |
22 | 22 | class Actions implements HooksContract |
23 | 23 | { |
24 | - protected $about; |
|
25 | - protected $admin; |
|
26 | - protected $app; |
|
27 | - protected $blocks; |
|
28 | - protected $console; |
|
29 | - protected $editor; |
|
30 | - protected $listtable; |
|
31 | - protected $menu; |
|
32 | - protected $main; |
|
33 | - protected $notices; |
|
34 | - protected $public; |
|
35 | - protected $review; |
|
36 | - protected $router; |
|
37 | - protected $settings; |
|
38 | - protected $taxonomy; |
|
39 | - protected $translator; |
|
40 | - protected $trustalyze; |
|
41 | - protected $welcome; |
|
24 | + protected $about; |
|
25 | + protected $admin; |
|
26 | + protected $app; |
|
27 | + protected $blocks; |
|
28 | + protected $console; |
|
29 | + protected $editor; |
|
30 | + protected $listtable; |
|
31 | + protected $menu; |
|
32 | + protected $main; |
|
33 | + protected $notices; |
|
34 | + protected $public; |
|
35 | + protected $review; |
|
36 | + protected $router; |
|
37 | + protected $settings; |
|
38 | + protected $taxonomy; |
|
39 | + protected $translator; |
|
40 | + protected $trustalyze; |
|
41 | + protected $welcome; |
|
42 | 42 | |
43 | - public function __construct(Application $app ) { |
|
44 | - $this->app = $app; |
|
45 | - $this->admin = $app->make(AdminController::class); |
|
46 | - $this->blocks = $app->make(BlocksController::class); |
|
47 | - $this->console = $app->make(Console::class); |
|
48 | - $this->editor = $app->make(EditorController::class); |
|
49 | - $this->listtable = $app->make(ListTableController::class); |
|
50 | - $this->main = $app->make(MainController::class); |
|
51 | - $this->menu = $app->make(MenuController::class); |
|
52 | - $this->notices = $app->make(NoticeController::class); |
|
53 | - $this->public = $app->make(PublicController::class); |
|
54 | - $this->review = $app->make(ReviewController::class); |
|
55 | - $this->router = $app->make(Router::class); |
|
56 | - $this->settings = $app->make(SettingsController::class); |
|
57 | - $this->taxonomy = $app->make(TaxonomyController::class); |
|
58 | - $this->translator = $app->make(TranslationController::class); |
|
59 | - $this->trustalyze = $app->make(TrustalyzeController::class); |
|
60 | - $this->welcome = $app->make(WelcomeController::class); |
|
61 | - } |
|
43 | + public function __construct(Application $app ) { |
|
44 | + $this->app = $app; |
|
45 | + $this->admin = $app->make(AdminController::class); |
|
46 | + $this->blocks = $app->make(BlocksController::class); |
|
47 | + $this->console = $app->make(Console::class); |
|
48 | + $this->editor = $app->make(EditorController::class); |
|
49 | + $this->listtable = $app->make(ListTableController::class); |
|
50 | + $this->main = $app->make(MainController::class); |
|
51 | + $this->menu = $app->make(MenuController::class); |
|
52 | + $this->notices = $app->make(NoticeController::class); |
|
53 | + $this->public = $app->make(PublicController::class); |
|
54 | + $this->review = $app->make(ReviewController::class); |
|
55 | + $this->router = $app->make(Router::class); |
|
56 | + $this->settings = $app->make(SettingsController::class); |
|
57 | + $this->taxonomy = $app->make(TaxonomyController::class); |
|
58 | + $this->translator = $app->make(TranslationController::class); |
|
59 | + $this->trustalyze = $app->make(TrustalyzeController::class); |
|
60 | + $this->welcome = $app->make(WelcomeController::class); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @return void |
|
65 | - */ |
|
66 | - public function run() |
|
67 | - { |
|
68 | - add_action('admin_enqueue_scripts', [$this->admin, 'enqueueAssets']); |
|
69 | - add_action('admin_init', [$this->admin, 'registerTinymcePopups']); |
|
70 | - add_action('media_buttons', [$this->admin, 'renderTinymceButton'], 11); |
|
71 | - add_action('admin_init', [$this->admin, 'runMigrations']); |
|
72 | - add_action('plugins_loaded', [$this->app, 'getDefaults'], 11); |
|
73 | - add_action('plugins_loaded', [$this->app, 'registerAddons']); |
|
74 | - add_action('plugins_loaded', [$this->app, 'registerLanguages']); |
|
75 | - add_action('plugins_loaded', [$this->app, 'registerReviewTypes']); |
|
76 | - add_action('admin_init', [$this->app, 'setDefaults']); |
|
77 | - add_action('init', [$this->blocks, 'registerAssets'], 9); |
|
78 | - add_action('init', [$this->blocks, 'registerBlocks']); |
|
79 | - add_action('admin_footer', [$this->console, 'logOnce']); |
|
80 | - add_action('wp_footer', [$this->console, 'logOnce']); |
|
81 | - add_action('add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes']); |
|
82 | - add_action('admin_print_scripts', [$this->editor, 'removeAutosave'], 999); |
|
83 | - add_action('admin_menu', [$this->editor, 'removeMetaBoxes']); |
|
84 | - add_action('current_screen', [$this->editor, 'removePostTypeSupport']); |
|
85 | - add_action('post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox']); |
|
86 | - add_action('admin_head', [$this->editor, 'renderReviewFields']); |
|
87 | - add_action('admin_action_revert', [$this->editor, 'revertReview']); |
|
88 | - add_action('save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'], 10, 3); |
|
89 | - add_action('admin_action_approve', [$this->listtable, 'approve']); |
|
90 | - add_action('bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2); |
|
91 | - add_action('restrict_manage_posts', [$this->listtable, 'renderColumnFilters']); |
|
92 | - add_action('manage_'.Application::POST_TYPE.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2); |
|
93 | - add_action('save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields']); |
|
94 | - add_action('pre_get_posts', [$this->listtable, 'setQueryForColumn']); |
|
95 | - add_action('admin_action_unapprove', [$this->listtable, 'unapprove']); |
|
96 | - add_action('init', [$this->main, 'registerPostType'], 8); |
|
97 | - add_action('init', [$this->main, 'registerShortcodes']); |
|
98 | - add_action('init', [$this->main, 'registerTaxonomy']); |
|
99 | - add_action('widgets_init', [$this->main, 'registerWidgets']); |
|
100 | - add_action('admin_menu', [$this->menu, 'registerMenuCount']); |
|
101 | - add_action('admin_menu', [$this->menu, 'registerSubMenus']); |
|
102 | - add_action('admin_init', [$this->menu, 'setCustomPermissions'], 999); |
|
103 | - add_action('admin_notices', [$this->notices, 'filterAdminNotices']); |
|
104 | - add_action('wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999); |
|
105 | - add_filter('site-reviews/builder', [$this->public, 'modifyBuilder']); |
|
106 | - add_action('wp_footer', [$this->public, 'renderSchema']); |
|
107 | - add_action('set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6); |
|
108 | - add_action('transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3); |
|
109 | - add_action('site-reviews/review/created', [$this->review, 'onAfterCreate']); |
|
110 | - add_action('before_delete_post', [$this->review, 'onBeforeDelete']); |
|
111 | - add_action('update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4); |
|
112 | - add_action('admin_init', [$this->router, 'routeAdminPostRequest']); |
|
113 | - add_action('wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
114 | - add_action('wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
115 | - add_action('init', [$this->router, 'routePublicPostRequest']); |
|
116 | - add_action('admin_init', [$this->settings, 'registerSettings']); |
|
117 | - add_action(Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents']); |
|
118 | - add_action(Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents']); |
|
119 | - add_action(Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents']); |
|
120 | - add_action(Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents']); |
|
121 | - add_action('restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9); |
|
122 | - add_action('set_object_terms', [$this->taxonomy, 'restrictTermSelection'], 9, 6); |
|
123 | - add_action('admin_enqueue_scripts', [$this->translator, 'translatePostStatusLabels']); |
|
124 | - add_action('site-reviews/review/created', [$this->trustalyze, 'onCreated']); |
|
125 | - add_action('site-reviews/review/reverted', [$this->trustalyze, 'onReverted']); |
|
126 | - add_action('site-reviews/review/saved', [$this->trustalyze, 'onSaved']); |
|
127 | - add_action('updated_postmeta', [$this->trustalyze, 'onUpdatedMeta'], 10, 3); |
|
128 | - add_action('activated_plugin', [$this->welcome, 'redirectOnActivation'], 10, 2); |
|
129 | - add_action('admin_menu', [$this->welcome, 'registerPage']); |
|
130 | - } |
|
63 | + /** |
|
64 | + * @return void |
|
65 | + */ |
|
66 | + public function run() |
|
67 | + { |
|
68 | + add_action('admin_enqueue_scripts', [$this->admin, 'enqueueAssets']); |
|
69 | + add_action('admin_init', [$this->admin, 'registerTinymcePopups']); |
|
70 | + add_action('media_buttons', [$this->admin, 'renderTinymceButton'], 11); |
|
71 | + add_action('admin_init', [$this->admin, 'runMigrations']); |
|
72 | + add_action('plugins_loaded', [$this->app, 'getDefaults'], 11); |
|
73 | + add_action('plugins_loaded', [$this->app, 'registerAddons']); |
|
74 | + add_action('plugins_loaded', [$this->app, 'registerLanguages']); |
|
75 | + add_action('plugins_loaded', [$this->app, 'registerReviewTypes']); |
|
76 | + add_action('admin_init', [$this->app, 'setDefaults']); |
|
77 | + add_action('init', [$this->blocks, 'registerAssets'], 9); |
|
78 | + add_action('init', [$this->blocks, 'registerBlocks']); |
|
79 | + add_action('admin_footer', [$this->console, 'logOnce']); |
|
80 | + add_action('wp_footer', [$this->console, 'logOnce']); |
|
81 | + add_action('add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes']); |
|
82 | + add_action('admin_print_scripts', [$this->editor, 'removeAutosave'], 999); |
|
83 | + add_action('admin_menu', [$this->editor, 'removeMetaBoxes']); |
|
84 | + add_action('current_screen', [$this->editor, 'removePostTypeSupport']); |
|
85 | + add_action('post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox']); |
|
86 | + add_action('admin_head', [$this->editor, 'renderReviewFields']); |
|
87 | + add_action('admin_action_revert', [$this->editor, 'revertReview']); |
|
88 | + add_action('save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'], 10, 3); |
|
89 | + add_action('admin_action_approve', [$this->listtable, 'approve']); |
|
90 | + add_action('bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2); |
|
91 | + add_action('restrict_manage_posts', [$this->listtable, 'renderColumnFilters']); |
|
92 | + add_action('manage_'.Application::POST_TYPE.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2); |
|
93 | + add_action('save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields']); |
|
94 | + add_action('pre_get_posts', [$this->listtable, 'setQueryForColumn']); |
|
95 | + add_action('admin_action_unapprove', [$this->listtable, 'unapprove']); |
|
96 | + add_action('init', [$this->main, 'registerPostType'], 8); |
|
97 | + add_action('init', [$this->main, 'registerShortcodes']); |
|
98 | + add_action('init', [$this->main, 'registerTaxonomy']); |
|
99 | + add_action('widgets_init', [$this->main, 'registerWidgets']); |
|
100 | + add_action('admin_menu', [$this->menu, 'registerMenuCount']); |
|
101 | + add_action('admin_menu', [$this->menu, 'registerSubMenus']); |
|
102 | + add_action('admin_init', [$this->menu, 'setCustomPermissions'], 999); |
|
103 | + add_action('admin_notices', [$this->notices, 'filterAdminNotices']); |
|
104 | + add_action('wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999); |
|
105 | + add_filter('site-reviews/builder', [$this->public, 'modifyBuilder']); |
|
106 | + add_action('wp_footer', [$this->public, 'renderSchema']); |
|
107 | + add_action('set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6); |
|
108 | + add_action('transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3); |
|
109 | + add_action('site-reviews/review/created', [$this->review, 'onAfterCreate']); |
|
110 | + add_action('before_delete_post', [$this->review, 'onBeforeDelete']); |
|
111 | + add_action('update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4); |
|
112 | + add_action('admin_init', [$this->router, 'routeAdminPostRequest']); |
|
113 | + add_action('wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
114 | + add_action('wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
115 | + add_action('init', [$this->router, 'routePublicPostRequest']); |
|
116 | + add_action('admin_init', [$this->settings, 'registerSettings']); |
|
117 | + add_action(Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents']); |
|
118 | + add_action(Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents']); |
|
119 | + add_action(Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents']); |
|
120 | + add_action(Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents']); |
|
121 | + add_action('restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9); |
|
122 | + add_action('set_object_terms', [$this->taxonomy, 'restrictTermSelection'], 9, 6); |
|
123 | + add_action('admin_enqueue_scripts', [$this->translator, 'translatePostStatusLabels']); |
|
124 | + add_action('site-reviews/review/created', [$this->trustalyze, 'onCreated']); |
|
125 | + add_action('site-reviews/review/reverted', [$this->trustalyze, 'onReverted']); |
|
126 | + add_action('site-reviews/review/saved', [$this->trustalyze, 'onSaved']); |
|
127 | + add_action('updated_postmeta', [$this->trustalyze, 'onUpdatedMeta'], 10, 3); |
|
128 | + add_action('activated_plugin', [$this->welcome, 'redirectOnActivation'], 10, 2); |
|
129 | + add_action('admin_menu', [$this->welcome, 'registerPage']); |
|
130 | + } |
|
131 | 131 | } |
@@ -40,24 +40,24 @@ discard block |
||
40 | 40 | protected $trustalyze; |
41 | 41 | protected $welcome; |
42 | 42 | |
43 | - public function __construct(Application $app ) { |
|
43 | + public function __construct( Application $app ) { |
|
44 | 44 | $this->app = $app; |
45 | - $this->admin = $app->make(AdminController::class); |
|
46 | - $this->blocks = $app->make(BlocksController::class); |
|
47 | - $this->console = $app->make(Console::class); |
|
48 | - $this->editor = $app->make(EditorController::class); |
|
49 | - $this->listtable = $app->make(ListTableController::class); |
|
50 | - $this->main = $app->make(MainController::class); |
|
51 | - $this->menu = $app->make(MenuController::class); |
|
52 | - $this->notices = $app->make(NoticeController::class); |
|
53 | - $this->public = $app->make(PublicController::class); |
|
54 | - $this->review = $app->make(ReviewController::class); |
|
55 | - $this->router = $app->make(Router::class); |
|
56 | - $this->settings = $app->make(SettingsController::class); |
|
57 | - $this->taxonomy = $app->make(TaxonomyController::class); |
|
58 | - $this->translator = $app->make(TranslationController::class); |
|
59 | - $this->trustalyze = $app->make(TrustalyzeController::class); |
|
60 | - $this->welcome = $app->make(WelcomeController::class); |
|
45 | + $this->admin = $app->make( AdminController::class ); |
|
46 | + $this->blocks = $app->make( BlocksController::class ); |
|
47 | + $this->console = $app->make( Console::class ); |
|
48 | + $this->editor = $app->make( EditorController::class ); |
|
49 | + $this->listtable = $app->make( ListTableController::class ); |
|
50 | + $this->main = $app->make( MainController::class ); |
|
51 | + $this->menu = $app->make( MenuController::class ); |
|
52 | + $this->notices = $app->make( NoticeController::class ); |
|
53 | + $this->public = $app->make( PublicController::class ); |
|
54 | + $this->review = $app->make( ReviewController::class ); |
|
55 | + $this->router = $app->make( Router::class ); |
|
56 | + $this->settings = $app->make( SettingsController::class ); |
|
57 | + $this->taxonomy = $app->make( TaxonomyController::class ); |
|
58 | + $this->translator = $app->make( TranslationController::class ); |
|
59 | + $this->trustalyze = $app->make( TrustalyzeController::class ); |
|
60 | + $this->welcome = $app->make( WelcomeController::class ); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -65,67 +65,67 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function run() |
67 | 67 | { |
68 | - add_action('admin_enqueue_scripts', [$this->admin, 'enqueueAssets']); |
|
69 | - add_action('admin_init', [$this->admin, 'registerTinymcePopups']); |
|
70 | - add_action('media_buttons', [$this->admin, 'renderTinymceButton'], 11); |
|
71 | - add_action('admin_init', [$this->admin, 'runMigrations']); |
|
72 | - add_action('plugins_loaded', [$this->app, 'getDefaults'], 11); |
|
73 | - add_action('plugins_loaded', [$this->app, 'registerAddons']); |
|
74 | - add_action('plugins_loaded', [$this->app, 'registerLanguages']); |
|
75 | - add_action('plugins_loaded', [$this->app, 'registerReviewTypes']); |
|
76 | - add_action('admin_init', [$this->app, 'setDefaults']); |
|
77 | - add_action('init', [$this->blocks, 'registerAssets'], 9); |
|
78 | - add_action('init', [$this->blocks, 'registerBlocks']); |
|
79 | - add_action('admin_footer', [$this->console, 'logOnce']); |
|
80 | - add_action('wp_footer', [$this->console, 'logOnce']); |
|
81 | - add_action('add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes']); |
|
82 | - add_action('admin_print_scripts', [$this->editor, 'removeAutosave'], 999); |
|
83 | - add_action('admin_menu', [$this->editor, 'removeMetaBoxes']); |
|
84 | - add_action('current_screen', [$this->editor, 'removePostTypeSupport']); |
|
85 | - add_action('post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox']); |
|
86 | - add_action('admin_head', [$this->editor, 'renderReviewFields']); |
|
87 | - add_action('admin_action_revert', [$this->editor, 'revertReview']); |
|
88 | - add_action('save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'], 10, 3); |
|
89 | - add_action('admin_action_approve', [$this->listtable, 'approve']); |
|
90 | - add_action('bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2); |
|
91 | - add_action('restrict_manage_posts', [$this->listtable, 'renderColumnFilters']); |
|
92 | - add_action('manage_'.Application::POST_TYPE.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2); |
|
93 | - add_action('save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields']); |
|
94 | - add_action('pre_get_posts', [$this->listtable, 'setQueryForColumn']); |
|
95 | - add_action('admin_action_unapprove', [$this->listtable, 'unapprove']); |
|
96 | - add_action('init', [$this->main, 'registerPostType'], 8); |
|
97 | - add_action('init', [$this->main, 'registerShortcodes']); |
|
98 | - add_action('init', [$this->main, 'registerTaxonomy']); |
|
99 | - add_action('widgets_init', [$this->main, 'registerWidgets']); |
|
100 | - add_action('admin_menu', [$this->menu, 'registerMenuCount']); |
|
101 | - add_action('admin_menu', [$this->menu, 'registerSubMenus']); |
|
102 | - add_action('admin_init', [$this->menu, 'setCustomPermissions'], 999); |
|
103 | - add_action('admin_notices', [$this->notices, 'filterAdminNotices']); |
|
104 | - add_action('wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999); |
|
105 | - add_filter('site-reviews/builder', [$this->public, 'modifyBuilder']); |
|
106 | - add_action('wp_footer', [$this->public, 'renderSchema']); |
|
107 | - add_action('set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6); |
|
108 | - add_action('transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3); |
|
109 | - add_action('site-reviews/review/created', [$this->review, 'onAfterCreate']); |
|
110 | - add_action('before_delete_post', [$this->review, 'onBeforeDelete']); |
|
111 | - add_action('update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4); |
|
112 | - add_action('admin_init', [$this->router, 'routeAdminPostRequest']); |
|
113 | - add_action('wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
114 | - add_action('wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
115 | - add_action('init', [$this->router, 'routePublicPostRequest']); |
|
116 | - add_action('admin_init', [$this->settings, 'registerSettings']); |
|
117 | - add_action(Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents']); |
|
118 | - add_action(Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents']); |
|
119 | - add_action(Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents']); |
|
120 | - add_action(Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents']); |
|
121 | - add_action('restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9); |
|
122 | - add_action('set_object_terms', [$this->taxonomy, 'restrictTermSelection'], 9, 6); |
|
123 | - add_action('admin_enqueue_scripts', [$this->translator, 'translatePostStatusLabels']); |
|
124 | - add_action('site-reviews/review/created', [$this->trustalyze, 'onCreated']); |
|
125 | - add_action('site-reviews/review/reverted', [$this->trustalyze, 'onReverted']); |
|
126 | - add_action('site-reviews/review/saved', [$this->trustalyze, 'onSaved']); |
|
127 | - add_action('updated_postmeta', [$this->trustalyze, 'onUpdatedMeta'], 10, 3); |
|
128 | - add_action('activated_plugin', [$this->welcome, 'redirectOnActivation'], 10, 2); |
|
129 | - add_action('admin_menu', [$this->welcome, 'registerPage']); |
|
68 | + add_action( 'admin_enqueue_scripts', [$this->admin, 'enqueueAssets'] ); |
|
69 | + add_action( 'admin_init', [$this->admin, 'registerTinymcePopups'] ); |
|
70 | + add_action( 'media_buttons', [$this->admin, 'renderTinymceButton'], 11 ); |
|
71 | + add_action( 'admin_init', [$this->admin, 'runMigrations'] ); |
|
72 | + add_action( 'plugins_loaded', [$this->app, 'getDefaults'], 11 ); |
|
73 | + add_action( 'plugins_loaded', [$this->app, 'registerAddons'] ); |
|
74 | + add_action( 'plugins_loaded', [$this->app, 'registerLanguages'] ); |
|
75 | + add_action( 'plugins_loaded', [$this->app, 'registerReviewTypes'] ); |
|
76 | + add_action( 'admin_init', [$this->app, 'setDefaults'] ); |
|
77 | + add_action( 'init', [$this->blocks, 'registerAssets'], 9 ); |
|
78 | + add_action( 'init', [$this->blocks, 'registerBlocks'] ); |
|
79 | + add_action( 'admin_footer', [$this->console, 'logOnce'] ); |
|
80 | + add_action( 'wp_footer', [$this->console, 'logOnce'] ); |
|
81 | + add_action( 'add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes'] ); |
|
82 | + add_action( 'admin_print_scripts', [$this->editor, 'removeAutosave'], 999 ); |
|
83 | + add_action( 'admin_menu', [$this->editor, 'removeMetaBoxes'] ); |
|
84 | + add_action( 'current_screen', [$this->editor, 'removePostTypeSupport'] ); |
|
85 | + add_action( 'post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox'] ); |
|
86 | + add_action( 'admin_head', [$this->editor, 'renderReviewFields'] ); |
|
87 | + add_action( 'admin_action_revert', [$this->editor, 'revertReview'] ); |
|
88 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'], 10, 3 ); |
|
89 | + add_action( 'admin_action_approve', [$this->listtable, 'approve'] ); |
|
90 | + add_action( 'bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2 ); |
|
91 | + add_action( 'restrict_manage_posts', [$this->listtable, 'renderColumnFilters'] ); |
|
92 | + add_action( 'manage_'.Application::POST_TYPE.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2 ); |
|
93 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields'] ); |
|
94 | + add_action( 'pre_get_posts', [$this->listtable, 'setQueryForColumn'] ); |
|
95 | + add_action( 'admin_action_unapprove', [$this->listtable, 'unapprove'] ); |
|
96 | + add_action( 'init', [$this->main, 'registerPostType'], 8 ); |
|
97 | + add_action( 'init', [$this->main, 'registerShortcodes'] ); |
|
98 | + add_action( 'init', [$this->main, 'registerTaxonomy'] ); |
|
99 | + add_action( 'widgets_init', [$this->main, 'registerWidgets'] ); |
|
100 | + add_action( 'admin_menu', [$this->menu, 'registerMenuCount'] ); |
|
101 | + add_action( 'admin_menu', [$this->menu, 'registerSubMenus'] ); |
|
102 | + add_action( 'admin_init', [$this->menu, 'setCustomPermissions'], 999 ); |
|
103 | + add_action( 'admin_notices', [$this->notices, 'filterAdminNotices'] ); |
|
104 | + add_action( 'wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999 ); |
|
105 | + add_filter( 'site-reviews/builder', [$this->public, 'modifyBuilder'] ); |
|
106 | + add_action( 'wp_footer', [$this->public, 'renderSchema'] ); |
|
107 | + add_action( 'set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6 ); |
|
108 | + add_action( 'transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3 ); |
|
109 | + add_action( 'site-reviews/review/created', [$this->review, 'onAfterCreate'] ); |
|
110 | + add_action( 'before_delete_post', [$this->review, 'onBeforeDelete'] ); |
|
111 | + add_action( 'update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4 ); |
|
112 | + add_action( 'admin_init', [$this->router, 'routeAdminPostRequest'] ); |
|
113 | + add_action( 'wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
|
114 | + add_action( 'wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
|
115 | + add_action( 'init', [$this->router, 'routePublicPostRequest'] ); |
|
116 | + add_action( 'admin_init', [$this->settings, 'registerSettings'] ); |
|
117 | + add_action( Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents'] ); |
|
118 | + add_action( Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents'] ); |
|
119 | + add_action( Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents'] ); |
|
120 | + add_action( Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents'] ); |
|
121 | + add_action( 'restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9 ); |
|
122 | + add_action( 'set_object_terms', [$this->taxonomy, 'restrictTermSelection'], 9, 6 ); |
|
123 | + add_action( 'admin_enqueue_scripts', [$this->translator, 'translatePostStatusLabels'] ); |
|
124 | + add_action( 'site-reviews/review/created', [$this->trustalyze, 'onCreated'] ); |
|
125 | + add_action( 'site-reviews/review/reverted', [$this->trustalyze, 'onReverted'] ); |
|
126 | + add_action( 'site-reviews/review/saved', [$this->trustalyze, 'onSaved'] ); |
|
127 | + add_action( 'updated_postmeta', [$this->trustalyze, 'onUpdatedMeta'], 10, 3 ); |
|
128 | + add_action( 'activated_plugin', [$this->welcome, 'redirectOnActivation'], 10, 2 ); |
|
129 | + add_action( 'admin_menu', [$this->welcome, 'registerPage'] ); |
|
130 | 130 | } |
131 | 131 | } |
@@ -40,7 +40,8 @@ |
||
40 | 40 | protected $trustalyze; |
41 | 41 | protected $welcome; |
42 | 42 | |
43 | - public function __construct(Application $app ) { |
|
43 | + public function __construct(Application $app ) |
|
44 | + { |
|
44 | 45 | $this->app = $app; |
45 | 46 | $this->admin = $app->make(AdminController::class); |
46 | 47 | $this->blocks = $app->make(BlocksController::class); |
@@ -15,72 +15,72 @@ |
||
15 | 15 | |
16 | 16 | class Filters implements HooksContract |
17 | 17 | { |
18 | - protected $admin; |
|
19 | - protected $app; |
|
20 | - protected $basename; |
|
21 | - protected $blocks; |
|
22 | - protected $editor; |
|
23 | - protected $listtable; |
|
24 | - protected $public; |
|
25 | - protected $translator; |
|
26 | - protected $trustalyze; |
|
27 | - protected $welcome; |
|
18 | + protected $admin; |
|
19 | + protected $app; |
|
20 | + protected $basename; |
|
21 | + protected $blocks; |
|
22 | + protected $editor; |
|
23 | + protected $listtable; |
|
24 | + protected $public; |
|
25 | + protected $translator; |
|
26 | + protected $trustalyze; |
|
27 | + protected $welcome; |
|
28 | 28 | |
29 | - public function __construct(Application $app) |
|
30 | - { |
|
31 | - $this->app = $app; |
|
32 | - $this->admin = $app->make(AdminController::class); |
|
33 | - $this->basename = plugin_basename($app->file); |
|
34 | - $this->blocks = $app->make(BlocksController::class); |
|
35 | - $this->editor = $app->make(EditorController::class); |
|
36 | - $this->listtable = $app->make(ListTableController::class); |
|
37 | - $this->public = $app->make(PublicController::class); |
|
38 | - $this->translator = $app->make(TranslationController::class); |
|
39 | - $this->trustalyze = $app->make(TrustalyzeController::class); |
|
40 | - $this->welcome = $app->make(WelcomeController::class); |
|
41 | - } |
|
29 | + public function __construct(Application $app) |
|
30 | + { |
|
31 | + $this->app = $app; |
|
32 | + $this->admin = $app->make(AdminController::class); |
|
33 | + $this->basename = plugin_basename($app->file); |
|
34 | + $this->blocks = $app->make(BlocksController::class); |
|
35 | + $this->editor = $app->make(EditorController::class); |
|
36 | + $this->listtable = $app->make(ListTableController::class); |
|
37 | + $this->public = $app->make(PublicController::class); |
|
38 | + $this->translator = $app->make(TranslationController::class); |
|
39 | + $this->trustalyze = $app->make(TrustalyzeController::class); |
|
40 | + $this->welcome = $app->make(WelcomeController::class); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return void |
|
45 | - */ |
|
46 | - public function run() |
|
47 | - { |
|
48 | - add_filter('map_meta_cap', [$this->admin, 'filterCreateCapability'], 10, 2); |
|
49 | - add_filter('mce_external_plugins', [$this->admin, 'filterTinymcePlugins'], 15); |
|
50 | - add_filter('plugin_action_links_'.$this->basename, [$this->admin, 'filterActionLinks']); |
|
51 | - add_filter('dashboard_glance_items', [$this->admin, 'filterDashboardGlanceItems']); |
|
52 | - add_filter('block_categories', [$this->blocks, 'filterBlockCategories']); |
|
53 | - add_filter('classic_editor_enabled_editors_for_post_type', [$this->blocks, 'filterEnabledEditors'], 10, 2); |
|
54 | - add_filter('use_block_editor_for_post_type', [$this->blocks, 'filterUseBlockEditor'], 10, 2); |
|
55 | - add_filter('wp_editor_settings', [$this->editor, 'filterEditorSettings']); |
|
56 | - add_filter('the_editor', [$this->editor, 'filterEditorTextarea']); |
|
57 | - add_filter('is_protected_meta', [$this->editor, 'filterIsProtectedMeta'], 10, 3); |
|
58 | - add_filter('post_updated_messages', [$this->editor, 'filterUpdateMessages']); |
|
59 | - add_filter('manage_'.Application::POST_TYPE.'_posts_columns', [$this->listtable, 'filterColumnsForPostType']); |
|
60 | - add_filter('post_date_column_status', [$this->listtable, 'filterDateColumnStatus'], 10, 2); |
|
61 | - add_filter('default_hidden_columns', [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2); |
|
62 | - add_filter('post_row_actions', [$this->listtable, 'filterRowActions'], 10, 2); |
|
63 | - add_filter('manage_edit-'.Application::POST_TYPE.'_sortable_columns', [$this->listtable, 'filterSortableColumns']); |
|
64 | - add_filter('script_loader_tag', [$this->public, 'filterEnqueuedScripts'], 10, 2); |
|
65 | - add_filter('site-reviews/config/forms/submission-form', [$this->public, 'filterFieldOrder'], 11); |
|
66 | - add_filter('site-reviews/render/view', [$this->public, 'filterRenderView']); |
|
67 | - add_filter('bulk_post_updated_messages', [$this->translator, 'filterBulkUpdateMessages'], 10, 2); |
|
68 | - add_filter('gettext', [$this->translator, 'filterGettext'], 9, 3); |
|
69 | - add_filter('site-reviews/gettext/site-reviews', [$this->translator, 'filterGettextSiteReviews'], 10, 2); |
|
70 | - add_filter('gettext_with_context', [$this->translator, 'filterGettextWithContext'], 9, 4); |
|
71 | - add_filter('site-reviews/gettext_with_context/site-reviews', [$this->translator, 'filterGettextWithContextSiteReviews'], 10, 3); |
|
72 | - add_filter('ngettext', [$this->translator, 'filterNgettext'], 9, 5); |
|
73 | - add_filter('site-reviews/ngettext/site-reviews', [$this->translator, 'filterNgettextSiteReviews'], 10, 4); |
|
74 | - add_filter('ngettext_with_context', [$this->translator, 'filterNgettextWithContext'], 9, 6); |
|
75 | - add_filter('site-reviews/ngettext_with_context/site-reviews', [$this->translator, 'filterNgettextWithContextSiteReviews'], 10, 5); |
|
76 | - add_filter('display_post_states', [$this->translator, 'filterPostStates'], 10, 2); |
|
77 | - add_filter('site-reviews/gettext/default', [$this->translator, 'filterPostStatusLabels'], 10, 2); |
|
78 | - add_filter('site-reviews/gettext_with_context/default', [$this->translator, 'filterPostStatusLabels'], 10, 2); |
|
79 | - add_filter('site-reviews/ngettext/default', [$this->translator, 'filterPostStatusText'], 10, 4); |
|
80 | - add_filter('site-reviews/settings/callback', [$this->trustalyze, 'filterSettingsCallback']); |
|
81 | - add_filter('site-reviews/interpolate/partials/form/table-row-multiple', [$this->trustalyze, 'filterSettingsTableRow'], 10, 3); |
|
82 | - add_filter('plugin_action_links_'.$this->basename, [$this->welcome, 'filterActionLinks'], 9); |
|
83 | - add_filter('admin_title', [$this->welcome, 'filterAdminTitle']); |
|
84 | - add_filter('admin_footer_text', [$this->welcome, 'filterFooterText']); |
|
85 | - } |
|
43 | + /** |
|
44 | + * @return void |
|
45 | + */ |
|
46 | + public function run() |
|
47 | + { |
|
48 | + add_filter('map_meta_cap', [$this->admin, 'filterCreateCapability'], 10, 2); |
|
49 | + add_filter('mce_external_plugins', [$this->admin, 'filterTinymcePlugins'], 15); |
|
50 | + add_filter('plugin_action_links_'.$this->basename, [$this->admin, 'filterActionLinks']); |
|
51 | + add_filter('dashboard_glance_items', [$this->admin, 'filterDashboardGlanceItems']); |
|
52 | + add_filter('block_categories', [$this->blocks, 'filterBlockCategories']); |
|
53 | + add_filter('classic_editor_enabled_editors_for_post_type', [$this->blocks, 'filterEnabledEditors'], 10, 2); |
|
54 | + add_filter('use_block_editor_for_post_type', [$this->blocks, 'filterUseBlockEditor'], 10, 2); |
|
55 | + add_filter('wp_editor_settings', [$this->editor, 'filterEditorSettings']); |
|
56 | + add_filter('the_editor', [$this->editor, 'filterEditorTextarea']); |
|
57 | + add_filter('is_protected_meta', [$this->editor, 'filterIsProtectedMeta'], 10, 3); |
|
58 | + add_filter('post_updated_messages', [$this->editor, 'filterUpdateMessages']); |
|
59 | + add_filter('manage_'.Application::POST_TYPE.'_posts_columns', [$this->listtable, 'filterColumnsForPostType']); |
|
60 | + add_filter('post_date_column_status', [$this->listtable, 'filterDateColumnStatus'], 10, 2); |
|
61 | + add_filter('default_hidden_columns', [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2); |
|
62 | + add_filter('post_row_actions', [$this->listtable, 'filterRowActions'], 10, 2); |
|
63 | + add_filter('manage_edit-'.Application::POST_TYPE.'_sortable_columns', [$this->listtable, 'filterSortableColumns']); |
|
64 | + add_filter('script_loader_tag', [$this->public, 'filterEnqueuedScripts'], 10, 2); |
|
65 | + add_filter('site-reviews/config/forms/submission-form', [$this->public, 'filterFieldOrder'], 11); |
|
66 | + add_filter('site-reviews/render/view', [$this->public, 'filterRenderView']); |
|
67 | + add_filter('bulk_post_updated_messages', [$this->translator, 'filterBulkUpdateMessages'], 10, 2); |
|
68 | + add_filter('gettext', [$this->translator, 'filterGettext'], 9, 3); |
|
69 | + add_filter('site-reviews/gettext/site-reviews', [$this->translator, 'filterGettextSiteReviews'], 10, 2); |
|
70 | + add_filter('gettext_with_context', [$this->translator, 'filterGettextWithContext'], 9, 4); |
|
71 | + add_filter('site-reviews/gettext_with_context/site-reviews', [$this->translator, 'filterGettextWithContextSiteReviews'], 10, 3); |
|
72 | + add_filter('ngettext', [$this->translator, 'filterNgettext'], 9, 5); |
|
73 | + add_filter('site-reviews/ngettext/site-reviews', [$this->translator, 'filterNgettextSiteReviews'], 10, 4); |
|
74 | + add_filter('ngettext_with_context', [$this->translator, 'filterNgettextWithContext'], 9, 6); |
|
75 | + add_filter('site-reviews/ngettext_with_context/site-reviews', [$this->translator, 'filterNgettextWithContextSiteReviews'], 10, 5); |
|
76 | + add_filter('display_post_states', [$this->translator, 'filterPostStates'], 10, 2); |
|
77 | + add_filter('site-reviews/gettext/default', [$this->translator, 'filterPostStatusLabels'], 10, 2); |
|
78 | + add_filter('site-reviews/gettext_with_context/default', [$this->translator, 'filterPostStatusLabels'], 10, 2); |
|
79 | + add_filter('site-reviews/ngettext/default', [$this->translator, 'filterPostStatusText'], 10, 4); |
|
80 | + add_filter('site-reviews/settings/callback', [$this->trustalyze, 'filterSettingsCallback']); |
|
81 | + add_filter('site-reviews/interpolate/partials/form/table-row-multiple', [$this->trustalyze, 'filterSettingsTableRow'], 10, 3); |
|
82 | + add_filter('plugin_action_links_'.$this->basename, [$this->welcome, 'filterActionLinks'], 9); |
|
83 | + add_filter('admin_title', [$this->welcome, 'filterAdminTitle']); |
|
84 | + add_filter('admin_footer_text', [$this->welcome, 'filterFooterText']); |
|
85 | + } |
|
86 | 86 | } |
@@ -26,18 +26,18 @@ discard block |
||
26 | 26 | protected $trustalyze; |
27 | 27 | protected $welcome; |
28 | 28 | |
29 | - public function __construct(Application $app) |
|
29 | + public function __construct( Application $app ) |
|
30 | 30 | { |
31 | 31 | $this->app = $app; |
32 | - $this->admin = $app->make(AdminController::class); |
|
33 | - $this->basename = plugin_basename($app->file); |
|
34 | - $this->blocks = $app->make(BlocksController::class); |
|
35 | - $this->editor = $app->make(EditorController::class); |
|
36 | - $this->listtable = $app->make(ListTableController::class); |
|
37 | - $this->public = $app->make(PublicController::class); |
|
38 | - $this->translator = $app->make(TranslationController::class); |
|
39 | - $this->trustalyze = $app->make(TrustalyzeController::class); |
|
40 | - $this->welcome = $app->make(WelcomeController::class); |
|
32 | + $this->admin = $app->make( AdminController::class ); |
|
33 | + $this->basename = plugin_basename( $app->file ); |
|
34 | + $this->blocks = $app->make( BlocksController::class ); |
|
35 | + $this->editor = $app->make( EditorController::class ); |
|
36 | + $this->listtable = $app->make( ListTableController::class ); |
|
37 | + $this->public = $app->make( PublicController::class ); |
|
38 | + $this->translator = $app->make( TranslationController::class ); |
|
39 | + $this->trustalyze = $app->make( TrustalyzeController::class ); |
|
40 | + $this->welcome = $app->make( WelcomeController::class ); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -45,42 +45,42 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function run() |
47 | 47 | { |
48 | - add_filter('map_meta_cap', [$this->admin, 'filterCreateCapability'], 10, 2); |
|
49 | - add_filter('mce_external_plugins', [$this->admin, 'filterTinymcePlugins'], 15); |
|
50 | - add_filter('plugin_action_links_'.$this->basename, [$this->admin, 'filterActionLinks']); |
|
51 | - add_filter('dashboard_glance_items', [$this->admin, 'filterDashboardGlanceItems']); |
|
52 | - add_filter('block_categories', [$this->blocks, 'filterBlockCategories']); |
|
53 | - add_filter('classic_editor_enabled_editors_for_post_type', [$this->blocks, 'filterEnabledEditors'], 10, 2); |
|
54 | - add_filter('use_block_editor_for_post_type', [$this->blocks, 'filterUseBlockEditor'], 10, 2); |
|
55 | - add_filter('wp_editor_settings', [$this->editor, 'filterEditorSettings']); |
|
56 | - add_filter('the_editor', [$this->editor, 'filterEditorTextarea']); |
|
57 | - add_filter('is_protected_meta', [$this->editor, 'filterIsProtectedMeta'], 10, 3); |
|
58 | - add_filter('post_updated_messages', [$this->editor, 'filterUpdateMessages']); |
|
59 | - add_filter('manage_'.Application::POST_TYPE.'_posts_columns', [$this->listtable, 'filterColumnsForPostType']); |
|
60 | - add_filter('post_date_column_status', [$this->listtable, 'filterDateColumnStatus'], 10, 2); |
|
61 | - add_filter('default_hidden_columns', [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2); |
|
62 | - add_filter('post_row_actions', [$this->listtable, 'filterRowActions'], 10, 2); |
|
63 | - add_filter('manage_edit-'.Application::POST_TYPE.'_sortable_columns', [$this->listtable, 'filterSortableColumns']); |
|
64 | - add_filter('script_loader_tag', [$this->public, 'filterEnqueuedScripts'], 10, 2); |
|
65 | - add_filter('site-reviews/config/forms/submission-form', [$this->public, 'filterFieldOrder'], 11); |
|
66 | - add_filter('site-reviews/render/view', [$this->public, 'filterRenderView']); |
|
67 | - add_filter('bulk_post_updated_messages', [$this->translator, 'filterBulkUpdateMessages'], 10, 2); |
|
68 | - add_filter('gettext', [$this->translator, 'filterGettext'], 9, 3); |
|
69 | - add_filter('site-reviews/gettext/site-reviews', [$this->translator, 'filterGettextSiteReviews'], 10, 2); |
|
70 | - add_filter('gettext_with_context', [$this->translator, 'filterGettextWithContext'], 9, 4); |
|
71 | - add_filter('site-reviews/gettext_with_context/site-reviews', [$this->translator, 'filterGettextWithContextSiteReviews'], 10, 3); |
|
72 | - add_filter('ngettext', [$this->translator, 'filterNgettext'], 9, 5); |
|
73 | - add_filter('site-reviews/ngettext/site-reviews', [$this->translator, 'filterNgettextSiteReviews'], 10, 4); |
|
74 | - add_filter('ngettext_with_context', [$this->translator, 'filterNgettextWithContext'], 9, 6); |
|
75 | - add_filter('site-reviews/ngettext_with_context/site-reviews', [$this->translator, 'filterNgettextWithContextSiteReviews'], 10, 5); |
|
76 | - add_filter('display_post_states', [$this->translator, 'filterPostStates'], 10, 2); |
|
77 | - add_filter('site-reviews/gettext/default', [$this->translator, 'filterPostStatusLabels'], 10, 2); |
|
78 | - add_filter('site-reviews/gettext_with_context/default', [$this->translator, 'filterPostStatusLabels'], 10, 2); |
|
79 | - add_filter('site-reviews/ngettext/default', [$this->translator, 'filterPostStatusText'], 10, 4); |
|
80 | - add_filter('site-reviews/settings/callback', [$this->trustalyze, 'filterSettingsCallback']); |
|
81 | - add_filter('site-reviews/interpolate/partials/form/table-row-multiple', [$this->trustalyze, 'filterSettingsTableRow'], 10, 3); |
|
82 | - add_filter('plugin_action_links_'.$this->basename, [$this->welcome, 'filterActionLinks'], 9); |
|
83 | - add_filter('admin_title', [$this->welcome, 'filterAdminTitle']); |
|
84 | - add_filter('admin_footer_text', [$this->welcome, 'filterFooterText']); |
|
48 | + add_filter( 'map_meta_cap', [$this->admin, 'filterCreateCapability'], 10, 2 ); |
|
49 | + add_filter( 'mce_external_plugins', [$this->admin, 'filterTinymcePlugins'], 15 ); |
|
50 | + add_filter( 'plugin_action_links_'.$this->basename, [$this->admin, 'filterActionLinks'] ); |
|
51 | + add_filter( 'dashboard_glance_items', [$this->admin, 'filterDashboardGlanceItems'] ); |
|
52 | + add_filter( 'block_categories', [$this->blocks, 'filterBlockCategories'] ); |
|
53 | + add_filter( 'classic_editor_enabled_editors_for_post_type', [$this->blocks, 'filterEnabledEditors'], 10, 2 ); |
|
54 | + add_filter( 'use_block_editor_for_post_type', [$this->blocks, 'filterUseBlockEditor'], 10, 2 ); |
|
55 | + add_filter( 'wp_editor_settings', [$this->editor, 'filterEditorSettings'] ); |
|
56 | + add_filter( 'the_editor', [$this->editor, 'filterEditorTextarea'] ); |
|
57 | + add_filter( 'is_protected_meta', [$this->editor, 'filterIsProtectedMeta'], 10, 3 ); |
|
58 | + add_filter( 'post_updated_messages', [$this->editor, 'filterUpdateMessages'] ); |
|
59 | + add_filter( 'manage_'.Application::POST_TYPE.'_posts_columns', [$this->listtable, 'filterColumnsForPostType'] ); |
|
60 | + add_filter( 'post_date_column_status', [$this->listtable, 'filterDateColumnStatus'], 10, 2 ); |
|
61 | + add_filter( 'default_hidden_columns', [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2 ); |
|
62 | + add_filter( 'post_row_actions', [$this->listtable, 'filterRowActions'], 10, 2 ); |
|
63 | + add_filter( 'manage_edit-'.Application::POST_TYPE.'_sortable_columns', [$this->listtable, 'filterSortableColumns'] ); |
|
64 | + add_filter( 'script_loader_tag', [$this->public, 'filterEnqueuedScripts'], 10, 2 ); |
|
65 | + add_filter( 'site-reviews/config/forms/submission-form', [$this->public, 'filterFieldOrder'], 11 ); |
|
66 | + add_filter( 'site-reviews/render/view', [$this->public, 'filterRenderView'] ); |
|
67 | + add_filter( 'bulk_post_updated_messages', [$this->translator, 'filterBulkUpdateMessages'], 10, 2 ); |
|
68 | + add_filter( 'gettext', [$this->translator, 'filterGettext'], 9, 3 ); |
|
69 | + add_filter( 'site-reviews/gettext/site-reviews', [$this->translator, 'filterGettextSiteReviews'], 10, 2 ); |
|
70 | + add_filter( 'gettext_with_context', [$this->translator, 'filterGettextWithContext'], 9, 4 ); |
|
71 | + add_filter( 'site-reviews/gettext_with_context/site-reviews', [$this->translator, 'filterGettextWithContextSiteReviews'], 10, 3 ); |
|
72 | + add_filter( 'ngettext', [$this->translator, 'filterNgettext'], 9, 5 ); |
|
73 | + add_filter( 'site-reviews/ngettext/site-reviews', [$this->translator, 'filterNgettextSiteReviews'], 10, 4 ); |
|
74 | + add_filter( 'ngettext_with_context', [$this->translator, 'filterNgettextWithContext'], 9, 6 ); |
|
75 | + add_filter( 'site-reviews/ngettext_with_context/site-reviews', [$this->translator, 'filterNgettextWithContextSiteReviews'], 10, 5 ); |
|
76 | + add_filter( 'display_post_states', [$this->translator, 'filterPostStates'], 10, 2 ); |
|
77 | + add_filter( 'site-reviews/gettext/default', [$this->translator, 'filterPostStatusLabels'], 10, 2 ); |
|
78 | + add_filter( 'site-reviews/gettext_with_context/default', [$this->translator, 'filterPostStatusLabels'], 10, 2 ); |
|
79 | + add_filter( 'site-reviews/ngettext/default', [$this->translator, 'filterPostStatusText'], 10, 4 ); |
|
80 | + add_filter( 'site-reviews/settings/callback', [$this->trustalyze, 'filterSettingsCallback'] ); |
|
81 | + add_filter( 'site-reviews/interpolate/partials/form/table-row-multiple', [$this->trustalyze, 'filterSettingsTableRow'], 10, 3 ); |
|
82 | + add_filter( 'plugin_action_links_'.$this->basename, [$this->welcome, 'filterActionLinks'], 9 ); |
|
83 | + add_filter( 'admin_title', [$this->welcome, 'filterAdminTitle'] ); |
|
84 | + add_filter( 'admin_footer_text', [$this->welcome, 'filterFooterText'] ); |
|
85 | 85 | } |
86 | 86 | } |
@@ -12,231 +12,231 @@ |
||
12 | 12 | |
13 | 13 | class TrustalyzeController extends Controller |
14 | 14 | { |
15 | - protected $apiKey = 'settings.general.trustalyze_serial'; |
|
16 | - protected $emailKey = 'settings.general.trustalyze_email'; |
|
17 | - protected $enabledKey = 'settings.general.trustalyze'; |
|
18 | - protected $trustalyzeKey = '_glsr_trustalyze'; |
|
19 | - |
|
20 | - /** |
|
21 | - * @return array |
|
22 | - * @filter site-reviews/settings/callback |
|
23 | - */ |
|
24 | - public function filterSettingsCallback(array $settings) |
|
25 | - { |
|
26 | - if ('yes' !== Arr::get($settings, $this->enabledKey)) { |
|
27 | - return $settings; |
|
28 | - } |
|
29 | - $isApiKeyModified = $this->isEmptyOrModified($this->apiKey, $settings); |
|
30 | - $isEmailModified = $this->isEmptyOrModified($this->emailKey, $settings); |
|
31 | - $isAccountVerified = glsr(OptionManager::class)->getWP($this->trustalyzeKey, false); |
|
32 | - if (!$isAccountVerified || $isApiKeyModified || $isEmailModified) { |
|
33 | - $settings = $this->sanitizeTrustalyzeSettings($settings); |
|
34 | - } |
|
35 | - return $settings; |
|
36 | - } |
|
37 | - |
|
38 | - /** |
|
39 | - * @param string $template |
|
40 | - * @return array |
|
41 | - * @filter site-reviews/interpolate/partials/form/table-row-multiple |
|
42 | - */ |
|
43 | - public function filterSettingsTableRow(array $context, $template, array $data) |
|
44 | - { |
|
45 | - if ($this->enabledKey !== Arr::get($data, 'field.path')) { |
|
46 | - return $context; |
|
47 | - } |
|
48 | - $trustalyzeProductType = glsr(OptionManager::class)->getWP($this->trustalyzeKey); |
|
49 | - if ('P' === $trustalyzeProductType) { |
|
50 | - return $context; |
|
51 | - } |
|
52 | - if ('F' === $trustalyzeProductType && 'yes' === glsr_get_option('general.trustalyze')) { |
|
53 | - $button = $this->buildUpgradeButton(); |
|
54 | - } else { |
|
55 | - $button = $this->buildCreateButton(); |
|
56 | - } |
|
57 | - $context['field'].= $button; |
|
58 | - return $context; |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * Triggered when a review is created. |
|
63 | - * @return void |
|
64 | - * @action site-reviews/review/created |
|
65 | - */ |
|
66 | - public function onCreated(Review $review) |
|
67 | - { |
|
68 | - if (!$this->canPostReview($review)) { |
|
69 | - return; |
|
70 | - } |
|
71 | - $trustalyze = glsr(Trustalyze::class)->sendReview($review); |
|
72 | - if ($trustalyze->success) { |
|
73 | - glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id); |
|
74 | - } |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Triggered when a review is reverted to its original title/content/date_timestamp. |
|
79 | - * @return void |
|
80 | - * @action site-reviews/review/reverted |
|
81 | - */ |
|
82 | - public function onReverted(Review $review) |
|
83 | - { |
|
84 | - if (!$this->canPostReview($review)) { |
|
85 | - return; |
|
86 | - } |
|
87 | - $trustalyze = glsr(Trustalyze::class)->sendReview($review); |
|
88 | - if ($trustalyze->success) { |
|
89 | - glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id); |
|
90 | - } |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * Triggered when an existing review is updated. |
|
95 | - * @return void |
|
96 | - * @action site-reviews/review/saved |
|
97 | - */ |
|
98 | - public function onSaved(Review $review) |
|
99 | - { |
|
100 | - if (!$this->canPostReview($review)) { |
|
101 | - return; |
|
102 | - } |
|
103 | - $trustalyze = glsr(Trustalyze::class)->sendReview($review); |
|
104 | - if ($trustalyze->success) { |
|
105 | - glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id); |
|
106 | - } |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * Triggered when a review's response is added or updated. |
|
111 | - * @param int $metaId |
|
112 | - * @param int $postId |
|
113 | - * @param string $metaKey |
|
114 | - * @return void |
|
115 | - * @action updated_postmeta |
|
116 | - */ |
|
117 | - public function onUpdatedMeta($metaId, $postId, $metaKey) |
|
118 | - { |
|
119 | - $review = glsr_get_review($postId); |
|
120 | - if (!$this->canPostResponse($review) || '_response' !== $metaKey) { |
|
121 | - return; |
|
122 | - } |
|
123 | - $trustalyze = glsr(Trustalyze::class)->sendReviewResponse($review); |
|
124 | - if ($trustalyze->success) { |
|
125 | - glsr(Database::class)->set($review->ID, 'trustalyze_response', true); |
|
126 | - } |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * @return string |
|
131 | - */ |
|
132 | - protected function buildCreateButton() |
|
133 | - { |
|
134 | - return glsr(Builder::class)->a(__('Create Your Trustalyze Account', 'site-reviews'), [ |
|
135 | - 'class' => 'button', |
|
136 | - 'href' => Trustalyze::WEB_URL, |
|
137 | - 'target' => '_blank', |
|
138 | - ]); |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * @return string |
|
143 | - */ |
|
144 | - protected function buildUpgradeButton() |
|
145 | - { |
|
146 | - $build = glsr(Builder::class); |
|
147 | - $notice = $build->p(__('Free Trustalyze accounts are limited to 500 blockchain transactions per year.', 'site-reviews')); |
|
148 | - $button = $build->a(__('Upgrade Your Trustalyze Plan', 'site-reviews'), [ |
|
149 | - 'class' => 'button', |
|
150 | - 'href' => Trustalyze::WEB_URL, |
|
151 | - 'target' => '_blank', |
|
152 | - ]); |
|
153 | - return $build->div($notice.$button, [ |
|
154 | - 'class' => 'glsr-notice-inline notice inline notice-info', |
|
155 | - ]); |
|
156 | - } |
|
157 | - |
|
158 | - /** |
|
159 | - * @return bool |
|
160 | - */ |
|
161 | - protected function canPostResponse(Review $review) |
|
162 | - { |
|
163 | - $requiredValues = [ |
|
164 | - glsr(Database::class)->get($review->ID, 'trustalyze'), |
|
165 | - $review->response, |
|
166 | - $review->review_id, |
|
167 | - ]; |
|
168 | - return $this->canProceed($review, 'trustalyze_response') |
|
169 | - && 'publish' === $review->status |
|
170 | - && 3 === count(array_filter($requiredValues)); |
|
171 | - } |
|
172 | - |
|
173 | - /** |
|
174 | - * @return bool |
|
175 | - */ |
|
176 | - protected function canPostReview(Review $review) |
|
177 | - { |
|
178 | - $requiredValues = [ |
|
179 | - $review->author, |
|
180 | - $review->content, |
|
181 | - $review->rating, |
|
182 | - $review->review_id, |
|
183 | - $review->title, |
|
184 | - ]; |
|
185 | - return $this->canProceed($review) |
|
186 | - && 'publish' === $review->status |
|
187 | - && 5 === count(array_filter($requiredValues)); |
|
188 | - } |
|
189 | - |
|
190 | - /** |
|
191 | - * @param string $metaKey |
|
192 | - * @return bool |
|
193 | - */ |
|
194 | - protected function canProceed(Review $review, $metaKey = 'trustalyze') |
|
195 | - { |
|
196 | - return glsr(OptionManager::class)->getBool($this->enabledKey) |
|
197 | - && $this->isReviewPostId($review->ID) |
|
198 | - && !$this->hasMetaKey($review, $metaKey); |
|
199 | - } |
|
200 | - |
|
201 | - /** |
|
202 | - * @param string $metaKey |
|
203 | - * @return bool |
|
204 | - */ |
|
205 | - protected function hasMetaKey(Review $review, $metaKey = 'trustalyze') |
|
206 | - { |
|
207 | - return '' !== glsr(Database::class)->get($review->ID, $metaKey); |
|
208 | - } |
|
209 | - |
|
210 | - /** |
|
211 | - * @param string $key |
|
212 | - * @return bool |
|
213 | - */ |
|
214 | - protected function isEmptyOrModified($key, array $settings) |
|
215 | - { |
|
216 | - $oldValue = glsr_get_option($key); |
|
217 | - $newValue = Arr::get($settings, $key); |
|
218 | - return empty($newValue) || $newValue !== $oldValue; |
|
219 | - } |
|
220 | - |
|
221 | - /** |
|
222 | - * @return array |
|
223 | - */ |
|
224 | - protected function sanitizeTrustalyzeSettings(array $settings) |
|
225 | - { |
|
226 | - $trustalyze = glsr(Trustalyze::class)->activateKey( |
|
227 | - Arr::get($settings, $this->apiKey), |
|
228 | - Arr::get($settings, $this->emailKey) |
|
229 | - ); |
|
230 | - if ($trustalyze->success) { |
|
231 | - update_option($this->trustalyzeKey, Arr::get($trustalyze->response, 'producttype')); |
|
232 | - } else { |
|
233 | - delete_option($this->trustalyzeKey); |
|
234 | - $settings = Arr::set($settings, $this->enabledKey, 'no'); |
|
235 | - glsr(Notice::class)->addError(sprintf( |
|
236 | - __('Your Trustalyze account details could not be verified, please try again. %s', 'site-reviews'), |
|
237 | - '('.$trustalyze->message.')' |
|
238 | - )); |
|
239 | - } |
|
240 | - return $settings; |
|
241 | - } |
|
15 | + protected $apiKey = 'settings.general.trustalyze_serial'; |
|
16 | + protected $emailKey = 'settings.general.trustalyze_email'; |
|
17 | + protected $enabledKey = 'settings.general.trustalyze'; |
|
18 | + protected $trustalyzeKey = '_glsr_trustalyze'; |
|
19 | + |
|
20 | + /** |
|
21 | + * @return array |
|
22 | + * @filter site-reviews/settings/callback |
|
23 | + */ |
|
24 | + public function filterSettingsCallback(array $settings) |
|
25 | + { |
|
26 | + if ('yes' !== Arr::get($settings, $this->enabledKey)) { |
|
27 | + return $settings; |
|
28 | + } |
|
29 | + $isApiKeyModified = $this->isEmptyOrModified($this->apiKey, $settings); |
|
30 | + $isEmailModified = $this->isEmptyOrModified($this->emailKey, $settings); |
|
31 | + $isAccountVerified = glsr(OptionManager::class)->getWP($this->trustalyzeKey, false); |
|
32 | + if (!$isAccountVerified || $isApiKeyModified || $isEmailModified) { |
|
33 | + $settings = $this->sanitizeTrustalyzeSettings($settings); |
|
34 | + } |
|
35 | + return $settings; |
|
36 | + } |
|
37 | + |
|
38 | + /** |
|
39 | + * @param string $template |
|
40 | + * @return array |
|
41 | + * @filter site-reviews/interpolate/partials/form/table-row-multiple |
|
42 | + */ |
|
43 | + public function filterSettingsTableRow(array $context, $template, array $data) |
|
44 | + { |
|
45 | + if ($this->enabledKey !== Arr::get($data, 'field.path')) { |
|
46 | + return $context; |
|
47 | + } |
|
48 | + $trustalyzeProductType = glsr(OptionManager::class)->getWP($this->trustalyzeKey); |
|
49 | + if ('P' === $trustalyzeProductType) { |
|
50 | + return $context; |
|
51 | + } |
|
52 | + if ('F' === $trustalyzeProductType && 'yes' === glsr_get_option('general.trustalyze')) { |
|
53 | + $button = $this->buildUpgradeButton(); |
|
54 | + } else { |
|
55 | + $button = $this->buildCreateButton(); |
|
56 | + } |
|
57 | + $context['field'].= $button; |
|
58 | + return $context; |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * Triggered when a review is created. |
|
63 | + * @return void |
|
64 | + * @action site-reviews/review/created |
|
65 | + */ |
|
66 | + public function onCreated(Review $review) |
|
67 | + { |
|
68 | + if (!$this->canPostReview($review)) { |
|
69 | + return; |
|
70 | + } |
|
71 | + $trustalyze = glsr(Trustalyze::class)->sendReview($review); |
|
72 | + if ($trustalyze->success) { |
|
73 | + glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id); |
|
74 | + } |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Triggered when a review is reverted to its original title/content/date_timestamp. |
|
79 | + * @return void |
|
80 | + * @action site-reviews/review/reverted |
|
81 | + */ |
|
82 | + public function onReverted(Review $review) |
|
83 | + { |
|
84 | + if (!$this->canPostReview($review)) { |
|
85 | + return; |
|
86 | + } |
|
87 | + $trustalyze = glsr(Trustalyze::class)->sendReview($review); |
|
88 | + if ($trustalyze->success) { |
|
89 | + glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id); |
|
90 | + } |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * Triggered when an existing review is updated. |
|
95 | + * @return void |
|
96 | + * @action site-reviews/review/saved |
|
97 | + */ |
|
98 | + public function onSaved(Review $review) |
|
99 | + { |
|
100 | + if (!$this->canPostReview($review)) { |
|
101 | + return; |
|
102 | + } |
|
103 | + $trustalyze = glsr(Trustalyze::class)->sendReview($review); |
|
104 | + if ($trustalyze->success) { |
|
105 | + glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id); |
|
106 | + } |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * Triggered when a review's response is added or updated. |
|
111 | + * @param int $metaId |
|
112 | + * @param int $postId |
|
113 | + * @param string $metaKey |
|
114 | + * @return void |
|
115 | + * @action updated_postmeta |
|
116 | + */ |
|
117 | + public function onUpdatedMeta($metaId, $postId, $metaKey) |
|
118 | + { |
|
119 | + $review = glsr_get_review($postId); |
|
120 | + if (!$this->canPostResponse($review) || '_response' !== $metaKey) { |
|
121 | + return; |
|
122 | + } |
|
123 | + $trustalyze = glsr(Trustalyze::class)->sendReviewResponse($review); |
|
124 | + if ($trustalyze->success) { |
|
125 | + glsr(Database::class)->set($review->ID, 'trustalyze_response', true); |
|
126 | + } |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * @return string |
|
131 | + */ |
|
132 | + protected function buildCreateButton() |
|
133 | + { |
|
134 | + return glsr(Builder::class)->a(__('Create Your Trustalyze Account', 'site-reviews'), [ |
|
135 | + 'class' => 'button', |
|
136 | + 'href' => Trustalyze::WEB_URL, |
|
137 | + 'target' => '_blank', |
|
138 | + ]); |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * @return string |
|
143 | + */ |
|
144 | + protected function buildUpgradeButton() |
|
145 | + { |
|
146 | + $build = glsr(Builder::class); |
|
147 | + $notice = $build->p(__('Free Trustalyze accounts are limited to 500 blockchain transactions per year.', 'site-reviews')); |
|
148 | + $button = $build->a(__('Upgrade Your Trustalyze Plan', 'site-reviews'), [ |
|
149 | + 'class' => 'button', |
|
150 | + 'href' => Trustalyze::WEB_URL, |
|
151 | + 'target' => '_blank', |
|
152 | + ]); |
|
153 | + return $build->div($notice.$button, [ |
|
154 | + 'class' => 'glsr-notice-inline notice inline notice-info', |
|
155 | + ]); |
|
156 | + } |
|
157 | + |
|
158 | + /** |
|
159 | + * @return bool |
|
160 | + */ |
|
161 | + protected function canPostResponse(Review $review) |
|
162 | + { |
|
163 | + $requiredValues = [ |
|
164 | + glsr(Database::class)->get($review->ID, 'trustalyze'), |
|
165 | + $review->response, |
|
166 | + $review->review_id, |
|
167 | + ]; |
|
168 | + return $this->canProceed($review, 'trustalyze_response') |
|
169 | + && 'publish' === $review->status |
|
170 | + && 3 === count(array_filter($requiredValues)); |
|
171 | + } |
|
172 | + |
|
173 | + /** |
|
174 | + * @return bool |
|
175 | + */ |
|
176 | + protected function canPostReview(Review $review) |
|
177 | + { |
|
178 | + $requiredValues = [ |
|
179 | + $review->author, |
|
180 | + $review->content, |
|
181 | + $review->rating, |
|
182 | + $review->review_id, |
|
183 | + $review->title, |
|
184 | + ]; |
|
185 | + return $this->canProceed($review) |
|
186 | + && 'publish' === $review->status |
|
187 | + && 5 === count(array_filter($requiredValues)); |
|
188 | + } |
|
189 | + |
|
190 | + /** |
|
191 | + * @param string $metaKey |
|
192 | + * @return bool |
|
193 | + */ |
|
194 | + protected function canProceed(Review $review, $metaKey = 'trustalyze') |
|
195 | + { |
|
196 | + return glsr(OptionManager::class)->getBool($this->enabledKey) |
|
197 | + && $this->isReviewPostId($review->ID) |
|
198 | + && !$this->hasMetaKey($review, $metaKey); |
|
199 | + } |
|
200 | + |
|
201 | + /** |
|
202 | + * @param string $metaKey |
|
203 | + * @return bool |
|
204 | + */ |
|
205 | + protected function hasMetaKey(Review $review, $metaKey = 'trustalyze') |
|
206 | + { |
|
207 | + return '' !== glsr(Database::class)->get($review->ID, $metaKey); |
|
208 | + } |
|
209 | + |
|
210 | + /** |
|
211 | + * @param string $key |
|
212 | + * @return bool |
|
213 | + */ |
|
214 | + protected function isEmptyOrModified($key, array $settings) |
|
215 | + { |
|
216 | + $oldValue = glsr_get_option($key); |
|
217 | + $newValue = Arr::get($settings, $key); |
|
218 | + return empty($newValue) || $newValue !== $oldValue; |
|
219 | + } |
|
220 | + |
|
221 | + /** |
|
222 | + * @return array |
|
223 | + */ |
|
224 | + protected function sanitizeTrustalyzeSettings(array $settings) |
|
225 | + { |
|
226 | + $trustalyze = glsr(Trustalyze::class)->activateKey( |
|
227 | + Arr::get($settings, $this->apiKey), |
|
228 | + Arr::get($settings, $this->emailKey) |
|
229 | + ); |
|
230 | + if ($trustalyze->success) { |
|
231 | + update_option($this->trustalyzeKey, Arr::get($trustalyze->response, 'producttype')); |
|
232 | + } else { |
|
233 | + delete_option($this->trustalyzeKey); |
|
234 | + $settings = Arr::set($settings, $this->enabledKey, 'no'); |
|
235 | + glsr(Notice::class)->addError(sprintf( |
|
236 | + __('Your Trustalyze account details could not be verified, please try again. %s', 'site-reviews'), |
|
237 | + '('.$trustalyze->message.')' |
|
238 | + )); |
|
239 | + } |
|
240 | + return $settings; |
|
241 | + } |
|
242 | 242 | } |
@@ -21,16 +21,16 @@ discard block |
||
21 | 21 | * @return array |
22 | 22 | * @filter site-reviews/settings/callback |
23 | 23 | */ |
24 | - public function filterSettingsCallback(array $settings) |
|
24 | + public function filterSettingsCallback( array $settings ) |
|
25 | 25 | { |
26 | - if ('yes' !== Arr::get($settings, $this->enabledKey)) { |
|
26 | + if( 'yes' !== Arr::get( $settings, $this->enabledKey ) ) { |
|
27 | 27 | return $settings; |
28 | 28 | } |
29 | - $isApiKeyModified = $this->isEmptyOrModified($this->apiKey, $settings); |
|
30 | - $isEmailModified = $this->isEmptyOrModified($this->emailKey, $settings); |
|
31 | - $isAccountVerified = glsr(OptionManager::class)->getWP($this->trustalyzeKey, false); |
|
32 | - if (!$isAccountVerified || $isApiKeyModified || $isEmailModified) { |
|
33 | - $settings = $this->sanitizeTrustalyzeSettings($settings); |
|
29 | + $isApiKeyModified = $this->isEmptyOrModified( $this->apiKey, $settings ); |
|
30 | + $isEmailModified = $this->isEmptyOrModified( $this->emailKey, $settings ); |
|
31 | + $isAccountVerified = glsr( OptionManager::class )->getWP( $this->trustalyzeKey, false ); |
|
32 | + if( !$isAccountVerified || $isApiKeyModified || $isEmailModified ) { |
|
33 | + $settings = $this->sanitizeTrustalyzeSettings( $settings ); |
|
34 | 34 | } |
35 | 35 | return $settings; |
36 | 36 | } |
@@ -40,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 | - $trustalyzeProductType = glsr(OptionManager::class)->getWP($this->trustalyzeKey); |
|
49 | - if ('P' === $trustalyzeProductType) { |
|
48 | + $trustalyzeProductType = glsr( OptionManager::class )->getWP( $this->trustalyzeKey ); |
|
49 | + if( 'P' === $trustalyzeProductType ) { |
|
50 | 50 | return $context; |
51 | 51 | } |
52 | - if ('F' === $trustalyzeProductType && 'yes' === glsr_get_option('general.trustalyze')) { |
|
52 | + if( 'F' === $trustalyzeProductType && 'yes' === glsr_get_option( 'general.trustalyze' ) ) { |
|
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 | - $trustalyze = glsr(Trustalyze::class)->sendReview($review); |
|
72 | - if ($trustalyze->success) { |
|
73 | - glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id); |
|
71 | + $trustalyze = glsr( Trustalyze::class )->sendReview( $review ); |
|
72 | + if( $trustalyze->success ) { |
|
73 | + glsr( Database::class )->set( $review->ID, 'trustalyze', $trustalyze->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 | - $trustalyze = glsr(Trustalyze::class)->sendReview($review); |
|
88 | - if ($trustalyze->success) { |
|
89 | - glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id); |
|
87 | + $trustalyze = glsr( Trustalyze::class )->sendReview( $review ); |
|
88 | + if( $trustalyze->success ) { |
|
89 | + glsr( Database::class )->set( $review->ID, 'trustalyze', $trustalyze->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 | - $trustalyze = glsr(Trustalyze::class)->sendReview($review); |
|
104 | - if ($trustalyze->success) { |
|
105 | - glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id); |
|
103 | + $trustalyze = glsr( Trustalyze::class )->sendReview( $review ); |
|
104 | + if( $trustalyze->success ) { |
|
105 | + glsr( Database::class )->set( $review->ID, 'trustalyze', $trustalyze->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 | - $trustalyze = glsr(Trustalyze::class)->sendReviewResponse($review); |
|
124 | - if ($trustalyze->success) { |
|
125 | - glsr(Database::class)->set($review->ID, 'trustalyze_response', true); |
|
123 | + $trustalyze = glsr( Trustalyze::class )->sendReviewResponse( $review ); |
|
124 | + if( $trustalyze->success ) { |
|
125 | + glsr( Database::class )->set( $review->ID, 'trustalyze_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 Trustalyze Account', 'site-reviews'), [ |
|
134 | + return glsr( Builder::class )->a( __( 'Create Your Trustalyze Account', 'site-reviews' ), [ |
|
135 | 135 | 'class' => 'button', |
136 | 136 | 'href' => Trustalyze::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 Trustalyze accounts are limited to 500 blockchain transactions per year.', 'site-reviews')); |
|
148 | - $button = $build->a(__('Upgrade Your Trustalyze Plan', 'site-reviews'), [ |
|
146 | + $build = glsr( Builder::class ); |
|
147 | + $notice = $build->p( __( 'Free Trustalyze accounts are limited to 500 blockchain transactions per year.', 'site-reviews' ) ); |
|
148 | + $button = $build->a( __( 'Upgrade Your Trustalyze Plan', 'site-reviews' ), [ |
|
149 | 149 | 'class' => 'button', |
150 | 150 | 'href' => Trustalyze::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, 'trustalyze'), |
|
164 | + glsr( Database::class )->get( $review->ID, 'trustalyze' ), |
|
165 | 165 | $review->response, |
166 | 166 | $review->review_id, |
167 | 167 | ]; |
168 | - return $this->canProceed($review, 'trustalyze_response') |
|
168 | + return $this->canProceed( $review, 'trustalyze_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 = 'trustalyze') |
|
194 | + protected function canProceed( Review $review, $metaKey = 'trustalyze' ) |
|
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 = 'trustalyze') |
|
205 | + protected function hasMetaKey( Review $review, $metaKey = 'trustalyze' ) |
|
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 sanitizeTrustalyzeSettings(array $settings) |
|
224 | + protected function sanitizeTrustalyzeSettings( array $settings ) |
|
225 | 225 | { |
226 | - $trustalyze = glsr(Trustalyze::class)->activateKey( |
|
227 | - Arr::get($settings, $this->apiKey), |
|
228 | - Arr::get($settings, $this->emailKey) |
|
226 | + $trustalyze = glsr( Trustalyze::class )->activateKey( |
|
227 | + Arr::get( $settings, $this->apiKey ), |
|
228 | + Arr::get( $settings, $this->emailKey ) |
|
229 | 229 | ); |
230 | - if ($trustalyze->success) { |
|
231 | - update_option($this->trustalyzeKey, Arr::get($trustalyze->response, 'producttype')); |
|
230 | + if( $trustalyze->success ) { |
|
231 | + update_option( $this->trustalyzeKey, Arr::get( $trustalyze->response, 'producttype' ) ); |
|
232 | 232 | } else { |
233 | - delete_option($this->trustalyzeKey); |
|
234 | - $settings = Arr::set($settings, $this->enabledKey, 'no'); |
|
235 | - glsr(Notice::class)->addError(sprintf( |
|
236 | - __('Your Trustalyze account details could not be verified, please try again. %s', 'site-reviews'), |
|
233 | + delete_option( $this->trustalyzeKey ); |
|
234 | + $settings = Arr::set( $settings, $this->enabledKey, 'no' ); |
|
235 | + glsr( Notice::class )->addError( sprintf( |
|
236 | + __( 'Your Trustalyze account details could not be verified, please try again. %s', 'site-reviews' ), |
|
237 | 237 | '('.$trustalyze->message.')' |
238 | - )); |
|
238 | + ) ); |
|
239 | 239 | } |
240 | 240 | return $settings; |
241 | 241 | } |
@@ -51,7 +51,8 @@ discard block |
||
51 | 51 | } |
52 | 52 | if ('F' === $trustalyzeProductType && 'yes' === glsr_get_option('general.trustalyze')) { |
53 | 53 | $button = $this->buildUpgradeButton(); |
54 | - } else { |
|
54 | + } |
|
55 | + else { |
|
55 | 56 | $button = $this->buildCreateButton(); |
56 | 57 | } |
57 | 58 | $context['field'].= $button; |
@@ -229,7 +230,8 @@ discard block |
||
229 | 230 | ); |
230 | 231 | if ($trustalyze->success) { |
231 | 232 | update_option($this->trustalyzeKey, Arr::get($trustalyze->response, 'producttype')); |
232 | - } else { |
|
233 | + } |
|
234 | + else { |
|
233 | 235 | delete_option($this->trustalyzeKey); |
234 | 236 | $settings = Arr::set($settings, $this->enabledKey, 'no'); |
235 | 237 | glsr(Notice::class)->addError(sprintf( |
@@ -10,114 +10,114 @@ |
||
10 | 10 | |
11 | 11 | class NoticeController extends Controller |
12 | 12 | { |
13 | - const USER_META_KEY = '_glsr_notices'; |
|
13 | + const USER_META_KEY = '_glsr_notices'; |
|
14 | 14 | |
15 | - /** |
|
16 | - * @var array |
|
17 | - */ |
|
18 | - protected $dismissValuesMap; |
|
15 | + /** |
|
16 | + * @var array |
|
17 | + */ |
|
18 | + protected $dismissValuesMap; |
|
19 | 19 | |
20 | - public function __construct() |
|
21 | - { |
|
22 | - $this->dismissValuesMap = [ |
|
23 | - 'trustalyze' => glsr()->version('major'), |
|
24 | - 'welcome' => glsr()->version('minor'), |
|
25 | - ]; |
|
26 | - } |
|
20 | + public function __construct() |
|
21 | + { |
|
22 | + $this->dismissValuesMap = [ |
|
23 | + 'trustalyze' => glsr()->version('major'), |
|
24 | + 'welcome' => glsr()->version('minor'), |
|
25 | + ]; |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * @return void |
|
30 | - * @action admin_notices |
|
31 | - */ |
|
32 | - public function filterAdminNotices() |
|
33 | - { |
|
34 | - $screen = glsr_current_screen(); |
|
35 | - $this->renderWelcomeNotice($screen->post_type); |
|
36 | - $this->renderTrustalyzeNotice($screen->post_type); |
|
37 | - } |
|
28 | + /** |
|
29 | + * @return void |
|
30 | + * @action admin_notices |
|
31 | + */ |
|
32 | + public function filterAdminNotices() |
|
33 | + { |
|
34 | + $screen = glsr_current_screen(); |
|
35 | + $this->renderWelcomeNotice($screen->post_type); |
|
36 | + $this->renderTrustalyzeNotice($screen->post_type); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @return void |
|
41 | - */ |
|
42 | - public function routerDismissNotice(array $request) |
|
43 | - { |
|
44 | - if ($key = Arr::get($request, 'notice')) { |
|
45 | - $this->dismissNotice($key); |
|
46 | - } |
|
47 | - } |
|
39 | + /** |
|
40 | + * @return void |
|
41 | + */ |
|
42 | + public function routerDismissNotice(array $request) |
|
43 | + { |
|
44 | + if ($key = Arr::get($request, 'notice')) { |
|
45 | + $this->dismissNotice($key); |
|
46 | + } |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @param string $key |
|
51 | - * @return void |
|
52 | - */ |
|
53 | - protected function dismissNotice($key) |
|
54 | - { |
|
55 | - $this->setUserMeta($key, $this->getVersionFor($key)); |
|
56 | - } |
|
49 | + /** |
|
50 | + * @param string $key |
|
51 | + * @return void |
|
52 | + */ |
|
53 | + protected function dismissNotice($key) |
|
54 | + { |
|
55 | + $this->setUserMeta($key, $this->getVersionFor($key)); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @param string $key |
|
60 | - * @param mixed $fallback |
|
61 | - * @return mixed |
|
62 | - */ |
|
63 | - protected function getUserMeta($key, $fallback) |
|
64 | - { |
|
65 | - $meta = get_user_meta(get_current_user_id(), static::USER_META_KEY, true); |
|
66 | - return Arr::get($meta, $key, $fallback); |
|
67 | - } |
|
58 | + /** |
|
59 | + * @param string $key |
|
60 | + * @param mixed $fallback |
|
61 | + * @return mixed |
|
62 | + */ |
|
63 | + protected function getUserMeta($key, $fallback) |
|
64 | + { |
|
65 | + $meta = get_user_meta(get_current_user_id(), static::USER_META_KEY, true); |
|
66 | + return Arr::get($meta, $key, $fallback); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @param string $noticeKey |
|
71 | - * @return string |
|
72 | - */ |
|
73 | - protected function getVersionFor($noticeKey) |
|
74 | - { |
|
75 | - return Arr::get($this->dismissValuesMap, $noticeKey, glsr()->version('major')); |
|
76 | - } |
|
69 | + /** |
|
70 | + * @param string $noticeKey |
|
71 | + * @return string |
|
72 | + */ |
|
73 | + protected function getVersionFor($noticeKey) |
|
74 | + { |
|
75 | + return Arr::get($this->dismissValuesMap, $noticeKey, glsr()->version('major')); |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @param string $screenPostType |
|
80 | - * @return void |
|
81 | - */ |
|
82 | - protected function renderTrustalyzeNotice($screenPostType) |
|
83 | - { |
|
84 | - if (Application::POST_TYPE == $screenPostType |
|
85 | - && Helper::isGreaterThan($this->getVersionFor('trustalyze'), $this->getUserMeta('trustalyze', 0)) |
|
86 | - && !glsr(OptionManager::class)->getBool('settings.general.trustalyze') |
|
87 | - && glsr()->can('manage_options')) { |
|
88 | - glsr()->render('partials/notices/trustalyze'); |
|
89 | - } |
|
90 | - } |
|
78 | + /** |
|
79 | + * @param string $screenPostType |
|
80 | + * @return void |
|
81 | + */ |
|
82 | + protected function renderTrustalyzeNotice($screenPostType) |
|
83 | + { |
|
84 | + if (Application::POST_TYPE == $screenPostType |
|
85 | + && Helper::isGreaterThan($this->getVersionFor('trustalyze'), $this->getUserMeta('trustalyze', 0)) |
|
86 | + && !glsr(OptionManager::class)->getBool('settings.general.trustalyze') |
|
87 | + && glsr()->can('manage_options')) { |
|
88 | + glsr()->render('partials/notices/trustalyze'); |
|
89 | + } |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * @param string $screenPostType |
|
94 | - * @return void |
|
95 | - */ |
|
96 | - protected function renderWelcomeNotice($screenPostType) |
|
97 | - { |
|
98 | - if (Application::POST_TYPE == $screenPostType |
|
99 | - && Helper::isGreaterThan($this->getVersionFor('welcome'), $this->getUserMeta('welcome', 0)) |
|
100 | - && glsr()->can('edit_others_posts')) { |
|
101 | - $welcomeText = '0.0.0' == glsr(OptionManager::class)->get('version_upgraded_from') |
|
102 | - ? __('Thanks for installing Site Reviews v%s, we hope you love it!', 'site-reviews') |
|
103 | - : __('Thanks for updating to Site Reviews v%s, we hope you love the changes!', 'site-reviews'); |
|
104 | - glsr()->render('partials/notices/welcome', [ |
|
105 | - 'text' => sprintf($welcomeText, glsr()->version), |
|
106 | - ]); |
|
107 | - } |
|
108 | - } |
|
92 | + /** |
|
93 | + * @param string $screenPostType |
|
94 | + * @return void |
|
95 | + */ |
|
96 | + protected function renderWelcomeNotice($screenPostType) |
|
97 | + { |
|
98 | + if (Application::POST_TYPE == $screenPostType |
|
99 | + && Helper::isGreaterThan($this->getVersionFor('welcome'), $this->getUserMeta('welcome', 0)) |
|
100 | + && glsr()->can('edit_others_posts')) { |
|
101 | + $welcomeText = '0.0.0' == glsr(OptionManager::class)->get('version_upgraded_from') |
|
102 | + ? __('Thanks for installing Site Reviews v%s, we hope you love it!', 'site-reviews') |
|
103 | + : __('Thanks for updating to Site Reviews v%s, we hope you love the changes!', 'site-reviews'); |
|
104 | + glsr()->render('partials/notices/welcome', [ |
|
105 | + 'text' => sprintf($welcomeText, glsr()->version), |
|
106 | + ]); |
|
107 | + } |
|
108 | + } |
|
109 | 109 | |
110 | - /** |
|
111 | - * @param string $key |
|
112 | - * @param mixed $fallback |
|
113 | - * @return mixed |
|
114 | - */ |
|
115 | - protected function setUserMeta($key, $value) |
|
116 | - { |
|
117 | - $userId = get_current_user_id(); |
|
118 | - $meta = (array) get_user_meta($userId, static::USER_META_KEY, true); |
|
119 | - $meta = array_filter(wp_parse_args($meta, [])); |
|
120 | - $meta[$key] = $value; |
|
121 | - update_user_meta($userId, static::USER_META_KEY, $meta); |
|
122 | - } |
|
110 | + /** |
|
111 | + * @param string $key |
|
112 | + * @param mixed $fallback |
|
113 | + * @return mixed |
|
114 | + */ |
|
115 | + protected function setUserMeta($key, $value) |
|
116 | + { |
|
117 | + $userId = get_current_user_id(); |
|
118 | + $meta = (array) get_user_meta($userId, static::USER_META_KEY, true); |
|
119 | + $meta = array_filter(wp_parse_args($meta, [])); |
|
120 | + $meta[$key] = $value; |
|
121 | + update_user_meta($userId, static::USER_META_KEY, $meta); |
|
122 | + } |
|
123 | 123 | } |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | public function __construct() |
21 | 21 | { |
22 | 22 | $this->dismissValuesMap = [ |
23 | - 'trustalyze' => glsr()->version('major'), |
|
24 | - 'welcome' => glsr()->version('minor'), |
|
23 | + 'trustalyze' => glsr()->version( 'major' ), |
|
24 | + 'welcome' => glsr()->version( 'minor' ), |
|
25 | 25 | ]; |
26 | 26 | } |
27 | 27 | |
@@ -32,17 +32,17 @@ discard block |
||
32 | 32 | public function filterAdminNotices() |
33 | 33 | { |
34 | 34 | $screen = glsr_current_screen(); |
35 | - $this->renderWelcomeNotice($screen->post_type); |
|
36 | - $this->renderTrustalyzeNotice($screen->post_type); |
|
35 | + $this->renderWelcomeNotice( $screen->post_type ); |
|
36 | + $this->renderTrustalyzeNotice( $screen->post_type ); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @return void |
41 | 41 | */ |
42 | - public function routerDismissNotice(array $request) |
|
42 | + public function routerDismissNotice( array $request ) |
|
43 | 43 | { |
44 | - if ($key = Arr::get($request, 'notice')) { |
|
45 | - $this->dismissNotice($key); |
|
44 | + if( $key = Arr::get( $request, 'notice' ) ) { |
|
45 | + $this->dismissNotice( $key ); |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | * @param string $key |
51 | 51 | * @return void |
52 | 52 | */ |
53 | - protected function dismissNotice($key) |
|
53 | + protected function dismissNotice( $key ) |
|
54 | 54 | { |
55 | - $this->setUserMeta($key, $this->getVersionFor($key)); |
|
55 | + $this->setUserMeta( $key, $this->getVersionFor( $key ) ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -60,32 +60,32 @@ discard block |
||
60 | 60 | * @param mixed $fallback |
61 | 61 | * @return mixed |
62 | 62 | */ |
63 | - protected function getUserMeta($key, $fallback) |
|
63 | + protected function getUserMeta( $key, $fallback ) |
|
64 | 64 | { |
65 | - $meta = get_user_meta(get_current_user_id(), static::USER_META_KEY, true); |
|
66 | - return Arr::get($meta, $key, $fallback); |
|
65 | + $meta = get_user_meta( get_current_user_id(), static::USER_META_KEY, true ); |
|
66 | + return Arr::get( $meta, $key, $fallback ); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
70 | 70 | * @param string $noticeKey |
71 | 71 | * @return string |
72 | 72 | */ |
73 | - protected function getVersionFor($noticeKey) |
|
73 | + protected function getVersionFor( $noticeKey ) |
|
74 | 74 | { |
75 | - return Arr::get($this->dismissValuesMap, $noticeKey, glsr()->version('major')); |
|
75 | + return Arr::get( $this->dismissValuesMap, $noticeKey, glsr()->version( 'major' ) ); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | 79 | * @param string $screenPostType |
80 | 80 | * @return void |
81 | 81 | */ |
82 | - protected function renderTrustalyzeNotice($screenPostType) |
|
82 | + protected function renderTrustalyzeNotice( $screenPostType ) |
|
83 | 83 | { |
84 | - if (Application::POST_TYPE == $screenPostType |
|
85 | - && Helper::isGreaterThan($this->getVersionFor('trustalyze'), $this->getUserMeta('trustalyze', 0)) |
|
86 | - && !glsr(OptionManager::class)->getBool('settings.general.trustalyze') |
|
87 | - && glsr()->can('manage_options')) { |
|
88 | - glsr()->render('partials/notices/trustalyze'); |
|
84 | + if( Application::POST_TYPE == $screenPostType |
|
85 | + && Helper::isGreaterThan( $this->getVersionFor( 'trustalyze' ), $this->getUserMeta( 'trustalyze', 0 ) ) |
|
86 | + && !glsr( OptionManager::class )->getBool( 'settings.general.trustalyze' ) |
|
87 | + && glsr()->can( 'manage_options' ) ) { |
|
88 | + glsr()->render( 'partials/notices/trustalyze' ); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
@@ -93,17 +93,17 @@ discard block |
||
93 | 93 | * @param string $screenPostType |
94 | 94 | * @return void |
95 | 95 | */ |
96 | - protected function renderWelcomeNotice($screenPostType) |
|
96 | + protected function renderWelcomeNotice( $screenPostType ) |
|
97 | 97 | { |
98 | - if (Application::POST_TYPE == $screenPostType |
|
99 | - && Helper::isGreaterThan($this->getVersionFor('welcome'), $this->getUserMeta('welcome', 0)) |
|
100 | - && glsr()->can('edit_others_posts')) { |
|
101 | - $welcomeText = '0.0.0' == glsr(OptionManager::class)->get('version_upgraded_from') |
|
102 | - ? __('Thanks for installing Site Reviews v%s, we hope you love it!', 'site-reviews') |
|
103 | - : __('Thanks for updating to Site Reviews v%s, we hope you love the changes!', 'site-reviews'); |
|
104 | - glsr()->render('partials/notices/welcome', [ |
|
105 | - 'text' => sprintf($welcomeText, glsr()->version), |
|
106 | - ]); |
|
98 | + if( Application::POST_TYPE == $screenPostType |
|
99 | + && Helper::isGreaterThan( $this->getVersionFor( 'welcome' ), $this->getUserMeta( 'welcome', 0 ) ) |
|
100 | + && glsr()->can( 'edit_others_posts' ) ) { |
|
101 | + $welcomeText = '0.0.0' == glsr( OptionManager::class )->get( 'version_upgraded_from' ) |
|
102 | + ? __( 'Thanks for installing Site Reviews v%s, we hope you love it!', 'site-reviews' ) |
|
103 | + : __( 'Thanks for updating to Site Reviews v%s, we hope you love the changes!', 'site-reviews' ); |
|
104 | + glsr()->render( 'partials/notices/welcome', [ |
|
105 | + 'text' => sprintf( $welcomeText, glsr()->version ), |
|
106 | + ] ); |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | * @param mixed $fallback |
113 | 113 | * @return mixed |
114 | 114 | */ |
115 | - protected function setUserMeta($key, $value) |
|
115 | + protected function setUserMeta( $key, $value ) |
|
116 | 116 | { |
117 | 117 | $userId = get_current_user_id(); |
118 | - $meta = (array) get_user_meta($userId, static::USER_META_KEY, true); |
|
119 | - $meta = array_filter(wp_parse_args($meta, [])); |
|
118 | + $meta = (array)get_user_meta( $userId, static::USER_META_KEY, true ); |
|
119 | + $meta = array_filter( wp_parse_args( $meta, [] ) ); |
|
120 | 120 | $meta[$key] = $value; |
121 | - update_user_meta($userId, static::USER_META_KEY, $meta); |
|
121 | + update_user_meta( $userId, static::USER_META_KEY, $meta ); |
|
122 | 122 | } |
123 | 123 | } |