Error in pdf generating plugin using FPDF

The problem is that your output_pdf() function is being called too early. You have the function running in the root of the main plugin file, meaning that it runs as soon as the plugin is loaded, and before before WordPress has finished loading. You need to at least hook it to run later, such as … Read more

Empty Pdf file generated with FPDF library in WordPress plugin [closed]

This might not solve the problem, but what you’re currently doing looks unnecessarily convoluted (ajax request, fake link, serve PDF via link click etc.) Why not just a link styled as a button… <a class=”button” href=”<?= admin_url( ‘admin-post.php?action=wpse_212972_pdf’ ) ?>”>Download</a> …and then serve the PDF as a download directly from the server (using WP’s generic … Read more

How to build a PDF repository in WordPress

Right now, the support for tagging media is pretty disappointing. You can add tags or categories to the attachment post type, but you’ll find the UI is unacceptably bad (it’s a text box where you enter terms separated by commas). There’s a plugin Media Tags that is decent though, so you might look into that. … Read more

A link (not in the post) to download a specific PDF file

The pdf is itself an attachment post so in wordpress template hierarchy we can create a template named pdf.php Then you can write following code in it which force download the pdf file. <?php if (have_posts()) : the_post(); $pdf_title = $post->post_title; $pdf_src = get_attached_file($post->ID ); $bytes = filesize( $pdf_src ); header(“Pragma: public”); // required header(“Expires: … Read more

Permalink for PDF of article

Using add_rewrite_endpoint <?php if ( ! class_exists( ‘PDFRewriteEndpoint’ ) ): class PDFRewriteEndpoint { /** * Add actions and filters in constructor. */ public function __construct() { add_action( ‘parse_request’, array ( $this, ‘sniff_requests’ ), 0 ); add_action( ‘init’, array ( $this, ‘add_endpoint’ ), 0 ); } /** * Add rewrite rules. */ public function add_endpoint() { … Read more

Call to undefined function wp_generate_attachment_metadata()

Despite you already solved it (the “undefined” issue), it should be noted that wp_generate_attachment_metadata() is defined in wp-admin/includes/image.php, so you need to manually load that file if you’re using the function on the front-end, i.e. public side of the site or non admin/wp-admin pages (e.g. single attachment pages). And in fact, the function reference says … Read more

Attach pdf from dynamic url

You can try to do it in two ways. The first one, much more simple, is to save a temporary PDF file somewhere, for example in a uploads directory, use it as attachment and delete if after the call to wp_mail() function is made: function my_custom_save_post( $post_id, $post, $update ) { if( ! $update ) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)