Site logo

Archived topic

Elements feature - Hooks -- do not strip out slashes from Hook names please

5 replies · Started by deckerweb on September 5, 2018

Viewing posts 1–6 of 6

Hi there!
I am using the new "Elements" feature and its awesome, thank you! :)

I am using your filter 'generate_hooks_list' to add custom hooks, for example from Elementor. In general this works like a charm!
However, since Elementor is using a different naming scheme like 'elementor/page_templates/canvas/before_content' (see the slashes!) the issue begins.

Your current sanitizing security function "sanitize_key" strips out those slashes and makes the custom action from Elementor useless in this context. I can save the template but it falls back to the first hook in your list which is 'wp_head'.

Changing the sanitizing callback function would solve this issue. I tested locally with 'esc_attr' and that works fine! :-) (It saves properly and correctly saves my custom added hook from the list, and also all other stuff works like it should then.)
I am sure there may be better more suited security functions for this but we just need to make sure it does not strip out slashes from action hook names as these become more and more common.

I mean the file wp-content/plugins/gp-premium/elements/class-metabox.php, around line 1517, my version of the plugin is 1.7.2

Thanks a lot in advance!

With kind regards,
David

Hey David,

Thanks for reporting this! I'll find a better function to sanitize them for 1.7.3.

Appreciate it! :)

Hi Tom!

Thanks for your tweak in 1.7.3 -- for "Custom Hooks" it works like a charm! ;-)

However, there is still the issue when I use your available filter 'generate_hooks_list' -- when I use that it still strips out all hooks from my custom list and "falls back" to the default "wp_head" hook on saving.

When I tweak the line 1472 in file /elements/class-metabox.php from 'key' to 'text' then all works like I want it :)

To give some background why I would need this:
Your filter is really handy to make other stuff available, for example from Easy Digital Downloads, other plugins like "Give" or whatever. Lots of plugins changed their hook handles to handles which includes "/" therefore the logic needs to be capable of this.

I am also currently working on a plugin - it is finished already, to be honest (only waiting on this issue...) - which will conditionally connect additional *useful* hooks to this filter. To make it even easier for non-coders to get this stuff working. Your whole "Elements" feature is perfectly suited for non-coders so an extended hooks list for them can be very handy and useful.

It would be really awesome if I can include integration with GeneratePress' Elements in my plugin as it belongs in there, in my opinion. The plugin will be free on .org as a helper plugin for site builders who use GeneratePress as their base.

Sorry for bothering you again.

If there is any more clarfication needed I am ready to give all whats needed!

Thanks so much in advance, Dave :)

P.S I am sorry for delay on my behalf, wasn't able to work on my project/ plugin in the last 6 weeks so sorry for being late on this.

Thanks for this, David! I'll take a closer look and will get back to you :)

Just a heads up that this is fixed in 1.7.5 :)

This archived topic is closed to new replies.