'WPBC_AJX_BFB_LOAD_FORM_CONFIG', 'ajax_nonce_load' => '', 'ajax_action_import' => 'wpbc_bfb_import_simple_form', 'ajax_nonce_import' => '', 'default_form_key' => 'default_booking_form', 'dropdown_title' => __( 'Forms', 'booking' ), 'dropdown_font_icon' => '', // 'wpbc-bi-download', ); $config = wp_parse_args( $config, $defaults ); $config['ajax_nonce_import_legacy_forms'] = wp_create_nonce( 'wpbc_bfb_import_legacy_forms' ); $config['ajax_action_import_legacy_forms'] = 'WPBC_AJX_BFB_IMPORT_LEGACY_FORMS'; // Build dropdown items: LOAD / IMPORT actions. $items = array( array( 'type' => 'header', 'title' => __( 'Restore or Replace Current Form', 'booking' ), ), array( 'type' => 'link', 'title' => __( 'Replace with Template', 'booking' ) . '...', 'url' => 'javascript:void(0);', 'attr' => array( 'onclick' => 'wpbc_bfb__menu_forms__apply_template(this);', 'data-wpbc-u-busy-text' => __( 'Applying', 'booking' ) . '...', 'title' => __( 'Replace the current form layout with a ready-made template.', 'booking' ), 'style' => 'font-weight:600;', ), ), // Reload last saved form from DB. array( 'type' => 'link', 'title' => __( 'Restore last saved version', 'booking' ), 'url' => 'javascript:void(0);', 'attr' => array( 'onclick' => 'wpbc_bfb__ajax_load_current_form(this);', 'data-wpbc-bfb-load-nonce' => $config['ajax_nonce_load'], 'data-wpbc-bfb-load-action' => $config['ajax_action_load'], 'data-wpbc-bfb-form-key' => $config['default_form_key'], 'data-wpbc-u-busy-text' => __( 'Loading', 'booking' ) . '...', 'title' => __( 'Discard unsaved changes and restore the last saved version of this form.', 'booking' ), ), ), array( 'type' => 'divider' ), array( 'type' => 'header', 'title' => __( 'Create, Open, and Save Forms', 'booking' ), ), array( 'type' => 'link', 'title' => __( 'Create New Form', 'booking' ) . '...', 'url' => 'javascript:void(0);', 'attr' => array( 'onclick' => 'wpbc_bfb__menu_forms__new(this);', 'data-wpbc-bfb-load-nonce' => $config['ajax_nonce_load'], 'data-wpbc-bfb-load-action' => $config['ajax_action_load'], 'data-wpbc-bfb-form-key' => $config['default_form_key'], 'data-wpbc-u-busy-text' => __( 'Loading', 'booking' ) . '...', 'title' => __( 'Create a new booking form.', 'booking' ), ), ), array( 'type' => 'link', 'title' => __( 'Open', 'booking' ) . ' ...', 'url' => 'javascript:void(0);', 'attr' => array( 'onclick' => 'wpbc_bfb__menu_forms__load(this);', 'data-wpbc-bfb-load-nonce' => $config['ajax_nonce_load'], 'data-wpbc-bfb-load-action' => $config['ajax_action_load'], 'data-wpbc-bfb-form-key' => $config['default_form_key'], 'data-wpbc-u-busy-text' => __( 'Loading', 'booking' ) . '...', 'title' => __( 'Open an existing saved booking form.', 'booking' ), ), ), array( 'type' => 'link', 'title' => __( 'Save', 'booking' ), 'url' => 'javascript:void(0);', 'attr' => array( 'onclick' => 'wpbc_bfb__ajax_save_current_form(this);', 'data-wpbc-bfb-load-nonce' => $config['ajax_nonce_load'], 'data-wpbc-bfb-load-action' => $config['ajax_action_load'], 'data-wpbc-bfb-form-key' => $config['default_form_key'], 'data-wpbc-u-busy-text' => __( 'Saving', 'booking' ) . '...', 'title' => __( 'Save changes to the current booking form.', 'booking' ), ), ), array( 'type' => 'link', 'title' => __( 'Save As', 'booking' ) . ' ...', 'url' => 'javascript:void(0);', 'attr' => array( 'onclick' => 'wpbc_bfb__menu_forms__save_as(this);', 'data-wpbc-bfb-load-nonce' => $config['ajax_nonce_load'], 'data-wpbc-bfb-load-action' => $config['ajax_action_load'], 'data-wpbc-bfb-form-key' => $config['default_form_key'], 'data-wpbc-u-busy-text' => __( 'Saving', 'booking' ) . '...', 'title' => __( 'Save a copy of this form with a new name.', 'booking' ), ), ), // array( 'type' => 'divider' ), // // Reload last saved form from DB. // array( // 'type' => 'link', // 'title' => __( 'Load Template Example', 'booking' ), // 'url' => 'javascript:void(0);', // 'attr' => array( // 'onclick' => 'var json_form_structure = wpbc_bfb__form_structure__get_example(); wpbc_bfb__on_structure_loaded( json_form_structure );', // 'data-wpbc-bfb-load-nonce' => $config['ajax_nonce_load'], // 'data-wpbc-bfb-load-action' => $config['ajax_action_load'], // 'data-wpbc-bfb-form-key' => $config['default_form_key'], // 'data-wpbc-u-busy-text' => __( 'Loading', 'booking' ) . '...', // 'title' => __( 'Discard current changes and load the last saved form structure from database.', 'booking' ), // ), // ), ); $items = wpbc_bfb__top_toolbar__dropdown_menu__main_forms__maybe_add_import_options( $items, $config ); $el_arr = array( 'title' => $config['dropdown_title'], 'font_icon' => $config['dropdown_font_icon'], 'position' => 'left', 'items' => $items, ); wpbc_ui_el__dropdown_menu( $el_arr ); } /** * Maybe Add Import Options to the Main "Form" menu in the top toolbar. * * @param array $items - already existed itmes for drop down menu. * * @return array|mixed */ function wpbc_bfb__top_toolbar__dropdown_menu__main_forms__maybe_add_import_options( $items = array(), $config = array() ) { $items[] = array( 'type' => 'divider' ); $items[] = array( 'type' => 'header', 'title' => __( 'Import Legacy Forms', 'booking' ), ); // ----------------------------------------------------------------------------------------------------------------- // == Import == // ----------------------------------------------------------------------------------------------------------------- // == Free Simple == - Import from Simple Form - Usually in - Free version. $items[] = array( 'type' => 'link', 'title' => __( 'Import from Simple Form', 'booking' ), 'url' => 'javascript:void(0);', 'attr' => array( 'onclick' => 'wpbc_bfb__import_from_simple_form(this);', 'data-wpbc-bfb-import-nonce' => $config['ajax_nonce_import'], 'data-wpbc-bfb-import-action' => $config['ajax_action_import'], 'data-wpbc-u-busy-text' => __( 'Importing', 'booking' ) . '...', 'title' => __( 'Import fields from the previous Simple Form into the Form Builder.', 'booking' ), ), ); // == Pro Advanced == - Import booking forms for == Super Booking Admin == user ( user_id = 0 ). if ( class_exists( 'wpdev_bk_personal' ) ) { $custom_forms_count = 0; if ( class_exists( 'wpdev_bk_biz_m' ) && ( ! empty( maybe_unserialize( get_bk_option( 'booking_forms_extended' ) ) ) ) ) { $custom_forms_count = maybe_unserialize( get_bk_option( 'booking_forms_extended' ) ); $custom_forms_count = count( $custom_forms_count ); } ++$custom_forms_count; $items[] = array( 'type' => 'link', /* translators: 1: number of custom booking forms. */ 'title' => sprintf( _n( 'Import %s Advanced Form', 'Import %s Advanced Forms', $custom_forms_count, 'booking' ), $custom_forms_count ), 'url' => 'javascript:void(0);', 'attr' => array( 'onclick' => 'wpbc_bfb__import_legacy_forms(this);', 'data-wpbc-bfb-import-nonce' => $config['ajax_nonce_import_legacy_forms'], 'data-wpbc-bfb-import-action' => $config['ajax_action_import_legacy_forms'], 'data-wpbc-bfb-import-mode' => 'all_global', 'data-wpbc-bfb-skip-if-exists' => 'overwrite', // 'skip' | 'overwrite'. Default - 'skip'. 'data-wpbc-bfb-set-form-not-defined' => 'not_defined', // 'not_defined' | ''. Default - 'not_defined'. 'data-wpbc-u-busy-text' => __( 'Importing', 'booking' ) . '...', 'title' => __( 'Import all global legacy booking forms into Form Builder storage.', 'booking' ), ), ); } // Import booking forms for == All Users ==. if ( class_exists( 'wpdev_bk_multiuser' ) ) { $is_user_super_admin = apply_bk_filter( 'is_user_super_admin', wpbc_get_current_user_id() ); if ( ! $is_user_super_admin ) { // Import booking forms only for the == Current User == (usually - "Regular User"). $items[] = array( 'type' => 'link', 'title' => __( 'Import Advanced Forms for Current User', 'booking' ), 'url' => 'javascript:void(0);', 'attr' => array( 'onclick' => 'wpbc_bfb__import_legacy_forms(this);', 'data-wpbc-bfb-import-nonce' => $config['ajax_nonce_import_legacy_forms'], 'data-wpbc-bfb-import-action' => $config['ajax_action_import_legacy_forms'], 'data-wpbc-bfb-import-mode' => 'current_context', 'data-wpbc-u-busy-text' => __( 'Importing', 'booking' ) . '...', 'title' => __( 'Import all existing Advanced Forms for the current user into the Form Builder.', 'booking' ), 'data-wpbc-bfb-skip-if-exists' => 'overwrite', // 'skip' | 'overwrite'. Default - 'skip'. 'data-wpbc-bfb-set-form-not-defined' => 'not_defined', // 'not_defined' | ''. Default - 'not_defined'. ), ); } if ( $is_user_super_admin ) { $items[] = array( 'type' => 'link', 'title' => __( 'Import Advanced Forms for All Users', 'booking' ), 'url' => 'javascript:void(0);', 'attr' => array( 'onclick' => 'wpbc_bfb__import_legacy_forms(this);', 'data-wpbc-bfb-import-nonce' => $config['ajax_nonce_import_legacy_forms'], 'data-wpbc-bfb-import-action' => $config['ajax_action_import_legacy_forms'], 'data-wpbc-bfb-import-mode' => 'all_users', 'data-wpbc-u-busy-text' => __( 'Importing', 'booking' ) . '...', 'title' => __( 'Import all existing Advanced Forms for all users into the Form Builder.', 'booking' ), // 'data-wpbc-bfb-skip-if-exists' => 'overwrite', // 'skip' | 'overwrite'. Default - 'skip'. // 'data-wpbc-bfb-set-form-not-defined' => 'not_defined', // 'not_defined' | ''. Default - 'not_defined'. ), ); } } // ----------------------------------------------------------------------------------------------------------------- return $items; } /** * Show Form Builder LOAD / IMPORT dropdown + define JS helpers. * * Hooked into: wpbc_ui_el__top_nav__content_center * * @param string $page_tag Current page tag. * @param string $active_page_tab Current tab. * @param string $active_page_subtab Current subtab. * * @return void */ function wpbc_bfb__top_toolbar__dropdown_menu__main_forms__show( $page_tag, $active_page_tab, $active_page_subtab ) { if ( ! wpbc_is_builder_booking_form_page() ) { return; } // === Common config ================================================================================================ $ajax_action_load = 'WPBC_AJX_BFB_LOAD_FORM_CONFIG'; $ajax_nonce_load = wp_create_nonce( 'wpbc_bfb_form_load' ); $ajax_action_import = 'wpbc_bfb_import_simple_form'; $ajax_nonce_import = wp_create_nonce( $ajax_action_import ); $default_form_key = 'default_booking_form'; wpbc_ui_el__divider_vertical( array( 'style' => 'width: 0.75px;' ) ); ?>
$ajax_action_load, 'ajax_nonce_load' => $ajax_nonce_load, 'ajax_action_import' => $ajax_action_import, 'ajax_nonce_import' => $ajax_nonce_import, 'default_form_key' => $default_form_key, ) ); ?>
:
...
...
:
'; $html .= sprintf( '%d %s ', absint( $column_number ), esc_html( $label ), esc_attr( $icon_class ) ); $html .= ''; return $html; } /** * Show fullscreen warning for mobile / small-screen usage of the Form Builder. * * The builder is optimized for desktop. This fullscreen overlay warns users on * small screens and lets them continue or close the notice. * * @return void */ function wpbc_bfb__ui__show_warning__no_mobile_mode() { ?>