Skip to:
Content
Pages
Categories
Search
Top
Bottom

Group Extension API questions

  • I’m finding the Group Extension API on the Codex to be very helpful.

    I do have a couple of questions, though.

    1. Should ‘nav_item_name’ be translatable, like
      'nav_item_name' => __( 'label_name', 'handle');
    2. Can ‘enable_nav_item’ be conditional? Would a check like this work? (Is the group extension called at the right time to perform these kinds of checks?)
      //Only show the navigation tab if this group has the plugin enabled
          $show_nav_item = ( plugin_is_enabled( bp_get_current_group_id() ) ) ? true : false;
      
      function __construct() {
              $args = array(
      		'enable_nav_item' => $show_nav_item,
      		);
      		parent::init( $args );
      	}

    Thanks for your help,

    -David

Viewing 2 replies - 1 through 2 (of 2 total)

  • Boone Gorges
    Keymaster

    @boonebgorges

    – Yes, 'nav_item_name' should be translatable if you plan to distribute the plugin. If it’s for a custom installation, it doesn’t matter.

    – Yes, you can set 'enable_nav_item' (or any other config value) conditionally. I’d do your conditional logic *inside* of the constructor, to be sure that it’s loaded late enough:

    function __construct() {
        $show_nav_item = (bool) plugin_is_enabled( bp_get_current_group_id() );
        $args = array(
            'enable_nav_item' => $show_nav_item,
        );
        parent::init( $args );
    }

    Great! Thanks for clearing this up.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Group Extension API questions’ is closed to new replies.
Skip to toolbar