function bos_ajax_preview() { if (isset($_REQUEST['nonce'])) { // Verify that the incoming request is coming with the security nonce if (wp_verify_nonce($_REQUEST['nonce'], 'bos_ajax_nonce')) { $arrayFields = bos_searchbox_settings_fields_array(); foreach ($arrayFields as $field) { if ($field[1] == 'text' || $field[1] == 'radio' || $field[1] == 'select') { $options[$field[0]] = isset($_REQUEST[$field[0]]) ? stripslashes(sanitize_text_field($_REQUEST[$field[0]])) : ''; } elseif ($field[1] == 'checkbox') { if ($field[0] == 'calendar') { $options[$field[0]] = empty($_REQUEST['calendar']) ? 0 : 1; } //if ( $field[ 0 ] == 'calendar' ) if ($field[0] == 'flexible_dates') { $options[$field[0]] = empty($_REQUEST['flexible_dates']) ? 0 : 1; } //if ( $field[ 0 ] == 'flexible_dates' ) } } //foreach( $arrayFields as $field) $preview = true; echo '<div id="bos_preview_title"><img src="' . BOS_IMG_PLUGIN_DIR . '/preview_title.png" alt="Preview" /></div>'; bos_create_searchbox($options, $preview); die; } else { die('There was an issue in the preview statement'); } } }
function widget($args, $instance) { extract($args); echo $before_widget; //retrieve all options stored in DB $options = bos_searchbox_retrieve_all_user_options(); if (empty($options)) { $options = bos_searchbox_retrieve_all_options(); } // if no user customization, then use the defaults value $preview = false; //This is the front-end searchbox bos_create_searchbox($options, $preview); echo $after_widget; }
function bos_searchbox_option_page() { // Include of checkin and checkout select ?> <div class="wrap"> <?php screen_icon(); ?> <h2><img src="<?php echo BOS_IMG_PLUGIN_DIR . '/booking_logotype_blue_150x25.png'; ?> " /></h2> <div class="updated"><p><?php _e('If you like you can customise Booking.com searchbox with the settings panel below, or you can just start using the default one in <strong>Appearance > Widgets</strong> section now.', BOS_TEXT_DOMAIN); ?> </p></div> <div id="bos_wrap" style="background: transparent url( <?php echo BOS_IMG_PLUGIN_DIR . '/sand.jpg'; ?> ) repeat-y 60% 0;"> <div id="bos_left"> <form action="options.php" method="post" id="bos_form"> <?php settings_fields('bos_searchbox_settings'); ?> <?php do_settings_sections('bos_searchbox'); ?> <p class="submit"> <input type="button" id="preview_button" class="button-primary" value="<?php _e('Preview', BOS_TEXT_DOMAIN); ?> " /> <input type="submit" class="button-primary" value="<?php _e('Save Changes', BOS_TEXT_DOMAIN); ?> " /> </p> </form> </div> <div id="bos_right"> <div id="bos_preview"> <div id="bos_preview_title"><img src="<?php echo BOS_IMG_PLUGIN_DIR . '/preview_title.png'; ?> " alt="Preview" /></div> <?php $options = bos_searchbox_retrieve_all_user_options(); if (empty($options)) { $options = bos_searchbox_retrieve_all_options(); } // if no user customization, then use the defaults value $preview = true; bos_create_searchbox($options, $preview); ?> </div> </div> <div class="clear"></div> </div> </div> <?php }