You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

115 lines
3.4 KiB

  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. * Core class used to implement a Meta widget.
  11. *
  12. * Displays log in/out, RSS feed links, etc.
  13. *
  14. * @since 2.8.0
  15. *
  16. * @see WP_Widget
  17. */
  18. class WP_Widget_Meta extends WP_Widget {
  19. /**
  20. * Sets up a new Meta widget instance.
  21. *
  22. * @since 2.8.0
  23. * @access public
  24. */
  25. public function __construct() {
  26. $widget_ops = array(
  27. 'classname' => 'widget_meta',
  28. 'description' => __( 'Login, RSS, &amp; WordPress.org links.' ),
  29. 'customize_selective_refresh' => true,
  30. );
  31. parent::__construct( 'meta', __( 'Meta' ), $widget_ops );
  32. }
  33. /**
  34. * Outputs the content for the current Meta widget instance.
  35. *
  36. * @since 2.8.0
  37. * @access public
  38. *
  39. * @param array $args Display arguments including 'before_title', 'after_title',
  40. * 'before_widget', and 'after_widget'.
  41. * @param array $instance Settings for the current Meta widget instance.
  42. */
  43. public function widget( $args, $instance ) {
  44. /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
  45. $title = apply_filters( 'widget_title', empty($instance['title']) ? __( 'Meta' ) : $instance['title'], $instance, $this->id_base );
  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. * Filters 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. wp_meta();
  70. ?>
  71. </ul>
  72. <?php
  73. echo $args['after_widget'];
  74. }
  75. /**
  76. * Handles updating settings for the current Meta widget instance.
  77. *
  78. * @since 2.8.0
  79. * @access public
  80. *
  81. * @param array $new_instance New settings for this instance as input by the user via
  82. * WP_Widget::form().
  83. * @param array $old_instance Old settings for this instance.
  84. * @return array Updated settings to save.
  85. */
  86. public function update( $new_instance, $old_instance ) {
  87. $instance = $old_instance;
  88. $instance['title'] = sanitize_text_field( $new_instance['title'] );
  89. return $instance;
  90. }
  91. /**
  92. * Outputs the settings form for the Meta widget.
  93. *
  94. * @since 2.8.0
  95. * @access public
  96. *
  97. * @param array $instance Current settings.
  98. */
  99. public function form( $instance ) {
  100. $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
  101. $title = sanitize_text_field( $instance['title'] );
  102. ?>
  103. <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>
  104. <?php
  105. }
  106. }