/gist:dac825eb195febcb0e19 Secret
Created
June 24, 2015 14:04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Redirect back to term edit page after save | |
* When there's lots of meta boxes to change on a term page, | |
* we want to keep the user on the page for a while | |
*/ | |
add_action( 'admin_init', function() { | |
global $pagenow; | |
if ( 'edit-tags.php' !== $pagenow | |
|| ! empty( $_GET['tag_ID'] ) | |
|| ! empty( $_GET['action'] ) | |
|| empty( $_GET['message'] ) | |
|| 3 != $_GET['message'] ) { | |
return; | |
} | |
$referer = wp_get_referer(); | |
parse_str( parse_url( $referer, PHP_URL_QUERY ), $args ); | |
$args['message'] = 3; | |
$redirect_back = add_query_arg( $args, admin_url( 'edit-tags.php' ) ); | |
wp_safe_redirect( $redirect_back ); | |
exit; | |
}); | |
add_action( 'admin_notices', function() { | |
global $pagenow; | |
if ( 'edit-tags.php' !== $pagenow | |
|| empty( $_GET['tag_ID'] ) | |
|| empty( $_GET['action'] ) | |
|| empty( $_GET['message'] ) | |
|| 3 != $_GET['message'] ) { | |
return; | |
} | |
echo '<div id="message" class="updated"><p>' . esc_html__( 'Item updated.', 'fusion' ) . '</p></div>'; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment