• Resolved Pacotole

    (@pacotole)


    It would be nice to pass the $post_id variable in the 'autoremove_attachments_allowed' filter. That way we could easily add conditions like enabling it only for some CPTs.

    $allowed_to_remove = apply_filters( 'autoremove_attachments_allowed', true, $post_id );
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Pacotole

    (@pacotole)

    Oops! I just saw it in the FAQs ???♂?
    Anyway, it seems cleaner to me to pass it as an argument than to use a global variable.

    Plugin Author Eusebiu Oprinoiu

    (@eusebiuoprinoiu)

    Hello, Pacotole!

    Both methods are OK to use. In this case, using the global variable was an intentional choice.
    The people who need to use this filter might not have much experience with WordPress development and might not be aware that filters accept additional arguments. Or even if they do, they might forget to specify the number of arguments, leading to errors or unexpected behavior.
    This is just a safety net on my part.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.