✏️ 编辑:class-ai1wm-import-users.php
路径:
/home/forge/all-in-one-wp-migration/lib/model/import/class-ai1wm-import-users.php
大小:2.85 KB · 修改:2023-03-28 11:20:55 · 权限:0644 · 可写
← 返回目录
👁 查看
⬇ 下载
<?php /** * Copyright (C) 2014-2020 ServMask Inc. * * This program is 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 * (at your option) any later version. * * This program 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. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ if ( ! defined( 'ABSPATH' ) ) { die( 'Kangaroos cannot jump here' ); } class Ai1wm_Import_Users { public static function execute( $params ) { // Check multisite.json file if ( is_file( ai1wm_multisite_path( $params ) ) ) { // Set progress Ai1wm_Status::info( __( 'Preparing users...', AI1WM_PLUGIN_NAME ) ); // Read multisite.json file $handle = ai1wm_open( ai1wm_multisite_path( $params ), 'r' ); // Parse multisite.json file $multisite = ai1wm_read( $handle, filesize( ai1wm_multisite_path( $params ) ) ); $multisite = json_decode( $multisite, true ); // Close handle ai1wm_close( $handle ); // Set WordPress super admins if ( isset( $multisite['Admins'] ) && ( $admins = $multisite['Admins'] ) ) { foreach ( $admins as $username ) { if ( ( $user = get_user_by( 'login', $username ) ) ) { if ( $user->exists() ) { $user->set_role( 'administrator' ); } } } } // Set progress Ai1wm_Status::info( __( 'Done preparing users.', AI1WM_PLUGIN_NAME ) ); } return $params; } }
💾 保存
取消
保存为 UTF-8,换行统一为 LF