'; echo sprintf( '

%s "%s"

', __( 'Previewing', 'advanced-forms' ), $form['title'] ); echo sprintf( '%s', get_edit_post_link( $form['post_id'] ), __( 'Back to form', 'advanced-forms' ) ); echo '
'; if ( af_has_submission() && ! af_submission_failed() ) { echo '
'; echo sprintf( '

%s. %s

', __( 'Form successfully submitted', 'advanced-forms' ), '', __( 'Test again', 'advanced-forms' ) ); echo '
'; } echo '
'; echo '
'; echo '
'; advanced_form( $form['post_id'] ); echo '
'; echo '
'; echo '
'; echo ''; } /** * Wordpress won't display a page title, probably of the submenu hack in register_admin_page. * This function is hooked to the admin_title filter and fixes the issue. * * @since 1.4.0 */ function fix_admin_title( $admin_title, $title ) { if ( get_current_screen()->id != 'admin_page_af_preview_form' ) { return $admin_title; } return __( 'Preview form', 'advanced-forms' ) . $admin_title; } /** * We need to enqueue ACF early for it to be included in the head. * ACF needs to be enqueued early in the admin panel. * * @since 1.5.3 */ function enqueue_acf( $page ) { if ( 'admin_page_af_preview_form' != $page ) { return; } acf_enqueue_scripts(); } /** * Add preview button to form publish box * * @since 1.4.0 */ function add_preview_button( $form_id ) { $test_url = add_query_arg( 'form_id', $form_id, menu_page_url( 'af_preview_form', false ) ); echo sprintf( '%s', $test_url, __( 'Preview', 'advanced-forms' ) ); } /** * Add WP button classes to form submit buttons in admin * * @since 1.4.0 */ function add_classes_to_button( $attributes ) { if ( ! is_admin() ) { return $attributes; } $attributes['class'] .= ' button button-primary button-large'; return $attributes; } /** * Add WP button classes to multi-page form buttons * * @since 1.5.0 */ function add_classes_to_page_buttons( $attributes ) { if ( ! is_admin() ) { return $attributes; } $attributes['class'] .= ' button button-large'; return $attributes; } } return new AF_Admin_Forms_Preview();