diff --git a/gumroad/README.txt b/gumroad/README.txt index 16ea74f..6fded27 100644 --- a/gumroad/README.txt +++ b/gumroad/README.txt @@ -2,8 +2,8 @@ Contributors: karloscarweber, pderksen, nickyoung87, gumroad Tags: gumroad, gumroad product pages, gumroad overlay, gumroad embed, ecommerce, e-commerce, pdf, javascript, overlay, embed Requires at least: 3.9 -Tested up to: 4.9.6 -Stable tag: 2.1 +Tested up to: 5.7.1 +Stable tag: 3.0.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -11,21 +11,23 @@ Make your Gumroad products available for purchase right within WordPress. == Description == -This plugin lets you embed Gumroad into your website, using our Overlay and Embed widgets: https://gumroad.com/widgets +This plugin lets you embed Gumroad into your website, using our Overlay and Embed widgets: https://gumroad.com/widgets. Zero coding knowledge is required. Once installed, all links to Gumroad will automatically open the Gumroad Overlay (lightbox popup). -For more information on how this plugin works, you can see a video on our Overlay here: https://www.youtube.com/watch?v=u80Ey6lSRyE +For more information on how this plugin works, you can see a video on our Overlay here: https://www.youtube.com/watch?v=u80Ey6lSRyE. You can also use shortcodes: -Basic overlay example: `[gumroad id="DviQY"]` +Basic overlay example: `[gumroad url="https://gumroad.com/l/DviQY"]` -Basic embed example: `[gumroad id="GAPdj" type="embed"]` +Basic embed example: `[gumroad url="https://gumroad.com/l/GAPdj" type="embed"]` -Overlay that will automatically show the payment form: `[gumroad id="DviQY" text="Purchase Item" wanted="true"]` +Overlay that will automatically show the payment form: `[gumroad url="https://gumroad.com/l/DviQY" text="Purchase Item" wanted="true"]` -The ID ("GAPdJ") is the same as your Gumroad product URL ("gumroad.com/l/GAPdJ"). See the full documentation in Settings > Gumroad after the plugin is activated. +Overlay for an affiliated product: `[gumroad url="https://gumroad.com/a/919237747/llNDe" type="overlay"]` + +See the full documentation in Settings > Gumroad after the plugin is activated. == Installation == @@ -69,6 +71,10 @@ See the official Gumroad [overlay](https://gumroad.com/overlay) or [embed](https == Changelog == += 3.0.0 - April 30, 2021 = + +* Add support for specifying both regular and affiliated product URLs in Gumroad Block as well as short codes. + = 1.2.4 - January 30, 2019 = * Add Gutenberg Blocks diff --git a/gumroad/assets/images/gumroad-wp-007.png b/gumroad/assets/images/gumroad-wp-007.png new file mode 100644 index 0000000..7016aed Binary files /dev/null and b/gumroad/assets/images/gumroad-wp-007.png differ diff --git a/gumroad/dist/blocks.build.js b/gumroad/dist/blocks.build.js index 7d76a48..2ec8551 100644 --- a/gumroad/dist/blocks.build.js +++ b/gumroad/dist/blocks.build.js @@ -1 +1 @@ -!function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});n(1)},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==typeof t&&"function"!==typeof t?e:t}function a(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var l=n(2),u=(n.n(l),function(){function e(e,t){for(var n=0;n', esc_attr( $id ) ); +function gum_embed( $args ) { + return sprintf( '
', esc_attr( $args['url'] ) ); } /** diff --git a/gumroad/includes/scanner.php b/gumroad/includes/scanner.php index 147eea1..b3deb89 100644 --- a/gumroad/includes/scanner.php +++ b/gumroad/includes/scanner.php @@ -24,7 +24,7 @@ function gum_post_scanner( $post_object ) { function scanner( $post_content ) { // counts to see if we find any gumroad product links. - if (count(preg_grep('/(gumroad.com\/l\/[[:alnum:]]|gum.co\/[[:alnum:]])/', explode("\n", $post_content))) > 0) { + if (count(preg_grep('/(gumroad.com\/a\/[[:alnum:]]+\/[[:alnum:]]|gumroad.com\/l\/[[:alnum:]]|gum.co\/[[:alnum:]])/', explode("\n", $post_content))) > 0) { gum_load_js('overlay'); } if (count(preg_grep('/(class=\"gumroad-product-embed\")/', explode("\n", $post_content))) > 0) { diff --git a/gumroad/includes/shortcodes.php b/gumroad/includes/shortcodes.php index 4f55a33..60a59a7 100644 --- a/gumroad/includes/shortcodes.php +++ b/gumroad/includes/shortcodes.php @@ -20,6 +20,7 @@ function gum_gumroad_shortcode( $attr ) { $defaults = array( 'id' => '', + 'url' => '', 'type' => 'none', // none, overlay, embed 'class' => '', 'text' => 'I want this!', @@ -33,11 +34,21 @@ function gum_gumroad_shortcode( $attr ) { $attr = array_merge( $defaults, $attr ); - if( ! empty( $id ) ) { + if( ! empty( $id ) || ! empty( $url ) ) { // link behaviour + if ( ! empty( $url ) ) { + // Embed widget doesn't work with alias domain URLs + $attr['url'] = str_replace('gum.co/a/', 'gumroad.com/a/', $attr['url']); + $attr['url'] = str_replace('gum.co/', 'gumroad.com/l/', $attr['url']); + } + + if ( empty( $attr['url'] ) && ! empty( $id ) ) { + $attr['url'] = 'https://gumroad.com/l/' . $id; + } + if ( $type == 'embed') { // Embed - $html = gum_embed( $id ); + $html = gum_embed( $attr ); } else if ( $type == 'overlay' ) { // Overlay $html = gum_overlay( $attr ); } else { // Default diff --git a/gumroad/package.json b/gumroad/package.json index 8994cae..38e45cf 100644 --- a/gumroad/package.json +++ b/gumroad/package.json @@ -1,6 +1,6 @@ { "name": "wp-gumroad", - "version": "2.1.0", + "version": "3.0.0", "private": true, "scripts": { "start": "cgb-scripts start", diff --git a/gumroad/src/gumroad-block/block.js b/gumroad/src/gumroad-block/block.js index f737c09..c12d715 100644 --- a/gumroad/src/gumroad-block/block.js +++ b/gumroad/src/gumroad-block/block.js @@ -24,7 +24,7 @@ const { const gumroadURL = 'https://gumroad.com/l/demo'; const defaultID = 'demo'; -const gumroadURLRegex = /(https:\/\/gumroad\.com\/l\/)|(https:\/\/gumroad\.com\/)|(https:\/\/gum\.co\/l\/)|(https:\/\/gum\.co\/)/g; +const gumroadURLRegex = /(https:\/\/gumroad\.com\/a\/[[:alnum:]]+\/)|(https:\/\/gumroad\.com\/l\/)|(https:\/\/gumroad\.com\/)|(https:\/\/gum\.co\/)/g; class GumControls extends Component { constructor( props ) { @@ -223,6 +223,11 @@ registerBlockType( 'gumroad/gumroad-block', { var urlString = url, wantedString = '', classesString = classes; + // Embed widget doesn't work with alias domain URLs + urlString = urlString + .replace("gum.co/a/", "gumroad.com/a/") + .replace("gum.co/", "gumroad.com/l/"); + // Wanted if (wanted == 'true' || wanted == true) { wantedString = '?wanted=true'; @@ -237,7 +242,7 @@ registerBlockType( 'gumroad/gumroad-block', { if ( type == 'embed' ) { return ( // return if link behavior normal -
+
) } else if ( type == 'overlay' ) { // overlay links diff --git a/gumroad/views/admin.php b/gumroad/views/admin.php index b0db43b..4b45fa3 100644 --- a/gumroad/views/admin.php +++ b/gumroad/views/admin.php @@ -47,7 +47,7 @@

Using Shortcodes

-

For version 5.0:

+

For WordPress version 5.0:

Open the Editor and either type / or click on the plus icon and then choose to add a shortcode.

@@ -55,21 +55,27 @@

-

With the Shortcode Block you can use shortcodes normally like you would in version 4.9.

+

With the Shortcode Block you can use shortcodes normally like you would in WordPress version 4.9.

- +

-

For version 4.9.2 and lower:

+

For WordPress version 4.9.2 and lower:

-

Use the shortcode [gumroad id="DviQY"] to add a normal link (anchor tag) to a Gumroad product with the text "I want this!". Clicking this link will not trigger the overlay. +

Use the shortcode [gumroad url="https://gumroad.com/l/DviQY"] to add a normal link (anchor tag) to a Gumroad product with the text "I want this!". Clicking this link will not trigger the overlay. -

Use the shortcode [gumroad id="DviQY" button="true"] to add a button to a Gumroad product. This button will be purely cosmetic. +

Use the shortcode [gumroad url="https://gumroad.com/l/DviQY" button="true"] to add a button to a Gumroad product. This button will be purely cosmetic. -

Use the shortcode [gumroad id="DviQY" type="overlay"] to add a link to a Gumroad product that will open in an overlay.

+

Use the shortcode [gumroad url="https://gumroad.com/l/DviQY" type="overlay"] to add a link to a Gumroad product that will open in an overlay.

-

Use the shortcode [gumroad id="GAPdj" type="embed"] to add an embedded Gumroad product.

+

Use the shortcode [gumroad url="https://gumroad.com/l/GAPdj" type="embed"] to add an embedded Gumroad product.

+ +

Similarly,

+ +

Use the shortcode [gumroad url="https://gumroad.com/a/919237747/llNDe" type="overlay"] to add a link to an affiliated Gumroad product that will open in an overlay.

+ +

Use the shortcode [gumroad url="https://gumroad.com/a/919237747/llNDe" type="embed"] to add an embedded affiliated Gumroad product.

Available attributes for a shortcode:

@@ -77,6 +83,7 @@ Attribute + Required? Description Options Default @@ -84,37 +91,48 @@ - id - Gumroad product ID - Any valid Gumroad product ID, What is my Gumroad product ID? + url + Yes + Gumroad product URL + + + none type + No The type of product link you want to show. none, overlay, embed none text + No Text for the link or button (applies to overlay only). Any text I want this! wanted + No If true, user will be sent directly to the checkout form (applies to overlay only). true if wanted, otherwise leave unspecified False button + No An option to change the gumroad link into a Gumroad button. true, false False class + No An optional class that you can add to gumroad buttons and links Text including letters, numbers, and dashes. A space separates multiple classes none @@ -125,17 +143,17 @@

More examples

Automatic linking and embeds

-

You can forego using shortcodes entirely, and links to Gumroad products will automatically trigger the overlay. Embed code copied from the Gumroad product widget will also work without including the script tag:

+

You can forego using shortcodes entirely, and links to Gumroad products will automatically trigger the overlay. Embed code copied from the Gumroad product widget will also work without including the script tag:

- <div class="gumroad-product-embed" data-gumroad-product-id="DviQY"><a href="https://gumroad.com/l/qLlJJ">Loading...</a></div> + <div class="gumroad-product-embed"><a href="https://gumroad.com/l/DviQY">Loading...</a></div>