Skip to content

Commit

Permalink
Fixes bug when opening PDF with pretty links. Disables UBL opening on…
Browse files Browse the repository at this point in the history
… setting.
  • Loading branch information
alexmigf committed Oct 17, 2023
1 parent 25e66d6 commit e252c3f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions includes/class-wcpdf-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public function ajax_preview() {
}

// validate option values
$form_settings = WPO_WCPDF()->settings->callbacks->validate( $form_settings );
$form_settings = $this->callbacks->validate( $form_settings );

// filter the options
add_filter( "option_{$option_key}", function( $value, $option ) use ( $form_settings ) {
Expand All @@ -306,7 +306,7 @@ public function ajax_preview() {
if ( $document ) {
if ( ! $document->exists() ) {
$document->set_date( current_time( 'timestamp', true ) );
$number_store_method = WPO_WCPDF()->settings->get_sequential_number_store_method();
$number_store_method = $this->get_sequential_number_store_method();
$number_store_name = apply_filters( 'wpo_wcpdf_document_sequential_number_store', "{$document->slug}_number", $document );
$number_store = new Sequential_Number_Store( $number_store_name, $number_store_method );
$document->set_number( $number_store->get_next() );
Expand Down Expand Up @@ -526,20 +526,23 @@ public function get_document_settings( $document_type, $output_format = 'pdf' )
}

public function get_output_format( $document = null ) {
$output_format = 'pdf'; // default

if ( isset( $this->debug_settings['html_output'] ) || ( isset( $_REQUEST['output'] ) && 'html' === $_REQUEST['output'] ) ) {
$output_format = 'html';
} elseif ( isset( $_REQUEST['output'] ) && ! empty( $_REQUEST['output'] ) && ! empty( $document ) && in_array( $_REQUEST['output'], $document->output_formats ) ) {
$output_format = sanitize_text_field( $_REQUEST['output'] );
} else {
$output_format = 'pdf';
$document_settings = $this->get_document_settings( $document->get_type(), esc_attr( $_REQUEST['output'] ) );
if ( isset( $document_settings['enabled'] ) ) {
$output_format = esc_attr( $_REQUEST['output'] );
}
}

return apply_filters( 'wpo_wcpdf_output_format', $output_format, $document );
}

public function get_output_mode() {
if ( isset( WPO_WCPDF()->settings->general_settings['download_display'] ) ) {
switch ( WPO_WCPDF()->settings->general_settings['download_display'] ) {
if ( isset( $this->general_settings['download_display'] ) ) {
switch ( $this->general_settings['download_display'] ) {
case 'display':
$output_mode = 'inline';
break;
Expand Down
2 changes: 1 addition & 1 deletion includes/documents/abstract-wcpdf-order-document.php
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ public function output_pdf( $output_mode = 'download' ) {
$pdf = $this->get_pdf();
wcpdf_pdf_headers( $this->get_filename(), $output_mode, $pdf );
echo $pdf;
wp_die();
exit();
}

public function output_html() {
Expand Down

0 comments on commit e252c3f

Please sign in to comment.