This error appeared after the transfer of the site to another domain. Due to this error, there is no access to /wp-admin, and this error is displayed on the site above the content:
Warning: array_search() expects parameter 2 to be array, null given in /wp-content/plugins/visualcomposer/visualcomposer/Modules/FrontView/ContentUrlReplaceController.php on line 68
The error in the admin panel:
Warning: array_search() expects parameter 2 to be array, null given in /wp-content/plugins/visualcomposer/visualcomposer/Modules/FrontView/ContentUrlReplaceController.php on line 68 Warning: Cannot modify header information - headers already sent by (output started at /wp-content/plugins/visualcomposer/visualcomposer/Modules/FrontView/ContentUrlReplaceController.php:68) in /wp-includes/pluggable.php on line 1265 Warning: Cannot modify header information - headers already sent by (output started at /wp-content/plugins/visualcomposer/visualcomposer/Modules/FrontView/ContentUrlReplaceController.php:68) in /wp-includes/pluggable.php on line 1268
Solution to fix Visualcomposer issue without disabling the plugin
Edit the file /wp-content/plugins/visualcomposer/visualcomposer/Modules/FrontView/ContentUrlReplaceController.php, find line 68 and comment the following code:
$siteKey = array_search($siteUrl, $siteUrls['prevUrls']); if (false !== $siteKey) { unset($siteUrls['prevUrls'][ $siteKey ]); $optionsHelper->set('siteUrls', ['prevUrls' => $siteUrls['prevUrls'], 'currentUrl' => $siteUrl]); }