'subtab', // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link' | 'html'.
'title' => '', // Example: __( 'Dashboard' // Title of TAB.
'page_title' => '', // __( 'Search Availability' // Title of Page.
'hint' => '', // __( 'Configure the layout and functionality of both the search form and search results.' // Hint.
'link' => '', // wpbc_get_settings_url() . '&scroll_to_section=wpbc_general_settings_dashboard_tab', // Link.
'css_classes' => '', // cls CSS .
'font_icon' => 'wpbc_icn_dashboard',
'font_icon_right' => 'wpbc-bi-question-circle', // 'wpbc-bi-question-circle' .
'default' => false, // Is this sub tab activated by default or not: true || false.
);
$tabs[ 'form' ] = array(
'is_show_top_path' => false, // true | false. By default value is: false.
'left_navigation__default_view_mode' => 'compact', // '' | 'min' | 'compact' | 'max' | 'none'. By default value is: ''.
'page_title' => __( 'Booking Form', 'booking'), // Header - Title. If false, than hidden.
'page_description' => __('Add, remove, or customize fields in your booking form.','booking'), // Header - Title Description. If false, than hidden.
'title' => __( 'Booking Form', 'booking') // Title of TAB
, 'page_title'=> __( 'Booking Form', 'booking') // Title of Page
, 'hint' => __( 'Add, remove, or customize fields in your booking form.', 'booking') // Hint
//, 'css_classes'=> '' // CSS class(es)
, 'font_icon' => 'wpbc_icn_dashboard _customize dashboard rtt draw' // CSS definition of forn Icon
, 'default' => false // Is this tab activated by default or not: true || false.
, 'subtabs' => array()
, 'folder_style' => 'order:10;',
);
$section_id = 'wpbc_general_settings_booking_form_fields_metabox';
$subtabs['booking_form_fields'] = array_merge(
$subtab_default,
array(
'title' => __( 'Booking Form Fields', 'booking' ),
'page_title' => __( 'Booking Form Fields', 'booking' ),
'hint' => __( 'Add, remove, or customize fields in your booking form.', 'booking' ),
'font_icon' => 'wpbc-bi-ui-radios',
'font_icon_right' => 'wpbc-bi-question-circle',
'css_classes' => 'do_expand__' . $section_id . '_link', // sub_bold', .
//'onclick' => "wpbc_admin_ui__do__open_url__expand_section( '" . wpbc_get_settings_url() . "', '" . $section_id . "' );",
'link' => wpbc_get_settings_url() . '&tab=form',
'default' => true,
)
);
$tabs[ 'form' ]['subtabs'] = $subtabs;
if ( ! class_exists( 'wpdev_bk_personal' ) ) // FixIn: 8.1.1.12.
$tabs[ 'upgrade-link' ] = array(
'title' => __('Free vs Pro','booking') // Title of TAB
, 'hint' => __('Upgrade to higher versions', 'booking') // Hint
//, 'page_title' => __('Upgrade', 'booking') // Title of Page
, 'link' => 'https://wpbookingcalendar.com/features/' // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link
, 'position' => 'right' // 'left' || 'right' || ''
//, 'css_classes' => '' // CSS class(es)
//, 'icon' => '' // Icon - link to the real PNG img
, 'font_icon' => 'wpbc_icn_redeem'// CSS definition of forn Icon
//, 'default' => false // Is this tab activated by default or not: true || false.
//, 'subtabs' => array()
, 'folder_style' => 'order:9999;'
);
return $tabs;
}
public function content() {
$this->css();
// Define Notices Section and show some static messages, if needed
do_action( 'wpbc_hook_settings_page_header', 'form_field_free_settings');
if ( ! wpbc_is_mu_user_can_be_here('activated_user') ) return false; // Check if MU user activated, otherwise show Warning message.
//if ( ! wpbc_is_mu_user_can_be_here('only_super_admin') ) return false; // User is not Super admin, so exit. Basically its was already checked at the bottom of the PHP file, just in case.
// -------------------------------------------------------------------------------------------------------------
// Submit
// -------------------------------------------------------------------------------------------------------------
$submit_form_name = 'wpbc_form_field_free'; // Define form name
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
if ( isset( $_POST[ 'is_form_sbmitted_' . $submit_form_name ] ) ) {
// Nonce checking {Return false if invalid, 1 if generated between, 0-12 hours ago, 2 if generated between 12-24 hours ago. }
$nonce_gen_time = check_admin_referer( 'wpbc_settings_page_' . $submit_form_name ); // Its stop show anything on submitting, if it's not refear to the original page
wpbc_simple_form__page_save_submit(); // Save Changes
}
echo '';
wpbc_js_for_bookings_page(); // JavaScript: Tooltips, Popover, Datepick (js & css) //////////////////
echo '';
// -------------------------------------------------------------------------------------------------------------
// Content
// -------------------------------------------------------------------------------------------------------------
?>
left_navigation_menu_template();
?>
fields_generator_section();
wpbc_close_meta_box_section();
?>
show_booking_form_fields_table( $booking_form_structure );
?>
';
esc_html_e( 'Error', 'booking' );
echo '! ';
/* translators: 1: ... */
echo wp_kses_post( __( 'You can either use the time slots field or the start time and duration time fields, but not both. If you choose to use the start time and duration time fields, make sure to use them together.', 'booking' ) );
?>
';
esc_html_e( 'Error', 'booking' );
echo '! ';
/* translators: 1: ... */
echo wp_kses_post( __( 'You must use both the start time field and the duration time field together.', 'booking' ) );
?>
1 ) {
return 'duplicated_time_fields';
}
} else {
if ( count( $time_fields_arr ) === 1 ) {
return 'missed_time_fields';
}
}
return 'ok';
}
/**
* Show Fields Table */
private function show_booking_form_fields_table( $booking_form_structure ) {
$booking_form_structure = maybe_unserialize( $booking_form_structure );
$skip_obligatory_field_types =array();// array( 'calendar', 'submit', 'captcha' );
$obligatory_field_types = array( 'calendar', 'submit', 'email' );
if ( ! wpbc_is_mu_user_can_be_here( 'only_super_admin' ) ) {
$obligatory_field_types[] = 'captcha';
}
if ( 'duplicated_time_fields' === $this->is_exist_duplicated_time_fields( $booking_form_structure ) ) {
$this->help_notice__show_time_fields_once();
}
if ( 'missed_time_fields' === $this->is_exist_duplicated_time_fields( $booking_form_structure ) ) {
$this->help_notice__show_missed_time_fields();
}
?>
' . esc_html__('Shortcodes' ,'booking') . '. '
. wp_kses_post( sprintf(__('You can generate the form fields for your form (at the left side) by selection specific field in the above selectbox.' ,'booking'),'
[email* email]'))
/* translators: 1: ... */
.'
' . wp_kses_post( sprintf( __( 'Please read more about the booking form fields configuration %1$shere%2$s.', 'booking' ),'
', '') )
. '
' . esc_html__('Default Form Templates' ,'booking') . '. ' .
/* translators: 1: ... */
wp_kses_post( sprintf( __( 'You can reset your active form template by selecting default %1$sform template%2$s at the top toolbar. Please select the form template and click on %3$sReset%4$s button for resetting only active form (Booking Form or Content of Booking Fields form). Click on %5$sBoth%6$s button if you want to reset both forms: Booking Form and Content of Booking Fields form.', 'booking' )
,'',''
,'',''
,'',''
) )
.'
';
?>
generate_field(
'text_field_generator'
, array(
'active' => true
, 'required' => true
, 'label' => true
, 'name' => true
, 'value' => false
, 'type' => 'text'
)
);
?>
generate_field(
'textarea_field_generator'
, array(
'active' => true
, 'required' => true
, 'label' => true
, 'name' => true
, 'value' => false
, 'type' => 'textarea'
)
);
?>
generate_field(
'selectbox_field_generator'
, array(
'active' => true
, 'required' => true
, 'label' => true
, 'name' => true
, 'value' => true
, 'type' => 'selectbox'
)
);
?>
generate_field(
'checkbox_field_generator'
, array(
'active' => true
, 'required' => true
, 'label' => true
, 'name' => true
, 'value' => false
, 'type' => 'checkbox'
)
);
?>
generate_field(
'rangetime_field_generator'
, array(
'active' => true
, 'required' => true
, 'label' => true
, 'name' => true
, 'value' => true
, 'type' => 'selectbox'
, 'required_attr' => array( 'disabled' => true
, 'value' => 'On'
)
, 'label_attr' => array( 'placeholder' => __( 'Time Slots', 'booking' )
, 'value' => __( 'Time Slots', 'booking' )
)
, 'name_attr' => array( 'disabled' => true
, 'placeholder' => 'rangetime'
, 'value' => 'rangetime'
)
, 'value_attr' => array( 'value' => "10:00 AM - 12:00 PM@@10:00 - 12:00\n12:00 PM - 02:00 PM@@12:00 - 14:00\n13:00 - 14:00\n11:00 - 15:00\n14:00 - 16:00\n16:00 - 18:00\n18:00 - 20:00"
, 'attr' => array(
'placeholder' => "10:00 AM - 12:00 PM@@10:00 - 12:00\n12:00 PM - 02:00 PM@@12:00 - 14:00\n13:00 - 14:00\n11:00 - 15:00\n14:00 - 16:00\n16:00 - 18:00\n18:00 - 20:00"
)
, 'rows' => 8
, 'cols' => 37
)
)
);
?>
generate_field(
'durationtime_field_generator',
array(
'active' => true,
'required' => true,
'label' => true,
'name' => true,
'value' => true,
'type' => 'selectbox',
'required_attr' => array(
'disabled' => true,
'value' => 'On',
),
'label_attr' => array(
'placeholder' => __( 'Duration Time', 'booking' ),
'value' => __( 'Duration Time', 'booking' ),
),
'name_attr' => array(
'disabled' => true,
'placeholder' => 'durationtime',
'value' => 'durationtime',
),
'value_attr' => array(
'value' => "Service A (15 min)@@00:15\nService B (20 min)@@00:20\nService C (30 min)@@00:30\nService D (1 hour)@@01:00\nService E (2 hours)@@02:00",
'attr' => array(
'placeholder' => "Service A (15 min)@@00:15\nService B (20 min)@@00:20\nService C (30 min)@@00:30\nService D (1 hour)@@01:00\nService E (2 hours)@@02:00",
),
'rows' => 8,
'cols' => 37,
),
)
);
?>
generate_field(
'starttime_field_generator',
array(
'active' => true,
'required' => true,
'label' => true,
'name' => true,
'value' => true,
'type' => 'selectbox',
'required_attr' => array(
'disabled' => true,
'value' => 'On',
),
'label_attr' => array(
'placeholder' => __( 'Start Time', 'booking' ),
'value' => __( 'Start Time', 'booking' ),
),
'name_attr' => array(
'disabled' => true,
'placeholder' => 'starttime',
'value' => 'starttime',
),
'value_attr' => array(
'value' => "10:00 AM@@10:00\n10:30 AM@@10:30\n11:00 AM@@11:00\n11:30 AM@@11:30\n12:00 PM@@12:00\n12:30 PM@@12:30\n1:00 PM@@13:00\n1:30 PM@@13:30\n2:00 PM@@14:00\n2:30 PM@@14:30\n3:00 PM@@15:00\n3:30 PM@@15:30\n4:00 PM@@16:00\n4:30 PM@@16:30\n5:00 PM@@17:00\n5:30 PM@@17:30\n6:00 PM@@18:00",
'attr' => array(
'placeholder' => "10:00 AM@@10:00\n10:30 AM@@10:30\n11:00 AM@@11:00\n11:30 AM@@11:30\n12:00 PM@@12:00\n12:30 PM@@12:30\n1:00 PM@@13:00\n1:30 PM@@13:30\n2:00 PM@@14:00\n2:30 PM@@14:30\n3:00 PM@@15:00\n3:30 PM@@15:30\n4:00 PM@@16:00\n4:30 PM@@16:30\n5:00 PM@@17:00\n5:30 PM@@17:30\n6:00 PM@@18:00",
),
'rows' => 8,
'cols' => 37,
),
)
);
?>
generate_field(
'endtime_field_generator',
array(
'active' => true,
'required' => true,
'label' => true,
'name' => true,
'value' => true,
'type' => 'selectbox',
'required_attr' => array(
'disabled' => true,
'value' => 'On',
),
'label_attr' => array(
'placeholder' => __( 'End Time', 'booking' ),
'value' => __( 'End Time', 'booking' ),
),
'name_attr' => array(
'disabled' => true,
'placeholder' => 'endtime',
'value' => 'endtime',
),
'value_attr' => array(
'value' => "10:00 AM@@10:00\n10:30 AM@@10:30\n11:00 AM@@11:00\n11:30 AM@@11:30\n12:00 PM@@12:00\n12:30 PM@@12:30\n1:00 PM@@13:00\n1:30 PM@@13:30\n2:00 PM@@14:00\n2:30 PM@@14:30\n3:00 PM@@15:00\n3:30 PM@@15:30\n4:00 PM@@16:00\n4:30 PM@@16:30\n5:00 PM@@17:00\n5:30 PM@@17:30\n6:00 PM@@18:00",
'attr' => array(
'placeholder' => "10:00 AM@@10:00\n10:30 AM@@10:30\n11:00 AM@@11:00\n11:30 AM@@11:30\n12:00 PM@@12:00\n12:30 PM@@12:30\n1:00 PM@@13:00\n1:30 PM@@13:30\n2:00 PM@@14:00\n2:30 PM@@14:30\n3:00 PM@@15:00\n3:30 PM@@15:30\n4:00 PM@@16:00\n4:30 PM@@16:30\n5:00 PM@@17:00\n5:30 PM@@17:30\n6:00 PM@@18:00",
),
'rows' => 8,
'cols' => 37,
),
)
);
?>
true
, 'required' => true
, 'label' => true
, 'name' => true
, 'value' => true
//FixIn: TimeFreeGenerator (inside of form fields edited, as well)
, 'required_attr' => array( 'disabled' => false
, 'value' => 'Off'
)
, 'label_attr' => array( 'placeholder' => __('First Name', 'booking')
, 'value' => ''
)
, 'name_attr' => array( 'disabled' => false
, 'placeholder' => 'first_name'
, 'value' => ''
)
, 'value_attr' => array( 'value' => ''
, 'attr' => array( 'placeholder' => "1\n2\n3\n4" )
, 'rows' => 8
, 'cols' => 37
)
);
$field_options = wp_parse_args( $field_options, $defaults );
?>
public function activate() {
add_bk_option( 'booking_form', wpbc_simple_form__get_booking_form__as_shortcodes() );
add_bk_option( 'booking_form_show', wpbc_simple_form__get_form_show__as_shortcodes() );
add_bk_option( 'booking_form_visual', wpbc_simple_form__visual__get_default_form() );
}
public function deactivate() {
delete_bk_option( 'booking_form' );
delete_bk_option( 'booking_form_show' );
delete_bk_option( 'booking_form_visual');
}
//
}
add_action('wpbc_menu_created', array( new WPBC_Page_SettingsFormFieldsFree() , '__construct') ); // Executed after creation of Menu
// =====================================================================================================================
// Load JS files at specific pages only
// =====================================================================================================================
/**
* Load JS files.
*
* @param $hook 'post.php' | 'wp-booking-calendar3_page_wpbc-resources'
*
* @return void
*/
function wpbc_register_js__page_form_simple( $hook ) {
if (
( isset( $_REQUEST['page'] ) ) && ( 'wpbc-settings' === $_REQUEST['page'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
&& ( isset( $_REQUEST['tab'] ) ) && ( 'form' === $_REQUEST['tab'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
) {
// wpbc_load_js__required_for_modals();
// wpbc_load_js__required_for_media_upload();
wp_enqueue_script( 'wpbc_simple_form', wpbc_plugin_url( '/includes/page-form-simple/_src/wpbc_simple_form.js' ), array( 'wpbc_all' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) );
}
}
add_action( 'admin_enqueue_scripts', 'wpbc_register_js__page_form_simple' );