wp_parse_widget_id( string $id )

Converts a widget ID into its id_base and number components.


Parameters Parameters

$id

(string) (Required) Widget ID.


Top ↑

Return Return

(array) Array containing a widget's id_base and number components.


Top ↑

Source Source

File: wp-includes/widgets.php

function wp_parse_widget_id( $id ) {
	$parsed = array();

	if ( preg_match( '/^(.+)-(\d+)$/', $id, $matches ) ) {
		$parsed['id_base'] = $matches[1];
		$parsed['number']  = (int) $matches[2];
	} else {
		// Likely an old single widget.
		$parsed['id_base'] = $id;
	}

	return $parsed;
}


Top ↑

Changelog Changelog

Changelog
Version Description
5.8.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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