Skip to content

Fix snippet errors reporting #324

@CarolinaOP

Description

@CarolinaOP

Current behavior

When saving a snippet with code errors, the editor showed a success notice even though the snippet couldn't be activated, and the code_error field was lost.

Expected behavior

When saving a snippet with code errors:

  • The snippet is saved to the database
  • The snippet is not activated (remains inactive)
  • The REST API response includes the code_error field as [message, line_number].
  • The editor receives and parses code_error from the response.
  • The user should see clear feedback that the snippet was saved but could not be activated due to code errors, with the error details available in the snippet object.

Steps to reproduce

  1. Create a new php snippet with an error
  2. Click Save and Activate

A success notice appears but the snippet was not activated.

WordPress version

6.9

Code Snippets version

3.9.3

Code Snippets license

Core (free)

Anything else?

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions