code-snippets icon indicating copy to clipboard operation
code-snippets copied to clipboard

Add support for conditions

Open sheabunge opened this issue 3 years ago • 2 comments

One feature we have requested pretty often is the ability to choose exactly when a snippet is evaluated. This could encompass both where (i.e., post type, page type, etc) and when (logged in, administrator, specific users, etc).

While this can be easily achieved by including conditional tags in Functions snippets, it seems that people would find an interface control helpful, and it would be especially useful for snippets that don't allow for PHP code (CSS/JS snippets).

Conditions should work with all four snippet types: Functions, Content, Styles, Scripts.

Relevant topics

  • Originally raised here: https://github.com/sheabunge/code-snippets/issues/95
  • https://wordpress.org/support/topic/javascript-only-on-one-page/

sheabunge avatar Jul 05 '22 09:07 sheabunge

It's really annoying to add code snippets to individual pages, posts, etc. because you always have to edit them there and have no overview or control in the plugin itself. Conditionally adding snippets within the plugin in a clear interface is a must.

nowrds avatar Oct 16 '22 18:10 nowrds