You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a plugin adds a meta box to the editor and the meta box has some default values the default values are not saved when creating a new post. The values are only saved if the default values are changed. This is not the normal behaviour with the classic editor. The default values are always saved.
Using master branch.
Steps to Reproduce (for bugs)
Use the following plugin code
Click on new page
Add a title
Publish the post
<?php
/*
Plugin Name: Example for meta box with gutenberg
Author: OnTheGoSystems
Version: 1.0
*/
global $pagenow;
if ( in_array( $pagenow, array( 'post.php', 'post-new.php', 'edit.php' ), true ) ) {
add_action( 'admin_head', 'gutenberg_new_post_add_meta_box' );
}
function gutenberg_new_post_add_meta_box() {
add_meta_box( 'gutenberg_div', 'Options', 'gutenberg_meta_box', null, 'side', 'high' );
}
function gutenberg_meta_box() {
?>
<select name="gutenberg_select_test">
<option value="1">Value 1</option>
<option value="2">Value 2</option>
<option value="3">Value 3</option>
</select>
<?php
}
add_action( 'save_post', 'gutenberg_save_post_example' );
function gutenberg_save_post_example( $post_id ) {
if ( isset( $_POST['gutenberg_select_test'] ) ) {
update_post_meta( $post_id, 'gutenberg_select_test', $_POST['gutenberg_select_test'] );
}
}
Expected Behavior
The 'save_post' action should be triggered and the update_post_meta function is called. This is what happens with the classic editor
Current Behavior
The 'save_post' action is not triggered and the post meta is not updated.
Possible Solution
I think all meta boxes should be considered as 'dirty' for new posts and all the meta box data should be submitted when saving the initial post.
The text was updated successfully, but these errors were encountered:
Issue Overview
When a plugin adds a meta box to the editor and the meta box has some default values the default values are not saved when creating a new post. The values are only saved if the default values are changed. This is not the normal behaviour with the classic editor. The default values are always saved.
Using master branch.
Steps to Reproduce (for bugs)
Expected Behavior
The 'save_post' action should be triggered and the
update_post_meta
function is called. This is what happens with the classic editorCurrent Behavior
The 'save_post' action is not triggered and the post meta is not updated.
Possible Solution
I think all meta boxes should be considered as 'dirty' for new posts and all the meta box data should be submitted when saving the initial post.
The text was updated successfully, but these errors were encountered: