Make WordPress Core

Ticket #53858: 53858-2.patch

File 53858-2.patch, 2.7 KB (added by ayeshrajans, 3 years ago)

Last patch errornously said @subpackage oEmbed. Fixed in this one.

  • new file src/wp-includes/PHP_Compat/readonly.php

    commit 5c0cef40980e721b6196f5aa776f050ca1158dc7
    Author: Ayesh Karunaratne <ayesh@aye.sh>
    Date:   Mon Aug 2 19:51:55 2021 +0530
    
        Extract readonly function
    
    diff --git a/src/wp-includes/PHP_Compat/readonly.php b/src/wp-includes/PHP_Compat/readonly.php
    new file mode 100644
    index 0000000000..a82c0b6c11
    - +  
     1<?php
     2
     3/**
     4 * Conditionally declares a `readonly` function, which was renamed to
     5 * `wp_readonly` in WordPress 5.9.
     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
     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        return wp_readonly( $readonly, $current, $echo );
     33}
  • src/wp-includes/general-template.php

    diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php
    index ab8877f7be..d54441cab5 100644
    a b function disabled( $disabled, $current = true, $echo = true ) { 
    48134813 *
    48144814 * Compares the first two arguments and if identical marks as readonly
    48154815 *
    4816  * @since 4.9.0
     4816 * @since 5.9.0
    48174817 *
    48184818 * @param mixed $readonly One of the values to compare
    48194819 * @param mixed $current  (true) The other value to compare if not just true
    48204820 * @param bool  $echo     Whether to echo or just return the string
    48214821 * @return string HTML attribute or empty string
    48224822 */
    4823 function readonly( $readonly, $current = true, $echo = true ) {
     4823function wp_readonly( $readonly, $current = true, $echo = true ) {
    48244824        return __checked_selected_helper( $readonly, $current, $echo, 'readonly' );
    48254825}
    48264826
     4827/**
     4828 * Include a compat `readonly` function on PHP < 8.1. Since PHP 8.1,
     4829 * `readonly` is a reserved keyword, and it is not possible to use
     4830 * it as a function name. In order to maintain compatibility with
     4831 * existing functions, this function was extracted to a separate file,
     4832 * and included on PHP < 8.1.
     4833 */
     4834if (PHP_VERSION_ID < 80100) {
     4835        require_once __DIR__ . '/PHP_Compat/readonly.php';
     4836}
     4837
     4838
    48274839/**
    48284840 * Private helper function for checked, selected, disabled and readonly.
    48294841 *