PluginProbe
Timetics – Appointment Booking Calendar & Scheduling / 1.0.38
Timetics – Appointment Booking Calendar & Scheduling v1.0.38
1.0.62 1.0.63 1.0.61 1.0.60 1.0.59 1.0.58 1.0.57 1.0.56 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 All 64 releases
← All changes | core/admin/hooks.php +9 -81 1.0.571.0.38 View file →
@@ -4,11 +4,8 @@
4 4 *
5 5 * @package Timetics
6 6 */
7 7 namespace Timetics\Core\Admin;
8 -
9 -defined( 'ABSPATH' ) || exit;
10 -
11 8 use Timetics\Utils\Singleton;
12 9
13 10
14 11 class Hooks {
@@ -33,11 +30,8 @@
33 30 add_action( 'wp_initialize_site', [ $this, 'update_user_role_on_insert_new_site' ], 110 );
34 31
35 32 add_action( 'set_user_role', [ $this, 'set_roles' ], 10, 2 );
36 33
37 - add_filter( 'show_admin_bar', [ $this, 'hide_admin_bar_for_customers' ] );
38 - add_action( 'admin_init', [ $this, 'block_admin_for_customers' ] );
39 -
40 34 add_filter( 'timetics_menu', [ $this, 'update_busyness_menu' ] );
41 35
42 36 add_filter( 'timetics_settings', [ $this, 'set_google_auth_url' ] );
43 37
@@ -142,10 +136,9 @@
142 136
143 137 update_option( 'timetics_onboard_setup', true );
144 138 update_option( 'timetics_onboard_settings', false );
145 139
146 - wp_safe_redirect( admin_url('admin.php?page=timetics#/onboard') );
147 - exit;
140 + exit( esc_url( wp_redirect( admin_url('admin.php?page=timetics#/onboard') ) ) );
148 141 }
149 142
150 143 /**
151 144 * Update site admin roles whne new site created
@@ -182,61 +175,8 @@
182 175 $user->add_role('timetics-customer');
183 176 }
184 177
185 178 /**
186 - * Hide the WP admin toolbar for customer-only users.
187 - *
188 - * @param bool $show
189 - *
190 - * @return bool
191 - */
192 - public function hide_admin_bar_for_customers( $show ) {
193 - $user = wp_get_current_user();
194 -
195 - if ( ! $user || ! $user->exists() ) {
196 - return $show;
197 - }
198 -
199 - if ( $this->is_customer_only( $user ) ) {
200 - return false;
201 - }
202 -
203 - return $show;
204 - }
205 -
206 - /**
207 - * Redirect customer-only users away from /wp-admin/.
208 - *
209 - * @return void
210 - */
211 - public function block_admin_for_customers() {
212 - if ( wp_doing_ajax() ) {
213 - return;
214 - }
215 -
216 - $user = wp_get_current_user();
217 -
218 - if ( $user && $user->exists() && $this->is_customer_only( $user ) ) {
219 - wp_safe_redirect( home_url() );
220 - exit;
221 - }
222 - }
223 -
224 - /**
225 - * Whether the given user's only Timetics-relevant role is timetics-customer.
226 - *
227 - * @param \WP_User $user
228 - *
229 - * @return bool
230 - */
231 - private function is_customer_only( $user ) {
232 - $roles = (array) $user->roles;
233 -
234 - return in_array( 'timetics-customer', $roles, true )
235 - && ! array_intersect( $roles, [ 'administrator', 'editor', 'author', 'contributor', 'timetics-staff' ] );
236 - }
237 -
238 - /**
239 179 * Update busyness menu item
240 180 *
241 181 * @param array $menu_items
242 182 *
@@ -291,54 +231,42 @@
291 231
292 232
293 233 $admin_email = get_option( 'admin_email' );
294 234
295 - /* translators: {%customer_name%} is a token replaced at runtime with the recipient customer's name */
296 - $customer_greeting = __( 'Hi {%customer_name%}', 'timetics' );
297 - /* translators: {%host_name%} is a token replaced at runtime with the recipient host's name */
298 - $host_greeting = __( 'Hi {%host_name%}', 'timetics' );
299 - $new_meeting_msg = __( 'A new meeting has been scheduled.', 'timetics' );
300 - /* translators: {%meeting_title%} is a token replaced at runtime with the meeting title */
301 - $canceled_msg = __( '{%meeting_title%} has been canceled.', 'timetics' );
302 - /* translators: {%meeting_title%} is a token replaced at runtime with the meeting title */
303 - $rescheduled_msg = __( '{%meeting_title%} has been rescheduled', 'timetics' );
304 - /* translators: {%meeting_title%}, {%meeting_date%}, {%meeting_time%} are tokens replaced at runtime with the meeting details */
305 - $reminder_msg = __( '{%meeting_title%} at {%meeting_date%} {%meeting_time%}', 'timetics' );
306 -
307 235 $defaults = [
308 236
309 237 'booking_created_customer_email_from' => $admin_email,
310 238 'booking_created_customer_email_title' => sprintf('%s', __( 'New meeting scheduled!', 'timetics' )),
311 - 'booking_created_customer_email_body' => sprintf('<p>%s</p><p>%s</p>', $customer_greeting, $new_meeting_msg),
239 + 'booking_created_customer_email_body' => sprintf('<p>%s</p><p>%s</p>', __( 'Hi {%customer_name%}', 'timetics' ), __( 'A new meeting has been scheduled.', 'timetics' )),
312 240
313 241 'booking_created_host_email_from' => $admin_email,
314 242 'booking_created_host_email_title' => sprintf('%s', __( 'New meeting scheduled!', 'timetics' )),
315 - 'booking_created_host_email_body' => sprintf('<p>%s</p><p>%s</p>', $host_greeting, $new_meeting_msg),
243 + 'booking_created_host_email_body' => sprintf('<p>%s</p><p>%s</p>', __( 'Hi {%host_name%}', 'timetics' ), __( 'A new meeting has been scheduled.', 'timetics' )),
316 244
317 245
318 246 'booking_canceled_customer_email_from' => $admin_email,
319 247 'booking_canceled_customer_email_title' => sprintf('%s', __( 'Meeting cancelled', 'timetics' )),
320 - 'booking_canceled_customer_email_body' => sprintf('<p>%s</p><p>%s</p>', $customer_greeting, $canceled_msg),
248 + 'booking_canceled_customer_email_body' => sprintf('<p>%s</p><p>%s</p>', __( 'Hi {%customer_name%}', 'timetics' ), __( '{%meeting_title%} has been canceled.', 'timetics' )),
321 249
322 250 'booking_canceled_host_email_from' => $admin_email,
323 251 'booking_canceled_host_email_title' => sprintf('%s', __( 'Meeting cancelled', 'timetics' )),
324 - 'booking_canceled_host_email_body' => sprintf('<p>%s</p><p>%s</p>', $host_greeting, $canceled_msg),
252 + 'booking_canceled_host_email_body' => sprintf('<p>%s</p><p>%s</p>', __( 'Hi {%host_name%}', 'timetics' ), __( '{%meeting_title%} has been canceled.', 'timetics' )),
325 253
326 254 'booking_rescheduled_customer_email_from' => $admin_email,
327 255 'booking_rescheduled_customer_email_title' => sprintf('%s', __( 'Meeting rescheduled!', 'timetics' )),
328 - 'booking_rescheduled_customer_email_body' => sprintf('<p>%s</p><p>%s</p>', $host_greeting, $rescheduled_msg),
256 + 'booking_rescheduled_customer_email_body' => sprintf('<p>%s</p><p>%s</p>', __( 'Hi {%host_name%}', 'timetics' ), __( '{%meeting_title%} has been rescheduled', 'timetics' )),
329 257
330 258 'booking_rescheduled_host_email_from' => $admin_email,
331 259 'booking_rescheduled_host_email_title' => sprintf('%s', __('Meeting rescheduled!', 'timetics' )),
332 - 'booking_rescheduled_host_email_body' => sprintf('<p>%s</p><p>%s</p>', $host_greeting, $rescheduled_msg),
260 + 'booking_rescheduled_host_email_body' => sprintf('<p>%s</p><p>%s</p>', __( 'Hi {%host_name%}', 'timetics' ), __( '{%meeting_title%} has been rescheduled', 'timetics' )),
333 261
334 262 'booking_reminder_customer_email_from' => $admin_email,
335 263 'booking_reminder_customer_email_title' => sprintf('%s', __( 'Meeting time reminder', 'timetics' )),
336 - 'booking_reminder_customer_email_body' => sprintf('<p>%s</p><p>%s</p>', $customer_greeting, $reminder_msg),
264 + 'booking_reminder_customer_email_body' => sprintf('<p>%s</p><p>%s</p>', __( 'Hi {%customer_name%}', 'timetics' ), __( '{%meeting_title%} at {%meeting_date%} {%meeting_time%}', 'timetics' )),
337 265
338 266 'booking_reminder_host_email_from' => $admin_email,
339 267 'booking_reminder_host_email_title' => sprintf('%s', __( 'Meeting time reminder', 'timetics' )),
340 - 'booking_reminder_host_email_body' => sprintf('<p>%s</p><p>%s</p>', $host_greeting, $reminder_msg),
268 + 'booking_reminder_host_email_body' => sprintf('<p>%s</p><p>%s</p>', __( 'Hi {%host_name%}', 'timetics' ), __( '{%meeting_title%} at {%meeting_date%} {%meeting_time%}', 'timetics' )),
341 269 ];
342 270
343 271 $settings = wp_parse_args( $settings, $defaults );
344 272