Skip to content

Commit

Permalink
Prefer "require_once" in a few spots.
Browse files Browse the repository at this point in the history
This change prevents unintended PHP warnings when silly JJJ people are doing silly JJJ things.

Fixes #594.
  • Loading branch information
JJJ authored Feb 29, 2024
1 parent 2b0d9bc commit e802bd9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions class-two-factor-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public static function get_providers() {
* For each filtered provider,
*/
foreach ( $providers as $provider_key => $path ) {
include_once $path;
require_once $path;

$class = $provider_key;

Expand Down Expand Up @@ -785,7 +785,7 @@ public static function login_html( $user, $login_nonce, $redirect_to, $error_msg

if ( ! function_exists( 'login_header' ) ) {
// We really should migrate login_header() out of `wp-login.php` so it can be called from an includes file.
include_once TWO_FACTOR_DIR . 'includes/function.login-header.php';
require_once TWO_FACTOR_DIR . 'includes/function.login-header.php';
}

// Disable the language switcher.
Expand Down Expand Up @@ -913,7 +913,7 @@ function() {
</script>
<?php
if ( ! function_exists( 'login_footer' ) ) {
include_once TWO_FACTOR_DIR . 'includes/function.login-footer.php';
require_once TWO_FACTOR_DIR . 'includes/function.login-footer.php';
}

login_footer();
Expand Down
4 changes: 2 additions & 2 deletions providers/class-two-factor-fido-u2f-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public static function show_user_profile( $user ) {
<p><a href="https://support.google.com/accounts/answer/6103523"><?php esc_html_e( 'You can find FIDO U2F Security Key devices for sale from here.', 'two-factor' ); ?></a></p>

<?php
require TWO_FACTOR_DIR . 'providers/class-two-factor-fido-u2f-admin-list-table.php';
require_once TWO_FACTOR_DIR . 'providers/class-two-factor-fido-u2f-admin-list-table.php';
$u2f_list_table = new Two_Factor_FIDO_U2F_Admin_List_Table();
$u2f_list_table->items = $security_keys;
$u2f_list_table->prepare_items();
Expand Down Expand Up @@ -328,7 +328,7 @@ public static function delete_link( $item ) {
public static function wp_ajax_inline_save() {
check_ajax_referer( 'keyinlineeditnonce', '_inline_edit' );

require TWO_FACTOR_DIR . 'providers/class-two-factor-fido-u2f-admin-list-table.php';
require_once TWO_FACTOR_DIR . 'providers/class-two-factor-fido-u2f-admin-list-table.php';
$wp_list_table = new Two_Factor_FIDO_U2F_Admin_List_Table();

if ( ! isset( $_POST['keyHandle'] ) ) {
Expand Down
4 changes: 2 additions & 2 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
tests_add_filter(
'muplugins_loaded',
function() {
require dirname( __DIR__ ) . '/two-factor.php';
require_once dirname( __DIR__ ) . '/two-factor.php';
}
);

// Start up the WP testing environment.
require getenv( 'WP_PHPUNIT__DIR' ) . '/includes/bootstrap.php';
require_once getenv( 'WP_PHPUNIT__DIR' ) . '/includes/bootstrap.php';

0 comments on commit e802bd9

Please sign in to comment.