PluginProbe
Friends / 4.3.2
Friends v4.3.2
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-add-subscription.php

class-widget-add-subscription.php in Friends 4.3.2, at widgets/class-widget-add-subscription.php

94 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Friend Request Widget
4 *
5 * A widget that allows you to send a friend request.
6 *
7 * @package Friends
8 * @since 0.3
9 */
10
11 namespace Friends;
12
13 /**
14 * This is the class for the Friend Request Widget.
15 *
16 * @package Friends
17 * @author Alex Kirk
18 */
19 class Widget_Add_Subscription extends \WP_Widget {
20 /**
21 * Constructor
22 */
23 public function __construct() {
24 parent::__construct(
25 'friends-widget-friend-request',
26 __( 'Follow', 'friends' ),
27 array(
28 'description' => __( 'Follow someone new.', '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 ?>
49 <form action="<?php echo esc_url( home_url( '/friends/add-friend/' ) ); ?>" method="get" class="form-horizontal">
50 <div class="form-group">
51 <input type="text" name="url" required aria-label="<?php esc_attr_e( 'Enter a URL or an @user@instance handle to follow', 'friends' ); ?>" placeholder="<?php esc_attr_e( 'URL or @user@instance', 'friends' ); ?>" class="form-input input-sm" />
52 </div>
53 <div class="form-group">
54 <button class="btn btn-primary btn-sm"><?php esc_html_e( 'Follow', 'friends' ); ?></button>
55 </div>
56 </form>
57 <?php
58 echo $args['after_widget'];
59 }
60
61 /**
62 * Update widget configuration.
63 *
64 * @param array $new_instance New settings.
65 * @param array $old_instance Old settings.
66 * @return array Sanitized instance settings.
67 */
68 public function update( $new_instance, $old_instance ) {
69 $instance = $this->defaults;
70
71 return $instance;
72 }
73
74 /**
75 * Return an associative array of default values
76 *
77 * These values are used in new widgets.
78 *
79 * @return array Array of default values for the Widget's options
80 */
81 public function defaults() {
82 return array(
83 'title' => '',
84 );
85 }
86
87 /**
88 * Register this widget.
89 */
90 public static function register() {
91 register_widget( __CLASS__ );
92 }
93 }
94