diff --git a/.wp-env/mu-plugin.php b/.wp-env/mu-plugin.php index c4d2eb60..47143492 100644 --- a/.wp-env/mu-plugin.php +++ b/.wp-env/mu-plugin.php @@ -15,6 +15,17 @@ function is_special_user( $user_id ) { } require_once __DIR__ . '/pub/mu-plugins/loader.php'; +// needs to work in both envs + // wpmupluginsdir constant - wont in local tests b/c points to $_tests_dir + // rel path doesn't work b/c wpenv maps to different dir than what actually exists on FS when checking repo directly + + // wpenv web + // wpenv test + // local web + // local test + + // this is getting too time consuming + // should maybe just use wpenv like everyone else, but it doesn't work well for me // Enable dummy provider for convenience when running locally. add_filter( 'two_factor_providers', function( $providers ) { @@ -43,4 +54,4 @@ function is_special_user( $user_id ) { add_action( 'wp_install', function() { update_option( 'template', 'wporg-support' ); update_option( 'stylesheet', 'wporg-support' ); -} ); \ No newline at end of file +} ); diff --git a/README.md b/README.md index aae345aa..921365de 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,16 @@ WordPress.org-specific customizations for the Two Factor plugin ## Setup +TODO: a lot of this isn't needed for wp-env users, so maybe branch the instructions based on which env they want to use + 1. Set up a local WP site. 1. Add this code to your `wp-config.php`: ```php define( 'WP_ENVIRONMENT_TYPE', 'local' ); + // TODO can remove all this and include .wpenv/muplugin.php instead // Mimic w.org for testing wporg-two-factor - global $supes, $super_admins; + ``` -1. Install and build the `wporg-mu-plugins` repository. +1. `git clone https://github.com/WordPress/wporg-mu-plugins.git --branch build wp-content/mu-plugins/pub` 1. Add this code to your `wp-content/mu-plugins/0-sandbox.php`: ```php - require_once WPMU_PLUGIN_DIR. '/wporg-mu-plugins/mu-plugins/loader.php'; + require_once WPMU_PLUGIN_DIR . '/wporg-mu-plugins/mu-plugins/loader.php'; + + /// replace all this w/ just loading wpenv // Enable dummy provider for convenience when testing locally. add_filter( 'two_factor_providers', function( $providers ) { diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 42f240f4..360e7896 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -40,7 +40,21 @@ function _manually_load_plugin() { // Mimic w.org capes.php. $GLOBALS['super_admins'] = array(); - require_once dirname( __DIR__, 3 ) . '/mu-plugins//wporg-mu-plugins/mu-plugins/loader.php'; + // $wp_content_dir = dirname( __DIR__, 3 ); // Not `WP_CONTENT_DIR` because that would be the $_tests_dir, which may be different. + // $is_wp_env = defined( 'WP_ENV' ); + // exists? need to add custom to wpenv.json? or diff way to detect + + // don't need this is setup env to match, update instructions + + // won't need this if get local env setup to match docker env, and update readme to document that + // if ( ! function_exists( 'wporg_encrypt' ) ) { + // try { + // require_once dirname( __DIR__, 3 ) . '/mu-plugins/wporg-mu-plugins/mu-plugins/loader.php'; + // } catch ( Exception $exception ) { + // die( 'ERROR: not load wporg-mu-plugins. See README for setup instructions.' ); + // } + // } + require dirname( __DIR__, 2 ) . '/two-factor/two-factor.php'; require dirname( __DIR__ ) . '/wporg-two-factor.php'; }