• Resolved capson

    (@capson)


    I am getting

    
    Warning: Missing argument 2 for Nelio_Content_External_Featured_Image_Public::maybe_add_efi_as_background() in /home/.../wp-content/plugins/nelio-content/public/class-nelio-content-external-featured-image-public.php on line 285

    on all my post pages

    Please advise

    Thanks
    Tim

    • This topic was modified 7 years, 3 months ago by capson.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • I am getting a similar message:

    Warning: Missing argument 2 for Nelio_Content_External_Featured_Image_Public::maybe_add_efi_as_background(), called in /janellereston/wp-includes/class-wp-hook.php on line 298 and defined in /janellereston/wp-content/plugins/nelio-content/public/class-nelio-content-external-featured-image-public.php on line 285

    I have deactivated the plugin since this was visible to all visitors, but that didn’t get rid of the message despite the fact I cleared the caches. Yikes.

    Deleting the plugin made the message go away, thank goodness.

    Plugin Author David Aguilera

    (@davilera)

    Hi!

    Thanks for the heads up. I’m quite surprised you’re getting this warning. The function that’s “causing” the warning (maybe_add_efi_as_background) has several parameters and is used as a callback from a WordPress filer:

    
    add_filter( 'post_thumbnail_html', array( $this, 'maybe_add_efi_as_background' ), 10, 4 );
    

    If you take a look at WordPress docs, you’ll see that this filter has more than one parameter:

    
    apply_filters( 'post_thumbnail_html',
      string $html, int $post_id, string $post_thumbnail_id,
      string|array $size, string $attr )
    

    so I don’t understand why you’re getting the warning (the second argument shouldn’t be missing). Anyway, here’s how you can fix it until we release a new version of the plugin:

    1. Edit the file public/class-nelio-content-external-featured-image-public.php in our plugin
    2. Go to line 285, where function maybe_add_efi_as_background is defined
    3. The second parameter is $post_id. Set a default value for this parameter: $post_id = 0
    4. The final result should look like this:
    
    public function maybe_add_efi_as_background( $html, $post_id = 0, …
    

    Alternatively, you can disable warnings in your server (it’s usually a good idea to disable debug options in a production site).

    Thanks again for your feedback.

    Regards,
    David

    Thread Starter capson

    (@capson)

    Hello David, I followed your fix and that fixed it.

    I have error messages set to off but this still showed

    Thanks!

    Plugin Author David Aguilera

    (@davilera)

    Great, @capson!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Warning: Missing argument 2 for Nelio_Content_External_Featured_Image’ is closed to new replies.