Make WordPress Core

Changeset 55633

Timestamp:
04/08/2023 09:03:08 AM (16 months ago)
Author:
SergeyBiryukov
Message:

Twenty Twenty-One: Replace include_once with require_once for required classes.

Per WordPress PHP coding standards, it is strongly recommended to use require[_once] for unconditional includes. When using include[_once], PHP will throw a warning when the file is not found but will continue execution, which will almost certainly lead to other errors/warnings/notices being thrown if your application depends on the file loaded, potentially leading to security leaks. For that reason, require[_once] is generally the better choice as it will throw a Fatal Error if the file cannot be found.

Follow-up to [49216], [49633].

Props wpfy.
See #57839.

Location:
trunk/src/wp-content/themes/twentytwentyone/classes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-customize.php

    r51657 r55633  
    114114            // Background color.
    115115            // Include the custom control class.
    116             include_once get_theme_file_path( 'classes/class-twenty-twenty-one-customize-color-control.php' ); // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound
     116            e_once get_theme_file_path( 'classes/class-twenty-twenty-one-customize-color-control.php' ); // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound
    117117
    118118            // Register the custom control.
  • trunk/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-dark-mode.php

    r55413 r55633  
    136136
    137137        // Custom notice control.
    138         include_once get_theme_file_path( 'classes/class-twenty-twenty-one-customize-notice-control.php' ); // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound
     138        e_once get_theme_file_path( 'classes/class-twenty-twenty-one-customize-notice-control.php' ); // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound
    139139
    140140        $wp_customize->add_setting(
Note: See TracChangeset for help on using the changeset viewer.