Index: trunk/wp-content/plugins/xpressme/include/common_functions.php
===================================================================
--- trunk/wp-content/plugins/xpressme/include/common_functions.php	(revision 95)
+++ 	(revision )
@@ -1,77 +1,0 @@
-<?php
-// xoops db
-function get_xpress_dir_path()
-{
-	return ABSPATH;
-}
-
-function get_xpress_dir_name()
-{
-	return basename(ABSPATH);
-}
-
-function get_wp_prefix_only()
-{
-	$dir_name = get_xpress_dir_name();
-	$prefix = $dir_name;
-	if ($prefix == 'wordpress') $prefix = 'wp';
-	
-	$prefix = $prefix . '_';
-	return $prefix;
-}
-
-function get_xoops_prefix()
-{
-	global $xoops_config;
-	$ret =$xoops_config->xoops_db_prefix . '_';
-	return $ret;
-}
-function get_wp_prefix()
-{
-	$prefix = get_xoops_prefix() . get_wp_prefix_only();
-	return $prefix;
-}
-
-function get_xpress_modid()
-{
-	global $xoops_db;
-	
-	$modulename = get_xpress_dir_name();	
-	$sql = "SELECT mid FROM " . get_xoops_prefix() . "modules WHERE dirname = '$modulename'";
-	$mid = $xoops_db->get_var($sql);
-	return $mid;	
-}
-
-function get_xpress_db_version()
-{
-	include get_xpress_dir_path() . '/wp-includes/version.php';
-	return $wp_db_version;
-}
-
-function block_cache_refresh()
-{
-	global $xoops_db;
-	$mid = get_xpress_modid();
-	$sql = "SELECT bid,options,func_file FROM " . get_xoops_prefix() . "newblocks WHERE mid = $mid";
-	$blocks = $xoops_db->get_results($sql);
-	$mydirname = get_xpress_dir_name();
-	require_once get_xpress_dir_path() . '/include/xpress_block_render.php';
-
-
-	foreach($blocks as $block){
-		$func_file = $block->func_file;
-		$call_theme_function_name = str_replace(".php", "", $func_file);
-		$inc_theme_file_name = str_replace(".php", "", $func_file) . '_theme.php';
-		$cache_title = str_replace(".php", "", $func_file);
-		$blockID = $block->bid;
-		$options = explode("|", $block->options);
-					
-		$block_theme_file = get_block_file_path($mydirname,$inc_theme_file_name);
-		require_once $block_theme_file;
-		$block_render = $call_theme_function_name($options);		//The block name and the called function name should be assumed to be the same name. 			
-		$xml['block'] = $block_render;
-		xpress_block_cache_write($mydirname,$cache_title. $blockID, $xml);
-	}
-}
-
-?>
Index: trunk/wp-content/plugins/xpressme/include/custom_functions.php
===================================================================
--- trunk/wp-content/plugins/xpressme/include/custom_functions.php	(revision 95)
+++ trunk/wp-content/plugins/xpressme/include/custom_functions.php	(revision 96)
@@ -3,7 +3,9 @@
 function xpress_credit($show = false)
 {
-	global $xoopsModule,$wp_version;
-	
-	$ret = '<a href="http://www.toemon.com"'. " target='_blank'" . '>XPressME Ver.' . sprintf('%.2f %s',$xoopsModule->getInfo('version'),$xoopsModule->getInfo('codename')) .'</a>';
+	global $wp_version , $modversion;
+	
+	$xpress_version = $modversion['version'];
+	$xpress_codename = $modversion['codename'];
+	$ret = '<a href="http://www.toemon.com"'. " target='_blank'" . '>XPressME Ver.' . sprintf('%.2f %s',$xpress_version,$xpress_codename) .'</a>';
 	if (strstr($wp_version,'ME')){
 		$ret .= '(included <a href="http://wpme.sourceforge.jp/" title="Powered by WordPress"'." target='_blank'". '>WordPress ' . $wp_version . '</a>)';
@@ -192,4 +194,5 @@
 // Set post views given a post ID or post object. 
 function post_views_counting($post_id = 0) {
+	global $xoops_db,$wpdb;
 	global $table_prefix;
 	static $views;
@@ -201,5 +204,5 @@
 
 
-	$views_db = $table_prefix . "views";
+	$views_db = get_wp_prefix() . 'views';
 
 	if($post_id==0 || !empty($views[$post_id])) return null;
@@ -212,20 +215,11 @@
 
     $sql = "SELECT post_views FROM " . $views_db . " WHERE post_id=$post_id";
-    $exist = false;
-    if ($result = $GLOBALS["xoopsDB"]->query($sql)) {
-        while($row = $GLOBALS["xoopsDB"]->fetchArray($result)){
-        	$exist = true;
-	        break;
-    	}
-	}
-	if($exist){
+	$post_views_found = $xoops_db->get_var($sql);
+	if($post_views_found){
         $sql = "UPDATE " . $views_db . " SET post_views=post_views+1 WHERE post_id=$post_id";
     }else{
         $sql = "INSERT INTO " . $views_db . " (post_id, post_views) VALUES ($post_id, 1)";
     }
-    if ($result = $GLOBALS["xoopsDB"]->queryF($sql)) {
-    	$views[$post_id] = 1;
-    }
-    
+    $xoops_db->query($sql);
 	return true;
 }
Index: trunk/wp-content/plugins/xpressme/include/notify_functions.php
===================================================================
--- trunk/wp-content/plugins/xpressme/include/notify_functions.php	(revision 95)
+++ trunk/wp-content/plugins/xpressme/include/notify_functions.php	(revision 96)
@@ -48,7 +48,6 @@
 		$_SERVER['REQUEST_METHOD'] = 'POST';
 	}
-	
-	include_once $xoops_config->xoops_mainfile_path;	// load XOOPS System
-	include_once $xoops_config->xoops_root_path . '/include/notification_functions.php' ;
+//	set_error_handler("xpress_error_handler");
+	require $xoops_config->xoops_mainfile_path;	// load XOOPS System
 	$module_id = get_xpress_modid() ;
 	$notification_handler =& xoops_gethandler( 'notification' ) ;
@@ -58,7 +57,4 @@
 function do_CommentWaiting($commentID, $comment_post_ID)
 {
-//	global $xoops_config;
-//	require_once $xoops_config->xoops_mainfile_path;
-//	xoops_mainfile_path;
 //	require_once XOOPS_ROOT_PATH . '/include/notification_functions.php' ;
 //	$notification_handler =& xoops_gethandler( 'notification' ) ;
@@ -120,5 +116,4 @@
 {
 	global $xoops_config, $xoops_db;
-	xpress_debug();
 	
 
Index: trunk/wp-content/plugins/xpressme/include/pluggable-override.php
===================================================================
--- trunk/wp-content/plugins/xpressme/include/pluggable-override.php	(revision 95)
+++ trunk/wp-content/plugins/xpressme/include/pluggable-override.php	(revision 96)
@@ -56,4 +56,5 @@
 endif;
 
+if ( !function_exists('xpress_login') ) :
 function xpress_login(){
 	global $current_user;
@@ -81,5 +82,7 @@
 	return 0;	
 }
+endif;
 
+if ( !function_exists('check_xpress_auth_cookie') ) :
 function check_xpress_auth_cookie() {		// for wp2.5
 	if ( empty($_COOKIE[AUTH_COOKIE]) ){
@@ -112,4 +115,5 @@
 	return false;
 }
+endif;
 
 if ( !function_exists('wp_check_password') ) :
Index: trunk/wp-content/plugins/xpressme/include/xpress_common_functions.php
===================================================================
--- trunk/wp-content/plugins/xpressme/include/xpress_common_functions.php	(revision 95)
+++ trunk/wp-content/plugins/xpressme/include/xpress_common_functions.php	(revision 96)
@@ -49,4 +49,56 @@
 }
 
+function is_block_cache_found($block_name)
+{
+	global $xoops_config;
+	$mydirname = get_xpress_dir_name();
+
+	if(defined('XOOPS_ROOT_PATH')){
+		$cache_dir = XOOPS_ROOT_PATH . '/cache/';
+	} else {
+		$cache_dir = $xoops_config->xoops_root_path . '/cache/';
+	}
+	$xml_name = $block_name . '.xml';
+
+    $filename = $cache_dir .$mydirname . '_' . $xml_name;
+	$cache_time = 0;
+//        if (file_exists($filename) && ((time() - filemtime($filename)) < $cache_time)) {
+    if (file_exists($filename)) {
+        return true;
+        } else {
+		return false;
+	}
+}
+
+
+//When there is no block cash, and an optional block is different, false is returned.
+function is_block_cache_normal()
+{
+	global $xoops_config;
+	global $xoops_db;
+	$mid = get_xpress_modid();
+	$sql = "SELECT bid,options,func_file FROM " . get_xoops_prefix() . "newblocks WHERE mid = $mid ";
+	$blocks = $xoops_db->get_results($sql);
+	$mydirname = get_xpress_dir_name();
+	require_once get_xpress_dir_path() . '/include/xpress_block_render.php';
+
+	foreach($blocks as $block){
+		$func_file = $block->func_file;
+		$call_theme_function_name = str_replace(".php", "", $func_file);
+		$inc_theme_file_name = str_replace(".php", "", $func_file) . '_theme.php';
+		$cache_title = str_replace(".php", "", $func_file);
+		$blockID = $block->bid;
+		$options = explode("|", $block->options);
+		
+		if (!is_block_cache_found($cache_title . $blockID)) return false;
+		$xml = xpress_block_cache_read($mydirname,$cache_title. $blockID);
+		$options = '';
+		$options = @$xml['block']['options'];
+		if( strcmp($options,$block->options) != 0 ) return false;
+	}
+	return true;
+}
+
+
 function block_cache_refresh()
 {
@@ -71,4 +123,5 @@
 		$block_render = $call_theme_function_name($options);		//The block name and the called function name should be assumed to be the same name. 			
 		$xml['block'] = $block_render;
+		$xml['block']['options'] = $block->options;
 		xpress_block_cache_write($mydirname,$cache_title. $blockID, $xml);
 	}
Index: trunk/wp-content/plugins/xpressme/xpressme.php
===================================================================
--- trunk/wp-content/plugins/xpressme/xpressme.php	(revision 95)
+++ trunk/wp-content/plugins/xpressme/xpressme.php	(revision 96)
@@ -27,12 +27,14 @@
 	remove_action( 'pre_post_update', 'wp_save_post_revision' );			// Not Save Post Revision
 }
+
+//XOOPS Bloack Cache Refresh
 add_action("comment_post",	"block_cache_refresh");
 add_action("edit_comment",	"block_cache_refresh");
-add_action("delete_comment","block_cache_refresh");
-add_action("delete_post",	"block_cache_refresh");
+add_action("wp_set_comment_status","block_cache_refresh"); //wp_delete_comment() at deleted
+add_action("deleted_post",	"block_cache_refresh");
 add_action("publish_post",	"block_cache_refresh");
 add_action("edit_post",		"block_cache_refresh");
 add_action("private_to_published",	"block_cache_refresh");
-add_action("wp_set_comment_status" , "block_cache_refresh");
+add_action("transition_post_status", "block_cache_refresh");
 
 add_action("the_content",	"set_post_views_count");
Index: trunk/wp-content/themes/xpress_default/index.php
===================================================================
--- trunk/wp-content/themes/xpress_default/index.php	(revision 95)
+++ trunk/wp-content/themes/xpress_default/index.php	(revision 96)
@@ -33,6 +33,16 @@
 				</div>
 
-				<p class="postmetadata"><!-- Post author start --><?php/* _e('Posted:', 'xpress'); echo '&nbsp;'; the_author_posts_link(); echo '<br />' ; */?><!-- Post author end --><?php if(function_exists('the_tags')) : ?><?php the_tags(__('Tags:', 'xpress') . ' ', ', ', '<br />'); ?><?php endif; ?><?php printf(__('Posted in %s', 'xpress'), get_the_category_list(', ')); ?> | <?php edit_post_link(__('Edit', 'xpress'), '', ' | '); ?>  <?php comments_popup_link(__('No Comments &#187;', 'xpress'), __('1 Comment &#187;', 'xpress'), __('% Comments &#187;', 'xpress'), '', __('Comments Closed', 'xpress') ); ?></p>
-				<?php xpress_post_views_count($post->id,__('Views :%d', 'xpress'),true) ?>
+				<p class="postmetadata"><!-- Post author start -->
+				<!-- Post author end -->
+				<?php
+					if(function_exists('the_tags'))
+						echo the_tags(__('Tags:', 'xpress') . ' ', ', ', '<br />');
+					printf(__('Posted in %s', 'xpress'), get_the_category_list(', '));
+					echo ' | ';
+					edit_post_link(__('Edit', 'xpress'), '', ' | ');
+					comments_popup_link(__('No Comments &#187;', 'xpress'), __('1 Comment &#187;', 'xpress'), __('% Comments &#187;', 'xpress'), '', __('Comments Closed', 'xpress') );
+				?>
+				</p>
+				<?php xpress_post_views_count($post->ID,__('Views :%d', 'xpress'),true) ?>
 
 				</div>
Index: trunk/wp-content/themes/xpress_default/searchform.php
===================================================================
--- trunk/wp-content/themes/xpress_default/searchform.php	(revision 95)
+++ trunk/wp-content/themes/xpress_default/searchform.php	(revision 96)
@@ -1,5 +1,5 @@
 <form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
 <label class="hidden" for="s"><?php _e('Search for:', 'xpress'); ?></label>
-<div><input type="text" value="<?php if(function_exists('the_serch_query')) : ?><?php the_search_query(); ?><?php else : ?><?php echo attribute_escape($s); ?><?php endif; ?>" name="s" id="s" />
+<div><input type="text" value="<?php the_search_query(); ?>" name="s" id="s" />
 <input type="submit" id="searchsubmit" value="<?php _e('Search', 'xpress'); ?>" />
 </div>
