-2

Is there an easy way to apply a function on all action hooks?

I want to apply esc_attr() to every action hook (in a way that would work from functions.php or a plugin).

I figure I would need to filter do_action and do_action_ref_array except that those functions don't use apply_filters. Is there any way to do this?

  • Looks like paranoia. What is underlying aim of this wish? – Alexey Sep 25 '11 at 0:01
  • 4
    If you're worried about a plugin that does not escape data, you should stop using the plugin. No need to use a sledge hammer on the whole operation. – Brian Fegter Sep 25 '11 at 2:31
  • I want to make a plugin, for which I need action hooks to be escaped. – ryanve Sep 25 '11 at 18:38
2

Just to answer the title

Apply function on all action hooks?

isn't that hard, when you know where to look:

add_action( 'all', 'callback_function' );
4

I want to make a plugin, for which I need action hooks to be escaped.

No, your Plugin needs to escape its own data on output (and validate/sanitize it on input).

Every add_action() and add_filter() call has an associated callback function. You need to do your escaping inside the callback.

1

While this might be possible technically (with messy output buffering) this makes little sense. It would likely break a lot of output and escaping functions must be used contextually - there is no sense in using esc_attr() for everything.

If this is your own plugin and you have control over code - just go with conventional development techniques like using filters for data that needs to be modified in hooks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.