: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$results[$theme] = $result;
$upgrader->maintenance_mode(false);
wp_clean_themes_cache($parsed_args['clear_update_cache']);
'upgrader_process_complete',
$upgrader->skin->bulk_footer();
$upgrader->skin->footer();
remove_filter('upgrader_pre_install', array($upgrader, 'current_before'));
remove_filter('upgrader_post_install', array($upgrader, 'current_after'));
remove_filter('upgrader_clear_destination', array($upgrader, 'delete_old_theme'));
$past_failure_emails = get_option('auto_plugin_theme_update_emails', array());
foreach ($results as $theme => $result) {
if (!$result || is_wp_error($result) || !isset($past_failure_emails[$theme])) {
unset($past_failure_emails[$theme]);
update_option('auto_plugin_theme_update_emails', $past_failure_emails);
function upgradeThemes($themes, $has_bv_skin = false, $bv_bulk_upgrade = false) {
foreach ($themes as $theme) {
$_themes[$theme['stylesheet']] = $theme['package'];
if (empty(array_keys($_themes))) {
if (class_exists('Theme_Upgrader')) {
require_once( "bv_upgrader_skin.php" );
$skin = new BVUpgraderSkin("theme_upgrade");
$skin = new Bulk_Theme_Upgrader_Skin();
$upgrader = new Theme_Upgrader($skin);
$result = $this->bv_theme_bulk_upgrade($upgrader, $_themes);
$result = $upgrader->bulk_upgrade(array_keys($_themes));
foreach (array_keys($_themes) as $stylesheet) {
if (!array_key_exists($stylesheet, $result)) {
$result[$stylesheet] = array('status' => "Error");
$res = $result[$stylesheet];
if (!$res || is_wp_error($res)) {
$result[$stylesheet] = array('status' => "Error");
$result[$stylesheet] = array('status' => "Done");
function install($params, $has_bv_skin = false) {
if (isset($params['plugins'])) {
foreach ($params['plugins'] as $plugin) {
if (!array_key_exists('plugins', $result))
$result["plugins"] = array();
$plugin['dest'] = WP_PLUGIN_DIR;
$res = $this->installPackage("plugin", $plugin, $has_bv_skin);
$pluginName = $plugin['package'];
$result["plugins"][$pluginName] = $res;
if (isset($params['themes'])) {
foreach ($params['themes'] as $theme) {
if (!array_key_exists('themes', $result))
$result["themes"] = array();
$theme['dest'] = WP_CONTENT_DIR.'/themes';
$res = $this->installPackage("theme", $theme, $has_bv_skin);
$themeName = $theme['package'];
$result["themes"][$themeName] = $res;
function installPackage($type, $params, $has_bv_skin = false) {
if (!isset($params['package']) || empty($params['package'])) {
return array('status' => "Error", 'message' => "No package is sent");
$valid_domain_regex = "/^(http|https):\/\/[\-\w]*\.(blogvault\.net|w\.org|wp\.org|wordpress\.org)\//";
if (BVHelper::safePregMatch($valid_domain_regex, $params['package']) !== 1) {
return array('status' => "Error", 'message' => "Invalid package domain");
require_once( "bv_upgrader_skin.php" );
$skin = new BVUpgraderSkin("installer", array(), $params['package']);
$skin = new WP_Upgrader_Skin();
if ("plugin" === $type) {
$upgrader = new Plugin_Upgrader($skin);
} elseif ("theme" === $type) {
$upgrader = new Theme_Upgrader($skin);
$upgrader = new WP_Upgrader($skin);
$destination = $params['dest'];
$clear_destination = isset($params['cleardest']) ? $params['cleardest'] : false;
$package_url = $params['package'];
$key = basename($package_url);
add_filter('upgrader_source_selection', array($upgrader, 'check_package'));
'package' => $package_url,
'destination' => $destination,
'clear_destination' => $clear_destination,
remove_filter('upgrader_source_selection', array($upgrader, 'check_package'));
$res = array('status' => "Error", 'message' => $this->getError($res));
$res = array( 'status' => "Done");
function getPremiumUpdates() {
return apply_filters( 'mwp_premium_update_notification', array() );
function getPremiumUpgradesInfo() {
return apply_filters( 'mwp_premium_perform_update', array() );
function autoLogin($username, $isHttps) {
$user = get_user_by('login', $username);
wp_set_current_user( $user->ID );
wp_set_auth_cookie( $user->ID, false, true );
# As we are not sure about wp-cofig.php settings for sure login
wp_set_auth_cookie( $user->ID, false, true );
wp_set_auth_cookie( $user->ID, false, false );
$redirect_to = get_admin_url();
wp_safe_redirect( $redirect_to );
public function refreshPluginUpdates() {
global $wp_current_filter;
$wp_current_filter[] = 'load-update-core.php';
array_pop($wp_current_filter);
public function refreshThemeUpdates() {
global $wp_current_filter;
$wp_current_filter[] = 'load-update-core.php';
array_pop($wp_current_filter);
function upgradeElementorDB($file) {
$managerClass = $file === "elementor/elementor.php" ? '\Elementor\Core\Upgrade\Manager' : '\ElementorPro\Core\Upgrade\Manager';
if (!class_exists($managerClass)) {
return array('status' => 'Error', 'error' => 'Elementor plugin not found or disabled', 'source' => 'BV');
$manager = new $managerClass();
$required_methods = array('get_task_runner', 'should_upgrade', 'on_runner_complete',
'get_current_version', 'get_new_version');
foreach ($required_methods as $method) {
if (!method_exists($manager, $method)) {
return array('status' => 'Error', 'error' => 'Required methods are missing', 'source' => 'BV');
'from' => $manager->get_current_version(),
'to' => $manager->get_new_version(),
if ($manager->should_upgrade()) {
$callbacks = $manager->get_upgrade_callbacks();
if (!empty($callbacks)) {
$manager->get_task_runner()->handle_immediately($callbacks);
$manager->on_runner_complete(true);
return array('status' => 'Error', 'error' => 'Database Update is not available currently',
'update_info' => $updateInfo, 'source' => 'BV');
return array('status' => 'Done', 'update_info' => $updateInfo);
return array('status' => 'Error', 'error' => $e->getMessage());
function upgradeWoocommerceDb() {
if (!defined('WC_ABSPATH')) {
return array('status' => 'Error', 'error' => 'WC not found', 'source' => 'BV');
if (file_exists(WC_ABSPATH . 'includes/class-wc-install.php')) {
include_once WC_ABSPATH . 'includes/class-wc-install.php';
if (file_exists(WC_ABSPATH . 'includes/wc-update-functions.php')) {
include_once WC_ABSPATH . 'includes/wc-update-functions.php';
if (!class_exists('WC_Install') || !method_exists('WC_Install', 'needs_db_update') ||
!method_exists('WC_Install', 'get_db_update_callbacks')) {
return array('status' => 'Error', 'error' => 'WC files missing or corrupted', 'source' => 'BV');
$current_db_version = $this->settings->getOption('woocommerce_db_version');
if (!$current_db_version) {
return array('status' => 'Error', 'error' => 'Current WC DB version not available', 'source' => 'BV');
$latest_db_version = $this->bvinfo->getLatestWooCommerceDBVersion();
if ($current_db_version >= $latest_db_version) {
return array('status' => 'Error', 'error' => 'WC DB update not available', 'source' => 'BV');
$db_update_callbacks = WC_Install::get_db_update_callbacks();
foreach ($db_update_callbacks as $version => $update_callbacks) {
if (version_compare($current_db_version, $version, '<')) {
foreach ($update_callbacks as $update_callback) {
WC()->queue()->schedule_single(
'woocommerce_run_update_callback',
array('update_callback' => $update_callback),
$current_wc_version = WC()->version;
if (version_compare($current_db_version, $current_wc_version, '<') &&
!WC()->queue()->get_next('woocommerce_update_db_to_current_version')) {
WC()->queue()->schedule_single(
'woocommerce_update_db_to_current_version',
array('version' => $current_wc_version),
return array('status' => 'Done');
return array('status' => 'Error', 'error' => $e->getMessage());
if (function_exists('wp_upgrade')) {
return "NOUPGRADERFUNCTION";
function process($request) {
if (!$this->is_pantheon() && !$wp_filesystem) {
$params = $request->params;
switch ($request->method) {
$resp = array("adduser" => $this->addUser($params['args']));
$has_bv_skin = array_key_exists('bvskin', $params);
$bv_bulk_upgrade = array_key_exists('bv_bulk_update', $params['args']);
$resp = array("upgrades" => $this->upgrade($params['args'], $has_bv_skin, $bv_bulk_upgrade));
$has_bv_skin = array_key_exists('bvskin', $args);
$bv_bulk_upgrade = array_key_exists('bv_bulk_update', $args);
$resp['upgrades'] = $this->upgrade($args['upgrades'], $has_bv_skin, $bv_bulk_upgrade);
if (isset($args['delete_transient'])) {
$resp['delete_transient'] = $this->settings->deleteTransient($args['delete_transient']);
if (isset($args['wp_update_plugins'])) {
$resp['wp_update_plugins'] = $this->refreshPluginUpdates();
if (isset($args['wp_update_themes'])) {
$resp['wp_update_themes'] = $this->refreshThemeUpdates();
$resp = array("edit" => $this->edit($params['args']));
$has_bv_skin = array_key_exists('bvskin', $params);
$resp = array("install" => $this->install($params['args'], $has_bv_skin));
case "getpremiumupdates":
$resp = array("premiumupdates" => $this->getPremiumUpdates());
case "getpremiumupgradesinfo":
$resp = array("premiumupgradesinfo" => $this->getPremiumUpgradesInfo());
$resp = array("writeable" => $this->isServerWritable());
if (array_key_exists('https', $params))
$resp = array("autologin" => $this->autoLogin($params['username'], $isHttps));
$resp = array("status" => $this->upgrade_db());
$files = $params['files'];
foreach ($files as $file) {
case "woocommerce/woocommerce.php":
$resp[$file] = $this->upgradeWoocommerceDb();
case "elementor/elementor.php":
case "elementor-pro/elementor-pro.php":
$resp[$file] = $this->upgradeElementorDB($file);
if ($this->skin && is_array($resp)) {
$resp = array_merge($resp, $this->skin->status);