function xoops_uid_to_wp_uid($xoops_uid = '',$mydirname){ global $xoopsDB,$xoops_db; if (empty($mydirname)) $mydirname = basename( dirname( dirname( __FILE__ ) ) ) ; $wp_prefix = preg_replace('/wordpress/','wp',$mydirname); if (empty($xoops_db)) { // not load XPressME $xoops_user_tbl = $xoopsDB->prefix('users'); $wp_user_tbl = $xoopsDB->prefix($wp_prefix . "_users"); $xoops_user_SQL ="SELECT uname FROM $xoops_user_tbl WHERE uid = $xoops_uid"; $xoops_user_Res = $xoopsDB->query($xoops_user_SQL, 0, 0); if ($xoopsDB->getRowsNum($xoops_user_Res) > 0){ $xoops_user_Row = $xoopsDB->fetchArray($xoops_user_Res); $xoops_user_name = $xoops_user_Row['uname']; $wp_user_SQL ="SELECT ID FROM $wp_user_tbl WHERE user_login LIKE '$xoops_user_name'"; $wp_user_Res = $xoopsDB->query($wp_user_SQL, 0, 0); if ($xoopsDB->getRowsNum($wp_user_Res) > 0){ $wp_user_Row = $xoopsDB->fetchArray($wp_user_Res); $wp_user_id = $wp_user_Row['ID']; return $wp_user_id; } } return 0; } else { // load XPressME or not Load XOOPS $xoops_user_tbl = get_xoops_prefix() . 'users'; $wp_user_tbl = get_wp_prefix() . 'users'; $xoops_user_name = $xoops_db->get_var("SELECT uname FROM $xoops_user_tbl WHERE uid = $xoops_uid"); if (empty($xoops_user_name)) return 0; $wp_user_id = $xoops_db->get_var("SELECT ID FROM $wp_user_tbl WHERE user_login LIKE '$xoops_user_name'"); if (!empty($wp_user_id)) return $wp_user_id; else return 0; } }
function popular_posts_block($options) { $mydirname = empty($options[0]) ? 'xpress' : $options[0]; $this_template = empty($options[1]) ? 'db:' . $mydirname . '_block_popular.html' : trim($options[1]); $disp_count = empty($options[2]) ? '10' : $options[2]; $show_month_range = empty($options[3]) ? '0' : $options[3]; $date_format = empty($options[4]) ? '' : $options[4]; $time_format = empty($options[5]) ? '' : $options[5]; $tag_select = $options[6]; $cat_select = empty($options[7]) ? '0' : $options[7]; $selected = explode(',', $cat_select); $mydirpath = get_xpress_dir_path(); if (empty($date_format)) { $date_format = get_settings('date_format'); } if (empty($time_format)) { $time_format = get_settings('time_format'); } if (array_search(0, $selected) === 0) { $cat_select = 0; } $cat_select; $block = array(); $item_no = 0; $selected_author_id = xpress_selected_author_id('echo=0'); global $wpdb, $wp_query, $xoops_db; $db_prefix = get_wp_prefix(); $post_tb = $wpdb->posts; $view_tb = $db_prefix . 'views'; $user_tb = $db_prefix . 'users'; $term_relationships_tb = $wpdb->term_relationships; // upper 2.3 $term_taxonomy = $wpdb->term_taxonomy; // upper 2.3 $terms_tb = $wpdb->terms; // upper 2.3 $post2cat_tb = $wpdb->post2cat; //under 2.3 $categories_tb = $wpdb->categories; //under 2.3 include $mydirpath . '/wp-includes/version.php'; $select = "SELECT {$view_tb}.post_views, {$post_tb}.ID, {$post_tb}.post_title, {$post_tb}.post_date"; if ($wp_db_version >= 6124) { $from = " FROM ((("; $from .= " {$post_tb} LEFT JOIN {$view_tb} ON {$post_tb}.ID = {$view_tb}.post_id)"; $from .= " INNER JOIN {$term_relationships_tb} ON {$post_tb}.ID = {$term_relationships_tb}.object_id)"; $from .= " INNER JOIN {$term_taxonomy} ON {$term_relationships_tb}.term_taxonomy_id = {$term_taxonomy}.term_taxonomy_id)"; $from .= " INNER JOIN {$terms_tb} ON {$term_taxonomy}.term_id = {$terms_tb}.term_id "; $where = " WHERE {$post_tb}.post_type = 'post' AND {$post_tb}.post_status = 'publish'"; // if (!empty($selected_author_id)){ // $where .= " AND ($post_tb.post_author = $selected_author_id) "; // $where .= " AND ($post_tb.post_author = 2) "; // } if ($cat_select) { $where .= " AND ({$term_taxonomy}.term_id IN ({$cat_select}))"; } if (!empty($tag_select)) { $tag_id_list = get_tag_id($tag_select); if (!empty($tag_id_list)) { $where .= " AND ({$term_taxonomy}.term_id IN ({$tag_id_list}))"; } } } else { $from = " FROM (("; $from .= " {$post_tb} LEFT JOIN {$view_tb} ON {$post_tb}.ID = {$view_tb}.post_id)"; $from .= " LEFT JOIN {$post2cat_tb} ON {$post_tb}.ID = {$post2cat_tb}.post_id)"; $from .= " INNER JOIN {$user_tb} ON {$post_tb}.post_author = {$user_tb}.ID"; $where = " WHERE ({$post_tb}.post_status = 'publish') AND (UNIX_TIMESTAMP({$post_tb}.post_date) <= UNIX_TIMESTAMP())"; if ($cat_select) { $where .= " AND ({$post2cat_tb}.category_id IN ({$cat_select}))"; } } if ($show_month_range > 0) { $where .= " AND (UNIX_TIMESTAMP({$post_tb}.post_date) >= UNIX_TIMESTAMP(DATE_ADD(CURRENT_DATE, INTERVAL -{$show_month_range} month)))"; } $order_limmit = " GROUP BY {$post_tb}.ID ORDER BY {$view_tb}.post_views DESC LIMIT 0, {$disp_count}"; $sql = $select . $from . $where . $order_limmit; $populars = $wpdb->get_results($sql); foreach ($populars as $popular) { $wp_query->in_the_loop = true; //for use the_tags() in multi lopp $r = new WP_Query("p={$popular->ID}"); if ($r->have_posts()) { $r->the_post(); ob_start(); the_ID(); $post_id = ob_get_contents(); ob_end_clean(); ob_start(); the_title(); $title = ob_get_contents(); ob_end_clean(); ob_start(); the_permalink(); $permalink = ob_get_contents(); ob_end_clean(); ob_start(); the_author_posts_link(); $author = ob_get_contents(); ob_end_clean(); ob_start(); the_category(' • '); $category = ob_get_contents(); ob_end_clean(); if (function_exists('the_tags')) { ob_start(); the_tags(__('Tags:', 'xpress') . ' ', ' • ', ''); $tags = ob_get_contents(); ob_end_clean(); } else { $tags = ''; } ob_start(); the_modified_date($date_format); $post_modified_date = ob_get_contents(); ob_end_clean(); ob_start(); the_modified_date($time_format); $post_modified_time = ob_get_contents(); ob_end_clean(); ob_start(); the_time($date_format); $post_date = ob_get_contents(); ob_end_clean(); ob_start(); the_time($time_format); $post_time = ob_get_contents(); ob_end_clean(); ob_start(); comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)')); $comments_popup_link = ob_get_contents(); ob_end_clean(); $post_title = '<a href="' . $permalink . '">' . $title . '</a>'; $post_date_time = $post_date . ' ' . $post_time; $post_modified_date_time = $post_modified_date . ' ' . $post_modified_time; $trackback_url = trackback_url(false); $post_viwes = xpress_post_views_count('post_id=' . $post_id . '&format=' . __('Views :%d', 'xpress') . '&echo=0'); // if (empty($tags)) $tags = __('Not Tag'); $row_data = array('post_id' => $post_id, 'post_title' => $post_title, 'post_date' => $post_date, 'post_time' => $post_time, 'post_date_time' => $post_date_time, 'post_modified_date' => $post_modified_date, 'post_modified_time' => $post_modified_time, 'post_modified_date_time' => $post_modified_date_time, 'post_author' => $author, 'post_category' => $category, 'post_tags' => $tags, 'post_views' => $post_viwes, 'comment_link' => $comments_popup_link, 'trackback_url' => $trackback_url); $block['contents']['item' . $item_no] = $row_data; $item_no++; } } // end of foreach $block['data_count'] = $item_no; //xml unserialise error return $block; }
function xpress_get_blog_option($option_name,$b_id = 1) { global $wpdb; $db_prefix = get_wp_prefix(); if (empty($b_id)) $b_id =1; $blog_prefix = ''; if ($b_id >1) $blog_prefix = $b_id . '_'; $options_tb = $db_prefix . $blog_prefix .'options'; $sql = "SELECT option_value FROM $options_tb WHERE option_name = $option_name"; $ret_val = $wpdb->get_var($sql); return $ret_val; }
function ReadPostData($post_data = null) { global $xoops_db, $blog_id; if (empty($blog_id)) { if (defined(BLOG_ID_CURRENT_SITE)) { $blog_id = BLOG_ID_CURRENT_SITE; } else { $blog_id = 1; } } foreach ((array) $post_data as $index_key => $value) { if (preg_match('/^ch_/', $index_key)) { // case ch_ $indedx = preg_replace('/^ch_/', '', $index_key); $set_value = stripslashes(trim($value)); // post d3forum if ($indedx === 'd3forum') { $this->D3Forum_old_Link_clear($value); if ($value == 'none') { $this->is_use_d3forum = false; $this->d3forum_module_dir = ''; $this->d3forum_forum_id = ''; $this->d3forum_external_link_format = get_xpress_dir_name() . '::xpressD3commentContent'; } else { $d3f_set = explode('|', $value); $this->is_use_d3forum = true; $this->d3forum_module_dir = $d3f_set[1]; if (preg_match('/Create New In Cat=([0-9]*)/', $d3f_set[2], $matchs)) { $cat_id = $matchs[1]; $title = get_option('blogname'); $this->d3forum_forum_id = $this->D3Forum_create_new($this->d3forum_module_dir, $cat_id, $title); } else { $this->d3forum_forum_id = $d3f_set[2]; } $this->d3forum_external_link_format = get_xpress_dir_name() . '::xpressD3commentContent'; $this->D3Forum_link_set(); } } else { //post other if (empty($set_value)) { switch ($indedx) { case 'old_post_link_text': $set_value = __('Older Post', 'xpressme'); break; case 'newer_post_link_text': $set_value = __('Newer Post', 'xpressme'); break; case 'old_page_link_text': $set_value = __('Older Entries', 'xpressme'); break; case 'newer_page_link_text': $set_value = __('Newer Entries', 'xpressme'); break; case 'excerpt_more_link_text': $set_value = __('Read the rest of this entry »', 'xpressme'); break; case 'theme_select': $set_value = 'use_wordpress_select'; break; default: } } $this->{$indedx} = $value; } } // end of case 'ch_' } // end of loop global $xoops_config; $table = get_wp_prefix() . 'group_role'; // $sql= "SELECT * FROM $table"; // $this->groupe_role = $xoops_db->get_results($sql); // before Read foreach ($this->groupe_role as $groupe) { $post_role_gid = 'role_gid_' . $groupe->groupid; $login_all_gid = 'login_all_gid_' . $groupe->groupid; if (isset($post_data[$post_role_gid])) { $role = stripslashes(trim($post_data[$post_role_gid])); $login_all = stripslashes(trim($post_data[$login_all_gid])); if (empty($login_all)) { $login_all = '0'; } $groupe->role = $role; $groupe->login_all = $login_all; $update_sql = "UPDATE {$table} "; $update_sql .= 'SET '; $update_sql .= "role = '{$role}' , "; $update_sql .= "login_all = {$login_all} "; $update_sql .= "WHERE (groupid = '{$groupe->groupid}' AND blog_id = {$blog_id})"; $xoops_db->query($update_sql); } } }
function Notification_reserve_send() { global $xpress_config, $xoops_db; if (!defined("XOOPS_MAINFILE_INCLUDED")) { return; } $notification_handler =& xoops_gethandler('notification'); $xpress_prefix = get_wp_prefix(); $notfiy_reserve_db = $xpress_prefix . 'notify_reserve'; $extra_tags_arry = addslashes(serialize($extra_tags)); $user_list_arry = addslashes(serialize($user_list)); $sql = "SELECT * "; $sql .= "FROM {$notfiy_reserve_db} "; $sql .= "WHERE notify_reserve_status = 'reserve'"; $notify_reserves = $xoops_db->get_results($sql); //So as not to process it by other sessions while processing it, status is changed. foreach ($notify_reserves as $notify) { $notify_reserve_id = $notify->notify_reserve_id; $sql = "UPDATE {$notfiy_reserve_db} SET notify_reserve_status = 'sending' WHERE notify_reserve_id = {$notify_reserve_id}"; $xoops_db->query($sql); } foreach ($notify_reserves as $notify) { $notify_reserve_id = $notify->notify_reserve_id; $category = $notify->category; $item_id = $notify->item_id; $event = $notify->event; $extra_tags = unserialize($notify->extra_tags_arry); $user_list = unserialize($notify->user_list_arry); $module_id = $notify->module_id; $omit_user_id = $notify->omit_user_id; $notification_handler->triggerEvent($category, $item_id, $event, $extra_tags, $user_list, $module_id, $omit_user_id); $sql = "DELETE FROM {$notfiy_reserve_db} WHERE notify_reserve_id = {$notify_reserve_id}"; $xoops_db->query($sql); } }
function repair_user_meta_prefix() { global $xoops_db; // repair usermeta db $db_xpress_usermeta = get_wp_prefix() . 'usermeta'; $wp_prefix_only = get_wp_prefix_only(); $user_meta_prefix = get_wp_prefix(); $sql = "SELECT * FROM {$db_xpress_usermeta} WHERE meta_key LIKE '%_" . $wp_prefix_only . "%'"; $user_metas = $xoops_db->get_results($sql); if (!empty($user_metas)) { foreach ($user_metas as $user_meta) { if (strpos($user_meta->meta_key, $user_meta_prefix) === false) { $new_meta_key = ''; if (strpos($user_meta->meta_key, $wp_prefix_only . 'user_level')) { $new_meta_key = $user_meta_prefix . 'user_level'; } if (strpos($user_meta->meta_key, $wp_prefix_only . 'capabilities')) { $new_meta_key = $user_meta_prefix . 'capabilities'; } if (strpos($user_meta->meta_key, $wp_prefix_only . 'autosave_draft_ids')) { $new_meta_key = $user_meta_prefix . 'autosave_draft_ids'; } if (strpos($user_meta->meta_key, $wp_prefix_only . 'usersettings')) { if (strpos($user_meta->meta_key, $wp_prefix_only . 'usersettingstime')) { $new_meta_key = $user_meta_prefix . 'usersettingstime'; } else { $new_meta_key = $user_meta_prefix . 'usersettings'; } } if (!empty($new_meta_key)) { $repair_sql = "UPDATE {$db_xpress_usermeta} "; $repair_sql .= 'SET '; $repair_sql .= "meta_key = '{$new_meta_key}' "; $repair_sql .= "WHERE (umeta_id = {$user_meta->umeta_id} )"; $xoops_db->query($repair_sql); } } } } // repair option db user_roles include_once ABSPATH . '/include/general_functions.php'; $prefix = get_wp_prefix(); $option_tables = get_table_list($prefix, 'options'); if (!empty($option_tables)) { foreach ($option_tables as $option_table) { $mid_prefix = get_multi_mid_prefix($prefix, 'options', $option_table); $new_option_name = $prefix . $mid_prefix . 'user_roles'; $sql = "SELECT option_id , option_name FROM {$option_table} WHERE option_name LIKE '%_user_roles'"; $option = $xoops_db->get_row($sql); if ($option->option_name != $new_option_name) { $repair_sql = "UPDATE {$db_wp_option} "; $repair_sql .= 'SET '; $repair_sql .= "option_name = '{$new_option_name}' "; $repair_sql .= "WHERE (option_id = {$option->option_id} )"; $xoops_db->query($repair_sql); } } } }
function wp_d3forum_sync_topic($d3forum_dirname, $topic_id, $sync_also_forum = true, $sync_topic_title = false) { global $xpress_config, $xoops_db; $d3forum_prefix = get_xoops_prefix() . $d3forum_dirname . '_'; $xpress_prefix = get_wp_prefix(); $topic_id = intval($topic_id); $forum_id = $xoops_db->get_var("SELECT forum_id FROM " . $d3forum_prefix . "topics WHERE topic_id={$topic_id}"); // get first_post_id $first_post_id = $xoops_db->get_var("SELECT post_id FROM " . $d3forum_prefix . "posts WHERE topic_id={$topic_id} AND pid=0"); // get last_post_id and total_posts $sql = "SELECT MAX(post_id) as last_post_id,COUNT(post_id) as total_posts FROM " . $d3forum_prefix . "posts WHERE topic_id={$topic_id}"; $row = $xoops_db->get_row($sql); $last_post_id = $row->last_post_id; $total_posts = $row->total_posts; if (empty($total_posts)) { // this is empty topic should be removed wp_d3forum_delete_topic($d3forum_dirname, $topic_id, 0); } else { // update redundant columns in topics table $row = $xoops_db->get_row("SELECT post_time,uid,subject,unique_path FROM " . $d3forum_prefix . "posts WHERE post_id={$first_post_id}"); $first_post_time = $row->post_time; $first_uid = $row->uid; $first_subject = $row->subject; $unique_path = $row->unique_path; $row = $xoops_db->get_row("SELECT post_time,uid FROM " . $d3forum_prefix . "posts WHERE post_id={$last_post_id}"); $last_post_time = $row->post_time; $last_uid = $row->uid; // sync topic_title same as first post's subject if specified $topictitle4set = $sync_topic_title ? "topic_title='" . addslashes($first_subject) . "'," : ""; $xoops_db->query("UPDATE " . $d3forum_prefix . "topics SET {$topictitle4set} topic_posts_count={$total_posts}, topic_first_uid={$first_uid}, topic_first_post_id={$first_post_id}, topic_first_post_time={$first_post_time}, topic_last_uid={$last_uid}, topic_last_post_id={$last_post_id}, topic_last_post_time={$last_post_time} WHERE topic_id={$topic_id}"); // rebuild tree informations $tree_array = wp_d3forum_maketree_recursive($d3forum_prefix . "posts", intval($first_post_id), 'post_id', array(), 0, empty($unique_path) ? '.1' : $unique_path); if (!empty($tree_array)) { foreach ($tree_array as $key => $val) { $xoops_db->query("UPDATE " . $d3forum_prefix . "posts SET depth_in_tree=" . $val['depth'] . ", order_in_tree=" . ($key + 1) . ", unique_path='" . addslashes($val['unique_path']) . "' WHERE post_id=" . $val['post_id']); } } } if ($sync_also_forum) { return wp_d3forum_sync_forum($d3forum_dirname, $forum_id); } else { return true; } }
function global_popular_posts_block($options) { $mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ; $this_template = empty( $options[1] ) ? 'db:'.$mydirname.'_grobal_popular_posts_block.html' : trim( $options[1] ); $disp_count = empty( $options[2] ) ? '10' : $options[2] ; $show_month_range = empty( $options[3] ) ? '0' : $options[3] ; $date_format = empty( $options[4] ) ? '' : $options[4] ; $time_format = empty( $options[5] ) ? '' : $options[5] ; $selected = explode(',' , $cat_select); $mydirpath = get_xpress_dir_path(); if (empty($date_format)) $date_format = get_settings('date_format'); if (empty($time_format)) $time_format = get_settings('time_format'); $cat_select; $block = array(); $item_no = 0; $selected_author_id = xpress_selected_author_id('echo=0'); $data_array = array(); global $wpdb,$wp_query,$xoops_db,$wp_rewrite; if (xpress_is_multiblog()){ $blogs = get_blog_list(0,'all'); foreach ($blogs AS $blog) { switch_to_blog($blog['blog_id']); $wp_rewrite->init(); $blog_title = get_bloginfo('name'); $blog_link = get_bloginfo('url'); $blog_title_link = '<a href="' . $blog_link . '">' . $blog_title . '</a>' ; $db_prefix = get_wp_prefix(); $post_tb = $wpdb->posts; $view_tb = $db_prefix . 'views'; $user_tb = $db_prefix . 'users'; $term_relationships_tb = $wpdb->term_relationships; // upper 2.3 $term_taxonomy = $wpdb->term_taxonomy; // upper 2.3 $terms_tb = $wpdb->terms; // upper 2.3 $post2cat_tb = $wpdb->post2cat; //under 2.3 $categories_tb = $wpdb->categories; //under 2.3 include ($mydirpath . '/wp-includes/version.php'); $select = "SELECT $view_tb.post_views, $post_tb.ID, $post_tb.post_title, $post_tb.post_date"; if ($wp_db_version >= 6124){ $from = " FROM ((("; $from .= " $post_tb LEFT JOIN $view_tb ON $post_tb.ID = $view_tb.post_id)"; $from .= " INNER JOIN $term_relationships_tb ON $post_tb.ID = $term_relationships_tb.object_id)"; $from .= " INNER JOIN $term_taxonomy ON $term_relationships_tb.term_taxonomy_id = $term_taxonomy.term_taxonomy_id)"; $from .= " INNER JOIN $terms_tb ON $term_taxonomy.term_id = $terms_tb.term_id "; $where = " WHERE $post_tb.post_type = 'post' AND $post_tb.post_status = 'publish'"; } else { $from = " FROM (("; $from .= " $post_tb LEFT JOIN $view_tb ON $post_tb.ID = $view_tb.post_id)"; $from .= " LEFT JOIN $post2cat_tb ON $post_tb.ID = $post2cat_tb.post_id)"; $from .= " INNER JOIN $user_tb ON $post_tb.post_author = $user_tb.ID"; $where = " WHERE ($post_tb.post_status = 'publish') AND (UNIX_TIMESTAMP($post_tb.post_date) <= UNIX_TIMESTAMP())" ; } if ($show_month_range > 0) { $where .= " AND (UNIX_TIMESTAMP($post_tb.post_date) >= UNIX_TIMESTAMP(DATE_ADD(CURRENT_DATE, INTERVAL -$show_month_range month)))"; } $order_limmit = " GROUP BY $post_tb.ID ORDER BY $view_tb.post_views DESC LIMIT 0, $disp_count"; $sql = $select . $from . $where . $order_limmit; $populars = $wpdb->get_results($sql); foreach ($populars as $popular){ $wp_query->in_the_loop = true; //for use the_tags() in multi lopp $r = new WP_Query("p=$popular->ID"); if($r->have_posts()){ $r->the_post(); ob_start(); the_ID(); $post_id = ob_get_contents(); ob_end_clean(); ob_start(); the_title(); $title = ob_get_contents(); ob_end_clean(); ob_start(); the_permalink(); $permalink = ob_get_contents(); ob_end_clean(); ob_start(); the_author_posts_link(); $author = ob_get_contents(); ob_end_clean(); ob_start(); the_category(' • '); $category = ob_get_contents(); ob_end_clean(); if (function_exists('the_tags')){ ob_start(); the_tags(__('Tags:', 'xpress') . ' ',' • ',''); $tags = ob_get_contents(); ob_end_clean(); } else { $tags = ''; } ob_start(); the_modified_date($date_format); $post_modified_date = ob_get_contents(); ob_end_clean(); ob_start(); the_modified_date($time_format); $post_modified_time = ob_get_contents(); ob_end_clean(); ob_start(); the_time($date_format); $post_date = ob_get_contents(); ob_end_clean(); ob_start(); the_time($time_format); $post_time = ob_get_contents(); ob_end_clean(); ob_start(); comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)')); $comments_popup_link = ob_get_contents(); ob_end_clean(); $post_title = '<a href="' . $permalink . '">' . $title . '</a>'; $post_date_time = $post_date . ' ' . $post_time ; $post_modified_date_time = $post_modified_date . ' ' . $post_modified_time ; $trackback_url = trackback_url(false); $post_views = xpress_post_views_count('post_id=' . $post_id . '&format=' . __('Views :%d', 'xpress'). '&echo=0'); $post_views_num = (int) xpress_post_views_count("post_id={$post_id}&format=%d&echo=0"); $row_data = array( 'blog_title' => $blog_title , 'blog_link' => $blog_link , 'blog_title_link' => $blog_title_link , 'post_id' => $post_id , 'post_title' => $post_title , 'post_date' => $post_date , 'post_time' => $post_time , 'post_date_time' => $post_date_time , 'post_modified_date' => $post_modified_date , 'post_modified_time' => $post_modified_time , 'post_modified_date_time' => $post_modified_date_time , 'post_author' => $author , 'post_category' => $category , 'post_tags' => $tags, 'post_views' => $post_views, 'post_views_num' => $post_views_num, 'comment_link' => $comments_popup_link , 'trackback_url' => $trackback_url ); $data_array[] = $row_data; } } // end of foreach restore_current_blog(); $wp_rewrite->init(); } usort($data_array, "post_views_cmp"); if (!empty($disp_count)){ $data_array = array_slice($data_array,0,$disp_count); } $item_no = 0; foreach ($data_array as $data) { $block['contents']['item'.$item_no] = $data; $item_no++; } $block['data_count'] = $item_no; } else { $block['err_message'] = __('This blog is not set to the multi blog.', 'xpress'); } return $block ; }