Open ryanwelcher opened 3 months ago
Sorry,
I do not understand your remark about render.php I added it already here :
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "create-block/testimonalcard",
"version": "0.1.0",
"title": "Testimonal Card",
"category": "widgets",
"icon": "id",
"description": "my testimonal card as solution to a wpchallenge.com challenge",
"example": {},
"supports": {
"html": false
},
"attributes": {
"quote": {
"type": "string"
},
"name": {
"type": "string"
},
"job": {
"type": "string"
}
},
"textdomain": "testimonalcard",
"editorScript": "file:./index.js",
"editorStyle": "file:./index.css",
"style": "file:./style-index.css",
"render": "file:./render.php"
}
many thanks, Uploaded a new version and it worked better.
Finally it worked in a group :)
I hope you are happy., If you have more feedback , just add it here
Hello @RoelofWobben
As per your request, I've had a look at your plugin and have a couple of suggestions.
After adding an instance of this block to the block editor, I found that I was not able to select it again unless I did it using the List View. This was due to having added a
className
to the root elements inedit.js
.I fixed this by passing the className to
useBlockProps
:You can learn more about useBlockProps here.
The content of your
render.php
is incorrect.While you were outputting markup, there were no classes, ids, or others attributes being applied to the wrapper div. This is because
{ ...useBlockProps.save }
is only run in a React context when saving a static block. By adding the"render": "file:./render.php"
to your block.json, you are actually creating a dynamic block that uses the contents ofrender.php
to override what is output bysave.js
. You can read more about static vs dynamic rendering here.I updated render.php to use the following ( note the use of esc_html() to safely escape the values ):