alleyinteractive / alleyinteractive/wordpress-fieldmanager
Allow overriding 'wp_insert_post_empty_content' based on whether a field has data
- 主要言語
- PHP
- スター
- 563
- フォーク
- 99
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
When `wp_insert_post()` considers a post "empty," it exits before firing the `save_post` hook on which `Fieldmanager_Context_Post` saves field data: https://github.com/WordPress/wordpress-develop/blob/master/src/wp-includes/post.php#L3047-L3069.
Thus, a user who enters data into only a Fieldmanager field before saving a post for the first time might lose their work after trying to save.
To avoid this problem, we could allow Fieldmanager to filter to `wp_insert_post_empty_content` so that it returns `false` and continues saving the post when fields that opt-in to the feature have data, along the lines of:
```
add_filter( 'wp_insert_post_empty_content', function ( $maybe_empty ) {
return $maybe_empty && empty( $_POST['my_fm_field'] );
}, 100 );
```
Tentatively, `Fieldmanager_Context_Post` might be the best location for such a feature.
コントリビューションガイド
評価
この issue はまだ評価されていません。