__('Contact Widget', 'beautymatters'),) // Args ); } /** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget($args, $instance) { echo '
'; } /** * Back-end widget form. * * @see WP_Widget::form() * * @param array $instance Previously saved values from database. */ public function form($instance) { if (isset($instance['title'])) { $title = $instance['title']; } else { $title = __('Contact', 'beautymatters'); } $firstname = (isset($instance['firstname'])) ? $instance['firstname'] : ""; $lastname = (isset($instance['lastname'])) ? $instance['lastname'] : ""; $street = (isset($instance['street'])) ? $instance['street'] : ""; $country = (isset($instance['country'])) ? $instance['country'] : ""; $city = (isset($instance['city'])) ? $instance['city'] : ""; $zipcode = (isset($instance['zipcode'])) ? $instance['zipcode'] : ""; $phone = (isset($instance['phone'])) ? $instance['phone'] : ""; $fax = (isset($instance['fax'])) ? $instance['fax'] : ""; $mobile = (isset($instance['mobile'])) ? $instance['mobile'] : ""; $email = (isset($instance['email'])) ? $instance['email'] : ""; $this->generate_field("Title:", $title, "title"); $this->generate_field("Firstname:", $firstname, "firstname"); $this->generate_field("Lastname:", $lastname, "lastname"); $this->generate_field("Street:", $street, "street"); $this->generate_field("Country:", $country, "country"); $this->generate_field("City:", $city, "city"); $this->generate_field("Zipcode:", $zipcode, "zipcode"); $this->generate_field("Phone:", $phone, "phone"); $this->generate_field("Fax:", $fax, "fax"); $this->generate_field("Mobile:", $mobile, "mobile"); $this->generate_field("Email:", $email, "email"); } function generate_field($label, $value, $id) { echo ''; echo ''; echo ''; echo '
'; } /** * Sanitize widget form values as they are saved. * * @see WP_Widget::update() * * @param array $new_instance Values just sent to be saved. * @param array $old_instance Previously saved values from database. * * @return array Updated safe values to be saved. */ public function update($new_instance, $old_instance) { $instance = $old_instance; $instance['title'] = (!empty($new_instance['title']) ) ? strip_tags($new_instance['title']) : ''; $instance['firstname'] = (!empty($new_instance['firstname']) ) ? strip_tags($new_instance['firstname']) : ''; $instance['lastname'] = (!empty($new_instance['lastname']) ) ? strip_tags($new_instance['lastname']) : ''; $instance['street'] = (!empty($new_instance['street']) ) ? strip_tags($new_instance['street']) : ''; $instance['country'] = (!empty($new_instance['country']) ) ? strip_tags($new_instance['country']) : ''; $instance['city'] = (!empty($new_instance['city']) ) ? strip_tags($new_instance['city']) : ''; $instance['zipcode'] = (!empty($new_instance['zipcode']) ) ? strip_tags($new_instance['zipcode']) : ''; $instance['phone'] = (!empty($new_instance['phone']) ) ? strip_tags($new_instance['phone']) : ''; $instance['fax'] = (!empty($new_instance['fax']) ) ? strip_tags($new_instance['fax']) : ''; $instance['mobile'] = (!empty($new_instance['mobile']) ) ? strip_tags($new_instance['mobile']) : ''; $instance['email'] = (!empty($new_instance['email']) ) ? strip_tags($new_instance['email']) : ''; return $instance; } }