# friends/2.9.1/widgets/class-widget-refresh.php

Friends, version 2.9.1. 87 lines.

- Page: https://pluginprobe.com/plugins/friends/2.9.1/code/widgets/class-widget-refresh.php
- Raw: https://pluginprobe.com/plugins/friends/2.9.1/raw/widgets/class-widget-refresh.php
- Modified: 2023-09-23T05:40:06+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/friends/2.9.1/code/widgets/class-widget-refresh.php#L10-L20`.

```php
<?php
/**
 * Friend Posts Refresh
 *
 * A widget that allows you to refresh your friend posts.
 *
 * @package Friends
 * @since 0.3
 */

namespace Friends;

/**
 * This is the class for the Friend Posts Refresh Widget.
 *
 * @package Friends
 * @author Alex Kirk
 */
class Widget_Refresh extends \WP_Widget {
	/**
	 * Constructor
	 */
	public function __construct() {
		parent::__construct(
			'friends-widget-refresh',
			__( 'Friend Posts Refresh', 'friends' ),
			array(
				'description' => __( "Shows a refresh link to refetch your friends' posts.", 'friends' ),
			)
		);
	}

	/**
	 * Render the widget.
	 *
	 * @param array $args Sidebar arguments.
	 * @param array $instance Widget instance settings.
	 */
	public function widget( $args, $instance ) {
		$instance = wp_parse_args( $instance, $this->defaults() );

		$title = apply_filters( 'widget_title', $instance['title'] );
		echo $args['before_widget'];
		if ( ! empty( $title ) ) {
			echo $args['before_title'] . $title . $args['after_title'];
		}

		echo '<a href="' . esc_url( home_url( '/friends/?refresh' ) ) . '">' . esc_html__( 'Refresh', 'friends' ) . '</a>';

		echo $args['after_widget'];
	}


	/**
	 * Update widget configuration.
	 *
	 * @param array $new_instance New settings.
	 * @param array $old_instance Old settings.
	 * @return array Sanitized instance settings.
	 */
	public function update( $new_instance, $old_instance ) {
		$instance = $this->defaults;

		return $instance;
	}

	/**
	 * Return an associative array of default values
	 *
	 * These values are used in new widgets.
	 *
	 * @return array Array of default values for the Widget's options
	 */
	public function defaults() {
		return array(
			'title' => '',
		);
	}

	/**
	 * Register this widget.
	 */
	public static function register() {
		register_widget( __CLASS__ );
	}
}

```
