diff --git a/src/blocks/donate/edit.js b/src/blocks/donate/edit.js
index 20d850422..404520889 100644
--- a/src/blocks/donate/edit.js
+++ b/src/blocks/donate/edit.js
@@ -50,7 +50,7 @@ class Edit extends Component {
/* If block is in "manual" mode, override certain state properties with values stored in attributes */
blockData() {
const { attributes } = this.props;
- const { manual } = attributes;
+ const { manual, campaign } = attributes;
const data = { ...this.state, ...( manual ? attributes : {} ) };
if ( manual ) {
data.customDonationAmounts = {
@@ -59,6 +59,7 @@ class Edit extends Component {
year: data.tiered ? 12 * data.suggestedAmounts[ 1 ] : 12 * data.suggestedAmountUntiered,
};
}
+ data.campaign = campaign;
return data;
}
@@ -437,7 +438,8 @@ class Edit extends Component {
}
render() {
- const { manual } = this.blockData();
+ const { setAttributes } = this.props;
+ const { manual, campaign } = this.blockData();
return (
{ this.renderPlaceholder() }
@@ -470,6 +472,17 @@ class Edit extends Component {
{ this.renderManualControls() }
) }
+
+
+ setAttributes( {
+ campaign: value,
+ } )
+ }
+ />
+
);
diff --git a/src/blocks/donate/index.js b/src/blocks/donate/index.js
index 008dc49f8..8dd54517c 100644
--- a/src/blocks/donate/index.js
+++ b/src/blocks/donate/index.js
@@ -55,6 +55,9 @@ export const settings = {
type: 'boolean',
default: true,
},
+ campaign: {
+ type: 'string',
+ },
},
supports: {
html: false,
diff --git a/src/blocks/donate/view.php b/src/blocks/donate/view.php
index ca41d8fe6..57db86fbe 100644
--- a/src/blocks/donate/view.php
+++ b/src/blocks/donate/view.php
@@ -38,6 +38,8 @@ function newspack_blocks_render_block_donate( $attributes ) {
$selected_frequency = 'month';
$suggested_amounts = $settings['suggestedAmounts'];
+ $campaign = $attributes['campaign'] ?? false;
+
$uid = rand(); // Unique identifier to prevent labels colliding with other instances of Donate block.
ob_start();
@@ -102,6 +104,9 @@ class='donate-label'
+
+
+
+
+
+
'boolean',
'default' => true,
],
+ 'campaign' => [
+ 'type' => 'string',
+ ]
),
'render_callback' => 'newspack_blocks_render_block_donate',
)