A WordPress-centric search engine for devs and theme authors



next_widget_id_number ›

Sincen/a
Deprecatedn/a
next_widget_id_number ( $id_base )
Parameters:
  • (string) $id_base
    Required: Yes
Returns:
  • (int)
Defined at:
Codex:

No description yet.



Source

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;
}