wp_parse_widget_id

函数


wp_parse_widget_id ( $id )
参数
  • (string)
    $id
    Widget ID.
    Required:
返回值
  • (array) Array containing a widget’s id_base and number components.
定义位置
  • wp-includes/widgets.php
    , line 1900
引入
5.8.0
弃用

Converts a widget ID into its id_base and number components.

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