Archived topic
Custom Sidebar without PHP?
5 replies · Started by Matt Stern on January 18, 2022
Hi Guys,
For security concerns, my client has requested the DISALLOW_FILE_EDIT to restrict php.
We're using the Merch starter site, and one hook from that was the use of a right sidebar on Woo product pages. This displayed the sidebar to the right of the product description. Screenshot: https://nimb.ws/sv5jhF
The code for that is <?php get_sidebar( 'right-sidebar'); ?> and the hook is woocommerce_after_single_product_summary
B/c of the php restriction, this will not load on the front end.
So I'm wondering, is it possible to create this using a block element? I created a block element with the style and content for the sidebar, then tried to place it on the woo product page using hooks, but am not able to get it to display properly. See: https://honestairpurifiers.com/airpura-r600-air-purifier
Any thoughts? Thank you!
Hi there,
Unfortunately it's not possible to execute PHP with a block element.
Maybe this filter would be a good solution?
https://docs.generatepress.com/article/generate_hooks_execute_php/
Got it, thx. Can you clarify. does this security measure only prevent people who already have access to the dashboard from executing php? Or does it also provide some sort of protection from outside attacks?
Perhaps if we enabled two-factor authentication, we could allow the php without the risk?
Thanks for the help.
Hi there,
its a security measure that stops people who already have access to dashboard.
You can allow PHP editing just in the Hooks if you want:
https://docs.generatepress.com/article/generate_hooks_execute_php/
Perfect, thanks David.
You're welcome