Skip to content

Instantly share code, notes, and snippets.

@raftaar1191
Created March 2, 2017 14:37
Show Gist options
  • Save raftaar1191/56520d1bb6e505a8f560da3f4ffb2aef to your computer and use it in GitHub Desktop.
Save raftaar1191/56520d1bb6e505a8f560da3f4ffb2aef to your computer and use it in GitHub Desktop.
Add sub menu in rtMedia media tab in profile menu
<?php
// check if function does not exists
if ( ! function_exists( 'rtmedia_add_extra_sub_nav_for_upload' ) ) {
function rtmedia_add_extra_sub_nav_for_upload() {
// IMPORTANT Please change the page_slug
$page_slug = 'file-upload';
// check if function does not exists
if ( function_exists( 'get_page_by_path' ) ) {
// get the page by slug
$page_data = get_page_by_path( $page_slug );
// check if the page exists.
if ( is_object( $page_data ) ) {
// check if the page id exists.
if ( isset( $page_data->ID ) ) {
global $wp_admin_bar;
global $rtmedia;
$page_id = $page_data->ID;
?>
<li class="rtmedia-nav-item-<?php echo $page_slug; ?>-profile-1-li">
<a id="rtmedia-nav-item-<?php echo $page_slug; ?>" href="<?php echo get_permalink( $page_id ); ?>">Upload</a>
</li>
<?php
}
}
}
}
}
add_action( 'add_extra_sub_nav' , 'rtmedia_add_extra_sub_nav_for_upload', 10 );
@raftaar1191
Copy link
Author

raftaar1191 commented Mar 2, 2017

Please the above snippet in functions.php of child themes.

=================IMPORTANT====================
Please change the $page_slug variable to your page slug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment