Skip to content

Commit

Permalink
Merge branch 'main' into feat/compatibility-layer
Browse files Browse the repository at this point in the history
  • Loading branch information
al-esc authored Jul 25, 2024
2 parents 27ab9b0 + b4dbc57 commit 3e10ed4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
24 changes: 21 additions & 3 deletions inc/network/includes-network.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<div class="error inline"><p><strong>' . __( 'Warning:' ) . '</strong> ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</p></div>';
}

return '';
}

/**
* Prints step 1 for Network installation process.
*
Expand Down Expand Up @@ -231,7 +247,7 @@ function network_step1( $errors = false ) {
endif;

if ( WP_CONTENT_DIR !== ABSPATH . 'wp-content' && ( allow_subdirectory_install() || ! allow_subdomain_install() ) ) {
echo '<div class="error inline"><p><strong>' . esc_html__( 'Warning:' ) . '</strong> ' . esc_html__( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</p></div>';
echo esc_html( pantheon_get_subdirectory_networks_message() );
}

$is_www = ( 0 === strpos( $hostname, 'www.' ) );
Expand Down Expand Up @@ -595,7 +611,8 @@ function network_step2( $errors = false ) {
);
echo '</p>';
if ( ! $subdomain_install && WP_CONTENT_DIR !== ABSPATH . 'wp-content' ) {
echo '<p><strong>' . esc_html__( 'Warning:' ) . ' ' . esc_html__( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
// Display the subdirectory networks message unless filtered.
echo esc_html( pantheon_get_subdirectory_networks_message() );
}
?>
<p class="configuration-rules-label"><label for="network-webconfig-rules">
Expand Down Expand Up @@ -657,7 +674,8 @@ function network_step2( $errors = false ) {
);
echo '</p>';
if ( ! $subdomain_install && WP_CONTENT_DIR !== ABSPATH . 'wp-content' ) {
echo '<p><strong>' . esc_html__( 'Warning:' ) . ' ' . esc_html__( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
// Display the subdirectory networks message unless filtered.
echo esc_html( pantheon_get_subdirectory_networks_message() );
}
?>
<p class="configuration-rules-label"><label for="network-htaccess-rules">
Expand Down
10 changes: 10 additions & 0 deletions tests/phpunit/test-network.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,14 @@ public function test_get_clean_basedomain() {
public function test_pantheon_remove_network_setup() {
$this->assertNull( Pantheon\NetworkSetup\pantheon_remove_network_setup() );
}

public function test_disable_subdirectory_custom_wp_content_warning() {
// Test the default condition.
$this->assertNotEmpty( pantheon_get_subdirectory_networks_message() );
}

public function test_disable_subdirectory_custom_wp_content_warning_filtered() {
add_filter( 'pantheon.enable_subdirectory_networks_message', '__return_false' );
$this->assertEmpty( pantheon_get_subdirectory_networks_message() );
}
}

0 comments on commit 3e10ed4

Please sign in to comment.