-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwpmu-micro.php
57 lines (48 loc) · 1.73 KB
/
wpmu-micro.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
add_action( 'wpmu_new_blog', 'landbryo_create_pages', 10, 2 );
function landbryo_create_pages( $blog_id, $user_id ){
switch_to_blog( $blog_id );
// Create home page.
$page_id = wp_insert_post( array(
'post_title' => 'Home',
'post_name' => 'home',
'post_content' => '',
'post_status' => 'publish',
'post_author' => $user_id, // or "1" (super-admin?)
'post_type' => 'page',
'menu_order' => 1,
'comment_status' => 'closed',
'ping_status' => 'closed',
'page_template' => 'page-home.php',
) );
// Create contact page.
$page_id = wp_insert_post( array(
'post_title' => 'Contact',
'post_name' => 'contact',
'post_content' => '[gravityform id="1" title="false" description="false"]',
'post_status' => 'publish',
'post_author' => $user_id, // or "1" (super-admin?)
'post_type' => 'page',
'menu_order' => 2,
'comment_status' => 'closed',
'ping_status' => 'closed',
'page_template' => '',
) );
// Find and delete the WP default post and page.
$defaultPage = get_page_by_title( 'Sample Page' );
$defaultPost = get_page_by_title( 'Hello world!' );
wp_delete_post( $defaultPage->ID );
wp_delete_post( $defaultPost->ID );
// Set default home page.
$home = get_page_by_title( 'Home' );
update_option( 'page_on_front', $home->ID );
update_option( 'show_on_front', 'page' );
// Leave this line at the end of this function to restore the current blog.
restore_current_blog();
}
// Set permalink structure on the creation of new site.
function landbryo_set_permalinks() {
global $wp_rewrite;
$wp_rewrite->set_permalink_structure( '/%postname%/' );
}
add_action( 'wpmu_new_blog', 'landbryo_set_permalinks' );