Skip to content
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 21 commits into from
Sep 22, 2023

Conversation

EvanHerman
Copy link

@EvanHerman EvanHerman commented Sep 21, 2023

Closes #251

Description of the Change

As outlined in the issue linked below, this PR conditionally displays a View in code editor link beneath each PHPCS warning/error so users can make changes to their code in the code editor in the WordPress dashboard.

image

Open files in external IDE

Editing files can be done in an external editor using the supplied plugin_check_validation_error_source_file_editor_url_template filter.

Examples:

PhpStorm

add_filter( 'plugin_check_validation_error_source_file_editor_url_template', function () {
    return 'phpstorm://open?file={{file}}&line={{line}}';
} );

VS Code

add_filter( 'plugin_check_validation_error_source_file_editor_url_template', function () {
    return 'vscode://file/{{file}}:{{line}}';
} );

How to test the Change

Run the Plugin Check (from this branch) on any plugin with a PHPCS warning or error and click on the 'View in code editor' to be brought over to the plugin file editor. Once there, confirm that the editor scrolls down to (and highlights) the correct line.

Changelog Entry

Added - 'View in code editor' link beneath each PHPCS error or warning.

Credits

Props @westonruter, @felixarntz, @mukeshpanchal27, @bordoni

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@EvanHerman EvanHerman marked this pull request as ready for review September 21, 2023 23:22
Copy link
Member

@bordoni bordoni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some changes to make the logic easier to read, do you mind adding a Changelog to the readme.txt?

admin/admin.php Outdated Show resolved Hide resolved
@bordoni bordoni added the [Type] Enhancement A suggestion for improvement of an existing feature label Sep 21, 2023
checks/phpcs.php Outdated Show resolved Hide resolved

$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',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need to be translated at some point.

Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Member

@mukeshpanchal27 mukeshpanchal27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @EvanHerman for the PR. Left some feedback.

This PR closed the original issue but make sure we have to update it in trunk so we will get this for future version.

checks/phpcs.php Outdated Show resolved Hide resolved
checks/phpcs.php Outdated Show resolved Hide resolved
checks/phpcs.php Outdated Show resolved Hide resolved
@felixarntz
Copy link
Member

@EvanHerman @bordoni A general question not specifically about this change: I see this is targeting legacy-plugin, what about the trunk branch?

I would like to better understand what your current plans are with the "legacy plugin", because I thought it was about publishing only a 0.2. Since this PR is an enhancement and not a bug fix, I'm curious whether you plan to do further releases based on that codebase? I want to be mindful of us not duplicating too much work, and I think switching sooner than later will help with that.

@bordoni
Copy link
Member

bordoni commented Sep 22, 2023

@felixarntz 100% in agreement there, I will create a Ticket for me to port this functionality to the trunk version once it comes time to port the Legacy code into the new plugin.

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EvanHerman This looks good, just one important change needed (permissions check).

)
);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checks/phpcs.php Outdated Show resolved Hide resolved
checks/phpcs.php Outdated Show resolved Hide resolved
bordoni and others added 2 commits September 22, 2023 15:15
Co-authored-by: Felix Arntz <[email protected]>
@bordoni bordoni merged commit 8d0feab into WordPress:legacy-plugin Sep 22, 2023
1 check failed
bordoni added a commit that referenced this pull request Sep 22, 2023
@bordoni bordoni added this to the 0.2.1 milestone Sep 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement A suggestion for improvement of an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants