Emette il contenuto dell'istanza corrente del widget Archives.

Parametri

$args

(array)(Richiesto)Argomenti di visualizzazione, tra cui 'before_title', 'after_title', 'before_widget' e 'after_widget'.

$instanza

(array)(Richiesto)Impostazioni per l'istanza corrente del widget Archivio.

Fonte

File: wp-includes/widgets/class-wp-widget-archives.php

public function widget( $args, $instance ) {
		$default_title = __( 'Archives' );
		$title         = ! empty( $instance['title'] ) ? $instance['title'] : $default_title;

		/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
		$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );

		$count    = ! empty( $instance['count'] ) ? '1' : '0';
		$dropdown = ! empty( $instance['dropdown'] ) ? '1' : '0';

		echo $args['before_widget'];

		if ( $title ) {
			echo $args['before_title'] . $title . $args['after_title'];
		}

		if ( $dropdown ) {
			$dropdown_id = "{$this->id_base}-dropdown-{$this->number}";
			?>
		<labelclass="screen-reader-text"for="echoesc_attr($dropdown_id);?>">echo$title;?>label><selectid="echoesc_attr($dropdown_id);?>"name="archive-dropdown">/**
			 * Filters the arguments for the Archives widget drop-down.
			 *
			 * @since 2.8.0
			 * @since 4.9.0 Added the `$instance` parameter.
			 *
			 * @see wp_get_archives()
			 *
			 * @param array $args     An array of Archives widget drop-down arguments.
			 * @param array $instance Settings for the current Archives widget instance.
			 */$dropdown_args=apply_filters('widget_archives_dropdown_args',array('type'=>'monthly','format'=>'option','show_post_count'=>$count,),$instance);switch($dropdown_args['type']){case'yearly':$label=__('Select Year');break;case'monthly':$label=__('Select Month');break;case'daily':$label=__('Select Day');break;case'weekly':$label=__('Select Week');break;default:$label=__('Select Post');break;}$type_attr=current_theme_supports('html5','script')?'':' type="text/javascript"';?><optionvalue="">echoesc_html($label);?>option>wp_get_archives($dropdown_args);?>select><scriptecho$type_attr;?>>/* */(function(){var dropdown = documentgetElementById("echoesc_js($dropdown_id);?>");functiononSelectChange(){if( dropdownoptions[ dropdownselectedIndex ]value !==''){
			documentlocationhref =thisoptions[thisselectedIndex ]value;}}
	dropdownonchange = onSelectChange;})();/* ]]>*/script>}else{$format=current_theme_supports('html5','navigation-widgets')?'html5':'xhtml';/** This filter is documented in wp-includes/widgets/class-wp-nav-menu-widget.php */$format=apply_filters('navigation_widgets_format',$format);if('html5'===$format){// The title may be filtered: Strip out HTML and make sure the aria-label is never empty.$title=trim(strip_tags($title));$aria_label=$title?$title:$default_title;echo'';}}echo$args['after_widget'];}

Correlato

Utilizzi

Usi Descrizione
wp-includes/widgets/class-wp-nav-menu-widget.php: navigation_widgets_format

Filtra il formato HTML dei widget con collegamenti di navigazione.

wp-includes/theme.php: current_theme_supports()

Verifica il supporto di un tema per una determinata caratteristica.

wp-includes/l10n.php: __()

Recupera la traduzione di $testo.

wp-includes/formatting.php: esc_attr()

Escaping per gli attributi HTML.

wp-includes/formatting.php: esc_html()

Escaping per i blocchi HTML.

wp-includes/formatting.php: esc_js()

Esegue l'escape di apici singoli, htmlspecialchar " &, e corregge le terminazioni di riga.

wp-includes/general-template.php: wp_get_archives()

Mostra i collegamenti agli archivi in base al tipo e al formato.

wp-includes/widgets/class-wp-widget-archives.php: widget_archives_dropdown_args

Filtra gli argomenti per la tendina del widget Archivi.

wp-includes/widgets/class-wp-widget-archives.php: widget_archivi_args

Filtra gli argomenti per il widget Archivi.

wp-includes/widgets/class-wp-widget-pages.php: widget_titolo

Filtra il titolo del widget.

wp-includes/plugin.php: applica_filtri()

Richiama le funzioni di callback che sono state aggiunte a un gancio per i filtri.

Changelog

Versione Descrizione
2.8.0 Introdotto.