PluginProbe
Friends / 2.8.5
Friends v2.8.5
4.3.2 4.3.1 4.3.0 4.2.2 4.2.1 4.2.0 4.1.0 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.0 2.9.1 All 88 releases
friends / widgets / class-widget-refresh.php

class-widget-refresh.php in Friends 2.8.5, at widgets/class-widget-refresh.php

87 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Friend Posts Refresh
4 *
5 * A widget that allows you to refresh your friend posts.
6 *
7 * @package Friends
8 * @since 0.3
9 */
10
11 namespace Friends;
12
13 /**
14 * This is the class for the Friend Posts Refresh Widget.
15 *
16 * @package Friends
17 * @author Alex Kirk
18 */
19 class Widget_Refresh extends \WP_Widget {
20 /**
21 * Constructor
22 */
23 public function __construct() {
24 parent::__construct(
25 'friends-widget-refresh',
26 __( 'Friend Posts Refresh', 'friends' ),
27 array(
28 'description' => __( "Shows a refresh link to refetch your friends' posts.", 'friends' ),
29 )
30 );
31 }
32
33 /**
34 * Render the widget.
35 *
36 * @param array $args Sidebar arguments.
37 * @param array $instance Widget instance settings.
38 */
39 public function widget( $args, $instance ) {
40 $instance = wp_parse_args( $instance, $this->defaults() );
41
42 $title = apply_filters( 'widget_title', $instance['title'] );
43 echo $args['before_widget'];
44 if ( ! empty( $title ) ) {
45 echo $args['before_title'] . $title . $args['after_title'];
46 }
47
48 echo '<a href="' . esc_url( home_url( '/friends/?refresh' ) ) . '">' . esc_html__( 'Refresh', 'friends' ) . '</a>';
49
50 echo $args['after_widget'];
51 }
52
53
54 /**
55 * Update widget configuration.
56 *
57 * @param array $new_instance New settings.
58 * @param array $old_instance Old settings.
59 * @return array Sanitized instance settings.
60 */
61 public function update( $new_instance, $old_instance ) {
62 $instance = $this->defaults;
63
64 return $instance;
65 }
66
67 /**
68 * Return an associative array of default values
69 *
70 * These values are used in new widgets.
71 *
72 * @return array Array of default values for the Widget's options
73 */
74 public function defaults() {
75 return array(
76 'title' => '',
77 );
78 }
79
80 /**
81 * Register this widget.
82 */
83 public static function register() {
84 register_widget( __CLASS__ );
85 }
86 }
87