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
feat: add missing extra fields to EnqueuedAsset
, EnqueuedScript
and EnqueuedStylesheet
#2988
feat: add missing extra fields to EnqueuedAsset
, EnqueuedScript
and EnqueuedStylesheet
#2988
Conversation
f1b5a72
to
40023c5
Compare
'src' => [ | ||
'resolve' => static function ( \_WP_Dependency $script ) { | ||
return ! empty( $script->src ) && is_string( $script->src ) ? $script->src : null; | ||
'extraData' => [ |
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.
Similar blocks of code found in 3 locations. Consider refactoring.
return $script->extra['data']; | ||
}, | ||
], | ||
'strategy' => [ |
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.
Similar blocks of code found in 3 locations. Consider refactoring.
return array_filter( $before_scripts ); | ||
}, | ||
], | ||
'conditional' => [ |
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.
Similar blocks of code found in 3 locations. Consider refactoring.
…ependencies both return lists of their same type.
…ueued-asset-extra-fields
'type' => [ 'list_of' => 'EnqueuedScript' ], | ||
'description' => __( 'Dependencies needed to use this asset', 'wp-graphql' ), | ||
], | ||
'extraData' => [ |
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.
Similar blocks of code found in 3 locations. Consider refactoring.
return $script->extra['data']; | ||
}, | ||
], | ||
'strategy' => [ |
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.
Similar blocks of code found in 3 locations. Consider refactoring.
Code Climate has analyzed commit 5eb6c08 and detected 22 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
What does this implement/fix? Explain your changes.
The PR registers GraphQL fields for script/style data stored in the
$extra
property on the instance. More specifically:EnqueuedAsset
after
andbefore
fields, for code that is supposed to be inlined before/after the asset is called.conditional
field, for HTML comment conditionalsextra
in favor ofEnqueuedScript.extraData
.args
in favor ofEnqueuedStylesheet.media
.dependency
to be anEnqueuedAsset
instead of anEnqueuedScipt
.EnqueuedScript
extraData
for inline js data passed to the script (previously `EnqueuedAsset.extra)strategy
and the correspondingScriptLoadingStrategyEnum
.EnqueuedStylesheet
isRtl
,media
path
,suffix
, andtitle
rel
, which is derived from$style->extra['alt']
since it seemed clunky to use anisAlt
to force users to know they need to dorel={isAlt ? 'alternative stylesheet' : 'stylesheet' }
Does this close any currently open issues?
Fixes #2938
Any relevant logs, error output, GraphiQL screenshots, etc?
Any other comments?
Where has this been tested?
Operating System: Ubunut 20.04 (wsl2 + devilbox + php 8.1.15)
WordPress Version: 6.4.1