|
1 <?php |
|
2 /** |
|
3 * Widget API: WP_Widget_Meta class |
|
4 * |
|
5 * @package WordPress |
|
6 * @subpackage Widgets |
|
7 * @since 4.4.0 |
|
8 */ |
|
9 |
|
10 /** |
|
11 * Core class used to implement a Meta widget. |
|
12 * |
|
13 * Displays log in/out, RSS feed links, etc. |
|
14 * |
|
15 * @since 2.8.0 |
|
16 * |
|
17 * @see WP_Widget |
|
18 */ |
|
19 class WP_Widget_Meta extends WP_Widget { |
|
20 |
|
21 /** |
|
22 * Sets up a new Meta widget instance. |
|
23 * |
|
24 * @since 2.8.0 |
|
25 */ |
|
26 public function __construct() { |
|
27 $widget_ops = array( |
|
28 'classname' => 'widget_meta', |
|
29 'description' => __( 'Login, RSS, & WordPress.org links.' ), |
|
30 'customize_selective_refresh' => true, |
|
31 ); |
|
32 parent::__construct( 'meta', __( 'Meta' ), $widget_ops ); |
|
33 } |
|
34 |
|
35 /** |
|
36 * Outputs the content for the current Meta widget instance. |
|
37 * |
|
38 * @since 2.8.0 |
|
39 * |
|
40 * @param array $args Display arguments including 'before_title', 'after_title', |
|
41 * 'before_widget', and 'after_widget'. |
|
42 * @param array $instance Settings for the current Meta widget instance. |
|
43 */ |
|
44 public function widget( $args, $instance ) { |
|
45 $title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Meta' ); |
|
46 |
|
47 /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
|
48 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
|
49 |
|
50 echo $args['before_widget']; |
|
51 |
|
52 if ( $title ) { |
|
53 echo $args['before_title'] . $title . $args['after_title']; |
|
54 } |
|
55 ?> |
|
56 <ul> |
|
57 <?php wp_register(); ?> |
|
58 <li><?php wp_loginout(); ?></li> |
|
59 <li><a href="<?php echo esc_url( get_bloginfo( 'rss2_url' ) ); ?>"><?php _e('Entries <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li> |
|
60 <li><a href="<?php echo esc_url( get_bloginfo( 'comments_rss2_url' ) ); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li> |
|
61 <?php |
|
62 /** |
|
63 * Filters the "Powered by WordPress" text in the Meta widget. |
|
64 * |
|
65 * @since 3.6.0 |
|
66 * @since 4.9.0 Added the `$instance` parameter. |
|
67 * |
|
68 * @param string $title_text Default title text for the WordPress.org link. |
|
69 * @param array $instance Array of settings for the current widget. |
|
70 */ |
|
71 echo apply_filters( 'widget_meta_poweredby', sprintf( '<li><a href="%s" title="%s">%s</a></li>', |
|
72 esc_url( __( 'https://wordpress.org/' ) ), |
|
73 esc_attr__( 'Powered by WordPress, state-of-the-art semantic personal publishing platform.' ), |
|
74 _x( 'WordPress.org', 'meta widget link text' ) |
|
75 ), $instance ); |
|
76 |
|
77 wp_meta(); |
|
78 ?> |
|
79 </ul> |
|
80 <?php |
|
81 |
|
82 echo $args['after_widget']; |
|
83 } |
|
84 |
|
85 /** |
|
86 * Handles updating settings for the current Meta widget instance. |
|
87 * |
|
88 * @since 2.8.0 |
|
89 * |
|
90 * @param array $new_instance New settings for this instance as input by the user via |
|
91 * WP_Widget::form(). |
|
92 * @param array $old_instance Old settings for this instance. |
|
93 * @return array Updated settings to save. |
|
94 */ |
|
95 public function update( $new_instance, $old_instance ) { |
|
96 $instance = $old_instance; |
|
97 $instance['title'] = sanitize_text_field( $new_instance['title'] ); |
|
98 |
|
99 return $instance; |
|
100 } |
|
101 |
|
102 /** |
|
103 * Outputs the settings form for the Meta widget. |
|
104 * |
|
105 * @since 2.8.0 |
|
106 * |
|
107 * @param array $instance Current settings. |
|
108 */ |
|
109 public function form( $instance ) { |
|
110 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); |
|
111 $title = sanitize_text_field( $instance['title'] ); |
|
112 ?> |
|
113 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p> |
|
114 <?php |
|
115 } |
|
116 } |