Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to check if the logged-in user is editing the current page from within a template #4683

Open
Pixelguymm opened this issue Aug 9, 2024 · 4 comments

Comments

@Pixelguymm
Copy link

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.
@BoDonkey
Copy link
Contributor

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.

@Pixelguymm
Copy link
Author

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.

@BoDonkey
Copy link
Contributor

Can't you check the edit mode and use JS to add a body class to accomplish what you are describing?

@Pixelguymm
Copy link
Author

Probably could. Using CSS does the job for now, but I'll keep that in mind in case I hit a wall. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants