Skip to content

Instantly share code, notes, and snippets.

@kasparsd
Created April 20, 2015 07:15
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 kasparsd/6859c4b399c145ae216a to your computer and use it in GitHub Desktop.
Save kasparsd/6859c4b399c145ae216a to your computer and use it in GitHub Desktop.
Notify WordPress menu update exceeding max_input_vars
<?php
/*
* Plugin Name: Menu Update Warning
* Plugin URI:
* Description:
* Version: 0.1
* Author:
* Author URI:
*/
add_action( 'admin_head-nav-menus.php', function() {
if ( 'POST' !== $_SERVER['REQUEST_METHOD'] )
return;
add_action( 'admin_notices', function() {
$items_sent = count( $_POST, 1 );
$items_accepted = ini_get('max_input_vars');
if ( $items_sent > $items_accepted ) {
$notice = sprintf(
__( 'Error: Menu update sent %d items while the server is configured to accept no more than %d items. Some of the menu items may have been lost!' ),
$items_sent,
$items_accepted
);
printf(
'<div class="error">
<p>%s</p>
</div>',
esc_html( $notice )
);
}
} );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment