arcRes_BookingWidget_option_iconmap = get_option("arcRes_BookingWidget_option_iconmap", "100000"); $this->arcRes_BookingWidget_option_layout = get_option( "arcRes_BookingWidget_option_layout", "vertical" ); $this->arcRes_BookingWidget_option_arcResReferralOnly = get_option( "arcRes_BookingWidget_option_arcResReferralOnly", "0" ); $this->arcRes_BookingWidget_option_cookieType = get_option( "arcRes_BookingWidget_option_cookieType", "permanent"); // includes the javascript code in the header add_action('wp_head', array( &$this, 'arcRes_addJSHeader' )); // add the stylesheet $this->arcRes_addStylesheet(); // includes the admin menu for the plugin add_action('admin_menu', array( &$this, 'arcRes_menu' ) ); } public function arcRes_addJSHeader(){ if ($this->arcRes_BookingWidget_option_arcResReferralOnly == 0){ $this->arcRes_includeHeaderCode(); } elseif($this->arcRes_BookingWidget_option_cookieType === 'temporary'){ if(array_key_exists("axsesReferrer",$_GET)) $_SESSION['axsesReferrer'] = $_GET['axsesReferrer']; if (isset($_SESSION['axsesReferrer'])) $this->arcRes_includeHeaderCode(); } else{ if(array_key_exists("axsesReferrer",$_GET)) setcookie("axsesReferrer","1",time()+(60*60*24*365), SITECOOKIEPATH, COOKIE_DOMAIN, false, true); if(isset($_COOKIE['axsesReferrer']) || array_key_exists("axsesReferrer",$_GET)) $this->arcRes_includeHeaderCode(); } } private function arcRes_addStylesheet(){ // set the stylesheet based on the plugin options if (strcasecmp($this->arcRes_BookingWidget_option_layout,"horizontal") == 0) $stylesheet = "arcResBookingWidget-horizontal.css"; else $stylesheet = "arcResBookingWidget-vertical.css"; $stylesheetURL = site_url().'/wp-content/plugins/arcResBookingWidget/css/'.$stylesheet; wp_register_style('arcResStylesheet', $stylesheetURL); wp_enqueue_style( 'arcResStylesheet'); } private function arcRes_includeHeaderCode(){ // include the booking widget javascript code echo ' '; } public function arcRes_showBookingWidget(){ if ($this->arcRes_BookingWidget_option_arcResReferralOnly == 1){ $this->arcRes_DetermineWidget(); } else { $this->arcRes_displayBookingWidget(); } } private function arcRes_displayBookingWidget(){ echo ''; } private function arcRes_DetermineWidget(){ if (strcasecmp($this->arcRes_BookingWidget_option_cookieType,"temporary") == 0){ $this->arcRes_DetermineWidgetTemporary(); } else{ $this->arcRes_DetermineWidgetPermanent(); } } private function arcRes_DetermineWidgetTemporary(){ /** * This function uses SESSION variables to temporarily store the axsesReferrer variable. * Since it is a SESSION variable it is destroyed once the browser is closed. * Returning visitors are therefore shown the alternative booking engine. * To always show returning visitors the arcRes Booking Widget, set Visitors to Permanent in the plugin settings (found in the Settings > arcRes Booking Widget in WP Admin) */ if (isset($_SESSION['axsesReferrer'])) $this->arcRes_displayBookingWidget(); else $this->arcRes_alternativeBookingEngine(); } private function arcRes_DetermineWidgetPermanent(){ /** * This function uses COOKIES to permanently store the axsesReferrer variable. * Since it is a COOKIE variable it persists after the browser is closed. * Returning visitors are therefore shown the arcRes Booking Widget. * To show returning visitors the alternative booking engine, set Visitors to Temporary in the plugin settings (found in the Settings > arcRes Booking Widget in WP Admin) */ if(isset($_COOKIE['axsesReferrer']) || array_key_exists("axsesReferrer",$_GET)) $this->arcRes_displayBookingWidget(); else $this->arcRes_alternativeBookingEngine(); } private function arcRes_alternativeBookingEngine(){ /***** Place the code for the alternative BookingEngine here *****/ echo 'The alternative booking engine will appear here.'; } /*** Backend Functions ***/ function arcRes_menu(){ add_options_page('arcRes Booking Widget Options', 'arcRes Booking Widget', 'manage_options', 'arcRes-BookingWidget-options', array( &$this, 'arcRes_BookingWidget_options' )); } function arcRes_BookingWidget_options() { if (!current_user_can('manage_options')) { wp_die( __('You do not have sufficient permissions to access this page.') ); } $optionsUpdated = false; if( isset($_POST["formAction"]) && $_POST["formAction"] == 'Y' ) { // update the options update_option("arcRes_BookingWidget_option_iconmap",$_POST["arcRes_BookingWidget_option_iconmap"]); update_option("arcRes_BookingWidget_option_layout",$_POST["arcRes_BookingWidget_option_layout"]); update_option("arcRes_BookingWidget_option_arcResReferralOnly",$_POST["arcRes_BookingWidget_option_arcResReferralOnly"]); update_option("arcRes_BookingWidget_option_cookieType",$_POST["arcRes_BookingWidget_option_cookieType"]); // reset the object properties $this->arcRes_BookingWidget_option_iconmap = $_POST["arcRes_BookingWidget_option_iconmap"]; $this->arcRes_BookingWidget_option_layout = $_POST["arcRes_BookingWidget_option_layout"]; $this->arcRes_BookingWidget_option_arcResReferralOnly = $_POST["arcRes_BookingWidget_option_arcResReferralOnly"]; $this->arcRes_BookingWidget_option_cookieType = $_POST["arcRes_BookingWidget_option_cookieType"]; $optionsUpdated = true; } ?>