widget_title
Filter HookDescription
Outputs the content for the current Text widget instance.Hook Information
File Location |
wp-includes/widgets/class-wp-widget-text.php
View on GitHub
|
Hook Type | Filter |
Line Number | 233 |
Hook Parameters
Type | Name | Description |
---|---|---|
array
|
$args
|
Display arguments including 'before_title', 'after_title', 'before_widget', and 'after_widget'. |
array
|
$instance
|
Settings for the current Text widget instance. |
Usage Examples
Basic Usage
<?php
// Hook into widget_title
add_filter('widget_title', 'my_custom_filter', 10, 2);
function my_custom_filter($args, $instance) {
// Your custom filtering logic here
return $args;
}
Source Code Context
wp-includes/widgets/class-wp-widget-text.php:233
- How this hook is used in WordPress core
<?php
228 global $post;
229
230 $title = ! empty( $instance['title'] ) ? $instance['title'] : '';
231
232 /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
233 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
234
235 $text = ! empty( $instance['text'] ) ? $instance['text'] : '';
236 $is_visual_text_widget = ( ! empty( $instance['visual'] ) && ! empty( $instance['filter'] ) );
237
238 // In 4.8.0 only, visual Text widgets get filter=content, without visual prop; upgrade instance props just-in-time.
PHP Documentation
<?php
/**
* Outputs the content for the current Text widget instance.
*
* @since 2.8.0
*
* @global WP_Post $post Global post object.
*
* @param array $args Display arguments including 'before_title', 'after_title',
* 'before_widget', and 'after_widget'.
* @param array $instance Settings for the current Text widget instance.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/widgets/class-wp-widget-text.php
Related Hooks
Related hooks will be displayed here in future updates.