Make WordPress Core

Ticket #56513: 56513-themes.2.patch

File 56513-themes.2.patch, 7.5 KB (added by jrf, 2 years ago)

Optional patch to add the new attribute to the WP native themes

  • src/wp-content/themes/twentyfourteen/inc/featured-content.php

    From ba5a28932822c70970b9bd298fd560101709bc09 Mon Sep 17 00:00:00 2001
    From: jrfnl <jrfnl@users.noreply.github.com>
    Date: Sun, 9 Oct 2022 20:00:16 +0200
    Subject: [PATCH] Code Modernization: Add `AllowDynamicProperties` attribute to
     all (parent) classes in themes.
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.
    
    To reduce “noise” in the meantime, both in the error logs of WP users moving onto PHP 8.2, in the test run logs of WP itself, in test runs of plugins and themes, as well as to prevent duplicate tickets from being opened for the same issue, this commit adds the `#[AllowDynamicProperties]` attribute to all “parent” classes in WP.
    
    This commit is an update to the prior patch as committed in [54133] and specifically addresses the WP native themes.
    
    This commit only affects classes in the `src` directory of WordPress core.
    * Tests should not get this attribute, but should be fixed to not use dynamic properties instead. Patches for this are already being committed under ticket #56033.
    
    Reference: [https://wiki.php.net/rfc/deprecate_dynamic_properties PHP RFC: Deprecate dynamic properties].
    
    Follow-up to [53922], [54133].
    
    See #56513, #56034.
    ---
     src/wp-content/themes/twentyfourteen/inc/featured-content.php    | 1 +
     .../twentynineteen/classes/class-twentynineteen-svg-icons.php    | 1 +
     .../themes/twentytwenty/classes/class-twentytwenty-customize.php | 1 +
     .../classes/class-twentytwenty-non-latin-languages.php           | 1 +
     .../twentytwenty/classes/class-twentytwenty-script-loader.php    | 1 +
     .../themes/twentytwenty/classes/class-twentytwenty-svg-icons.php | 1 +
     .../classes/class-twenty-twenty-one-custom-colors.php            | 1 +
     .../classes/class-twenty-twenty-one-customize.php                | 1 +
     .../classes/class-twenty-twenty-one-dark-mode.php                | 1 +
     .../classes/class-twenty-twenty-one-svg-icons.php                | 1 +
     10 files changed, 10 insertions(+)
    
    diff --git a/src/wp-content/themes/twentyfourteen/inc/featured-content.php b/src/wp-content/themes/twentyfourteen/inc/featured-content.php
    index da8b76f715..5b35a4bad1 100644
    a b  
    1010 * this tag now has special meaning beyond that of a normal tags, users
    1111 * will have the ability to hide it from the front end of their site.
    1212 */
     13#[AllowDynamicProperties]
    1314class Featured_Content {
    1415
    1516        /**
  • src/wp-content/themes/twentynineteen/classes/class-twentynineteen-svg-icons.php

    diff --git a/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-svg-icons.php b/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-svg-icons.php
    index aa2ebf27bb..2d38ee901f 100644
    a b  
    1919 *
    2020 * @since Twenty Nineteen 1.0
    2121 */
     22#[AllowDynamicProperties]
    2223class TwentyNineteen_SVG_Icons {
    2324
    2425        /**
  • src/wp-content/themes/twentytwenty/classes/class-twentytwenty-customize.php

    diff --git a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-customize.php b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-customize.php
    index d4b21ece58..265b2852f8 100644
    a b if ( ! class_exists( 'TwentyTwenty_Customize' ) ) { 
    1313         *
    1414         * @since Twenty Twenty 1.0
    1515         */
     16        #[AllowDynamicProperties]
    1617        class TwentyTwenty_Customize {
    1718
    1819                /**
  • src/wp-content/themes/twentytwenty/classes/class-twentytwenty-non-latin-languages.php

    diff --git a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-non-latin-languages.php b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-non-latin-languages.php
    index e5a7f0dc74..a934319ae1 100644
    a b if ( ! class_exists( 'TwentyTwenty_Non_Latin_Languages' ) ) { 
    1515         *
    1616         * @since Twenty Twenty 1.0
    1717         */
     18        #[AllowDynamicProperties]
    1819        class TwentyTwenty_Non_Latin_Languages {
    1920
    2021                /**
  • src/wp-content/themes/twentytwenty/classes/class-twentytwenty-script-loader.php

    diff --git a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-script-loader.php b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-script-loader.php
    index 0327420471..e5b36fc567 100644
    a b if ( ! class_exists( 'TwentyTwenty_Script_Loader' ) ) { 
    1717         *
    1818         * @since Twenty Twenty 1.0
    1919         */
     20        #[AllowDynamicProperties]
    2021        class TwentyTwenty_Script_Loader {
    2122
    2223                /**
  • src/wp-content/themes/twentytwenty/classes/class-twentytwenty-svg-icons.php

    diff --git a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-svg-icons.php b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-svg-icons.php
    index 714b3a1454..6ead5a43de 100644
    a b if ( ! class_exists( 'TwentyTwenty_SVG_Icons' ) ) { 
    1414         *
    1515         * @since Twenty Twenty 1.0
    1616         */
     17        #[AllowDynamicProperties]
    1718        class TwentyTwenty_SVG_Icons {
    1819                /**
    1920                 * GET SVG CODE
  • src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-custom-colors.php

    diff --git a/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-custom-colors.php b/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-custom-colors.php
    index 3b6833c388..3ccba339ac 100644
    a b  
    1010/**
    1111 * This class is in charge of color customization via the Customizer.
    1212 */
     13#[AllowDynamicProperties]
    1314class Twenty_Twenty_One_Custom_Colors {
    1415
    1516        /**
  • src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-customize.php

    diff --git a/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-customize.php b/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-customize.php
    index 4a0fe6f7af..3de3f36d29 100644
    a b if ( ! class_exists( 'Twenty_Twenty_One_Customize' ) ) { 
    1313         *
    1414         * @since Twenty Twenty-One 1.0
    1515         */
     16        #[AllowDynamicProperties]
    1617        class Twenty_Twenty_One_Customize {
    1718
    1819                /**
  • src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-dark-mode.php

    diff --git a/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-dark-mode.php b/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-dark-mode.php
    index 6955fc7c1b..4bdf9abca4 100644
    a b  
    1010/**
    1111 * This class is in charge of Dark Mode.
    1212 */
     13#[AllowDynamicProperties]
    1314class Twenty_Twenty_One_Dark_Mode {
    1415
    1516        /**
  • src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-svg-icons.php

    diff --git a/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-svg-icons.php b/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-svg-icons.php
    index 3a82cf76ab..a601b75a34 100644
    a b  
    1919 *
    2020 * @since Twenty Twenty-One 1.0
    2121 */
     22#[AllowDynamicProperties]
    2223class Twenty_Twenty_One_SVG_Icons {
    2324
    2425        /**