get_widget_key example

if ( isset( $attributes['id'] ) ) {
        $sidebar_id = wp_find_widgets_sidebar( $attributes['id'] );
        return wp_render_widget( $attributes['id']$sidebar_id );
    }

    if ( ! isset( $attributes['idBase'] ) ) {
        return '';
    }

    $id_base       = $attributes['idBase'];
    $widget_key    = $wp_widget_factory->get_widget_key( $id_base );
    $widget_object = $wp_widget_factory->get_widget_object( $id_base );

    if ( ! $widget_key || ! $widget_object ) {
        return '';
    }

    if ( isset( $attributes['instance']['encoded']$attributes['instance']['hash'] ) ) {
        $serialized_instance = base64_decode( $attributes['instance']['encoded'] );
        if ( ! hash_equals( wp_hash( $serialized_instance )(string) $attributes['instance']['hash'] ) ) {
            return '';
        }
        


    /** * Returns the registered WP_Widget object for the given widget type. * * @since 5.8.0 * * @param string $id_base Widget type ID. * @return WP_Widget|null */
    public function get_widget_object( $id_base ) {
        $key = $this->get_widget_key( $id_base );
        if ( '' === $key ) {
            return null;
        }

        return $this->widgets[ $key ];
    }

    /** * Returns the registered key for the given widget type. * * @since 5.8.0 * * @param string $id_base Widget type ID. * @return string */
/** This filter is documented in wp-includes/class-wp-widget.php */
            $instance = apply_filters(
                'widget_update_callback',
                $instance,
                $new_instance,
                $old_instance,
                $widget_object
            );
        }

        $serialized_instance = serialize( $instance );
        $widget_key          = $wp_widget_factory->get_widget_key( $id );

        $response = array(
            'form'     => trim(
                $this->get_widget_form(
                    $widget_object,
                    $instance
                )
            ),
            'preview'  => trim(
                $this->get_widget_preview(
                    $widget_key,
                    
Home | Imprint | This part of the site doesn't use cookies.