3 * Widget API: WP_Widget_Meta class
11 * Core class used to implement a Meta widget.
13 * Displays log in/out, RSS feed links, etc.
19 class WP_Widget_Meta extends WP_Widget {
22 * Sets up a new Meta widget instance.
27 public function __construct() {
29 'classname' => 'widget_meta',
30 'description' => __( 'Login, RSS, & WordPress.org links.' ),
31 'customize_selective_refresh' => true,
33 parent::__construct( 'meta', __( 'Meta' ), $widget_ops );
37 * Outputs the content for the current Meta widget instance.
42 * @param array $args Display arguments including 'before_title', 'after_title',
43 * 'before_widget', and 'after_widget'.
44 * @param array $instance Settings for the current Meta widget instance.
46 public function widget( $args, $instance ) {
47 /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
48 $title = apply_filters( 'widget_title', empty($instance['title']) ? __( 'Meta' ) : $instance['title'], $instance, $this->id_base );
50 echo $args['before_widget'];
52 echo $args['before_title'] . $title . $args['after_title'];
56 <?php wp_register(); ?>
57 <li><?php wp_loginout(); ?></li>
58 <li><a href="<?php echo esc_url( get_bloginfo( 'rss2_url' ) ); ?>"><?php _e('Entries <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
59 <li><a href="<?php echo esc_url( get_bloginfo( 'comments_rss2_url' ) ); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
62 * Filters the "Powered by WordPress" text in the Meta widget.
66 * @param string $title_text Default title text for the WordPress.org link.
68 echo apply_filters( 'widget_meta_poweredby', sprintf( '<li><a href="%s" title="%s">%s</a></li>',
69 esc_url( __( 'https://wordpress.org/' ) ),
70 esc_attr__( 'Powered by WordPress, state-of-the-art semantic personal publishing platform.' ),
71 _x( 'WordPress.org', 'meta widget link text' )
78 echo $args['after_widget'];
82 * Handles updating settings for the current Meta widget instance.
87 * @param array $new_instance New settings for this instance as input by the user via
89 * @param array $old_instance Old settings for this instance.
90 * @return array Updated settings to save.
92 public function update( $new_instance, $old_instance ) {
93 $instance = $old_instance;
94 $instance['title'] = sanitize_text_field( $new_instance['title'] );
100 * Outputs the settings form for the Meta widget.
105 * @param array $instance Current settings.
107 public function form( $instance ) {
108 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
109 $title = sanitize_text_field( $instance['title'] );
111 <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>