: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
class wfImportExportController {
* Returns the singleton wfImportExportController.
* @return wfImportExportController
public static function shared() {
$_shared = new wfImportExportController();
public function export() {
$keys = wfConfig::getExportableOptionsKeys();
foreach ($keys as $key) {
$export[$key] = wfConfig::get($key, '');
$export['scanSched'] = wfConfig::get_ser('scanSched', array());
$export['blocks'] = wfBlock::exportBlocks();
$api = new wfAPI(wfConfig::get('apiKey'), wfUtils::getWPVersion());
$res = $api->call('export_options', array(), array('export' => json_encode($export)));
if ($res['ok'] && $res['token']) {
'token' => $res['token'],
return array('err' => __("An error occurred: ", 'wordfence') . $res['err']);
throw new Exception(__("Invalid response: ", 'wordfence') . var_export($res, true));
return array('err' => __("An error occurred: ", 'wordfence') . $e->getMessage());
public function import($token) {
$api = new wfAPI(wfConfig::get('apiKey'), wfUtils::getWPVersion());
$res = $api->call('import_options', array(), array('token' => $token));
if ($res['ok'] && $res['export']) {
$import = @json_decode($res['export'], true);
if (!is_array($import)) {
return array('err' => __("An error occurred: Invalid options format received.", 'wordfence'));
$keys = wfConfig::getExportableOptionsKeys();
foreach ($keys as $key) {
if (isset($import[$key])) {
$toSet[$key] = $import[$key];
$validation = wfConfig::validate($toSet);
if ($validation !== true) {
foreach ($validation as $error) {
$skipped[$error['option']] = $error['error'];
unset($toSet[$error['option']]);
$totalSet += count($toSet);
wfConfig::save(wfConfig::clean($toSet));
if (isset($import['scanSched']) && is_array($import['scanSched'])) {
wfConfig::set_ser('scanSched', $import['scanSched']);
wfScanner::shared()->scheduleScans();
if (isset($import['blocks']) && is_array($import['blocks'])) {
wfBlock::importBlocks($import['blocks']);
$totalSet += count($import['blocks']);
return array('err' => sprintf(/* translators: Error message. */ __("An error occurred: %s", 'wordfence'), $res['err']));
throw new Exception(sprintf(/* translators: Error message. */ __("Invalid response: %s", 'wordfence'), var_export($res, true)));
return array('err' => sprintf(/* translators: Error message. */ __("An error occurred: %s", 'wordfence'), $e->getMessage()));