rveitch
10/16/2015 - 1:53 AM

Jetpack Auto-Connect

Jetpack Auto-Connect

<?php
/*
 * Debug Bar Console hack to manually enable
*/
update_option( 'auto-connect', 1 );
$option = get_option( 'auto-connect' );
echo 'Auto-Connect:' . $option . '<br>If Auto-Connect = 1, then Jetpack new site auto-connect is enabled.';

	/**
	 * Registers new sites upon creation
	 *
	 * @since 2.9
	 * @uses  wpmu_new_blog
	 *
	 * @param int $blog_id
	 **/
	public function do_automatically_add_new_site( $blog_id ) {
		$this->do_subsiteregister( $blog_id );
	}


/*
 * If admin wants to automagically register new sites set the hook here
 * This is a hacky way because xmlrpc is not available on wpmu_new_blog
 * Source: /jetpack/views/admin/network-settings.php
 */
if( $this->get_option( 'auto-connect' ) == 1 ) {
	add_action( 'wpmu_new_blog', array( $this, 'do_automatically_add_new_site' ) );
}

/*
 * Uncomment this in Jetpack network-settings.php, lines 18-26.
 * Source: /jetpack/views/admin/network-settings.php
 */
<?php /*
			<tr valign="top">
				<th scope="row"><label for="auto-connect">Auto-Connect New Sites</label></th>
				<td>
					<input type="checkbox" name="auto-connect" id="auto-connect" value="1" <?php checked($options['auto-connect']); ?> />
					<label for="auto-connect">Automagically connect all new sites in the network.</label>
				</td>
			</tr>
/**/ ?>