<?php
/**
* Data provider for block patterns.
*
* @package Test
*/
namespace RomArt\DataProviders;
/**
* BlockPatternsDataProvider class.
*/
class BlockPatternsDataProvider extends DataProviderBase {
/**
* Gets the page header block pattern.
*
* @return string
*/
public static function get_page_header_block_pattern(): string {
$header_pattern_posts = get_posts( [
'name' => 'header-pages',
'post_type' => 'wp_template_part',
'numberposts'=> 1,
] );
if ( empty( $header_pattern_posts ) ) {
return '';
}
return do_blocks( get_post_field( 'post_content', $header_pattern_posts[0]->ID ) );
}
/**
* Gets the footer block pattern.
*
* @return string
*/
public static function get_footer_block_pattern(): string {
$footer_pattern_post = get_posts( [
'name' => 'footer-pages',
'post_type' => 'wp_template_part',
'numberposts'=> 1,
] );
if ( empty( $footer_pattern_post ) ) {
return '';
}
return do_blocks( get_post_field( 'post_content', $footer_pattern_post[0]->ID ) );
}
}
This works fine and it returns template parts, but some styles are missing.
When I use these template parts in the block editor, for example to create a page template, all styles are there. But when I load them programatically like this, some are missing.
I noticed some differences in CSS classes, such as when the foooter is loaded in the page template (block editor), it has class wp-container-core-group-is-layout-15
and it looks good, but when I load it programatically, it has wp-container-core-group-is-layout-10
and looks different