Index: trunk/include/onupdate.php
===================================================================
--- trunk/include/onupdate.php	(revision 186)
+++ trunk/include/onupdate.php	(revision 187)
@@ -23,37 +23,5 @@
 	$mid = $module->getVar('mid') ;
 
-//XPress TABLE UPGRADE
-	global $wpdb,$wp_rewrite, $wp_queries, $table_prefix, $wp_db_version, $wp_roles,$wp_query;
-	define('WP_INSTALLING', true);
-	$mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname;
-	$path = $mydirpath . '/';
-	if (file_exists($path . 'wp-load.php')) {
-		require_once $path . 'wp-load.php';
-	} else {
-		require_once $path . 'wp-config.php';
-	}
-	require_once($mydirpath . '/wp-admin/upgrade-functions.php');
-
-	if ( get_db_version($mydirname) != $wp_db_version ){
-		if( function_exists( 'wp_upgrade' ) )	{	
-			wp_upgrade();			
-		} else {
-			wp_cache_flush();
-			make_db_current_silent();
-			upgrade_all();
-			wp_cache_flush();
-		}				
-			$msgs[] = 'Upgrade Wordpress Database Ver.' . get_db_version($mydirname) .' to' . $wp_db_version;
-	}
-
-	/* activate the xpressme plugin */
-	require_once dirname( __FILE__ ).'/xpress_active_plugin.php';
-	if (xpress_pulugin_activation('xpressme/xpressme.php')){
-		$msgs[] = 'The xpressme plug-in was activated.';
-	}
-	
-//	update_option("blog_charset", wp_blog_charset());
-	$xpress_version = $module->modinfo['version'];
-	
+// XPressME orignal table updayte
 	if (! enhanced_table_check($mydirname,'views')){
 		$xp_prefix = $mydirname;
@@ -140,11 +108,77 @@
 	}
 
-	// make templates
+// make templates
 	include_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/include/xpress_templates_make.php' ;
 	$t_mess = xpress_templates_make($mid,$mydirname);
 	
 	$msgs = array_merge($msgs,$t_mess);
+
+
+//Wordpress TABLE UPGRADE
+	global $wpdb,$wp_rewrite, $wp_queries, $table_prefix, $wp_db_version, $wp_roles,$wp_query;
+	define('WP_INSTALLING', true);
+	$mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname;
+	$path = $mydirpath . '/';
+	
+/* 
+ * xpress_put_siteurl($mydirname,''); 
+ * Call to a member function register() The on a non-object error is evaded.
+ * It happens by register_widget() that exists in wp-includes/widgets.php. 
+ * The blog is not installed. It is cheating to function wp_maybe_load_widgets(). 
+ * As a result, default-widgets.php is not loaded.
+ */
+	xpress_put_siteurl($mydirname,''); 				// Site_url is temporarily deleted. 
+	
+	if (file_exists($path . 'wp-load.php')) {
+		require_once $path . 'wp-load.php';
+	} else {
+		require_once $path . 'wp-config.php';
+	}
+	
+	$site_url= XOOPS_URL."/modules/".$mydirname;		
+	update_option("home", $site_url);				// Site_url is set again. 
+	update_option("siteurl", $site_url);
+
+	require_once($mydirpath . '/wp-admin/upgrade-functions.php');
+
+	if ( get_db_version($mydirname) != $wp_db_version ){
+		if( function_exists( 'wp_upgrade' ) )	{	
+			wp_upgrade();			
+		} else {
+			wp_cache_flush();
+			make_db_current_silent();
+			upgrade_all();
+			wp_cache_flush();
+		}				
+			$msgs[] = 'Upgrade Wordpress Database Ver.' . get_db_version($mydirname) .' to' . $wp_db_version;
+	}
+
+	/* activate the xpressme plugin */
+	require_once dirname( __FILE__ ).'/xpress_active_plugin.php';
+	if (xpress_pulugin_activation('xpressme/xpressme.php')){
+		$msgs[] = 'The xpressme plug-in was activated.';
+	}
+	
+//	update_option("blog_charset", wp_blog_charset());
+	$xpress_version = $module->modinfo['version'];
+	
+
 	
 	return true ;
+}
+endif;
+
+if( ! function_exists( 'xpress_put_siteurl' ) ) :
+function xpress_put_siteurl($mydirname,$url){
+		global $xoopsModule;
+		$wp_prefix = $mydirname;
+		if ($wp_prefix == 'wordpress'){
+			$wp_prefix = 'wp';
+		}
+		$xoopsDB =& Database::getInstance();
+		$db_xpress_option = $xoopsDB->prefix($wp_prefix . '_options');
+
+		$sql = "UPDATE $db_xpress_option SET option_value = '$url' WHERE option_name = 'siteurl'";
+		$res = $xoopsDB->queryF($sql, 0, 0);
 }
 endif;
