Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 12 additions & 18 deletions EMAILCASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Hello, and thank you for joining the Better Deal for Data community!

We're grateful for your endorsement of the BD4D Standard, and excited to welcome you to this movement to unlock the full potential of data to serve society.

This message is to confirm that we have your permission to display your name and affiliation as a BD4D Endorser on our website. We will contact you if we have additional questions regarding your endorsement.
This message is to confirm that we have your permission to display your name (and affiliation if you've provided one) as a BD4D Endorser on our website. We will contact you if we have additional questions regarding your endorsement.

If you would like to sign up for our email newsletter in the future, or if you have feedback, questions, or a data story to share, please do send us a message at info@bd4d.org. We'd love to hear from you!

Expand All @@ -44,6 +44,8 @@ Celine
M Celine Takatsuno
Better Deal for Data, a Tech Matters initiative.
Tech Matters is a nonprofit tech organization.

Follow us on Bluesky (https://bsky.app/profile/bd4d.bsky.social) and LinkedIn (https://www.linkedin.com/company/better-deal-for-data/)
```

---
Expand All @@ -57,10 +59,12 @@ Hello, and thank you for joining the Better Deal for Data community!
We're grateful for your endorsement of the BD4D Standard, and excited to welcome you to this movement to unlock the full potential of data to serve society.

This message is to confirm:
• We have permission to display your name and affiliation as a BD4D Endorser on our website; and

• We have permission to display your name (and affiliation if you've provided one) as a BD4D Endorser on our website; and

• You have subscribed to our email updates via our website. If you wish to unsubscribe from our email updates, please reply to this email with the word "Unsubscribe."

We'd love to hear your feedback, questions, or stories about data! You can reach us at info@bd4d.org.
We'd love to hear your feedback, questions, or stories about data! You can reach us at info@bd4d.org, and follow us on Bluesky (https://bsky.app/profile/bd4d.bsky.social) and LinkedIn (https://www.linkedin.com/company/better-deal-for-data/)!

All the best,
Celine
Expand All @@ -81,7 +85,7 @@ Hello, and welcome to the Better Deal for Data community–we're excited to supp

We'd love to learn more about how you work with data for good, and answer any questions you have about the BD4D Commitments, BD4D Playbook, or implementation. We will contact you personally within the next two business days.

In the meantime, please don't hesitate to contact us at info@bd4d.org to share any feedback or ideas.
In the meantime, please don't hesitate to contact us at info@bd4d.org to share any feedback or ideas, and follow us on Bluesky (https://bsky.app/profile/bd4d.bsky.social) and LinkedIn (https://www.linkedin.com/company/better-deal-for-data/).

Many thanks,
Celine
Expand All @@ -94,19 +98,9 @@ Tech Matters is a nonprofit tech organization.

---

## Case E: No checkboxes selected (email provided)
## Case E: No checkboxes selected
Newsletter: ✗ | Endorser: ✗ | Adoption: ✗

```
Hello, and thank you for joining the Better Deal for Data community!

We're excited to welcome you to the movement to unlock the full potential of data to serve society.

All the best,
Celine

M Celine Takatsuno
Better Deal for Data, a Tech Matters initiative.
Tech Matters is a nonprofit tech organization.
```
**No auto-reply email is sent.** The submission is still recorded in Airtable and the on-page
success message is shown, but a confirmation email is only sent when the user opts into at least one
of newsletter / endorser / adoption (Cases A–D).
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ The plugin writes form submissions to Airtable via the REST API (`https://api.ai
| `Adoption?` | Adoption checkbox | Boolean | Always sent |
| `CotW-Opted In?` | _Supporter checkbox — removed from form (v1.0.6); field retained for historical opt-ins_ | Boolean | No longer sent |

**Note:** At least one of `Email Address` or `Form Comments` must be provided for submission.
**Note:** First and Last Name are required. Email Address is required only when an opt-in checkbox (newsletter / endorser / adoption) is checked; otherwise it is optional.

### Key Files

Expand Down
2 changes: 1 addition & 1 deletion wp-content/plugins/bd4d/assets/js/main.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 36 additions & 20 deletions wp-content/plugins/bd4d/assets/js/main.src.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion wp-content/plugins/bd4d/assets/js/main.src.js.map

Large diffs are not rendered by default.

56 changes: 36 additions & 20 deletions wp-content/plugins/bd4d/assets/js/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ window.bd4d = {
} );
},

getFreshNonce: function() {

// The contact form page is cached, so the nonce baked into its HTML can
// be stale or expired by submit time (which fails as a 403). Fetch a
// fresh one from the never-cached admin-ajax endpoint instead, falling
// back to the baked-in nonce if the request fails.
return new Promise( function( resolve ) {
jQuery.ajax( {
type: 'POST',
url: localize._ajax_url,
data: { action: 'bd4d_nonce' },
timeout: 15000,
success: ( res ) => resolve( res?.data?.nonce || localize._ajax_nonce ),
error: () => resolve( localize._ajax_nonce )
} );
} );
},

processSubscription: function( event ) {
const submitButton = document.querySelector( 'input[type="submit"]' );
const originalButtonText = submitButton.value;
Expand Down Expand Up @@ -89,19 +107,12 @@ window.bd4d = {
return;
}

if ( ! emailAddress && ! message ) {
event.target
.querySelectorAll( '#inline-subscribe-email,#inline-subscribe-message' )
.forEach( ( item ) => item.classList.add( 'has-error' ) );
event.target.querySelector( '.error-message' ).textContent = localize.error_codes[6];
window.bd4d.resetButton( submitButton, originalButtonText );
return;
}

// Fetch a fresh reCAPTCHA token, then send. Doing this at submit time
// (rather than at page load) avoids expired-token failures for people
// who spend more than ~2 minutes filling out the form.
window.bd4d.getRecaptchaToken().then( ( token ) => {
// Fetch a fresh reCAPTCHA token and a fresh nonce at submit time, then
// send. The reCAPTCHA token expires ~2 min after generation, and the
// nonce baked into the cached page can be stale (causing a 403), so both
// are refreshed here rather than trusting the page-load values.
Promise.all( [ window.bd4d.getFreshNonce(), window.bd4d.getRecaptchaToken() ] ).then( ( [ nonce, token ] ) => {
data._ajax_nonce = nonce;
data.token = token;

jQuery.ajax( {
Expand All @@ -118,15 +129,20 @@ window.bd4d = {
.querySelectorAll( '#joinbd4dnet .et_pb_text_inner,#joinbd4dnet .form-fields' )
.forEach( ( item ) => item.classList.add( 'hidden' ) );
event.target.querySelector( '.message' ).classList.remove( 'hidden' );
if ( emailAddress ) {
event.target
.querySelectorAll( '.message .yes-email' )
.forEach( ( item ) => item.classList.remove( 'hidden' ) );

// Pick the success message: any opt-in checked -> "watch your
// inbox"; otherwise it depends on whether a comment was given.
let messageVariant;
if ( newsletter.checked || endorser.checked || adoption.checked ) {
messageVariant = '.msg-optin';
} else if ( message ) {
messageVariant = '.msg-comment';
} else {
event.target
.querySelectorAll( '.message .no-email' )
.forEach( ( item ) => item.classList.remove( 'hidden' ) );
messageVariant = '.msg-nocomment';
}
event.target
.querySelectorAll( '.message ' + messageVariant )
.forEach( ( item ) => item.classList.remove( 'hidden' ) );
} else {
let errorMessage = localize.error_codes[res?.data?.error_code];
if ( 4 === res?.data?.error_code ) {
Expand Down
4 changes: 2 additions & 2 deletions wp-content/plugins/bd4d/bd4d.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
* Author: Tech Matters
* Text Domain: bd4d
* Domain Path: /languages
* Version: 1.0.6
* Version: 1.0.8
* Requires at least: 6.2
*
* @package BD4D
*/

defined( 'ABSPATH' ) || exit;
define( 'BD4D_VERSION', '1.0.6' );
define( 'BD4D_VERSION', '1.0.8' );

require_once __DIR__ . '/includes/class-bd4d.php';
require_once __DIR__ . '/includes/settings/class-settings.php';
Expand Down
Loading
Loading