wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



wp_parse_widget_id › WordPress Function

Od5.8.0
Przestarzałyn/a
wp_parse_widget_id ( $id )
Parametry:
  • (string) $id Widget ID.
    Wymagane: Tak
Powrót:
  • (array) Array containing a widget's id_base and number components.
Zdefiniowane na:
Codex:

Converts a widget ID into its id_base and number components.



Źródło

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