[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/widgets/ -> class-wp-widget-meta.php (source)

   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, &amp; 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 feed' ); ?></a></li>
  60              <li><a href="<?php echo esc_url( get_bloginfo( 'comments_rss2_url' ) ); ?>"><?php _e( 'Comments feed' ); ?></a></li>
  61              <?php
  62              /**
  63               * Filters the "WordPress.org" list item HTML in the Meta widget.
  64               *
  65               * @since 3.6.0
  66               * @since 4.9.0 Added the `$instance` parameter.
  67               *
  68               * @param string $html     Default HTML for the WordPress.org list item.
  69               * @param array  $instance Array of settings for the current widget.
  70               */
  71              echo apply_filters(
  72                  'widget_meta_poweredby',
  73                  sprintf(
  74                      '<li><a href="%1$s">%2$s</a></li>',
  75                      esc_url( __( 'https://wordpress.org/' ) ),
  76                      __( 'WordPress.org' )
  77                  ),
  78                  $instance
  79              );
  80  
  81              wp_meta();
  82              ?>
  83              </ul>
  84              <?php
  85  
  86              echo $args['after_widget'];
  87      }
  88  
  89      /**
  90       * Handles updating settings for the current Meta widget instance.
  91       *
  92       * @since 2.8.0
  93       *
  94       * @param array $new_instance New settings for this instance as input by the user via
  95       *                            WP_Widget::form().
  96       * @param array $old_instance Old settings for this instance.
  97       * @return array Updated settings to save.
  98       */
  99  	public function update( $new_instance, $old_instance ) {
 100          $instance          = $old_instance;
 101          $instance['title'] = sanitize_text_field( $new_instance['title'] );
 102  
 103          return $instance;
 104      }
 105  
 106      /**
 107       * Outputs the settings form for the Meta widget.
 108       *
 109       * @since 2.8.0
 110       *
 111       * @param array $instance Current settings.
 112       */
 113  	public function form( $instance ) {
 114          $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
 115          ?>
 116              <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( $instance['title'] ); ?>" /></p>
 117          <?php
 118      }
 119  }


Generated: Wed Dec 11 01:00:03 2019 Cross-referenced by PHPXref 0.7.1