Archived topic
Generateblocks can´t generate css files
7 replies · Started by Longinos on December 12, 2021
Hi
I open this ticket as per Tom request.
Read the wordpress.org support thread
https://wordpress.org/support/topic/cant-generate-css-files/#post-15154591
I put here 3 images:
1.- The GPP elements created with Generateblocks for post navigation
2.- The inlined css
3.- The generateblocks config set to file.
https://imgur.com/a/SQHsLfN
The site is in the private area, you can see this element and the inlined css in all post.
No /uploads/generateblocks/ files are created.
Hi there,
So the main issue here is that the file isn't being created? The CSS itself is building correctly, it's just inline vs external.
If so, what happens if you add a test GenerateBlocks Button to that post? Does it build an external file?
Yes, the issue is file isn´t created.
I added a generateblocks button to a post and the file still not created.
I have put:
echo "<pre>".$page_id".</pre>"; in the funct can_write() after the $page_id is set
and echo "<pre>".$id".</pre>" in page_id() before the return $id;
When a post is updated this echoes nothing in can_write() and the post id in page_id().
These both functions are in class-enqueue-css.php file.
In can_write() if no $page_id is set then fallback to inline.
Can you share the post where you've added the Button?
I ask because the file writing is bypassed completely if no blocks exist in the content.
In the url posted in private, you can see a blue button with link to #.
I will come to this tomorrow because here is late at nigth.
EDIT: So when generateblocks is in a element applied to the post no file is generated?
Ah I think I see the issue. We default to inline inside single posts to prevent people from having hundreds of CSS files built on their server. There are usually a lot more posts than pages on a website.
You can change this default like this:
add_filter( 'generateblocks_css_print_method', function( $method ) {
if ( is_single() ) {
$method = 'file';
}
return $method;
} );
Let me know if that helps or not :)
Hi Tom
So by default only in pages are file created, in pages where content have a generateblocks block, don´t aplies to geneteblocks block in elements applied to pages, is this rigth?
Block Elements should be treated like regular content. I'll have to test whether they will force a file generation if no other blocks exist on the page - I believe they will but can't say 100%.