data->user_pass, $user->ID)) { $creds = array('user_login' => $user->data->user_login, 'user_password' => $password); $creds['remember'] = true; } $user = wp_signon( $creds, false ); $page_id = get_queried_object_id(); wp_redirect(get_the_permalink($page_id)); exit; } } public function booked_profile_template(){ if (!is_user_logged_in()) { return do_shortcode('[booked-login]'); } else { ob_start(); require(BOOKED_PLUGIN_TEMPLATES_DIR . 'profile.php'); return ob_get_clean(); } } /* CALENDAR SWITCHER SHORTCODE */ public function booked_calendar_switcher_shortcode( $attrs ){ if( $attrs ){ extract( $attrs ); } $rand = rand(0000000,9999999); $args = array( 'taxonomy' => 'booked_custom_calendars', 'hide_empty' => 0, 'echo' => 0, 'class' => 'booked_calendar_chooser', 'id' => 'booked_calendar_chooser_'.$rand, 'name' => 'booked_calendar_chooser_'.$rand ); if( isset($id) ){ $args['include'] = wp_parse_id_list( $id ); $args['orderby'] = 'include'; } if (!get_option('booked_hide_default_calendar')): $args['show_option_all'] = esc_html__('Default Calendar','booked'); endif; return str_replace( "\n", '', wp_dropdown_categories( $args ) ); } /* CALENDAR SHORTCODE */ public function booked_calendar_shortcode($atts, $content = null){ $local_time = current_time('timestamp'); $calendars = get_terms('booked_custom_calendars',array('orderby'=>'name','order'=>'ASC','hide_empty'=>false)); $atts = shortcode_atts( array( 'size' => 'large', 'calendar' => false, 'year' => false, 'month' => false, 'day' => false, 'switcher' => false, 'style' => 'calendar', 'members-only' => false ), $atts ); if ($atts['members-only'] && is_user_logged_in() || !$atts['members-only']): ob_start(); $atts = apply_filters('booked_calendar_shortcode_atts', $atts ); $rand = rand(0000000,9999999); echo '
'; $home_url = booked_home_url(); echo '
'.$home_url.'/
'; if ($atts['switcher']): $args = array( 'taxonomy' => 'booked_custom_calendars', 'hide_empty' => 0, 'echo' => 0, 'id' => 'booked_calendar_chooser_'.$rand, 'name' => 'booked_calendar_chooser_'.$rand, 'class' => 'booked_calendar_chooser', 'selected' => $atts['calendar'], 'orderby' => 'name', 'order' => 'ASC' ); if (!get_option('booked_hide_default_calendar')): $args['show_option_all'] = esc_html__('Default Calendar','booked'); endif; echo '

' . str_replace( "\n", '', wp_dropdown_categories( $args ) ) . '

'; endif; if (get_option('booked_hide_default_calendar') && $atts['switcher'] && !$atts['calendar'] && !empty($calendars)): $atts['calendar'] = $calendars[0]->term_id; endif; if ($atts['year'] || $atts['month'] || $atts['day']): $force_calendar = true; $year = ($atts['year'] ? $atts['year'] : date_i18n('Y',$local_time)); $month = ($atts['month'] ? date_i18n('m',strtotime($year.'-'.$atts['month'].'-01')) : date_i18n('m',$local_time)); $day = ($atts['day'] ? date_i18n('d',strtotime($year.'-'.$month.'-'.$atts['day'])) : date_i18n('d',$local_time)); $default_date = $year.'-'.$month.'-'.$day; else: $default_date = date_i18n('Y-m-d',$local_time); $force_calendar = false; endif; if (!$atts['style'] || $atts['style'] != 'list'): echo '
'; booked_fe_calendar($atts['year'],$atts['month'],$atts['calendar'],$force_calendar); echo '
'; elseif ($atts['style'] == 'list'): echo '
'; booked_fe_appointment_list_content($default_date,$atts['calendar'],$force_calendar); echo '
'; endif; echo '
'; wp_reset_postdata(); return ob_get_clean(); else: return false; endif; } /* APPOINTMENTS SHORTCODE */ public function booked_appointments_shortcode($atts = null, $content = null) { ob_start(); if ( is_user_logged_in() ): $booked_current_user = wp_get_current_user(); $my_id = $booked_current_user->ID; $historic = isset($atts['historic']) && $atts['historic'] ? true : false; $time_format = get_option('time_format'); $date_format = get_option('date_format'); $appointments_array = booked_user_appointments($my_id,false,$time_format,$date_format,$historic); $total_appts = count($appointments_array); $appointment_default_status = get_option('booked_new_appointment_default','draft'); $only_titles = get_option('booked_show_only_titles',false); if (!isset($atts['remove_wrapper'])): echo '
'; endif; echo '
'; if ($historic): if ($total_appts): echo '

' . number_format($total_appts) . ' ' . _n('Past Appointment','Past Appointments',$total_appts,'booked') . '

'; else: echo '

'.esc_html__('No past appointments.','booked').'

'; endif; else: if ($total_appts): echo '

' . number_format($total_appts) . ' ' . _n('Upcoming Appointment','Upcoming Appointments',$total_appts,'booked') . '

'; else: echo '

'.esc_html__('No upcoming appointments.','booked').'

'; endif; endif; foreach($appointments_array as $appt): $today = date_i18n($date_format); $date_display = date_i18n($date_format,$appt['timestamp']); if ($date_display == $today){ $date_display = esc_html__('Today','booked'); $day_name = ''; } else { $day_name = date_i18n('l',$appt['timestamp']).', '; } $date_to_convert = date_i18n('Y-m-d',$appt['timestamp']); $cf_meta_value = get_post_meta($appt['post_id'], '_cf_meta_value',true); $timeslots = explode('-',$appt['timeslot']); $time_start = date_i18n($time_format,strtotime($timeslots[0])); $time_end = date_i18n($time_format,strtotime($timeslots[1])); $appt_date_time = strtotime($date_to_convert.' '.date_i18n('H:i:s',strtotime($timeslots[0]))); $atc_date_startend = date_i18n('Y-m-d',$appt['timestamp']); $atc_time_start = date_i18n('H:i:s',strtotime($timeslots[0])); $atc_time_end = date_i18n('H:i:s',strtotime($timeslots[1])); $current_timestamp = current_time('timestamp'); $cancellation_buffer = get_option('booked_cancellation_buffer',0); if ($cancellation_buffer): if ($cancellation_buffer < 1){ $time_type = 'minutes'; $time_count = $cancellation_buffer * 60; } else { $time_type = 'hours'; $time_count = $cancellation_buffer; } $buffered_timestamp = strtotime('+'.$time_count.' '.$time_type,$current_timestamp); $date_to_compare = $buffered_timestamp; else: $date_to_compare = current_time('timestamp'); endif; $timeslotText = ''; $status = ($appt['status'] != 'publish' && $appt['status'] != 'future' ? esc_html__('pending','booked') : esc_html__('approved','booked')); $status_class = $appt['status'] != 'publish' && $appt['status'] != 'future' ? 'pending' : 'approved'; $ts_title = get_post_meta($appt['post_id'], '_appointment_title',true); if ($timeslots[0] == '0000' && $timeslots[1] == '2400'): if ($only_titles && !$ts_title || !$only_titles): $timeslotText = esc_html__('All day','booked'); endif; $atc_date_startend_end = date_i18n('Y-m-d',strtotime(date_i18n('Y-m-d',$appt['timestamp']) . '+ 1 Day')); $atc_time_end = '00:00:00'; else : if ($only_titles && !$ts_title || !$only_titles): $timeslotText = (!get_option('booked_hide_end_times') ? esc_html__('from','booked').' ' : esc_html__('at','booked').' ') . $time_start . (!get_option('booked_hide_end_times') ? ' – '.$time_end : ''); endif; $atc_date_startend_end = $atc_date_startend; endif; echo ''; if (!$historic): if ($appointment_default_status !== 'publish' && $appt['status'] !== 'future' || $appointment_default_status == 'publish' && $status_class == 'pending'): echo ''.($status_class == 'pending' ? '' : '').'  '.$status.''; endif; endif; echo (!empty($appt['calendar_id']) ? ''.esc_html__('Calendar','booked').': '.$appt['calendar_id'][0]->name.'
' : ''); echo ''.($ts_title ? ''.$ts_title.':  ' : '').$day_name.$date_display.'  ' . $timeslotText; do_action('booked_shortcode_appointments_additional_information', $appt['post_id']); echo ($cf_meta_value ? '
'.esc_html__('Additional information','booked').'
'.$cf_meta_value.'
' : ''); if (!$historic): $calendar_button_array = array( 'atc_date_startend' => $atc_date_startend, 'atc_time_start' => $atc_time_start, 'atc_date_startend_end' => $atc_date_startend_end, 'atc_time_end' => $atc_time_end, ); ob_start(); booked_add_to_calendar_button($calendar_button_array,$cf_meta_value); if ( apply_filters('booked_shortcode_appointments_allow_cancel', true, $appt['post_id']) && !get_option('booked_dont_allow_user_cancellations',false) ) { if ( $appt_date_time >= $date_to_compare ) { echo ''.esc_html__('Cancel Appointment','booked').''; } } do_action('booked_shortcode_appointments_buttons', $appt['post_id']); $buttons_content = ob_get_clean(); if ($buttons_content): echo '
'; echo $buttons_content; echo '
'; endif; endif; echo '
'; endforeach; echo '
'; if (!isset($atts['remove_wrapper'])): echo '
'; endif; wp_reset_postdata(); else : return '

'.esc_html__('Please log in to view your upcoming appointments.','booked').'

'; endif; return ob_get_clean(); } /* LOGIN SHORTCODE */ public function booked_login_form( $atts, $content = null ) { global $post; if (!is_user_logged_in()) { ob_start(); ?>


ID; ?>
false, 'redirect' => get_the_permalink($login_redirect), 'label_username' => esc_html__( 'Email Address','booked' ) ) ); ?>
', $booked_reg_errors); ?>