Skip to content

Commit

Permalink
include assets via PHP
Browse files Browse the repository at this point in the history
  • Loading branch information
faisal-alvi committed Jun 14, 2024
1 parent 6acff38 commit 46fc59b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
3 changes: 1 addition & 2 deletions includes/blocks/block-editor/tabs-item/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@
"reusable": false,
"html": false
},
"parent":[ "tenup/tabs" ],
"editorScript": "file:../../../../dist/blocks/tabs-item-block.js"
"parent":[ "tenup/tabs" ]
}
18 changes: 18 additions & 0 deletions includes/blocks/block-editor/tabs-item/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,24 @@ function register() {
]
);
}

// Enqueue assets.
add_action( 'enqueue_block_assets', $n( 'enqueue_block_assets' ) );
}

/**
* Enqueue block assets.
*/
function enqueue_block_assets() {
$asset_file = include PUBLISHER_MEDIA_KIT_PATH . 'dist/blocks/tabs-item-block.asset.php';

wp_enqueue_script(
'publisher-media-kit-tabs-item-block',
PUBLISHER_MEDIA_KIT_URL . '/dist/blocks/tabs-item-block.js',
$asset_file['dependencies'],
$asset_file['version'],
true
);
}

/**
Expand Down
5 changes: 1 addition & 4 deletions includes/blocks/block-editor/tabs/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,5 @@
},
"supports": {
"html": false
},
"editorScript": "file:../../../../dist/blocks/tabs-block.js",
"editorStyle": "file:../../../../dist/blocks/tabs-block.css",
"style": "file:../../../../dist/blocks/tabs-block.css"
}
}
25 changes: 25 additions & 0 deletions includes/blocks/block-editor/tabs/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,31 @@ function register() {
]
);
}

// Enqueue assets.
add_action( 'enqueue_block_assets', $n( 'enqueue_block_assets' ) );
}

/**
* Enqueue block assets.
*/
function enqueue_block_assets() {
$asset_file = include PUBLISHER_MEDIA_KIT_PATH . 'dist/blocks/tabs-block.asset.php';

wp_enqueue_script(
'publisher-media-kit-tabs-block',
PUBLISHER_MEDIA_KIT_URL . '/dist/blocks/tabs-block.js',
$asset_file['dependencies'],
$asset_file['version'],
true
);

wp_enqueue_style(
'publisher-media-kit-tabs-block',
PUBLISHER_MEDIA_KIT_URL . '/dist/blocks/tabs-block.css',
[],
$asset_file['version']
);
}

/**
Expand Down

0 comments on commit 46fc59b

Please sign in to comment.