'sm_search_widget', 'description' => __( "Adds a customizable search widget to your site" ) ); $this->WP_Widget('sm_search_widget', __('SimpleMap Search'), $widget_ops); } function widget( $args, $instance ) { global $simple_map, $wp_rewrite; extract( $args ); $options = $simple_map->get_options(); $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'] ); // Search Form Options $show_address = $instance['show_address'] ? 1 : 0; $show_city = $instance['show_city'] ? 1 : 0; $show_state = $instance['show_state'] ? 1 : 0; $show_zip = $instance['show_zip'] ? 1 : 0; $show_distance = $instance['show_distance'] ? 1 : 0; $default_lat = $instance['default_lat'] ? $instance['default_lat'] : 0; $default_lng = $instance['default_lng'] ? $instance['default_lng'] : 0; $simplemap_page = $instance['simplemap_page'] ? $instance['simplemap_page'] : 2; // Set taxonomies to available equivalents $show = array(); $terms = array(); foreach ( $options['taxonomies'] as $taxonomy => $tax_info ) { $key = strtolower( $tax_info['plural'] ); $show[$taxonomy] = $instance['show_' . $key] ? 1 : 0; $terms[$taxonomy] = $instance[$key] ? $instance[$key] : ''; } $available = $terms; echo $before_widget; if ( $title ) echo '' . $before_title . $title . $after_title . ''; // Form Field Values $address_value = isset( $_REQUEST['location_search_address'] ) ? $_REQUEST['location_search_address'] : ''; $city_value = isset( $_REQUEST['location_search_city'] ) ? $_REQUEST['location_search_city'] : ''; $state_value = isset( $_REQUEST['location_search_state'] ) ? $_REQUEST['location_search_state'] : ''; $zip_value = isset( $_REQUEST['location_search_zip'] ) ? $_REQUEST['location_search_zip'] : ''; $radius_value = isset( $_REQUEST['location_search_distance'] ) ? $_REQUEST['location_search_distance'] : $options['default_radius']; $limit_value = isset( $_REQUEST['location_search_limit'] ) ? $_REQUEST['location_search_limit'] : $options['results_limit']; // Set action based on permalink structure if ( ! $wp_rewrite->permalink_structure ) { $method = 'get'; $action = site_url(); } else { $method = 'post'; $action = get_permalink( absint( $simplemap_page ) ); } $location_search = ''; // close map_search div echo $location_search; echo $after_widget; } // Save settings in backend function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags( $new_instance['title'] ); $instance['show_address'] = $new_instance['show_address'] ? 1 : 0; $instance['show_city'] = $new_instance['show_city'] ? 1 : 0; $instance['show_state'] = $new_instance['show_state'] ? 1 : 0; $instance['show_zip'] = $new_instance['show_zip'] ? 1 : 0; $instance['show_distance'] = $new_instance['show_distance'] ? 1 : 0; $instance['default_lat'] = $new_instance['default_lat'] ? $new_instance['default_lat'] : 0; $instance['default_lng'] = $new_instance['default_lng'] ? $new_instance['default_lng'] : 0; $instance['simplemap_page'] = $new_instance['simplemap_page'] ? $new_instance['simplemap_page'] : 2; global $simple_map; $options = $simple_map->get_options(); foreach ( $options['taxonomies'] as $taxonomy => $tax_info ) { $key = strtolower( $tax_info['plural'] ); $instance['show_' . $key] = $new_instance['show_' . $key] ? 1 : 0; $instance[$key] = $new_instance[$key] ? $new_instance[$key] : ''; } return $instance; } function form( $instance ) { //Defaults $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); $title = esc_attr( $instance['title'] ); $show_address = isset( $instance['show_address'] ) ? (bool) $instance['show_address'] : false; $show_city = isset( $instance['show_city'] ) ? (bool) $instance['show_city'] : false; $show_state = isset( $instance['show_state'] ) ? (bool) $instance['show_state'] : false; $show_zip = isset( $instance['show_zip'] ) ? (bool) $instance['show_zip'] : false; $show_distance = isset( $instance['show_distance'] ) ? (bool) $instance['show_distance'] : false; $default_lat = isset( $instance['default_lat'] ) ? esc_attr( $instance['default_lat'] ) : 0; $default_lng = isset( $instance['default_lng'] ) ? esc_attr( $instance['default_lng'] ) : 0; $simplemap_page = isset( $instance['simplemap_page'] ) ? esc_attr( $instance['simplemap_page'] ) : ''; ?>

/>
/>
/>
/>
/>
get_options(); foreach ( $options['taxonomies'] as $taxonomy => $tax_info ) { $key = strtolower( $tax_info['plural'] ); $show_field = 'show_' . $key; $show = isset( $instance[$show_field] ) ? (bool) $instance[$show_field] : false; ?> />

*/ ?>