📄 wp-menu.php
字号:
if(isset($params['indent_rec'])){$indent = $params['indent_rec'];} $params['indent_rec'] = $indent; if($params['heading']=="h2") { if(!isset($params['children'][0]['post_parent'])){$params['children'] = array(array('post_parent'=>0));} $headingTitle = wp_menu_get_heading($params['children'][0]['post_parent']); $ret .= $params['indent_rec']."<h2>".$headingTitle."</h2>\n"; } if(($params['nav_wrap']==0&&$params['level']>0)||$params['nav_wrap']==1) { $ret .= $params['indent_rec']."<".$params['nav_tag']; if(!empty($params['nav_class'])){$ret .= " class=\"".$params['nav_class']."\"";} if(!empty($params['nav_id'])){$ret .= " id=\"".$params['nav_id']."\"";} $ret .= ">\n"; } if($params['heading']=="dt") { if(!isset($params['children'][0]['post_parent'])){$params['children'] = array(array('post_parent'=>0));} $headingTitle = wp_menu_get_heading($params['children'][0]['post_parent']); $ret .= $params['indent_rec']."\t<dt>".$headingTitle."</dt>\n"; } foreach($params['children'] as $k=>$v) { $ret .= $params['indent_rec']."\t<".$item_type; if($params['active']=="item"&&!empty($params['active_class'])&&(in_array($params['this_id'],$v['children_ids'])||$params['this_id']==$v['ID'])) { $ret .= " class=\"".$params['active_class']."\""; } $ret .= ">"; $ret .= "<a href=\"".$v['link_href']."\""; if(!empty($params['link_titles'])){$ret .= " title=\"".$v['link_title']."\"";} if(!empty($params['target'])){$ret .= " target=\"".$params['target']."\"";} if($params['active']=="link"&&!empty($params['active_class'])&&(in_array($params['this_id'],$v['children_ids'])||$params['this_id']==$v['ID'])) { $ret .= " class=\"".$params['active_class']."\""; } if($params['accesskeys']==1) { $params['x']++; $ret .= " accesskey=\"".$params['x']."\""; } $ret .= ">".$v['link_title']."</a>"; if(!empty($v['children'])) { $rat = "\n".wp_menu_get_level($v['children'],$params); if($rat!=""){$ret .= $rat.$params['indent_rec']."\t";} } $ret .= "</".$item_type.">\n"; } if(($params['nav_wrap']==0&&$params['level']>0)||$params['nav_wrap']==1) { $ret .= $params['indent_rec']."</".$params['nav_tag'].">\n"; } } if($params['div']==1) { $ret .= $params['indent']."</div>\n"; } return $ret; }function wp_menu_get_level($children,$params) { if(empty($children)){return;} $params['level']++; $params['indent_rec'] = $params['indent_rec']."\t"; $ret = ""; if(($params['nav_wrap']==0&&$params['level']>1)||$params['nav_wrap']==1) { $ret .= $params['indent_rec']."\t<ul"; if($params['heading']=="0"&&$params['nav_applied']==0) { if(!empty($params['nav_class'])){$ret .= " class=\"".$params['nav_class']."\"";} if(!empty($params['nav_id'])){$ret .= " id=\"".$params['nav_id']."\"";} $params['nav_applied'] = 1; } $ret .= ">\n"; } $wasActive=0; foreach($children as $k=>$v) { if($params['home_path']==$childURL['path']) { $v['link_href'] = $params['home_link']; } if($params['exclude_uri']!==false&&strpos($v['link_href'],$params['exclude_uri'])!==false) { continue; } $thisisActive = 0; $childURL = parse_url($v['link_href']); if(!$childURL) { if($newchildURL = parse_url('http://'.$_SERVER['HTTP_HOST'].$v['link_href'])) { $childURL = $newchildURL; } } $primaryURL = '.'.$_SERVER['REQUEST_URI']; if($wasActive<1 &&!empty($params['active_class']) &&( in_array($params['this_id'],$v['children_ids']) ||$params['this_id']==$v['ID'] ||( (strpos($primaryURL,'.'.$childURL['path'])>-1&&$params['is_custom']==0) ||$primaryURL=='.'.$childURL['path'] ||($params['c2p_active']>0&&$v['ID']==$params['c2p_pid']) ||($params['b2p_active']>0&&$v['ID']==$params['b2p_pid']) ||($params['home_path']==$childURL['path']&&$primaryURL=='./') ) ) ) { $thisisActive=1; $wasActive=1; } $ret .= $params['indent_rec']."\t\t<li"; if($thisisActive>0&&$params['active']=="item") { $ret .= " class=\"".$params['active_class']."\""; } $ret .= ">"; $ret .= "<a href=\"".$v['link_href']."\""; if(!empty($params['link_titles'])){$ret .= " title=\"".$v['link_title']."\"";} if(!empty($params['target'])){$ret .= " target=\"".$params['target']."\"";} if($thisisActive>0&&$params['active']=="link") { $ret .= " class=\"".$params['active_class']."\""; } if($params['accesskeys']==1) { $params['x']++; $ret .= " accesskey=\"".$params['x']."\""; } $ret .= ">".$v['link_title']."</a>"; if(!empty($v['children'])&&$params['nav_type']!="single") { $indent = $params['indent_rec']; $params['indent_rec'] = $indent."\t"; $rat = "\n".wp_menu_get_level($v['children'],$params); $params['indent_rec'] = $indent; if($rat!=""){$ret .= $rat.$params['indent_rec']."\t\t";} } $ret .= "</li>\n"; } if(($params['nav_wrap']==0&&$params['level']>1)||$params['nav_wrap']==1) { $ret .= $params['indent_rec']."\t</ul>\n"; } return $ret; }function wp_menu_get_href($id) { $ret = get_bloginfo("wpurl")."/"; if($id!=0){$ret = get_permalink($id);} return $ret; }function wp_menu_secondary_menu_links($page_id='x',$params='') { global $wp_query; $get = $wp_query->post; if($page_id!='x'&&$page_id!=$get->ID) { $get = get_post($page_id); } if($get->post_type!='page') { $get = wp_menu_page_by_path($params); } $get_top_post = $get; $top_post_parent_id = $get_top_post->ID; $get_top_post_parent_id = $get_top_post->post_parent; if($page_id=='x') while($get_top_post_parent_id) { $get_top_post = get_post($get_top_post_parent_id); $top_post_parent_id = $get_top_post->ID; $get_top_post_parent_id = $get_top_post->post_parent; } $ext = ''; if(isset($params['nav_type'])&&$params['nav_type']=="single_secondary") { if($params['nav_levels']!=0&&$params['nav_levels']<2) { $ext = '&depth='.($params['nav_levels']-1); } } $sub_pages = wp_list_pages('sort_column=menu_order&title_li=&echo=0&child_of='.$top_post_parent_id.$ext); $matches_1 = $matches_2 = $matches_3 = $matches_4 = $ret['matches'] = $ret['full']['non'] = $ret['full']['current'] = $ret['full']['current_parent'] = $ret['full']['current_ancestor'] = $ret['full'] = $ret = array(); preg_match_all('/page-item-(.\d*)\"/si',$sub_pages,$matches_1); preg_match_all('/page-item-(.\d*) current_page_item\"/si',$sub_pages,$matches_2); preg_match_all('/page-item-(.\d*) current_page_ancestor current_page_parent\"/si',$sub_pages,$matches_3); preg_match_all('/page-item-(.\d*) current_page_ancestor\"/si',$sub_pages,$matches_4); if(isset($params['nav_type'])&&$params['nav_type']=="single_secondary") { $ret['full']['current'][] = $top_post_parent_id; } foreach($matches_1[1] as $m) { $ret['matches'][] = $m; if(isset($params['nav_type'])&&$params['nav_type']=="single_secondary") { $ret['full']['current'][] = $m; } else { $ret['full']['non'][] = $m; } } foreach($matches_2[1] as $m) { $ret['matches'][] = $m; $ret['full']['current'][] = $m; } foreach($matches_3[1] as $m) { $ret['matches'][] = $m; $ret['full']['current_parent'][] = $m; $ret['full']['current'][] = $m; } foreach($matches_4[1] as $m) { $ret['matches'][] = $m; $ret['full']['current_ancestor'][] = $m; $ret['full']['current'][] = $m; } $ret['matches'][] = $top_post_parent_id; $ret['full']['top'] = $top_post_parent_id; return $ret; }function wp_menu_page_drop_last ($uri=NULL) { if($uri==NULL) { $uri = $_SERVER['REQUEST_URI']; } $exp = explode('/',$uri); $exp = array_filter($exp); $exp = array_reverse($exp); unset($exp[0]); $exp = array_reverse($exp); $uri = '/'.implode('/',$exp).'/'; if($uri=='//'){$uri='/';} return $uri; }function wp_menu_page_by_path ($params='',$uri=NULL) { if(!is_array($params)){$params = array();} if($uri==NULL) { $uri = $_SERVER['REQUEST_URI']; } $page = get_page_by_path($uri); if(isset($params['page_by_path_last'])&&$params['page_by_path_last']==$uri&&$page==NULL) { global $wp_query; $get = $wp_query->post; return $get; } $params['page_by_path_last'] = $uri; if($page==NULL) { $uri = wp_menu_page_drop_last($uri); $page = wp_menu_page_by_path($params,$uri); } return $page; }?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -