-
Notifications
You must be signed in to change notification settings - Fork 54
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 'View in code editor' link to the PHPCS warnings/errors #262
Merged
Merged
Changes from 9 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
df61ade
Add a view in code editor link to the PHPCS warnings/errors
EvanHerman d697fbd
Update var name
EvanHerman 820b0ca
Add alt and aria-label to the edit link
EvanHerman 40f31d1
Remove theme reference
EvanHerman ec2632b
Update docblock
EvanHerman 6ac270b
Empty line at end of file
EvanHerman 51601fe
Move get_plugins call inside of conditional
EvanHerman 57c9e54
Update admin/admin.php based on suggestion
EvanHerman 7974800
Remove DISALLOW_FILE_EDIT condition
EvanHerman f74bb10
Remove duplicate var
EvanHerman 477c0ae
use %s
EvanHerman 32954e1
Add changelog entry
EvanHerman 85fff97
Merge branch 'legacy-plugin' into legacy-plugin
EvanHerman ea36507
Introduce a way to open files in an external editor
EvanHerman a4e5d56
Fix typo
EvanHerman bc41ab2
Fix comment
EvanHerman 1e66025
Update filter name
EvanHerman c9f2e76
Merge branch 'legacy-plugin' into legacy-plugin
EvanHerman d72c91d
Add missing editlink var
EvanHerman a193c22
Include Capabilities
bordoni c74de6a
Simplify to use `str_contains`
bordoni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,16 +110,39 @@ protected function phpcs_result_to_warnings( $result ) { | |
} | ||
|
||
$source_code = esc_html( trim( file( $this->path . '/' . $filename )[ $message['line'] - 1 ] ) ); | ||
$plugin_data = get_plugins( '/' . $this->slug ); | ||
$edit_link = ''; | ||
EvanHerman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
$edit_link = sprintf( | ||
'<a href="%1$s" title="%2$s" aria-label="%2$s" target="_blank">%3$s</a>', | ||
esc_url( | ||
add_query_arg( | ||
[ | ||
'plugin' => rawurlencode( $this->slug . '/' . array_key_first( $plugin_data ) ), | ||
'file' => rawurlencode( $this->slug . '/' . $filename ), | ||
'line' => rawurlencode( $message['line'] ), | ||
], | ||
admin_url( 'plugin-editor.php' ) | ||
) | ||
), | ||
sprintf( | ||
/* translators: %1$s is the path to a plugin file. */ | ||
esc_attr__( 'View %1$s in the plugin file editor.', 'plugin-check' ), | ||
EvanHerman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
$this->slug . '/' . $filename | ||
), | ||
esc_html__( 'View in code editor', 'plugin-check' ) | ||
); | ||
|
||
$return[] = new $notice_class( | ||
$message['source'], | ||
sprintf( | ||
'%s Line %d of file %s.<br>%s.<br>%s', | ||
'%s Line %d of file %s.<br>%s.<br>%s%s', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will need to be translated at some point. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh that is a great catch too, I will handle that in a separate PR. |
||
"<strong>{$message['source']}</strong>", | ||
$message['line'], | ||
$filename, | ||
rtrim( $message['message'], '.' ), | ||
"<pre><code>{$source_code}</code></pre>" | ||
"<pre><code>{$source_code}</code></pre>", | ||
$edit_link | ||
) | ||
); | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is awesome 👍
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.
Inline after script goodness! 😄
Source: https://github.com/ampproject/amp-wp/blob/956c8d298764e4b22b936347d7c8b591b2fadfc2/includes/validation/class-amp-validation-error-taxonomy.php#L1034-L1062