Skip to content

Commit eaaf898

Browse files
emcarruDoğa Gürdal
authored andcommitted
feat(snippets/php): update component scaffolding and remove unused snippet (#1)
Move `wp_enqueue_scripts` into to `addComponentData` filter, so that the component assets are only enqueued when the component is actually on the current page.
1 parent 1c37304 commit eaaf898

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

snippets/php.json

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
11
{
2-
"Add Component Assets": {
3-
"prefix": "flyntComponentAssets",
4-
"body": [
5-
"use Flynt\\\\Features\\\\Components\\\\Component;",
6-
"",
7-
"add_action('wp_enqueue_scripts', function () {",
8-
"\tComponent::enqueueAssets('${1:${TM_DIRECTORY/.*\\/(.+)$/${1:/capitalize}/}}'${2:, []});",
9-
"});"
10-
]
11-
},
122
"Add Component Asset Dependency": {
133
"prefix": "flyntComponentDependency",
144
"body": [
@@ -36,11 +26,10 @@
3626
"",
3727
"use Flynt\\\\Features\\\\Components\\\\Component;",
3828
"",
39-
"add_action('wp_enqueue_scripts', function () {",
40-
"\tComponent::enqueueAssets('$1');",
41-
"});",
42-
"",
4329
"add_filter('Flynt/addComponentData?name=$1', function (\\$data) {",
30+
"\tadd_action('wp_enqueue_scripts', function () {",
31+
"\t\tComponent::enqueueAssets('$1');",
32+
"\t});",
4433
"\treturn \\$data;",
4534
"});"
4635
]

0 commit comments

Comments
 (0)