-2
當我嘗試去我的本地站點,上傳新主題後,我收到消息: 解析錯誤:語法錯誤,意外的'}'在C:\ wamp \ www \ test03 \可溼性粉劑內容\主題\海澤拉\ INC \上線52意外的「意外」}「」
這一切都對pdf.php是代碼:
<? 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/>";
}
}
}
}
}
?>
我看不出有什麼錯在這裏。
謝謝