Skip to content

Commit

Permalink
Merge pull request #372 from ernilambar/371-use-parser-in-trademarks
Browse files Browse the repository at this point in the history
Use Readme Parser in Trademarks check class
  • Loading branch information
mukeshpanchal27 authored Jan 8, 2024
2 parents 43c4af9 + 8e79029 commit eb3f847
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions includes/Checker/Checks/Trademarks_Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use WordPress\Plugin_Check\Traits\Amend_Check_Result;
use WordPress\Plugin_Check\Traits\Find_Readme;
use WordPress\Plugin_Check\Traits\Stable_Check;
use WordPressdotorg\Plugin_Directory\Readme\Parser;

/**
* Check for trademarks.
Expand Down Expand Up @@ -248,24 +249,18 @@ private function check_for_name_in_readme( Check_Result $result, array $files )
return;
}

$matches = array();
// Get the plugin name from readme file.
$file = self::file_preg_match( '/===(.*)===/i', $readme, $matches );
$readme_file = reset( $readme );

if ( ! $file || ! isset( $matches[1] ) ) {
return;
}

$name = trim( $matches[1] );
$parser = new Parser( $readme_file );

try {
$this->validate_name_has_no_trademarks( $name );
$this->validate_name_has_no_trademarks( $parser->name );
} catch ( Exception $e ) {
$this->add_result_error_for_file(
$result,
$e->getMessage(),
'trademarked_term',
$file
$readme_file
);
}
}
Expand Down

0 comments on commit eb3f847

Please sign in to comment.