__('A widget that shows contact information', 'agensy') ) ); } private function widget_fields() { $fields = array( 'gmap_contact_title' => array( 'agensy_widgets_name' => 'gmap_contact_title', 'agensy_widgets_title' => __('Title', 'agensy'), 'agensy_widgets_field_type' => 'text', ), 'gmap_phone' => array( 'agensy_widgets_name' => 'gmap_phone', 'agensy_widgets_title' => __(' Phone', 'agensy'), 'agensy_widgets_field_type' => 'text', ), 'gmap_support_email' => array( 'agensy_widgets_name' => 'gmap_support_email', 'agensy_widgets_title' => __('Support', 'agensy'), 'agensy_widgets_field_type' => 'text', ), 'gmap_contact_email' => array( 'agensy_widgets_name' => 'gmap_contact_email', 'agensy_widgets_title' => __('Email', 'agensy'), 'agensy_widgets_field_type' => 'text', ), 'gmap_location' => array( 'agensy_widgets_name' => 'gmap_location', 'agensy_widgets_title' => __('Address', 'agensy'), 'agensy_widgets_field_type' => 'text', ), ); return $fields; } /** * Front-end display of widget. * */ public function widget($args, $instance) { extract($args); if($instance!=null){ $gmap_contact_title = isset($instance['gmap_contact_title']) ? $instance['gmap_contact_title'] : ''; $gmap_phone = isset($instance['gmap_phone']) ? $instance['gmap_phone'] : ''; $gmap_support_email = isset($instance['gmap_support_email']) ? $instance['gmap_support_email'] : ''; $gmap_contact_email = isset($instance['gmap_contact_email']) ? $instance['gmap_contact_email'] : ''; $gmap_location = isset($instance['gmap_location']) ? $instance['gmap_location'] : ''; echo $before_widget; ?>
widget_fields(); // Loop through fields foreach( $widget_fields as $widget_field ) { extract( $widget_field ); // Use helper function to get updated field values $instance[$agensy_widgets_name] = agensy_widgets_updated_field_value( $widget_field, $new_instance[$agensy_widgets_name] ); } return $instance; } public function form( $instance ) { $widget_fields = $this->widget_fields(); // Loop through fields foreach( $widget_fields as $widget_field ) { // Make array elements available as variables extract( $widget_field ); $agensy_widgets_field_value = isset( $instance[$agensy_widgets_name] ) ? esc_attr( $instance[$agensy_widgets_name] ) : ''; agensy_widgets_show_widget_field( $this, $widget_field, $agensy_widgets_field_value ); } } }