parse_widget_id example



    /** * Converts a widget_id into its corresponding Customizer setting ID (option name). * * @since 3.9.0 * * @param string $widget_id Widget ID. * @return string Maybe-parsed widget ID. */
    public function get_setting_id( $widget_id ) {
        $parsed_widget_id = $this->parse_widget_id( $widget_id );
        $setting_id       = sprintf( 'widget_%s', $parsed_widget_id['id_base'] );

        if ( ! is_null( $parsed_widget_id['number'] ) ) {
            $setting_id .= sprintf( '[%d]', $parsed_widget_id['number'] );
        }
        return $setting_id;
    }

    /** * Determines whether the widget is considered "wide". * * Core widgets which may have controls wider than 250, but can still be shown * in the narrow Customizer panel. The RSS and Text widgets in Core, for example, * have widths of 400 and yet they still render fine in the Customizer panel. * * This method will return all Core widgets as being not wide, but this can be * overridden with the {@see 'is_wide_widget_in_customizer'} filter. * * @since 3.9.0 * * @global array $wp_registered_widget_controls * * @param string $widget_id Widget ID. * @return bool Whether or not the widget is a "wide" widget. */
Home | Imprint | This part of the site doesn't use cookies.