Downloads submenu,
* regardless of which actual Downloads Taxonomy screen we are on.
*
* The conditional prevents the override when the user is viewing settings or
* any third-party plugins.
*
* @since 3.0.0
*
* @global string $submenu_file
*/
function edd_taxonomies_modify_menu_highlight() {
global $submenu_file;
// Bail if not viewing a taxonomy
if ( empty( $_GET['taxonomy'] ) ) {
return;
}
// Get taxonomies
$taxonomy = sanitize_key( $_GET['taxonomy'] );
$taxonomies = get_object_taxonomies( 'download' );
// Bail if current taxonomy is not a download taxonomy
if ( ! in_array( $taxonomy, $taxonomies, true ) ) {
return;
}
// Force the submenu file
$submenu_file = 'edit.php?post_type=download';
}
add_filter( 'admin_head', 'edd_taxonomies_modify_menu_highlight', 9999 );
/**
* This tells WordPress to highlight the Downloads > Downloads submenu when
* adding a new product.
*
* @since 3.0.0
*
* @global string $submenu_file
*/
function edd_add_new_modify_menu_highlight() {
global $submenu_file, $pagenow;
// Bail if not viewing the right page or post type
if ( empty( $_GET['post_type'] ) || ( 'post-new.php' !== $pagenow ) ) {
return;
}
// Get post_type
$post_type = sanitize_key( $_GET['post_type'] );
// Bail if current post type is not download
if ( 'download' !== $post_type ) {
return;
}
// Force the submenu file
$submenu_file = 'edit.php?post_type=download';
}
add_filter( 'admin_head', 'edd_add_new_modify_menu_highlight', 9999 );
/**
* Displays the product tabs for Products, Categories, and Tags
*
* @since 2.8.9
*/
function edd_display_product_tabs() {
// Initial tabs
$tabs = array(
'products' => array(
'name' => edd_get_label_plural(),
'url' => edd_get_admin_url(),
),
);
// Get taxonomies
$taxonomies = get_object_taxonomies( 'download', 'objects' );
foreach ( $taxonomies as $tax => $details ) {
$tabs[ $tax ] = array(
'name' => $details->labels->menu_name,
'url' => add_query_arg( array(
'taxonomy' => sanitize_key( $tax ),
'post_type' => 'download'
), admin_url( 'edit-tags.php' ) )
);
}
// Filter the tabs
$tabs = apply_filters( 'edd_add_ons_tabs', $tabs );
// Taxonomies
if ( isset( $_GET['taxonomy'] ) && in_array( $_GET['taxonomy'], array_keys( $taxonomies ), true ) ) {
$active_tab = $_GET['taxonomy'];
// Default to Products
} else {
$active_tab = 'products';
}
// Start a buffer
ob_start();
?>