/*
** Add Dropdown Pages Links to WordPress Admin Bar
*/
// Add Parent Link
function dplugins_toolbar_page_links($wp_admin_bar) {
$parent_menu_args = array(
'id' => 'dplugins-ct-pages',
'title' => 'Páginas',
'href' => site_url().'/wp-admin/edit.php?post_type=ct_template',
'meta' => array(
'class' => 'dplugins-ct-pages',
'title' => 'Páginas'
)
);
$wp_admin_bar->add_node($parent_menu_args);
// Add Pages List
$ct_pages = get_posts(array(
'post_type' => 'page',
'posts_per_page' => -1,
));
if($ct_pages){
foreach($ct_pages as $ct_page){
$ct_page_args = array(
'id' => 'dplugins-'.$ct_page->post_name,
'title' => $ct_page->post_title,
'href' => site_url().'/wp-admin/post.php?post='.$ct_page->ID.'&action=edit',
'parent' => 'dplugins-ct-pages',
'meta' => array(
'class' => 'dplugins-oxy-pages',
'title' => $ct_page->post_title,
)
);
$wp_admin_bar->add_node($ct_page_args);
}
}
}
add_action('admin_bar_menu', 'dplugins_toolbar_page_links', 999);