I am attempting to create a plugin utilizing FPDF to create an choices web page to print customized put up sorts.
Right here is my code:
<?php
/*
* Plugin Title: RT FPDF Tutorial
* Description: A plugin created to reveal how one can construct a PDF doc from WordPress posts.
* Model: 1.0
*/
if ( ! outlined( 'ABSPATH' ) ) {
exit;
}
embody( 'pdf-helper-functions.php');
$pdf = new PDF_HTML();
if( isset($_POST['generate_posts_pdf'])){
output_pdf();
}
add_action( 'admin_menu', 'rt_fpdf_create_admin_menu' );
operate rt_fpdf_create_admin_menu() {
$hook = add_submenu_page(
'instruments.php',
'PDF Generator',
'PDF Generator',
'manage_options',
'rt-fdpf-tutorial',
'rt_fpdf_create_admin_page'
);
}
operate rt_fpdf_create_admin_page() {
echo '<div class="wrap">';
echo ' <kind technique="post" id="as-fdpf-form"><button class="button button-primary" sort="submit" identify="generate_posts_pdf" worth="generate">Generate the Listing</button></kind>';
echo '</div>';
}
operate output_pdf() {
international $pdf;
$title_line_height = 10;
$content_line_height = 8;
$args = array(
'post_type' => 'cc_family',
);
// The Question
//$the_query = new WP_Query( array ('post_type' => 'cc_family') );
$pdf->AddPage();
$pdf->SetFont( 'Arial', '', 42 );
$pdf->Write(20, 'No households to make a listing but');
$pdf->Output('D','new-directory.pdf');
exit;
}
Because the code is correct now it really works ($the_query is commented out.) A pdf is created with the content material "no families…".
If I un-comment the road above to begin including the question, I get a vital error on my web site. If I add a whole generic question I get an error as properly.
I’ve tried with get_posts() and this works, nevertheless it does not appear to permit me to tug customized fields. Is there one thing particular to including a brand new question I’ve missed?
Replace so as to add the error:
> [13-Sep-2021 15:30:51 UTC] PHP Discover: ob_end_flush(): did not ship
> buffer of zlib output compression (0) in
> /dwelling/whn/public_html/wp-includes/features.php on line 5107
> [13-Sep-2021 15:30:53 UTC] PHP Deadly error: Uncaught Error: Name to
> undefined operate is_user_logged_in() in
> /dwelling/whn/public_html/wp-includes/class-wp-query.php:2544 Stack
> hint:
> #0 /dwelling/whn/public_html/wp-includes/class-wp-query.php(3465): WP_Query->get_posts()
> #1 /dwelling/whn/public_html/wp-includes/class-wp-query.php(3576): WP_Query->question(Array)
> #2 /dwelling/whn/public_html/wp-content/plugins/pdfer/rt_pdf.php(48): WP_Query->__construct(Array)
> #3 /dwelling/whn/public_html/wp-content/plugins/pdfer/rt_pdf.php(18): output_pdf()
> #4 /dwelling/whn/public_html/wp-settings.php(409): include_once('/dwelling/wh3n/publ...')
> #5 /dwelling/whn/public_html/wp-config.php(91): require_once('/dwelling/wh3n/publ...')
> #6 /dwelling/whn/public_html/wp-load.php(50): require_once('/dwelling/wh3n/publ...')
> #7 /dwelling/whn/public_html/wp-admin/admin.php(34): require_once('/dwelling/wh3n/publ...')
> #8 /dwelling/whn/public_html/wp-admin/instruments.php(40): require_once('/dwelling/wh3n/publ...')
> #9 {fundamental} thrown in /dwelling/whn/public_html/wp-includes/class-wp-query.php on line 2544
> [13-Sep-2021 15:30:53 UTC] PHP Discover: is_embed was referred to as
> <robust>incorrectly</robust>. Conditional question tags don't work
> earlier than the question is run. Earlier than then, they at all times return false. Please
> see <a
> href="https://wordpress.org/support/article/debugging-in-wordpress/">Debugging
> in WordPress</a> for extra info. (This message was added in
> model 3.1.0.) in /dwelling/whn/public_html/wp-includes/features.php on
> line 5663 [13-Sep-2021 15:30:53 UTC] PHP Discover: is_search was referred to as
> <robust>incorrectly</robust>. Conditional question tags don't work
> earlier than the question is run. Earlier than then, they at all times return false. Please
> see <a
> href="https://wordpress.org/support/article/debugging-in-wordpress/">Debugging
> in WordPress</a> for extra info. (This message was added in
> model 3.1.0.) in /dwelling/whn/public_html/wp-includes/features.php on
> line 5663 [13-Sep-2021 15:30:54 UTC] PHP Discover: ob_end_flush():
> did not ship buffer of zlib output compression (0) in
> /dwelling/whn/public_html/wp-includes/features.php on line 5107