acf_form_comment::edit_comment
This function is run on the admin comment.php page and will render the ACF fields within custom metaboxes to look native
Метод класса: acf_form_comment{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$acf_form_comment = new acf_form_comment(); $acf_form_comment->edit_comment( $comment );
- $comment(обязательный)
- .
Список изменений
| С версии 5.0.0 | Введена. |
Код acf_form_comment::edit_comment() acf form comment::edit comment ACF 6.4.2
<?php
function edit_comment( $comment ) {
// vars
$post_id = "comment_{$comment->comment_ID}";
// get field groups
$field_groups = acf_get_field_groups(
array(
'comment' => get_post_type( $comment->comment_post_ID ),
)
);
// render
if ( ! empty( $field_groups ) ) {
// render post data
acf_form_data(
array(
'screen' => 'comment',
'post_id' => $post_id,
)
);
foreach ( $field_groups as $field_group ) {
// load fields
$fields = acf_get_fields( $field_group );
// vars
$o = array(
'id' => 'acf-' . $field_group['ID'],
'key' => $field_group['key'],
// 'style' => $field_group['style'],
'label' => $field_group['label_placement'],
'edit_url' => '',
'edit_title' => __( 'Edit field group', 'acf' ),
// 'visibility' => $visibility
);
// edit_url
if ( $field_group['ID'] && acf_current_user_can_admin() ) {
$o['edit_url'] = admin_url( 'post.php?post=' . $field_group['ID'] . '&action=edit' );
}
?>
<div id="acf-<?php echo esc_attr( $field_group['ID'] ); ?>" class="stuffbox">
<h3 class="hndle"><?php echo esc_html( $field_group['title'] ); ?></h3>
<div class="inside">
<?php acf_render_fields( $fields, $post_id, 'div', $field_group['instruction_placement'] ); ?>
<script type="text/javascript">
if( typeof acf !== 'undefined' ) {
acf.newPostbox(<?php echo json_encode( $o ); ?>);
}
</script>
</div>
</div>
<?php
}
}
}