From 2dbbc1951188f41da665e31fac4c1e66c5999b98 Mon Sep 17 00:00:00 2001 From: Justin Foell <630830+jrfoell@users.noreply.github.com> Date: Mon, 3 Feb 2020 11:30:06 -0600 Subject: [PATCH] Re-added PHP register block for front-end render; Added example image --- src/blocks.php | 40 ++++++++++++++++++------------------ src/blocks/activity/index.js | 2 +- src/index.js | 4 ---- 3 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/blocks.php b/src/blocks.php index bded1b7..7eea7e4 100644 --- a/src/blocks.php +++ b/src/blocks.php @@ -16,45 +16,45 @@ function wpstrava_register_block() { // automatically load dependencies and version $asset_file = include WPSTRAVA_PLUGIN_DIR . 'build/index.asset.php'; - wp_enqueue_script( + wp_register_script( 'wp-strava-block', plugins_url( 'build/index.js', WPSTRAVA_PLUGIN_FILE ), $asset_file['dependencies'], $asset_file['version'] ); - wp_enqueue_style( + wp_register_style( 'wp-strava-block-editor', plugins_url( 'build/editor.css', WPSTRAVA_PLUGIN_FILE ), array( 'wp-edit-blocks' ), filemtime( WPSTRAVA_PLUGIN_DIR . 'build/editor.css' ) ); - wp_enqueue_style( + wp_register_style( 'wp-strava-block', plugins_url( 'build/style.css', WPSTRAVA_PLUGIN_FILE ), array(), filemtime( WPSTRAVA_PLUGIN_DIR . 'build/style.css' ) ); - // register_block_type( - // 'wp-strava-block', - // array( - // 'style' => 'wp-strava-block', - // 'editor_style' => 'wp-strava-block-editor', - // 'editor_script' => 'wp-strava-block', - // 'render_callback' => 'wpstrava_activity_render_block', - // ) - // ); + register_block_type( + 'wp-strava/activity', + array( + 'style' => 'wp-strava-block', + 'editor_style' => 'wp-strava-block-editor', + 'editor_script' => 'wp-strava-block', + 'render_callback' => 'wpstrava_activity_render_block', + ) + ); - // 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-block', 'wp-strava' ); - // } + 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-block', 'wp-strava' ); + } } add_action( 'init', 'wpstrava_register_block' ); diff --git a/src/blocks/activity/index.js b/src/blocks/activity/index.js index 232aafb..335474b 100644 --- a/src/blocks/activity/index.js +++ b/src/blocks/activity/index.js @@ -5,6 +5,6 @@ registerBlockType( 'wp-strava/activity', { title: 'Strava Activity', icon: 'chart-line', category: 'widgets', - edit: () => , + edit: () => , save: () =>
Hola, mundo!
, } ); diff --git a/src/index.js b/src/index.js index 44e0cb3..2214244 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1 @@ -console.log('LOLBBQ'); -console.log('WTF'); - import './blocks/activity'; -