esc_html__('A widget to display Personal Information', 'business-shuffle') ) ); } /** * Helper function that holds widget fields * Array is used in update and form functions */ private function widget_fields() { $fields = array( 'title' => array( 'business_shuffle_widgets_name' => 'title', 'business_shuffle_widgets_title' => esc_html__('Title', 'business-shuffle'), 'business_shuffle_widgets_field_type' => 'text', ), 'image' => array( 'business_shuffle_widgets_name' => 'image', 'business_shuffle_widgets_title' => esc_html__('Image', 'business-shuffle'), 'business_shuffle_widgets_field_type' => 'upload', ), 'intro' => array( 'business_shuffle_widgets_name' => 'intro', 'business_shuffle_widgets_title' => esc_html__('Short Intro', 'business-shuffle'), 'business_shuffle_widgets_field_type' => 'textarea', 'business_shuffle_widgets_row' => '4' ), 'signature' => array( 'business_shuffle_widgets_name' => 'name', 'business_shuffle_widgets_title' => esc_html__('Name', 'business-shuffle'), 'business_shuffle_widgets_field_type' => 'text', ) ); return $fields; } /** * 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) { extract($args); $title = isset( $instance['title'] ) ? $instance['title'] : '' ; $image = isset( $instance['image'] ) ? $instance['image'] : '' ; $intro = isset( $instance['intro'] ) ? $instance['intro'] : '' ; $name = isset( $instance['name'] ) ? $instance['name'] : '' ; echo $before_widget; // WPCS: XSS OK. ?>
'; endif; if (!empty($name)): echo '
'.esc_html($name).'
'; endif; if (!empty($intro)): echo '
'.wp_kses_post($intro).'
'; endif; ?> widget_fields(); // Loop through fields foreach ($widget_fields as $widget_field) { extract($widget_field); // Use helper function to get updated field values $instance[$business_shuffle_widgets_name] = business_shuffle_widgets_updated_field_value($widget_field, $new_instance[$business_shuffle_widgets_name]); } return $instance; } /** * Back-end widget form. * * @see WP_Widget::form() * * @param array $instance Previously saved values from database. * * @uses business_shuffle_widgets_show_widget_field() defined in widget-fields.php */ 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); $business_shuffle_widgets_field_value = !empty($instance[$business_shuffle_widgets_name]) ? esc_attr($instance[$business_shuffle_widgets_name]) : ''; business_shuffle_widgets_show_widget_field($this, $widget_field, $business_shuffle_widgets_field_value); } } }