diff --git a/pantheon.php b/pantheon.php index c3d9b1b..61a3e3f 100644 --- a/pantheon.php +++ b/pantheon.php @@ -3,36 +3,32 @@ * Plugin Name: Pantheon * Plugin URI: https://pantheon.io/ * Description: Building on Pantheon's and WordPress's strengths, together. - * <<<<<<< HEAD - * Version: 1.4.4 - * ======= * Version: 1.5.0 - * >>>>>>> 05d46a9 (Feature: Add compatibility layer logic and status output.) * Author: Pantheon * Author URI: https://pantheon.io/ * * @package pantheon */ -define('PANTHEON_MU_PLUGIN_VERSION', '1.5.0'); +define( 'PANTHEON_MU_PLUGIN_VERSION', '1.5.0' ); -if (isset($_ENV['PANTHEON_ENVIRONMENT'])) { +if ( isset( $_ENV['PANTHEON_ENVIRONMENT'] ) ) { require_once 'inc/functions.php'; require_once 'inc/pantheon-page-cache.php'; require_once 'inc/site-health.php'; - if (!defined('DISABLE_PANTHEON_UPDATE_NOTICES') || !DISABLE_PANTHEON_UPDATE_NOTICES) { + if ( ! defined( 'DISABLE_PANTHEON_UPDATE_NOTICES' ) || ! DISABLE_PANTHEON_UPDATE_NOTICES ) { require_once 'inc/pantheon-updates.php'; } - if (!defined('RETURN_TO_PANTHEON_BUTTON') || RETURN_TO_PANTHEON_BUTTON) { + if ( ! defined( 'RETURN_TO_PANTHEON_BUTTON' ) || RETURN_TO_PANTHEON_BUTTON ) { require_once 'inc/pantheon-login-form-mods.php'; } - if ('dev' === $_ENV['PANTHEON_ENVIRONMENT'] && function_exists('wp_is_writable')) { + if ( 'dev' === $_ENV['PANTHEON_ENVIRONMENT'] && function_exists( 'wp_is_writable' ) ) { require_once 'inc/pantheon-plugin-install-notice.php'; } - if (defined('WP_CLI') && WP_CLI) { + if ( defined( 'WP_CLI' ) && WP_CLI ) { require_once 'inc/cli.php'; } - if (!defined('FS_METHOD')) { + if ( ! defined( 'FS_METHOD' ) ) { /** * When this constant is not set, WordPress writes and then deletes a * temporary file to determine if it has direct access to the filesystem, @@ -42,21 +38,21 @@ * Setting this constant to 'direct' tells WordPress to assume it has * direct access and skip creating the extra temporary file. */ - define('FS_METHOD', 'direct'); + define( 'FS_METHOD', 'direct' ); } // When developing a WordPress Multisite locally, ensure that this constant is set. // This will set the Multisite variable in all Pantheon environments. - if (getenv('FRAMEWORK') === 'wordpress_network' && !defined('WP_ALLOW_MULTISITE')) { - define('WP_ALLOW_MULTISITE', true); + if ( getenv( 'FRAMEWORK' ) === 'wordpress_network' && ! defined( 'WP_ALLOW_MULTISITE' ) ) { + define( 'WP_ALLOW_MULTISITE', true ); } - if (defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE) { + if ( defined( 'WP_ALLOW_MULTISITE' ) && WP_ALLOW_MULTISITE ) { require_once 'inc/pantheon-network-setup.php'; - if (!defined('MULTISITE') && MULTISITE) { + if ( ! defined( 'MULTISITE' ) && MULTISITE ) { require_once 'inc/pantheon-multisite-finalize.php'; } } - if (!defined('PANTHEON_COMPATIBILITY') || PANTHEON_COMPATIBILITY) { + if ( ! defined( 'PANTHEON_COMPATIBILITY' ) || PANTHEON_COMPATIBILITY ) { require_once 'inc/compatibility/class-compatibilityfactory.php'; Pantheon\Compatibility\CompatibilityFactory::get_instance(); } diff --git a/tests/phpunit/test-compatibility-layer.php b/tests/phpunit/test-compatibility-layer.php index 375ce33..c47071e 100644 --- a/tests/phpunit/test-compatibility-layer.php +++ b/tests/phpunit/test-compatibility-layer.php @@ -6,6 +6,8 @@ */ use Pantheon\Compatibility\CompatibilityFactory; +use Pantheon\Compatibility\ForceLogin; + /** * Pantheon Compatibility Layer Test Case @@ -13,6 +15,7 @@ class Test_Compatibility_Layer extends WP_UnitTestCase { + /** * The original active plugins. * @@ -60,6 +63,22 @@ public function test_instantiate_compatibility_layers() { } } + public function test_compatibility_hooks() { + $this->set_active_plugin( 'wp-force-login/wp-force-login.php' ); + CompatibilityFactory::get_instance(); + global $wp_filter; + $this->assertTrue( array_key_exists( 'deactivate_wp-force-login/wp-force-login.php', $wp_filter ) ); + $hooked_functions = array_column($wp_filter['deactivate_wp-force-login/wp-force-login.php']->callbacks[10], + 'function'); + $function_names = array_column( $hooked_functions, 0 ); + $this->assertInstanceOf( ForceLogin::class, $function_names[0] ); + } + + private function set_active_plugin( $plugin ) { + update_option( 'active_plugins', $plugin ); + wp_cache_delete( 'plugins', 'plugins' ); + } + public function test_daily_pantheon_cron() { $this->set_active_plugin( 'wp-force-login/wp-force-login.php' ); $this->compatibility_factory->daily_pantheon_cron(); @@ -68,9 +87,4 @@ public function test_daily_pantheon_cron() { $this->assertIsArray( $applied_fixes ); $this->assertArrayHasKey( 'wp-force-login/wp-force-login.php', $applied_fixes ); } - - private function set_active_plugin( $plugin ) { - update_option( 'active_plugins', $plugin ); - wp_cache_delete( 'plugins', 'plugins' ); - } }