wp_sprintf
Filter HookDescription
Filters a fragment from the pattern passed to wp_sprintf(). If the fragment is unchanged, then sprintf() will be run on the fragment.Hook Information
File Location |
wp-includes/formatting.php
View on GitHub
|
Hook Type | Filter |
Line Number | 5287 |
Hook Parameters
Type | Name | Description |
---|---|---|
string
|
$fragment
|
A fragment from the pattern. |
string
|
$arg
|
The argument. |
Usage Examples
Basic Usage
<?php
// Hook into wp_sprintf
add_filter('wp_sprintf', 'my_custom_filter', 10, 2);
function my_custom_filter($fragment, $arg) {
// Your custom filtering logic here
return $fragment;
}
Source Code Context
wp-includes/formatting.php:5287
- How this hook is used in WordPress core
<?php
5282 * @since 2.5.0
5283 *
5284 * @param string $fragment A fragment from the pattern.
5285 * @param string $arg The argument.
5286 */
5287 $_fragment = apply_filters( 'wp_sprintf', $fragment, $arg );
5288
5289 if ( $_fragment !== $fragment ) {
5290 $fragment = $_fragment;
5291 } else {
5292 $fragment = sprintf( $fragment, (string) $arg );
PHP Documentation
<?php
/**
* Filters a fragment from the pattern passed to wp_sprintf().
*
* If the fragment is unchanged, then sprintf() will be run on the fragment.
*
* @since 2.5.0
*
* @param string $fragment A fragment from the pattern.
* @param string $arg The argument.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/formatting.php
Related Hooks
Related hooks will be displayed here in future updates.