$post_title, 'post_type' => $post_type, 'post_content' => $this->get_content_for_form( $form_id ), ); $new_id = wp_insert_post( $post_data ); wp_send_json_success( array( 'ID' => $new_id ) ); } /** * Get the properly-formatted comment string for the block we're inserting. * * @since 2.6 * * @param $form_id * * @return string */ private function get_content_for_form( $form_id ) { $attrs = array( 'formId' => $form_id ); return get_comment_delimited_block_content( 'gravityforms/form', $attrs, '' ); } }