= 3.8) {
$title = '' . __('Edit Content', 'bs_abep') . '';
$img = '';
} else {
$title = '
' . __('Edit Content', 'bs_abep') . '';
$img = '_no_dashicon';
}
$admin_url = admin_url();
// Add the Parent link.
$wp_admin_bar->add_menu( array(
'title' => $title,
'href' => false,
'id' => 'bs_abep_links'.$img,
));
$args = array(
'order' => 'ASC',
'orderby' => 'menu_order',
'post_status' => 'publish',
'posts_per_page' => -1,
);
foreach ($options as $post_type => $nice_name){
$args['post_type'] = $post_type;
// Filter the args now
if (has_filter('bs_abep_query_args')) {
$args = apply_filters('bs_abep_query_args', $args);
// Let's reset the post type in case the user inadvertently changed it - there's really no reaon to change it.
$args['post_type'] = $post_type;
}
$bs_abep_query = get_posts( $args );
if ( !empty($bs_abep_query) ) :
// We have some posts, let's add a parent menu
$wp_admin_bar->add_menu( array(
'title' => $nice_name,
'href' => $admin_url . 'edit.php?post_type=' . $post_type,
'id' => $post_type,
'parent' => 'bs_abep_links'.$img
));
foreach ($bs_abep_query as $post) {
if ($post->post_parent != 0){
$label = ' – '.ucwords($post->post_title);
$parent_id = $post->post_parent;
if ( ( count( get_post_ancestors($parent_id) ) ) >= 1 ) {
$label = ' '.$label;
}
} else {
$label = ucwords($post->post_title);
}
$url = get_edit_post_link($post->ID);
$wp_admin_bar->add_menu( array(
'title' => $label,
'href' => $url,
'id' => $post->ID,
'parent' => $post_type
));
}
endif;
}
}
function bs_abep_activation_callback() {
$options = get_option('bs_abep_settings', array());
$default = array(
'types' => array(
'page' => 'Pages',
),
);
if ( empty($options) ) {
update_option('bs_abep_settings', $default );
}
}
?>