'; 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() ) { 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; } /** * Add preview button to form publish box * * @since 1.4.0 * */ function add_test_button( $post ) { if ( is_null( $post ) || 'af_form' != $post->post_type ) { return; } $test_url = add_query_arg( 'form_id', $post->ID, menu_page_url( 'af_preview_form', false ) ); echo '
'; echo sprintf( '%s', $test_url, __( 'Preview form', 'advanced-forms' ) ); echo '
'; } /** * 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; } } return new AF_Admin_Preview();