Make WordPress Core


Ignore:
Timestamp:
08/26/2021 12:57:08 PM (3 years ago)
Author:
hellofromTonya
Message:

Coding Standards: Use static closures when not using $this.

When a closure does not use $this, it can be made static for improved performance.

Static closures are supported in PHP since PHP 5.4. ​

Props jrf, hellofromTonya, swissspidy, SergeyBiryukov.
See #53359.

File:
1 edited

Legend:

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

    r51294 r51657  
    154154                    'section'         => 'colors',
    155155                    'priority'        => 100,
    156                     'active_callback' => function() {
     156                    'active_callback' => static function() {
    157157                        return 127 >= Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( get_theme_mod( 'background_color', 'D1E4DD' ) );
    158158                    },
     
    166166                'capability'        => 'edit_theme_options',
    167167                'default'           => false,
    168                 'sanitize_callback' => function( $value ) {
     168                'sanitize_callback' => static function( $value ) {
    169169                    return (bool) $value;
    170170                },
     
    189189                'priority'        => 110,
    190190                'description'     => $description,
    191                 'active_callback' => function( $value ) {
     191                'active_callback' => static function( $value ) {
    192192                    return 127 < Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( get_theme_mod( 'background_color', 'D1E4DD' ) );
    193193                },
Note: See TracChangeset for help on using the changeset viewer.