/** * Restores a site to pre 1.2.8. * * @since 1.2.8 * @access private * @return void */ private static function pre_1_2_8_restore() { global $wpdb; if (!self::pre_1_2_8_table_exists() || self::pre_1_2_8_table_is_empty()) { $cache_dir = FLBuilderModel::get_cache_dir(); $backup_path = $cache_dir['path'] . 'backup.dat'; // Install the database. FLBuilderModel::install_database(); // Check for the backup file. if (file_exists($backup_path)) { // Get the backup data. $backup = unserialize(file_get_contents($backup_path)); // Check for the correct backup data. if (!isset($backup->nodes) || !isset($backup->meta)) { return; } // Restore the nodes. foreach ($backup->nodes as $node) { $wpdb->insert("{$wpdb->prefix}fl_builder_nodes", array('node' => $node->node, 'type' => $node->type, 'layout' => $node->layout, 'parent' => $node->parent, 'position' => $node->position, 'settings' => $node->settings, 'status' => $node->status), array('%s', '%s', '%s', '%s', '%d', '%s', '%s')); } // Restore the meta. foreach ($backup->meta as $meta) { update_post_meta($meta->post_id, '_fl_builder_layout', $meta->meta_value); } } } }