Skip to content

Instantly share code, notes, and snippets.

@danielbachhuber
Created June 24, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielbachhuber/dac825eb195febcb0e19 to your computer and use it in GitHub Desktop.
Save danielbachhuber/dac825eb195febcb0e19 to your computer and use it in GitHub Desktop.
<?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