{} ', 'wpforms-lite' ), ! empty( $this->form_data['settings']['form_title'] ) ? sanitize_text_field( $this->form_data['settings']['form_title'] ) : esc_html__( 'Form Template', 'wpforms-lite' ) ); } return sprintf( /* translators: %s - form name. */ esc_html__( '%s Preview', 'wpforms-lite' ), ! empty( $this->form_data['settings']['form_title'] ) ? sanitize_text_field( $this->form_data['settings']['form_title'] ) : esc_html__( 'Form', 'wpforms-lite' ) ); } /** * Customize form preview page content. * * @since 1.5.1 * * @return string */ public function the_content() { if ( ! isset( $this->form_data['id'] ) ) { return ''; } if ( ! wpforms_current_user_can( 'view_form_single', $this->form_data['id'] ) ) { return ''; } $admin_url = admin_url( 'admin.php' ); $links = []; if ( wpforms_current_user_can( 'edit_form_single', $this->form_data['id'] ) ) { $links[] = [ 'url' => esc_url( add_query_arg( [ 'page' => 'wpforms-builder', 'view' => 'fields', 'form_id' => absint( $this->form_data['id'] ), ], $admin_url ) ), 'text' => $this->is_form_template ? esc_html__( 'Edit Form Template', 'wpforms-lite' ) : esc_html__( 'Edit Form', 'wpforms-lite' ), ]; } if ( wpforms()->is_pro() && wpforms_current_user_can( 'view_entries_form_single', $this->form_data['id'] ) ) { $links[] = [ 'url' => esc_url( add_query_arg( [ 'page' => 'wpforms-entries', 'view' => 'list', 'form_id' => absint( $this->form_data['id'] ), ], $admin_url ) ), 'text' => esc_html__( 'View Entries', 'wpforms-lite' ), ]; } if ( ! $this->is_form_template && wpforms_current_user_can( wpforms_get_capability_manage_options(), $this->form_data['id'] ) && wpforms()->obj( 'payment' )->get_by( 'form_id', $this->form_data['id'] ) ) { $links[] = [ 'url' => esc_url( add_query_arg( [ 'page' => 'wpforms-payments', 'form_id' => absint( $this->form_data['id'] ), ], $admin_url ) ), 'text' => esc_html__( 'View Payments', 'wpforms-lite' ), ]; } if ( ! empty( $_GET['new_window'] ) ) { // phpcs:ignore $links[] = [ 'url' => 'javascript:window.close();', 'text' => esc_html__( 'Close this window', 'wpforms-lite' ), ]; } $content = ''; $content .= $this->add_preview_notice(); $content .= '
';
$content .= $this->is_form_template ?
esc_html__( 'This is a preview of the latest saved revision of your form template. If this preview does not match your template, save your changes and then refresh this page. This template preview is not publicly accessible.', 'wpforms-lite' ) :
esc_html__( 'This is a preview of the latest saved revision of your form. If this preview does not match your form, save your changes and then refresh this page. This form preview is not publicly accessible.', 'wpforms-lite' );
if ( ! empty( $links ) ) {
$content .= '
';
$content .= '';
foreach ( $links as $key => $link ) {
$content .= '' . $link['text'] . '';
$l = array_keys( $links );
if ( end( $l ) !== $key ) {
$content .= ' | ';
}
}
$content .= '';
}
$content .= '
'; $content .= sprintf( wp_kses( /* translators: %s - WPForms doc link. */ __( 'For form testing tips, check out our complete guide!', 'wpforms-lite' ), [ 'a' => [ 'href' => [], 'target' => [], 'rel' => [], ], ] ), esc_url( wpforms_utm_link( 'https://wpforms.com/docs/how-to-properly-test-your-wordpress-forms-before-launching-checklist/', $this->is_form_template ? 'Form Template Preview' : 'Form Preview', 'Form Testing Tips Documentation' ) ) ); $content .= '
'; $content .= do_shortcode( '[wpforms id="' . absint( $this->form_data['id'] ) . '"]' ); return $content; } /** * Add preview notice. * * @since 1.8.8 * * @return string HTML content. */ private function add_preview_notice(): string { if ( ! $this->is_form_template ) { return ''; } $content = '%s
', esc_html( $message ) ); } $content .= '