bp_core_new_nav_default(数组|字符串$ args.=''的)

修改单击顶级NAV项时加载的默认子Nav项目。

描述

参数

$ args.

大批|细绳的)(可选的)

  • 'parent_slug'
    (细绳)默认的导航项目的SLUID正在更改。
  • 'screen_function'
    (可调用)单击导航项时将运行的新默认回调函数。
  • 'subnav_slug'
    (细绳)新的默认子Nav项目的SLUI。

默认值: ''

来源

文件:BP-Core / BP-Core-BuddyBar.php

函数bp_core_new_nav_default($ args =''){$ bp = buddypress();$默认值=数组('parent_slug'=> false,//父级的slu。'screen_function'=> false,//单击时要运行的函数的名称。'subnav_slug'=> false // slupSubNav项目单击时选择。);$ r = wp_parse_args($ args,$默认值);//这是针对成员的特定 - 它不可用组。$ parent_nav = $ bp->成员 - > nav-> get_primary(数组('slug'=> $ r ['parent_slug']),false);if(!$ parent_nav){return;$ parent_nav =重置($ parent_nav);if(!空($ parent_nav-> screen_function)){//如果可调用屏幕函数,则删除我们的屏幕挂钩。if(is_callable($ parent_nav-> screen_function)){remove_action('bp_screens',$ parent_nav-> screen_function,3); } } // Edit the screen function for the parent nav. $bp->members->nav->edit_nav( array( 'screen_function' => &$r['screen_function'], 'default_subnav_slug' => $r['subnav_slug'], ), $parent_nav->slug ); if ( bp_is_current_component( $parent_nav->slug ) ) { // The only way to tell whether to set the subnav is to peek at the unfiltered_uri // Find the component. $component_uri_key = array_search( $parent_nav->slug, $bp->unfiltered_uri ); if ( false !== $component_uri_key ) { if ( ! empty( $bp->unfiltered_uri[$component_uri_key + 1] ) ) { $unfiltered_action = $bp->unfiltered_uri[$component_uri_key + 1]; } } // No subnav item has been requested in the URL, so set a new nav default. if ( empty( $unfiltered_action ) ) { if ( ! bp_is_current_action( $r['subnav_slug'] ) ) { if ( is_callable( $r['screen_function'] ) ) { add_action( 'bp_screens', $r['screen_function'], 3 ); } $bp->current_action = $r['subnav_slug']; unset( $bp->canonical_stack['action'] ); } // The URL is explicitly requesting the new subnav item, but should be // directed to the canonical URL. } elseif ( $unfiltered_action == $r['subnav_slug'] ) { unset( $bp->canonical_stack['action'] ); // In all other cases (including the case where the original subnav item // is explicitly called in the URL), the canonical URL will contain the // subnav slug. } else { $bp->canonical_stack['action'] = bp_current_action(); } } return; }

变更乐

变更乐
版本 描述
BuddyPress 1.1.0. 介绍。

问题?

我们总是很乐意帮助您可能拥有的代码或其他问题!搜索我们开发人员文档联系支持,或与我们联系销售团队