function xt_core_set_globals() { global $xt, $wp, $xt_template_name; xt_core_constants_route(); $xt->option = get_option(XT_OPTION_GLOBAL); //TODO slug if (!is_admin()) { if (isset($wp->query_vars['pagename'])) { $base = xt_base(); if ($wp->query_vars['pagename'] == $base) { $xt->is_xintao = true; if (isset($wp->query_vars['xt_action'])) { $action = $wp->query_vars['xt_action']; $param = $wp->query_vars['xt_param']; switch ($action) { case 'login': $xt->is_login = true; break; case 'search': $xt->is_shares = true; $wp->query_vars['xt_param'] = xt_core_share_params($param); break; case 'album': $xt->is_albums = true; $wp->query_vars['xt_param'] = xt_core_album_params($param); break; case 'user': $xt->is_users = true; break; case 'id': $xt->is_share = true; break; case 'aid': $xt->is_album = true; break; case 'gid': $xt->is_group = true; break; case 'uid': $xt->is_user = true; break; case 'account': $xt->is_account = true; break; case 'invite': $xt->is_invite = true; break; case 'taobao': if (!empty($param) && is_numeric($param)) { $xt->is_taobao = true; $wp->query_vars['xt_param'] = $param; } else { $xt->is_taobaos = true; $wp->query_vars['xt_param'] = xt_core_taobao_params($param); } break; case 'shop': $xt->is_shops = true; $wp->query_vars['xt_param'] = xt_core_shop_params($param); break; case 'paipai': $xt->is_paipais = true; $wp->query_vars['xt_param'] = xt_core_paipai_params($param); break; case 'bijia': $xt->is_bijias = true; $wp->query_vars['xt_param'] = xt_core_bijia_params($param); break; case 'tuan': $xt->is_tuans = true; $wp->query_vars['xt_param'] = xt_core_tuan_params($param); break; case 'temai': $xt->is_temais = true; $wp->query_vars['xt_param'] = xt_core_temai_params($param); break; case 'coupon': $xt->is_coupons = true; $wp->query_vars['xt_param'] = xt_core_coupon_params($param); break; case 'daogou': $xt->is_daogous = true; $wp->query_vars['xt_param'] = xt_core_daogou_params($param); break; case 'help': $xt->is_helps = true; $wp->query_vars['xt_param'] = xt_core_help_params($param); break; case 'brands': $xt->is_brands = true; break; case 'stars': $xt->is_stars = true; break; case 'activities': $xt->is_activities = true; break; case 'taoquan': $xt->is_taoquan = true; break; case 'malls': $xt->is_malls = true; break; case 'jump': $xt->is_jump = true; $wp->query_vars['xt_param'] = xt_core_jump_params($param); break; case 'sitemap': case 'sitemapshare': case 'sitemappost': case 'sitemapalbum': case 'sitemapuser': case 'sitemapother': $xt->is_sitemap = true; break; default: xt_set_404(); break; } } else { $wp->query_vars['xt_action'] = 'error404'; xt_set_404(); } } elseif (xt_is_page($wp->query_vars['pagename'])) { $xt->is_xintao = true; $xt->is_page = true; } elseif ($wp->query_vars['pagename'] == xt_base_daogou()) { $xt->is_xintao = true; $xt->is_daogous = true; $wp->query_vars['xt_param'] = xt_core_daogou_params(array()); } elseif ($wp->query_vars['pagename'] == xt_base_help()) { $xt->is_xintao = true; $xt->is_helps = true; $wp->query_vars['xt_param'] = xt_core_help_params(array()); } else { $xt->is_xintao = true; xt_set_404(); } } elseif (isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] == 'daogou') { $xt->is_xintao = true; $xt->is_daogou = true; } elseif (isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] == 'help') { $xt->is_xintao = true; $xt->is_help = true; } elseif (isset($wp->query_vars['name']) && !empty($wp->query_vars['name'])) { $xt->is_xintao = false; } else { $xt->is_xintao = true; xt_set_404(); } if ($xt->is_login) { $xt_template_name = 'xt-login'; } elseif ($xt->is_account) { $xt_template_name = 'xt-account'; } elseif ($xt->is_sitemap) { $xt_template_name = 'xt-sitemap'; } else { if ($xt->is_index) { $xt_template_name = 'home'; } elseif ($xt->is_shares) { $xt_template_name = 'shares'; } elseif ($xt->is_share) { $xt_template_name = 'share'; } elseif ($xt->is_albums) { $xt_template_name = 'albums'; } elseif ($xt->is_album) { $xt_template_name = 'album'; } elseif ($xt->is_users) { $xt_template_name = 'users'; } elseif ($xt->is_user) { $xt_template_name = 'user'; } elseif ($xt->is_taobaos) { $xt_template_name = 'taobaos'; } elseif ($xt->is_taobao) { $xt_template_name = 'taobao'; } elseif ($xt->is_shops) { $xt_template_name = 'shops'; } elseif ($xt->is_paipais) { $xt_template_name = 'paipais'; } elseif ($xt->is_bijias) { $xt_template_name = 'bijias'; } elseif ($xt->is_tuans) { $xt_template_name = 'tuans'; } elseif ($xt->is_temais) { $xt_template_name = 'temais'; } elseif ($xt->is_coupons) { $xt_template_name = 'coupons'; } elseif ($xt->is_invite) { $xt_template_name = 'invite'; } elseif ($xt->is_daogous) { $xt_template_name = 'daogous'; } elseif ($xt->is_daogou) { $xt_template_name = 'daogou'; } elseif ($xt->is_helps) { $xt_template_name = 'helps'; } elseif ($xt->is_help) { $xt_template_name = 'help'; } elseif ($xt->is_brands) { $xt_template_name = 'brands'; } elseif ($xt->is_stars) { $xt_template_name = 'stars'; } elseif ($xt->is_activities) { $xt_template_name = 'activities'; } elseif ($xt->is_taoquan) { $xt_template_name = 'taoquan'; } elseif ($xt->is_malls) { $xt_template_name = 'malls'; } elseif ($xt->is_error404) { $xt_template_name = 'error404'; } } } }
function xt_register_post_type() { $taglabels = array('name' => __('Tags'), 'singular_name' => __('Tag'), 'search_items' => __('Search Tags'), 'popular_items' => __('Search Tags'), 'all_items' => __('All Tags'), 'edit_item' => __('Edit Tag'), 'update_item' => __('Update Tag'), 'add_new_item' => __('Adding Tags'), 'new_item_name' => __('New Tag Name'), 'separate_items_with_commas' => __('Separate tags with commas'), 'add_or_remove_items' => __('Add or remove tags'), 'choose_from_most_used' => __('Choose from the most used tags')); register_taxonomy('daogou_category', 'daogou', array('hierarchical' => true, 'query_var' => 'daogou_category_name', 'rewrite' => false, 'show_admin_column' => true)); register_taxonomy('daogou_tag', 'daogou', array('hierarchical' => false, 'query_var' => 'daogou_tag', 'rewrite' => false, 'labels' => $taglabels, 'show_admin_column' => true)); register_taxonomy('help_category', 'help', array('hierarchical' => true, 'query_var' => 'help_category_name', 'rewrite' => false, 'show_admin_column' => true)); register_taxonomy('help_tag', 'help', array('hierarchical' => false, 'query_var' => 'help_tag', 'rewrite' => false, 'labels' => $taglabels, 'show_admin_column' => true)); register_post_type('daogou', array('labels' => array('name' => '导购文章', 'singular_name' => '导购文章', 'add_new' => '新建导购', 'all_items' => '所有导购', 'add_new_item' => '新建导购', 'edit_item' => '编辑导购', 'new_item' => '新建导购', 'view_item' => '浏览该导购页面', 'search_items' => '搜索导购', 'not_found' => '未找到符合的导购文章', 'not_found_in_trash' => '未找到符合的导购文章', 'menu_name' => '导购文章', 'name_admin_bar' => '导购文章'), 'public' => true, 'capability_type' => 'post', 'map_meta_cap' => true, 'hierarchical' => true, 'rewrite' => array('slug' => xt_base_daogou(), 'with_front' => false), 'query_var' => true, 'delete_with_user' => true, 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'comments'), 'taxonomies' => array('daogou_category', 'daogou_tag'))); register_post_type('help', array('labels' => array('name' => '帮助', 'singular_name' => '帮助', 'add_new' => '新建帮助', 'all_items' => '所有帮助', 'add_new_item' => '新建帮助', 'edit_item' => '编辑帮助', 'new_item' => '新建帮助', 'view_item' => '浏览该帮助页面', 'search_items' => '搜索帮助', 'not_found' => '未找到符合的帮助文章', 'not_found_in_trash' => '未找到符合的帮助文章', 'menu_name' => '帮助文章', 'name_admin_bar' => '帮助文章'), 'public' => true, 'capability_type' => 'post', 'map_meta_cap' => true, 'hierarchical' => true, 'rewrite' => array('slug' => xt_base_help(), 'with_front' => false), 'query_var' => true, 'delete_with_user' => true, 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'comments'), 'taxonomies' => array('help_category', 'help_tag'))); }