Skip to content

Commit

Permalink
Remove hacked menu redirect.
Browse files Browse the repository at this point in the history
Props lop-cz.
  • Loading branch information
benhuson committed Apr 19, 2012
1 parent db812a4 commit 1414e68
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 24 deletions.
23 changes: 1 addition & 22 deletions admin/admin.php
Expand Up @@ -44,7 +44,6 @@ class AttachmentTaxSupp_Admin {
*/
function AttachmentTaxSupp_Admin() {
global $AttachmentTaxSupp;
add_action( 'admin_init', array( $this, 'admin_init' ) );
add_action( 'admin_menu', array( $this, 'add_media_taxonomy_menus' ) );
add_filter( 'attachment_fields_to_edit', array( $this, 'attachment_fields_to_edit' ), null, 2 );
add_filter( 'attachment_fields_to_save', array( $this, 'attachment_fields_to_save' ), null, 2 );
Expand Down Expand Up @@ -111,34 +110,14 @@ function get_edit_term_link( $location, $term_id, $taxonomy, $object_type ) {
return $location;
}

/**
* Redirect to edit taxonomy
* This is a bit hacky. Would be nice if taxonomy menu items were
* added automatically like for posts.
*/
function admin_init() {
if ( isset( $_GET['page'] ) && 'attachmenttaxsupp_' == substr( $_GET['page'], 0, 18 ) ) {
$tax = substr( $_GET['page'], 18 );
if ( taxonomy_exists( $tax ) ) {
if ( is_network_admin() ) {
$tax_url = network_admin_url( 'edit-tags.php?taxonomy=' . $tax );
} else {
$tax_url = admin_url( 'edit-tags.php?taxonomy=' . $tax );
}
wp_redirect( add_query_arg( 'post_type', 'attachment', $tax_url ) );
exit;
}
}
}

/**
* Add Media Taxonomy Menus
*
* @todo Check if taxonomy has UI etc.
*/
function add_media_taxonomy_menus() {
foreach ( get_taxonomies( array( 'object_type' => array( 'attachment' ) ), 'objects' ) as $tax ) {
add_submenu_page( 'upload.php', $tax->label, $tax->labels->menu_name, 'edit_posts', 'attachmenttaxsupp_' . $tax->name, array( $this, 'media_taxonomy_edit_page' ) );
add_submenu_page( 'upload.php', $tax->label, $tax->labels->menu_name, 'edit_posts', 'edit-tags.php?taxonomy=' . $tax->name . '&post_type=attachment' );
}
}

Expand Down
4 changes: 2 additions & 2 deletions admin/js/admin.js
@@ -1,6 +1,6 @@

jQuery(document).ready( function($) {

// Taxonomies
if ( $('.tagsdiv').length ) {
tagBox.init();
Expand All @@ -9,7 +9,7 @@ jQuery(document).ready( function($) {
// Admin Menu
if ($('body.attachmenttaxsupp').length > 0) {
$('#menu-media .wp-submenu li a').each(function(){
if ($(this).attr('href') == 'upload.php?page=attachmenttaxsupp_' + attachmentTaxSuppSettings.taxonomy) {
if ($(this).attr('href') == 'edit-tags.php?taxonomy=' + attachmentTaxSuppSettings.taxonomy + '&post_type=attachment') {
// Deselect Posts Menu
$('#menu-posts').removeClass('wp-has-current-submenu').removeClass('wp-menu-open').removeClass('open-if-no-js').addClass('wp-not-current-submenu');
$('#menu-posts > a').removeClass('wp-has-current-submenu').addClass('wp-not-current-submenu');
Expand Down

0 comments on commit 1414e68

Please sign in to comment.