next_widget_id_number( string $id_base )


Parameters Parameters

$id_base

(string) (Required)


Top ↑

Return Return

(int)



Top ↑

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

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.