PluginProbe
Friends / 2.8.8
Friends v2.8.8
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-friend-request.php

class-widget-friend-request.php in Friends 2.8.8, at widgets/class-widget-friend-request.php

95 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_Friend_Request extends \WP_Widget {
20 /**
21 * Constructor
22 */
23 public function __construct() {
24 parent::__construct(
25 'friends-widget-friend-request',
26 __( 'Friend request', 'friends' ),
27 array(
28 'description' => __( 'Send a friend request.', '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( self_admin_url( 'admin.php?page=add-friend' ) ); ?>" method="post" class="form-horizontal">
50 <?php wp_nonce_field( 'add-friend' ); ?>
51 <div class="form-group">
52 <input type="text" name="friend_url" aria-label="<?php echo esc_attr_e( "Enter the Friend's URL", 'friends' ); ?>" placeholder="<?php echo esc_attr_e( "Friend's URL", 'friends' ); ?>" class="form-input input-sm" />
53 </div>
54 <div class="form-group">
55 <button class="btn btn-primary btn-sm"><?php echo esc_attr_e( 'Add Friend', 'friends' ); ?></button>
56 </div>
57 </form>
58 <?php
59 echo $args['after_widget'];
60 }
61
62 /**
63 * Update widget configuration.
64 *
65 * @param array $new_instance New settings.
66 * @param array $old_instance Old settings.
67 * @return array Sanitized instance settings.
68 */
69 public function update( $new_instance, $old_instance ) {
70 $instance = $this->defaults;
71
72 return $instance;
73 }
74
75 /**
76 * Return an associative array of default values
77 *
78 * These values are used in new widgets.
79 *
80 * @return array Array of default values for the Widget's options
81 */
82 public function defaults() {
83 return array(
84 'title' => '',
85 );
86 }
87
88 /**
89 * Register this widget.
90 */
91 public static function register() {
92 register_widget( __CLASS__ );
93 }
94 }
95