Example #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();
}
Example #2
0
function jquery_com_staging_urls($content)
{
    foreach (array_keys(jquery_sites()) as $site) {
        $content = str_replace('//' . $site, '//' . JQUERY_STAGING_PREFIX . $site, $content);
    }
    return $content;
}
// Allow full HTML in term descriptions.
add_action( 'init', 'jquery_unfiltered_html_for_term_descriptions' );
add_action( 'set_current_user', 'jquery_unfiltered_html_for_term_descriptions' );
function jquery_unfiltered_html_for_term_descriptions() {
	remove_filter( 'pre_term_description', 'wp_filter_kses' );
	remove_filter( 'pre_term_description', 'wp_filter_post_kses' );
	if ( ! current_user_can( 'unfiltered_html' ) )
		add_filter( 'pre_term_description', 'wp_filter_post_kses' );
}

// Bypass multisite checks.
add_filter( 'ms_site_check', '__return_true' );

// Add body classes found in postmeta.
add_filter( 'body_class', function( $classes ) {
	$sites = jquery_sites();
	if ( isset( $sites[ JQUERY_LIVE_SITE ]['body_class'] ) )
		array_unshift( $classes, $sites[ JQUERY_LIVE_SITE ]['body_class'] );
	if ( 0 === strpos( JQUERY_LIVE_SITE, 'api.' ) )
		array_unshift( $classes, 'api' );

	if ( is_page() )
		$classes[] = 'page-slug-' . sanitize_html_class( strtolower( get_queried_object()->post_name ) );
	if ( is_singular() && $post_classes = get_post_meta( get_queried_object_id(), 'body_class', true ) )
		$classes = array_merge( $classes, explode( ' ', $post_classes ) );

	if ( is_archive() || is_search() ) {
		$classes[] = 'listing';
	}

	return $classes;
function jq_logo_link()
{
    // TODO: remove when blog.jquery.com-theme is gone
    if (!function_exists('jquery_sites')) {
        return '/';
    }
    $sites = jquery_sites();
    return empty($sites[JQUERY_LIVE_SITE]['logo_link']) ? '/' : $sites[JQUERY_LIVE_SITE]['logo_link'];
}