'architect_lite_about_us', 'description' => __( 'Display content for about us.', 'architect-lite' ) ); parent::__construct( 'architect_lite_about_us', __( 'Owner : About Us', 'architect-lite' ), $widget_ops ); } /** * Helper function that holds widget fields * Array is used in update and form functions */ private function widget_fields() { $owner_pages = owner_pages_dropdown(); $fields = array( 'section_page' => array( 'owner_widgets_name' => 'section_page', 'owner_widgets_title' => __( 'Section Page', 'architect-lite' ), 'owner_widgets_field_type' => 'select', 'owner_widgets_field_options' => $owner_pages ), ); 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 ); if( empty( $instance ) ) { return ; } $section_page = empty( $instance['section_page'] ) ? '' : $instance['section_page']; if(!empty($section_page)): $section_page_detail = get_post($section_page); 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[$owner_widgets_name] = owner_widgets_updated_field_value( $widget_field, $new_instance[$owner_widgets_name] ); } return $instance; } /** * Back-end widget form. * * @see WP_Widget::form() * * @param array $instance Previously saved values from database. * * @uses owner_widgets_show_widget_field() defined in owner-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 ); $owner_widgets_field_value = !empty( $instance[$owner_widgets_name] ) ? wp_kses_post( $instance[$owner_widgets_name] ) : ''; owner_widgets_show_widget_field( $this, $widget_field, $owner_widgets_field_value ); } } }