Ticket #53858: 53858-3.patch
File 53858-3.patch, 2.7 KB (added by , 3 years ago) |
---|
-
src/wp-includes/general-template.php
diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php index ab8877f7be..b4a00eadd1 100644
a b function disabled( $disabled, $current = true, $echo = true ) { 4814 4814 * Compares the first two arguments and if identical marks as readonly 4815 4815 * 4816 4816 * @since 4.9.0 4817 * @since 5.9.0 This function was renamed from `readonly`. 4817 4818 * 4818 4819 * @param mixed $readonly One of the values to compare 4819 4820 * @param mixed $current (true) The other value to compare if not just true 4820 4821 * @param bool $echo Whether to echo or just return the string 4821 4822 * @return string HTML attribute or empty string 4822 4823 */ 4823 function readonly( $readonly, $current = true, $echo = true ) {4824 function wp_readonly( $readonly, $current = true, $echo = true ) { 4824 4825 return __checked_selected_helper( $readonly, $current, $echo, 'readonly' ); 4825 4826 } 4826 4827 4828 /** 4829 * Include a compat `readonly` function on PHP < 8.1. Since PHP 8.1, 4830 * `readonly` is a reserved keyword, and it is not possible to use 4831 * it as a function name. In order to maintain compatibility with 4832 * existing functions, this function was extracted to a separate file, 4833 * and included on PHP < 8.1. 4834 */ 4835 if (PHP_VERSION_ID < 80100) { 4836 require_once __DIR__ . '/php-compat/readonly.php'; 4837 } 4838 4827 4839 /** 4828 4840 * Private helper function for checked, selected, disabled and readonly. 4829 4841 * -
new file src/wp-includes/php-compat/readonly.php
diff --git a/src/wp-includes/php-compat/readonly.php b/src/wp-includes/php-compat/readonly.php new file mode 100644 index 0000000000..c3e72092c1
- + 1 <?php 2 3 /** 4 * Conditionally declares a `readonly` function, which was renamed to 5 * `wp_readonly` in WordPress 5.9.0. 6 * 7 * In order to avoid PHP parser errors, this function was extracted to 8 * this separate file, and only included conditionally on PHP 8.1. 9 * 10 * Including this file on PHP >= 8.1 results in a fatal error. 11 * 12 * @package WordPress 13 */ 14 15 /** 16 * Outputs the HTML readonly attribute. 17 * 18 * Compares the first two arguments and if identical marks as readonly 19 * 20 * This function is deprecated, and cannot be used on PHP >= 8.1. 21 * @see wp_readonly 22 * 23 * @since 4.9.0 24 * @deprecated 5.9.0 Use `wp_readonly` introduced in 5.9.0. 25 * 26 * @param mixed $readonly One of the values to compare 27 * @param mixed $current (true) The other value to compare if not just true 28 * @param bool $echo Whether to echo or just return the string 29 * @return string HTML attribute or empty string 30 */ 31 function readonly( $readonly, $current = true, $echo = true ) { 32 _deprecated_function( __FUNCTION__, '5.9.0' ); 33 return wp_readonly( $readonly, $current, $echo ); 34 }