Skip to content

Commit

Permalink
Eventbrite block: add link to saved HTML (#14510)
Browse files Browse the repository at this point in the history
* Eventbrite: add a link to the saved modal HTML

This will allow displaying useful info in RSS feeds / subscriptions emails, or when one disables the Jetpack plugin.

* Add CSS to hide the direct link.

* Enqueue CSS when not using modal view

* Add link to button as well
  • Loading branch information
jeherve authored Jan 30, 2020
1 parent 8e6df97 commit 791a349
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
3 changes: 3 additions & 0 deletions extensions/blocks/eventbrite/eventbrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ function jetpack_render_eventbrite_block( $attr, $content ) {

wp_enqueue_script( 'eventbrite-widget', 'https://www.eventbrite.com/static/widgets/eb_widgets.js', array(), JETPACK__VERSION, true );

// Add CSS to hide direct link.
Jetpack_Gutenberg::load_assets_as_required( 'eventbrite' );

// Show the embedded version.
if ( empty( $attr['useModal'] ) ) {
wp_add_inline_script(
Expand Down
18 changes: 16 additions & 2 deletions extensions/blocks/eventbrite/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function saveButton( eventId, attributes ) {
customTextColor,
text,
textColor,
url,
} = attributes;

const textClass = getColorClassName( 'color', textColor );
Expand Down Expand Up @@ -56,12 +57,17 @@ function saveButton( eventId, attributes ) {
value={ text }
type="button"
/>
{ url && (
<a className="eventbrite__direct-link" href={ url }>
{ url }
</a>
) }
</div>
);
}

export default function save( { attributes } ) {
const { eventId, useModal } = attributes;
const { eventId, useModal, url } = attributes;

if ( ! eventId ) {
return;
Expand All @@ -71,5 +77,13 @@ export default function save( { attributes } ) {
return saveButton( eventId, attributes );
}

return <div id={ createWidgetId( eventId ) } />;
return (
<div id={ createWidgetId( eventId ) }>
{ url && (
<a className="eventbrite__direct-link" href={ url }>
{ url }
</a>
) }
</div>
);
}
5 changes: 5 additions & 0 deletions extensions/blocks/eventbrite/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.wp-block-jetpack-eventbrite {
a.eventbrite__direct-link {
display: none;
}
}
4 changes: 4 additions & 0 deletions extensions/blocks/eventbrite/view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Internal dependencies
*/
import './style.scss';

0 comments on commit 791a349

Please sign in to comment.