Index: branches/XPressMU/xpressme_integration_kit/admin/menu.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/admin/menu.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/admin/menu.php	(revision 488)
@@ -58,4 +58,6 @@
 $adminmenu[$i++]['link'] = "index.php";
 
+$adminmenu[$i]['title'] = _MI_XP2_TO_UPDATE ;
+$adminmenu[$i++]['link'] = "admin/update.php";
 
 ?>
Index: branches/XPressMU/xpressme_integration_kit/blocks/archives_block.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/blocks/archives_block.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/blocks/archives_block.php	(revision 488)
@@ -28,5 +28,5 @@
 
 		$form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />";
-	    $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />";
+		$form .= block_template_setting($mydirname,'options[1]',htmlspecialchars($this_template,ENT_QUOTES));
 		$form .= "<br />";
 		$a_month = _MB_XP2_ARC_MONTH ;
@@ -62,5 +62,5 @@
 		$form .=  "</select><br/>";
 		
-		$form .= "<br />" . _MB_XP2_COUNT_ZERO_ALL . "  <input type='text' name='options[3]' value='" . $limit . "' />";
+		$form .= "<br />" . _MB_XP2_COUNT_ZERO_ALL . "  <input type='text' size='3' name='options[3]' value='" . $limit . "' />";
 		$form .= "<br />" . yes_no_radio_option('options[4]', _MB_XP2_SHOW_NUM_OF_POST , $show_post_count);
 		$form .= "<br />" . yes_no_radio_option('options[5]', _MB_XP2_SHOW_DROP_DOWN , $drop_down);
Index: branches/XPressMU/xpressme_integration_kit/blocks/authors_block.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/blocks/authors_block.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/blocks/authors_block.php	(revision 488)
@@ -28,5 +28,5 @@
 			
 		$form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />";
-	    $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />";
+		$form .= block_template_setting($mydirname,'options[1]',htmlspecialchars($this_template,ENT_QUOTES));
 		$form .= "<br />";
 		$form .= yes_no_radio_option('options[2]', _MB_XP2_SHOW_NUM_OF_POST , $optioncount);
Index: branches/XPressMU/xpressme_integration_kit/blocks/block_common.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/blocks/block_common.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/blocks/block_common.php	(revision 488)
@@ -103,5 +103,5 @@
 
     $option = "<option value=\"0\" ";
-    if ($isAll) $form .= " selected=\"selected\"";
+    if ($isAll) $option .= " selected=\"selected\"";
     $option .= ">"._MB_XP2_ALL ."</option>";
 
@@ -146,4 +146,56 @@
 endif;
 
+if(!function_exists("block_template_setting")):
+function block_template_setting($mydirname,$option_name = '',$value='')
+{
+	$temp_parm = explode(':' , $value);
+	if (empty($temp_parm[1])) {
+		$filename=$temp_parm[0];
+		$temp_type = 'db';
+	} else  {
+		$filename=$temp_parm[1];
+		$temp_type = $temp_parm[0];
+	}
+
+	$none_prefix_filename = '';
+	$pattern = '^' . $mydirname . '_(.*).html';
+	if (preg_match('/' . $pattern . '/' , $filename, $match)){ // file prefix check
+		$none_prefix_filename = $match[1];
+	}
+	
+	$output = _MB_XP2_THISTEMPLATE . "\n";
+	$output .= 	'<input type="hidden" size="50" name="' . $option_name . '" value="' . $value .'"/>' . "\n";
+    $output .= '&nbsp;<select name="template_type" onclick="Template_Make()">' ."\n";
+	switch ($temp_type){
+		case 'db':
+		case 'DB':
+			$output .=  '<option value="0" selected="selected">db</option>';
+			$output .=  '<option value="1">file</option>';
+			break;
+		default:
+			$output .=  '<option value="0">db</option>';
+			$output .=  '<option value="1" selected="selected">file</option>';
+	}
+	$output .= '</select>';
+	$output .= '<b>:'.$mydirname . '_</b>';
+	$output .= '<input type="text" size="30" name="none_prefix_file" value="'. $none_prefix_filename. '"  onChange="Template_Make()"/><b>.html</b><br />';
+    $output .= '
+<script type="text/javascript">
+	function Template_Make(){
+		var type_element = document.getElementsByName("template_type").item(0);
+		var name_element = document.getElementsByName("none_prefix_file").item(0);
+		var real_element = document.getElementsByName("' .$option_name . '").item(0);
+
+		var file_name = "' . $mydirname . '_" + name_element.value + ".html";
+		if (type_element.value ==0) var tmp_type = "db:"; else var tmp_type = "file:";
+		real_element.value = tmp_type + file_name;
+	}
+</script>
+';
+    
+    return $output;
+
+}
+endif;
 
 ?>
Index: branches/XPressMU/xpressme_integration_kit/blocks/calender_block.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/blocks/calender_block.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/blocks/calender_block.php	(revision 488)
@@ -26,5 +26,5 @@
 
 		$form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />\n";
-	    $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />";
+		$form .= block_template_setting($mydirname,'options[1]',htmlspecialchars($this_template,ENT_QUOTES));
 		$form .= "<br />";
 		$form .= _MB_XP2_SUN_COLOR .": <input type='text' name='options[2]' value='" . $sun_color . "' /><br />\n";
Index: branches/XPressMU/xpressme_integration_kit/blocks/category_block.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/blocks/category_block.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/blocks/category_block.php	(revision 488)
@@ -34,6 +34,6 @@
 		require_once(XOOPS_ROOT_PATH.'/modules/'.$mydirname.'/blocks/block_common.php');	
 
-		$form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' />";
-	    $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />";
+		$form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />";
+		$form .= block_template_setting($mydirname,'options[1]',htmlspecialchars($this_template,ENT_QUOTES));
 		$form .= "<br />";
 		$form .= _MB_XP2_CAT_ALL_STR . "  <input type='text' name='options[2]' value='" . $show_option_all . "' /><br />";
Index: branches/XPressMU/xpressme_integration_kit/blocks/enhanced_block.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/blocks/enhanced_block.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/blocks/enhanced_block.php	(revision 488)
@@ -19,12 +19,14 @@
 		$mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
 		$this_template = empty( $options[1] ) ? 'db:'.$mydirname.'_enhanced_block.html' : trim( $options[1] );
+	    $form .= _MB_XP2_THISTEMPLATE . "<input type='text' size='50' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />";
 		$include_file = empty( $options[2] ) ? '' : $options[2] ;
 		
+		require_once(XOOPS_ROOT_PATH.'/modules/'.$mydirname.'/blocks/block_common.php');
 
 		$form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />";
-	    $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />";
+		$form .= block_template_setting($mydirname,'options[1]',htmlspecialchars($this_template,ENT_QUOTES));
 		$form .= "<br />";
 		$form .= _MB_XP2_ENHACED_FILE .":<br />\n";
-		$form .= '&emsp;' . _MB_XP2_FILE_NAME . ": my_<input type='text' name='options[2]' value='" . $include_file . "' />_block.php<br>\n";
+		$form .= '&emsp;' . _MB_XP2_FILE_NAME . ": <b>my_</b><input type='text' name='options[2]' value='" . $include_file . "' /><b>_block.php</b><br>\n";
 		$form .= '&emsp;' . _MB_XP2_MAKE_ENHACED_FILE . "<br>\n";
 		return $form;
Index: branches/XPressMU/xpressme_integration_kit/blocks/meta_block.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/blocks/meta_block.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/blocks/meta_block.php	(revision 488)
@@ -31,5 +31,5 @@
 
 		$form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />";
-	    $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />";
+		$form .= block_template_setting($mydirname,'options[1]',htmlspecialchars($this_template,ENT_QUOTES));
 		$form .= "<br />";
 		$form .= yes_no_radio_option('options[2]', _MB_XP2_META_WP_LINK , $wp_link) . "<br />\n";
Index: branches/XPressMU/xpressme_integration_kit/blocks/page_block.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/blocks/page_block.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/blocks/page_block.php	(revision 488)
@@ -35,5 +35,5 @@
 
 		$form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />";
-	    $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />";
+		$form .= block_template_setting($mydirname,'options[1]',htmlspecialchars($this_template,ENT_QUOTES));
 		$form .= "<br />";
 		$form .= _MB_XP2_PAGE_ORDERBY .": ";
Index: branches/XPressMU/xpressme_integration_kit/blocks/popular_posts_block.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/blocks/popular_posts_block.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/blocks/popular_posts_block.php	(revision 488)
@@ -28,7 +28,6 @@
 		
 		require_once(XOOPS_ROOT_PATH.'/modules/'.$mydirname.'/blocks/block_common.php');
-
 		$form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />\n";
-	    $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />\n";
+		$form .= block_template_setting($mydirname,'options[1]',htmlspecialchars($this_template,ENT_QUOTES));
 		$form .= "<br />\n";
 		$form .= _MB_XP2_COUNT .": <input type='text' name='options[2]' value='" . $disp_count . "' /><br />\n";
Index: branches/XPressMU/xpressme_integration_kit/blocks/recent_comments_block.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/blocks/recent_comments_block.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/blocks/recent_comments_block.php	(revision 488)
@@ -30,8 +30,8 @@
 		
 		$form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />\n";
-	    $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />\n";
+		$form .= block_template_setting($mydirname,'options[1]',htmlspecialchars($this_template,ENT_QUOTES));
 		$form .= "<br />";
-		$form .= _MB_XP2_COUNT .": <input type='text' name='options[2]' value='" . $disp_count . "' /><br />\n";
-		$form .= _MB_XP2_LENGTH .": <input type='text' name='options[3]' value='" . $disp_length . "' /><br />\n";
+		$form .= _MB_XP2_COUNT .": <input type='text' size='3' name='options[2]' value='" . $disp_count . "' /><br />\n";
+		$form .= _MB_XP2_LENGTH .": <input type='text' size='3' name='options[3]' value='" . $disp_length . "' /><br />\n";
 		$form .= _MB_XP2_DATE_FORMAT .": <input type='text' name='options[4]' value='" . $date_format . "' /><br />\n";
 		$form .= _MB_XP2_TIME_FORMAT .": <input type='text' name='options[5]' value='" . $time_format . "' /><br />\n";
Index: branches/XPressMU/xpressme_integration_kit/blocks/recent_posts_content_block.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/blocks/recent_posts_content_block.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/blocks/recent_posts_content_block.php	(revision 488)
@@ -34,6 +34,7 @@
 		
 		$form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />\n";
-	    $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />";
-		$form .= _MB_XP2_COUNT .": <input type='text' name='options[2]' value='" . $disp_count . "' /><br />\n";
+		$form .= block_template_setting($mydirname,'options[1]',htmlspecialchars($this_template,ENT_QUOTES));
+		$form .= "<br />";
+		$form .= _MB_XP2_COUNT .": <input type='text' size='3' name='options[2]' value='" . $disp_count . "' /><br />\n";
 		$form .= yes_no_radio_option('options[3]', _MB_XP2_P_EXCERPT , $excerpt) . "<br />\n";
 		$form .= _MB_XP2_P_EXCERPT_SIZE .": <input type='text' name='options[4]' value='" . $excerpt_size . "' /><br />\n";
Index: branches/XPressMU/xpressme_integration_kit/blocks/recent_posts_list_block.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/blocks/recent_posts_list_block.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/blocks/recent_posts_list_block.php	(revision 488)
@@ -31,9 +31,9 @@
 
 		$form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />\n";
-	    $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />\n";
+		$form .= block_template_setting($mydirname,'options[1]',htmlspecialchars($this_template,ENT_QUOTES));
 		$form .= "<br />\n";	
-		$form .= _MB_XP2_COUNT .": <input type='text' name='options[2]' value='" . $disp_count . "' /><br />\n";
-		$form .= _MB_XP2_REDNEW_DAYS .": <input type='text' name='options[3]' value='" . $disp_red . "' /><br />\n";
-		$form .= _MB_XP2_GREENNEW_DAYS .": <input type='text' name='options[4]' value='" . $disp_green . "' /><br />\n";
+		$form .= _MB_XP2_COUNT .": <input type='text' size='3' name='options[2]' value='" . $disp_count . "' /><br />\n";
+		$form .= _MB_XP2_REDNEW_DAYS .": <input type='text' size='3' name='options[3]' value='" . $disp_red . "' /><br />\n";
+		$form .= _MB_XP2_GREENNEW_DAYS .": <input type='text' size='3' name='options[4]' value='" . $disp_green . "' /><br />\n";
 		$form .= _MB_XP2_DATE_FORMAT .": <input type='text' name='options[5]' value='" . $date_format . "' /><br />\n";
 		$form .= _MB_XP2_TIME_FORMAT .": <input type='text' name='options[6]' value='" . $time_format . "' /><br />\n";
Index: branches/XPressMU/xpressme_integration_kit/blocks/search_block.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/blocks/search_block.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/blocks/search_block.php	(revision 488)
@@ -25,7 +25,7 @@
 		
 		$form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />";
-	    $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />";
+		$form .= block_template_setting($mydirname,'options[1]',htmlspecialchars($this_template,ENT_QUOTES));
 		$form .= "<br />";		
-		$form .= _MB_XP2_SEARCH_LENGTH .": <input type='text' name='options[2]' value='" . $disp_count . "' /><br />";
+		$form .= _MB_XP2_SEARCH_LENGTH .": <input type='text' size='3' name='options[2]' value='" . $disp_count . "' /><br />";
 //	    $form .="<br /><input type='text' size='60' name='options[2]' value='".htmlspecialchars($this_template,ENT_QUOTES)."' />";
 
Index: branches/XPressMU/xpressme_integration_kit/blocks/tag_cloud_block.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/blocks/tag_cloud_block.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/blocks/tag_cloud_block.php	(revision 488)
@@ -32,5 +32,5 @@
 
 		$form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />";
-	    $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />";
+		$form .= block_template_setting($mydirname,'options[1]',htmlspecialchars($this_template,ENT_QUOTES));
 		$form .= "<br />";
 		$form .= _MB_XP2_CLOUD_SMALLEST .": <input type='text' size='4' name='options[2]' value='" . $smallest . "' /><br />";
Index: branches/XPressMU/xpressme_integration_kit/blocks/widget_block.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/blocks/widget_block.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/blocks/widget_block.php	(revision 488)
@@ -46,5 +46,5 @@
 
 		$form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />";
-	    $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />";
+		$form .= block_template_setting($mydirname,'options[1]',htmlspecialchars($this_template,ENT_QUOTES));
 		$form .= "<br />" . yes_no_radio_option('options[2]', _MB_XP2_WIDGET_TITLE_SHOW , $title_show);
 		$form .= "<br />";
Index: branches/XPressMU/xpressme_integration_kit/include/add_xpress_process.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/include/add_xpress_process.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/include/add_xpress_process.php	(revision 488)
@@ -7,13 +7,46 @@
 }
 
+function safe_site_url(){
+	global $xoops_config;
+	
+	if (is_xpress_index_page_call()){
+		$siteurl = get_option('siteurl');
+		$home = get_option('home');
+		$module_url = $xoops_config->module_url;
+		$module_name = $xoops_config->module_name;
+		$schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
+		$guess_url = preg_replace('|/' . $module_name . '/.*|i', '/' . $module_name, $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
+
+		if(strcmp($siteurl,$module_url) !== 0) {
+			if (!@fclose(@fopen($siteurl . '/xoops_version.php', "r"))){
+				update_option('siteurl' , $module_url);
+			}
+		}
+
+		if(strcmp($guess_ur,$home) !== 0) {
+			if (@fclose(@fopen($guess_url . '/xoops_version.php', "r"))){
+				update_option('home' , $guess_url);
+			}
+		}
+	}
+}
+
 require_once( dirname( __FILE__ ).'/request_url.php');
 if (is_xpress_index_page_call()){
+	//$_SERVER['REQUEST_METHOD'] = 'POST' is
 	//When notifying by a private message, Notification_reserve_send();
 	//it is evaded that the data base becomes read-only as a result of the check on the referrer and the method. 
+	$request_method =  (isset($_SERVER['REQUEST_METHOD'])) ? $_SERVER['REQUEST_METHOD'] : '';
 	$_SERVER['REQUEST_METHOD'] = 'POST';
+	require_once $xoops_config->xoops_mainfile_path; //It is necessary to execute it for the user attestation before wp-settings.php. 
+	$_SERVER['REQUEST_METHOD'] = $request_method;
+	
+	unset($offset);		//This Trap is provides the case where $offset is defined on the XOOPS side.
+	require_once(ABSPATH.'wp-settings.php');
+	
+	//When it is not possible to connect it correctly at site home URL on the WordPress side, 
+	//URL is corrected based on accessed URL. 
+	safe_site_url();
 
-	require_once $xoops_config->xoops_mainfile_path; //It is necessary to execute it for the user attestation before wp-settings.php. 
-	unset($offset);
-	require_once(ABSPATH.'wp-settings.php');
 	if (!is_object($xoopsUser)){	// before login auth cookie clear
 		wp_logout();
Index: branches/XPressMU/xpressme_integration_kit/include/general_functions.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/include/general_functions.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/include/general_functions.php	(revision 488)
@@ -126,4 +126,6 @@
 		$table_list = array();
 		$ret = array();
+		$pattern = $wp_prefix . $table_name . '|' . $wp_prefix . '[0-9]*_' . $table_name;
+
 		if (!empty($wp_prefix) && !empty($table_name)){
 			$sql = "SHOW TABLES LIKE '" . $wp_prefix  . '%' . $table_name . "'";
@@ -132,5 +134,7 @@
 				if($result = $xoopsDB->queryF($sql)){
 					while($row = $xoopsDB->fetchRow($result)){
-						$table_list[] = $row[0];
+						if(preg_match('/' . $pattern . '/' , $row[0])){
+							$table_list[] = $row[0];
+						}
 					}
 				}
@@ -138,5 +142,7 @@
 				$rows = $xoops_db->get_results($sql, ARRAY_N);
 				foreach ($rows as $row){
-					$table_list[] = $row[0];
+					if(preg_match('/' . $pattern . '/' , $row[0])){
+						$table_list[] = $row[0];
+					}
 				}
 			}			
Index: branches/XPressMU/xpressme_integration_kit/include/oninstall.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/include/oninstall.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/include/oninstall.php	(revision 488)
@@ -45,5 +45,5 @@
 
 //xpress
-	global $wpdb,$wp_rewrite, $wp_queries, $table_prefix, $wp_db_version, $wp_roles, $wp_query;
+	global $wpdb,$wp_rewrite, $wp_queries, $table_prefix, $wp_db_version, $wp_roles, $wp_query,$wp_embed;
 	global $xoops_config;
 		
Index: branches/XPressMU/xpressme_integration_kit/include/onupdate.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/include/onupdate.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/include/onupdate.php	(revision 488)
@@ -42,6 +42,13 @@
 	$site_url= XOOPS_URL."/modules/".$mydirname;
 	xpress_put_siteurl($mydirname,$site_url);
-	xpress_put_home($mydirname,$site_url);
-
+	$home = get_xpress_option($mydirname,'home');
+	$home_check = 'home option is right';
+	if (strcmp($site_url,$home) !== 0 ){
+		if (!@fclose(@fopen($home . '/xoops_version.php', "r"))){
+			xpress_put_home($mydirname,$site_url);
+			$home_check = 'Change home option $home to $site_url';
+		}
+	}
+	$msgs[] = $home_check;
 // XPressME orignal table update
 	$t_mess = xpress_table_make($module , $mydirname);
@@ -50,6 +57,10 @@
 // make templates
 	include_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/include/xpress_templates_make.php' ;
+	$mod_version = $module->getVar('version') ;
+
+	$t_mess = xpress_clean_templates_file($mydirname,$mod_version);
+	$msgs = array_merge($msgs,$t_mess);
+	
 	$t_mess = xpress_templates_make($mid,$mydirname);
-	
 	$msgs = array_merge($msgs,$t_mess);
 
@@ -97,4 +108,24 @@
 endif;
 
+if( ! function_exists( 'get_xpress_option' ) ) {
+	function get_xpress_option($mydirname,$option_name){
+		global $xoopsModule;
+		$wp_prefix = $mydirname;
+		if ($wp_prefix == 'wordpress'){
+			$wp_prefix = 'wp';
+		}
+		$xoopsDB =& Database::getInstance();
+		$option_table = $xoopsDB->prefix($wp_prefix . '_options');
+
+		$sql = "SELECT option_value FROM $option_table WHERE option_name = '" . $option_name . "'";
+		
+		$result =  $xoopsDB->query($sql, 0, 0);
+		if ($xoopsDB->getRowsNum($result)  > 0){
+			$row = $xoopsDB->fetchArray($result);
+			return $row['option_value'];
+		}
+		return 0;
+	}
+}
 
 if( ! function_exists( 'xpress_message_append_onupdate' ) ) :
@@ -190,4 +221,22 @@
 			$db->queryF( $queries ) ;
 			$msgs[] = "$views_table  ADD blog_id .";
+		}
+		
+		// The table is repaired.
+		$non_blogid_sql ="SELECT * FROM $views_table WHERE blog_id IS NULL OR blog_id < 1";
+		$non_blogid_res = $db->query($non_blogid_sql, 0, 0);
+		while($row = $db->fetchArray($non_blogid_res)){
+			$total_view = $row['post_views'];
+			$post_id = $row['post_id'];
+			$new_blogid_sql ="SELECT SUM(post_views) as post_views_sum FROM $views_table WHERE post_id = $post_id AND blog_id = 1 GROUP BY post_id";
+			$new_blogid_res = $db->query($new_blogid_sql, 0, 0);
+			if ($db->getRowsNum($new_blogid_res)  > 0){
+				$new_row = $db->fetchArray($new_blogid_res);
+				$total_view = $total_view + $new_row['post_views_sum'];
+				$del_sql = "DELETE FROM $views_table WHERE post_id = $post_id AND blog_id = 1";
+				$db->queryF( $del_sql ) ;
+			}
+			$update_sql = "UPDATE $views_table SET post_views = $total_view , blog_id = 1 WHERE post_id = $post_id AND (blog_id IS NULL OR blog_id < 1)";
+			$db->queryF( $update_sql ) ;
 		}
 	}
Index: branches/XPressMU/xpressme_integration_kit/include/set_cash_cookie_path.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/include/set_cash_cookie_path.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/include/set_cash_cookie_path.php	(revision 488)
@@ -8,5 +8,5 @@
  */
 if ( !defined('USER_COOKIE') )
-	define('USER_COOKIE', $modname . 'user_' . $hash);
+	define('USER_COOKIE', 'wordpress_' . $modname . '_user_' . $hash);
 
 /**
@@ -15,5 +15,5 @@
  */
 if ( !defined('PASS_COOKIE') )
-	define('PASS_COOKIE', $modname . 'pass_' . $hash);
+	define('PASS_COOKIE', 'wordpress_' . $modname . '_pass_' . $hash);
 
 /**
@@ -22,5 +22,5 @@
  */
 if ( !defined('AUTH_COOKIE') )
-	define('AUTH_COOKIE', $modname . '_auth_' . $hash);
+	define('AUTH_COOKIE', 'wordpress_' . $modname . '_auth_' . $hash);
 
 /**
@@ -29,5 +29,5 @@
  */
 if ( !defined('SECURE_AUTH_COOKIE') )
-	define('SECURE_AUTH_COOKIE', $modname . '_sec_' . $hash);
+	define('SECURE_AUTH_COOKIE', 'wordpress_' . $modname . '_sec_' . $hash);
 
 /**
@@ -36,5 +36,5 @@
  */
 if ( !defined('LOGGED_IN_COOKIE') )
-	define('LOGGED_IN_COOKIE', $modname . '_logged_in_' . $hash);
+	define('LOGGED_IN_COOKIE', 'wordpress_' . $modname . '_logged_in_' . $hash);
 
 /**
@@ -43,5 +43,5 @@
  */
 if ( !defined('TEST_COOKIE') )
-	define('TEST_COOKIE', $modname . '_test_cookie');
+	define('TEST_COOKIE', 'wordpress_' . $modname . '_test_cookie');
 
 /**
Index: branches/XPressMU/xpressme_integration_kit/include/xpress_block_render.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/include/xpress_block_render.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/include/xpress_block_render.php	(revision 488)
@@ -29,5 +29,7 @@
 			$ret = @xpress_XML_unserialize($xml_data);
 			if (strstr($xml_data, '<?xml version="1.0" encoding="EUC-JP" ?>') !== false){
-				$ans = mb_convert_variables('EUC-JP' , 'UTF-8', &$ret);
+				if (version_compare(PHP_VERSION, '5.0.0', '>')) {
+					$ans = mb_convert_variables('EUC-JP' , 'UTF-8', &$ret); //xpress_XML_unserialize() Return UTF-8 at PHP5
+				}
 			}
 			return $ret;
@@ -52,4 +54,18 @@
 			}
 			return $block_id;
+	}
+
+	function get_block_mid($mydirname)
+	{
+			$xoopsDB =& Database::getInstance();
+			$modules_tbl = $xoopsDB->prefix('modules');	
+
+			$sql = "SELECT mid FROM $modules_tbl WHERE dirname = '$mydirname'";
+			$result =  $xoopsDB->query($sql, 0, 0);
+			if ($xoopsDB->getRowsNum($result)  > 0){
+				$row = $xoopsDB->fetchArray($result);
+				$mid = $row['mid'];
+			}
+			return $mid;
 	}
 
@@ -160,5 +176,5 @@
 	function xpress_block_render($mydirname,$block_function_name,$options)
 	{
-		global $wpdb;
+		global $wpdb,$xoops_config;
 		$func_file = $block_function_name;
 		$call_theme_function_name = str_replace(".php", "", $block_function_name);
@@ -167,9 +183,9 @@
 		$blockID =get_block_id($mydirname,$func_file,$options);		
 
-		$this_url = '/modules/'. $mydirname;
+		$this_block_url = '/' . $mydirname . '/';
 		$call_url = $_SERVER['REQUEST_URI'];
 		
 		xpress_block_css_set($mydirname);
-		if (strstr($call_url,$this_url)){			
+		if (strstr($call_url , $this_block_url) !== false){
 			$block_theme_file = get_block_file_path($mydirname,$inc_theme_file_name);
 			require_once $block_theme_file['file_path'];
@@ -185,10 +201,47 @@
 			}
 		}
-
-		$templates_file = 'db:'.$mydirname. '_' . str_replace(".php", ".html", $block_function_name);
+		$temp_option = explode(':' , $options[1]);
+		
+		if (isset($temp_option[1])) {
+			$templates_file = $temp_option[1];
+		} else {
+			$templates_file = 'db:'.$mydirname. '_' . str_replace(".php", ".html", $block_function_name);
+		}
+		
 		$tpl =& new XoopsTpl() ;
+		$tpl->template_dir = $xoops_config->module_path . '/templates';
+		if (!$tpl->template_exists($templates_file)){
+			$src_file_path = $xoops_config->module_path . '/templates/' .$mydirname. '_' . str_replace(".php", ".html", $block_function_name);
+			$templates_file = add_xpress_tpl($mydirname,$templates_file,$src_file_path);
+		}
 		$tpl->assign( 'block' , $block ) ;
 		$ret['content'] = $tpl->fetch( $templates_file ) ;
 		return $ret ;
+	}
+	
+	function add_xpress_tpl($mydirname,$templates='',$src_file_path){
+		global $wpdb,$xoops_config , $xoops_db;
+		
+		$mid = get_block_mid($mydirname);
+
+		$temp_parm = explode(':' , $templates);
+		if (empty($temp_parm[1])) {
+			$filename=$temp_parm[0];
+			$type = 'db';
+		} else  {
+			$filename=$temp_parm[1];
+			$type = $temp_parm[0];
+		}
+		$temp_file_path = $xoops_config->module_path . '/templates/'. $filename;
+		$pattern = '^' . $mydirname . '_';
+		if (preg_match('/' . $pattern . '/' , $filename, $match)){ // file prefix check
+			if (!file_exists($temp_file_path)){		// Repetition check
+				if (file_exists($src_file_path)){	// source file check
+					$rcd = copy($src_file_path, $temp_file_path);
+				}
+			}
+			return  'file:' . $filename;
+		}
+		return $templates;
 	}
 	
@@ -243,4 +296,5 @@
 	{
 		global $xoops_db,$xoops_config;
+		
 		$mid = get_xpress_modid();
 		$sql = "SELECT bid,options,func_file FROM " . get_xoops_prefix() . "newblocks WHERE mid = $mid AND visible = 1";
@@ -260,5 +314,5 @@
         if ($dh = opendir($cache_dir)) {
             while (($file = readdir($dh)) !== false) {
-                if (preg_match('/^' . preg_quote($mydirname) . '/', $file)) {
+                if (preg_match('/^' . preg_quote($mydirname) . '_/', $file)) {
                 	if(! preg_match('/' . $pattern . '/', $file)) {
                     	unlink($cache_dir.$file);
@@ -287,6 +341,5 @@
 			return $xu_row['conf_value'];
 		}
-	}
-	
+	}	
 }	
 ?>
Index: branches/XPressMU/xpressme_integration_kit/include/xpress_templates_make.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/include/xpress_templates_make.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/include/xpress_templates_make.php	(revision 488)
@@ -7,4 +7,6 @@
 	$tplfile_handler =& xoops_gethandler( 'tplfile' ) ;
 	$tpl_path = XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/templates' ;
+	
+	//copy  template file from source
 	if( $handler = @opendir( $tpl_path . '/source/' ) ) {
 		while( ( $file = readdir( $handler ) ) !== false ) {
@@ -26,34 +28,19 @@
 					$msgs[] = '<span style="color:#ff0000;">ERROR: Could not copy template <b>'.htmlspecialchars($target_file_name).'</b> from ' . htmlspecialchars($file). '(check templates directory permision (777))</span><br />';
 				}					
-				$tplfile =& $tplfile_handler->create() ;
-				if ($rcd) {
-					$mtime = intval( @filemtime( $target_file_path ) ) ;
-					$tplfile->setVar( 'tpl_source' , file_get_contents( $target_file_path ) , true ) ;
-				} else {
-					$mtime = intval( @filemtime( $file_path ) ) ;
-					$tplfile->setVar( 'tpl_source' , file_get_contents( $file_path ) , true ) ;
-				}
-
-				$tplfile->setVar( 'tpl_refid' , $mid ) ;
-				$tplfile->setVar( 'tpl_tplset' , 'default' ) ;
-				$tplfile->setVar( 'tpl_file' , $target_file_name ) ;
-				$tplfile->setVar( 'tpl_desc' , '' , true ) ;
-				$tplfile->setVar( 'tpl_module' , $mydirname ) ;
-				$tplfile->setVar( 'tpl_lastmodified' , $mtime ) ;
-				$tplfile->setVar( 'tpl_lastimported' , 0 ) ;
-				$tplfile->setVar( 'tpl_type' , 'module' ) ;
-				if( ! $tplfile_handler->insert( $tplfile ) ) {
-					$msgs[] = '<span style="color:#ff0000;">ERROR: Could not insert template <b>'.htmlspecialchars($target_file_name).'</b> to the database.</span><br />';
-				} else {
-					$tplid = $tplfile->getVar( 'tpl_id' ) ;
-					$msgs[] = 'Template <b>'.htmlspecialchars($target_file_name) .'</b> added to the database. (ID: <b>'.$tplid.'</b>)<br />';
-					// generate compiled file
-					include_once XOOPS_ROOT_PATH.'/class/xoopsblock.php' ;
-					include_once XOOPS_ROOT_PATH.'/class/template.php' ;
-					if( ! xoops_template_touch( $tplid ) ) {
-						$msgs[] = '<span style="color:#ff0000;">ERROR: Failed compiling template <b>'.htmlspecialchars($target_file_name).'</b>.</span><br />';
-					} else {
-						$msgs[] = 'Template <b>'.htmlspecialchars($target_file_name).'</b> compiled.</span><br />';
-					}
+			}
+		}
+		closedir( $handler ) ;
+	}
+	
+	// template added to the database.
+	if( $handler = @opendir( $tpl_path . '/' ) ) {
+		while( ( $file = readdir( $handler ) ) !== false ) {
+			if( substr( $file , 0 , 1 ) == '.' ) continue ;
+			$file_path = $tpl_path . '/' . $file ;
+			$file_name = $file ;
+			$pattern = '^' . $mydirname . '_';
+			if (preg_match('/' . $pattern . '/' , $file_name, $match)){
+				if( is_file( $file_path ) ) {
+					$msgs[] = xpress_create_db_template($file_name,$file_path,$mydirname,$mid);
 				}
 			}
@@ -61,4 +48,5 @@
 		closedir( $handler ) ;
 	}
+	
 	include_once XOOPS_ROOT_PATH.'/class/xoopsblock.php' ;
 	include_once XOOPS_ROOT_PATH.'/class/template.php' ;
@@ -68,4 +56,35 @@
 }
 
+function xpress_create_db_template($file_name,$file_path,$mydirname,$mid){
+	if( is_file( $file_path ) ) {
+		$tplfile_handler =& xoops_gethandler( 'tplfile' ) ;
+		$tplfile =& $tplfile_handler->create() ;
+		$mtime = intval( @filemtime( $file_path ) ) ;
+		$tplfile->setVar( 'tpl_source' , file_get_contents( $file_path ) , true ) ;
+		$tplfile->setVar( 'tpl_refid' , $mid ) ;
+		$tplfile->setVar( 'tpl_tplset' , 'default' ) ;
+		$tplfile->setVar( 'tpl_file' ,  $file_name ) ;
+		$tplfile->setVar( 'tpl_desc' , '' , true ) ;
+		$tplfile->setVar( 'tpl_module' , $mydirname ) ;
+		$tplfile->setVar( 'tpl_lastmodified' , $mtime ) ;
+		$tplfile->setVar( 'tpl_lastimported' , 0 ) ;
+		$tplfile->setVar( 'tpl_type' , 'module' ) ;
+		if( ! $tplfile_handler->insert( $tplfile ) ) {
+			$msg = '<span style="color:#ff0000;">ERROR: Template Could not added to the database. <b>'.htmlspecialchars($file_name).'</b> to the database.</span><br />';
+		} else {
+			$tplid = $tplfile->getVar( 'tpl_id' ) ;
+			$msg = 'Template <b>'.htmlspecialchars($file_name) .'</b> added to the database. (ID: <b>'.$tplid.'</b>)<br />';
+			// generate compiled file
+			include_once XOOPS_ROOT_PATH.'/class/xoopsblock.php' ;
+			include_once XOOPS_ROOT_PATH.'/class/template.php' ;
+			if( ! xoops_template_touch( $tplid ) ) {
+				$msg = '<span style="color:#ff0000;">ERROR: Failed compiling template <b>'.htmlspecialchars($file_name).'</b>.</span><br />';
+			} else {
+				$msg = 'Template <b>'.htmlspecialchars($file_name).'</b> compiled.</span><br />';
+			}
+		}
+	}
+	return $msg;
+}
 
 function is_template($file_name){
@@ -96,4 +115,46 @@
 }
 
+function xpress_clean_templates_file($mydirname,$mod_version)
+{
+	$tpl_path = XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/templates/' ;
+	$msgs = array();
+	if( $handler = @opendir( $tpl_path) ) {
+		while( ( $file = readdir( $handler ) ) !== false ) {
+			if( substr( $file , 0 , 1 ) == '.' ) continue ;
+			if ( strcmp($file,'source')==0 ) continue ;
+			if ( strcmp($file,'index.html')==0 ) continue ;
+			$target_file_path = $tpl_path . $file;
+			if (is_dir($target_file_path)){
+				rmDirectory($target_file_path);
+				$msgs[] = 'Template <b>'.htmlspecialchars($file).'</b> directory deleted.</span><br />';
+			} else {
+				if ($mod_version >= 200){
+					$pattern = '^' . $mydirname . '_';
+					if (preg_match('/' . $pattern . '/' , $file, $match))  continue ;
+				}
+				$rcd = @unlink($target_file_path);
+				$msgs[] = 'Template <b>'.htmlspecialchars($file).'</b> file deleted.</span><br />';
+			}
+		}
+		closedir( $handler ) ;
+	}
+	return $msgs;
+}
+
+function rmDirectory($dir){
+	if ($handle = opendir("$dir")){
+		while (false !== ($item = readdir($handle))){
+			if ($item != "." && $item != ".."){
+				if (is_dir("$dir/$item")){
+					rmDirectory("$dir/$item");
+				}else{
+					unlink("$dir/$item");
+				}
+			}
+		}
+		closedir($handle);
+		rmdir($dir);
+	}
+}
 
 ?>
Index: branches/XPressMU/xpressme_integration_kit/language/english/blocks.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/language/english/blocks.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/language/english/blocks.php	(revision 488)
@@ -26,4 +26,5 @@
 	define("_MB_XP2_LIST","List");
 	define("_MB_XP2_FILE_NAME","Files Name");
+	define("_MB_XP2_THISTEMPLATE","Template");
 	
 // recent comment block	
@@ -107,5 +108,5 @@
 	
 // Categorie
-	define("_MB_XP2_CAT_ALL_STR","All categories link Display Title. (blank is not displayj");
+	define("_MB_XP2_CAT_ALL_STR","All categories link Display Title. (blank is not display)");
 	define("_MB_XP2_CAT_ORDERBY","Order of the categories");
 	define("_MB_XP2_CAT_NAME","name");
Index: branches/XPressMU/xpressme_integration_kit/language/english/modinfo.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/language/english/modinfo.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/language/english/modinfo.php	(revision 488)
@@ -22,4 +22,5 @@
 	define("_MI_XP2_MENU_XPRESS","XPressME Setting");
 	define("_MI_XP2_MENU_TO_MODULE","to Modules");
+	define("_MI_XP2_TO_UPDATE","Update");
 
 	// Module Config
Index: branches/XPressMU/xpressme_integration_kit/language/ja_utf8/blocks.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/language/ja_utf8/blocks.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/language/ja_utf8/blocks.php	(revision 488)
@@ -26,4 +26,5 @@
 	define("_MB_XP2_LIST","リスト");
 	define("_MB_XP2_FILE_NAME","ファイル名");
+	define("_MB_XP2_THISTEMPLATE","このブロックのテンプレート");
 	
 // recent comment block	
Index: branches/XPressMU/xpressme_integration_kit/language/ja_utf8/modinfo.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/language/ja_utf8/modinfo.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/language/ja_utf8/modinfo.php	(revision 488)
@@ -22,4 +22,5 @@
 	define("_MI_XP2_MENU_XPRESS","XPressME設定");
 	define("_MI_XP2_MENU_TO_MODULE","モジュールへ");
+	define("_MI_XP2_TO_UPDATE","アップデート");
 
 	// Module Config
Index: branches/XPressMU/xpressme_integration_kit/wp-content/plugins/xpressme/include/custom_functions.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/wp-content/plugins/xpressme/include/custom_functions.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/wp-content/plugins/xpressme/include/custom_functions.php	(revision 488)
@@ -95,5 +95,5 @@
 
 	$output = '';
-  	$author_cookie = get_xpress_dir_name() . "_select_author" ;
+  	$author_cookie = 'select_' . get_xpress_dir_name() . "_author" ;
   	if (!empty($_COOKIE[$author_cookie])){
   		$uid = intval($_COOKIE[$author_cookie]);
@@ -115,5 +115,5 @@
 	extract( $r );
 	$output = '';
-  	$author_cookie = get_xpress_dir_name() . "_select_author" ;
+  	$author_cookie = 'select_' . get_xpress_dir_name() . "_author" ;
   	if (!empty($_COOKIE[$author_cookie])){
   		$output = intval($_COOKIE[$author_cookie]);
@@ -161,8 +161,9 @@
 	$xpress_codename = $xoops_config->module_codename;
 	if ($no_link){
-		$output = 'XPressMU Ver.' . sprintf('%.2f %s',$xpress_version,$xpress_codename);
 		if ($xoops_config->is_wpmu) {
+			$output = 'XPressMU Ver.' . sprintf('%.2f %s',$xpress_version,$xpress_codename);
 			$output .= '(included WordPress MU ' . $wpmu_version. ')';
 		} else {
+			$output = 'XPressME Ver.' . sprintf('%.2f %s',$xpress_version,$xpress_codename);
 			if (strstr($wp_version,'ME')){
 				$output .= '(included WordPress ' . $wp_version . ')';
@@ -172,8 +173,9 @@
 		}
 	} else {
-		$output = '<a href="http://ja.xpressme.info"'. " target='_blank'" . '>XPressMU Ver.' . sprintf('%.2f %s',$xpress_version,$xpress_codename) .'</a>';
 		if ($xoops_config->is_wpmu) {
+			$output = '<a href="http://ja.xpressme.info"'. " target='_blank'" . '>XPressMU Ver.' . sprintf('%.2f %s',$xpress_version,$xpress_codename) .'</a>';
 			$output .= '(included <a href="http://mu.wordpress.org/" title="Powered by WordPress"'." target='_blank'". '>WordPress MU ' . $wpmu_version . '</a>)';
 		} else {
+			$output = '<a href="http://ja.xpressme.info"'. " target='_blank'" . '>XPressME Ver.' . sprintf('%.2f %s',$xpress_version,$xpress_codename) .'</a>';
 			if (strstr($wp_version,'ME')){
 				$output .= '(included <a href="http://wpme.sourceforge.jp/" title="Powered by WordPress"'." target='_blank'". '>WordPress ' . $wp_version . '</a>)';
@@ -467,5 +469,5 @@
 }
 
-function set_post_views_count(&$content) {
+function set_post_views_count($content) {
 	if ( empty($_GET["feed"]) &&  empty($GLOBALS["feed"]) && empty($GLOBALS["doing_trackback"]) && empty($GLOBALS["doing_rss"]) && empty($_POST) && is_single() ){
 		post_views_counting();
Index: branches/XPressMU/xpressme_integration_kit/wp-content/plugins/xpressme/include/functions_for_wp_old.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/wp-content/plugins/xpressme/include/functions_for_wp_old.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/wp-content/plugins/xpressme/include/functions_for_wp_old.php	(revision 488)
@@ -190,4 +190,27 @@
 
 endif;	// Under WP2.5
+
+// Under WP2.7
+if (version_compare($xoops_config->wp_version,'2.6', '<')) :
+	/**
+	 * Guess the URL for the site.
+	 *
+	 * Will remove wp-admin links to retrieve only return URLs not in the wp-admin
+	 * directory.
+	 *
+	 * @since 2.6.0
+	 *
+	 * @return string
+	 */
+	function wp_guess_url() {
+	if ( defined('WP_SITEURL') && '' != WP_SITEURL ) {
+		$url = WP_SITEURL;
+	} else {
+		$schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
+		$url = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
+	}
+	return $url;
+}
+endif;	// Under WP2.6
 
 // Under WP2.7
Index: branches/XPressMU/xpressme_integration_kit/wp-content/plugins/xpressme/include/xpress_common_functions.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/wp-content/plugins/xpressme/include/xpress_common_functions.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/wp-content/plugins/xpressme/include/xpress_common_functions.php	(revision 488)
@@ -242,5 +242,5 @@
 	if (is_admin()) return $query_vars;
 	
-	$author_cookie = get_xpress_dir_name() . "_select_author" ;
+	$author_cookie = 'select_' . get_xpress_dir_name() . "_author" ;
 	if(xpress_is_multi_user()){
 		if (!empty($_GET)){
@@ -290,9 +290,9 @@
 }
 
-function xpress_query_filter(&$query)
+function xpress_query_filter($query)
 {
 	if (is_admin()) return $query;
 
-	$author_cookie = get_xpress_dir_name() . "_select_author" ;
+	$author_cookie = 'select_' . get_xpress_dir_name() . "_author" ;
 	
 	if (strpos($query,'SELECT') === false)  return $query;
@@ -357,12 +357,4 @@
 }
 
-function safe_site_url_filter($site_url){
-	global $xoops_config;
-	if (!$xoops_config->is_wpmu){
-		if ($site_url != get_xpress_url()) $site_url = get_xpress_url();
-	}
-	return $site_url;
-}
-
 function get_block_file_path($mydirname,$file_name)
 {
Index: branches/XPressMU/xpressme_integration_kit/wp-content/plugins/xpressme/xpressme.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/wp-content/plugins/xpressme/xpressme.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/wp-content/plugins/xpressme/xpressme.php	(revision 488)
@@ -71,9 +71,4 @@
 }
 add_action("wp_meta" , "wp_meta_add_xpress_menu");			// add xpress menu  in wp_meta
-	
-//Site URL check
-add_filter('option_home',			"safe_site_url_filter");
-add_filter('option_siteurl',		"safe_site_url_filter");
-	
 
 //XOOPS Bloack Cache Refresh
@@ -301,6 +296,6 @@
 
 include_once dirname( __FILE__ ).'/include/dashboard_feed.php' ;
-
-include_once dirname( __FILE__ ).'/xpressme_widget_class.php' ;
-
+if(xpress_is_wp_version('>=','2.8')){
+	include_once dirname( __FILE__ ).'/xpressme_widget_class.php' ;
+}
 ?>
Index: branches/XPressMU/xpressme_integration_kit/xoops_version.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/xoops_version.php	(revision 452)
+++ branches/XPressMU/xpressme_integration_kit/xoops_version.php	(revision 488)
@@ -47,5 +47,5 @@
 
 // status
-$modversion['codename'] = "RC1";
+$modversion['codename'] = "";
 
 // onInstall, onUpdate, onUninstall
