-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnewblog_setter.php
More file actions
119 lines (98 loc) · 2.91 KB
/
newblog_setter.php
File metadata and controls
119 lines (98 loc) · 2.91 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
/**
* @package Default_Site_Structure
* @version 2.0.1
*
* Plugin Name: Default Site Structure
* Plugin URI: https://boofolaworks.com/wordpress/plugins/mu-multisite-plugins/
* Description: Crates default pages and set them as front/blog index pages.
* Network: true
* Version: 2.0.1
* Author: BOOFOLA LLC
* Author URI: https://boofolallc.com/
* License: GPLv2 or later
* Text Domain: mu-multisite-plugins
*
* @package BoofolaWorks Must-Use Multisite Plugins
* @category Settings
*
* This plugin is created as free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This plugin is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
/* Start Adding Functions Below this Line */
namespace WPSE177819;
add_action( 'wp_loaded', __NAMESPACE__ . '\init' );
/**
* @wp-hook wp_loaded
*/
function init() {
add_action(
'wpmu_new_blog',
function( $blog_id, $user_id ) {
switch_to_blog( $blog_id );
$front_page_id = wp_insert_post( front_page_data( $user_id ) );
if ( ! is_wp_error( $front_page_id ) && 0 !== $front_page_id ) {
update_option( 'show_on_front', 'page' );
update_option( 'page_on_front', $front_page_id );
}
update_option( 'date_format', date_format() );
update_option( 'time_format', time_format() );
restore_current_blog();
},
10,
2
);
}
/**
* Returns the data of the front page
*
* @param int $post_author
*
* @return array
*/
function front_page_data( $post_author ) {
return [
'post_title' => 'Home',
'post_content' => '',
'post_type' => 'page',
'post_author' => $post_author,
'post_status' => 'publish'
];
}
add_action ('wpmu_new_blog', 'wpse296303_delete_wordpress_defaults', 100, 1);
function wpse296303_delete_wordpress_defaults ($blog_id, $user_id, $domain, $path, $site_id, $meta) {
// Switch to the newly created blog
switch_to_blog ($blog_id);
// Delete 'Sample comment' page
wp_delete_comment (1, true);
// Delete 'Hello World!' post
wp_delete_post (1, true);
// Delete 'Sample page' page
wp_delete_post (2, true);
}
restore_current_blog();
/**
* Returns the custom date format
*
* @return string
*/
function date_format() {
return 'd,m,Y';
}
/**
* Returns the custom time format
*
* @return string
*/
function time_format() {
return 'H/i/s';
}
/* Stop Adding Functions Below this Line */
?>