From 92a5da955b327ac5197024238b763ec16e60b8d8 Mon Sep 17 00:00:00 2001 From: wpmuguru Date: Sat, 8 May 2010 15:25:33 +0000 Subject: [PATCH] add network install rule, filter & UI tweaks, see #12931 git-svn-id: http://svn.automattic.com/wordpress/trunk@14513 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/network.php | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/wp-admin/network.php b/wp-admin/network.php index 5b671e791..fc9080d90 100644 --- a/wp-admin/network.php +++ b/wp-admin/network.php @@ -49,6 +49,23 @@ function allow_subdomain_install() { return true; } +/** + * Allow folder install + * + * @since 3.0.0 + * @return bool Whether folder install is allowed + */ +function allow_folder_install() { + global $wpdb; + if ( apply_filters( 'allow_folder_install', false ) ) + return true; + + $post = $wpdb->get_row( "SELECT ID FROM $wpdb->posts WHERE post_date < DATE_SUB(NOW(), INTERVAL 1 MONTH) AND post_status = 'publish'" ); + if ( empty( $post ) ) + return true; + + return false; +} /** * Get base domain of network. * @@ -108,10 +125,7 @@ function network_step1( $errors = false ) { $has_ports = strstr( $hostname, ':' ); if ( ( false !== $has_ports && ! in_array( $has_ports, array( ':80', ':443' ) ) ) ) { echo '

' . __( 'Error:') . ' ' . __( 'You cannot install a network of sites with your server address.' ) . '

'; - if ( $no_ip ) - echo '

' . __( 'You cannot use an IP address such as 127.0.0.1.' ) . '

'; - else - echo '

' . sprintf( __( 'You cannot use port numbers such as %s.' ), $has_ports ) . '

'; + echo '

' . sprintf( __( 'You cannot use port numbers such as %s.' ), $has_ports ) . '

'; echo '' . __( 'Return to Dashboard' ) . ''; include( './admin-footer.php' ); die(); @@ -140,6 +154,8 @@ function network_step1( $errors = false ) { $subdomain_install = (bool) $_POST['subdomain_install']; } elseif ( apache_mod_loaded('mod_rewrite') ) { // assume nothing $subdomain_install = true; + } elseif ( !allow_folder_install() ) { + $subdomain_install = true; } else { $subdomain_install = false; if ( got_mod_rewrite() ) // dangerous assumptions @@ -149,7 +165,7 @@ function network_step1( $errors = false ) { echo '

' . __( 'If mod_rewrite is disabled, ask your administrator to enable that module, or look at the Apache documentation or elsewhere for help setting it up.' ) . '

'; } - if ( allow_subdomain_install() ) : ?> + if ( allow_subdomain_install() && allow_folder_install() ) : ?>

You cannot change this later.' ); ?>

@@ -237,7 +253,7 @@ function network_step2( $errors = false ) { echo '
' . $errors->get_error_message() . '
'; if ( $_POST ) { - $subdomain_install = allow_subdomain_install() ? ! empty( $_POST['subdomain_install'] ) : false; + $subdomain_install = allow_subdomain_install() ? ( allow_folder_install() ? ! empty( $_POST['subdomain_install'] ) : true ) : false; } else { if ( is_multisite() ) { $subdomain_install = is_subdomain_install(); @@ -332,7 +348,7 @@ $htaccess_file .= "\nRewriteRule . index.php [L]"; -

+