/** * xt_obtain_the_title function, for replaacing the page title with the category or product * @return string - the new page title */ function xt_obtain_the_title($sep) { global $xt, $wpdb, $wp_query, $xt_meta, $share, $xt_catalog, $xt_user, $xt_album, $xt_taobao_item; if (!$xt->is_xintao) { return NULL; } $_site = get_bloginfo('name'); if ($xt->is_index) { $title = $_site; $site_description = get_bloginfo('description', 'display'); if ($site_description) { $title = "{$_site} {$sep} {$site_description}"; } $_metas = get_option(XT_OPTION_PAGE_PRE . 'home'); if (!empty($_metas) && isset($_metas['seos'])) { $_meta = $_metas['seos']; $_meta_keywords = htmlentities(stripslashes($_meta['keywords']), ENT_QUOTES, 'UTF-8'); $_meta_description = htmlentities(stripslashes($_meta['description']), ENT_QUOTES, 'UTF-8'); $_from = array('{sitetitle}', '{description}'); $_to = array($_site, $site_description); $xt_meta['keywords'] = str_replace($_from, $_to, $_meta_keywords); $xt_meta['description'] = str_replace($_from, $_to, $_meta_description); } return $title; } elseif ($xt->is_page) { if (isset($wp_query->post) && isset($wp_query->post->ID)) { $title = $wp_query->post->post_title; $_metas = get_option(XT_OPTION_PAGE_PRE . $wp_query->post->ID); $_from = array('{title}', '{sitetitle}'); $_to = array($title, $_site); $_meta_title = $title; if (!empty($_metas) && isset($_metas['seos'])) { $_meta = $_metas['seos']; $_meta_title = htmlentities(stripslashes($_meta['title']), ENT_QUOTES, 'UTF-8'); $_meta_keywords = htmlentities(stripslashes($_meta['keywords']), ENT_QUOTES, 'UTF-8'); $_meta_description = htmlentities(stripslashes($_meta['description']), ENT_QUOTES, 'UTF-8'); $xt_meta['keywords'] = str_replace($_from, $_to, $_meta_keywords); $xt_meta['description'] = str_replace($_from, $_to, $_meta_description); } $_title = str_replace($_from, $_to, $_meta_title); return (empty($_title) ? $title : $_title) . " " . $sep . " " . $_site; } } elseif ($xt->is_shares) { $_metas = get_option(XT_OPTION_PAGE_PRE . 'shares'); if (!empty($_metas) && isset($_metas['seos'])) { $_meta = $_metas['seos']; $_meta_title = htmlentities(stripslashes($_meta['title']), ENT_QUOTES, 'UTF-8'); $_meta_keywords = htmlentities(stripslashes($_meta['keywords']), ENT_QUOTES, 'UTF-8'); $_meta_description = htmlentities(stripslashes($_meta['description']), ENT_QUOTES, 'UTF-8'); $_param = $wp_query->query_vars['xt_param']; $_price = $_param['price']; $prices = xt_prices(); switch ($_price) { case 'low': $_price = '(价位:0-' . $prices['low']['end'] . '元)'; break; case 'medium': $_price = '(价位:' . $prices['medium']['start'] . '-' . $prices['medium']['end'] . '元)'; break; case 'high': $_price = '(价位:' . $prices['high']['start'] . '-' . $prices['high']['end'] . '元)'; break; case 'higher': $_price = '(价位:' . $prices['higher']['start'] . '元以上)'; break; default: $_price = ''; } $_from = array('{page}', '{sortOrder}', '{cat}', '{s}', '{price}', '{sitetitle}'); $_sortOrder = array('newest' => '最新', 'popular' => '潮流', 'hot' => '最热'); $_to = array($_param['page'] > 1 ? '第' . $_param['page'] . '页 ' : '', isset($_sortOrder[$_param['sortOrder']]) ? $_sortOrder[$_param['sortOrder']] : '', !empty($xt_catalog) ? $xt_catalog->title : '', $_param['s'], $_price, $_site); if (empty($xt_catalog)) { $_meta_keywords = preg_replace('/(\\{sortOrder\\}){0,1}\\{cat\\}(,|\\s|,)?/i', '', $_meta_keywords); } if (empty($_param['s'])) { $_meta_keywords = preg_replace('/(\\{sortOrder\\}){0,1}\\{s\\}(,|\\s|,)?/i', '', $_meta_keywords); } $xt_meta['keywords'] = str_replace($_from, $_to, $_meta_keywords); $xt_meta['description'] = str_replace($_from, $_to, $_meta_description); return str_replace($_from, $_to, $_meta_title) . " " . $sep . " " . $_site; } } elseif ($xt->is_share) { $_metas = get_option(XT_OPTION_PAGE_PRE . 'share'); if (!empty($_metas) && isset($_metas['seos'])) { $_meta = $_metas['seos']; $_meta_title = htmlentities(stripslashes($_meta['title']), ENT_QUOTES, 'UTF-8'); $_meta_keywords = htmlentities(stripslashes($_meta['keywords']), ENT_QUOTES, 'UTF-8'); $_meta_description = htmlentities(stripslashes($_meta['description']), ENT_QUOTES, 'UTF-8'); $_from = array('{title}', '{price}', '{sitetitle}', '{tags}', '{user}', '{share}'); $_to = array($share->title, $share->cache_data['item']['price'], $_site, $share->tags, $share->user_name, $share->content); $xt_meta['keywords'] = str_replace($_from, $_to, $_meta_keywords); $xt_meta['description'] = str_replace($_from, $_to, $_meta_description); return str_replace($_from, $_to, $_meta_title) . " " . $sep . " " . $_site; } } elseif ($xt->is_user) { $_metas = get_option(XT_OPTION_PAGE_PRE . 'user'); if (!empty($_metas) && isset($_metas['seos'])) { $_meta = $_metas['seos']; $_meta_title = htmlentities(stripslashes($_meta['title']), ENT_QUOTES, 'UTF-8'); $_meta_keywords = htmlentities(stripslashes($_meta['keywords']), ENT_QUOTES, 'UTF-8'); $_meta_description = htmlentities(stripslashes($_meta['description']), ENT_QUOTES, 'UTF-8'); $_from = array('{user}', '{sitetitle}', '{description}'); if (empty($xt_user->display_name)) { $xt_user->display_name = $xt_user->user_login; } $user_name = $wpdb->escape($xt_user->display_name); $_description = xt_html(xt_get_the_user_description()); $_to = array($user_name, $_site, $_description); $xt_meta['keywords'] = str_replace($_from, $_to, $_meta_keywords); $xt_meta['description'] = str_replace($_from, $_to, $_meta_description); return str_replace($_from, $_to, $_meta_title) . " " . $sep . " " . $_site; } } elseif ($xt->is_albums) { $_metas = get_option(XT_OPTION_PAGE_PRE . 'albums'); if (!empty($_metas) && isset($_metas['seos'])) { $_meta = $_metas['seos']; $_meta_title = htmlentities(stripslashes($_meta['title']), ENT_QUOTES, 'UTF-8'); $_meta_keywords = htmlentities(stripslashes($_meta['keywords']), ENT_QUOTES, 'UTF-8'); $_meta_description = htmlentities(stripslashes($_meta['description']), ENT_QUOTES, 'UTF-8'); $_param = $wp_query->query_vars['xt_param']; $_from = array('{page}', '{sortOrder}', '{s}', '{sitetitle}'); $_sortOrder = array('newest' => '最新', 'popular' => '潮流', 'hot' => '最热'); $_to = array($_param['page'] > 1 ? '第' . $_param['page'] . '页 ' : '', isset($_sortOrder[$_param['sortOrder']]) ? $_sortOrder[$_param['sortOrder']] : '', $_param['s'], $_site); $xt_meta['keywords'] = str_replace($_from, $_to, $_meta_keywords); $xt_meta['description'] = str_replace($_from, $_to, $_meta_description); return str_replace($_from, $_to, $_meta_title) . " " . $sep . " " . $_site; } } elseif ($xt->is_album) { $_metas = get_option(XT_OPTION_PAGE_PRE . 'album'); if (!empty($_metas) && isset($_metas['seos'])) { $_meta = $_metas['seos']; $_meta_title = htmlentities(stripslashes($_meta['title']), ENT_QUOTES, 'UTF-8'); $_meta_keywords = htmlentities(stripslashes($_meta['keywords']), ENT_QUOTES, 'UTF-8'); $_meta_description = htmlentities(stripslashes($_meta['description']), ENT_QUOTES, 'UTF-8'); $_from = array('{user}', '{sitetitle}', '{albumtitle}', '{albumcontent}'); if (empty($xt_user->display_name)) { $xt_user->display_name = $xt_user->user_login; } $user_name = $wpdb->escape($xt_user->display_name); $_to = array($user_name, $_site, $xt_album->title, $xt_album->content); $xt_meta['keywords'] = str_replace($_from, $_to, $_meta_keywords); $xt_meta['description'] = str_replace($_from, $_to, $_meta_description); return str_replace($_from, $_to, $_meta_title) . " " . $sep . " " . $_site; } } elseif ($xt->is_daogous) { $_metas = get_option(XT_OPTION_PAGE_PRE . 'daogous'); if (!empty($_metas) && isset($_metas['seos'])) { $_meta = $_metas['seos']; $_meta_title = htmlentities(stripslashes($_meta['title']), ENT_QUOTES, 'UTF-8'); $_meta_keywords = htmlentities(stripslashes($_meta['keywords']), ENT_QUOTES, 'UTF-8'); $_meta_description = htmlentities(stripslashes($_meta['description']), ENT_QUOTES, 'UTF-8'); $_param = $wp_query->query_vars['xt_param']; $_cat = '最新'; $_from = array('{cat}', '{s}', '{sitetitle}'); if (!empty($_param['cid'])) { $xt_daogou_itemcat = xt_daogou_item_cat($_param['cid']); if (!empty($xt_daogou_itemcat)) { $_cat = $xt_daogou_itemcat->name; } } $_to = array($_cat, $_param['s'], $_site); $xt_meta['keywords'] = str_replace($_from, $_to, $_meta_keywords); $xt_meta['description'] = str_replace($_from, $_to, $_meta_description); return str_replace($_from, $_to, $_meta_title) . " " . $sep . " " . $_site; } } elseif ($xt->is_helps) { $_metas = get_option(XT_OPTION_PAGE_PRE . 'helps'); if (!empty($_metas) && isset($_metas['seos'])) { $_meta = $_metas['seos']; $_meta_title = htmlentities(stripslashes($_meta['title']), ENT_QUOTES, 'UTF-8'); $_meta_keywords = htmlentities(stripslashes($_meta['keywords']), ENT_QUOTES, 'UTF-8'); $_meta_description = htmlentities(stripslashes($_meta['description']), ENT_QUOTES, 'UTF-8'); $_param = $wp_query->query_vars['xt_param']; $_cat = '常见问题'; $_from = array('{cat}', '{s}', '{sitetitle}'); if (!empty($_param['cid'])) { $xt_help_itemcat = xt_help_item_cat($_param['cid']); if (!empty($xt_help_itemcat)) { $_cat = $xt_help_itemcat->name; } } $_to = array($_cat, $_param['s'], $_site); $xt_meta['keywords'] = str_replace($_from, $_to, $_meta_keywords); $xt_meta['description'] = str_replace($_from, $_to, $_meta_description); return str_replace($_from, $_to, $_meta_title) . " " . $sep . " " . $_site; } } elseif ($xt->is_daogou || $xt->is_help) { $__page = 'daogou'; if ($xt->is_help) { $__page = 'help'; } $_metas = get_option(XT_OPTION_PAGE_PRE . $__page); if (!empty($_metas) && isset($_metas['seos'])) { $_meta = $_metas['seos']; $_meta_title = htmlentities(stripslashes($_meta['title']), ENT_QUOTES, 'UTF-8'); $_meta_keywords = htmlentities(stripslashes($_meta['keywords']), ENT_QUOTES, 'UTF-8'); $_meta_description = htmlentities(stripslashes($_meta['description']), ENT_QUOTES, 'UTF-8'); $_from = array('{sitetitle}', '{blogtitle}', '{blogtags}', '{blogexcerpt}'); $_postexcerpt = ''; $_post = get_queried_object(); if ($_post->post_excerpt) { $_postexcerpt = $_post->post_excerpt; } else { $_postexcerpt = wp_trim_words(strip_tags($_post->post_content), 180); } $_posttags = array(); $_tags = wp_get_post_tags($_post->ID); if (!empty($_tags)) { foreach ($_tags as $_tag) { $_posttags[] = $_tag->name; } } $_posttags = implode(' ', $_posttags); $_to = array($_site, $_post->post_title, $_posttags, $_postexcerpt); $xt_meta['keywords'] = str_replace($_from, $_to, $_meta_keywords); $xt_meta['description'] = str_replace($_from, $_to, $_meta_description); return str_replace($_from, $_to, $_meta_title) . " " . $sep . " " . $_site; } } elseif ($xt->is_account) { if (empty($xt_user->display_name)) { $xt_user->display_name = $xt_user->user_login; } $user_name = $wpdb->escape($xt_user->display_name); return $user_name . $sep . '管理中心' . " " . $sep . " " . $_site; } elseif ($xt->is_taobaos) { $_metas = get_option(XT_OPTION_PAGE_PRE . 'taobaos'); if (!empty($_metas) && isset($_metas['seos'])) { $_meta = $_metas['seos']; $_meta_title = htmlentities(stripslashes($_meta['title']), ENT_QUOTES, 'UTF-8'); $_meta_keywords = htmlentities(stripslashes($_meta['keywords']), ENT_QUOTES, 'UTF-8'); $_meta_description = htmlentities(stripslashes($_meta['description']), ENT_QUOTES, 'UTF-8'); $_param = $wp_query->query_vars['xt_param']; $_s = $_param['keyword']; $_start_price = $_param['start_price']; $_end_price = $_param['end_price']; $_sort = $_param['sort']; $_mall = $_param['mall_item']; $_cat = ''; if (!empty($_sort)) { $xt_sort_taobao = xt_sort_taobao(); if (isset($xt_sort_taobao[$_sort])) { $_sort = $xt_sort_taobao[$_sort]['seo']; } else { $_sort = '人气'; } } if (empty($_sort)) { $_sort = '人气'; } if (!empty($_param['cid'])) { $xt_taobao_itemcat = xt_taobao_item_cat(absint($_param['cid'])); if (!empty($xt_taobao_itemcat)) { $_cat = $xt_taobao_itemcat['name']; } } $_from = array('{page}', '{sitetitle}', '{cat}', '{s}', '{start_price}', '{end_price}', '{sort}', '{mall}'); $_to = array($_param['page_no'] > 1 ? '第' . $_param['page_no'] . '页 ' : '', $_site, $_cat, $_s, $_start_price ? '最低价格:' . $_start_price : '', $_end_price ? '最高价格:' . $_end_price : '', $_sort, $_mall ? '天猫' : ''); $xt_meta['keywords'] = str_replace($_from, $_to, $_meta_keywords); $xt_meta['description'] = str_replace($_from, $_to, $_meta_description); return str_replace($_from, $_to, $_meta_title) . " " . $sep . " " . $_site; } } elseif ($xt->is_taobao) { $_metas = get_option(XT_OPTION_PAGE_PRE . 'taobao'); if (!empty($_metas) && isset($_metas['seos'])) { $_meta = $_metas['seos']; $_meta_title = htmlentities(stripslashes($_meta['title']), ENT_QUOTES, 'UTF-8'); $_meta_keywords = htmlentities(stripslashes($_meta['keywords']), ENT_QUOTES, 'UTF-8'); $_meta_description = htmlentities(stripslashes($_meta['description']), ENT_QUOTES, 'UTF-8'); $_param = $wp_query->query_vars['xt_param']; $_from = array('{sitetitle}', '{itemtitle}', '{itemprice}'); $_to = array($_site, $xt_taobao_item->title, $xt_taobao_item->price); $xt_meta['keywords'] = str_replace($_from, $_to, $_meta_keywords); $xt_meta['description'] = str_replace($_from, $_to, $_meta_description); return str_replace($_from, $_to, $_meta_title) . " " . $sep . " " . $_site; } } elseif ($xt->is_shops) { $_metas = get_option(XT_OPTION_PAGE_PRE . 'shops'); if (!empty($_metas) && isset($_metas['seos'])) { $_meta = $_metas['seos']; $_meta_title = htmlentities(stripslashes($_meta['title']), ENT_QUOTES, 'UTF-8'); $_meta_keywords = htmlentities(stripslashes($_meta['keywords']), ENT_QUOTES, 'UTF-8'); $_meta_description = htmlentities(stripslashes($_meta['description']), ENT_QUOTES, 'UTF-8'); $_param = $wp_query->query_vars['xt_param']; $_s = $_param['keyword']; $_start_credit = $_param['start_credit']; $_end_credit = $_param['end_credit']; $_mall = $_param['only_mall']; $_cat = ''; if (!empty($_param['cid'])) { $xt_taobao_shopcat = xt_taobao_shopcat(absint($_param['cid'])); if (!empty($xt_taobao_shopcat)) { $_cat = $xt_taobao_shopcat['name']; } } $_from = array('{page}', '{sitetitle}', '{cat}', '{s}', '{start_credit}', '{end_credit}', '{mall}'); $_to = array($_param['page_no'] > 1 ? '第' . $_param['page_no'] . '页 ' : '', $_site, $_cat, $_s, $_start_credit ? '最低信用:' . $_start_credit : '', $_end_credit ? '最高信用:' . $_end_credit : '', $_mall ? '天猫' : ''); $xt_meta['keywords'] = str_replace($_from, $_to, $_meta_keywords); $xt_meta['description'] = str_replace($_from, $_to, $_meta_description); return str_replace($_from, $_to, $_meta_title) . " " . $sep . " " . $_site; } } elseif ($xt->is_paipais) { $_metas = get_option(XT_OPTION_PAGE_PRE . 'paipais'); if (!empty($_metas) && isset($_metas['seos'])) { $_meta = $_metas['seos']; $_meta_title = htmlentities(stripslashes($_meta['title']), ENT_QUOTES, 'UTF-8'); $_meta_keywords = htmlentities(stripslashes($_meta['keywords']), ENT_QUOTES, 'UTF-8'); $_meta_description = htmlentities(stripslashes($_meta['description']), ENT_QUOTES, 'UTF-8'); $_param = $wp_query->query_vars['xt_param']; $_s = $_param['keyWord']; $_start_price = $_param['begPrice']; $_end_price = $_param['endPrice']; $_sort = $_param['orderStyle']; $_cat = ''; if (!empty($_sort)) { $xt_sort_paipai = xt_sort_paipai(); if (isset($xt_sort_paipai[$_sort])) { $_sort = $xt_sort_paipai[$_sort]['seo']; } else { $_sort = ''; } } if (!empty($_param['classId'])) { $xt_paipai_itemcat = xt_paipai_item_cat(absint($_param['classId'])); if (!empty($xt_paipai_itemcat)) { $_cat = $xt_paipai_itemcat['name']; } } $_from = array('{page}', '{sitetitle}', '{cat}', '{s}', '{start_price}', '{end_price}', '{sort}'); $_to = array($_param['pageIndex'] > 1 ? '第' . $_param['pageIndex'] . '页 ' : '', $_site, $_cat, $_s, $_start_price > 0 ? '最低价格:' . $_start_price : '', $_end_price > 0 ? '最高价格:' . $_end_price : '', $_sort); $xt_meta['keywords'] = str_replace($_from, $_to, $_meta_keywords); $xt_meta['description'] = str_replace($_from, $_to, $_meta_description); return str_replace($_from, $_to, $_meta_title) . " " . $sep . " " . $_site; } } elseif ($xt->is_bijias) { $_metas = get_option(XT_OPTION_PAGE_PRE . 'bijias'); if (!empty($_metas) && isset($_metas['seos'])) { $_meta = $_metas['seos']; $_meta_title = htmlentities(stripslashes($_meta['title']), ENT_QUOTES, 'UTF-8'); $_meta_keywords = htmlentities(stripslashes($_meta['keywords']), ENT_QUOTES, 'UTF-8'); $_meta_description = htmlentities(stripslashes($_meta['description']), ENT_QUOTES, 'UTF-8'); $_param = $wp_query->query_vars['xt_param']; $_s = $_param['keyword']; $_start_price = $_param['minprice']; $_end_price = $_param['maxprice']; $_sort = $_param['orderby']; $_cat = ''; if (!empty($_sort)) { $xt_sort_bijia = xt_sort_bijia(); if (isset($xt_sort_bijia[$_sort])) { $_sort = $xt_sort_bijia[$_sort]['seo']; } else { $_sort = ''; } } if (!empty($_param['catid']) && $_param['catid'] != -1) { $xt_bijia_itemcat = xt_bijia_item_cat($_param['catid']); if (!empty($xt_bijia_itemcat)) { $_cat = $xt_bijia_itemcat['name']; } } $_from = array('{page}', '{sitetitle}', '{cat}', '{s}', '{start_price}', '{end_price}', '{sort}'); $_to = array($_param['page_no'] > 1 ? '第' . $_param['page_no'] . '页 ' : '', $_site, $_cat, $_s, $_start_price > 0 ? '最低价格:' . $_start_price : '', $_end_price > 0 ? '最高价格:' . $_end_price : '', $_sort); $xt_meta['keywords'] = str_replace($_from, $_to, $_meta_keywords); $xt_meta['description'] = str_replace($_from, $_to, $_meta_description); return str_replace($_from, $_to, $_meta_title) . " " . $sep . " " . $_site; } } elseif ($xt->is_tuans) { $_metas = get_option(XT_OPTION_PAGE_PRE . 'tuans'); if (!empty($_metas) && isset($_metas['seos'])) { $_meta = $_metas['seos']; $_meta_title = htmlentities(stripslashes($_meta['title']), ENT_QUOTES, 'UTF-8'); $_meta_keywords = htmlentities(stripslashes($_meta['keywords']), ENT_QUOTES, 'UTF-8'); $_meta_description = htmlentities(stripslashes($_meta['description']), ENT_QUOTES, 'UTF-8'); $_param = $wp_query->query_vars['xt_param']; $_s = $_param['keyword']; $_price = $_param['price']; $_sort = $_param['orderby']; $_city = ''; $_cat = ''; if (!empty($_sort)) { $xt_sort_tuan = xt_sort_tuan(); if (isset($xt_sort_tuan[$_sort])) { $_sort = $xt_sort_tuan[$_sort]['seo']; } else { $_sort = ''; } } if (!empty($_param['catid']) && $_param['catid'] != -1) { $xt_tuan_itemcat = xt_tuan_item_cat($_param['catid']); if (!empty($xt_tuan_itemcat)) { $_cat = $xt_tuan_itemcat['name']; } } if (!empty($_param['city_id'])) { $xt_yiqifa_tuan_cities = xt_yiqifa_tuan_city(); if (isset($xt_yiqifa_tuan_cities[$_param['city_id']])) { $_city = $xt_yiqifa_tuan_cities[$_param['city_id']]['name_cn']; } } switch ($_price) { case 'low': $_price = '50元以下'; break; case 'medium': $_price = '50-100元'; break; case 'high': $_price = '100元以上'; break; default: $_price = ''; } $_from = array('{page}', '{sitetitle}', '{city}', '{cat}', '{s}', '{price}', '{sort}'); $_to = array($_param['page_no'] > 1 ? '第' . $_param['page_no'] . '页 ' : '', $_site, $_city, $_cat, $_s, $_price, $_sort); $xt_meta['keywords'] = str_replace($_from, $_to, $_meta_keywords); $xt_meta['description'] = str_replace($_from, $_to, $_meta_description); return str_replace($_from, $_to, $_meta_title) . " " . $sep . " " . $_site; } } elseif ($xt->is_temais) { $_metas = get_option(XT_OPTION_PAGE_PRE . 'temais'); if (!empty($_metas) && isset($_metas['seos'])) { $_meta = $_metas['seos']; $_meta_title = htmlentities(stripslashes($_meta['title']), ENT_QUOTES, 'UTF-8'); $_meta_keywords = htmlentities(stripslashes($_meta['keywords']), ENT_QUOTES, 'UTF-8'); $_meta_description = htmlentities(stripslashes($_meta['description']), ENT_QUOTES, 'UTF-8'); $_param = $wp_query->query_vars['xt_param']; $_sort = $_param['sort']; $_city = ''; $_cat = ''; if (!empty($_sort)) { $xt_sort_temai = xt_sort_temai(); if (isset($xt_sort_temai[$_sort])) { $_sort = $xt_sort_temai[$_sort]['seo']; } else { $_sort = ''; } } if (!empty($_param['cat'])) { $xt_temai_itemcat = xt_temai_item_cat($_param['cat']); if (!empty($xt_temai_itemcat)) { $_cat = $xt_temai_itemcat['name']; } } $_from = array('{page}', '{sitetitle}', '{cat}', '{sort}'); $_to = array($_param['page_no'] > 1 ? '第' . $_param['page_no'] . '页 ' : '', $_site, $_cat, $_sort); $xt_meta['keywords'] = str_replace($_from, $_to, $_meta_keywords); $xt_meta['description'] = str_replace($_from, $_to, $_meta_description); return str_replace($_from, $_to, $_meta_title) . " " . $sep . " " . $_site; } } elseif ($xt->is_coupons) { $_metas = get_option(XT_OPTION_PAGE_PRE . 'coupons'); if (!empty($_metas) && isset($_metas['seos'])) { $_meta = $_metas['seos']; $_meta_title = htmlentities(stripslashes($_meta['title']), ENT_QUOTES, 'UTF-8'); $_meta_keywords = htmlentities(stripslashes($_meta['keywords']), ENT_QUOTES, 'UTF-8'); $_meta_description = htmlentities(stripslashes($_meta['description']), ENT_QUOTES, 'UTF-8'); $_param = $wp_query->query_vars['xt_param']; $_s = $_param['keyword']; $_sort = $_param['sort']; $_mall = $_param['shop_type']; $_cat = ''; if (!empty($_sort)) { $xt_sort_taobao = xt_sort_taobao(); if (isset($xt_sort_taobao[$_sort])) { $_sort = $xt_sort_taobao[$_sort]['seo']; } else { $_sort = '人气'; } } if (empty($_sort)) { $_sort = '人气'; } if (!empty($_param['cid'])) { $xt_taobao_itemcat = xt_taobao_item_cat(absint($_param['cid'])); if (!empty($xt_taobao_itemcat)) { $_cat = $xt_taobao_itemcat['name']; } } $_from = array('{page}', '{sitetitle}', '{cat}', '{s}', '{sort}', '{mall}'); $_to = array($_param['page_no'] > 1 ? '第' . $_param['page_no'] . '页 ' : '', $_site, $_cat, $_s, $_sort, $_mall ? '天猫' : ''); $xt_meta['keywords'] = str_replace($_from, $_to, $_meta_keywords); $xt_meta['description'] = str_replace($_from, $_to, $_meta_description); return str_replace($_from, $_to, $_meta_title) . " " . $sep . " " . $_site; } } elseif ($xt->is_invite) { $_metas = get_option(XT_OPTION_PAGE_PRE . 'invite'); if (!empty($_metas) && isset($_metas['seos'])) { $_meta = $_metas['seos']; $_meta_title = htmlentities(stripslashes($_meta['title']), ENT_QUOTES, 'UTF-8'); $_meta_keywords = htmlentities(stripslashes($_meta['keywords']), ENT_QUOTES, 'UTF-8'); $_meta_description = htmlentities(stripslashes($_meta['description']), ENT_QUOTES, 'UTF-8'); if (empty($xt_user->display_name)) { $xt_user->display_name = $xt_user->user_login; } $user_name = $wpdb->escape($xt_user->display_name); $jifen = intval(xt_fanxian_registe_jifen()); if ($jifen > 100) { $jifen = intval($jifen / 100); } else { $jifen = 0; } $cash = intval(xt_fanxian_registe_cash()); $amount = $cash + $jifen; $_from = array('{sitetitle}', '{user}', '{cash}', '{jifenbao}', '{amount}'); $_to = array($_site, $user_name, $cash, $jifen, $amount); $xt_meta['keywords'] = str_replace($_from, $_to, $_meta_keywords); $xt_meta['description'] = str_replace($_from, $_to, $_meta_description); return str_replace($_from, $_to, $_meta_title) . " " . $sep . " " . $_site; } } elseif ($xt->is_brands || $xt->is_stars || $xt->is_activities || $xt->is_taoquan || $xt->is_malls || $xt->is_error404) { $__page = 'stars'; if ($xt->is_brands) { $__page = 'brands'; } elseif ($xt->is_activities) { $__page = 'activities'; } elseif ($xt->is_taoquan) { $__page = 'taoquan'; } elseif ($xt->is_malls) { $__page = 'malls'; } elseif ($xt->is_error404) { $__page = 'error404'; } $_metas = get_option(XT_OPTION_PAGE_PRE . $__page); if (!empty($_metas) && isset($_metas['seos'])) { $_meta = $_metas['seos']; $_meta_title = htmlentities(stripslashes($_meta['title']), ENT_QUOTES, 'UTF-8'); $_meta_keywords = htmlentities(stripslashes($_meta['keywords']), ENT_QUOTES, 'UTF-8'); $_meta_description = htmlentities(stripslashes($_meta['description']), ENT_QUOTES, 'UTF-8'); $_from = array('{sitetitle}'); $_to = array($_site); $xt_meta['keywords'] = str_replace($_from, $_to, $_meta_keywords); $xt_meta['description'] = str_replace($_from, $_to, $_meta_description); return str_replace($_from, $_to, $_meta_title) . " " . $sep . " " . $_site; } } return null; }
function widget($args, $instance) { extract($args); $title = apply_filters('xt_widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); $cids = apply_filters('xt_filter_ids', $instance['cids']); $style = $instance['style']; global $xt, $xt_catalog, $wp_query; $s = ''; echo $before_widget; if (!empty($cids)) { $cids = explode(',', $cids); $roots = xt_catalogs_share_sub(0); $catalogs = array(); if (!empty($roots)) { foreach ($roots as $root) { if (in_array($root->id, $cids)) { $catalogs[] = $root; } } } $fCid = $cids[0]; $sCid = 0; if ($xt->is_shares && !empty($xt_catalog)) { $xt_share_param = $wp_query->query_vars['xt_param']; $s = isset($xt_share_param['s']) ? $xt_share_param['s'] : ''; $parentCid = $xt_catalog->id; if ($xt_catalog->parent) { $parentCid = $xt_catalog->parent; $sCid = $xt_catalog->id; } if (in_array($parentCid, $cids)) { $fCid = $parentCid; } } $childs = xt_catalogs_share_sub($fCid); switch ($style) { case 'mogujie': _xt_widget_catalog_share_mogujie($fCid, $sCid, $s, $catalogs, $childs); break; case 'fandongxi': _xt_widget_catalog_share_fandongxi($fCid, $sCid, $s, $catalogs, $childs); break; } } if ($xt->is_shares) { $xt_share_param = $wp_query->query_vars['xt_param']; $s = isset($xt_share_param['s']) ? $xt_share_param['s'] : ''; $h3 = !empty($s) ? $s : (!empty($xt_catalog) ? $xt_catalog->title : ''); $filterCid = ''; $filterPrice = $xt_share_param['price']; $filterSortOrder = $xt_share_param['sortOrder']; if (!empty($xt_catalog)) { $filterCid = $xt_catalog->id; } $prices = xt_prices(); ?> <div class="row-fluid clearfix" style="margin-top:10px;"> <h3 class="pull-left text-default" style="margin:0px;"><?php echo $h3; ?> </h3> <div class="pull-left" style="padding:8px 0px 3px 20px;"> 排序: <div class="btn-group"> <a class="btn btn-small <?php echo $filterSortOrder == 'popular' ? 'btn-primary' : ''; ?> " href="<?php echo xt_get_shares_search_url(array('cid' => $filterCid, 's' => $s, 'sortOrder' => 'popular', 'price' => $filterPrice)); ?> " data-value="popular">潮流</a> <a class="btn btn-small <?php echo $filterSortOrder == 'newest' ? 'btn-primary' : ''; ?> " href="<?php echo xt_get_shares_search_url(array('cid' => $filterCid, 's' => $s, 'sortOrder' => 'newest', 'price' => $filterPrice)); ?> " data-value="newest">最新</a> <a class="btn btn-small <?php echo $filterSortOrder == 'hot' ? 'btn-primary' : ''; ?> " href="<?php echo xt_get_shares_search_url(array('cid' => $filterCid, 's' => $s, 'sortOrder' => 'hot', 'price' => $filterPrice)); ?> " data-value="hot">最热</a> </div> 价格: <div class="btn-group"> <a class="btn btn-small <?php echo $filterPrice == '' ? 'btn-primary' : ''; ?> " href="<?php echo xt_get_shares_search_url(array('cid' => $filterCid, 's' => $s, 'sortOrder' => $filterSortOrder, 'price' => '')); ?> " data-value="">全部</a> <a class="btn btn-small <?php echo $filterPrice == 'low' ? 'btn-primary' : ''; ?> " href="<?php echo xt_get_shares_search_url(array('cid' => $filterCid, 's' => $s, 'sortOrder' => $filterSortOrder, 'price' => 'low')); ?> " data-value="low"><?php echo $prices['low']['end']; ?> 元</a> <a class="btn btn-small <?php echo $filterPrice == 'medium' ? 'btn-primary' : ''; ?> " href="<?php echo xt_get_shares_search_url(array('cid' => $filterCid, 's' => $s, 'sortOrder' => $filterSortOrder, 'price' => 'medium')); ?> " data-value="medium"><?php echo $prices['medium']['end']; ?> 元</a> <a class="btn btn-small <?php echo $filterPrice == 'high' ? 'btn-primary' : ''; ?> " href="<?php echo xt_get_shares_search_url(array('cid' => $filterCid, 's' => $s, 'sortOrder' => $filterSortOrder, 'price' => 'high')); ?> " data-value="high"><?php echo $prices['high']['end']; ?> 元</a> <a class="btn btn-small <?php echo $filterPrice == 'higher' ? 'btn-primary' : ''; ?> " href="<?php echo xt_get_shares_search_url(array('cid' => $filterCid, 's' => $s, 'sortOrder' => $filterSortOrder, 'price' => 'higher')); ?> " data-value="higher">更高</a> </div> </div> </div> <?php } echo $after_widget; }
function _get_shares($args) { global $wpdb; $id = isset($args['id']) && absint($args['id']) ? absint($args['id']) : 0; $album_id = isset($args['album_id']) && absint($args['album_id']) ? absint($args['album_id']) : 0; if ($id > 0) { //single $result = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . XT_TABLE_SHARE . " g WHERE g.id = %d", $id)); if (!empty($result)) { return array('share' => array($result), 'total' => 1); } else { return array('share' => array(), 'total' => 0); } } $user_id = $args['user_id']; $sortOrder = $args['sortOrder']; $cid = $args['cid']; $share_per_page = $args['share_per_page']; $page = $args['page']; $s = $args['s']; $price = $args['price']; $isFavorite = $args['isFavorite']; $isHome = $args['isHome']; $fields = $args['fields']; $table = $album_id > 0 ? XT_TABLE_SHARE_ALBUM : ($isFavorite ? XT_TABLE_FAVORITE : XT_TABLE_SHARE); $join = ''; $where = ''; $groupby = ''; $order = ''; $pagination = ''; $found_rows = ''; if (!empty($cid) && $cid > 0) { global $xt_catalog; if (empty($xt_catalog) || $xt_catalog->id != $cid) { $xt_catalog = xt_get_catalog($cid); } if (!empty($xt_catalog)) { if (isset($xt_catalog->children) && !empty($xt_catalog->children)) { $join .= " INNER JOIN " . XT_TABLE_SHARE_CATALOG . " ON " . XT_TABLE_SHARE_CATALOG . ".id = " . XT_TABLE_SHARE . ".id "; $where .= " AND " . XT_TABLE_SHARE_CATALOG . ".cid in(" . $wpdb->escape($xt_catalog->children) . "," . $cid . ") "; $groupby .= "GROUP BY " . XT_TABLE_SHARE . ".id"; } else { $join .= " INNER JOIN " . XT_TABLE_SHARE_CATALOG . " ON " . XT_TABLE_SHARE_CATALOG . ".id = " . XT_TABLE_SHARE . ".id "; $where .= $wpdb->prepare(" AND " . XT_TABLE_SHARE_CATALOG . ".cid=%d ", $cid); } } } elseif ($cid == -1) { $join = ''; $where = ' AND ' . XT_TABLE_SHARE . '.id NOT IN (SELECT ID FROM ' . XT_TABLE_SHARE_CATALOG . ')'; } if (!empty($user_id) && $user_id > 0) { if ($isHome) { global $xt_pageuser_follows; if (!empty($xt_pageuser_follows) && is_array($xt_pageuser_follows)) { $followIds = implode(',', $xt_pageuser_follows); $where .= " AND " . XT_TABLE_SHARE . ".user_id in (" . $followIds . ") "; } } elseif ($isFavorite) { $where .= $wpdb->prepare(" AND " . XT_TABLE_FAVORITE . ".user_id = %d AND " . XT_TABLE_FAVORITE . ".type=1", $user_id); } elseif ($album_id > 0) { $where .= $wpdb->prepare(" AND " . XT_TABLE_SHARE_ALBUM . ".user_id = %d ", $user_id); } else { $where .= $wpdb->prepare(" AND " . XT_TABLE_SHARE . ".user_id = %d ", $user_id); } } if ($isFavorite) { $join .= " INNER JOIN " . XT_TABLE_SHARE . " ON " . XT_TABLE_FAVORITE . ".id=" . XT_TABLE_SHARE . ".id "; } elseif (!empty($s)) { $match_key = xt_segment_unicode($wpdb->escape($s), '+'); $join .= " INNER JOIN " . XT_TABLE_SHARE_MATCH . " gm ON match(gm.content_match) against('" . $match_key . "' IN BOOLEAN MODE) AND gm.share_id=" . XT_TABLE_SHARE . ".id "; } elseif ($album_id > 0) { $where .= $wpdb->prepare(" AND " . XT_TABLE_SHARE_ALBUM . ".album_id = %d ", $album_id); $join .= " INNER JOIN " . XT_TABLE_SHARE . " ON " . XT_TABLE_SHARE_ALBUM . ".id=" . XT_TABLE_SHARE . ".id "; } $fields .= " ,{$wpdb->usermeta}.meta_value as user_avatar"; $join .= " LEFT JOIN {$wpdb->usermeta} ON {$wpdb->usermeta}.user_id = " . XT_TABLE_SHARE . ".user_id AND {$wpdb->usermeta}.meta_key='" . XT_USER_AVATAR . "' "; if (!empty($price)) { $prices = xt_prices(); switch ($price) { case 'low': $where .= " AND " . XT_TABLE_SHARE . ".price <= " . $prices['low']['end']; break; case 'medium': $where .= " AND " . XT_TABLE_SHARE . ".price >= " . $prices['medium']['start'] . " AND " . XT_TABLE_SHARE . ".price <= " . $prices['medium']['end']; break; case 'high': $where .= " AND " . XT_TABLE_SHARE . ".price >= " . $prices['high']['start'] . " AND " . XT_TABLE_SHARE . ".price <= " . $prices['high']['end']; break; case 'higher': $where .= " AND " . XT_TABLE_SHARE . ".price >= " . $prices['higher']['start']; break; } } $today_time = xt_get_todaytime(); if ($isHome) { $order = " ORDER BY " . XT_TABLE_SHARE . ".create_date DESC"; } elseif ($isFavorite) { $order = " ORDER BY " . XT_TABLE_FAVORITE . ".create_date DESC"; } else { switch ($sortOrder) { case 'newest': default: $order = " ORDER BY " . XT_TABLE_SHARE . ".create_date DESC"; break; case 'popular': $day7_time = $today_time - 604800; //7 days $fields .= ",(UNIX_TIMESTAMP(" . XT_TABLE_SHARE . ".create_date) > {$day7_time}) AS time_sort "; $order = " ORDER BY time_sort DESC," . XT_TABLE_SHARE . ".fav_count DESC"; break; case 'hot': $day30_time = $today_time - 2592000; //30 days $fields .= ",(UNIX_TIMESTAMP(" . XT_TABLE_SHARE . ".create_date) > {$day30_time}) AS time_sort "; $order = " ORDER BY time_sort DESC," . XT_TABLE_SHARE . ".fav_count DESC"; break; } } if ($share_per_page && $page) { $pagination = $wpdb->prepare("LIMIT %d, %d", intval(($page - 1) * $share_per_page), intval($share_per_page)); } if (!empty($where)) { $where = ' WHERE 1=1 ' . $where; } if (!$args['no_found_rows']) { $found_rows = 'SQL_CALC_FOUND_ROWS'; } $sql = "SELECT {$found_rows} {$fields} FROM {$table} {$join} {$where} {$groupby} {$order} {$pagination}"; $paged_share_sql = apply_filters('xt_share_get_paged_share_sql', $sql, $sql); $paged_share = $wpdb->get_results($paged_share_sql); $total_share = -1; if (!$args['no_found_rows']) { $total_share = $wpdb->get_var('SELECT FOUND_ROWS()'); $max_num_pages = ceil($total_share / $args['share_per_page']); } unset($sql); return array('share' => $paged_share, 'total' => $total_share); }