name = __( 'Confirmation', 'appointments' ); } public function get_defaults() { return array( 'title' => array( 'type' => 'text', 'name' => __( 'Title', 'appointments' ), 'value' => sprintf( '

%s

', esc_html__( 'Please check the appointment details below and confirm:', 'appointments' ) ), 'help' => __( 'Text above fields. Default: "Please check the appointment details below and confirm:"', 'appointments' ), ), 'button_text' => array( 'type' => 'text', 'name' => __( 'Button text', 'appointments' ), 'value' => __( 'Please click here to confirm this appointment', 'appointments' ), 'help' => __( 'Text of the button that asks client to confirm the appointment. Default: "Please click here to confirm this appointment"', 'appointments' ), ), 'confirm_text' => array( 'type' => 'text', 'name' => __( 'Confim text', 'appointments' ), 'value' => __( 'We have received your appointment. Thanks!', 'appointments' ), 'help' => __( 'Javascript text that will be displayed after receiving of the appointment. This will only be displayed if you do not require payment. Default: "We have received your appointment. Thanks!"', 'appointments' ), ), 'warning_text' => array( 'type' => 'text', 'name' => __( 'Warning text', 'appointments' ), 'value' => __( 'Please fill in the requested field','appointments' ), 'help' => __( ' Javascript text displayed if client does not fill a required field. Default: "Please fill in the requested field"', 'appointments' ), ), 'name' => array( 'type' => 'text', 'name' => __( 'Name label', 'appointments' ), 'value' => __( 'Your name:','appointments' ), 'help' => __( 'Descriptive title of the field.', 'appointments' ), ), 'email' => array( 'type' => 'text', 'name' => __( 'Email label', 'appointments' ), 'value' => __( 'Your email:','appointments' ), 'help' => __( 'Descriptive title of the field.', 'appointments' ), ), 'phone' => array( 'type' => 'text', 'name' => __( 'Phone label', 'appointments' ), 'value' => __( 'Your phone:','appointments' ), 'help' => __( 'Descriptive title of the field.', 'appointments' ), ), 'address' => array( 'type' => 'text', 'name' => __( 'Address label', 'appointments' ), 'value' => __( 'Your address:','appointments' ), 'help' => __( 'Descriptive title of the field.', 'appointments' ), ), 'city' => array( 'type' => 'text', 'name' => __( 'City label', 'appointments' ), 'value' => __( 'City:','appointments' ), 'help' => __( 'Descriptive title of the field.', 'appointments' ), ), 'note' => array( 'type' => 'text', 'name' => __( 'Notes label', 'appointments' ), 'value' => __( 'Your notes:','appointments' ), 'help' => __( 'Descriptive title of the field.', 'appointments' ), ), 'gcal' => array( 'type' => 'text', 'name' => __( 'Google Cal label', 'appointments' ), 'value' => __( 'Access Google Calendar and submit appointment','appointments' ), 'help' => __( 'Text that will be displayed beside Google Calendar checkbox. Default: "Open Google Calendar and submit appointment"', 'appointments' ), ), ); } public function get_usage_info() { return '' . __( 'Inserts a form which displays the details of the selected appointment and has fields which should be filled by the client.', 'appointments' ) . '
' . __( 'This shortcode is always required to complete an appointment.', 'appointments' ) . ''; } public function process_shortcode( $args = array(), $content = '' ) { $args = wp_parse_args( $args, $this->_defaults_to_args() ); extract( $args ); global $appointments; // Get user form data from his cookie $data = Appointments_Sessions::get_visitor_personal_data(); $n = isset( $data['n'] ) ? sanitize_text_field( $data['n'] ) : ''; // Name $e = isset( $data['e'] ) ? sanitize_text_field( $data['e'] ) : ''; // Email $p = isset( $data['p'] ) ? sanitize_text_field( $data['p'] ) : ''; // Phone $a = isset( $data['a'] ) ? sanitize_text_field( $data['a'] ) : ''; // Address $c = isset( $data['c'] ) ? sanitize_text_field( $data['c'] ) : ''; // City $g = isset( $data['g'] ) ? sanitize_text_field( $data['g'] ) : ''; // GCal selection if ( $g ) { $gcal_checked = ' checked="checked"'; } else { $gcal_checked = ''; } // User may have already saved his data before if ( is_user_logged_in() ) { global $current_user; $user_info = get_userdata( $current_user->ID ); $name_meta = get_user_meta( $current_user->ID, 'app_name', true ); if ( $name_meta ) { $n = $name_meta; } else if ( $user_info->display_name ) { $n = $user_info->display_name; } else if ( $user_info->user_nicename ) { $n = $user_info->user_nicename; } else if ( $user_info->user_login ) { $n = $user_info->user_login; } $email_meta = get_user_meta( $current_user->ID, 'app_email', true ); if ( $email_meta ) { $e = $email_meta; } else if ( $user_info->user_email ) { $e = $user_info->user_email; } $phone_meta = get_user_meta( $current_user->ID, 'app_phone', true ); if ( $phone_meta ) { $p = $phone_meta; } $address_meta = get_user_meta( $current_user->ID, 'app_address', true ); if ( $address_meta ) { $a = $address_meta; } $city_meta = get_user_meta( $current_user->ID, 'app_city', true ); if ( $city_meta ) { $c = $city_meta; } } $ret = ''; /** * GDPR */ $gdpr_checkbox_show = appointments_get_option( 'gdpr_checkbox_show' ); $gdpr_checkbox_show = 'yes' === $gdpr_checkbox_show; ob_start(); ?>
appointments_plugin_url() . 'images/waiting.gif', 'isUserLoggedIn' => is_user_logged_in(), 'loginRequired' => $appointments->options['login_required'], 'ajaxurl' => admin_url( 'admin-ajax.php', $schema ), 'nonce' => wp_create_nonce( 'AppShortcodeConfirmation' ), 'askName' => $appointments->options['ask_name'], 'askEmail' => $appointments->options['ask_email'], 'askPhone' => $appointments->options['ask_phone'], 'askAddress' => $appointments->options['ask_address'], 'askCity' => $appointments->options['ask_city'], 'askNote' => $appointments->options['ask_note'], 'askGDPR' => $appointments->options['ask_note'], 'askGCal' => isset( $appointments->options['gcal'] ) && 'yes' == $appointments->options['gcal'], 'askGDPR' => isset( $appointments->options['gdpr_checkbox_show'] ) && 'yes' == $appointments->options['gdpr_checkbox_show'], 'warningText' => esc_js( $args['warning_text'] ), 'confirmationText' => esc_js( $args['confirm_text'] ), 'connectionErrorText' => esc_js( __( 'A connection problem occurred. Please try again.','appointments' ) ), 'GDPRmissingText' => esc_js( $appointments->options['gdpr_checkbox_alert'] ), 'errorTitle' => esc_js( __( 'Error', 'appointments' ) ), ); wp_localize_script( 'app-shortcode-confirmation', 'AppShortcodeConfirmation', $i10n ); return $ret; } }