Skip to content

Commit

Permalink
Apply suggestions from Felix's code review
Browse files Browse the repository at this point in the history
Co-authored-by: Felix Arntz <[email protected]>
  • Loading branch information
mukeshpanchal27 and felixarntz authored Oct 31, 2023
1 parent 55d8780 commit c202309
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions includes/Traits/File_Editor_URL.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@ trait File_Editor_URL {
*
* @param Check_Result $result The check result to amend, including the plugin context to check.
* @param string $filename Error file name.
* @param int $line Line number of error.
* @param int $line Optional. Line number of error. Default 0 (no specific line).
* @return string|null File editor URL or null if not available.
*/
protected function get_file_editor_url( Check_Result $result, $filename, $line ) {
if ( ! isset( $filename, $line ) ) {
return null;
}
protected function get_file_editor_url( Check_Result $result, $filename, $line = 0 ) {

$edit_url = null;

Expand Down Expand Up @@ -102,12 +99,15 @@ protected function get_file_editor_url( Check_Result $result, $filename, $line )

// Fall back to using the plugin editor if no external editor is offered.
if ( ! $edit_url && current_user_can( 'edit_plugins' ) ) {
$query_args = array(
'plugin' => rawurlencode( $result->plugin()->basename() ),
'file' => rawurlencode( $plugin_slug . '/' . $filename ),
);
if ( $line ) {
$query_args['line'] = $line;
}
return add_query_arg(
array(
'plugin' => rawurlencode( $result->plugin()->basename() ),
'file' => rawurlencode( $plugin_slug . '/' . $filename ),
'line' => $line,
),
$query_args,
admin_url( 'plugin-editor.php' )
);
}
Expand Down

0 comments on commit c202309

Please sign in to comment.