wpce_default_document v3.11
Filters the default document in the editor.
This allows to set a custom root node for a new post's document.
Parameters
?object $root_nodeThe document's root node.
nullif no default document is set.WP_Post $postThe post the document is created for.
WPCE $wpceThe WPCE instance.
Example
php
add_filter('wpce_default_document', function (?object $root_node, WP_Post $post, WPCE $wpce) {
// Set a custom root node for the 'my_custom_post_type' post type
if ($post->post_type === 'my_custom_post_type') {
$root_node = (object) [
'id' => 'root',
'label' => 'My Custom Post Type',
'properties' => [],
'children' => [
(object) [
'id' => 'text',
'name' => 'Text',
'children' => [],
'properties' => [
'content' => '<p>Lorem ipsum dolor sit amet...</p>',
],
'visible' => true,
],
],
'visible' => true,
];
}
return $root_node;
}, 10, 3);