__( 'Settings', 'booking-manager' ) // Title of TAB
, 'page_title' => __( 'Settings', 'booking-manager' ) // Title of Page
, 'hint' => __( 'Settings', 'booking-manager' ) // Hint
, 'link' => '' // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link
, 'position' => '' // 'left' || 'right' || ''
, 'css_classes' => '' // CSS class(es)
, 'icon' => '' // Icon - link to the real PNG img
, 'font_icon' => 'glyphicon glyphicon-menu-hamburger' // CSS definition of forn Icon
, 'default' => false // Is this tab activated by default or not: true || false.
, 'disabled' => false // Is this tab disbaled: true || false.
, 'hided' => false // Is this tab hided: true || false.
, 'subtabs' => array()
);
// $subtabs = array();
// $tabs[ 'items' ][ 'subtabs' ] = $subtabs;
$subtabs['listing'] = array(
'type' => 'subtab' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link' | 'html'
, 'title' => __('Listing Template' , 'booking-manager') // Title of TAB
, 'page_title' => __('Listing Template', 'booking-manager') // Title of Page
, 'hint' => __('Listing Template' , 'booking-manager') // Hint
, 'link' => '' // link
, 'position' => '' // 'left' || 'right' || ''
, 'css_classes' => '' // CSS class(es)
//, 'icon' => 'http://.../icon.png' // Icon - link to the real PNG img
//, 'font_icon' => 'glyphicon glyphicon-envelope' // CSS definition of Font Icon
, 'default' => !true // Is this sub tab activated by default or not: true || false.
, 'disabled' => false // Is this sub tab deactivated: true || false.
, 'checkbox' => false // or definition array for specific checkbox: array( 'checked' => true, 'name' => 'feature1_active_status' ) //, 'checkbox' => array( 'checked' => $is_checked, 'name' => 'enabled_active_status' )
, 'content' => 'content' // Function to load as conten of this TAB
);
$tabs[ 'wpbm-settings' ]['subtabs'] = $subtabs;
return $tabs;
}
public function content() {
if ( ! $this->can_manage_listing_template() ) {
wp_die(
esc_html__( 'Sorry, you are not allowed to manage the Booking Manager listing template.', 'booking-manager' )
, esc_html__( 'Forbidden', 'booking-manager' )
, array( 'response' => 403 )
);
}
do_action( 'wpbm_hook_settings_page_header', array( 'page' => $this->in_page() ) ); // Define Notices Section and show some static messages, if needed.
////////////////////////////////////////////////////////////////////////
// Submit /////////////////////////////////////////////////////////////
$submit_form_name = 'wpbm_form_listing'; // Define form name
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( 'wpbm_settings_page_' . $submit_form_name ); // Its stop show anything on submiting, if its not refear to the original page
// Save Changes
$this->update();
}
////////////////////////////////////////////////////////////////////////
// Get Data from DB ////////////////////////////////////////////////////
$data_list_tmpl = get_wpbm_option( 'wpbm_listing_template' );
//$data_list_tmpl = wpbm_nl_after_br( $data_list_tmpl );
////////////////////////////////////////////////////////////////////////
// Toolbar /////////////////////////////////////////////////////////////
wpbm_bs_toolbar_sub_html_container_start();
?>toolbar_reset_to_default(); // Reset to Default Forms
$save_button = array( 'title' => __('Save Changes', 'booking-manager'), 'form' => $submit_form_name );
$this->toolbar_save_button( $save_button ); // Save Button
?>
css();
$this->js();
do_action( 'wpbm_hook_settings_page_footer', 'listing_template' );
}
/** Save Chanages */
public function update() {
if ( ! $this->can_manage_listing_template() ) {
wp_die(
esc_html__( 'Sorry, you are not allowed to manage the Booking Manager listing template.', 'booking-manager' )
, esc_html__( 'Forbidden', 'booking-manager' )
, array( 'response' => 403 )
);
}
$data_list_tmpl = isset( $_POST['listing_template'] ) ? trim( wp_unslash( $_POST['listing_template'] ) ) : '';
$data_list_tmpl = wpbm_sanitize_listing_template( $data_list_tmpl );
update_wpbm_option( 'wpbm_listing_template' , $data_list_tmpl );
wpbm_show_changes_saved_message();
}
/**
* Listing template is a global frontend template, so managing it requires
* administrator-level options access rather than the general plugin menu role.
*
* @return bool
*/
private function can_manage_listing_template() {
return current_user_can( 'manage_options' );
}
//
/** CSS for this page */
private function css() {
?>
//
/** Show Save button in toolbar for saving form */
private function toolbar_save_button( $save_button ) {
?>
__('Select', 'booking-manager') . ' ' . __('Form Template', 'booking-manager')
, 'id' => ''
, 'name' => ''
, 'style' => 'font-weight: 400;border-bottom:1px dashed #ccc;'
, 'class' => ''
, 'disabled' => false
, 'selected' => false
, 'attr' => array()
);
$templates[ 'optgroup_sf_s' ] = array(
'optgroup' => true
, 'close' => false
, 'title' => ' ' . __('Standard Templates' ,'booking-manager')
);
$templates[ 'standard' ] = array(
'title' => __('Standard', 'booking-manager')
, 'id' => ''
, 'name' => ''
, 'style' => ''
, 'class' => ''
, 'disabled' => false
, 'selected' => false
, 'attr' => array()
);
/*
$templates[ '2collumns' ] = array(
'title' => '2 ' . __('Columns', 'booking-manager')
, 'id' => ''
, 'name' => ''
, 'style' => ''
, 'class' => ''
, 'disabled' => false
, 'selected' => false
, 'attr' => array()
);
*/
$templates[ 'optgroup_sf_e' ] = array( 'optgroup' => true, 'close' => true );
/*
$templates[ 'optgroup_af_s' ] = array(
'optgroup' => true
, 'close' => false
, 'title' => ' ' . __('Advanced Templates' ,'booking-manager')
);
$templates[ 'wizard' ] = array(
'title' => __('Wizard (several steps)', 'booking-manager')
, 'id' => ''
, 'name' => ''
, 'style' => ''
, 'class' => ''
, 'disabled' => false
, 'selected' => false
, 'attr' => array()
);
$templates[ 'optgroup_af_e' ] = array( 'optgroup' => true, 'close' => true );
*/
$params = array(
'label_for' => 'select_form_help_shortcode' // "For" parameter of label element
, 'label' => '' //__('Add New Field', 'booking-manager') // Label above the input group
, 'style' => '' // CSS Style of entire div element
, 'items' => array(
array(
'type' => 'addon'
, 'element' => 'text' // text | radio | checkbox
, 'text' => __('Reset Form', 'booking-manager') . ':'
, 'class' => '' // Any CSS class here
, 'style' => 'font-weight:600;' // CSS Style of entire div element
)
// Warning! Can be text or selectbox, not both OR you need to define width
, array(
'type' => 'select'
, 'id' => 'select_default_form_template'
, 'name' => 'select_default_form_template'
, 'style' => ''
, 'class' => ''
, 'multiple' => false
, 'disabled' => false
, 'disabled_options' => array() // If some options disbaled, then its must list here
, 'attr' => array() // Any additional attributes, if this radio | checkbox element
, 'options' => $templates // Associated array of titles and values
, 'value' => '' // Some Value from optins array that selected by default
, 'onfocus' => ''
//, 'onchange' => "wpbm_show_fields_generator( this.options[this.selectedIndex].value );"
)
)
);
?> 'min_cost' // "For" parameter of label element
, 'label' => '' //__('Add New Field', 'booking-manager') // Label above the input group
, 'style' => '' // CSS Style of entire div element
, 'items' => array(
array(
'type' => 'button'
, 'title' => __('Reset', 'booking-manager') // __('Reset', 'booking-manager')
, 'hint' => array( 'title' => __('Reset Form' ,'booking-manager') , 'position' => 'top' )
, 'class' => 'button tooltip_top'
, 'font_icon' => 'glyphicon glyphicon-repeat'
, 'icon_position' => 'right'
, 'action' => " var sel_res_val = document.getElementById('select_default_form_template').options[ document.getElementById('select_default_form_template').selectedIndex ].value;"
. " if ( sel_res_val == 'selector_hint') { "
. " wpbm_field_highlight( '#select_default_form_template' ); return;" //. " jQuery('#wpbm_form_field').trigger( 'submit' );"
. " }"
//. " if ( wpbm_are_you_sure('" . esc_js(__('Do you really want to do this ?' ,'booking-manager')) . "') ) {"
. " wpbm_reset_from_to_template( sel_res_val ); " //. " jQuery('#wpbm_form_field').trigger( 'submit' );"
//. " }"
)
)
);
?>
//
/** Show Booking Form - in Settings page */
private function show_listing_template( $data ) {
wp_editor( $data,
'listing_template',
array(
'wpautop' => false
, 'media_buttons' => false
, 'textarea_name' => 'listing_template'
, 'textarea_rows' => 10
, 'tinymce' => !false // Remove Visual Mode from the Editor
, 'default_editor' => 'html' // 'tinymce' | 'html' // 'html' is used for the "Text" editor tab.
, 'editor_class' => 'wpbm-textarea-tinymce' // Any extra CSS Classes to append to the Editor textarea
, 'teeny' => true // Whether to output the minimal editor configuration used in PressThis
, 'drag_drop_upload' => false // Enable Drag & Drop Upload Support (since WordPress 3.9)
)
);
//echo '';
?>
[DATES]' );
?>
[SUMMARY]' );
?>
[UID]' );
?>
[DESCRIPTION]' );
?>
[MODIFIED]' );
?>
[LOCATION]' );
?>
[BOOKING_ID]' );
?>
[BOOKING_LINK]' );
?>
' . __('Example' ,'booking-manager') . ':
';
echo '' . '<a href="[BOOKING_LINK]" target="_blank">[BOOKING_ID]</a>' . ''
?>
<br/>');?>
' . __('HTML' ,'booking-manager') . '. '
. sprintf(__('You can use any %sHTML tags%s in the booking form. Please use the HTML tags carefully. Be sure, that all "open" tags (like %s) are closed (like this %s).' ,'booking-manager')
,'',''
,'<div>'
,'</div>'
);
?>
';
}
//
}
add_action('wpbm_menu_created', array( new WPBM_Page_SettingsListing() , '__construct') ); // Executed after creation of Menu