-
Notifications
You must be signed in to change notification settings - Fork 384
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
Wrap registered widgets in callbacks to track widget validation errors #1012
Conversation
|
* Include core as a source in addition to plugins and themes. * Refactor source comments to only consist of JSON-encoded source data. * Include the function name in the source.
3d82d39
to
5033910
Compare
* Ensure that filters/actions added during execution of page get wrapped. * Prevent hook wrapping from happening on callbacks for functions with parameters passed by reference. * Split widget callback wrapping logic out from hook callback wrapping.
Ready for review! |
Will Review Hi @westonruter, |
* After a test method runs, reset any state in WordPress the test method might have changed. | ||
*/ | ||
public function tearDown() { | ||
$GLOBALS['wp_registered_widgets'] = $this->original_wp_registered_widgets; // WPCS: override ok. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea to reset the original global $wp_registered_widgets
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be something that gets reset for us automatically, but it wasn't so this is to ensure we reset the global state.
return sprintf( | ||
'<!--%samp-source-stack %s-->', | ||
$is_start ? '' : '/', | ||
str_replace( '--', '', wp_json_encode( $source ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's nice how this adds the json-encoded source data to the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved
Hi @westonruter,
It's nice how this displays the function in the UI, and places the json-encoded sources in the comment.
Example validation data for when a Custom HTML widget is added which includes a
script
tag:Fixes #1005.