WordPress 4.4
[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('classname' => 'widget_meta', 'description' => __( "Login, RSS, &amp; WordPress.org links.") );
29                 parent::__construct('meta', __('Meta'), $widget_ops);
30         }
31
32         /**
33          * Outputs the content for the current Meta widget instance.
34          *
35          * @since 2.8.0
36          * @access public
37          *
38          * @param array $args     Display arguments including 'before_title', 'after_title',
39          *                        'before_widget', and 'after_widget'.
40          * @param array $instance Settings for the current Meta widget instance.
41          */
42         public function widget( $args, $instance ) {
43                 /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
44                 $title = apply_filters( 'widget_title', empty($instance['title']) ? __( 'Meta' ) : $instance['title'], $instance, $this->id_base );
45
46                 echo $args['before_widget'];
47                 if ( $title ) {
48                         echo $args['before_title'] . $title . $args['after_title'];
49                 }
50                         ?>
51                         <ul>
52                         <?php wp_register(); ?>
53                         <li><?php wp_loginout(); ?></li>
54                         <li><a href="<?php echo esc_url( get_bloginfo( 'rss2_url' ) ); ?>"><?php _e('Entries <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
55                         <li><a href="<?php echo esc_url( get_bloginfo( 'comments_rss2_url' ) ); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
56                         <?php
57                         /**
58                          * Filter the "Powered by WordPress" text in the Meta widget.
59                          *
60                          * @since 3.6.0
61                          *
62                          * @param string $title_text Default title text for the WordPress.org link.
63                          */
64                         echo apply_filters( 'widget_meta_poweredby', sprintf( '<li><a href="%s" title="%s">%s</a></li>',
65                                 esc_url( __( 'https://wordpress.org/' ) ),
66                                 esc_attr__( 'Powered by WordPress, state-of-the-art semantic personal publishing platform.' ),
67                                 _x( 'WordPress.org', 'meta widget link text' )
68                         ) );
69
70                         wp_meta();
71                         ?>
72                         </ul>
73                         <?php
74                 echo $args['after_widget'];
75         }
76
77         /**
78          * Handles updating settings for the current Meta widget instance.
79          *
80          * @since 2.8.0
81          * @access public
82          *
83          * @param array $new_instance New settings for this instance as input by the user via
84          *                            WP_Widget::form().
85          * @param array $old_instance Old settings for this instance.
86          * @return array Updated settings to save.
87          */
88         public function update( $new_instance, $old_instance ) {
89                 $instance = $old_instance;
90                 $instance['title'] = sanitize_text_field( $new_instance['title'] );
91
92                 return $instance;
93         }
94
95         /**
96          * Outputs the settings form for the Meta widget.
97          *
98          * @since 2.8.0
99          * @access public
100          *
101          * @param array $instance Current settings.
102          */
103         public function form( $instance ) {
104                 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
105                 $title = sanitize_text_field( $instance['title'] );
106 ?>
107                         <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>
108 <?php
109         }
110 }