WordPress at a glance
function is not described

next_widget_id_number() WP 1.0

  • Global. Array. $wp_registered_widgets

No Hooks.

Return

Int.

Usage

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

Code of next widget id number: wp-admin/includes/widgets.php VER 5.1.1

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

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

	return $number;
}