mirror of
https://github.com/10h30/wp-strava.git
synced 2026-07-18 14:14:01 +09:00
Added skeletal activity block
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* Functions to register client-side assets (scripts and stylesheets) for the
|
||||
* Gutenberg block.
|
||||
*
|
||||
* @package wp-strava
|
||||
*/
|
||||
|
||||
/**
|
||||
* Registers all block assets so that they can be enqueued through Gutenberg in
|
||||
* the corresponding context.
|
||||
*
|
||||
* @see https://wordpress.org/gutenberg/handbook/blocks/writing-your-first-block-type/#enqueuing-block-scripts
|
||||
*/
|
||||
function register_activity_block() {
|
||||
// automatically load dependencies and version
|
||||
$asset_file = include plugin_dir_path( __FILE__ ) . 'build/index.asset.php';
|
||||
|
||||
wp_register_script(
|
||||
'wp-strava/activity',
|
||||
plugins_url( 'build/index.js', __FILE__ ),
|
||||
$asset_file['dependencies'],
|
||||
$asset_file['version']
|
||||
);
|
||||
|
||||
wp_register_style(
|
||||
'wp-strava/activity',
|
||||
plugins_url( 'style.css', __FILE__ ),
|
||||
array(),
|
||||
filemtime( plugin_dir_path( __FILE__ ) . 'style.css' )
|
||||
);
|
||||
|
||||
register_block_type(
|
||||
'wp-strava/activity',
|
||||
array(
|
||||
'style' => 'wp-strava/activity',
|
||||
'editor_script' => 'wp-strava/activity',
|
||||
)
|
||||
);
|
||||
|
||||
if ( function_exists( 'wp_set_script_translations' ) ) {
|
||||
/**
|
||||
* May be extended to wp_set_script_translations( 'my-handle', 'my-domain',
|
||||
* plugin_dir_path( MY_PLUGIN ) . 'languages' ) ). For details see
|
||||
* https://make.wordpress.org/core/2018/11/09/new-javascript-i18n-support-in-wordpress/
|
||||
*/
|
||||
wp_set_script_translations( 'wp-strava/activity', 'wp-strava' );
|
||||
}
|
||||
}
|
||||
add_action( 'init', 'register_activity_block' );
|
||||
Reference in New Issue
Block a user