acf_form_comment::save_comment
Saves ACF field values to a comment.
Метод класса: acf_form_comment{}
Хуков нет.
Возвращает
integer|void.
Использование
$acf_form_comment = new acf_form_comment(); $acf_form_comment->save_comment( $comment_id );
- $comment_id(int) (обязательный)
- The ID of the comment being saved to.
Список изменений
| С версии 5.0.0 | Введена. |
Код acf_form_comment::save_comment() acf form comment::save comment ACF 6.8.11
public function save_comment( $comment_id ) {
// bail early if not valid nonce
if ( ! acf_verify_nonce( 'comment' ) ) {
return $comment_id;
}
if ( isset( $_POST['acf'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Verified above.
if ( ! is_array( $_POST['acf'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Verified above.
return $comment_id;
}
// Restrict $_POST['acf'] to fields rendered for this comment, or belonging to field groups that apply to it.
$this->restrict_save_input( $comment_id );
if ( empty( $_POST['acf'] ) ) {
return $comment_id;
}
$_POST['acf'] = wp_kses_post_deep( $_POST['acf'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Sanitized with wp_kses_post_deep().
}
// validate and save
if ( acf_validate_save_post( true ) ) {
acf_save_post( "comment_{$comment_id}" );
}
}