When I try to get to my local site, after uploading new theme, I get the message: Parse error: syntax error, unexpected '}' in C:\wamp\www\test03\wp-content\themes\hazera\inc\all-to-pdf.php on line 52
This is the code:
<? function to_pdf_form(){ ?>
<form method="post" action="">
<input style="margin-top:20px;" class="button" type="submit" name="submit-all-to-pdf" value="Upload all products to PDF!">
</form>
<p>Files uploaded to /wp-content/uploads/products-pdf.</p>
<?php
if ( isset($_POST['submit-all-to-pdf']) ){
ini_set('max_execution_time', 300);
global $post;
$args = array( 'post_type' => 'product', 'posts_per_page' => -1 );
$the_product = get_posts( $args );
foreach( $the_product as $post ) {
$product_id = get_the_ID();
$product_name = get_the_title ( $product_id );
if(class_exists('Pdfcrowd')){
if ( !$product_id ) die();
$pdf_version_url = add_query_arg( array('pdf_version' => 1), get_permalink($product_id));
$wp_upload_dir = wp_upload_dir();
if (!file_exists($wp_upload_dir['basedir'] . '/products-pdf')) {
mkdir($wp_upload_dir['basedir'] . '/products-pdf', 0777, true);
}
$pdf_file_name = 'product-' . $product_id . '.pdf';
$pdf_file_path = $wp_upload_dir['basedir'] . '/products-pdf/' . $pdf_file_name;
try
{
// create an API client instance
$client = new Pdfcrowd("username", "password");
if ( file_exists( $pdf_file_path ) ) continue;
$out_file = fopen($pdf_file_path, "wb");
$client->setHtmlZoom("120");
$client->convertURI($pdf_version_url, $out_file);
fclose($out_file);
// send the generated PDF
echo '<strong>' . $product_name .' uploaded successfully. </strong><br/>';
}
catch(PdfcrowdException $why)
{
echo "Pdfcrowd Error: " . $why . "<br/>";
}
}
}
}
}
?>
I don't see what's wrong here.
Thank you