functions:
function loadCustomTemplate($template) {
global $wp_query;
if(!file_exists($template))return;
$wp_query->is_page = true;
$wp_query->is_single = false;
$wp_query->is_home = false;
$wp_query->comments = false;
// if we have a 404 status
if ($wp_query->is_404) {
// set status of 404 to false
unset($wp_query->query["error"]);
$wp_query->query_vars["error"]="";
$wp_query->is_404=false;
}
// change the header to 200 OK
header("HTTP/1.1 200 OK");
//load our template
include($template);
exit;
}
function templateRedirect() {
$basename = basename($_SERVER['REQUEST_URI'], '?' . $_SERVER['QUERY_STRING']);
loadCustomTemplate(TEMPLATEPATH.'/custom/'."/$basename.php");
loadCustomTemplate(TEMPLATEPATH.'/custom_resident/'."/$basename.php");
}
add_action('template_redirect', 'templateRedirect');
//党员查询 add_menu_page 第四个参数不能相同
function my_add_pages_s()
{
$current_user = wp_get_current_user();
$role=$current_user->roles[0];
if($role=="administrator")
{
add_menu_page('党员信息查询', '党员信息查询', $role, 'dangyuan_s', 'my_toplevel_page_s','',100);
}
if($role=="editor")
{
add_menu_page('党员信息查询', '党员信息查询', $role, 'dangyuan_s', 'my_toplevel_page_s','',100);
}
if($role=="author")
{
// add_menu_page('党员信息查询', '党员信息查询', $role, 'dangyuan_s', 'my_toplevel_page_s','',80);
echo '';
}
}
function my_toplevel_page_s()
{
include("custom/first_s.php");
}
add_action('admin_menu', 'my_add_pages_s');
//插入
function my_add_pages_i()
{
$current_user = wp_get_current_user();
$role=$current_user->roles[0];
if($role=="administrator")
{
add_menu_page('党员信息插入', '党员信息插入', $role, 'dangyuan_i', 'my_toplevel_page_i','',110);
}
if($role=="editor")
{
add_menu_page('党员信息插入', '党员信息插入', $role, 'dangyuan_i', 'my_toplevel_page_i','',110);
}
if($role=="author")
{
add_menu_page('党员信息插入', '党员信息插入', $role, 'dangyuan_i', 'my_toplevel_page_i','',110);
}
}
function my_toplevel_page_i()
{
include("custom/add_i.php");
}
add_action('admin_menu', 'my_add_pages_i');
//编辑
function my_add_pages_e()
{
$current_user = wp_get_current_user();
$role=$current_user->roles[0];
if($role=="administrator")
{
add_menu_page('党员信息编辑', '党员信息编辑', $role, 'dangyuan_e', 'my_toplevel_page_e','',120);
}
if($role=="editor")
{
add_menu_page('党员信息编辑', '党员信息编辑', $role, 'dangyuan_e', 'my_toplevel_page_e','',120);
}
if($role=="author")
{
// add_menu_page('党员信息编辑', '党员信息编辑', $role, 'dangyuan_e', 'my_toplevel_page_e','',100);
echo '';
}
}
function my_toplevel_page_e()
{
include("custom/first_e.php");
}
add_action('admin_menu', 'my_add_pages_e');
//居民查询
function my_add_pages_resident_s()
{
$current_user = wp_get_current_user();
$role=$current_user->roles[0];
if($role=="administrator")
{
add_menu_page('居民信息查询', '居民信息查询', $role, 'jumin_s', 'my_toplevel_page_resident_s','',130);
}
if($role=="editor")
{
add_menu_page('居民信息查询', '居民信息查询', $role, 'jumin_s', 'my_toplevel_page_resident_s','',130);
}
if($role=="author")
{
// add_menu_page('居民信息查询', '居民信息查询', $role, 'jumin_s', 'my_toplevel_page_resident_s','',110);
echo '';
}
}
// my_toplevel_page() 用于显示菜单的内容,填写菜单页面的HTML代码即可
function my_toplevel_page_resident_s()
{
include("custom_resident/resident_s.php");
}
add_action('admin_menu', 'my_add_pages_resident_s');
//居民插入
function my_add_pages_resident_i()
{
$current_user = wp_get_current_user();
$role=$current_user->roles[0];
if($role=="administrator")
{
add_menu_page('居民信息插入', '居民信息插入', $role, 'jumin_i', 'my_toplevel_page_resident_i','',140);
}
if($role=="editor")
{
add_menu_page('居民信息插入', '居民信息插入', $role, 'jumin_i', 'my_toplevel_page_resident_i','',140);
}
if($role=="author")
{
add_menu_page('居民信息插入', '居民信息插入', $role, 'jumin_i', 'my_toplevel_page_resident_i','',140);
}
}
// my_toplevel_page() 用于显示菜单的内容,填写菜单页面的HTML代码即可
function my_toplevel_page_resident_i()
{
include("custom_resident/re_add_i.php");
}
add_action('admin_menu', 'my_add_pages_resident_i');
//居民编辑
function my_add_pages_resident_e()
{
$current_user = wp_get_current_user();
$role=$current_user->roles[0];
if($role=="administrator")
{
add_menu_page('居民信息编辑', '居民信息编辑', $role, 'jumin_e', 'my_toplevel_page_resident_e','',150);
}
if($role=="editor")
{
add_menu_page('居民信息编辑', '居民信息编辑', $role, 'jumin_e', 'my_toplevel_page_resident_e','',150);
}
if($role=="author")
{
// add_menu_page('居民信息编辑', '居民信息编辑', $role, 'jumin_e', 'my_toplevel_page_resident_e','',130);
echo '';
}
}
// my_toplevel_page() 用于显示菜单的内容,填写菜单页面的HTML代码即可
function my_toplevel_page_resident_e()
{
include("custom_resident/resident_e.php");
}
add_action('admin_menu', 'my_add_pages_resident_e');