WordPress 4.5
[autoinstalls/wordpress.git] / wp-includes / widgets / class-wp-widget-meta.php
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          * @access public
26          */
27         public function __construct() {
28                 $widget_ops = array(
29                         'classname' => 'widget_meta',
30                         'description' => __( 'Login, RSS, &amp; WordPress.org links.' ),
31                         'customize_selective_refresh' => true,
32                 );
33                 parent::__construct( 'meta', __( 'Meta' ), $widget_ops );
34         }
35
36         /**
37          * Outputs the content for the current Meta widget instance.
38          *
39          * @since 2.8.0
40          * @access public
41          *
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.
45          */
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 );
49
50                 echo $args['before_widget'];
51                 if ( $title ) {
52                         echo $args['before_title'] . $title . $args['after_title'];
53                 }
54                         ?>
55                         <ul>
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>
60                         <?php
61                         /**
62                          * Filter the "Powered by WordPress" text in the Meta widget.
63                          *
64                          * @since 3.6.0
65                          *
66                          * @param string $title_text Default title text for the WordPress.org link.
67                          */
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' )
72                         ) );
73
74                         wp_meta();
75                         ?>
76                         </ul>
77                         <?php
78                 echo $args['after_widget'];
79         }
80
81         /**
82          * Handles updating settings for the current Meta widget instance.
83          *
84          * @since 2.8.0
85          * @access public
86          *
87          * @param array $new_instance New settings for this instance as input by the user via
88          *                            WP_Widget::form().
89          * @param array $old_instance Old settings for this instance.
90          * @return array Updated settings to save.
91          */
92         public function update( $new_instance, $old_instance ) {
93                 $instance = $old_instance;
94                 $instance['title'] = sanitize_text_field( $new_instance['title'] );
95
96                 return $instance;
97         }
98
99         /**
100          * Outputs the settings form for the Meta widget.
101          *
102          * @since 2.8.0
103          * @access public
104          *
105          * @param array $instance Current settings.
106          */
107         public function form( $instance ) {
108                 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
109                 $title = sanitize_text_field( $instance['title'] );
110 ?>
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>
112 <?php
113         }
114 }