Settings > (Sync) Import page * @category Settings API * @author wpdevelop * * @web-site https://wpbookingcalendar.com/ * @email info@wpbookingcalendar.com * @modified 2017-07-09 * * This is COMMERCIAL SCRIPT * We are not guarantee correct work and support of Booking Calendar, if some file(s) was modified by someone else then wpdevelop. */ if ( ! defined( 'ABSPATH' ) ) { exit; } // Exit if accessed directly /** * Show Content * Update Content * Define Slug * Define where to show */ class WPBC_Page_SettingsImportFeeds extends WPBC_Page_Structure { // public $settings_api = false; public function in_page() { return 'wpbc-settings'; } public function tabs() { $tabs = array(); $tabs[ 'sync' ] = array( 'title' => __( 'Sync', 'booking') // Title of TAB , 'page_title'=> __( 'Sync', 'booking') // Title of Page , 'hint' => __('Import' ,'booking') . ' / ' . __('Export' ,'booking') //, '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' => 'wpbc_icn_sync_alt' // 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(); $subtabs[ 'import' ] = array( 'type' => 'subtab' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link' | 'html' , 'title' => __('Import' ,'booking') . ' - .ics' // Title of TAB , 'page_title' => __('Import Bookings via .ics' ,'booking') //. ' Beta' // Title of Page , 'hint' => __('Set up and configure the import of events using .ics feeds.' ,'booking') // Hint , 'link' => '' // link , 'position' => '' // 'left' || 'right' || '' , 'css_classes' => '' // CSS class(es) //, 'icon' => 'http://.../icon.png' // Icon - link to the real PNG img , 'font_icon' => 'wpbc-bi-box-arrow-in-down-right' , 'default' => false // Is this sub tab activated by default or not: true || false. // FixIn: 8.1.1.10. , '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[ 'sync' ]['subtabs'] = $subtabs; return $tabs; } /** Show Content of Settings page */ public function content() { $this->css(); //////////////////////////////////////////////////////////////////////// // Checking //////////////////////////////////////////////////////////////////////// do_action( 'wpbc_hook_settings_page_header', 'ics_import_settings'); // Define Notices Section and show some static messages, if needed 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. //////////////////////////////////////////////////////////////////////// // Load Data //////////////////////////////////////////////////////////////////////// //$booking_gcal_events_form_fields = get_bk_option( 'booking_gcal_events_form_fields'); //$booking_gcal_events_form_fields = maybe_unserialize( $booking_gcal_events_form_fields ); //////////////////////////////////////////////////////////////////////// // S u b m i t Main Form //////////////////////////////////////////////////////////////////////// $submit_form_name = 'wpbc_ics_import'; // Define form name //$this->get_api()->validated_form_id = $submit_form_name; // Define ID of Form for ability to validate fields (like required field) before submit. // 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 submiting, if its not refear to the original page // Save Changes $this->update(); } //////////////////////////////////////////////////////////////////////// // JavaScript: Tooltips, Popover, Datepick (js & css) //////////////////////////////////////////////////////////////////////// echo ''; wpbc_js_for_bookings_page(); echo ''; ?>
' . 'Booking Manager' . ' ' . ' ' . esc_html( $wpbm_minimum_version ) . ' (' . esc_html__( 'or newer', 'booking' ) . ') ' , '' . 'Booking Manager' . '' , '' , '' ) ); ?>
show_toolbar_import_fields(); wpbc_close_meta_box_section(); wpbc_open_meta_box_section( 'wpbc_settings_ics_import_help_info', __('Help', 'booking') ); wpbc_ics_import_export__show_help_info(); wpbc_close_meta_box_section(); ?>
enqueue_js(); wpbc_ics_import_ajax_js(); } /** Save Chanages */ public function update() { //debuge($_POST); // Get Validated Email fields // $validated_fields = $this->get_api()->validate_post(); // $validated_fields = apply_filters( 'wpbc_fields_before_saving_to_db__ics_import', $validated_fields ); //Hook for validated fields. //debuge($validated_fields); //$this->get_api()->save_to_db( $validated_fields ); // wpbc_show_changes_saved_message(); // Old way of saving: // update_bk_option( 'booking_cache_expiration' , WPBC_Settings_API::validate_text_post_static( 'booking_cache_expiration' ) ); } // /** CSS for this page */ private function css() { ?> /** Show Toolbar with import fields */ function show_toolbar_import_fields() { // Parameters for Ajax: ?>
set_upload_button( '.wpbc_upload_btn' ); $wpbm_upload->set_element_insert_url( '.wpbc_import_url' ); } ?>
Settings > Sync pages * * @param bool $is_import */ function wpbc_ics_import_export__show_help_info( $is_import = true ) { ?>

.ics', 'iCalendar' ), $message_ics ); echo wp_kses_post( $message_ics ); ?>

Airbnb, ' . 'Booking.com, ' . 'TripAdvisor, ' . 'VRBO, ' . 'FlipKey ' . 'HomeAway, ' . str_replace( array( '.ics', 'iCalendar' ), array( '.ics', 'iCalendar' ), __( 'and any other calendar that uses .ics format', 'booking' ) ) . '.
' ); $message_ics = str_replace( array( '.ics', 'iCalendar' ), array( '.ics', 'iCalendar' ), $message_ics ); echo wp_kses_post( $message_ics ); ?>

' /* '
(Airbnb, ' . 'Booking.com, ' . 'HomeAway, ' . 'TripAdvisor, ' . 'VRBO, ' . 'FlipKey ' . str_replace( array( '.ics', 'iCalendar' ), array( '.ics', 'iCalendar' ), __( 'and any other calendar that uses .ics format', 'booking' ) ) . ').
' */ ); $message_ics = str_replace( array( '.ics', 'iCalendar' ), array( '.ics', 'iCalendar' ), $message_ics ); echo wp_kses_post( $message_ics ); ?>

.ics', 'iCalendar' ), $message_ics ); echo wp_kses_post( $message_ics ); ?>

' /* '
(Airbnb, ' . 'Booking.com, ' . 'HomeAway, ' . 'TripAdvisor, ' . 'VRBO, ' . 'FlipKey ' . str_replace( array( '.ics', 'iCalendar' ), array( '.ics', 'iCalendar' ), __( 'and any other calendar that uses .ics format', 'booking' ) ) . ').
' */ ); $message_ics = str_replace( array( '.ics', 'iCalendar' , 'CRON'), array( '.ics', 'iCalendar' , 'CRON' ), $message_ics ); echo wp_kses_post( $message_ics ); ?>

.ics', 'iCalendar' ), $message_ics ); echo wp_kses_post( $message_ics ); ?>

  1. Booking Manager' ) ); ?>
  2. [booking-manager-import ...]' , '' , '' ) ); ?>.
    ' ); $message_ics = str_replace( array( '.ics', 'CRON' ), array( '.ics', 'CRON' ), $message_ics ); echo wp_kses_post( $message_ics ); ?>
    .ics', 'iCalendar' ), $message_ics ); echo wp_kses_post( $message_ics ); ?>
  3. Booking Manager [booking-manager-import ...]' ); $message_ics = str_replace( array( '.ics', 'CRON' ), array( '.ics', 'CRON' ), $message_ics ); echo wp_kses_post( $message_ics ); ?>

.ics', 'iCalendar' ), $message_ics ); echo wp_kses_post( $message_ics ); ?>

  1. Booking Manager' ) ); echo ' '; /* translators: 1: URL of Booking Manager plugin page.*/ echo wp_kses_post( sprintf( __( 'WordPress directory %s page.', 'booking' ), 'Booking Manager' ) ); ?>
  2. '); $message_ics = str_replace( array( '.ics', 'iCalendar' ), array( '.ics', 'iCalendar' ), $message_ics ); echo wp_kses_post( $message_ics ); ?>
  3. .ics', 'iCalendar' ), $message_ics ); echo wp_kses_post( $message_ics ); ?>
'admin' ?> Settings > Sync > "Import - .ics" page -> Section "Import", so no need to check this if ( wpbc_is_use_nonce_at_front_end() ) { ... } $result = check_ajax_referer( $action_nonce_name, $nonce_post_key ); // Check Security $is_show_debug_info = ( ( get_bk_option( 'booking_is_show_system_debug_log' ) == 'On' ) ? true : false ); if ( $is_show_debug_info ) add_action( 'wpbc_show_debug', 'wpbc_start_showing_debug', 10, 1 ); ////////////////////////////////////////////////////////////////////// // Import events from .ics feed to specific booking resource ////////////////////////////////////////////////////////////////////// // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound do_action( 'wpbm_ics_import_start', array( 'url' => esc_url_raw( $_POST['params']['wpbc_import_url'] ), // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash 'resource_id' => intval( $_POST['params']['wpbc_import_br_selection'] ), // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated 'import_conditions' => '', // Check dates availability and process only if dates available in specific booking resource! ) ); if ( $is_show_debug_info ) remove_action( 'wpbc_show_debug', 'wpbc_start_showing_debug', 10 ); /* if ( $is_show_debug_info ) { // Showingdebug log section ?> 'success' ) ); // Return JS OBJ: response_data = { response: "success" } wp_die( '', '', array( 'response' => null ) ); }