HEX
Server: Apache
System: Linux clpupre 5.4.0-90-generic #101-Ubuntu SMP Fri Oct 15 20:00:55 UTC 2021 x86_64
User: undanet (1000)
PHP: 7.4.3
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /home/undanet/www/wp-content/themes/panoramic-child/mpdf/mpdf.php
<?php 

add_action( 'template_redirect', 'mpdf_export', 98 );
function mpdf_export() {
	if (isset($_GET['download']) 
		&& $_GET['download'] == 'pdf' 
		&& isset($_GET['option'])
	) {
		$pdfName = isset($_GET['pdfname']) ? $_GET['pdfname'] : __('doc','panoramic_child');
		$isem = isset($_GET['isem']) ? true : false;
		output_mpdf($_GET['option'], $pdfName, $isem);
		exit;
	}
}

function output_mpdf($option, $pdfName, $isem ) {	
	if ( is_readable( dirname(__FILE__) . '/vendor/autoload.php' ) ) {
		require dirname(__FILE__) . '/vendor/autoload.php';
	}
	
	$pdfName = $pdfName . '.pdf';
	
	$wp_content = get_option($option);
	$wp_content = apply_filters( 'the_content', $wp_content );

	$mpdf = new \Mpdf\Mpdf(array(
		'format' => 'A4',
		'orientation' => 'P',
		'margin_left' => 15,
		'margin_right' => 15,
		'margin_top' => 35,
		'margin_bottom' => 40,
		'margin_header' => 9,
		'margin_footer' => 7,
	));
	
//$mpdf->showImageErrors = true;
	$mpdf->curlAllowUnsafeSslRequests = true;
	$mpdf->charset_in = 'utf-8';
	$mpdf->title2annots = false;
	$mpdf->onlyCoreFonts = true;    

	ob_start();
		include( get_theme_file_path() . '/mpdf/templates/footer.php');
    $pdf_footer = ob_get_clean();

	ob_start();
		include( get_theme_file_path() . '/mpdf/templates/header.php');
    $pdf_header = ob_get_clean();

	$mpdf->SetHTMLHeader( $pdf_header );
	$mpdf->SetHTMLFooter( $pdf_footer );
	
	$stylesheet = file_get_contents(get_theme_file_path() . '/mpdf/mpdf.css');

	$mpdf->WriteHTML($stylesheet,\Mpdf\HTMLParserMode::HEADER_CSS);
	$mpdf->WriteHTML($wp_content,\Mpdf\HTMLParserMode::HTML_BODY);
	
	if ($isem) {
		$mpdf->Output( WP_CONTENT_DIR . '/uploads/portalempleo/attachment/' . $pdfName, \Mpdf\Output\Destination::FILE );
		sem_with_pdf($option, $pdfName);
	}
	$mpdf->Output( $pdfName, \Mpdf\Output\Destination::INLINE );
}

function sem_with_pdf($option, $pdfName) {
	$attachment = WP_CONTENT_DIR . '/uploads/portalempleo/attachment/' . $pdfName ;
	$mailopts = get_option($option . '_mail');	
	
	$mailto = $mailopts['mailto']; 
	$subject = $mailopts['subject'];  
	$message = $mailopts['message'];

	$headers = array();
	add_filter( 'wp_mail_content_type', function( $content_type ) {return 'text/html';});
	$headers[] = 'From: ' .  get_bloginfo( 'name' ) . ' <' . get_option('admin_email') . '>'."\r\n";
	wp_mail( $mailto, $subject, $message, $headers, $attachment);   
	remove_filter( 'wp_mail_content_type', 'set_html_content_type' );
}

?>