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_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_currencyPosition', intval($_POST["currencyPosition"])); 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"])); 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( 'manage_options' ) ) { wp_die("Go away"); } 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"]), '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( 'manage_options' ) ) { wp_die("Go away"); } 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( 'manage_options' ) ) { wp_die("Go away"); } if (isset($_POST["textCheckAvailabilities"]) && isset($_POST["textSelectRoom"])) { update_option( 'abc_textCustomization', serialize( 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"]) ))); wp_redirect( admin_url( "admin.php?page=advanced-booking-calendar-show-settings&setting=textCustomization" ) ); }else{ wp_redirect( admin_url( "admin.php?page=advanced-booking-calendar-show-settings&setting=textCustomizationError" ) ); } exit; }//==>abc_booking_editPaymentSettings() add_action( 'admin_post_abc_booking_editTextCustomization', 'abc_booking_editTextCustomization' ); //Edit Text Customization function abc_booking_editPaymentSettings() { if ( !current_user_can( 'manage_options' ) ) { wp_die("Go away"); } //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' ); //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 $priceComma = ""; $priceDot = ""; $currencyPositionBefore = ""; $currencyPositionAfter = ""; $newslettertrue = ""; $newsletterfalse = ""; $cookiestrue = ""; $cookiesfalse = ""; $gatrue = ""; $gafalse = ""; $poweredbytrue = ""; $poweredbyfalse = ""; $deletiontrue = ""; $deletionfalse = ""; $usagetrue = ""; $usagefalse = ""; $firstdayofweekSunday = ""; $firstdayofweekMonday = ""; 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("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'; } $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('', '', ''); 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; } $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"]).'
'.__('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.'