validate_page() ) { return; } // load acf scripts acf_enqueue_scripts(); // actions add_action('admin_footer', array($this, 'admin_footer'), 10, 1); add_action('add_meta_boxes_comment', array($this, 'edit_comment'), 10, 1); } /* * edit_comment * * This function is run on the admin comment.php page and will render the ACF fields within custom metaboxes to look native * * @type function * @date 19/10/13 * @since 5.0.0 * * @param $comment (object) * @return n/a */ 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'); } ?>

$post->post_type )); // bail early if no field groups if( !$field_groups ) return $html; // enqueue scripts acf_enqueue_scripts(); // ob ob_start(); // render post data acf_form_data(array( 'screen' => 'comment', 'post_id' => $post_id )); echo '
'; foreach( $field_groups as $field_group ) { $fields = acf_get_fields( $field_group ); acf_render_fields( $fields, $post_id, 'p', $field_group['instruction_placement'] ); } echo '
'; // append $html .= ob_get_contents(); ob_end_clean(); // return return $html; } /* * save_comment * * This function will save the comment data * * @type function * @date 19/10/13 * @since 5.0.0 * * @param comment_id (int) * @return n/a */ function save_comment( $comment_id ) { // bail early if not valid nonce if( !acf_verify_nonce('comment') ) { return $comment_id; } // kses if( isset($_POST['acf']) ) { $_POST['acf'] = wp_kses_post_deep( $_POST['acf'] ); } // validate and save if( acf_validate_save_post(true) ) { acf_save_post( "comment_{$comment_id}" ); } } /* * admin_footer * * description * * @type function * @date 27/03/2015 * @since 5.1.5 * * @param $post_id (int) * @return $post_id (int) */ function admin_footer() { ?>