Changeset 3827809
- Timestamp:
- 11/26/2026 05:27:07 PM (less than one hour ago)
- Location:
- nonprofit-manager/trunk
- Files:
-
- 1 added
- 20 edited
-
includes/activation-hooks.php (modified) (4 diffs)
-
includes/email-newsletter/class-newsletter-manager.php (modified) (8 diffs)
-
includes/email-newsletter/editor.php (modified) (1 diff)
-
includes/email/helpers.php (modified) (4 diffs)
-
includes/import/admin-import.php (modified) (2 diffs)
-
includes/import/import-hub.php (modified) (1 diff)
-
includes/npmp-calendar.php (modified) (1 diff)
-
includes/npmp-content-blocks.php (modified) (2 diffs)
-
includes/npmp-dashboard-widgets.php (modified) (5 diffs)
-
includes/npmp-event-ics.php (modified) (1 diff)
-
includes/npmp-ics.php (modified) (5 diffs)
-
includes/npmp-payments-settings.php (modified) (5 diffs)
-
includes/npmp-pro-feature-pages.php (modified) (1 diff)
-
includes/npmp-scheduled-emails.php (modified) (5 diffs)
-
includes/npmp-setup-wizard.php (modified) (1 diff)
-
includes/npmp-subscription-preferences.php (modified) (2 diffs)
-
includes/payments/class-donation-manager.php (modified) (5 diffs)
-
includes/payments/npmp-payment-gateways.php (modified) (10 diffs)
-
includes/payments/npmp-stripe-webhook.php (added)
-
nonprofit-manager.php (modified) (2 diffs)
-
readme.txt (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
nonprofit-manager/trunk/includes/activation-hooks.php
r3812378 r3827809 58 58 npmp_create_donations_table(); 59 59 npmp_create_contacts_table(); 60 npmp_ create_newsletter_queue_table();60 npmp_upgrade_newsletter_queue_table(); 61 61 npmp_create_newsletter_opens_table(); 62 62 npmp_create_newsletter_clicks_table(); … … 550 550 551 551 /** 552 * The newsletter queue table's schema version. Raise it with every change to 553 * npmp_create_newsletter_queue_table(), and teach 554 * npmp_newsletter_queue_schema_complete() the new pieces. 555 * 556 * 2 (the release after 2026.11.26): attempts and retry_at, so a failed send 557 * waits and tries again, and the status_queued index the per-minute drain 558 * reads. 559 */ 560 const NPMP_NEWSLETTER_QUEUE_DB_VERSION = '2'; 561 562 /** 552 563 * Create (or update) the newsletter queue table. 564 * 565 * dbDelta() adds what an existing table lacks, so this upgrades a table from 566 * an older release too. It only adds: it never drops a column or touches a 567 * row. 568 * 569 * attempts counts the sends tried for a row, and retry_at (UTC) holds a row 570 * that failed back until its next try. status_queued serves the drain's 571 * query (status = 'pending', ordered by queued_at and id), and its last 572 * column lets MySQL skip rows waiting for a retry without reading them. 553 573 * 554 574 * @return void … … 568 588 queued_at DATETIME, 569 589 sent_at DATETIME NULL, 590 attempts TINYINT UNSIGNED NOT NULL DEFAULT 0, 591 retry_at DATETIME NULL, 570 592 PRIMARY KEY (id), 571 KEY newsletter_status (newsletter_id,status) 593 KEY newsletter_status (newsletter_id,status), 594 KEY status_queued (status,queued_at,id,retry_at) 572 595 ) {$charset};"; 573 596 … … 577 600 578 601 /** 579 * Ensure the newsletter queue table exists on sites that activated the plugin 580 * before the send queue moved off the npmp_nl_queue post type and into this 581 * dedicated table (activation hooks only run on a fresh activation, not on 582 * every already-active install). Belt-and-braces alongside the activation-time 583 * creation above, same reasoning as the other npmp_maybe_create_*_table() 584 * functions in this file. 585 * 586 * @return void 602 * Whether the queue table has everything schema version 603 * NPMP_NEWSLETTER_QUEUE_DB_VERSION adds, read from the live table. 604 * 605 * @return bool 606 */ 607 function npmp_newsletter_queue_schema_complete() { 608 global $wpdb; 609 $table = $wpdb->prefix . 'npmp_newsletter_queue'; 610 611 // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Schema check on a fixed table name, the same reads dbDelta() makes. 612 $columns = (array) $wpdb->get_results( "SHOW COLUMNS FROM {$table}" ); 613 $indexes = (array) $wpdb->get_results( "SHOW INDEX FROM {$table}" ); 614 // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.PreparedSQL.InterpolatedNotPrepared 615 616 return npmp_newsletter_queue_schema_missing( wp_list_pluck( $columns, 'Field' ), wp_list_pluck( $indexes, 'Key_name' ) ) === array(); 617 } 618 619 /** 620 * What the queue table still lacks, by name. 621 * 622 * @param string[] $columns Column names the table has. 623 * @param string[] $indexes Index names the table has. 624 * @return string[] Missing column and index names, empty when it's complete. 625 */ 626 function npmp_newsletter_queue_schema_missing( $columns, $indexes ) { 627 $have = array_map( 'strtolower', array_merge( (array) $columns, (array) $indexes ) ); 628 return array_values( array_diff( array( 'attempts', 'retry_at', 'status_queued' ), $have ) ); 629 } 630 631 /** 632 * Whether the queue table is on the current schema, so the drain may use 633 * attempts and retry_at. Until it is, the drain runs the way 2026.11.26 did. 634 * 635 * @return bool 636 */ 637 function npmp_newsletter_queue_has_retries() { 638 return NPMP_NEWSLETTER_QUEUE_DB_VERSION === (string) get_option( 'npmp_newsletter_queue_db_version', '' ); 639 } 640 641 /** 642 * Bring the queue table up to the current schema and record the version. 643 * 644 * One request at a time: a second request that arrives while the first one 645 * alters the table skips the upgrade, and its drain runs the old way. If the 646 * database refuses the change (a user without ALTER, say), we record nothing 647 * and wait an hour before we try again, and the queue keeps sending the old 648 * way meanwhile. 649 * 650 * @return bool True when the table is on the current schema. 651 */ 652 function npmp_upgrade_newsletter_queue_table() { 653 if ( ! npmp_mail_queue_lock( 'newsletter_queue_schema', 600 ) ) { 654 return false; 655 } 656 try { 657 npmp_create_newsletter_queue_table(); 658 if ( ! npmp_newsletter_queue_schema_complete() ) { 659 set_transient( 'npmp_newsletter_queue_db_retry_later', 1, HOUR_IN_SECONDS ); 660 return false; 661 } 662 update_option( 'npmp_newsletter_queue_db_version', NPMP_NEWSLETTER_QUEUE_DB_VERSION ); 663 // The setup wizard reads this flag as a sign of an earlier install. 664 update_option( 'npmp_newsletter_queue_table_created', 1 ); 665 delete_transient( 'npmp_newsletter_queue_db_retry_later' ); 666 return true; 667 } finally { 668 npmp_mail_queue_unlock( 'newsletter_queue_schema' ); 669 } 670 } 671 672 /** 673 * Create or upgrade the newsletter queue table once after an install or an 674 * update. Activation runs only on a fresh activation, never on an update, so 675 * this is how an existing site gets the new schema. 676 * 677 * Until 2026.11.26 a flag (npmp_newsletter_queue_table_created) ran this 678 * once, so no later change could reach an existing table. The schema version 679 * option decides now. 680 * 681 * We call it from the queue drain (NPMP_Newsletter_Manager::process_queue()) 682 * and from an admin's screen load, never from a visitor's page: on a table 683 * with millions of sent rows the new index takes a while to build, and a 684 * visitor's request could time out waiting for it. 685 * 686 * @return bool True when the table is on the current schema. 587 687 */ 588 688 function npmp_maybe_create_newsletter_queue_table() { 589 if ( get_option( 'npmp_newsletter_queue_table_created', false ) ) { 590 return; 591 } 592 593 npmp_create_newsletter_queue_table(); 594 update_option( 'npmp_newsletter_queue_table_created', 1 ); 595 } 596 add_action( 'plugins_loaded', 'npmp_maybe_create_newsletter_queue_table', 40 ); 689 if ( npmp_newsletter_queue_has_retries() ) { 690 return true; 691 } 692 if ( get_transient( 'npmp_newsletter_queue_db_retry_later' ) ) { 693 return false; 694 } 695 return npmp_upgrade_newsletter_queue_table(); 696 } 697 698 /** 699 * Upgrade the queue table when an admin opens a wp-admin screen, so a site 700 * whose cron rarely runs still gets the new schema. Visitors' forms post to 701 * admin-ajax.php and admin-post.php, which fire admin_init too, so we skip 702 * Ajax and anyone who can't manage options. 703 * 704 * @return void 705 */ 706 function npmp_maybe_upgrade_newsletter_queue_in_admin() { 707 if ( wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { 708 return; 709 } 710 npmp_maybe_create_newsletter_queue_table(); 711 } 712 add_action( 'admin_init', 'npmp_maybe_upgrade_newsletter_queue_in_admin' ); 597 713 598 714 /** -
nonprofit-manager/trunk/includes/email-newsletter/class-newsletter-manager.php
r3806368 r3827809 8 8 // as the old constant name claimed. 9 9 const EMAILS_PER_RUN = 10; 10 11 // A batch stops starting sends after this many seconds, so it ends well 12 // inside the run lock's 300 seconds (npmp_mail_queue_batch_continues()). 13 const BATCH_SECONDS = 240; 14 15 // A batch stops after this many failed sends in a row. When the mail 16 // server is down, every row tried would use up a try, so we leave the 17 // rest of the queue waiting until the server answers again. 18 const FAILURES_IN_A_ROW = 3; 19 10 20 const QUEUE_POST_TYPE = 'npmp_nl_queue'; 11 21 const EVENT_POST_TYPE = 'npmp_nl_event'; … … 252 262 } 253 263 try { 264 // The schema upgrade runs here and on admin screens, never on a 265 // visitor's page load. Inside the lock, so a second cron runner 266 // that starts meanwhile leaves the table alone. 267 if ( function_exists( 'npmp_maybe_create_newsletter_queue_table' ) ) { 268 npmp_maybe_create_newsletter_queue_table(); 269 } 254 270 self::drain_queue_batch(); 255 271 } finally { … … 259 275 260 276 /** 277 * Seconds to wait before each new try of a send that failed, in order. 278 * The count is the number of retries, so a row gets one try plus one per 279 * entry before we mark it failed. The default waits 5, 15, and 45 280 * minutes, which carries a send through about an hour of mail server 281 * trouble. 282 * 283 * @return int[] 284 */ 285 public static function retry_delays() { 286 /** 287 * Filter the waits between tries of a newsletter send that failed. 288 * Return an empty array to mark a failed send failed at once. 289 * 290 * @param int[] $delays Seconds before each retry, in order. 291 */ 292 $delays = apply_filters( 'npmp_newsletter_retry_delays', array( 5 * 60, 15 * 60, 45 * 60 ) ); 293 return is_array( $delays ) ? array_slice( array_map( 'absint', array_values( $delays ) ), 0, 10 ) : array(); 294 } 295 296 /** 297 * What a queue row becomes after a send that failed. 298 * 299 * @param int $attempts Sends tried for the row before this one. 300 * @param int[] $delays From retry_delays(). 301 * @return array{status:string,attempts:int,delay:int} status 'pending' 302 * with the seconds to wait, or 'failed' after the last try. 303 */ 304 public static function after_failed_send( $attempts, $delays ) { 305 $attempts = max( 0, (int) $attempts ) + 1; 306 $delays = array_values( (array) $delays ); 307 if ( $attempts > count( $delays ) ) { 308 return array( 309 'status' => 'failed', 310 'attempts' => $attempts, 311 'delay' => 0, 312 ); 313 } 314 return array( 315 'status' => 'pending', 316 'attempts' => $attempts, 317 'delay' => max( 0, (int) $delays[ $attempts - 1 ] ), 318 ); 319 } 320 321 /** 261 322 * Send one batch of pending queue rows. Call process_queue(), which holds 262 323 * the run lock around this. 263 324 * 325 * We put a send that fails back in the queue with its next try in 326 * retry_delays(), and mark the row failed only after the last try. 327 * Through 2026.11.26 we marked it failed at once, so one minute of mail 328 * server trouble cost that run's whole batch, and we called the newsletter 329 * sent once nothing else waited. 330 * 264 331 * @return void 265 332 */ 266 333 private static function drain_queue_batch() { 267 334 global $wpdb; 268 $table = $wpdb->prefix . 'npmp_newsletter_queue'; 335 $table = $wpdb->prefix . 'npmp_newsletter_queue'; 336 $started = microtime( true ); 337 338 // Until the table has attempts and retry_at, a failed send is final, 339 // the way it was through 2026.11.26. 340 $retries = function_exists( 'npmp_newsletter_queue_has_retries' ) && npmp_newsletter_queue_has_retries(); 269 341 270 342 $limit = intval( get_option( 'npmp_newsletter_rate_limit', self::EMAILS_PER_RUN ) ); … … 276 348 // same queued_at (one queue_newsletter() call), so ordering by 277 349 // queued_at alone would drain them in an undefined order across ticks. 278 $batch = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Dedicated queue table, drained on a per-minute cron. 279 $wpdb->prepare( 280 "SELECT id, newsletter_id, user_id, email FROM {$table} WHERE status = 'pending' ORDER BY queued_at ASC, id ASC LIMIT %d", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Fixed table name, only the LIMIT value is a placeholder. 281 $limit 282 ) 283 ); 350 // The status_queued index serves both queries. 351 if ( $retries ) { 352 $batch = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Dedicated queue table, drained on a per-minute cron. 353 $wpdb->prepare( 354 "SELECT id, newsletter_id, user_id, email, attempts FROM {$table} WHERE status = 'pending' AND ( retry_at IS NULL OR retry_at <= %s ) ORDER BY queued_at ASC, id ASC LIMIT %d", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Fixed table name, the time and the LIMIT are placeholders. 355 gmdate( 'Y-m-d H:i:s' ), 356 $limit 357 ) 358 ); 359 } else { 360 $batch = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Dedicated queue table, drained on a per-minute cron. 361 $wpdb->prepare( 362 "SELECT id, newsletter_id, user_id, email FROM {$table} WHERE status = 'pending' ORDER BY queued_at ASC, id ASC LIMIT %d", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Fixed table name, only the LIMIT value is a placeholder. 363 $limit 364 ) 365 ); 366 } 284 367 285 368 if ( empty( $batch ) ) { … … 293 376 $gone = array(); 294 377 378 /** 379 * Filter how many seconds one queue batch may work before it stops 380 * starting sends. Keep it under 300, the run lock's life. 381 * 382 * @param int $seconds Seconds of work. 383 * @param string $queue 'newsletter' or 'digest'. 384 */ 385 $budget = (float) apply_filters( 'npmp_mail_queue_batch_seconds', self::BATCH_SECONDS, 'newsletter' ); 386 $delays = $retries ? self::retry_delays() : array(); 387 $failed_in_a_row = 0; 388 295 389 // Someone can unsubscribe, or an admin can delete or change a contact, 296 390 // after the newsletter was queued. Look the batch up once and mail … … 299 393 300 394 foreach ( $batch as $row ) { 395 // Rows we don't reach keep waiting, untouched, for the next run. 396 if ( $failed_in_a_row >= self::FAILURES_IN_A_ROW || ! npmp_mail_queue_batch_continues( 'newsletter', $started, $budget ) ) { 397 break; 398 } 399 301 400 $queue_id = (int) $row->id; 302 401 $newsletter_id = (int) $row->newsletter_id; … … 355 454 } 356 455 456 $tries = isset( $row->attempts ) ? (int) $row->attempts : 0; 457 if ( $sent ) { 458 $failed_in_a_row = 0; 459 $data = array( 460 'status' => 'sent', 461 'sent_at' => current_time( 'mysql' ), 462 ); 463 if ( $retries ) { 464 $data['attempts'] = min( 255, $tries + 1 ); 465 } 466 } else { 467 ++$failed_in_a_row; 468 $next = self::after_failed_send( $tries, $delays ); 469 $data = array( 'status' => $next['status'] ); 470 if ( 'failed' === $next['status'] ) { 471 $data['sent_at'] = current_time( 'mysql' ); 472 } 473 if ( $retries ) { 474 $data['attempts'] = min( 255, $next['attempts'] ); 475 if ( 'pending' === $next['status'] ) { 476 $data['retry_at'] = gmdate( 'Y-m-d H:i:s', time() + $next['delay'] ); 477 } 478 } 479 } 480 357 481 $wpdb->update( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Dedicated queue table. 358 482 $table, 359 array( 360 'status' => $sent ? 'sent' : 'failed', 361 'sent_at' => current_time( 'mysql' ), 362 ), 483 $data, 363 484 array( 'id' => $queue_id ), 364 array ( '%s', '%s'),485 array_map( static fn( $column ) => 'attempts' === $column ? '%d' : '%s', array_keys( $data ) ), 365 486 array( '%d' ) 366 487 ); … … 375 496 376 497 // Mark each newsletter drained this run as fully sent once nothing is 377 // left pending for it. Checked once per newsletter after the batch, not 498 // left pending for it. A row waiting for a retry is still pending, so 499 // its newsletter reads queued until the last try. Checked once per newsletter after the batch, not 378 500 // once per email as the old code did. Marking on drain (rather than 379 501 // only inside a successful send, as before) also stops a newsletter -
nonprofit-manager/trunk/includes/email-newsletter/editor.php
r3807949 r3827809 512 512 echo '<p><label for="npmp-newsletter-preheader"><strong>' . esc_html__('Preheader', 'nonprofit-manager') . '</strong></label>'; 513 513 echo '<input type="text" id="npmp-newsletter-preheader" name="npmp_newsletter_preheader" class="widefat" value="' . esc_attr($preheader) . '" placeholder="' . esc_attr__('Short summary that appears next to the subject line.', 'nonprofit-manager') . '"></p>'; 514 echo '<p class="description npmp-newsletter-tags">' . esc_html__('To greet each reader by name, type [first_name] in the subject, preheader, body or template. [first_name default="Member"] fills in a word for contacts with no name. [last_name] and [name] work too.', 'nonprofit-manager') . npmp_email_recipient_tag_help_suffix() . '</p>';514 echo '<p class="description npmp-newsletter-tags">' . esc_html__('To greet each reader by name, type [first_name] in the subject, preheader, body or template. [first_name default="Member"] fills in a word for contacts with no name. You can also use the [last_name] and [name] tags.', 'nonprofit-manager') . npmp_email_recipient_tag_help_suffix() . '</p>'; 515 515 516 516 echo '<fieldset class="npmp-newsletter-audience">'; -
nonprofit-manager/trunk/includes/email/helpers.php
r3803911 r3827809 247 247 * INSERT IGNORE on the options table is atomic, so only one run gets the row. 248 248 * A lock older than $ttl seconds belongs to a run that died and is taken over. 249 * The row holds the time this run last wrote it, and the run remembers that 250 * stamp, so it can keep the lock fresh (npmp_mail_queue_lock_refresh()) and 251 * release only its own lock. 249 252 * 250 253 * @param string $name Queue name, e.g. 'newsletter'. … … 255 258 global $wpdb; 256 259 $option = 'npmp_queue_lock_' . sanitize_key( $name ); 260 $stamp = (string) time(); 257 261 258 262 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Atomic lock, must skip the options cache. 259 $got = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO {$wpdb->options} ( option_name, option_value, autoload ) VALUES ( %s, %s, 'no' )", $option, (string) time()) );263 $got = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO {$wpdb->options} ( option_name, option_value, autoload ) VALUES ( %s, %s, 'no' )", $option, $stamp ) ); 260 264 if ( $got ) { 265 npmp_mail_queue_lock_stamp( $name, $stamp ); 261 266 return true; 262 267 } … … 270 275 // Stale. Take it over only if nobody else did in the meantime. 271 276 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Compare-and-swap on the lock row. 272 return (bool) $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->options} SET option_value = %s WHERE option_name = %s AND option_value = %s", (string) time(), $option, (string) $since ) ); 277 $got = (bool) $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->options} SET option_value = %s WHERE option_name = %s AND option_value = %s", $stamp, $option, (string) $since ) ); 278 if ( $got ) { 279 npmp_mail_queue_lock_stamp( $name, $stamp ); 280 } 281 return $got; 282 } 283 284 /** 285 * The stamp this request last wrote into a lock it holds. 286 * 287 * '' means this request never took the lock, and 'lost' means another run 288 * took it over as stale. 289 * 290 * @param string $name Queue name. 291 * @param string|null $stamp A stamp to remember, '' to forget, null to read. 292 * @return string 293 */ 294 function npmp_mail_queue_lock_stamp( $name, $stamp = null ) { 295 static $stamps = array(); 296 $key = sanitize_key( $name ); 297 if ( '' === $stamp ) { 298 unset( $stamps[ $key ] ); 299 } elseif ( null !== $stamp ) { 300 $stamps[ $key ] = (string) $stamp; 301 } 302 return $stamps[ $key ] ?? ''; 303 } 304 305 /** 306 * Write the time into a lock this request holds, so it stays fresh through a 307 * long run, or learn that another run took it over. 308 * 309 * A run that outlives the lock's $ttl looks dead to the next cron tick, which 310 * takes the lock and reads the same pending rows. Refreshing the lock while 311 * the run still works stops that. 312 * 313 * @param string $name Queue name. 314 * @return bool True while this run still holds the lock. 315 */ 316 function npmp_mail_queue_lock_refresh( $name ) { 317 global $wpdb; 318 $held = npmp_mail_queue_lock_stamp( $name ); 319 if ( '' === $held || 'lost' === $held ) { 320 return false; 321 } 322 $stamp = (string) time(); 323 if ( $stamp === $held ) { 324 return true; 325 } 326 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Compare-and-swap on the lock row. 327 $changed = $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->options} SET option_value = %s WHERE option_name = %s AND option_value = %s", $stamp, 'npmp_queue_lock_' . sanitize_key( $name ), $held ) ); 328 npmp_mail_queue_lock_stamp( $name, $changed ? $stamp : 'lost' ); 329 return (bool) $changed; 330 } 331 332 /** 333 * Whether a queue batch may send one more message. 334 * 335 * The run lock goes stale after 300 seconds. A batch stops once it has worked 336 * $budget seconds, so it ends well inside that, and it refreshes its lock 337 * every 30 seconds in case one slow send carries it past the budget. It stops 338 * as soon as another run holds the lock. 339 * 340 * @param string $name Queue name, as passed to npmp_mail_queue_lock(). 341 * @param float $started microtime( true ) when the batch began. 342 * @param float $budget Seconds of work the batch may use. 343 * @return bool 344 */ 345 function npmp_mail_queue_batch_continues( $name, $started, $budget ) { 346 if ( microtime( true ) - (float) $started >= (float) $budget ) { 347 return false; 348 } 349 $held = npmp_mail_queue_lock_stamp( $name ); 350 if ( 'lost' === $held ) { 351 return false; 352 } 353 if ( '' !== $held && time() - (int) $held >= 30 ) { 354 return npmp_mail_queue_lock_refresh( $name ); 355 } 356 return true; 273 357 } 274 358 275 359 /** 276 360 * Release a lock taken with npmp_mail_queue_lock(). 361 * 362 * Deletes the lock only while it still holds this run's stamp, so a run that 363 * lost its lock to another can't free that other run's lock. 277 364 * 278 365 * @param string $name Queue name. … … 281 368 function npmp_mail_queue_unlock( $name ) { 282 369 global $wpdb; 370 $option = 'npmp_queue_lock_' . sanitize_key( $name ); 371 $held = npmp_mail_queue_lock_stamp( $name ); 372 npmp_mail_queue_lock_stamp( $name, '' ); 373 if ( 'lost' === $held ) { 374 return; 375 } 376 $where = array( 'option_name' => $option ); 377 $formats = array( '%s' ); 378 if ( '' !== $held ) { 379 $where['option_value'] = $held; 380 $formats[] = '%s'; 381 } 283 382 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Pairs with the direct insert above. 284 $wpdb->delete( $wpdb->options, array( 'option_name' => 'npmp_queue_lock_' . sanitize_key( $name ) ), array( '%s' ));285 wp_cache_delete( 'npmp_queue_lock_' . sanitize_key( $name ), 'options' );383 $wpdb->delete( $wpdb->options, $where, $formats ); 384 wp_cache_delete( $option, 'options' ); 286 385 } 287 386 -
nonprofit-manager/trunk/includes/import/admin-import.php
r3803911 r3827809 714 714 $allowed = array( 'mailchimp', 'csv', 'xlsx', 'google_sheet', 'constant_contact', 'brevo' ); 715 715 if ( ! in_array( $source, $allowed, true ) ) { 716 wp_send_json_error( __( ' This import source does not support chunked import.', 'nonprofit-manager' ) );716 wp_send_json_error( __( 'Nonprofit Manager can\'t import from this source in chunks.', 'nonprofit-manager' ) ); 717 717 } 718 718 … … 1344 1344 <label for="npmp-brevo-api-key"><strong><?php esc_html_e( 'Brevo API key', 'nonprofit-manager' ); ?></strong></label><br> 1345 1345 <span class="description"> 1346 <?php esc_html_e( 'In Brevo, open your name in the top corner, then SMTP & API, then API keys, and make a key for this import. We send the key only to Brevo, and only for this import. While the import runs, your site keeps the key locked, so your database alone never holds it. Delete the key in Brevo once you finish.', 'nonprofit-manager' ); ?>1346 <?php esc_html_e( 'In Brevo, open your name in the top corner, then SMTP & API, then API keys, and make a key for this import. We send the key only to Brevo, and only for this import. During the import, we seal the key with a secret only your browser holds, so nobody with only your database can read the key. Delete the key in Brevo once you finish.', 'nonprofit-manager' ); ?> 1347 1347 </span> 1348 1348 </p> -
nonprofit-manager/trunk/includes/import/import-hub.php
r3812376 r3827809 1260 1260 sprintf( 1261 1261 /* translators: %s: old plugin name. */ 1262 __( 'Bring over what you keep in %s. You review everything before you move anything, and you keep the old plugin\'s copy too.', 'nonprofit-manager' ),1262 __( 'Bring over what you keep in %s. You review everything before you move anything, and you also keep the old plugin\'s copy.', 'nonprofit-manager' ), 1263 1263 $source['name'] 1264 1264 ) -
nonprofit-manager/trunk/includes/npmp-calendar.php
r3807949 r3827809 2028 2028 echo '<tr>'; 2029 2029 echo '<td><code>[npmp_calendar print="no"]</code></td>'; 2030 echo '<td>' . esc_html__( 'Hides the Print or save as PDF button on this calendar. It works on [npmp_events] too.', 'nonprofit-manager' ) . '</td>';2030 echo '<td>' . esc_html__( 'Hides the Print or save as PDF button on this calendar. You can set it in the [npmp_events] shortcode.', 'nonprofit-manager' ) . '</td>'; 2031 2031 echo '</tr>'; 2032 2032 -
nonprofit-manager/trunk/includes/npmp-content-blocks.php
r3807949 r3827809 179 179 'fields' => __( 'Please fill in your name, email, and message, then try again.', 'nonprofit-manager' ), 180 180 'send' => __( 'We couldn\'t send your message. Please try again in a few minutes or email us directly.', 'nonprofit-manager' ), 181 'busy' => __( 'We got too many messages in a short time. Please try again in an hour.', 'nonprofit-manager' ), 181 182 ); 182 183 $text = isset( $messages[ $reason ] ) ? $messages[ $reason ] : __( 'We couldn\'t send your message. Please check the fields and try again.', 'nonprofit-manager' ); … … 268 269 if ( '' === $name || ! is_email( $email ) || '' === $message ) { 269 270 wp_safe_redirect( add_query_arg( array( 'npmp_contact' => 'error', 'npmp_contact_reason' => 'fields' ), $redirect ) ); 271 exit; 272 } 273 274 // Every message mails the site's inbox, and anyone holding the page's 275 // nonce can post the form. We cap messages per visitor and site-wide, 276 // the same way the signup form does, so a script can't flood the inbox. 277 // Both caps take the npmp_rate_limit_max filter ('contact_form' and 278 // 'contact_form_site'). Only a message we'd send counts. 279 if ( ! npmp_rate_limit_allows( 'contact_form', 10, HOUR_IN_SECONDS ) || ! npmp_rate_limit_allows( 'contact_form_site', 100, HOUR_IN_SECONDS, 'site' ) ) { 280 wp_safe_redirect( add_query_arg( array( 'npmp_contact' => 'error', 'npmp_contact_reason' => 'busy' ), $redirect ) ); 270 281 exit; 271 282 } -
nonprofit-manager/trunk/includes/npmp-dashboard-widgets.php
r3801295 r3827809 493 493 } 494 494 495 /* 496 * Cache for the Dashboard's donation figures. 497 * 498 * The year-to-date and recurring figures each run a grouped query over every 499 * donation, and the wp-admin Dashboard ran both on every load. We keep each 500 * query's rows for 10 minutes, marked with a token we change whenever a 501 * donation is added, edited, trashed, or deleted. A reader uses cached rows 502 * only when their token matches the current one, so a new gift never shows 503 * stale figures. 504 * 505 * We change the token once per request, at shutdown, after every write in 506 * that request. A Dashboard load that read the rows between a write and that 507 * shutdown stored them under the old token, so the next load reads afresh. A 508 * request that changed a donation reads afresh for the rest of the request. 509 * Only the SQL rows are cached: the run rate's "still due to renew" check and 510 * the npmp_annual_recurring_totals filter run on every load. 511 */ 512 513 /** 514 * Whether this request changed a donation, and mark that it did. 515 * 516 * @param bool $set True to mark the request. 517 * @return bool 518 */ 519 function npmp_dashboard_donations_dirty( $set = false ) { 520 static $dirty = false; 521 if ( $set ) { 522 $dirty = true; 523 } 524 return $dirty; 525 } 526 527 /** 528 * The token cached rows must match. 529 * 530 * @return string 531 */ 532 function npmp_dashboard_donations_token() { 533 return (string) get_option( 'npmp_dashboard_donations_token', '' ); 534 } 535 536 /** 537 * Cached rows for one Dashboard donation query. 538 * 539 * @param string $name Query name. 540 * @param string $scope What else the rows depend on (the year for YTD). 541 * @param string $token Token read before the query would run. 542 * @return array|null Rows, or null to run the query. 543 */ 544 function npmp_dashboard_donations_cache_get( $name, $scope, $token ) { 545 if ( npmp_dashboard_donations_dirty() ) { 546 return null; 547 } 548 $hit = get_transient( 'npmp_dash_' . $name ); 549 if ( ! is_array( $hit ) || ! isset( $hit['token'], $hit['scope'], $hit['rows'] ) || ! is_array( $hit['rows'] ) ) { 550 return null; 551 } 552 if ( (string) $hit['token'] !== (string) $token || (string) $hit['scope'] !== (string) $scope ) { 553 return null; 554 } 555 return $hit['rows']; 556 } 557 558 /** 559 * Keep one Dashboard donation query's rows for 10 minutes. 560 * 561 * @param string $name Query name. 562 * @param string $scope What else the rows depend on. 563 * @param string $token Token read before the query ran. 564 * @param array $rows Rows. 565 * @return void 566 */ 567 function npmp_dashboard_donations_cache_set( $name, $scope, $token, $rows ) { 568 if ( npmp_dashboard_donations_dirty() ) { 569 return; 570 } 571 set_transient( 572 'npmp_dash_' . $name, 573 array( 574 'token' => (string) $token, 575 'scope' => (string) $scope, 576 'rows' => (array) $rows, 577 ), 578 10 * MINUTE_IN_SECONDS 579 ); 580 } 581 582 /** 583 * Note that this request changed a donation. We change the token at shutdown. 584 * 585 * @return void 586 */ 587 function npmp_dashboard_donations_changed() { 588 if ( npmp_dashboard_donations_dirty() ) { 589 return; 590 } 591 npmp_dashboard_donations_dirty( true ); 592 add_action( 'shutdown', 'npmp_dashboard_donations_new_token' ); 593 } 594 595 /** 596 * Change the token, so every cached row set misses. 597 * 598 * @return void 599 */ 600 function npmp_dashboard_donations_new_token() { 601 update_option( 'npmp_dashboard_donations_token', uniqid( '', true ), false ); 602 } 603 604 /** 605 * Whether a post ID or object is a donation. 606 * 607 * @param int|WP_Post|null $post Post ID or object. 608 * @return bool 609 */ 610 function npmp_dashboard_is_donation( $post ) { 611 $type = is_object( $post ) && isset( $post->post_type ) ? (string) $post->post_type : (string) get_post_type( $post ); 612 return 'npmp_donation' === $type; 613 } 614 615 /** 616 * save_post_npmp_donation: a donation was added or edited (trash and 617 * restore go through wp_update_post() too). 618 * 619 * @return void 620 */ 621 function npmp_dashboard_donations_on_save() { 622 npmp_dashboard_donations_changed(); 623 } 624 625 /** 626 * transition_post_status: a donation changed status. 627 * 628 * @param string $new_status New status. 629 * @param string $old_status Old status. 630 * @param WP_Post $post Post. 631 * @return void 632 */ 633 function npmp_dashboard_donations_on_status( $new_status, $old_status, $post ) { 634 if ( $new_status !== $old_status && npmp_dashboard_is_donation( $post ) ) { 635 npmp_dashboard_donations_changed(); 636 } 637 } 638 639 /** 640 * before_delete_post and deleted_post: a donation went away. 641 * 642 * @param int $post_id Post ID. 643 * @param WP_Post|null $post Post, when WordPress passes one. 644 * @return void 645 */ 646 function npmp_dashboard_donations_on_delete( $post_id, $post = null ) { 647 if ( npmp_dashboard_is_donation( $post ? $post : $post_id ) ) { 648 npmp_dashboard_donations_changed(); 649 } 650 } 651 652 /** 653 * added_, updated_, and deleted_post_meta: a donation's amount, currency, 654 * frequency, or email changed. 655 * 656 * @param int|int[] $meta_id Meta ID or IDs. 657 * @param int $object_id Post ID. 658 * @param string $meta_key Meta key. 659 * @return void 660 */ 661 function npmp_dashboard_donations_on_meta( $meta_id, $object_id, $meta_key ) { 662 if ( in_array( $meta_key, array( '_npmp_donation_amount', '_npmp_donation_currency', '_npmp_donation_frequency', '_npmp_donation_email' ), true ) 663 && npmp_dashboard_is_donation( (int) $object_id ) ) { 664 npmp_dashboard_donations_changed(); 665 } 666 } 667 668 add_action( 'save_post_npmp_donation', 'npmp_dashboard_donations_on_save' ); 669 add_action( 'transition_post_status', 'npmp_dashboard_donations_on_status', 10, 3 ); 670 add_action( 'before_delete_post', 'npmp_dashboard_donations_on_delete', 10, 2 ); 671 add_action( 'deleted_post', 'npmp_dashboard_donations_on_delete', 10, 2 ); 672 add_action( 'added_post_meta', 'npmp_dashboard_donations_on_meta', 10, 3 ); 673 add_action( 'updated_post_meta', 'npmp_dashboard_donations_on_meta', 10, 3 ); 674 add_action( 'deleted_post_meta', 'npmp_dashboard_donations_on_meta', 10, 3 ); 675 495 676 /** 496 677 * Helper: Get year-to-date donation total in the site currency. … … 529 710 // Grouped by currency so a site that changed currency never adds pounds 530 711 // to dollars. A donation with no currency stored is USD. 531 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Small grouped aggregate, no row set to cache. 712 // The rows stay cached for 10 minutes until a donation changes (see 713 // npmp_dashboard_donations_cache_get()). 714 $token = npmp_dashboard_donations_token(); 715 $rows = npmp_dashboard_donations_cache_get( 'ytd', (string) $current_year, $token ); 716 if ( null !== $rows ) { 717 return npmp_group_totals_by_currency( $rows ); 718 } 719 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Grouped aggregate, cached above in a transient keyed to donation changes. 532 720 $rows = $wpdb->get_results( 533 721 $wpdb->prepare( … … 545 733 ARRAY_A 546 734 ); 547 548 return npmp_group_totals_by_currency( is_array( $rows ) ? $rows : array() ); 735 if ( is_array( $rows ) ) { 736 // A failed query returns null. We never cache that as "no gifts". 737 npmp_dashboard_donations_cache_set( 'ytd', (string) $current_year, $token, $rows ); 738 } 739 $rows = is_array( $rows ) ? $rows : array(); 740 741 return npmp_group_totals_by_currency( $rows ); 549 742 } 550 743 … … 590 783 // is the text after the first "|". This replaced GROUP_CONCAT ... 591 784 // SEPARATOR, which SQLite can't run, and needs no sort inside each group. 592 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Small grouped aggregate, nothing worth caching. 593 $rows = $wpdb->get_results( 785 // 786 // The rows stay cached for 10 minutes until a donation changes. Which 787 // gifts are still due to renew is worked out below on every load. 788 $token = npmp_dashboard_donations_token(); 789 $cached = npmp_dashboard_donations_cache_get( 'recurring', '', $token ); 790 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Grouped aggregate, cached in a transient keyed to donation changes. 791 $rows = null !== $cached ? $cached : $wpdb->get_results( 594 792 $wpdb->prepare( 595 793 "SELECT f.meta_value AS frequency, COALESCE( c.meta_value, '' ) AS currency, … … 612 810 ARRAY_A 613 811 ); 614 615 $rows = npmp_recurring_latest_rows( is_array( $rows ) ? $rows : array() ); 812 if ( null === $cached && is_array( $rows ) ) { 813 // A failed query returns null. We never cache that as "no gifts". 814 npmp_dashboard_donations_cache_set( 'recurring', '', $token, $rows ); 815 } 816 $rows = is_array( $rows ) ? $rows : array(); 817 818 $rows = npmp_recurring_latest_rows( $rows ); 616 819 $totals = npmp_recurring_run_rate_totals( $rows, time() ); 617 820 -
nonprofit-manager/trunk/includes/npmp-event-ics.php
r3806368 r3827809 73 73 'start' => npmp_event_ics_time( (string) ( $details['start'] ?? '' ) ), 74 74 'end' => npmp_event_ics_time( (string) ( $details['end'] ?? '' ) ), 75 'all_day' => npmp_ics_all_day_span( (string) ( $details['start'] ?? '' ), (string) ( $details['end'] ?? '' ) ), 75 76 'summary' => get_the_title( $event ), 76 77 'location' => (string) ( $details['location'] ?? '' ), -
nonprofit-manager/trunk/includes/npmp-ics.php
r3806368 r3827809 137 137 138 138 /** 139 * The first and last calendar day of an all-day event, or null for an event 140 * with times. 141 * 142 * Events have no all-day box. The event editor saves an empty start time as 143 * 00:00 and an empty end time as 23:59, an event from the old date-only field 144 * reads as 00:00, and every importer writes an all-day event as 00:00 to 145 * 23:59. The emails' [event_time] already says "All day" for a 00:00 start. So 146 * a start at 00:00 with no end, or with an end at 23:59, is all day. 147 * 148 * @param string $start Local start, "Y-m-d H:i:s" or "Y-m-d". 149 * @param string $end Local end in the same forms, or ''. 150 * @return string[]|null Array( first Y-m-d, last Y-m-d ), or null. 151 */ 152 function npmp_ics_all_day_span( $start, $end ) { 153 if ( ! preg_match( '/^(\d{4}-\d{2}-\d{2})(?:[ T]00:00(?::00)?)?$/', trim( (string) $start ), $s ) ) { 154 return null; 155 } 156 $end = trim( (string) $end ); 157 if ( '' === $end ) { 158 return array( $s[1], $s[1] ); 159 } 160 if ( ! preg_match( '/^(\d{4}-\d{2}-\d{2})(?:[ T]23:59(?::\d{2})?)?$/', $end, $e ) ) { 161 return null; 162 } 163 // An end day before the start day is a typo. The event keeps its one day. 164 return array( $s[1], max( $s[1], $e[1] ) ); 165 } 166 167 /** 168 * A Y-m-d day as an iCalendar DATE, moved by whole days. 169 * 170 * @param string $day Y-m-d. 171 * @param int $offset Days to add. 172 * @return string Ymd, or '' for a day that doesn't exist. 173 */ 174 function npmp_ics_date( $day, $offset = 0 ) { 175 if ( ! preg_match( '/^(\d{4})-(\d{2})-(\d{2})$/', (string) $day, $m ) || ! checkdate( (int) $m[2], (int) $m[3], (int) $m[1] ) ) { 176 return ''; 177 } 178 return gmdate( 'Ymd', gmmktime( 0, 0, 0, (int) $m[2], (int) $m[3] + (int) $offset, (int) $m[1] ) ); 179 } 180 181 /** 139 182 * One VEVENT. 140 183 * … … 143 186 * @type int $stamp DTSTAMP, Unix time. 144 187 * @type int $start Start, Unix time. 145 * @type int $end End, Unix time (0 for none). 188 * @type int $end End, Unix time. With none, or one that isn't 189 * after the start, the event runs one hour. 190 * @type array $all_day First and last day (Y-m-d) of an all-day 191 * event, from npmp_ics_all_day_span(), else empty. 146 192 * @type string $summary Title. 147 193 * @type string $location Physical place. … … 160 206 'start' => 0, 161 207 'end' => 0, 208 'all_day' => null, 162 209 'summary' => '', 163 210 'location' => '', … … 173 220 return ''; 174 221 } 175 $end = (int) $e['end'] > 0 ? (int) $e['end'] : $start; 222 // An end equal to the start showed in calendar apps as a zero-minute 223 // entry. With no end, or one that isn't after the start, we give the 224 // event an hour. 225 $end = (int) $e['end'] > $start ? (int) $e['end'] : $start + 3600; 176 226 $stamp = (int) $e['stamp'] > 0 ? (int) $e['stamp'] : $start; 227 // An all-day event gets DATE values, with DTEND the day after its last 228 // day (RFC 5545 3.6.1), so every calendar shows it on those days in any 229 // time zone. 230 $days = is_array( $e['all_day'] ) ? array_values( $e['all_day'] ) : array(); 231 $first = isset( $days[0] ) ? npmp_ics_date( $days[0] ) : ''; 232 $last = isset( $days[1] ) ? npmp_ics_date( $days[1], 1 ) : ''; 233 $is_all_day = '' !== $first && '' !== $last && $last > $first; 177 234 $url = npmp_ics_uri( $e['url'] ); 178 235 $place = trim( (string) $e['location'] ); … … 185 242 // spot an edited event, and the start date never moves on an edit. 186 243 $out .= npmp_ics_line( 'DTSTAMP', gmdate( 'Ymd\THis\Z', $stamp ) ); 187 $out .= npmp_ics_line( 'DTSTART', gmdate( 'Ymd\THis\Z', $start ) ); 188 $out .= npmp_ics_line( 'DTEND', gmdate( 'Ymd\THis\Z', $end ) ); 244 if ( $is_all_day ) { 245 $out .= npmp_ics_line( 'DTSTART;VALUE=DATE', $first ); 246 $out .= npmp_ics_line( 'DTEND;VALUE=DATE', $last ); 247 } else { 248 $out .= npmp_ics_line( 'DTSTART', gmdate( 'Ymd\THis\Z', $start ) ); 249 $out .= npmp_ics_line( 'DTEND', gmdate( 'Ymd\THis\Z', $end ) ); 250 } 189 251 $out .= npmp_ics_line( 'SUMMARY', npmp_ics_escape_text( $e['summary'] ) ); 190 252 if ( '' !== $where ) { -
nonprofit-manager/trunk/includes/npmp-payments-settings.php
r3808238 r3827809 597 597 } 598 598 599 // Stripe webhook signing secret (whsec_...). Used by the Pro 600 // recurring/dues webhook to verify Stripe signatures. This option 601 // was consumed by the webhook handler but had no admin field 602 // anywhere, so it could only be set with update_option() by hand. 599 // Stripe webhook signing secrets (whsec_...). Both webhook addresses 600 // check Stripe's signature against them: free's one-time gift 601 // endpoint (npmp-stripe-webhook.php) and Pro's recurring and dues 602 // endpoint. Each Stripe endpoint has its own secret, so an owner with 603 // both addresses in Stripe saves two. Saved on every site, since 604 // one-time gifts are free. A box with no whsec_ secret in it saves 605 // nothing and says so, and the saved secrets stay. 603 606 if ( ! empty( $_POST['npmp_stripe_webhook_secret'] ) ) { 604 update_option( 'npmp_stripe_webhook_secret', sanitize_text_field( wp_unslash( $_POST['npmp_stripe_webhook_secret'] ) ) ); 607 $webhook_secrets = npmp_stripe_webhook_secrets( sanitize_text_field( wp_unslash( $_POST['npmp_stripe_webhook_secret'] ) ) ); 608 if ( $webhook_secrets ) { 609 update_option( 'npmp_stripe_webhook_secret', implode( ' ', $webhook_secrets ) ); 610 } else { 611 $webhook_secret_error = true; 612 } 605 613 } 606 614 … … 643 651 <?php if ( ! empty( $saved ) ) : ?> 644 652 <div class="notice notice-success is-dismissible"><p><?php esc_html_e( 'Payment settings saved.', 'nonprofit-manager' ); ?></p></div> 653 <?php endif; ?> 654 <?php if ( ! empty( $webhook_secret_error ) ) : ?> 655 <div class="notice notice-error"><p><?php esc_html_e( 'We didn\'t save the signing secret. Copy the whole secret from the endpoint in Stripe, starting at whsec_.', 'nonprofit-manager' ); ?></p></div> 645 656 <?php endif; ?> 646 657 <?php if ( ! empty( $link_errors ) ) : ?> … … 761 772 <hr> 762 773 <h3><?php esc_html_e( 'PayPal Link Configuration', 'nonprofit-manager' ); ?></h3> 763 <p><?php esc_html_e( 'Donors pick the PayPal button, see PayPal in a new tab with the amount filled in, and finish the gift on PayPal. We pass the donor\'s name and email to PayPal too. You\'ll see these gifts in your PayPal account, not in your Donations list here, and we send no thank-you email for PayPal gifts.', 'nonprofit-manager' ); ?></p>774 <p><?php esc_html_e( 'Donors pick the PayPal button, see PayPal in a new tab with the amount filled in, and finish the gift on PayPal. We also pass the donor\'s name and email to PayPal. You\'ll see these gifts in your PayPal account, not in your Donations list here, and we send no thank-you email for PayPal gifts.', 'nonprofit-manager' ); ?></p> 764 775 <table class="form-table"> 765 776 <tr> … … 962 973 </table> 963 974 964 <?php if ( $is_pro ) : ?> 965 <h4><?php esc_html_e( 'Webhook Signing Secret', 'nonprofit-manager' ); ?></h4> 975 <?php 976 // One address on every site. With Pro, the free endpoint hands 977 // Pro every event, and Pro's older address keeps working. 978 $stripe_events = $is_pro 979 ? array( 'checkout.session.completed', 'invoice.payment_succeeded', 'invoice.payment_failed', 'customer.subscription.updated', 'customer.subscription.deleted' ) 980 : array( 'checkout.session.completed' ); 981 ?> 982 <h4><?php esc_html_e( 'Webhook', 'nonprofit-manager' ); ?></h4> 983 <p> 984 <?php 985 if ( $is_pro ) { 986 esc_html_e( 'Stripe reports recurring gifts and membership dues to your site through a webhook. With the webhook, you also get a record of every one-time gift, including gifts from donors who close the page before they return to your site.', 'nonprofit-manager' ); 987 } else { 988 esc_html_e( 'Without a webhook, you get a record of a Stripe gift only when the donor comes back to your page after paying. Add a webhook in Stripe to record every gift, including gifts from donors who close the page before they return to your site.', 'nonprofit-manager' ); 989 } 990 ?> 991 </p> 992 <ol> 993 <li> 994 <?php 995 printf( 996 /* translators: %s: link to the Webhooks screen in the Stripe Dashboard. */ 997 esc_html__( 'In your Stripe Dashboard, open %s and add an endpoint with the address below.', 'nonprofit-manager' ), 998 '<a href="https://dashboard.stripe.com/webhooks" target="_blank" rel="noopener">' . esc_html__( 'Webhooks', 'nonprofit-manager' ) . '</a>' 999 ); 1000 ?> 1001 </li> 1002 <li> 1003 <?php 1004 echo esc_html( _n( 'Send it this event:', 'Send it these events:', count( $stripe_events ), 'nonprofit-manager' ) ); 1005 echo ' <code>' . implode( '</code>, <code>', array_map( 'esc_html', $stripe_events ) ) . '</code>'; 1006 ?> 1007 </li> 1008 <li><?php esc_html_e( 'Copy the endpoint\'s signing secret into Signing Secret below, then save.', 'nonprofit-manager' ); ?></li> 1009 </ol> 966 1010 <table class="form-table"> 1011 <tr> 1012 <th scope="row"><?php esc_html_e( 'Webhook Address', 'nonprofit-manager' ); ?></th> 1013 <td> 1014 <code><?php echo esc_html( npmp_stripe_webhook_url() ); ?></code> 1015 <?php if ( $is_pro ) : ?> 1016 <p class="description"> 1017 <?php 1018 printf( 1019 /* translators: %s: the end of the older webhook address, in code tags. */ 1020 esc_html__( 'If you gave Stripe our older address, with %s at the end, you can keep that endpoint. If you also add this address, paste both endpoints\' signing secrets into Signing Secret.', 'nonprofit-manager' ), 1021 '<code>action=npmp_stripe_recurring_webhook</code>' 1022 ); 1023 ?> 1024 </p> 1025 <?php endif; ?> 1026 </td> 1027 </tr> 967 1028 <tr> 968 1029 <th><label for="npmp_stripe_webhook_secret"><?php esc_html_e( 'Signing Secret', 'nonprofit-manager' ); ?></label></th> 969 1030 <td> 970 1031 <input type="password" id="npmp_stripe_webhook_secret" name="npmp_stripe_webhook_secret" value="" class="regular-text" autocomplete="new-password" placeholder="<?php echo get_option( 'npmp_stripe_webhook_secret', '' ) ? esc_attr( '••••••••' . __( ' (saved)', 'nonprofit-manager' ) ) : 'whsec_...'; ?>"> 971 <p class="description"> 972 <?php esc_html_e( 'Required for recurring donations and membership dues. In the Stripe Dashboard, add a webhook endpoint pointing to the URL below, then paste its signing secret here. Leave blank to keep the saved secret.', 'nonprofit-manager' ); ?><br> 973 <code><?php echo esc_html( admin_url( 'admin-ajax.php?action=npmp_stripe_recurring_webhook' ) ); ?></code> 974 </p> 1032 <p class="description"><?php esc_html_e( 'Stripe shows the secret when you open the endpoint in Webhooks. For two endpoints, paste one secret, a space, and the other secret. Leave the box blank to keep the saved secrets, or paste new ones to replace every saved secret.', 'nonprofit-manager' ); ?></p> 975 1033 </td> 976 1034 </tr> 977 1035 </table> 978 1036 1037 <?php if ( $is_pro ) : ?> 979 1038 <h4><?php esc_html_e( 'Stripe Donation Frequencies', 'nonprofit-manager' ); ?></h4> 980 1039 <p><?php esc_html_e( 'Pick the schedules donors can choose for Stripe gifts. One-time gifts are always on.', 'nonprofit-manager' ); ?></p> … … 987 1046 <?php else : ?> 988 1047 <h4><?php esc_html_e( 'Stripe Donation Frequencies', 'nonprofit-manager' ); ?></h4> 989 <p><?php esc_html_e( ' One-time gifts are always on and need no webhook.', 'nonprofit-manager' ); ?></p>1048 <p><?php esc_html_e( 'Donors can always make a one-time gift.', 'nonprofit-manager' ); ?></p> 990 1049 <p><strong><?php esc_html_e( 'Recurring Donation Options:', 'nonprofit-manager' ); ?></strong></p> 991 1050 <label style="opacity:.6;"><input type="checkbox" disabled> <?php esc_html_e( 'Weekly', 'nonprofit-manager' ); ?></label><br> -
nonprofit-manager/trunk/includes/npmp-pro-feature-pages.php
r3799441 r3827809 43 43 'menu' => __( 'Automations', 'nonprofit-manager' ), 44 44 'title' => __( 'Email Automations', 'nonprofit-manager' ), 45 'line' => __( 'Send a welcome email on signup, a thank-you on each donation, a membership expiry reminder, anote when a recurring payment fails, and an email when you add a tag, with no one pressing Send. Email automations come with Nonprofit Manager Pro.', 'nonprofit-manager' ),45 'line' => __( 'Send a welcome email on signup, a thank-you on each donation, a note when a recurring payment fails, and an email when you add a tag, with no one pressing Send. Email automations come with Nonprofit Manager Pro.', 'nonprofit-manager' ), 46 46 'campaign' => 'automations', 47 47 ), -
nonprofit-manager/trunk/includes/npmp-scheduled-emails.php
r3812378 r3827809 2289 2289 /** 2290 2290 * The mail queue right now: readers waiting, how long the oldest has waited, 2291 * and how long since anything went out. 2291 * how long since anything went out, and how many waiting readers we already 2292 * tried and couldn't send to. 2292 2293 * 2293 2294 * queued_at and sent_at are written with current_time( 'mysql' ), so they hold 2294 2295 * site-local time and go back through the site timezone, never gmdate(). 2295 2296 * 2296 * @return array{waiting:int,oldest:int,since_send:int|null }2297 * @return array{waiting:int,oldest:int,since_send:int|null,retrying:int} 2297 2298 */ 2298 2299 function npmp_newsletter_queue_state() { … … 2301 2302 $now = npmp_scheduled_emails_now(); 2302 2303 2303 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Dedicated queue table, fixed name, read for one Site Health test. 2304 $row = $wpdb->get_row( "SELECT COUNT(*) AS waiting, MIN(queued_at) AS oldest FROM {$table} WHERE status = 'pending'" ); 2304 // A table from before the retry columns has no attempts to count. 2305 $tried = function_exists( 'npmp_newsletter_queue_has_retries' ) && npmp_newsletter_queue_has_retries() ? 'SUM( attempts > 0 )' : '0'; 2306 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Dedicated queue table, fixed name and a fixed expression, read for one Site Health test. 2307 $row = $wpdb->get_row( "SELECT COUNT(*) AS waiting, MIN(queued_at) AS oldest, {$tried} AS retrying FROM {$table} WHERE status = 'pending'" ); 2305 2308 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Same table and test. 2306 2309 $last = (string) $wpdb->get_var( "SELECT MAX(sent_at) FROM {$table}" ); … … 2313 2316 'oldest' => $oldest_ts ? (int) max( 0, round( ( $now - $oldest_ts ) / 60 ) ) : 0, 2314 2317 'since_send' => $last_ts ? (int) max( 0, round( ( $now - $last_ts ) / 60 ) ) : null, 2318 'retrying' => $row ? (int) $row->retrying : 0, 2315 2319 ); 2316 2320 } … … 2352 2356 (int) floor( $state['oldest'] / 60 ) 2353 2357 ) 2354 ) . '</p><p>' . esc_html( npmp_newsletter_queue_fix_text( ) ) . '</p>';2358 ) . '</p><p>' . esc_html( npmp_newsletter_queue_fix_text( (int) ( $state['retrying'] ?? 0 ) ) ) . '</p>'; 2355 2359 return $result; 2356 2360 } … … 2360 2364 * scheduler from a system cron job needs the other half of the advice: the 2361 2365 * standard "set up a real cron job" line is no help to someone who has one. 2362 * 2366 * When we tried waiting readers and the sends failed, the scheduler runs and 2367 * the mail settings need a look instead. 2368 * 2369 * @param int $retrying Waiting readers we already tried and couldn't send to. 2363 2370 * @return string 2364 2371 */ 2365 function npmp_newsletter_queue_fix_text() { 2372 function npmp_newsletter_queue_fix_text( $retrying = 0 ) { 2373 if ( (int) $retrying > 0 ) { 2374 $tries = class_exists( 'NPMP_Newsletter_Manager' ) ? count( NPMP_Newsletter_Manager::retry_delays() ) + 1 : 4; 2375 return sprintf( 2376 /* translators: 1: number of readers, 2: how many times Nonprofit Manager tries each send. */ 2377 _n( 2378 'Nonprofit Manager tried to send to %1$d of them and couldn\'t get the email to your mail server. Nonprofit Manager tries each send %2$d times, then marks it failed. Open Email Settings and send yourself a test email.', 2379 'Nonprofit Manager tried to send to %1$d of them and couldn\'t get the emails to your mail server. Nonprofit Manager tries each send %2$d times, then marks it failed. Open Email Settings and send yourself a test email.', 2380 (int) $retrying, 2381 'nonprofit-manager' 2382 ), 2383 (int) $retrying, 2384 $tries 2385 ); 2386 } 2366 2387 if ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) { 2367 2388 return sprintf( -
nonprofit-manager/trunk/includes/npmp-setup-wizard.php
r3801295 r3827809 609 609 <?php echo esc_html( $npmp_feature_names['newsletters'] ); ?> 610 610 </span> 611 <p><?php esc_html_e( 'Send newsletters and one scheduled email per event to your members. Needs Member Tracking, so ticking this ticks it too.', 'nonprofit-manager' ); ?></p>611 <p><?php esc_html_e( 'Send newsletters and one scheduled email per event to your members. Tick this box and you turn on Member Tracking, which these emails require.', 'nonprofit-manager' ); ?></p> 612 612 </label> 613 613 </div> -
nonprofit-manager/trunk/includes/npmp-subscription-preferences.php
r3807949 r3827809 809 809 function npmp_drain_digest_batch() { 810 810 global $wpdb; 811 $table = $wpdb->prefix . 'npmp_digest_queue'; 811 $table = $wpdb->prefix . 'npmp_digest_queue'; 812 $started = microtime( true ); 812 813 813 814 $limit = intval( get_option( 'npmp_digest_rate_limit', 10 ) ); … … 844 845 $contacts = class_exists( 'NPMP_Member_Manager' ) ? NPMP_Member_Manager::get_instance()->lookup_emails( wp_list_pluck( $batch, 'email' ) ) : null; 845 846 847 /** This filter is documented in includes/email-newsletter/class-newsletter-manager.php. */ 848 $budget = (float) apply_filters( 'npmp_mail_queue_batch_seconds', 240, 'digest' ); 849 846 850 foreach ( $batch as $row ) { 851 // A slow batch stops before its run lock goes stale, and the rows it 852 // didn't reach wait for the next run. 853 if ( ! npmp_mail_queue_batch_continues( 'digest', $started, $budget ) ) { 854 break; 855 } 856 847 857 $email = sanitize_email( $row->email ); 848 858 -
nonprofit-manager/trunk/includes/payments/class-donation-manager.php
r3814662 r3827809 50 50 * currency the gateway reports, never the setting. 51 51 * } 52 * @param bool $created Output. True only when this call wrote the row. 53 * A caller that thanks the donor checks it, since 54 * a request that took the lock just after another 55 * one wrote the row gets that row's ID back with 56 * $created false. 52 57 * @return int|false Insert ID on success (the existing ID when this 53 58 * transaction is already on file), false on failure. … … 56 61 * caller thanks the donor once. 57 62 */ 58 public function log_donation( $data ) { 63 public function log_donation( $data, &$created = null ) { 64 $created = false; 59 65 $email = sanitize_email( $data['email'] ?? '' ); 60 66 $name = sanitize_text_field( $data['name'] ?? '' ); … … 134 140 } 135 141 136 if ( is_wp_error( $post_id ) ) {142 if ( is_wp_error( $post_id ) || ! $post_id ) { 137 143 return false; 138 144 } 145 $created = true; 139 146 140 147 // The dashboards read the list of currencies in use from a cache. A … … 231 238 232 239 /** 233 * Find a donation by its gateway transaction id. 240 * Find a donation by its gateway transaction id, in any status. 241 * 242 * Trashed and draft donations count. Looking at published ones only let 243 * a late Stripe resend or a revisited success URL record a gift again 244 * after the owner trashed it, and thank the donor a second time. 234 245 * 235 246 * @param string $txn_id Gateway transaction/session/order id. … … 245 256 array( 246 257 'post_type' => self::POST_TYPE, 247 'post_status' => 'publish', 258 // 'any' leaves out trash, so name it as well. 259 'post_status' => array( 'any', 'trash' ), 248 260 'posts_per_page' => 1, 249 261 'fields' => 'ids', -
nonprofit-manager/trunk/includes/payments/npmp-payment-gateways.php
r3814662 r3827809 989 989 } 990 990 991 // Both PayPal buttons post the id of the order PayPal just captured, so a 992 // claim with no order can't be a real gift. Without an API secret it would 993 // record with nothing to dedupe on. We refuse only claims like this one 994 // and never add a per-visitor or per-site cap here: the buttons post each 995 // paid order once and ignore our answer, so a cap would lose a real gift 996 // from a donor who shares an address with someone abusing the form. 997 if ( '' === $transaction_id ) { 998 npmp_payment_debug_log( 'donation log rejected: no order id' ); 999 wp_send_json_error( array( 'message' => __( 'We could not verify this payment with PayPal. If you completed the donation, please contact us.', 'nonprofit-manager' ) ) ); 1000 } 1001 991 1002 // A PayPal order already recorded is a replay (a double-fired onApprove, 992 1003 // or someone re-posting a real order id). Answer as the first call did … … 1038 1049 1039 1050 // Log donation 1051 $created = false; 1040 1052 $donation_id = $donation_manager->log_donation( 1041 1053 array( … … 1047 1059 'transaction_id' => $transaction_id, 1048 1060 'currency' => $currency, 1049 ) 1061 ), 1062 $created 1050 1063 ); 1051 1064 … … 1062 1075 } 1063 1076 1077 // Another post of this same order wrote the row between the look 1078 // above and the lock in log_donation(). That request logs the 1079 // verification and thanks the donor. 1080 if ( ! $created ) { 1081 wp_send_json_success( array( 'donation_id' => (int) $donation_id ) ); 1082 } 1083 1064 1084 // Persist the gateway verification result: an audit trail for 1065 1085 // reconciliation and disputes/chargebacks, previously discarded … … 1238 1258 'metadata[frequency]' => $frequency, 1239 1259 'metadata[gateway]' => 'stripe', 1260 // Which site made the session. Stripe sends every event on the 1261 // account to every endpoint, so a second site on the same account 1262 // gets this session's events too, and skips them by this tag. 1263 'metadata[npmp_site]' => npmp_stripe_site_tag(), 1240 1264 ); 1241 1265 … … 1261 1285 $body['subscription_data[metadata][npmp_source]'] = 'donation'; 1262 1286 $body['subscription_data[metadata][frequency]'] = $frequency; 1287 $body['subscription_data[metadata][npmp_site]'] = npmp_stripe_site_tag(); 1263 1288 } else { 1264 1289 $body['mode'] = 'payment'; … … 1320 1345 * would inflate totals. 1321 1346 * 1347 * The checkout.session.completed webhook (npmp-stripe-webhook.php) records 1348 * the same one-time gift whether or not the donor comes back. Both go 1349 * through npmp_stripe_record_checkout_session(), so the donor gets one row 1350 * and one thank-you whichever lands first, or both at once. 1351 * 1322 1352 * @return void 1323 1353 */ … … 1341 1371 1342 1372 // Durable guard. A recorded donation for this session means it was 1343 // already finalized and the donor already thanked. Without this, a visit 1344 // to the same success URL after the 15-minute lock expired (browser 1345 // history, a bookmark, a flushed object cache) sent the thank-you email 1346 // again, because log_donation() dedupes the record but not the email. 1373 // already finalized and the donor already thanked, by an earlier return 1374 // or by the webhook. Without this, a visit to the same success URL after 1375 // the 15-minute lock expired (browser history, a bookmark, a flushed 1376 // object cache) sent the thank-you email again, because log_donation() 1377 // dedupes the record but not the email. 1347 1378 if ( class_exists( 'NPMP_Donation_Manager' ) && NPMP_Donation_Manager::get_instance()->find_by_transaction_id( $session_id ) ) { 1348 1379 return; … … 1370 1401 } 1371 1402 1372 // A Stripe 5xx or 429 is no answer at all. This return is the only place a 1373 // one-time gift gets recorded (there is no webhook for them), so holding 1374 // the lock here dropped the donation for anyone whose refresh came inside 1375 // the 15-minute window. Only a 200 is a definitive answer worth locking on. 1403 // A Stripe 5xx or 429 is no answer at all. On a site with no webhook set 1404 // up, this return is the only place a one-time gift gets recorded, so 1405 // holding the lock here dropped the donation for anyone whose refresh 1406 // came inside the 15-minute window. Only a 200 is a definitive answer 1407 // worth locking on. 1376 1408 if ( 200 !== (int) wp_remote_retrieve_response_code( $response ) ) { 1377 1409 delete_transient( $lock_key ); … … 1401 1433 } 1402 1434 1403 // Already recorded (a refresh after the 15-minute guard, or a replayed 1404 // link): don't send the thank-you again. 1405 if ( class_exists( 'NPMP_Donation_Manager' ) && NPMP_Donation_Manager::get_instance()->find_by_transaction_id( $session_id ) ) { 1435 // Only sessions this site created. Another site on the same Stripe 1436 // account uses the same form, and a hand-made success URL with that 1437 // site's session id would otherwise record and thank its donor here. 1438 if ( ! npmp_stripe_session_is_this_site( $session ) ) { 1406 1439 return; 1407 1440 } 1408 1441 1442 if ( 'subscription' === ( $session['mode'] ?? '' ) ) { 1443 // Subscription sessions leave no donation record here (Pro's webhook 1444 // records each invoice), so the return only thanks the donor, and the 1445 // lock is held long enough to cover a revisit. 1446 $gift = npmp_stripe_session_gift( $session ); 1447 if ( ! $gift ) { 1448 return; 1449 } 1450 npmp_send_thank_you_email( 1451 array( 1452 'email' => $gift['email'], 1453 'name' => $gift['name'], 1454 'amount' => $gift['amount'], 1455 'currency' => $gift['currency'], 1456 'frequency' => $gift['frequency'], 1457 'date' => date_i18n( get_option( 'date_format' ) ), 1458 ) 1459 ); 1460 npmp_add_donor_to_membership( $gift['email'], $gift['name'] ); 1461 set_transient( $lock_key, 1, 30 * DAY_IN_SECONDS ); 1462 return; 1463 } 1464 1465 // Stripe answered for the id in the URL, so that id is the transaction. 1466 $session['id'] = $session_id; 1467 $result = npmp_stripe_record_checkout_session( $session ); 1468 1469 // The write failed (wp_insert_post() returned an error, say the database 1470 // went away mid-request). Stripe has the money, so thanking the donor and 1471 // then holding the 30-day lock below lost the gift for good on a site 1472 // with no webhook. Release the lock and stop, so the donor's refresh 1473 // tries again. 1474 if ( 'failed' === $result ) { 1475 delete_transient( $lock_key ); 1476 npmp_payment_debug_log( 'stripe return: donation insert failed, lock released for retry' ); 1477 return; 1478 } 1479 1480 if ( 'recorded' === $result ) { 1481 set_transient( $lock_key, 1, 30 * DAY_IN_SECONDS ); 1482 } 1483 } 1484 add_action( 'template_redirect', 'npmp_maybe_finalize_stripe_donation' ); 1485 1486 /** 1487 * The donor and the money from a Stripe Checkout Session. 1488 * 1489 * Every value comes from the session Stripe sent or returned, never from 1490 * the browser: the email Stripe collected, the amount Stripe charged 1491 * (amount_total, in the currency's smallest unit), and the currency Stripe 1492 * charged in. 1493 * 1494 * @param array $session Checkout Session, decoded from Stripe's JSON. 1495 * @return array{email:string,name:string,amount:float,currency:string,frequency:string}|null 1496 * Null when the session carries no usable email. 1497 */ 1498 function npmp_stripe_session_gift( $session ) { 1409 1499 $email = ''; 1410 if ( ! empty( $session['customer_details']['email'] ) ) {1500 if ( ! empty( $session['customer_details']['email'] ) && is_string( $session['customer_details']['email'] ) ) { 1411 1501 $email = sanitize_email( $session['customer_details']['email'] ); 1412 } elseif ( ! empty( $session['customer_email'] ) ) {1502 } elseif ( ! empty( $session['customer_email'] ) && is_string( $session['customer_email'] ) ) { 1413 1503 $email = sanitize_email( $session['customer_email'] ); 1414 1504 } 1415 1505 1416 1506 if ( ! $email || ! is_email( $email ) ) { 1417 return ;1418 } 1419 1420 // The currency Stripe charged in, from the session itself. The setting may1421 // have changed since the donor started checkout.1422 $currency = npmp_normalize_currency_code( $session['currency'] ?? '' );1507 return null; 1508 } 1509 1510 // The currency Stripe charged in, from the session itself. The setting 1511 // may have changed since the donor started checkout. 1512 $currency = npmp_normalize_currency_code( $session['currency'] ?? '' ); 1423 1513 if ( '' === $currency ) { 1424 1514 $currency = npmp_currency(); 1425 1515 } 1516 1426 1517 $amount = isset( $session['amount_total'] ) && is_numeric( $session['amount_total'] ) ? npmp_currency_from_minor( $session['amount_total'], $currency ) : 0; 1427 $frequency = isset( $session['metadata']['frequency'] ) ? sanitize_text_field( $session['metadata']['frequency'] ) : 'one_time'; 1428 $name = isset( $session['customer_details']['name'] ) ? sanitize_text_field( $session['customer_details']['name'] ) : ''; 1429 1430 if ( 'subscription' !== ( $session['mode'] ?? '' ) && $amount > 0 && class_exists( 'NPMP_Donation_Manager' ) ) { 1431 $recorded = NPMP_Donation_Manager::get_instance()->log_donation( 1432 array( 1433 'email' => $email, 1434 'name' => $name, 1435 'amount' => $amount, 1436 'frequency' => $frequency, 1437 'gateway' => 'stripe', 1438 'transaction_id' => $session_id, 1439 'currency' => $currency, 1440 ) 1441 ); 1442 1443 // The write failed (wp_insert_post() returned an error, say the 1444 // database went away mid-request). Stripe has the money and this 1445 // return is the only place the gift is ever recorded, so thanking the 1446 // donor and then holding the 30-day lock below lost it for good. 1447 // Release the lock and stop, so the donor's refresh tries again. 1448 if ( ! $recorded ) { 1449 // A second return for this same session recorded the gift while 1450 // this one waited, and it thanks the donor. 1451 if ( NPMP_Donation_Manager::get_instance()->find_by_transaction_id( $session_id ) ) { 1452 return; 1453 } 1454 delete_transient( $lock_key ); 1455 npmp_payment_debug_log( 'stripe return: donation insert failed, lock released for retry' ); 1456 return; 1457 } 1518 $frequency = isset( $session['metadata']['frequency'] ) && is_string( $session['metadata']['frequency'] ) ? sanitize_text_field( $session['metadata']['frequency'] ) : 'one_time'; 1519 $name = isset( $session['customer_details']['name'] ) && is_string( $session['customer_details']['name'] ) ? sanitize_text_field( $session['customer_details']['name'] ) : ''; 1520 1521 return array( 1522 'email' => $email, 1523 'name' => $name, 1524 'amount' => (float) $amount, 1525 'currency' => $currency, 1526 'frequency' => '' === $frequency ? 'one_time' : $frequency, 1527 ); 1528 } 1529 1530 /** 1531 * Record a paid one-time Stripe gift from this site's donation form, and 1532 * thank the donor once. 1533 * 1534 * Three callers reach this, in any order and at the same moment: the 1535 * donor's return (npmp_maybe_finalize_stripe_donation()), the 1536 * checkout.session.completed webhook (npmp_stripe_webhook_dispatch()), and 1537 * Pro's older webhook address. log_donation() keeps one row per session id 1538 * under a lock, and only the call that wrote the row sends the thank-you 1539 * and adds the contact. A call that finds the row, waits for another 1540 * request's row, or takes the lock just after another request wrote the 1541 * row answers 'duplicate' and sends nothing. So the donor gets one row, 1542 * one receipt, and one run of Pro's donation automations however many of 1543 * those requests arrive. 1544 * 1545 * @param array $session Checkout Session, decoded from Stripe's JSON. The 1546 * caller vouches for it: a signed webhook event, or 1547 * Stripe's own API answer. 1548 * @return string 'recorded' when this call wrote the row and thanked the 1549 * donor. 'duplicate' when the gift was already on file or 1550 * another request wrote it just now. 'skipped' when the 1551 * session isn't a paid one-time gift from this form, so 1552 * there's nothing to record. 'foreign' when another site 1553 * on the same Stripe account created the session, so that 1554 * site records the gift. 'failed' when the write failed 1555 * and the caller should try again. 1556 */ 1557 function npmp_stripe_record_checkout_session( $session ) { 1558 if ( ! is_array( $session ) || ! class_exists( 'NPMP_Donation_Manager' ) ) { 1559 return 'skipped'; 1560 } 1561 1562 $session_id = isset( $session['id'] ) && is_string( $session['id'] ) ? $session['id'] : ''; 1563 if ( ! preg_match( '/^cs_[A-Za-z0-9_]+$/', $session_id ) ) { 1564 return 'skipped'; 1565 } 1566 1567 // Only money Stripe actually took. A session can complete unpaid (a 1568 // delayed payment method) or with nothing to pay. 1569 if ( 'paid' !== ( $session['payment_status'] ?? '' ) ) { 1570 return 'skipped'; 1571 } 1572 1573 // Only sessions this form created. A Stripe account shared with a store 1574 // (WooCommerce and the like), or Pro's dues join form, has other paid 1575 // sessions, and those aren't one-time gifts from this form. 1576 if ( 'stripe' !== ( $session['metadata']['gateway'] ?? '' ) ) { 1577 return 'skipped'; 1578 } 1579 1580 // Only sessions this site created. Stripe sends every event on the 1581 // account to every endpoint, so two sites on one Stripe account each 1582 // get the other's gifts. Before this check, each recorded the other's 1583 // gifts, added the other's donors, and thanked them in its own name. 1584 if ( ! npmp_stripe_session_is_this_site( $session ) ) { 1585 return 'foreign'; 1586 } 1587 1588 // A one-time charge. Pro's webhook records each invoice of a 1589 // subscription. 1590 if ( 'payment' !== ( $session['mode'] ?? '' ) ) { 1591 return 'skipped'; 1592 } 1593 1594 $donations = NPMP_Donation_Manager::get_instance(); 1595 if ( $donations->find_by_transaction_id( $session_id ) ) { 1596 return 'duplicate'; 1597 } 1598 1599 $gift = npmp_stripe_session_gift( $session ); 1600 if ( ! $gift || $gift['amount'] <= 0 ) { 1601 return 'skipped'; 1602 } 1603 1604 $created = false; 1605 $recorded = $donations->log_donation( 1606 array( 1607 'email' => $gift['email'], 1608 'name' => $gift['name'], 1609 'amount' => $gift['amount'], 1610 'frequency' => $gift['frequency'], 1611 'gateway' => 'stripe', 1612 'transaction_id' => $session_id, 1613 'currency' => $gift['currency'], 1614 ), 1615 $created 1616 ); 1617 1618 if ( ! $recorded ) { 1619 // Another request for this same session recorded the gift while 1620 // this one waited, and that request thanks the donor. 1621 return $donations->find_by_transaction_id( $session_id ) ? 'duplicate' : 'failed'; 1622 } 1623 1624 // Another request wrote the row between this call's first look and the 1625 // lock. That request thanks the donor. 1626 if ( ! $created ) { 1627 return 'duplicate'; 1458 1628 } 1459 1629 1460 1630 npmp_send_thank_you_email( 1461 1631 array( 1462 'email' => $ email,1463 'name' => $ name,1464 'amount' => $ amount,1465 'currency' => $ currency,1466 'frequency' => $ frequency,1632 'email' => $gift['email'], 1633 'name' => $gift['name'], 1634 'amount' => $gift['amount'], 1635 'currency' => $gift['currency'], 1636 'frequency' => $gift['frequency'], 1467 1637 'date' => date_i18n( get_option( 'date_format' ) ), 1468 1638 ) 1469 1639 ); 1470 1640 1471 npmp_add_donor_to_membership( $email, $name ); 1472 1473 // Subscription sessions leave no donation record here (Pro's webhook 1474 // records them), so hold the lock long enough to cover a revisit. 1475 set_transient( $lock_key, 1, 30 * DAY_IN_SECONDS ); 1476 } 1477 add_action( 'template_redirect', 'npmp_maybe_finalize_stripe_donation' ); 1641 npmp_add_donor_to_membership( $gift['email'], $gift['name'] ); 1642 1643 return 'recorded'; 1644 } 1478 1645 1479 1646 /* ============================================================== -
nonprofit-manager/trunk/nonprofit-manager.php
r3814662 r3827809 4 4 * Plugin URI: https://nonprofitmanager.app/ 5 5 * Description: Manage memberships, donations, newsletters and events from one plugin. 6 * Version: 2026.11.2 66 * Version: 2026.11.27 7 7 * Requires at least: 6.0 8 8 * Requires PHP: 8.1 … … 43 43 require_once plugin_dir_path( __FILE__ ) . 'includes/npmp-pro-feature-pages.php'; 44 44 require_once plugin_dir_path( __FILE__ ) . 'includes/payments/npmp-gateway-rules.php'; 45 // Stripe webhook (one-time gifts, and Pro's events with Pro active). Outside 46 // the Donations module so Pro's dues events still arrive with Donations off. 47 require_once plugin_dir_path( __FILE__ ) . 'includes/payments/npmp-stripe-webhook.php'; 45 48 require_once plugin_dir_path( __FILE__ ) . 'includes/npmp-setup-wizard.php'; 46 49 // Guided product tour + the org-identity data model it walks through. Loaded -
nonprofit-manager/trunk/readme.txt
r3814662 r3827809 4 4 Requires at least: 6.0 5 5 Tested up to: 7.1 6 Stable tag: 2026.11.2 66 Stable tag: 2026.11.27 7 7 Requires PHP: 8.1 8 8 License: GPLv2 or later … … 55 55 * Past newsletters for one group on that group's page, with `[npmp_newsletters group="computing"]`* 56 56 * As many scheduled emails as you want for the whole organization, each group, and each event* 57 * Email automation workflows: welcome emails , donation receipts, and expiry reminders*57 * Email automation workflows: welcome emails and donation receipts* 58 58 * Send through Amazon SES, SendGrid, Mailgun, Postmark, Brevo, or any SMTP server* 59 59 … … 107 107 **List imports** 108 108 109 Importing from Mailchimp or Constant Contact reads your list using the API key you supply. Mailchimp: https://mailchimp.com/legal/terms/ and https://www.intuit.com/privacy/statement/ Constant Contact: https://www.constantcontact.com/legal/terms and https://www.constantcontact.com/legal/privacy-notice109 Importing from Mailchimp or Constant Contact reads your list using the API key you supply. Importing from Brevo (api.brevo.com) reads your lists, contacts, and attributes with the API key you paste, sent in a request header and used only during that import. Importing from a Google Sheet (docs.google.com) fetches the published CSV at the link you paste, and Google sees your server's address and that link. Mailchimp: https://mailchimp.com/legal/terms/ and https://www.intuit.com/privacy/statement/ Constant Contact: https://www.constantcontact.com/legal/terms and https://www.constantcontact.com/legal/privacy-notice Brevo: https://www.brevo.com/legal/termsofuse/ and https://www.brevo.com/legal/privacypolicy/ Google Sheets: https://policies.google.com/terms and https://policies.google.com/privacy 110 110 111 111 **Social sharing** … … 183 183 == Changelog == 184 184 185 = 2026.11.27 = 186 * Added a Stripe webhook to record every gift. 187 * Allowed a signing secret for each Stripe endpoint. 188 * Fixed gifts crossing between sites sharing Stripe. 189 * Added three retries for failed newsletter sends. 190 * Fixed slow newsletter batches sending readers two copies. 191 * Sped up the newsletter queue with an index. 192 * Capped contact form messages per visitor and site. 193 * Refused PayPal gift claims with no order ID. 194 * Gave iCal events with no end one hour. 195 * Wrote all-day iCal events as dates. 196 * Cached Dashboard donation totals until a gift changes. 197 * Removed the expiry reminder claim from the listing. 198 185 199 = 2026.11.26 = 186 * Fixed a gift record ed twice when two requests for the same payment arrived together.187 * Added a dismissible notice after setup, with the Pro plans forrecurring gifts and dues billing.188 * Added a Free vs Pro section and a recurring gifts question to the WordPress.orglisting.200 * Fixed a gift recording twice on simultaneous payment requests. 201 * Added a dismissible setup notice about Pro recurring gifts and dues billing. 202 * Added a Free vs Pro section and recurring gifts question to the listing. 189 203 190 204 = 2026.11.25 = 191 * Fixed sending on a site that switched Newsletters on after installing the plugin. We queued every newsletter there and sent none.192 * Changed Scheduled Emails to read "Sending to 2 members" until we empty the queue.193 * Added a Site Health warning for a n email queue we stop emptying.205 * Fixed newsletters not sending after you enable Newsletters. 206 * Changed Scheduled Emails to read "Sending to 2 members" during sends. 207 * Added a Site Health warning for a stalled email queue. 194 208 195 209 = 2026.11.24 = 196 * Fixed Switch Plugins : you see an old plugin as switched once you delete its files, when we can't delete its data safely.197 * Fixed the wording of step 4, and of step 1 for The Events Calendar,on Switch Plugins.198 * Added your current sender setting beside each checkbox on the Newsletter Plugin and FluentCRM import screens.210 * Fixed Switch Plugins marking an old plugin switched after file deletion. 211 * Fixed step 4 and Events Calendar step 1 wording on Switch Plugins. 212 * Added your sender setting beside each Newsletter Plugin and FluentCRM checkbox. 199 213 200 214 = 2026.11.23 = 201 215 * Changed embedded ONLYOFFICE documents to a link in emails. 202 * Changed TablePress tables in emails to show their first page of rows, with the row count.216 * Changed TablePress emails to show the first page of rows. 203 217 * Added the [preferences_url] footer tag (or [subscribe_url]) for each reader's preferences page. 204 218 205 219 = 2026.11.22 = 206 * Added a Help link beside each screen title and a Nonprofit Manager tab in the Help panel, with the help center article for that screen.207 * Removed the PayPal frequency boxes from Payment Settings, since every PayPal gift is one-time. Turn on recurring gifts in the Stripe section.220 * Added a Help link beside each screen title and a Help panel tab. 221 * Removed PayPal frequency boxes from Payment Settings. 208 222 209 223 = 2026.11.21 = 210 * Added tags to events, and we add them as hashtags when you share an event.224 * Added tags to events, shared as hashtags. 211 225 * Added featured images to newsletters, on the web version and in newsletter lists. 212 * Fixed unsubscribe and preferences links going to a page that only mentioned our shortcode.226 * Fixed unsubscribe and preferences links going to a page without the form. 213 227 214 228 = 2026.11.20 = 215 * Added the meeting link, meeting ID, and passcode to the iCal feed, unless you keep an event's link for emails only.216 * Added a calendar file (.ics) with the meeting details to event emails sent through WordPress, SMTP, or Amazon SES.217 * Changed embedded videos and slides in newsletter emails to links , with a thumbnail for YouTube. Your web version keeps the player.218 * Fixed long iCal feed lines , which we now foldat 75 octets.229 * Added meeting link, meeting ID, and passcode to the iCal feed. 230 * Added an .ics calendar file with meeting details to event emails. 231 * Changed embedded videos and slides in newsletter emails to links. 232 * Fixed long iCal feed lines by folding at 75 octets. 219 233 220 234 = 2026.11.19 = 221 235 * Fixed Givebutter imports bringing in a lost dispute as a gift. 222 * Fixed Givebutter offline gifts with a blank Email. We use Contact Email and the contact's name.223 * Fixed Donorbox imports leaving Frequency blank. We fill it from Donation Type.236 * Fixed Givebutter offline gifts with a blank Email. 237 * Fixed Donorbox imports leaving Frequency blank. 224 238 225 239 = 2026.11.18 = … … 227 241 228 242 = 2026.11.17 = 229 * Added Meeting ID and Passcode fields beside an event's link, and[meeting_id] and [passcode] email tags.230 * Added "Show the meeting link only in emails" to events , so you can keep the link, meeting ID, and passcode off your site.243 * Added Meeting ID and Passcode fields, with [meeting_id] and [passcode] email tags. 244 * Added "Show the meeting link only in emails" to events. 231 245 * Added the meeting ID and passcode to the built-in Tomorrow email. 232 246 233 247 = 2026.11.16 = 234 * Fixed newsletters you send again , so readers who already got one don't get a second copy.235 * Fixed sends to readers who unsubscribe or turn off the digest after a send starts. They no longer get thatsend.248 * Fixed newsletters you send again reaching readers twice. 249 * Fixed sends to readers who unsubscribe or turn off the digest mid-send. 236 250 * Fixed imported events sending a "New event" email for each one. 237 * Fixed Email Settings saving SMTP passwords and API keys with %, <, or double spaces. They now save as typed.251 * Fixed Email Settings corrupting SMTP passwords and API keys with %, <, or spaces. 238 252 * Fixed duplicated newsletters losing their template. 239 * Fixed the calendar list with past events on, so you see upcoming events first under the right title.240 * Fixed Excel join dates, blank CSV rows, past gifts with no date, and Constant Contact lists past the first pagein imports.253 * Fixed the calendar list order and title when you show past events. 254 * Fixed Excel dates, blank CSV rows, undated gifts, and Constant Contact lists in imports. 241 255 * Fixed donor names with parentheses on the Donations screen. 242 256 * Fixed the "Copied" label and the Events settings screen on translated sites. 243 * Changed the empty events message to "No upcoming events." or "No past events." where that fits.244 * Changed signup and resubscribe confirmation links to expire after 7 days , with a link to sign up again.257 * Changed the empty events message to "No upcoming events." or "No past events." 258 * Changed signup and resubscribe confirmation links to expire after 7 days. 245 259 * Changed Facebook sharing to Graph API v26.0. 246 * Security: hardened past newsletter, FluentCRM, MailPoet, and XLSX imports, sealed Mailchimp and Constant Contact keys during imports, removed the email attribute from [npmp_can_spam], capped unsubscribe confirmations per address, and tightened reCAPTCHA checks. 260 * Security: hardened past newsletter, FluentCRM, MailPoet, and XLSX imports. 261 * Security: sealed Mailchimp and Constant Contact keys during imports. 262 * Security: removed the email attribute from [npmp_can_spam]. 263 * Security: capped unsubscribe confirmations per address and tightened reCAPTCHA checks. 247 264 * Copy: plural forms, US spelling, and clearer admin notices. 248 265 249 266 = 2026.11.15 = 250 * Fixed `[npmp_events past="true"]` , so you see only past events. For past and upcoming together, use `past="all"`.251 * Added a Categories link to the Events menu , so you can rename or delete old event categories.267 * Fixed `[npmp_events past="true"]` showing upcoming events. Use `past="all"` for both. 268 * Added a Categories link to the Events menu. 252 269 * Added a Groups column to the Events Overview with Nonprofit Manager Pro. 253 270 254 271 = 2026.11.14 = 255 * Fixed the Preview button in the Newsletter Archive and the newsletter editor, so you can read any newsletter, imported ones included.256 * Fixed the signup form so nobody can put an Inactive contact back on your list unless that person confirms by email.257 * Fixed "Send a test to me" in the event editor, so you get the template you picked, saved or not.258 * Fixed newsletters w hose template you deleted, so you get the default template, as you do in event emails.259 * Fixed the group names in the newsletter editor's audience label, so you see "Art and History" before and after you save.272 * Fixed the Preview button in the Newsletter Archive and editor. 273 * Fixed the signup form re-subscribing Inactive contacts without email confirmation. 274 * Fixed "Send a test to me" using the wrong template. 275 * Fixed newsletters with a deleted template using the default template. 276 * Fixed group names in the newsletter editor's audience label. 260 277 * Added a limit of three signup confirmation emails an hour for each address. 261 * Added a Donate button to newsletters and event emails in place of the donation form, since mail apps don't support forms.262 * Added name and email prefill on donation forms for signed-in users and for readers who come from a newsletter.263 * Added a Payment link option , so you can send donors to any payment page with the amount, name, email, currency, and note filled in.278 * Added a Donate button to newsletters and event emails. 279 * Added name and email prefill on donation forms. 280 * Added a Payment link option with amount, name, email, currency, and note prefilled. 264 281 * Added the donor's name and email to the PayPal donation link. 265 282 266 283 = 2026.11.13 = 267 * Fixed the second test email and second pop-up you got each time you sent a test newsletter.268 * Fixed the newsletter editor and Newsletter Archive, where you saw "All subscribed members" and All Members ticked again after you pickeda group.269 * Fixed Duplicate on a group newsletter , where you got a copy with nogroup.270 * Fixed where you find Event Details in the event editor: in the sidebar, even if you moved the box in an older version.271 * Fixed the signup form for current subscribers, so they can join a new group once they confirm by email.272 * Fixed the groups you lost when someone who had unsubscribed signed up again with the form.273 * Fixed the signup form so nobody can change another person's groups or email choices by typing their address.274 * Fixed the signup form message, so you see the same one for every address.275 * Added an Email Template picker to the event editor , like the one in the newsletter editor.276 * Added a search box and sortable Title, Last Sent, Recipients, and Publiccolumns to the Newsletter Archive.284 * Fixed the second test email and pop-up on newsletter tests. 285 * Fixed "All subscribed members" ticking again after you pick a group. 286 * Fixed Duplicate on a group newsletter dropping the group. 287 * Fixed Event Details position in the event editor sidebar. 288 * Fixed the signup form letting current subscribers join a new group after confirming. 289 * Fixed groups lost when an unsubscribed person signs up again. 290 * Fixed the signup form letting anyone change another person's groups or email choices. 291 * Fixed the signup form showing different messages for different addresses. 292 * Added an Email Template picker to the event editor. 293 * Added a search box and sortable columns to the Newsletter Archive. 277 294 * Added Newsletter to the + New menu in the admin bar. 278 295 279 296 = 2026.11.12 = 280 * Fixed contacts who unsubscribed coming back as subscribed when you ticked "Update existing contacts" for an import.281 * Added a n importer for FluentCRM: contacts, statuses, signup dates, lists as groups, tags, custom fields, and sender settings.282 * Added a Brevo import : contacts from a list or your whole account, blocklisted addresses as Unsubscribed, lists as groups, attributes as custom fields, and join dates.283 * Added custom fields to imports with Pro: extra CSV and Excel columns, Mailchimp merge fields, Constant Contact custom fields, and MailPoet custom fields.284 * Added a n importer for past gifts from a file: donors and their paid gifts from a Zeffy, Givebutter, or Donorbox CSV, or a spreadsheet.285 * Added a n importer for past newsletters from MailPoet and The Newsletter Plugin: each sent newsletter with its subject, send date, and content, off your public archive until you tick its box.286 * Added "Show in the public archive" and "Hide from the public archive" to Newsletter Archive's bulk actions.287 * Added MailPoet tags to the import , in each contact's Tags field next to the tags they already have.297 * Fixed "Update existing contacts" resubscribing unsubscribed contacts. 298 * Added a FluentCRM importer for contacts, statuses, lists, tags, and custom fields. 299 * Added a Brevo import for contacts, lists, blocklisted addresses, attributes, and join dates. 300 * Added Pro custom field imports for CSV, Excel, Mailchimp, Constant Contact, and MailPoet. 301 * Added a past gifts importer for Zeffy, Givebutter, and Donorbox files. 302 * Added a past newsletters importer for MailPoet and The Newsletter Plugin. 303 * Added public archive show and hide bulk actions to the Newsletter Archive. 304 * Added MailPoet tags to the import's Tags field. 288 305 * Added a link back to Switch Plugins on every import screen. 289 * Added a card with a button for the Pro note inthe setup wizard.290 * Fixed slow imports from MailPoet, The Newsletter Plugin, GiveWP, Charitable, Paid Memberships Pro, and CSV fileson sites with thousands of contacts.291 * Fixed free imports from MailPoet and The Newsletter Plugin: subscribed people now get your free places first.306 * Added a Pro note card with a button to the setup wizard. 307 * Fixed slow imports on sites with thousands of contacts. 308 * Fixed free MailPoet and Newsletter Plugin imports filling free places with subscribers first. 292 309 * Fixed the Switch Plugins step you saw while an import was still running. 293 310 * Fixed the empty groups you got from MailPoet lists with no subscribed members. 294 * Fixed the parent categories you lost from The Events Calendar when only their child categories had events.295 * Fixed the threshold you saw in the review request in place of your own contact or event count.296 * Fixed numbers of four digits or more without commas on theimport and Switch Plugins screens.311 * Fixed lost parent categories from The Events Calendar. 312 * Fixed the review request showing the wrong threshold. 313 * Fixed missing commas in numbers on import and Switch Plugins screens. 297 314 * Fixed newsletters you deleted staying in the send queue. 298 315 * Fixed the blank recurring donations total on the dashboard of SQLite sites. 299 * Fixed the HTML code you saw in place of quotation marksin the import message about the Email column.316 * Fixed HTML code showing in the import message about the Email column. 300 317 301 318 = 2026.11.11 = 302 * Fixed welcome emails going to contacts brought in by the MailPoet, Newsletter, Paid Memberships Pro, and donation importers.303 * Added an importer for Ultimate Member: members by role, account status, membership levels from roles, join dates, phone, and country.304 * Added an importer for Event Organiser: events, every date, venues, categories, images, and old links.305 * Added a n importer for My Calendar: events, every date, locations, categories, images, and old links.306 * Added a n importer for WP Event Manager: events, venues, online links, categories, banners, old links, and the list length.307 * Added the free contact limit , and how many places you have left, to the top ofSwitch Plugins.319 * Fixed welcome emails going to imported contacts. 320 * Added an Ultimate Member importer for members, levels, join dates, phone, and country. 321 * Added an Event Organiser importer for events, dates, venues, categories, images, and links. 322 * Added a My Calendar importer for events, dates, locations, categories, images, and links. 323 * Added a WP Event Manager importer for events, venues, links, categories, and banners. 324 * Added the free contact limit and places left to Switch Plugins. 308 325 * Added the GiveWP and Paid Memberships Pro delete-data warning to the turn-off step. 309 * Fixed The Events Calendar import so you get cancelled and postponed events as drafts.310 * Fixed the GiveWP and Charitable gift import so Active and Pending contacts keep theirstatus.311 * Fixed the MailPoet import so a Donor who subscribed in MailPoet gets your newsletter.312 * Fixed duplicate contacts when you reloaded a running import or ran one in two tabs.313 * Fixed time-outs on Switch Plugins for sites with tens of thousands of MailPoet, Newsletter, or Paid Memberships Prosubscribers.314 * Fixed the empty import you got from "Start the import" on a pluginyou never turned on.315 * Fixed the MailPoet screen's wording of the free limit as a total for your site.326 * Fixed The Events Calendar import of cancelled and postponed events. 327 * Fixed GiveWP and Charitable imports changing Active and Pending status. 328 * Fixed MailPoet imports skipping Donors who subscribed. 329 * Fixed duplicate contacts on reloaded or parallel imports. 330 * Fixed Switch Plugins time-outs on sites with tens of thousands of subscribers. 331 * Fixed empty imports from plugins you never turned on. 332 * Fixed the MailPoet screen's free limit wording. 316 333 317 334 = 2026.11.10 = 318 * Fixed paragraph breaks in event text on event lists, the Events block, and the events archive.319 * Added a note for administrators on the signup form about attributes only Pro supports.335 * Fixed paragraph breaks in event text on lists, blocks, and archives. 336 * Added a signup form note for administrators about Pro-only attributes. 320 337 321 338 = 2026.11.9 = 322 * Added your newsletter footer and unsubscribe link to post and event notifications and the weeklydigest.323 * Added a Form color setting under Membership Settings for the button color on every front-end form.339 * Added your newsletter footer and unsubscribe link to notifications and the digest. 340 * Added a Form color setting under Membership Settings. 324 341 * Added what the person signed up for to the please-confirm email. 325 * Added the Newsletters block and [npmp_newsletters] shortcode to list past newsletters you make public.326 * Added the [event_description] tag for event emails, with thefull description, headings, lists, links, and images.327 * Added the planned emails and their send times to a new event's email box, before the first save.342 * Added the Newsletters block and [npmp_newsletters] shortcode for past newsletters. 343 * Added the [event_description] tag with full description, headings, lists, links, and images. 344 * Added planned emails and send times to a new event's email box. 328 345 * Fixed line breaks between paragraphs in [event_excerpt]. 329 * Fixed the first name, last name, and full name tags in the body and subject oftest emails.330 * Fixed the status in the event email box after a savein the block editor.346 * Fixed first name, last name, and full name tags in test emails. 347 * Fixed the event email box status after saving in the block editor. 331 348 332 349 = 2026.11.8 = … … 336 353 * Changed Quick Add Event on the Dashboard to save a draft. 337 354 * Added a Clicks column to Newsletter Reports. 338 * Used the organization address in the newsletter footer when no mailing address is set.339 * Cleaned up headings, labels, and wording on every admin screen , and kept the tour out of the editor.355 * Changed the newsletter footer to use the organization address. 356 * Cleaned up headings, labels, and wording on every admin screen. 340 357 * Updated the blocks to the current block editor version. 341 358 342 359 = 2026.11.7 = 343 * Added a n importer for Paid Memberships Pro: members, membership levels, join dates, and billing addresses, on the Switch Plugins screen.344 * Added a warning on the Switch Plugins screen when a setting in Charitable or GiveWP would delete their donation data.360 * Added a Paid Memberships Pro importer for members, levels, join dates, and addresses. 361 * Added a Switch Plugins warning for Charitable or GiveWP data deletion settings. 345 362 346 363 = 2026.11.6 = 347 * Raised the free import limit from 50 to 100 contacts , counted as a total for the site.364 * Raised the free import limit from 50 to 100 contacts. 348 365 * Added calendar settings to The Events Calendar importer. 349 * Added a Switch Plugins screen to import, check, turn off, delete, and clear out an old plugin one step at a time, starting with The Events Calendar.366 * Added the Switch Plugins screen, starting with The Events Calendar. 350 367 * Added an importer for MailPoet: contacts, lists, sender settings, and signup dates. 351 368 * Added MailPoet to the Switch Plugins screen. 352 * Added importers for GiveWP and Charitable: donors and past gifts, on the Switch Plugins screen.353 * Added a one-click update to the version notice that puts free and Pro on the same version.354 * Added importers for Events Manager and Sugar Calendar: events, venues, categories, and redirects from old event links, on the Switch Plugins screen.355 * Fixed redirects from old event links right after you turn a plugin off on the Switch Plugins screen.356 * Added a n importer for The Newsletter Plugin: contacts, lists, sender settings, and signup dates, on the Switch Plugins screen.369 * Added GiveWP and Charitable importers for donors and past gifts. 370 * Added a one-click update to the version notice. 371 * Added Events Manager and Sugar Calendar importers with event link redirects. 372 * Fixed old event link redirects after you turn a plugin off. 373 * Added a Newsletter Plugin importer for contacts, lists, sender settings, and signup dates. 357 374 358 375 = 2026.11.5 = … … 379 396 = 2026.11.2 = 380 397 * Added scheduled emails: one email per event, and Send later for any newsletter. 381 * Added a Print or save as PDF button to calendars and event lists , with a setting to hide the button.382 * Added an importer for s ites switching from The Events Calendar, with review, redirects, and a deactivate button.398 * Added a Print or save as PDF button to calendars and event lists. 399 * Added an importer for switching from The Events Calendar. 383 400 * Calendar weekday headers fit on phones, and category colors show on events. 384 * The Member List search finds people by name, email, or tag, and the list fits onphones.401 * Changed Member List search to find names, emails, or tags, and fit phones. 385 402 * Fixed newsletters and digests that two overlapping runs could send twice. 386 403 * Fixed click tracking on email, phone, and same-page links. … … 392 409 393 410 = 2026.11.1 = 394 * Events lists can show as a list, grid, cards, or mosaic, with featuredimages and excerpts.411 * Added list, grid, cards, and mosaic event layouts with images and excerpts. 395 412 * Past events sort newest first. 396 413 * The Events block follows the editor's color, type, spacing, and border settings. … … 682 699 == Upgrade Notice == 683 700 701 = 2026.11.27 = 702 Update to record Stripe gifts from donors who close the tab and to retry failed newsletter sends. 703 704 = 2026.11.26 = 705 Update so a gift never records twice when two requests for the same payment arrive together. 706 707 = 2026.11.25 = 708 Update to send the newsletters your site queued and never sent. 709 710 = 2026.11.16 = 711 Update for security hardening of imports, saved SMTP and API keys, unsubscribe confirmations, and reCAPTCHA checks. 712 684 713 = 2026.11.15 = 685 714 Update so `[npmp_events past="true"]` lists only past events.
Note:
See TracChangeset
for help on using the changeset viewer.