• Resolved adamsmithdlc123

    (@adamsmithdlc123)


    Hi, Everything worked fine then I updated PHP to version 7.4 from 7.0 – as per the message from the waterwoo plugin. Everything else on the site works fine. (This is only a test site so nothing too worrying, but I am going to be pushing this to a site which has php 7.4 already enabled.)

    I now can not download the PDF and get the following message:

    Fatal error: Uncaught ArgumentCountError: Too few arguments to function write_something_after_waterwoo_writes(), 1 passed in /home/sites/5a/5/57748c9ef1/public_html/wp-includes/class-wp-hook.php on line 310 and exactly 2 expected in /home/sites/5a/5/57748c9ef1/public_html/wp-content/themes/Avada/functions.php:824 Stack trace: #0 /home/sites/5a/5/57748c9ef1/public_html/wp-includes/class-wp-hook.php(310): write_something_after_waterwoo_writes(Object(SS_TCPDI)) #1 /home/sites/5a/5/57748c9ef1/public_html/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters('', Array) #2 /home/sites/5a/5/57748c9ef1/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #3 /home/sites/5a/5/57748c9ef1/public_html/wp-content/plugins/waterwoo-pdf/classes/wwpdf-watermark.php(65): do_action('wwpdf_after_wri...', Object(SS_TCPDI), 1) #4 /home/sites/5a/5/57748c9ef1/public_html/wp-content/plugins/waterwoo-pdf/classes/wwpdf-watermark.php(20): WWPDF_Watermark->do_watermark() #5 /home/sites/5a/5/57748c9ef1/public_html/wp-content/plugins/ in /home/sites/5a/5/57748c9ef1/public_html/wp-content/themes/Avada/functions.php on line 824
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter adamsmithdlc123

    (@adamsmithdlc123)

    My code in function.php :

    add_filter( 'wwpdf_add_custom_font', ‘my_custom_font_name’, 10, 1 );
    function my_custom_font_name() {
        $font = TCPDF_FONTS::addTTFfont( $font_file, $font_type, $enc, $flags, $outpath, $platid, $encid, $addcbbox, $linkbox );
        return $font;
    }
    
     function write_something_after_waterwoo_writes( $pdf, $pageno ) {
     		
     		$pdf->Ln();
     		$pdf->Ln();
     		$pdf->Ln();
     		$pdf->Ln();
     		$pdf->Ln();
     		$pdf->Ln();
     		$pdf->Ln();
     		$pdf->Ln();
     		$pdf->SetFont('franklin', 'R', 11);
     		$pdf->SetLeftMargin(124);
     		$pdf->Write(15, "Valid Until: " . date('j, F Y', strtotime("+1 years")));
    
    		
     	} 
     	add_action( 'wwpdf_after_write', 'write_something_after_waterwoo_writes', 1, 1);

    Plugin Author Little Package

    (@littlepackage)

    Hello,

    Sorry this took a while to get to. I’m just not in the habit of writing free custom code for folks, and your code just needs a really quick, simple correction which I was hoping you would catch yourself (because to be fair, I volunteer to maintain the plugin, not folks’ personalizations/customizations of it).

    As an aside, I don’t know why you have included the first hook/filter having to do with ‘wwpdf_add_custom_font’ — that won’t do anything but slow down your watermarking, and I’d remove it.

    Secondly, WordPress is showing you the problem when it gives you verbose error messages: “…TOO FEW ARGUMENTS TO FUNCTION WRITE_SOMETHING_AFTER_WATERWOO_WRITES()…” Too few people bother to read these verbose messages and that’s a shame. PHP 7.4 is more strict than PHP 7, so it’s saying…

    When you add_action(), you need to be passing 2 arguments, not one. Literally one character of your code needs to change. Hint: the 1 before the );

    Thread Starter adamsmithdlc123

    (@adamsmithdlc123)

    Hi, Im so sorry. I did alter it again and got it working. I want to apologise for wasting your time!

    Thank you again!

    Plugin Author Little Package

    (@littlepackage)

    You are welcome!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Fatal Error following php upgrade’ is closed to new replies.