0){ $content_post = get_post(intval($_POST["bookingpage"])); if( strpos($content_post->post_content, 'abc-bookingform') !== false) { update_option ('abc_bookingformvalidated', 1); $output .= '&bookingform=validated'; }else{ update_option ('abc_bookingformvalidated', 0); $output .= '&bookingform=error'; } } update_option ('abc_emailcopy', intval($_POST["emailcopy"])); update_option ('abc_bookingpage', intval($_POST["bookingpage"])); update_option ('abc_dateformat', sanitize_text_field($_POST["dateformat"])); update_option ('abc_priceformat', sanitize_text_field($_POST["priceformat"])); update_option ('abc_currency', sanitize_text_field($_POST["currency"])); update_option ('abc_customCss', sanitize_text_field($_POST["customCss"])); update_option ('abc_currencyPosition', intval($_POST["currencyPosition"])); update_option ('abc_unconfirmed', sanitize_text_field($_POST["unconfirmed"])); update_option ('abc_cookies', sanitize_text_field($_POST["cookies"])); update_option ('abc_googleanalytics', intval($_POST["googleanalytics"])); update_option ('abc_poweredby', intval($_POST["poweredby"])); update_option ('abc_deletion', intval($_POST["deletion"])); update_option ('abc_accessLevel', sanitize_text_field($_POST["accessLevel"])); if(getAbcSetting("newsletter") == 0 && intval($_POST["newsletter"]) == 1){ subscribeAbcNewsletter(sanitize_email($_POST["email"]), 0); }elseif(getAbcSetting("newsletter") == 1 && intval($_POST["newsletter"]) == 0){ subscribeAbcNewsletter(sanitize_email($_POST["email"]), 1); } update_option ('abc_newsletter', intval($_POST["newsletter"])); if(getAbcSetting("usage") == 0 && intval($_POST["usage"]) == 1){ activate_commitUsage(); }elseif(getAbcSetting("usage") == 1 && intval($_POST["usage"]) == 0){ deactivate_commitUsage(); } update_option ('abc_usage', intval($_POST["usage"])); } wp_redirect( admin_url( "admin.php?page=advanced-booking-calendar-show-settings&setting=general".$output ) ); exit; } //==>editCalendarSettings() add_action( 'admin_post_abc_booking_editCalendarSettings', 'abc_booking_editCalendarSettings' ); //Edit booking form settings function abc_booking_editBookingFormSettings() { if ( !current_user_can( abc_booking_admin_capabilities() ) ) { wp_die("You don't have access to this page."); } if (isset($_POST["firstname"]) && isset($_POST["lastname"]) && isset($_POST["phone"]) && isset($_POST["street"]) && isset($_POST["zip"]) && isset($_POST["city"]) && isset($_POST["county"]) && isset($_POST["country"]) && isset($_POST["message"])) { $fieldCounter = 0; if(intval($_POST["firstname"]) > 0) {$fieldCounter++;} if(intval($_POST["lastname"]) > 0) {$fieldCounter++;} if(intval($_POST["phone"]) > 0) {$fieldCounter++;} if(intval($_POST["street"]) > 0) {$fieldCounter++;} if(intval($_POST["zip"]) > 0) {$fieldCounter++;} if(intval($_POST["city"]) > 0) {$fieldCounter++;} if(intval($_POST["county"]) > 0) {$fieldCounter++;} if(intval($_POST["country"]) > 0) {$fieldCounter++;} if(intval($_POST["message"]) > 0) {$fieldCounter++;} $options = array( 'firstname' => intval($_POST["firstname"]), 'lastname' => intval($_POST["lastname"]), 'phone' => intval($_POST["phone"]), 'street' => intval($_POST["street"]), 'zip' => intval($_POST["zip"]), 'city' => intval($_POST["city"]), 'county' => intval($_POST["county"]), 'country' => intval($_POST["country"]), 'message' => intval($_POST["message"]), 'optincheckbox' => intval($_POST["optincheckbox"]), 'inputs' => $fieldCounter ); update_option('abc_bookingform', $options); } wp_redirect( admin_url( "admin.php?page=advanced-booking-calendar-show-settings&setting=bookingform" ) ); exit; } //==>f() add_action( 'admin_post_abc_booking_editBookingFormSettings', 'abc_booking_editBookingFormSettings' ); //Edit email settings function abc_booking_editEmailSettings() { if ( !current_user_can( abc_booking_admin_capabilities() ) ) { wp_die("You don't have access to this page."); } if (isset($_POST["subjectunconfirmed"]) && isset($_POST["textunconfirmed"]) && isset($_POST["subjectconfirmed"]) && isset($_POST["textconfirmed"]) && isset($_POST["subjectcanceled"]) && isset($_POST["textcanceled"]) && isset($_POST["subjectrejected"]) && isset($_POST["textrejected"]) ) { update_option ('abc_subject_unconfirmed', sanitize_text_field($_POST["subjectunconfirmed"])); update_option ('abc_text_unconfirmed', implode( "\n", array_map( 'sanitize_text_field', explode( "\n", $_POST["textunconfirmed"] )))); update_option ('abc_subject_confirmed', sanitize_text_field($_POST["subjectconfirmed"])); update_option ('abc_text_confirmed', implode( "\n", array_map( 'sanitize_text_field', explode( "\n", $_POST["textconfirmed"] )))); update_option ('abc_subject_canceled', sanitize_text_field($_POST["subjectcanceled"])); update_option ('abc_text_canceled', implode( "\n", array_map( 'sanitize_text_field', explode( "\n", $_POST["textcanceled"] )))); update_option ('abc_subject_rejected', sanitize_text_field($_POST["subjectrejected"])); update_option ('abc_text_rejected', implode( "\n", array_map( 'sanitize_text_field', explode( "\n", $_POST["textrejected"] )))); } wp_redirect( admin_url( "admin.php?page=advanced-booking-calendar-show-settings&setting=email" ) ); exit; } //==>editEmailSettings() add_action( 'admin_post_abc_booking_editEmailSettings', 'abc_booking_editEmailSettings' ); //Edit Payment Settings function abc_booking_editTextCustomization() { if ( !current_user_can( abc_booking_admin_capabilities() ) ) { wp_die("You don't have access to this page."); } if (isset($_POST["textCheckAvailabilities"]) && isset($_POST["abcLanguage"]) && isset($_POST["textSelectRoom"])) { $locale = ''; if(empty($_POST["abcLanguage"])){ $locale = 'en_US'; }else{ $locale = sanitize_text_field($_POST["abcLanguage"]); } $previosCustomization = array(); if(get_option( 'abc_textCustomization') != false){ $previousCustomization = unserialize(get_option( 'abc_textCustomization')); } $previousCustomization[$locale] = array( 'checkAvailabilities' => sanitize_text_field($_POST["textCheckAvailabilities"]), 'selectRoom' => sanitize_text_field($_POST["textSelectRoom"]), 'selectedRoom' => sanitize_text_field($_POST["textSelectedRoom"]), 'otherRooms' => sanitize_text_field($_POST["textOtherRooms"]), 'noRoom' => sanitize_text_field($_POST["textNoRoom"]), 'availRooms' => sanitize_text_field($_POST["textAvailRooms"]), 'roomType' => sanitize_text_field($_POST["textRoomType"]), 'yourStay' => sanitize_text_field($_POST["textYourStay"]), 'checkin' => sanitize_text_field($_POST["textCheckin"]), 'checkout' => sanitize_text_field($_POST["textCheckout"]), 'bookNow' => sanitize_text_field($_POST["textBookNow"]), 'thankYou' => sanitize_text_field($_POST["textThankYou"]), 'roomPrice' => sanitize_text_field($_POST["textRoomPrice"]), 'optin' => sanitize_text_field($_POST["textOptin"]) ); update_option( 'abc_textCustomization', serialize($previousCustomization)); } exit; }//==>abc_booking_editTextCustomization() //Edit Text Customization function ajax_abc_booking_editTextCustomization() { if(!isset( $_POST['abc_settings_nonce'] ) || !wp_verify_nonce($_POST['abc_settings_nonce'], 'abc-settings-nonce') ){ die('Permissions check failed!'); } echo abc_booking_editTextCustomization($_POST); die(); } add_action('wp_ajax_abc_booking_editTextCustomization', 'ajax_abc_booking_editTextCustomization'); function ajax_abc_booking_getTextCustomization(){ if(!isset( $_POST['abc_settings_nonce'] ) || !wp_verify_nonce($_POST['abc_settings_nonce'], 'abc-settings-nonce') ){ die('Permissions check failed!'); } $locale = ''; if(empty($_POST['abcLanguage'])){ $locale = 'en_US'; }else{ $locale = sanitize_text_field($_POST['abcLanguage']); } $textCustomization = array( 'checkAvailabilities' => '', 'selectRoom' => '', 'selectedRoom' => '', 'otherRooms' => '', 'noRoom' => '', 'availRooms' => '', 'roomType' => '', 'yourStay' => '', 'checkin' => '', 'checkout' => '', 'bookNow' => '', 'thankYou' => '', 'roomPrice' => '', 'optin' => '' ); if(get_option('abc_textCustomization') != false){ $textCustomization = unserialize(get_option('abc_textCustomization')); if(isset($textCustomization[$locale])){ $textCustomization = $textCustomization[$locale]; } } echo json_encode($textCustomization); die(); } add_action('wp_ajax_abc_booking_getTextCustomization', 'ajax_abc_booking_getTextCustomization'); function abc_booking_editPaymentSettings() { if ( !current_user_can( abc_booking_admin_capabilities() ) ) { wp_die("You don't have access to this page."); } //cash if (isset($_POST["activateCash"])) { if(empty($_POST["textCash"])) { wp_redirect( admin_url( "admin.php?page=advanced-booking-calendar-show-settings&setting=paymentSettingsError&type=Cash" ) ); exit; } } //on invoice if (isset($_POST["activateOnInvoice"])) { if(empty($_POST["textOnInvoice"])) { wp_redirect( admin_url( "admin.php?page=advanced-booking-calendar-show-settings&setting=paymentSettingsError&type=OnInvoice" ) ); exit; } } $paymentString = ''; if (isset($_POST["activateCash"])) { $cash = "true"; if(strlen($paymentString) > 0){ $paymentString .= ','; } $paymentString .= 'Cash'; } else { $cash = "false"; } if (isset($_POST["activateOnInvoice"])) { $onInvoice = "true"; if(strlen($paymentString) > 0){ $paymentString .= ','; } $paymentString .= 'Invoice'; } else { $onInvoice = "false"; } update_option('abc_paymentString', $paymentString); update_option( 'abc_paymentSettings', serialize( array( 'cash' => array('activate' => $cash, 'text' => sanitize_text_field($_POST["textCash"])), 'onInvoice' => array('activate' => $onInvoice, 'text' => sanitize_text_field($_POST["textOnInvoice"])) ))); wp_redirect( admin_url( "admin.php?page=advanced-booking-calendar-show-settings&setting=paymentSettings" ) ); exit; }//==>abc_booking_editPaymentSettings() add_action( 'admin_post_abc_booking_editPaymentSettings', 'abc_booking_editPaymentSettings' ); // Export database tables to JSON function abc_booking_exportTables() { if(isset( $_GET['abc_booking_exportTables'])){ if (!current_user_can(abc_booking_admin_capabilities())) { wp_die("You don't have access to this page."); } global $wpdb; $response = array(); $response['settings'] = array( 'abc_pluginversion' => get_option('abc_pluginversion'), 'abc_email' => get_option('abc_email'), 'abc_dateformat' => get_option('abc_dateformat'), 'abc_priceformat' => get_option('abc_priceformat'), 'abc_currency' => get_option('abc_currency'), 'abc_currencyPosition' => get_option('abc_currencyPosition'), 'blogname' => get_option('blogname') ); $tables = array( 'bookings', 'booking_extras', 'calendars', 'rooms', 'seasons', 'seasons_assignment' ); foreach($tables as $table){ $er = $wpdb->get_results('SELECT * FROM '.$wpdb->prefix.'abc_'.$table.' ORDER BY id', ARRAY_A); $results = array(); foreach($er as $row) { $results[] = $row; } $response[$table] = $results; } header("Content-type: text/plain"); header("Content-Disposition: attachment; filename=ABC_Export.json"); echo json_encode($response); exit; } } //==>exportTable add_action( 'plugins_loaded', 'abc_booking_exportTables' ); //Backend output: function advanced_booking_calendar_show_settings() { global $abcUrl; wp_enqueue_script('uikit-js', $abcUrl.'backend/js/uikit.min.js', array('jquery')); wp_enqueue_style('uikit', $abcUrl.'/frontend/css/uikit.gradient.min.css'); //Preparing Date vars (saved format is selected) $date1 = ""; $date2 = ""; $date3 = ""; $date4 = ""; if(getAbcSetting("dateformat") == "Y-m-d") { $date1 = 'selected'; } elseif(getAbcSetting("dateformat") == "d.m.Y") { $date2 = 'selected'; } elseif(getAbcSetting("dateformat") == "d/m/Y") { $date3 = 'selected'; } elseif(getAbcSetting("dateformat") == "m/d/Y") { $date4 = 'selected'; } //Price Format $emailcopytrue = ""; $emailcopyfalse = ""; $priceComma = ""; $priceDot = ""; $currencyPositionBefore = ""; $currencyPositionAfter = ""; $newslettertrue = ""; $newsletterfalse = ""; $unconfirmedtrue = ""; $unconfirmedfalse = ""; $cookiestrue = ""; $cookiesfalse = ""; $gatrue = ""; $gafalse = ""; $poweredbytrue = ""; $poweredbyfalse = ""; $deletiontrue = ""; $deletionfalse = ""; $usagetrue = ""; $usagefalse = ""; $firstdayofweekSunday = ""; $firstdayofweekMonday = ""; if(getAbcSetting("emailcopy") == "0") { $emailcopyfalse= 'checked'; } elseif(getAbcSetting("emailcopy") == "1") { $emailcopytrue= 'checked'; } if(getAbcSetting("priceformat") == ",") { $priceComma = 'selected'; } elseif(getAbcSetting("priceformat") == ".") { $priceDot = 'selected'; } if(getAbcSetting("currencyPosition") == 0) { $currencyPositionBefore = 'checked'; } elseif(getAbcSetting("currencyPosition") == 1) { $currencyPositionAfter = 'checked'; } if(getAbcSetting("newsletter") == "1") { $newslettertrue = 'checked'; } elseif(getAbcSetting("newsletter") == "0") { $newsletterfalse = 'checked'; } if(getAbcSetting("cookies") == "1") { $cookiestrue = 'checked'; } elseif(getAbcSetting("cookies") == "0") { $cookiesfalse = 'checked'; } if(getAbcSetting("unconfirmed") == "1") { $unconfirmedtrue = 'checked'; } elseif(getAbcSetting("unconfirmed") == "0") { $unconfirmedfalse = 'checked'; } if(getAbcSetting("googleanalytics") == "1") { $gatrue = 'checked'; } elseif(getAbcSetting("googleanalytics") == "0") { $gafalse = 'checked'; } if(getAbcSetting("poweredby") == "1") { $poweredbytrue = 'checked'; } elseif(getAbcSetting("poweredby") == "0") { $poweredbyfalse = 'checked'; } if(getAbcSetting("deletion") == "1") { $deletiontrue = 'checked'; } elseif(getAbcSetting("deletion") == "0") { $deletionfalse = 'checked'; } if(getAbcSetting("usage") == "1") { $usagetrue = 'checked'; } elseif(getAbcSetting("usage") == "0") { $usagefalse = 'checked'; } if(getAbcSetting("firstdayofweek") == "0") { $firstdayofweekSunday = 'checked'; } elseif(getAbcSetting("firstdayofweek") == "1") { $firstdayofweekMonday = 'checked'; } $accessLevel = getAbcSetting("accessLevel"); $accessLevelHtml = ''; foreach( abc_booking_admin_capabilities(true) as $k => $v){ $accessLevelHtml .= sprintf('',$k,(($accessLevel===$k) ? 'selected="selected"':''),translate_user_role($k)); } $bookingVarArray = abc_booking_getBookingVars(); $placeholderList = ''; $numItems = count($bookingVarArray); $i = 0; foreach ($bookingVarArray as $bookingVars){ $placeholderList .= '['.$bookingVars.']'; if(++$i === $numItems) { $placeholderList .= '.'; } else { $placeholderList .= ', '; } } $bookingForm = getAbcSetting("bookingform"); $firstname = array('', '', ''); $lastname = array('', '', ''); $phone = array('', '', ''); $street = array('', '', ''); $zip = array('', '', ''); $county = array('', '', ''); $city = array('', '', ''); $country = array('', '', ''); $message = array('', '', ''); $optincheckbox = array('', '', ''); switch ($bookingForm["firstname"]) { case '0':$firstname[0] = ' checked';break; case '1':$firstname[1] = ' checked';break; case '2':$firstname[2] = ' checked';break; } switch ($bookingForm["lastname"]) { case '0':$lastname[0] = ' checked';break; case '1':$lastname[1] = ' checked';break; case '2':$lastname[2] = ' checked';break; } switch ($bookingForm["phone"]) { case '0':$phone[0] = ' checked';break; case '1':$phone[1] = ' checked';break; case '2':$phone[2] = ' checked';break; } switch ($bookingForm["street"]) { case '0':$street[0] = ' checked';break; case '1':$street[1] = ' checked';break; case '2':$street[2] = ' checked';break; } switch ($bookingForm["zip"]) { case '0':$zip[0] = ' checked';break; case '1':$zip[1] = ' checked';break; case '2':$zip[2] = ' checked';break; } switch ($bookingForm["county"]) { case '0':$county[0] = ' checked';break; case '1':$county[1] = ' checked';break; case '2':$county[2] = ' checked';break; } switch ($bookingForm["city"]) { case '0':$city[0] = ' checked';break; case '1':$city[1] = ' checked';break; case '2':$city[2] = ' checked';break; } switch ($bookingForm["country"]) { case '0':$country[0] = ' checked';break; case '1':$country[1] = ' checked';break; case '2':$country[2] = ' checked';break; } switch ($bookingForm["message"]) { case '0':$message[0] = ' checked';break; case '1':$message[1] = ' checked';break; case '2':$message[2] = ' checked';break; } switch ($bookingForm["optincheckbox"]) { case '0':$optincheckbox[0] = ' checked';break; case '1':$optincheckbox[1] = ' checked';break; case '2':$optincheckbox[2] = ' checked';break; } $settingsMessage = ''; if ( isset($_GET["setting"]) ) { switch ($_GET["setting"]) { case 'email': $settingsMessage .= '
'.__('Email settings have been saved.', 'advanced-booking-calendar').'
'.__('General settings have been saved.', 'advanced-booking-calendar').'
'; if(isset($_GET["bookingform"]) && $_GET["bookingform"] == "error" ){ $settingsMessage .= ''.__('Warning! The page you selected does not contain the booking form shortcode. Please add the shortcode [abc-bookingform] or some functions may not work properly.', 'advanced-booking-calendar').'
'; }elseif(isset($_GET["bookingform"]) && $_GET["bookingform"] == "validated" ){ $settingsMessage .= ''.__('Great! The page you selected contains the booking form shortcode.', 'advanced-booking-calendar').'
'; } $settingsMessage .= ''.__('Booking form settings have been saved. Please make sure to update the email templates as well.', 'advanced-booking-calendar').'
'.__('New text labels have been saved.', 'advanced-booking-calendar').'
'.__('Payment Settings have been saved.', 'advanced-booking-calendar').'
'.__('Error while saving Payment Settings. Please fill out all required fields for', 'advanced-booking-calendar').' '.$type.'.
'.__('Unable to activate the selected Payment Gateway. The selected Booking Form Page is invalid.', 'advanced-booking-calendar').'
'.__('License was successfully activated.', 'advanced-booking-calendar').'
'.urldecode($_GET["message"]).'
'.__('Want to add a custom input in your booking form? Our Pro-Version lets you add three additional inputs!', 'advanced-booking-calendar').'
'.__('Use discount code BASICUPGRADE to save 10€.', 'advanced-booking-calendar').'
'.__('You can use the following placeholder in both subject and text. They will be replaced with the actual content when the email is send to the guest:', 'advanced-booking-calendar').'
'.$placeholderList.'