From f4211ca880193f82d67116143364c85e1a6fd6fc Mon Sep 17 00:00:00 2001 From: Justin Foell <630830+jrfoell@users.noreply.github.com> Date: Fri, 26 Nov 2021 13:06:21 -0600 Subject: [PATCH 1/2] Added some transformations --- src/blocks/activity/index.js | 46 ++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/src/blocks/activity/index.js b/src/blocks/activity/index.js index 333c154..cf2cb16 100644 --- a/src/blocks/activity/index.js +++ b/src/blocks/activity/index.js @@ -9,19 +9,51 @@ metadata.save = () => null; metadata.transforms = { from: [ { - type: "raw", - priority: 10, - isMatch: ( node ) => - node.nodeName === "P" && - node.innerText.startsWith( "https://www.strava.com/activities/" ), - + type: 'raw', + isMatch: ( node ) => { + return ( + node.nodeName === 'P' && + node.innerText.startsWith( 'https://www.strava.com/activities/' ) + ); + }, transform: function( node ) { return createBlock( metadata.name, { url: node.innerText, } ); } + }, + { + type: 'block', + blocks: [ 'core/paragraph' ], + isMatch: ( node ) => { + return node.content.startsWith( 'https://www.strava.com/activities/' ); + }, + transform: function( node ) { + return createBlock( metadata.name, { url: node.content } ); + } + }, + { + type: 'shortcode', + tag: [ 'activity', 'ride' ], + attributes: { + url: { + type: 'string', + shortcode: ( { named: atts } ) => { + return 'https://www.strava.com/activities/' + atts.id; + }, + }, + }, } - ] + ], + to: [ + { + type: 'block', + blocks: [ 'core/paragraph' ], + transform: ( attributes ) => { + return createBlock( 'core/paragraph', { content: attributes.url } ); + } + }, + ], }; registerBlockType( metadata.name, metadata ); From 5cc106aa48329fea3774eba22330b5115f7b8f3e Mon Sep 17 00:00:00 2001 From: Justin Foell <630830+jrfoell@users.noreply.github.com> Date: Fri, 26 Nov 2021 13:09:20 -0600 Subject: [PATCH 2/2] Bumped version --- readme.txt | 6 +++++- wp-strava.php | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/readme.txt b/readme.txt index 70ce305..54bd778 100755 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Contributors: cmanon, jrfoell, lancewillett, dlintott, sebastianerb Tags: strava, activity, bicycle, cycling, biking, running, run, swimming, swim, paddle, kayak, gps, shortcode, widget, plugin, block, blocks Requires at least: 4.6 Tested up to: 5.8 -Stable tag: 2.10.1 +Stable tag: 2.11.0 Requires PHP: 5.3 License: GPLv2 or later @@ -134,6 +134,10 @@ On the WP-Strava settings page you cannot currently remove and add another athle == Changelog == += 2.11.0 = +Added additional block transformations for "Activity" (from: Paragraph, Classic Shortcode; to: Paragraph) + + = 2.10.1 = Reworked settings save with multiple athletes, related to https://wordpress.org/support/topic/wp-strava-error-401-unauthorized/ diff --git a/wp-strava.php b/wp-strava.php index c732c04..416c721 100755 --- a/wp-strava.php +++ b/wp-strava.php @@ -3,7 +3,7 @@ * Plugin Name: WP Strava * Plugin URI: https://wordpress.org/plugins/wp-strava/ * Description: Show your strava.com activity on your WordPress site. Some Icons are Copyright © Yusuke Kamiyamane. All rights reserved. Licensed under a Creative Commons Attribution 3.0 license. - * Version: 2.10.1 + * Version: 2.11.0 * Author: Carlos Santa Cruz, Justin Foell, Lance Willett, Daniel Lintott, Sebastian Erb * License: GPL2 * Text Domain: wp-strava @@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -define( 'WPSTRAVA_PLUGIN_VERSION', '2.10.1' ); +define( 'WPSTRAVA_PLUGIN_VERSION', '2.11.0' ); define( 'WPSTRAVA_PLUGIN_FILE', __FILE__ ); define( 'WPSTRAVA_PLUGIN_DIR', trailingslashit( dirname( __FILE__ ) ) ); define( 'WPSTRAVA_PLUGIN_URL', plugins_url( '/', __FILE__ ) );