Add a way to check if the logged-in user is editing the current page from within a template
The problem to solve
I would like to render some of my custom widgets differently when they're being edited.
Proposed solution
Add an editing property somewhere within the data object, making it accessible from within widget templates.
Additional context
Some examples where this feature would be useful:
- Removing the link from a button, so the editor doesn't get redirected when trying to edit the button.
- Making invisible elements (like spacers) visible in edit mode.
You could accomplish this through browser-side JS by checking window.apos.adminBar.editMode. I'm not sure if there is another way on the server-side.
I've looked for a way, with no success. Though, for what it's worth, I did find that I could achieve most of what I wanted to do by styling elements differently when they're a child of .apos-area-widget-wrapper.
Can't you check the edit mode and use JS to add a body class to accomplish what you are describing?
Probably could. Using CSS does the job for now, but I'll keep that in mind in case I hit a wall. Thanks!