From 1414e68b3751ab79677d712d489096f8bc55a0fc Mon Sep 17 00:00:00 2001 From: Ben Huson Date: Thu, 19 Apr 2012 20:32:34 +0100 Subject: [PATCH] Remove hacked menu redirect. Props lop-cz. --- admin/admin.php | 23 +---------------------- admin/js/admin.js | 4 ++-- 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/admin/admin.php b/admin/admin.php index 5c9583c..81c8d43 100644 --- a/admin/admin.php +++ b/admin/admin.php @@ -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 ); @@ -111,26 +110,6 @@ 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 * @@ -138,7 +117,7 @@ function admin_init() { */ 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' ); } } diff --git a/admin/js/admin.js b/admin/js/admin.js index b2400e1..3474d65 100644 --- a/admin/js/admin.js +++ b/admin/js/admin.js @@ -1,6 +1,6 @@ jQuery(document).ready( function($) { - + // Taxonomies if ( $('.tagsdiv').length ) { tagBox.init(); @@ -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');