From b4dbc5777622043c4089c7707f83fe7d17fbf1c9 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Fri, 19 Jul 2024 12:54:52 -0600 Subject: [PATCH] [SITE-372] allow subdirectory networks warning to be filtered (#51) * add a new function for the message the message applies the filter so the individual calls don't need to do a check * add a test for the function and filter * update the @\since tag * bump the version * update the error message so it's standardized across all implementations it's not actually standard in the source because WP is dumb and no one looks at this page. * break test cases out into separate tests. Co-authored-by: Phil Tyler * fix linting --------- Co-authored-by: Phil Tyler --- inc/network/includes-network.php | 24 +++++++++++++++++++++--- pantheon.php | 4 ++-- tests/phpunit/test-network.php | 10 ++++++++++ 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/inc/network/includes-network.php b/inc/network/includes-network.php index fefa86b..a38957e 100644 --- a/inc/network/includes-network.php +++ b/inc/network/includes-network.php @@ -99,6 +99,22 @@ function get_clean_basedomain() { return $domain; } +/** + * Returns the warning message about subdirectory multisites not liking custom wp-content directories. + * + * Applies the 'pantheon.subdirectory_networks_message' filter. + * + * @since 1.4.5 + * @return string Warning message or empty string. + */ +function pantheon_get_subdirectory_networks_message() { + if ( apply_filters( 'pantheon.enable_subdirectory_networks_message', true ) ) { + return '

' . __( 'Warning:' ) . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '

'; + } + + return ''; +} + /** * Prints step 1 for Network installation process. * @@ -231,7 +247,7 @@ function network_step1( $errors = false ) { endif; if ( WP_CONTENT_DIR !== ABSPATH . 'wp-content' && ( allow_subdirectory_install() || ! allow_subdomain_install() ) ) { - echo '

' . esc_html__( 'Warning:' ) . ' ' . esc_html__( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '

'; + echo esc_html( pantheon_get_subdirectory_networks_message() ); } $is_www = ( 0 === strpos( $hostname, 'www.' ) ); @@ -595,7 +611,8 @@ function network_step2( $errors = false ) { ); echo '

'; if ( ! $subdomain_install && WP_CONTENT_DIR !== ABSPATH . 'wp-content' ) { - echo '

' . esc_html__( 'Warning:' ) . ' ' . esc_html__( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '

'; + // Display the subdirectory networks message unless filtered. + echo esc_html( pantheon_get_subdirectory_networks_message() ); } ?>

'; if ( ! $subdomain_install && WP_CONTENT_DIR !== ABSPATH . 'wp-content' ) { - echo '

' . esc_html__( 'Warning:' ) . ' ' . esc_html__( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '

'; + // Display the subdirectory networks message unless filtered. + echo esc_html( pantheon_get_subdirectory_networks_message() ); } ?>