Skip to content

Commit

Permalink
Plugin init: Ensure files relying on translations are called after `p…
Browse files Browse the repository at this point in the history
…lugins_loaded`.

Translation data may not be immediately available until WordPress has finished initializing. Moving all calls that happen before this that contain translation functions within an action hook to ensure correct load orders will let both WordPress core, and any translation plugins used, get ready before the plugin needs them.

Props @swisspidy, @Zodiac1978, @ipajen.
Fixes #448.
  • Loading branch information
Clorith committed Aug 6, 2023
1 parent da19f5c commit 7027a10
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions health-check.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,28 @@
}
}

// Include class-files used by our plugin.
require_once( dirname( __FILE__ ) . '/HealthCheck/class-health-check.php' );
require_once( dirname( __FILE__ ) . '/HealthCheck/class-health-check-loopback.php' );
require_once( dirname( __FILE__ ) . '/HealthCheck/class-health-check-screenshots.php' );
require_once( dirname( __FILE__ ) . '/HealthCheck/class-health-check-troubleshoot.php' );
add_action( 'plugins_loaded', function() {

Check failure on line 61 in health-check.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Opening parenthesis of a multi-line function call must be the last content on the line

Check failure on line 61 in health-check.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Only one argument is allowed per line in a multi-line function call
// Include class-files used by our plugin.
require_once( dirname( __FILE__ ) . '/HealthCheck/class-health-check.php' );
require_once( dirname( __FILE__ ) . '/HealthCheck/class-health-check-loopback.php' );
require_once( dirname( __FILE__ ) . '/HealthCheck/class-health-check-screenshots.php' );
require_once( dirname( __FILE__ ) . '/HealthCheck/class-health-check-troubleshoot.php' );

// Tools section.
require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-tool.php' );
require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-files-integrity.php' );
require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-mail-check.php' );
require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-debug-log-viewer.php' );
require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-plugin-compatibility.php' );
require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-phpinfo.php' );
require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-htaccess.php' );
require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-robotstxt.php' );
require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-beta-features.php' );
// Tools section.
require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-tool.php' );
require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-files-integrity.php' );
require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-mail-check.php' );
require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-debug-log-viewer.php' );
require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-plugin-compatibility.php' );
require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-phpinfo.php' );
require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-htaccess.php' );
require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-robotstxt.php' );
require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-beta-features.php' );

// Initialize our plugin.
new Health_Check();
// Initialize our plugin.
new Health_Check();

if ( defined( 'WP_CLI' ) && WP_CLI ) {
require_once( dirname( __FILE__ ) . '/HealthCheck/class-cli.php' );
}
if ( defined( 'WP_CLI' ) && WP_CLI ) {
require_once( dirname( __FILE__ ) . '/HealthCheck/class-cli.php' );
}
} );

Check failure on line 85 in health-check.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Closing parenthesis of a multi-line function call must be on a line by itself

2 comments on commit 7027a10

@Zodiac1978
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one "s" missing for Pascals' GitHub handle @swissspidy - just to be sure he gets the props :)

@swissspidy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes the curse of my username :-)

Please sign in to comment.