-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Comments: Add missing dots in wp-includes/formatting.php
#8241
Comments: Add missing dots in wp-includes/formatting.php
#8241
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
src/wp-includes/formatting.php
Outdated
@@ -6157,10 +6157,10 @@ function wp_staticize_emoji_for_email( $mail ) { | |||
function _wp_emoji_list( $type = 'entities' ) { | |||
// Do not remove the START/END comments - they're used to find where to insert the arrays. | |||
|
|||
// START: emoji arrays | |||
// START: emoji arrays. |
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 comment is used as a placeholder to update the arrays below, to make these changes you will also need to update the grunt.js
file to include the full stop (remember to escape the dots in the regex).
wordpress-develop/Gruntfile.js
Lines 1049 to 1116 in 99dd184
match: /\/\/ START: emoji arrays[\S\s]*\/\/ END: emoji arrays/g, | |
replacement: function() { | |
var regex, files, ghCli, | |
partials, partialsSet, | |
entities, emojiArray, | |
apiResponse, query; | |
grunt.log.writeln( 'Fetching list of Twemoji files...' ); | |
// Ensure that the GitHub CLI is installed. | |
ghCli = spawn( 'gh', [ '--version' ] ); | |
if ( 0 !== ghCli.status ) { | |
grunt.fatal( 'Emoji precommit script requires GitHub CLI. See https://cli.github.com/.' ); | |
} | |
// Fetch a list of the files that Twemoji supplies. | |
query = 'query={repository(owner: "jdecked", name: "twemoji") {object(expression: "v15.0.3:assets/svg") {... on Tree {entries {name}}}}}'; | |
files = spawn( 'gh', [ 'api', 'graphql', '-f', query] ); | |
if ( 0 !== files.status ) { | |
grunt.fatal( files.stderr.toString() ); | |
} | |
try { | |
apiResponse = JSON.parse( files.stdout.toString() ); | |
} catch ( e ) { | |
grunt.fatal( 'Unable to parse Twemoji file list' ); | |
} | |
entities = apiResponse.data.repository.object.entries; | |
entities = entities.reduce( function( accumulator, val ) { return accumulator + val.name + '\n'; }, '' ); | |
// Tidy up the file list. | |
entities = entities.replace( /\.svg/g, '' ); | |
entities = entities.replace( /^$/g, '' ); | |
// Convert the emoji entities to HTML entities. | |
partials = entities = entities.replace( /([a-z0-9]+)/g, '&#x$1;' ); | |
// Remove the hyphens between the HTML entities. | |
entities = entities.replace( /-/g, '' ); | |
// Sort the entities list by length, so the longest emoji will be found first. | |
emojiArray = entities.split( '\n' ).sort( function( a, b ) { | |
return b.length - a.length; | |
} ); | |
// Convert the entities list to PHP array syntax. | |
entities = '\'' + emojiArray.filter( function( val ) { | |
return val.length >= 8 ? val : false ; | |
} ).join( '\', \'' ) + '\''; | |
// Create a list of all characters used by the emoji list. | |
partials = partials.replace( /-/g, '\n' ); | |
// Set automatically removes duplicates. | |
partialsSet = new Set( partials.split( '\n' ) ); | |
// Convert the partials list to PHP array syntax. | |
partials = '\'' + Array.from( partialsSet ).filter( function( val ) { | |
return val.length >= 8 ? val : false ; | |
} ).join( '\', \'' ) + '\''; | |
regex = '// START: emoji arrays\n'; | |
regex += '\t$entities = array( ' + entities + ' );\n'; | |
regex += '\t$partials = array( ' + partials + ' );\n'; | |
regex += '\t// END: emoji arrays'; | |
return regex; |
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.
Thanks for catching this! You're absolutely right - I will revert the change to the "START: emoji arrays" comment since it's used as a marker for the Grunt task. I see now that modifying this would require coordinated changes in Gruntfile.js to update the regex pattern.
I'll update the PR to remove the period from this specific comment while keeping the other documentation improvements.
Hi @peterwilsoncc, |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Thanks for the PR! Merged in r59765. |
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.
Just a minor note inline about the terminology WP uses but otherwise I think this is good.
@@ -4696,7 +4696,7 @@ function esc_attr( $text ) { | |||
* | |||
* @since 2.0.6 | |||
* | |||
* @param string $safe_text The text after it has been escaped. | |||
* @param string $safe_text The text after it has been sanitized and escaped. |
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.
esc_attr()
is an escaping function, as WordPress uses the term sanitization for user input this could be confusing to developers.
* @param string $safe_text The text after it has been sanitized and escaped. | |
* @param string $safe_text The text after it has been escaped. |
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.
Hi @peterwilsoncc,
Should I open a follow-up PR to address this issue?
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.
@Infinite-Null Don't worry, it was more a nit pick than a particular concern.
Sorry about the coincidence of timing as I commented and Sergey committed. These things happen occasionally :)
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.
No worries at all! I appreciate the clarification. Thank You 😄
Trac ticket: #62885
Description
This PR adds missing periods (dots) at the end of complete sentence comments in wp-includes/formatting.php.
Implements the changes from this diff in accordance with this comment. Additionally, I have identified and corrected a few other instances in the file where periods were missing at the end of sentences.
Changes: