wp_parse_widget_id example


        wp_get_sidebars_widgets();
        $this->retrieve_widgets();

        $widget_id  = $request['id'];
        $sidebar_id = wp_find_widgets_sidebar( $widget_id );

        // Allow sidebar to be unset or missing when widget is not a WP_Widget.         $parsed_id     = wp_parse_widget_id( $widget_id );
        $widget_object = $wp_widget_factory->get_widget_object( $parsed_id['id_base'] );
        if ( is_null( $sidebar_id ) && $widget_object ) {
            return new WP_Error(
                'rest_widget_not_found',
                __( 'No widget was found with that id.' ),
                array( 'status' => 404 )
            );
        }

        if (
            $request->has_param( 'instance' ) ||
            

    protected function get_widgets() {
        global $wp_widget_factory$wp_registered_widgets;

        $widgets = array();

        foreach ( $wp_registered_widgets as $widget ) {
            $parsed_id     = wp_parse_widget_id( $widget['id'] );
            $widget_object = $wp_widget_factory->get_widget_object( $parsed_id['id_base'] );

            $widget['id']       = $parsed_id['id_base'];
            $widget['is_multi'] = (bool) $widget_object;

            if ( isset( $widget['name'] ) ) {
                $widget['name'] = html_entity_decode( $widget['name'], ENT_QUOTES, get_bloginfo( 'charset' ) );
            }

            if ( isset( $widget['description'] ) ) {
                $widget['description'] = html_entity_decode( $widget['description'], ENT_QUOTES, get_bloginfo( 'charset' ) );
            }
Home | Imprint | This part of the site doesn't use cookies.