WP_Customize_Widgets::parse_widget_id() – Converts a widget ID into its id_base and number components.

You appear to be a bot. Output may be restricted

Description

Converts a widget ID into its id_base and number components.

Usage

$array = WP_Customize_Widgets::parse_widget_id( $widget_id );

Parameters

$widget_id
( string ) required – Widget ID.

Returns

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

Source

File name: wordpress/wp-includes/class-wp-customize-widgets.php
Lines:

1 to 15 of 15
  public function parse_widget_id( $widget_id ) {
    $parsed = array(
      'number'  => null,
      'id_base' => null,
    );

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

 View on GitHub View on Trac