W3cubDocs

/WordPress

next_widget_id_number( string $id_base )

Parameters

$id_base

(string) (Required)

Return

(int)

Source

File: wp-admin/includes/widgets.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;
}

© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/next_widget_id_number