From 2d0a4779095b47ce3a0e2808b3759d084a8f5721 Mon Sep 17 00:00:00 2001
From: jrfnl <jrfnl@users.noreply.github.com>
Date: Fri, 12 Jul 2019 06:10:12 +0200
Subject: [PATCH] Simplify & modernize wp_sprintf()
---
src/wp-includes/formatting.php | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php
index ea7b80d6c2..abfbcbf815 100644
|
a
|
b
|
function wp_pre_kses_less_than_callback( $matches ) { |
| 4831 | 4831 | * @param mixed ...$args Arguments to be formatted into the $pattern string. |
| 4832 | 4832 | * @return string The formatted string. |
| 4833 | 4833 | */ |
| 4834 | | function wp_sprintf( $pattern ) { |
| 4835 | | $args = func_get_args(); |
| | 4834 | function wp_sprintf( $pattern, ...$args ) { |
| 4836 | 4835 | $len = strlen( $pattern ); |
| 4837 | 4836 | $start = 0; |
| 4838 | 4837 | $result = ''; |
| … |
… |
function wp_sprintf( $pattern ) { |
| 4862 | 4861 | if ( $pattern[ $start ] == '%' ) { |
| 4863 | 4862 | // Find numbered arguments or take the next one in order |
| 4864 | 4863 | if ( preg_match( '/^%(\d+)\$/', $fragment, $matches ) ) { |
| 4865 | | $arg = isset( $args[ $matches[1] ] ) ? $args[ $matches[1] ] : ''; |
| | 4864 | $index = $matches[1] - 1; // 0-based array vs 1-based sprintf arguments. |
| | 4865 | $arg = isset( $args[ $index ] ) ? $args[ $index ] : ''; |
| 4866 | 4866 | $fragment = str_replace( "%{$matches[1]}$", '%', $fragment ); |
| 4867 | 4867 | } else { |
| 4868 | | ++$arg_index; |
| 4869 | 4868 | $arg = isset( $args[ $arg_index ] ) ? $args[ $arg_index ] : ''; |
| | 4869 | ++$arg_index; |
| 4870 | 4870 | } |
| 4871 | 4871 | |
| 4872 | 4872 | /** |