Skip to content

Instantly share code, notes, and snippets.

@stas
Created February 13, 2011 14:21
Show Gist options
  • Save stas/824715 to your computer and use it in GitHub Desktop.
Save stas/824715 to your computer and use it in GitHub Desktop.
New Courseware hack to move nav_options elsewhere
<?php
/*
Plugin Name: Hide Courseware nav option and move them elsewhere...
Author: stas
*/
class CW_Hacks {
public static $hide = false;
public static $options = array();
function init() {
add_action( 'bp_before_group_body', array( __CLASS__, 'set_hide_on' ), 1 );
add_action( 'bp_before_group_body', array( __CLASS__, 'start_hide'), 2 );
add_action( 'bp_before_group_body', array( __CLASS__, 'end_hide'), 100 );
add_filter( 'courseware_group_nav_options', array( __CLASS__, 'nav_options' ), 100 );
add_action( 'bp_template_content', array( __CLASS__, 'render_nav' ), 1 );
}
function set_hide_on() {
self::$hide = true;
}
function start_hide() {
if( self::$hide )
echo '<!--';
}
function end_hide() {
if( self::$hide ) {
self::$hide = false;
echo '-->';
}
}
function nav_options( $options ) {
self::$options = $options;
return $options;
}
function render_nav() {
foreach( self::$options as $name => $uri )
echo "<a href='$uri'>$name</a> | ";
}
}
CW_Hacks::init();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment