Make WordPress Core

Changeset 56552


Ignore:
Timestamp:
09/11/2023 04:51:09 AM (14 months ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Use dirname() with the $levels parameter.

PHP 7.0 introduced the $levels parameter to the dirname() function, which means nested calls to dirname() are no longer needed.

Note: This is enforced by WPCS 3.0.0.

Reference: PHP Manual: dirname().

Follow-up to [56141].

Props jrf.
See #59161, #58831.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/theme.php

    r56245 r56552  
    157157 */
    158158function _get_template_edit_filename( $fullpath, $containingfolder ) {
    159     return str_replace( dirname( dirname( $containingfolder ) ), '', $fullpath );
     159    return str_replace( dirname( $containingfolder, 2 ), '', $fullpath );
    160160}
    161161
  • trunk/src/wp-admin/maint/repair.php

    r55645 r56552  
    88define( 'WP_REPAIRING', true );
    99
    10 require_once dirname( dirname( __DIR__ ) ) . '/wp-load.php';
     10require_once dirname( __DIR__, 2 ) . '/wp-load.php';
    1111
    1212header( 'Content-Type: text/html; charset=utf-8' );
  • trunk/tests/phpunit/includes/bootstrap.php

    r56547 r56552  
    1111        // Support the config file from the root of the develop repository.
    1212        if ( basename( $config_file_path ) === 'phpunit' && basename( dirname( $config_file_path ) ) === 'tests' ) {
    13             $config_file_path = dirname( dirname( $config_file_path ) );
     13            $config_file_path = dirname( $config_file_path, 2 );
    1414        }
    1515    }
     
    8080if ( ! class_exists( 'Yoast\PHPUnitPolyfills\Autoload' ) ) {
    8181    // Default location of the autoloader for WP core test runs.
    82     $phpunit_polyfills_autoloader = dirname( dirname( dirname( __DIR__ ) ) ) . '/vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php';
     82    $phpunit_polyfills_autoloader = dirname( __DIR__, 3 ) . '/vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php';
    8383    $phpunit_polyfills_error      = false;
    8484
  • trunk/tests/phpunit/tests/filesystem/base.php

    r52010 r56552  
    2525    }
    2626    public function filter_abstraction_file( $file ) {
    27         return dirname( dirname( __DIR__ ) ) . '/includes/mock-fs.php';
     27        return dirname( __DIR__, 2 ) . '/includes/mock-fs.php';
    2828    }
    2929
  • trunk/tests/phpunit/tests/pomo/pluralForms.php

    r56549 r56552  
    4444     */
    4545    public function test_regression( $lang, $nplurals, $expression ) {
    46         require_once dirname( dirname( __DIR__ ) ) . '/includes/plural-form-function.php';
     46        require_once dirname( __DIR__, 2 ) . '/includes/plural-form-function.php';
    4747
    4848        $parenthesized = self::parenthesize_plural_expression( $expression );
Note: See TracChangeset for help on using the changeset viewer.