alleyinteractive / alleyinteractive/wordpress-fieldmanager

Allow overriding 'wp_insert_post_empty_content' based on whether a field has data

オープン
#640 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
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 はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。