WordPress at Your Fingertips
function is not described

next_widget_id_number() WP 1.0

No Hooks.

Return

Int.

Usage

next_widget_id_number( $id_base );
$id_base(string) (required)
-

Notes

  • Global. Array. $wp_registered_widgets

Code of next_widget_id_number() WP 5.8.2

function next_widget_id_number( $id_base ) {
	global $wp_registered_widgets;
	$number = 1;

	foreach ( $wp_registered_widgets as $widget_id => $widget ) {
		if ( preg_match( '/' . preg_quote( $id_base, '/' ) . '-([0-9]+)$/', $widget_id, $matches ) ) {
			$number = max( $number, $matches[1] );
		}
	}
	$number++;

	return $number;
}