settings->get();
$ssa_settings = $ssa->settings->remove_unauthorized_settings_for_current_user( $ssa_settings, true, true );
$ssa_appointment_types = $ssa->appointment_type_model->query( array (
'fetch' => array(
'has_sms' => true,
),
)
);
// Clean instruction fields
foreach ($ssa_appointment_types as $appointment_type_key => $appointment_type) {
if ( empty( $appointment_type['custom_customer_information'] ) ) {
continue;
}
if ( ! is_array( $appointment_type['custom_customer_information'] ) ) {
continue;
}
foreach ($appointment_type['custom_customer_information'] as $field_key => $field) {
if ( empty( $ssa_appointment_types[$appointment_type_key]['custom_customer_information'][$field_key]['instructions'] ) ) {
continue;
}
$ssa_appointment_types[$appointment_type_key]['custom_customer_information'][$field_key]['instructions'] = strip_tags( $ssa_appointment_types[$appointment_type_key]['custom_customer_information'][$field_key]['instructions'], '' );
}
}
// Override availability window
foreach ($ssa_appointment_types as $appointment_type_key => $appointment_type) {
if ( ! empty( $_GET['availability_start_date'] ) ) {
$ssa_appointment_types[$appointment_type_key]['availability_start_date'] = esc_attr( $_GET['availability_start_date'] );
}
if ( ! empty( $_GET['availability_end_date'] ) ) {
$ssa_appointment_types[$appointment_type_key]['availability_end_date'] = esc_attr( $_GET['availability_end_date'] );
}
if ( ! empty( $_GET['suggest_first_available_within_minutes'] ) && $ssa->settings_installed->is_installed( 'booking_flows' ) ) {
$ssa_appointment_types[$appointment_type_key]['booking_flow_settings']['suggest_first_available_within_minutes'] = (int) esc_attr( $_GET['suggest_first_available_within_minutes'] );
}
if ( ! empty( $_GET['flow'] ) && $ssa->settings_installed->is_installed( 'booking_flows' ) ) {
$flow = sanitize_key($_GET['flow']);
$ssa_appointment_types[$appointment_type_key]['booking_flow_settings']['booking_flow'] = $flow;
if ($flow != 'first_available' ) {
$ssa_appointment_types[$appointment_type_key]['booking_flow_settings']['suggest_first_available'] = false;
} else {
$ssa_appointment_types[$appointment_type_key]['booking_flow_settings']['suggest_first_available'] = true;
}
}
if ( ! empty( $_GET['fallback_flow'] ) && $ssa->settings_installed->is_installed( 'booking_flows' ) ) {
$ssa_appointment_types[$appointment_type_key]['booking_flow_settings']['fallback_booking_flow'] = esc_attr( $_GET['fallback_flow'] );
}
if ( ! empty( $_GET['date_view'] ) ) {
$date_view = esc_attr( $_GET['date_view']);
if( $ssa->settings_installed->is_installed( 'booking_flows' ) ) {
$ssa_appointment_types[$appointment_type_key]['booking_layout'] = $date_view;
} elseif ( $date_view === "month" || $date_view === "week" ){
$ssa_appointment_types[$appointment_type_key]['booking_layout'] = $date_view;
}
}
if ( ! empty( $_GET['time_view'] ) && $ssa->settings_installed->is_installed( 'booking_flows' ) ) {
$ssa_appointment_types[$appointment_type_key]['booking_flow_settings']['time_view'] = esc_attr( $_GET['time_view'] );
}
}
// Check for $_GET['label'] if set, and convert it to $_GET['types']
if( ! empty( $_GET['label'] ) ) {
$label = sanitize_text_field( esc_attr( $_GET['label'] ) );
$ids = $ssa->shortcodes->convert_label_to_appt_types_ids( $label );
if ( empty( $ids ) ) {
$error_message = '' . __('Sorry, no appointment types available for this label, please check back later.', 'simply-schedule-appointments') . '
';
if( current_user_can( 'ssa_manage_site_settings' ) ) {
$error_message .= '' . sprintf( __('The specified appointment type label \'%1$s\' can\'t be found, or has no appointment types available %2$s (this message only viewable to site administrators)', 'simply-schedule-appointments'),
$label,
'' );
}
return $error_message;
} else {
$_GET['types'] = $ids;
}
}
if ( ! empty( $_GET['types'] ) ) {
$params_types = esc_attr( $_GET['types'] );
} else if ( ! empty( $params['types'] ) ) {
$params_types = $params['types'];
}
if ( ! empty( $params_types ) ) {
$restricted_types = explode( ',', $params_types );
$ssa_appointment_types = array_filter( $ssa_appointment_types, function( $appointment_type ) use ( $restricted_types ) {
if ( empty( $appointment_type['id'] ) || empty( $appointment_type['slug'] ) ) {
return false;
}
if ( in_array( $appointment_type['id'], $restricted_types ) ) {
return true;
}
if ( in_array( $appointment_type['slug'], $restricted_types ) ) {
return true;
}
return false;
});
$ssa_appointment_types = array_values( $ssa_appointment_types );
}
$ssa_appointment_types = apply_filters( 'ssa_booking_appointment_types', $ssa_appointment_types );
// Setup booking URL parameters for global variable
$ssa_booking_url_settings = array(
'booking_url' => null,
'booking_post_id' => null,
'booking_title' => null,
);
if( isset( $_GET['booking_url'] ) ) {
$ssa_booking_url_settings['booking_url'] = esc_attr( $_GET['booking_url'] );
}
if( isset( $_GET['booking_post_id'] ) ) {
$ssa_booking_url_settings['booking_post_id'] = esc_attr( $_GET['booking_post_id'] );
}
if( isset( $_GET['booking_title'] ) ) {
$ssa_booking_url_settings['booking_title'] = html_entity_decode( urldecode( esc_attr( $_GET['booking_title'] ) ) );
}
function ssa_get_language_attributes( $doctype = 'html' ) {
$attributes = array();
$is_rtl = SSA_Translation::is_rtl();
$lang = SSA_Translation::get_locale();
$lang = str_replace( '_', '-', $lang );
if ( $is_rtl ) {
$attributes[] = 'dir="rtl"';
}
$attributes[] = 'lang="' . esc_attr( $lang ) . '"';
$output = implode( ' ', $attributes );
return $output;
}
?>
>