在api的顶部。php页面位于class JSON_API
行添加以下代码:
add_action( \'wpmu_new_blog\', \'wpse_set_defaults\' );
function wpse_set_defaults( $blog_id ) {
global $json_api;
switch_to_blog( $blog_id );
// set the default controllers here
$required_controllers = explode(",", "categories,posts,user,attachments");
$id = \'json_api_controllers\';
$available_controllers = $json_api->get_controllers();
$active_controllers = explode(\',\', get_option($id, \'core\'));
$action = "activate";
foreach ($required_controllers as $controller) {
if (in_array($controller, $available_controllers)) {
if ($action == \'activate\' && !in_array($controller, $active_controllers)) {
$active_controllers[] = $controller;
} else if ($action == \'deactivate\') {
$index = array_search($controller, $active_controllers);
if ($index !== false) {
unset($active_controllers[$index]);
}
}
}
}
$value = implode(\',\', $active_controllers);
// get option and set it
$option_exists = (get_option($id, null) !== null);
if ($option_exists) {
update_option($id, $value);
} else {
add_option($id, $value);
}
restore_current_blog();
}
您也可以在此处设置其他选项。