Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SITE-372] allow subdirectory networks warning to be filtered #51

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions pantheon.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
* Plugin Name: Pantheon
* Plugin URI: https://pantheon.io/
* Description: Building on Pantheon's and WordPress's strengths, together.
* Version: 1.4.4
* Version: 1.4.5
* Author: Pantheon
* Author URI: https://pantheon.io/
*
* @package pantheon
*/

define( 'PANTHEON_MU_PLUGIN_VERSION', '1.4.4' );
define( 'PANTHEON_MU_PLUGIN_VERSION', '1.4.5' );

if ( isset( $_ENV['PANTHEON_ENVIRONMENT'] ) ) {
require_once 'inc/functions.php';
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() );
}
}