Create Form on Frontend-Duplicating Forms
-
Hello, so I’ve created a code to create forms from the frontend that can be accessed from the backend as well. I’m having an issue with my code. It duplicates the form one form has the calendar on the backend and the other doesn’t display the editor but it has the same name different id’s. I know you’re busy but I would appreciate the help. Maybe you could also integrate something like this in future plugin updates.
Here’s how it appears on the frontend: https://prntscr.com/11b6223
Here’s how it appears from the backend of 1 duplicate form the other form the calendar appears. Backend of Form
I know that it’s being called twice here:
$created = $wpdb->insert( BOOKACTI_TABLE_FORMS, array( 'title' => $title, 'user_id' => get_current_user_id(), 'creation_date' => $current_datetime_object->format( 'Y-m-d H:i:s' ), 'status' => $status, 'active' => intval( $active ) ), array( '%s', '%d', '%s', '%s', '%d' ) );
AND
here :
$form_id = bookacti_create_form( $title, 'publish', 1 );
I added JS and CSS files to child theme. I added admin-ajax snippet in another code separated below but I don’t think it’s what’s causing the issue.
Here’s the shortcode [calendar_form_creates] :add_shortcode('calendar_form_creates', 'calendar_form_creates'); function calendar_form_creates(){ $current_user_can_create_template = current_user_can( 'bookacti_create_templates' ); $current_user_can_edit_template = current_user_can( 'bookacti_edit_templates' ); $current_user_can_create_activities = current_user_can( 'bookacti_create_activities' ); $default_template = false; // use get_stylesheet_directory_uri() for child theme // // change to plugin directory files later// // Include global var on WC products and orders screens if( bookacti_is_plugin_active( 'woocommerce/woocommerce.php' ) ) { if( bookacti_is_wc_screen( array( 'product', 'product_variation', 'shop_order' ) ) ) { wp_enqueue_script( 'bookacti-js-global-var', get_stylesheet_directory_uri() . '/booking-activities/js/global-var.min.js', array( 'jquery' ), BOOKACTI_VERSION, false ); // Load in header } } // On backend, only include these scripts on Booking Activities pages if( is_admin() && ! bookacti_is_booking_activities_screen() ) { return; } // INCLUDE LIBRARIES $moment_version = '2.25.3'; if( ! wp_script_is( 'moment', 'registered' ) ) { wp_register_script( 'moment', get_stylesheet_directory_uri() . '/booking-activities/lib/fullcalendar/moment.min.js', array( 'jquery' ), $moment_version, true ); } if( ! wp_script_is( 'moment', 'enqueued' ) ) { wp_enqueue_script( 'moment' ); } // Fullcalendar: The max suported version is 3.10.2 $fullcalendar_version = '3.10.2'; $registered_fc = wp_scripts()->query( 'fullcalendar', 'registered' ); $registered_fc_version = $registered_fc && ! empty( $registered_fc->ver ) ? $registered_fc->ver : ''; if( ! $registered_fc || ( $registered_fc_version && version_compare( $registered_fc_version, $fullcalendar_version, '>' ) ) ) { wp_register_script( 'fullcalendar', get_stylesheet_directory_uri() . '/booking-activities/lib/fullcalendar/fullcalendar.min.js', array( 'jquery', 'moment' ), $fullcalendar_version, true ); } if( ! wp_script_is( 'fullcalendar', 'enqueued' ) ) { wp_enqueue_script( 'fullcalendar' ); } wp_enqueue_script( 'bookacti-js-fullcalendar-locale-all', get_stylesheet_directory_uri() . '/booking-activities/lib/fullcalendar/locale-all.js', array( 'jquery', 'fullcalendar' ), $fullcalendar_version, true ); // INCLUDE STYLESHEETS wp_enqueue_style ( 'bookacti-css-fullcalendar', get_stylesheet_directory_uri() . '/booking-activities/lib/fullcalendar/fullcalendar.min.css', array(), BOOKACTI_VERSION ); wp_enqueue_style ( 'bookacti-css-fullcalendar-print', get_stylesheet_directory_uri() . '/booking-activities/lib/fullcalendar/fullcalendar.print.min.css', array( 'bookacti-css-fullcalendar' ), BOOKACTI_VERSION, 'print' ); // INCLUDE JAVASCRIPT FILES wp_enqueue_script( 'bookacti-js-global-var', get_stylesheet_directory_uri() . '/booking-activities/js/global-var.min.js', array( 'jquery' ), BOOKACTI_VERSION, false ); // Load in header wp_enqueue_script( 'bookacti-js-global-functions', get_stylesheet_directory_uri() . '/booking-activities/js/global-functions.min.js', array( 'jquery', 'jquery-ui-tooltip', 'bookacti-js-global-var' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-booking-system-functions', get_stylesheet_directory_uri() . '/booking-activities/js/booking-system-functions.min.js', array( 'jquery', 'fullcalendar', 'jquery-effects-highlight', 'bookacti-js-global-var' ), BOOKACTI_VERSION, true ); // Include WooCommerce scripts if( bookacti_is_plugin_active( 'woocommerce/woocommerce.php' ) ) { if( bookacti_is_wc_screen( array( 'product', 'product_variation', 'shop_order' ) ) || bookacti_is_booking_activities_screen() ) { wp_enqueue_script( 'bookacti-js-woocommerce-backend', get_stylesheet_directory_uri() . '/booking-activities/js/woocommerce-backend.min.js', array( 'jquery' ), BOOKACTI_VERSION, true ); } } // Include WooCommerce style and scripts if( bookacti_is_plugin_active( 'woocommerce/woocommerce.php' ) ) { if( ! is_admin() || bookacti_is_wc_screen( array( 'product', 'product_variation', 'shop_order' ) ) ) { wp_enqueue_style ( 'bookacti-css-woocommerce', get_stylesheet_directory_uri() . '/booking-activities/css/woocommerce.min.css', array(), BOOKACTI_VERSION ); } if( ! is_admin() ) { wp_enqueue_script( 'bookacti-js-woocommerce-frontend', get_stylesheet_directory_uri() . '/booking-activities/js/woocommerce-frontend.min.js', array( 'jquery', 'fullcalendar', 'bookacti-js-global-var', 'bookacti-js-global-functions', 'bookacti-js-booking-method-calendar' ), BOOKACTI_VERSION, true ); } wp_enqueue_script( 'bookacti-js-woocommerce-global', get_stylesheet_directory_uri() . '/booking-activities/js/woocommerce-global.min.js', array( 'jquery', 'moment', 'jquery-ui-dialog', 'bookacti-js-global-var', 'bookacti-js-global-functions' ), BOOKACTI_VERSION, true ); } // Register Booking Activities' jquery-ui theme, so it is ready to be enqueued / dequeued if needed global $wp_version; $jquery_ui_css_filename = version_compare( $wp_version, '5.6', '<' ) ? 'jquery-ui-1.11.4.min.css' : 'jquery-ui.min.css'; wp_register_style( 'bookacti-css-jquery-ui', get_stylesheet_directory_uri() . '/booking-activities/lib/jquery-ui/themes/booking-activities/' . $jquery_ui_css_filename, array(), BOOKACTI_VERSION ); // On backend, only include these scripts on Booking Activities pages if( is_admin() && ! bookacti_is_booking_activities_screen() ) { return; } // INCLUDE STYLESHEETS wp_enqueue_style ( 'bookacti-css-backend', get_stylesheet_directory_uri() . '/booking-activities/css/backend.min.css'); wp_enqueue_style ( 'bookacti-css-templates', get_stylesheet_directory_uri() . '/booking-activities/css/templates.min.css'); wp_enqueue_style ( 'bookacti-css-landing', get_stylesheet_directory_uri() . '/booking-activities/css/landing.min.css'); // INCLUDE STYLESHEETS wp_enqueue_style( 'bookacti-css-global', get_stylesheet_directory_uri() . '/booking-activities/css/global.min.css'); wp_enqueue_style( 'bookacti-css-fonts', get_stylesheet_directory_uri() . '/booking-activities/css/fonts.min.css'); wp_enqueue_style( 'bookacti-css-bookings', get_stylesheet_directory_uri() . '/booking-activities/css/bookings.min.css'); wp_enqueue_style( 'bookacti-css-forms', get_stylesheet_directory_uri() . '/booking-activities/css/forms.min.css'); wp_enqueue_style( 'bookacti-css-jquery-ui' ); // INCLUDE JAVASCRIPT FILES wp_enqueue_script( 'bookacti-js-booking-system', get_stylesheet_directory_uri() . '/booking-activities/js/booking-system.min.js', array( 'jquery', 'fullcalendar', 'bookacti-js-global-var', 'bookacti-js-global-functions' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-booking-system-dialogs', get_stylesheet_directory_uri() . '/booking-activities/js/booking-system-dialogs.min.js', array( 'jquery', 'moment', 'jquery-ui-dialog', 'bookacti-js-global-var' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-booking-method-calendar', get_stylesheet_directory_uri() . '/booking-activities/js/booking-method-calendar.min.js', array( 'jquery', 'fullcalendar', 'bookacti-js-global-var', 'bookacti-js-global-functions' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-bookings-functions', get_stylesheet_directory_uri() . '/booking-activities/js/bookings-functions.min.js', array( 'jquery', 'fullcalendar', 'bookacti-js-global-var', 'bookacti-js-global-functions', ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-bookings-dialogs', get_stylesheet_directory_uri() . '/booking-activities/js/bookings-dialogs.min.js', array( 'jquery', 'moment', 'jquery-ui-dialog', 'bookacti-js-global-var', 'bookacti-js-global-functions' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-forms', get_stylesheet_directory_uri() . '/booking-activities/js/forms.min.js', array( 'jquery', 'jquery-ui-dialog', 'bookacti-js-global-functions' ), BOOKACTI_VERSION, true ); // INCLUDE JAVASCRIPT FILES wp_enqueue_script( 'bookacti-js-templates-forms-control', get_stylesheet_directory_uri() . '/booking-activities/js/templates-forms-control.min.js', array( 'jquery', 'moment', 'bookacti-js-global-var' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-templates-functions', get_stylesheet_directory_uri() . '/booking-activities/js/templates-functions.min.js', array( 'jquery', 'fullcalendar', 'jquery-touch-punch', 'jquery-effects-highlight', 'bookacti-js-global-var' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-templates-dialogs', get_stylesheet_directory_uri() . '/booking-activities/js/templates-dialogs.min.js', array( 'jquery', 'moment', 'jquery-ui-dialog', 'bookacti-js-global-var', 'bookacti-js-global-functions', 'bookacti-js-backend-functions', 'bookacti-js-templates-forms-control' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-templates', get_stylesheet_directory_uri() . '/booking-activities/js/templates.min.js', array( 'jquery', 'fullcalendar', 'bookacti-js-global-var', 'bookacti-js-global-functions', 'bookacti-js-templates-functions', 'bookacti-js-templates-dialogs' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-settings', get_stylesheet_directory_uri() . '/booking-activities/js/settings.min.js', array( 'jquery' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-form-editor-dialogs', get_stylesheet_directory_uri() . '/booking-activities/js/form-editor-dialogs.min.js', array( 'jquery', 'moment', 'jquery-ui-dialog', 'bookacti-js-global-var', 'bookacti-js-backend-functions' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-form-editor', get_stylesheet_directory_uri() . '/booking-activities/js/form-editor.min.js', array( 'jquery', 'jquery-touch-punch', 'jquery-ui-sortable', 'bookacti-js-global-var', 'bookacti-js-booking-system-functions', 'bookacti-js-forms', 'bookacti-js-form-editor-dialogs' ), BOOKACTI_VERSION, true ); // INCLUDE LIBRARIES $select2_version = '4.0.13'; if( ! wp_script_is( 'select2', 'registered' ) ) { wp_register_script( 'select2', get_stylesheet_directory_uri() . '/booking-activities/lib/select2/select2.min.js', array( 'jquery' ), $select2_version, true ); } if( ! wp_script_is( 'select2', 'enqueued' ) ) { wp_enqueue_script( 'select2' ); } wp_enqueue_style( 'select2', get_stylesheet_directory_uri() . '/booking-activities/lib/select2/select2.min.css', array(), $select2_version ); // INCLUDE JAVASCRIPT FILES wp_enqueue_script( 'bookacti-js-backend-functions', get_stylesheet_directory_uri() . '/booking-activities/js/backend-functions.min.js', array( 'jquery', 'jquery-ui-dialog', 'jquery-ui-tabs', 'jquery-ui-tooltip', 'bookacti-js-global-var', 'bookacti-js-global-functions' ), BOOKACTI_VERSION, true ); wp_enqueue_script( 'bookacti-js-bookings', get_stylesheet_directory_uri() . '/booking-activities/js/bookings.min.js', array( 'jquery', 'fullcalendar', 'bookacti-js-global-var', 'bookacti-js-global-functions', 'bookacti-js-backend-functions' ), BOOKACTI_VERSION, true ); ?> <div class='wrap'> <h1 class='wp-heading-inline'><?php esc_html_e( 'Calendar editor', 'booking-activities' ); ?></h1> <?php do_action( 'bookacti_calendar_editor_page_header' ); ?> <hr class='wp-header-end'> <div id='bookacti-fatal-error' class='bookacti-notices' style='display:none;'> <ul class='bookacti-error-list'> <li><strong> <?php /* translators: %s is a link to the official FAQ. The label of this link is "FAQ". */ echo sprintf( esc_html__( 'A fatal error occurred. Please try to refresh the page. If the error persists, follow the process under "Booking Activities doesn’t work as it should" here: %s.', 'booking-activities' ), '<a href="https://booking-activities.fr/en/documentation/faq">' . esc_html__( 'FAQ', 'booking-activities' ) . '</a>' ); ?> </strong> <li><em><?php esc_html_e( 'Advanced users, you can stop loading and free the fields to try to solve your problem:', 'booking-activities' ); ?></em> <input type='button' id='bookacti-exit-loading' value='<?php esc_attr_e( 'Stop loading and free fields', 'booking-activities' ) ?>' /> </ul> </div> <div id='bookacti-template-container'> <?php $templates = bookacti_fetch_templates(); wp_nonce_field( 'bookacti_fetch_template_events', 'nonce_fetch_template_events', false ); wp_nonce_field( 'bookacti_edit_template', 'nonce_edit_template', false ); ?> <div id='bookacti-template-sidebar' class='<?php if( ! $templates ) { echo 'bookacti-no-template'; } ?>'> <div id='bookacti-template-templates-container' class='bookacti-templates-box' > <div class='bookacti-template-box-title' > <h4><?php echo esc_html__( 'Calendars', 'booking-activities' ); ?></h4> <?php if( $current_user_can_create_template ) { ?> <div class='bookacti-insert-button dashicons dashicons-plus-alt' id='bookacti-insert-template' ></div> <?php } ?> </div> <div id='bookacti-template-picker-container' > <select name='template-picker' id='bookacti-template-picker' > <?php if( $templates ) { $default_template = get_user_meta( get_current_user_id(), 'bookacti_default_template', true ); $default_template_found = false; foreach ( $templates as $template ) { $selected = selected( $default_template, $template[ 'id' ], false ); if( ! empty( $selected ) ) { $default_template_found = true; } echo "<option value='" . esc_attr( $template[ 'id' ] ) . "' data-template-start='" . esc_attr( $template[ 'start' ] ) . "' data-template-end='" . esc_attr( $template[ 'end' ] ) . "' " . $selected . " >" . esc_html( $template[ 'title' ] ) . "</option>"; } if ( ! $default_template_found ) { reset( $templates ); $current_template = current( $templates ); $default_template = $current_template[ 'id' ]; update_user_meta( get_current_user_id(), 'bookacti_default_template', $default_template ); } } ?> </select> </div> <?php if( $current_user_can_edit_template ) { ?> <div id='bookacti-update-template'><span class='dashicons dashicons-admin-generic'></span></div> <?php } ?> </div> <div id='bookacti-template-activities-container' class='bookacti-templates-box' > <div class='bookacti-template-box-title' > <h4><?php echo esc_html__( 'Activities', 'booking-activities' ); ?></h4> <?php if( $current_user_can_create_activities ) { ?> <div class='bookacti-insert-button dashicons dashicons-plus-alt' id='bookacti-insert-activity' ></div> <?php } ?> </div> <?php // Display list of activities $activity_list = ''; if( $default_template ) { $activity_list = bookacti_get_template_activities_list( $default_template ); } ?> <div id='bookacti-template-activity-list' class='bookacti-custom-scrollbar'> <?php if( ! empty( $activity_list ) ) { echo $activity_list; } else if( ! $current_user_can_create_activities ) { ?> <div id='bookacti-template-no-activity' > <h2> <?php esc_html_e( 'There is no activity available, and you are not allowed to create one.', 'booking-activities' ); ?> </h2> </div> <?php } ?> </div> <?php if( $current_user_can_create_activities ) { ?> <div id='bookacti-template-first-activity-container' style='display:<?php echo empty( $activity_list ) ? 'block' : 'none'; ?>;' > <h2> <?php _e( 'Create your first activity', 'booking-activities' ); ?> </h2> <div id='bookacti-template-add-first-activity-button' class='dashicons dashicons-plus-alt'></div> </div> <?php } ?> </div> <div id='bookacti-template-groups-of-events-container' class='bookacti-templates-box' > <div class='bookacti-template-box-title' > <h4><?php echo esc_html__( 'Groups of events', 'booking-activities' ); ?></h4> <?php if( $current_user_can_edit_template ) { ?> <div class='bookacti-insert-button dashicons dashicons-plus-alt' id='bookacti-insert-group-of-events' ></div> <?php } ?> </div> <div id='bookacti-group-categories' class='bookacti-custom-scrollbar'> <?php // Display the template's groups of events list $groups_list = bookacti_get_template_groups_of_events_list( $default_template ); if( ! empty( $groups_list ) ) { echo $groups_list; } ?> </div> <?php // If no goup categories exists, display a tuto to create a group of events if( $current_user_can_edit_template ) { ?> <p id='bookacti-template-add-group-of-events-tuto-select-events' style='<?php if( ! empty( $groups_list ) ) { echo 'display:none;'; } ?>' > <?php _e( 'Select at least 2 events to create a group of events', 'booking-activities' ); ?> </p> <div id='bookacti-template-add-first-group-of-events-container' > <h2> <?php _e( 'Create your first group of events', 'booking-activities' ); ?> </h2> <div id='bookacti-template-add-first-group-of-events-button' class='dashicons dashicons-plus-alt' ></div> </div> <?php } ?> </div> <div id='bookacti-template-shortcuts-container'> <ul> <li> <strong><?php echo esc_html__( 'Duplicate an event:', 'booking-activities' ); ?></strong> <em><?php esc_html_e( 'Hold the "Alt" key while moving the event', 'booking-activities' ); ?></em> </li> <li> <strong><?php esc_html_e( 'Group events:', 'booking-activities' ); ?></strong> <em><?php esc_html_e( 'CRTL + G', 'CTRL key', 'booking-activities' ); ?></em> </li> </ul> </div> </div> <div id='bookacti-template-content' > <?php if( $templates ) { ?> <div id='bookacti-template-calendar' class='bookacti-calendar' ></div> <?php } ?> <div id='bookacti-first-template-container' <?php if( $templates ) { echo 'style="display:none;"'; } ?>> <h2> <?php echo $current_user_can_create_template ? esc_html__( 'Welcome to Booking Activities! Let\'s start by creating your first calendar', 'booking-activities' ) : esc_html__( 'There are no calendars available, and you are not allowed to create one.', 'booking-activities' ); ?> </h2> <?php if( $current_user_can_create_template ) { ?> <div id='bookacti-add-first-template-button' class='dashicons dashicons-plus-alt' ></div> <?php } ?> </div> </div> </div> <hr/> <div id='bookacti-calendar-integration-tuto-container' class='<?php if( ! $templates ) { echo 'bookacti-no-template'; } ?>' > <?php $template_id = ''; $activity_ids = array(); $initial_parameters = http_build_query( array( 'page' => 'bookacti_forms', 'action' => 'new', 'calendars' => $template_id, 'activities' => 'all', 'group_categories' => 'all', )); ?> </div> <form name='my-custom-booking-forms' method='POST' action='<?php the_permalink(); ?>'> title: <input type=”text” id=”title” name="calendar_title" value='<?php echo esc_attr(isset ($_POST['title'])); ?>'> <ol> <li> <?php if( current_user_can( 'bookacti_create_forms' ) ) { ?> <button type="submit" name="save_form"><?php _e('Create Form From This Calendar', 'booking-activities') ?></button> <?php esc_html_e( 'Click here to create a booking form with this calendar', 'booking-activities' ); ?> <?php } else { ?> <em><?php esc_html_e( 'You are not allowed to create booking forms.', 'booking-activities' ); ?></em> <?php } ?> </li> <li> <?php echo apply_filters( 'bookacti_calendar_integration_tuto', esc_html__( 'Copy and paste the booking form shortcode into the desired page or post', 'booking-activities' ), $template_id ); ?> <input type="hidden" name="id" value='<?php echo esc_attr(isset ($_POST['id'])); ?>'> <input type="hidden" name="active" value="1"> <input type="hidden" name="status" value="publish"> <input type="hidden" name="creation_date" value='<?php echo esc_attr(isset ($_POST['creation_date'])); ?>'> <input type="hidden" name="user_id" value="{{ Auth::user()->id }}"> <input type='hidden' name='calendar_field[calendars]' value='<?php echo isset ($template_id); ?>'/> <input type='hidden' name='calendar_field[activities]' value='all'/> <input type='hidden' name='calendar_field[group_categories]' value='all'/> </form> </div> </div> <?php //Include dialogs require_once( trailingslashit(get_stylesheet_directory() ) . 'booking-activities/view/view-templates-dialogs.php' ); ?> </div> <?php if(isset($_POST['save_form'])) { global $wpdb; $_bookacti_forms_table = $wpdb->prefix."bookacti_forms"; $title = ! empty( $_REQUEST[ 'calendar_title' ] ) ? sanitize_text_field( stripslashes( $_REQUEST[ 'calendar_title' ] ) ) : ''; $status = 'publish'; $active = 1; $form_id = bookacti_create_form( $title, 'publish', 1 ); if( ! $form_id ) { esc_html_e( 'Error occurs when trying to create the form.', 'booking-activities' ); exit; } // Insert calendar data (if any) if( ! empty( $_REQUEST[ 'calendar_field' ] ) && is_array( $_REQUEST[ 'calendar_field' ] ) ) { $default_calendar_meta = array(); if( ! empty( $_REQUEST[ 'calendar_field' ][ 'calendars' ] ) ) { $calendar_ids = bookacti_ids_to_array( $_REQUEST[ 'calendar_field' ][ 'calendars' ] ); $template_data = bookacti_get_mixed_template_data( $calendar_ids, false ); $default_calendar_meta = $template_data[ 'settings' ]; } $raw_calendar_meta = array_merge( $default_calendar_meta, $_REQUEST[ 'calendar_field' ] ); if( $raw_calendar_meta ) { // $raw_calendar_meta will be sanitized in bookacti_update_form_field_meta bookacti_update_form_field_meta( $raw_calendar_meta, 'calendar', $form_id ); } } $form_id = $wpdb->insert_id; // Get current UTC datetime $utc_timezone = new DateTimeZone( 'UTC' ); $current_datetime_object = new DateTime( 'now', $utc_timezone ); $created = $wpdb->insert( BOOKACTI_TABLE_FORMS, array( 'title' => $title, 'user_id' => get_current_user_id(), 'creation_date' => $current_datetime_object->format( 'Y-m-d H:i:s' ), 'status' => $status, 'active' => intval( $active ) ), array( '%s', '%d', '%s', '%s', '%d' ) ); if( ! $created ) { return $created; } $form_id = $wpdb->insert_id; // Set a default title if empty if( ! $title ) { /* translators: %d is the form id */ $title = sprintf( __( 'Form #%d', 'booking-activities' ), $form_id ); bookacti_update_form( $form_id, $title ); } return $form_id; } }
Ajax Script
add_action('wp_head', 'add_jquery_calendar_form_creates'); function add_jquery_calendar_form_creates() { global $post; if( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'calendar_form_creates') ) {?> <script type="text/javascript"> addLoadEvent = function(func){if(typeof jQuery!=='undefined')jQuery(document).ready(func);else if(typeof wpOnload!=='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}; var ajaxurl = '/wp-admin/admin-ajax.php', pagenow = 'booking-activities_page_bookacti_calendars', typenow = '', adminpage = 'booking-activities_page_bookacti_calendars', thousandsSeparator = ',', decimalPoint = '.', isRtl = 0; </script> <script> var bookacti_localized = {"error":"An error occurred.","error_select_event":"You haven't selected any event. Please select an event.","error_corrupted_event":"There is an inconsistency in the selected events data, please select an event and try again.","error_less_avail_than_quantity":"You want to make %1$s bookings but only %2$s are available for the selected events. Please choose another event or decrease the quantity.","error_quantity_inf_to_0":"The amount of desired bookings is less than or equal to 0. Please increase the quantity.","error_not_allowed":"You are not allowed to do that.","error_user_not_logged_in":"You are not logged in. Please create an account and log in first.","error_password_not_strong_enough":"Your password is not strong enough.","loading":"Loading","one_person_per_booking":"for one person","n_people_per_booking":"for %1$s people","booking":"booking","bookings":"bookings","ajaxurl":"https:\/\/my.pervasiveconcierge.com\/wp-admin\/admin-ajax.php","nonce_query_select2_options":"70f91ee61d","fullcalendar_locale":"en","current_lang_code":"en","current_locale":"en_US","available_booking_methods":["calendar"],"event_tiny_height":30,"event_small_height":75,"event_narrow_width":70,"event_wide_width":250,"started_events_bookable":false,"started_groups_bookable":false,"event_load_interval":92,"default_view_threshold":640,"bookings_tooltip_mouseover_timeout":250,"date_format":"M, jS - g:i A","date_format_long":"l, F jS, Y g:i A","time_format":"g:i A","dates_separator":" → ","date_time_separator":" → ","single_event":"Single event","selected_event":"Selected event","selected_events":"Selected events","avail":"avail.","avails":"avail.","hide_availability_fixed":0,"dialog_button_ok":"OK","dialog_button_cancel":"Close","dialog_button_cancel_booking":"Cancel booking","dialog_button_reschedule":"Reschedule","dialog_button_refund":"Refund","plugin_path":"https:\/\/my.pervasiveconcierge.com\/wp-content\/plugins\/booking-activities","is_admin":true,"current_user_id":1,"current_time":"2021-03-27 16:36:34","calendar_localization":"default","wp_time_format":"g:i a","wp_start_of_week":"1","nonce_dismiss_5stars_rating_notice":"3f09d284de","admin_url":"https:\/\/my.pervasiveconcierge.com\/wp-admin\/","is_qtranslate":false,"utc_offset":0,"create_new":"Create new","edit_id":"id","dialog_button_generate_link":"Generate export link","dialog_button_reset":"Reset","dialog_button_delete":"Delete","error_time_format":"The time format should be HH:mm where "HH" represents hours and "mm" minutes.","error_availability_period":"The "At the earliest" delay must be higher than the "At the latest" delay.","error_closing_before_opening":"The "Opening" date must be prior to the "Closing" date.","nonce_get_booking_rows":"b2342e9aa2","dialog_button_create_activity":"Create Activity","dialog_button_import_activity":"Import Activity","dialog_button_unbind":"Unbind","dialog_button_move":"Move","error_end_before_start":"The "Start" date must be prior to the "End" date.","error_fill_field":"Please fill this field.","error_invalid_value":"Please select a valid value.","error_repeat_period_not_set":"The repetition period is not set.","error_repeat_end_before_begin":"The repetition period cannot end before it started.","error_repeat_start_before_template":"The repetition period should not start before the beginning date of the calendar.","error_repeat_end_after_template":"The repetition period should not end after the end date of the calendar.","error_days_sup_to_365":"The number of days should be between 0 and 365.","error_hours_sup_to_23":"The number of hours should be between 0 and 23.","error_minutes_sup_to_59":"The number of minutes should be between 0 and 59.","error_activity_duration_is_null":"The activity duration should not be null.","error_less_avail_than_bookings":"You can't set less available bookings than it has already on one of the occurrence of this event.","error_booked_events_out_of_period":"The repetition period must include all booked occurrences.","error_event_not_btw_from_and_to":"The selected event should be included in the period in which it will be repeated.","error_freq_not_allowed":"Error: The repetition frequency is not a valid value.","error_excep_not_btw_from_and_to":"Exception dates should be included in the repetition period.","error_excep_duplicated":"Exceptions should all have a different date.","error_set_excep_on_booked_occur":"Warning: this occurrence is booked.","error_no_templates_for_activity":"The activity must be bound to at least one calendar.","error_select_at_least_two_events":"You must select at least two events.","error_edit_locked_event":"This event is booked, you cannot move it nor change its duration.","error_no_template_selected":"You must select a calendar first.","expired":"expired","days":"days","day":"day","error_cart_expired":"Your cart has expired.","add_product_to_cart_button_text":"Add to cart","add_booking_to_cart_button_text":"Book","empty_product_price":"You must set a price for your product, otherwise the booking form won\u2019t appear on the product page."}; </script> <script> var ajaxurl = "https://yourdomainname.com/wp-admin/admin-ajax.php"; </script><link rel='dns-prefetch' href='//stats.wp.com' /> <link rel='dns-prefetch' href='//s.w.org' /> <style> img.wp-smiley, img.emoji { display: inline !important; border: none !important; box-shadow: none !important; height: 1em !important; width: 1em !important; margin: 0 .07em !important; vertical-align: -0.1em !important; background: none !important; padding: 0 !important; } </style> <?php } }
- The topic ‘Create Form on Frontend-Duplicating Forms’ is closed to new replies.