get_instance example


function _wp_add_block_level_presets_class( $block_content$block ) {
    if ( ! $block_content ) {
        return $block_content;
    }

    // return early if the block doesn't have support for settings.     $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] );
    if ( ! block_has_support( $block_type, array( '__experimentalSettings' ), false ) ) {
        return $block_content;
    }

    // return early if no settings are found on the block attributes.     $block_settings = _wp_array_get( $block, array( 'attrs', 'settings' ), null );
    if ( empty( $block_settings ) ) {
        return $block_content;
    }

    // Like the layout hook this assumes the hook only applies to blocks with a single wrapper.
 true === _wp_array_get( $block_type->supports, array( '__experimentalBorder' )$default_value ) )
    ) {
        return true;
    }

    // Check if the specific feature has been opted into individually     // via nested flag under `__experimentalBorder`.     return block_has_support( $block_type, array( '__experimentalBorder', $feature )$default_value );
}

// Register the block support. WP_Block_Supports::get_instance()->register(
    'border',
    array(
        'register_attribute' => 'wp_register_border_support',
        'apply'              => 'wp_apply_border_support',
    )
);

    public function __construct( $block$available_context = array()$registry = null ) {
        $this->parsed_block = $block;
        $this->name         = $block['blockName'];

        if ( is_null( $registry ) ) {
            $registry = WP_Block_Type_Registry::get_instance();
        }

        $this->registry = $registry;

        $this->block_type = $registry->get_registered( $this->name );

        $this->available_context = $available_context;

        if ( ! empty( $this->block_type->uses_context ) ) {
            foreach ( $this->block_type->uses_context as $context_name ) {
                if ( array_key_exists( $context_name$this->available_context ) ) {
                    

    protected static function get_blocks_metadata() {
        $registry = WP_Block_Type_Registry::get_instance();
        $blocks   = $registry->get_all_registered();

        // Is there metadata for all currently registered blocks?         $blocks = array_diff_key( $blocksstatic::$blocks_metadata );
        if ( empty( $blocks ) ) {
            return static::$blocks_metadata;
        }

        foreach ( $blocks as $block_name => $block_type ) {
            $root_selector = wp_get_block_css_selector( $block_type );

            
<?php body_class(); ?>> <div id="page" class="site"> <div id="content" class="site-content"> <?php                 $registry = WP_Block_Type_Registry::get_instance();
                $block    = $registry->get_registered( 'core/legacy-widget' );
                echo $block->render( $_GET['legacy-widget-preview'] );
                ?> </div><!-- #content --> </div><!-- #page --> <?php wp_footer(); ?> </body> </html> <?php
    exit;
}
wp_add_dashboard_widget( 'dashboard_php_nag', __( 'PHP Update Recommended' ), 'wp_dashboard_php_nag' );
            }
        }
    }

    // Site Health.     if ( current_user_can( 'view_site_health_checks' ) && ! is_network_admin() ) {
        if ( ! class_exists( 'WP_Site_Health' ) ) {
            require_once ABSPATH . 'wp-admin/includes/class-wp-site-health.php';
        }

        WP_Site_Health::get_instance();

        wp_enqueue_style( 'site-health' );
        wp_enqueue_script( 'site-health' );

        wp_add_dashboard_widget( 'dashboard_site_health', __( 'Site Health Status' ), 'wp_dashboard_site_health' );
    }

    // Right Now.     if ( is_blog_admin() && current_user_can( 'edit_posts' ) ) {
        wp_add_dashboard_widget( 'dashboard_right_now', __( 'At a Glance' ), 'wp_dashboard_right_now' );
    }

    
$has_custom_classnames = array_key_exists( 'className', $block_attributes );

        if ( $has_custom_classnames ) {
            $attributes['class'] = $block_attributes['className'];
        }
    }

    return $attributes;
}

// Register the block support. WP_Block_Supports::get_instance()->register(
    'custom-classname',
    array(
        'register_attribute' => 'wp_register_custom_classname_support',
        'apply'              => 'wp_apply_custom_classname_support',
    )
);
$attributes = array();
    $styles     = wp_style_engine_get_styles( $shadow_block_styles );

    if ( ! empty( $styles['css'] ) ) {
        $attributes['style'] = $styles['css'];
    }

    return $attributes;
}

// Register the block support. WP_Block_Supports::get_instance()->register(
    'shadow',
    array(
        'register_attribute' => 'wp_register_shadow_support',
        'apply'              => 'wp_apply_shadow_support',
    )
);

                'available_updates_disk_space' => array(
                    'label' => __( 'Available disk space' ),
                    'test'  => 'available_updates_disk_space',
                ),
            ),
            'async'  => array(
                'dotorg_communication' => array(
                    'label'             => __( 'Communication with WordPress.org' ),
                    'test'              => rest_url( 'wp-site-health/v1/tests/dotorg-communication' ),
                    'has_rest'          => true,
                    'async_direct_test' => array( WP_Site_Health::get_instance(), 'get_test_dotorg_communication' ),
                ),
                'background_updates'   => array(
                    'label'             => __( 'Background updates' ),
                    'test'              => rest_url( 'wp-site-health/v1/tests/background-updates' ),
                    'has_rest'          => true,
                    'async_direct_test' => array( WP_Site_Health::get_instance(), 'get_test_background_updates' ),
                ),
                'loopback_requests'    => array(
                    'label'             => __( 'Loopback request' ),
                    'test'              => rest_url( 'wp-site-health/v1/tests/loopback-requests' ),
                    'has_rest'          => true,
                    
/** * Renders position styles to the block wrapper. * * @since 6.2.0 * @access private * * @param string $block_content Rendered block content. * @param array $block Block object. * @return string Filtered block content. */
function wp_render_position_support( $block_content$block ) {
    $block_type           = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] );
    $has_position_support = block_has_support( $block_type, array( 'position' ), false );

    if (
        ! $has_position_support ||
        empty( $block['attrs']['style']['position'] )
    ) {
        return $block_content;
    }

    $global_settings          = wp_get_global_settings();
    $theme_has_sticky_support = _wp_array_get( $global_settings, array( 'position', 'sticky' ), false );
    
return false;
        } elseif ( $path === $current_site->path ) {
            $current_blog = get_site_by_path( $domain$path );
        } else {
            // Search the network path + one more path segment (on top of the network path).             $current_blog = get_site_by_path( $domain$pathsubstr_count( $current_site->path, '/' ) );
        }
    } else {
        // Find the site by the domain and at most the first path segment.         $current_blog = get_site_by_path( $domain$path, 1 );
        if ( $current_blog ) {
            $current_site = WP_Network::get_instance( $current_blog->site_id ? $current_blog->site_id : 1 );
        } else {
            // If you don't have a site with the same domain/path as a network, you're pretty screwed, but:             $current_site = WP_Network::get_by_path( $domain$path, 1 );
        }
    }

    // The network declared by the site trumps any constants.     if ( $current_blog && $current_blog->site_id != $current_site->id ) {
        $current_site = WP_Network::get_instance( $current_blog->site_id );
    }

    

function render_block_core_pattern( $attributes ) {
    if ( empty( $attributes['slug'] ) ) {
        return '';
    }

    $slug     = $attributes['slug'];
    $registry = WP_Block_Patterns_Registry::get_instance();

    if ( ! $registry->is_registered( $slug ) ) {
        return '';
    }

    $pattern = $registry->get_registered( $slug );
    return do_blocks( $pattern['content'] );
}

add_action( 'init', 'register_block_core_pattern' );
if ( ! wp_is_https_supported() ) {
        wp_die( __( 'It looks like HTTPS is not supported for your website at this point.' ) );
    }

    $result = wp_update_urls_to_https();

    wp_redirect( add_query_arg( 'https_updated', (int) $resultwp_get_referer() ) );
    exit;
}

$health_check_site_status = WP_Site_Health::get_instance();

get_current_screen()->add_help_tab(
    array(
        'id'      => 'overview',
        'title'   => __( 'Overview' ),
        'content' =>
                '<p>' . __( 'This screen allows you to obtain a health diagnosis of your site, and displays an overall rating of the status of your installation.' ) . '</p>' .
                '<p>' . __( 'In the Status tab, you can see critical information about your WordPress configuration, along with anything else that requires your attention.' ) . '</p>' .
                '<p>' . __( 'In the Info tab, you will find all the details about the configuration of your WordPress site, server, and database. There is also an export feature that allows you to copy all of the information about your site to the clipboard, to help solve problems on your site when obtaining support.' ) . '</p>',
    )
);


function get_site( $site = null ) {
    if ( empty( $site ) ) {
        $site = get_current_blog_id();
    }

    if ( $site instanceof WP_Site ) {
        $_site = $site;
    } elseif ( is_object( $site ) ) {
        $_site = new WP_Site( $site );
    } else {
        $_site = WP_Site::get_instance( $site );
    }

    if ( ! $_site ) {
        return null;
    }

    /** * Fires after a site is retrieved. * * @since 4.6.0 * * @param WP_Site $_site Site data. */
array(
                    'methods'             => array( WP_REST_Server::READABLE, WP_REST_Server::CREATABLE ),
                    'callback'            => array( $this, 'get_item' ),
                    'permission_callback' => array( $this, 'get_item_permissions_check' ),
                    'args'                => array(
                        'context'    => $this->get_context_param( array( 'default' => 'view' ) ),
                        'attributes' => array(
                            'description'       => __( 'Attributes for the block.' ),
                            'type'              => 'object',
                            'default'           => array(),
                            'validate_callback' => static function D $value$request ) {
                                $block = WP_Block_Type_Registry::get_instance()->get_registered( $request['name'] );

                                if ( ! $block ) {
                                    // This will get rejected in ::get_item().                                     return true;
                                }

                                $schema = array(
                                    'type'                 => 'object',
                                    'properties'           => $block->get_attributes(),
                                    'additionalProperties' => false,
                                );

                                
Home | Imprint | This part of the site doesn't use cookies.