Disable block locking settings globally for posts and pages in WordPress 6.0

Disable block locking settings globally for posts and pages in WordPress 6.0 on child sites.

Snippet Type

Execute on Child Sites

Snippet

add_filter(
    'block_editor_settings_all',
    function( $settings, $context ) {
        
        // Disable for posts/pages.
        if ( $context->post && $context->post->post_type === 'page' ) {
            $settings['canLockBlocks'] = false;
        }
 
        return $settings;
    },
    10,
    2
);