Make WordPress Core

Ticket #53858: 53858-3.patch

File 53858-3.patch, 2.7 KB (added by ayeshrajans, 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 ) { 
    48144814 * Compares the first two arguments and if identical marks as readonly
    48154815 *
    48164816 * @since 4.9.0
     4817 * @since 5.9.0 This function was renamed from `readonly`.
    48174818 *
    48184819 * @param mixed $readonly One of the values to compare
    48194820 * @param mixed $current  (true) The other value to compare if not just true
    48204821 * @param bool  $echo     Whether to echo or just return the string
    48214822 * @return string HTML attribute or empty string
    48224823 */
    4823 function readonly( $readonly, $current = true, $echo = true ) {
     4824function wp_readonly( $readonly, $current = true, $echo = true ) {
    48244825        return __checked_selected_helper( $readonly, $current, $echo, 'readonly' );
    48254826}
    48264827
     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 */
     4835if (PHP_VERSION_ID < 80100) {
     4836        require_once __DIR__ . '/php-compat/readonly.php';
     4837}
     4838
    48274839/**
    48284840 * Private helper function for checked, selected, disabled and readonly.
    48294841 *
  • 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 */
     31function readonly( $readonly, $current = true, $echo = true ) {
     32        _deprecated_function( __FUNCTION__, '5.9.0' );
     33        return wp_readonly( $readonly, $current, $echo );
     34}