Last active
February 3, 2020 12:15
-
-
Save BhargavBhandari90/2aaebea7e67e07a08a5baddfcb868583 to your computer and use it in GitHub Desktop.
Add links to BuddyPress navigation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add this function to theme's functions.php | |
* | |
* Add links to BuddyPress navigation. | |
* This will add photo, video and music link to BuddyPress navigation. | |
* | |
* If you don't want to display "Media" tab, then add following css to | |
* rtMedia->Settings->Custom CSS: | |
* | |
* #media-personal-li { | |
* display: none; | |
* } | |
* | |
*/ | |
function rtmedia_custom_media_nav_tab() { | |
if ( ! function_exists( 'bp_core_new_nav_item' ) ) { | |
return; | |
} | |
// Array of links. | |
$links = array( | |
'photo' => esc_html__( 'Photos', 'rtmedia' ), | |
'video' => esc_html__( 'Videos', 'rtmedia' ), | |
'music' => esc_html__( 'Music', 'rtmedia' ), | |
); | |
$c=100; | |
foreach ( $links as $slug => $menu_title ) { | |
// Add links to BP navigation | |
bp_core_new_nav_item( array( | |
'name' => $menu_title, | |
'slug' => RTMEDIA_MEDIA_SLUG . '/' . $slug, | |
'position' => $c, | |
) ); | |
$c++; | |
} | |
} | |
if ( class_exists( 'BuddyPress' ) ) { | |
add_action( 'bp_init', 'rtmedia_custom_media_nav_tab', 11, 1 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment