/home/techb158/on-time-movers.com/wp-content/plugins/wpforms/src/Pro/Admin/Entries
Edit: /home/techb158/on-time-movers.com/wp-content/plugins/wpforms/src/Pro/Admin/Entries/PrintPreview.php (16005B)
is_print_page() ) {
return;
}
if ( ! $this->is_valid_request() ) {
wp_safe_redirect( admin_url( 'admin.php?page=wpforms-entries' ) );
exit;
}
$this->hooks();
}
/**
* Hooks.
*
* @since 1.5.1
*/
public function hooks() {
add_action( 'admin_init', [ $this, 'print_html' ], 1 );
add_filter( 'wpforms_entry_single_data', [ $this, 'add_hidden_data' ], 10, 2 );
}
/**
* Check if current page request meets requirements for entry print page.
*
* @since 1.5.1
*
* @return bool
*/
public function is_print_page() {
// Only proceed for the form builder.
return wpforms_is_admin_page( 'entries', 'print' );
}
/**
* Is the request valid?
*
* @since 1.7.1
*
* @return bool
*/
private function is_valid_request() {
// phpcs:disable WordPress.Security.NonceVerification.Recommended
// Check that entry ID was passed.
if ( empty( $_GET['entry_id'] ) ) {
return false;
}
$entry_id = absint( $_GET['entry_id'] );
if ( empty( $entry_id ) || (string) $entry_id !== $_GET['entry_id'] ) {
return false;
}
// phpcs:enable WordPress.Security.NonceVerification.Recommended
// Check for user with correct capabilities.
if ( ! wpforms_current_user_can( 'view_entry_single', $entry_id ) ) {
return false;
}
// Fetch the entry.
$this->entry = wpforms()->get( 'entry' )->get( $entry_id );
// Check if valid entry was found.
if ( empty( $this->entry ) ) {
return false;
}
// Fetch form details for the entry.
$this->form_data = wpforms()->get( 'form' )->get(
$this->entry->form_id,
[
'content_only' => true,
]
);
// Check if valid form was found.
if ( empty( $this->form_data ) ) {
return false;
}
// Everything passed, fetch entry notes.
$this->entry->entry_notes = wpforms()->get( 'entry_meta' )->get_meta(
[
'entry_id' => $this->entry->entry_id,
'type' => 'note',
]
);
return true;
}
/**
* Output HTML markup for the print preview page.
*
* @since 1.5.1
*/
public function print_html() {
$min = wpforms_get_min_suffix();
?>
WPForms Print Preview - form_data['settings']['form_title'] ) ) ); ?>
entry, $this->form_data ); ?>
entry, $this->form_data ); ?>
form_data['settings']['form_title'] ) ); ?> - entry->entry_id ) ); ?>
entry->entry_notes ) ) : ?>
entry, $this->form_data ],
'1.5.5 of the WPForms plugin',
'wpforms_pro_admin_entries_printpreview_print_html_header_after'
);
do_action( 'wpforms_pro_admin_entries_printpreview_print_html_header_after', $this->entry, $this->form_data );
$fields = apply_filters( 'wpforms_entry_single_data', wpforms_decode( $this->entry->fields ), $this->entry, $this->form_data );
if ( empty( $fields ) ) {
// Whoops, no fields! This shouldn't happen under normal use cases.
echo '
' . esc_html__( 'This entry does not have any fields', 'wpforms' ) . '
';
} else {
echo '
';
// Display the fields and their values.
foreach ( $fields as $field ) {
if ( ! isset( $field['id'] ) ) {
continue;
}
$field_value = isset( $field['value'] ) ? apply_filters( 'wpforms_html_field_value', wp_strip_all_tags( $field['value'] ), $field, $this->form_data, 'entry-single' ) : '';
$field_class = sanitize_html_class( 'wpforms-field-' . $field['type'] );
$field_class .= wpforms_is_empty_string( $field_value ) ? ' empty' : '';
$field_label = isset( $field['name'] ) ? $field['name'] : '';
if ( $field['type'] === 'divider' ) {
$field_label = isset( $field['label'] ) && ! empty( $field['label'] ) ? $field['label'] : esc_html__( 'Section Divider', 'wpforms' );
$field_class = sanitize_html_class( 'wpforms-field-' . $field['type'] ) . ' wpforms-hidden';
}
if ( $field['type'] === 'html' ) {
$field_value = isset( $field['code'] ) ? $field['code'] : '';
$field_class = sanitize_html_class( 'wpforms-field-' . $field['type'] ) . ' wpforms-hidden';
}
if ( $field['type'] === 'content' ) {
$field_value = isset( $field['content'] ) ? $field['content'] : '';
$field_class = sanitize_html_class( 'wpforms-field-' . $field['type'] ) . ' wpforms-hidden';
$field_label = esc_html__( 'Content Field', 'wpforms' );
}
?>
';
}
do_action_deprecated(
'wpforms_pro_admin_entries_printpreview_print_hrml_fields_after',
[ $this->entry, $this->form_data ],
'1.5.5 of the WPForms plugin',
'wpforms_pro_admin_entries_printpreview_print_html_fields_after'
);
do_action( 'wpforms_pro_admin_entries_printpreview_print_html_fields_after', $this->entry, $this->form_data );
if ( ! empty( $this->entry->entry_notes ) ) {
echo '
' . esc_html__( 'Notes', 'wpforms' ) . '
';
echo '
';
foreach ( $this->entry->entry_notes as $note ) {
$user = get_userdata( $note->user_id );
$user_name = ! empty( $user->display_name ) ? $user->display_name : $user->user_login;
$date = wpforms_datetime_format( $note->date, '', true );
echo '
';
echo '
';
printf( /* translators: %1$s - user name; %2$s - date */
esc_html__( 'Added by %1$s on %2$s', 'wpforms' ),
esc_html( $user_name ),
esc_html( $date )
);
echo '
';
echo '
' . wp_kses_post( $note->data ) . '
';
echo '
';
}
echo '
';
}
do_action_deprecated(
'wpforms_pro_admin_entries_printpreview_print_hrml_notes_after',
[ $this->entry, $this->form_data ],
'1.5.5 of the WPForms plugin',
'wpforms_pro_admin_entries_printpreview_print_html_notes_after'
);
do_action( 'wpforms_pro_admin_entries_printpreview_print_html_notes_after', $this->entry, $this->form_data );
?>
get( 'form' )->get( $entry->form_id, [ 'content_only' => true ] );
$settings = ! empty( $form_data['fields'] ) ? $form_data['fields'] : [];
// Order entry fields by the form fields.
foreach ( $settings as $key => $setting ) {
if ( empty( $setting['type'] ) ) {
unset( $settings[ $key ] );
continue;
}
$field_type = $setting['type'];
// Divider, HTML and content fields must always be included because it's allowed to show and hide these fields.
if ( in_array( $field_type, [ 'divider', 'html', 'content' ], true ) ) {
continue;
}
/** This filter is documented in /src/Pro/Admin/Entries/Edit.php */
if ( ! (bool) apply_filters( "wpforms_pro_admin_entries_edit_is_field_displayable_{$field_type}", true, $setting, $form_data ) ) {
unset( $settings[ $key ] );
continue;
}
if ( ! isset( $fields[ $key ] ) ) {
unset( $settings[ $key ] );
continue;
}
$settings[ $key ] = $fields[ $key ];
}
return $settings;
}
}