コード例 #1
0
function jquery_install_site($site, $user)
{
    $sites = jquery_sites();
    $details = $sites[$site];
    if (strpos($site, '/')) {
        list($domain, $path) = explode('/', $site, 2);
        $path = '/' . trim($path, '/') . '/';
    } else {
        $domain = $site;
        $path = '/';
    }
    $default_options = jquery_default_site_options();
    $default_options['admin_email'] = $user->user_email;
    if (1 !== $details['blog_id']) {
        $blog_id = insert_blog(JQUERY_STAGING_PREFIX . $domain, $path, 1);
        if ($blog_id != $details['blog_id']) {
            wp_die("Something went very wrong when trying to install {$domain} as site {$blog_id}-{$details['blog_id']}. Find nacin.");
        }
        switch_to_blog($blog_id);
        install_blog($blog_id, $details['options']['blogname']);
        add_user_to_blog($blog_id, $user->ID, 'administrator');
    }
    $options = array_merge($default_options, $details['options']);
    foreach ($options as $option => $value) {
        update_option($option, $value);
    }
    delete_option('rewrite_rules');
    restore_current_blog();
}
コード例 #2
0
function jquery_install_remaining_sites($user)
{
    $domains = jquery_domains();
    $default_options = jquery_default_site_options();
    $default_options['admin_email'] = $user->user_email;
    foreach ($domains as $domain => $details) {
        if (1 !== $details['blog_id']) {
            $blog_id = insert_blog(JQUERY_STAGING_PREFIX . $domain, '/', 1);
            if ($blog_id != $details['blog_id']) {
                wp_die("Something went very wrong when trying to install {$domain} as site {$blog_id}-{$details['blog_id']}. Find nacin.");
            }
            switch_to_blog($blog_id);
            install_blog($blog_id, $details['options']['blogname']);
            add_user_to_blog($blog_id, $user->ID, 'administrator');
        }
        $options = array_merge($default_options, $details['options']);
        foreach ($options as $option => $value) {
            update_option($option, $value);
        }
        // Work around a superficial bug in install_blog(), fixed in WP r21172.
        $home = untrailingslashit(get_option('home'));
        $siteurl = untrailingslashit(get_option('siteurl'));
        update_option('home', 'http://example.com');
        // Please just don't ask.
        update_option('siteurl', 'http://example.com');
        update_option('home', $home);
        update_option('siteurl', $siteurl);
        flush_rewrite_rules();
        restore_current_blog();
    }
}
コード例 #3
0
<?php
/* Plugin Name: jQuery Filters
 * Description: Default filters, option values, and other tweaks.
 */

if ( defined( 'WP_INSTALLING' ) )
	return;

$options = jquery_default_site_options();
$sites = jquery_sites();
$options = array_merge( $options, $sites[ JQUERY_LIVE_SITE ]['options'] );
foreach ( $options as $option => $value ) {
	if ( 'stylesheet' === $option || 'template' === $option )
		continue; // Don't mess with themes for now.
	add_filter( 'pre_option_' . $option, function( $null ) use ( $value, $blog_id ) {
		if ( $blog_id == get_current_blog_id() )
			return $value;
		return $null;
	} );
}
unset( $sites, $options, $option );

// Disable WordPress auto-paragraphing for posts.
remove_filter( 'the_content', 'wpautop' );

// Disable WordPress text transformations (smart quotes, etc.) for posts.
remove_filter( 'the_content', 'wptexturize' );

// Disable more restrictive multisite upload settings.
remove_filter( 'upload_mimes', 'check_upload_mimes' );
// Give unfiltered upload ability to super admins.