Skip to content

“Only run once” snippets runs on save #227

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

Open
lightbulbman opened this issue Mar 6, 2025 · 0 comments
Open

“Only run once” snippets runs on save #227

lightbulbman opened this issue Mar 6, 2025 · 0 comments
Labels

Comments

@lightbulbman
Copy link
Contributor

Current behavior

When creating a run-once snippet, it runs on every save, despite the fact the I just click the “save changes” button(!)

I test with a simple snippet like:

error_log("Test!!");
I make a change and hit execute. This saves and runs the snippet as expected.

Then I make another change eg error_log("Test 2!"); and only hit “Save Changes”. But in the logs I see the new message Test 2! that have never run before. That means that the snippet ran, even though the user just clicked save.

Please note that this happens only after the the snippet is saved and the run once was deliberately used at least once

Expected behavior

When saving a run-once snippet then the snippet should not run and only run when the save and execute button or execute once button is pressed

Steps to reproduce

  1. Create a php snippet and add some code like above
  2. Select Run Once and save - check code has run
  3. Make changes and click save - code will have run again

WordPress version

6.7.2

Code Snippets version

3.6.8

Code Snippets license

Core (free)

Anything else?

Link to WP.org original report: https://wordpress.org/support/topic/only-run-once-snippets-runs-on-save/

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

No branches or pull requests

1 participant