wp_find_widgets_sidebar example

/** * Renders the 'core/legacy-widget' block. * * @param array $attributes The block attributes. * * @return string Rendered block. */
function render_block_core_legacy_widget( $attributes ) {
    global $wp_widget_factory;

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

    

    public function get_item_permissions_check( $request ) {
        $this->retrieve_widgets();

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

        if ( $sidebar_id && $this->check_read_sidebar_permission( $sidebar_id ) ) {
            return true;
        }

        return $this->permissions_check( $request );
    }

    /** * Checks if a sidebar can be read publicly. * * @since 5.9.0 * * @param string $sidebar_id The sidebar ID. * @return bool Whether the sidebar can be read. */
Home | Imprint | This part of the site doesn't use cookies.