Last active
March 3, 2017 13:13
-
-
Save raftaar1191/7e29aae14148b5ec88af6cf8189cbb0c to your computer and use it in GitHub Desktop.
Add sub menu in media tab in admin menu
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 | |
// check if function does not exists | |
if ( ! function_exists( 'rtmedia_add_admin_bar_media_sub_menu_for_upload' ) ) { | |
function rtmedia_add_admin_bar_media_sub_menu_for_upload() { | |
// Please change the page_slug if you want from here | |
$page_slug = 'file-upload'; | |
// check if function does not exists and RTMEDIA_MEDIA_SLUG is alredy defined | |
if ( function_exists( 'get_page_by_path' ) && defined( 'RTMEDIA_MEDIA_SLUG' ) ) { | |
// 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; | |
$wp_admin_bar->add_menu( array( | |
'parent' => 'my-account-' . RTMEDIA_MEDIA_SLUG, | |
'id' => 'my-account-media-' . $page_slug, | |
'title' => 'Upload', | |
'href' => get_permalink( $page_id ), | |
) ); | |
} | |
} | |
} | |
} | |
} | |
add_action( 'rtmedia_add_admin_bar_media_sub_menu', 'rtmedia_add_admin_bar_media_sub_menu_for_upload', 10 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please the above snippet in functions.php of child themes.