impress-org / givewp

GiveWP - The #1 Donation Plugin for WordPress. Easily accept donations and fundraise using your WordPress website.
https://givewp.com/
GNU General Public License v3.0
344 stars 191 forks source link

fix: prevent XML from being stripped out in email content #3788

Closed Benunc closed 6 years ago

Benunc commented 6 years ago

Bug Report

User Story

As a developer or admin, I want to be able to include IE/Outlook-specific comments and style so that older browsers and email clients display things correctly.

The only way to do that is to include the styles inline.

Current Behavior

The wpautop() function runs on the message content no matter what, which strips out XML comments.

Expected Behavior

I expect to be able to turn off wpautop() if I want to.

Bug Type

Steps to Reproduce

  1. In the email editor, put in XML comments in the text editor.
  2. Preview or send the email.
  3. Those comments are stripped out.

Possible Solution

Add a filter here: https://github.com/impress-org/give/blob/8f10420e10a9dbd338dfa909bdd2a9632fc7efbf/includes/emails/class-give-emails.php#L412

Related

https://secure.helpscout.net/conversation/689164778/27566?folderId=672194

Acceptance Criteria

Environment

WordPress System Info ### WordPress Environment ### Home URL: https://livegive.wpsteward.com Site URL: https://livegive.wpsteward.com WP Version: 4.9.8 WP Multisite: – WP Memory Limit: 256 MB WP Debug Mode: – WP Cron: ✔ Language: en_US Permalink Structure: /%year%/%monthnum%/%day%/%postname%/ Show on Front: posts Table Prefix Length: wp_8138bfdc07_ Table Prefix Length: 14 Table Prefix Status: Acceptable Admin AJAX: Accessible Registered Post Statuses: publish, future, draft, pending, private, trash, auto-draft, inherit, request-pending, request-confirmed, request-failed, request-completed, refunded, failed, revoked, cancelled, abandoned, processing, preapproval, give_subscription ### Server Environment ### Hosting Provider: DBH: localhost, SRV: livegive.wpsteward.com TLS Connection: Connection uses TLS 1.2 TLS Connection: Probably Okay Server Info: Apache/2.4.35 (Unix) OpenSSL/1.0.1f PHP Version: 7.0.32 PHP Post Max Size: 1 GB PHP Time Limit: 30 PHP Max Input Vars: 5000 PHP Max Upload Size: 512 MB cURL Version: ❌ 7.35.0, OpenSSL/1.0.1f - We recommend a minimum cURL version of 7.40. SUHOSIN Installed: – MySQL Version: ❌ 5.5.61 - We recommend a minimum MySQL version of 5.6. See: WordPress Requirements Default Timezone is UTC: ✔ fsockopen/cURL: ✔ SoapClient: ✔ DOMDocument: ✔ gzip: ✔ GD Graphics Library: ✔ Multibyte String: ✔ Remote Post: ✔ Remote Get: ✔ ### Give Configuration ### Give Version: 2.2.5 Give Cache: Enabled Database Updates: All DB Updates Completed. Give Cache: Enabled Give Cache: ✔New Donation✔Donation Receipt❌New Offline Donation❌Offline Donation Instructions✔New User Registration✔User Registration Information❌Email access✔Daily Email Report✔Weekly Email Report✔Monthly Email Report❌Renewal Receipt Email❌Subscription Cancelled Email❌Subscription Completed Email✔Subscription Reminder Email❌Subscriptions Email Access Upgraded From: 2.2.1 Test Mode: Enabled Currency Code: USD Currency Position: After Decimal Separator: . Thousands Separator: , Success Page: https://livegive.wpsteward.com/donation-confirmation/ Failure Page: – Donation History Page: https://livegive.wpsteward.com/donation-history/ Give Forms Slug: /donations/ Enabled Payment Gateways: Test Donation, Stripe - Credit Card, PayPal Payments Pro, Authorize.net, PayPal Standard Default Payment Gateway: Stripe - Credit Card PayPal IPN Verification: Disabled PayPal IPN Notifications: IPN received for #1084 ( 8H4629943X7440214 ) on 09/04/2018 at 15:46. Status VERIFIED Donor Email Access: Disabled ### Active Give Add-ons ### Give - Authorize.net Gateway: ✔ Licensed – by WordImpress – 1.4.3 Give - Email Reports: ✔ Licensed – by WordImpress – 1.1.2 Give - Manual Donations: ✔ Licensed – by WordImpress – 1.4.1 Give - PDF Receipts: ✔ Licensed – by WordImpress – 2.3 Give - Recurring Donations: ✔ Licensed – by WordImpress – 1.8.1 Give - Tributes: ✔ Licensed – by WordImpress – 1.5.0 Give - Zapier: ✔ Licensed – by WordImpress – 1.2.1 ### Other Active Plugins ### Ben's Helper Functions: by BenUNC – Give - Fee Recovery: by GiveWP – 1.7.2 Give - Form Field Manager: by GiveWP – 1.4.0 Give - Google Analytics Donation Tracking: by GiveWP – 1.2.2 Give - PayPal Pro Gateway: by GiveWP – 1.2.0 Give - Stripe Gateway: by GiveWP – 2.1.1 Google Analytics for WordPress by MonsterInsights: by MonsterInsights – 7.1.0 Query Monitor: by John Blackbourn & contributors – 3.1.1 User Switching: by John Blackbourn & contributors – 1.3.1 WP Crontrol: by John Blackbourn & contributors – 1.6.2 ### Inactive Plugins ### Akismet Anti-Spam: by Automattic – 4.0.8 Email Cop: by Ashfame – 0.1.1 Give - Database HealthCheck: by WordImpress – 0.0.2 Give - Mollie Gateway: by WordImpress – 1.1.1 Hello Dolly: by Matt Mullenweg – 1.6 Page Builder by SiteOrigin: by SiteOrigin – 2.8.2 RegistrationMagic Premium: by Registrationmagic – 3.8.1.7 Restrict Content Pro: by Restrict Content Pro Team – 2.9.10 Series Engine: by Eric Murrell (Volacious) – 2.6.1 SiteOrigin Widgets Bundle: by SiteOrigin – 1.12.1 The GDPR Framework: by Codelight – 1.0.11 WonderPlugin Tabs: by Magic Hills Pty Ltd – 5.8 ### Active MU Plugins ### api-hacks.php: by – ### Theme ### Name: Twenty Seventeen Version: 1.7 Author URL: https://wordpress.org/ Child Theme: No – If you're modifying Give on a parent theme you didn't build personally, then we recommend using a child theme. See: How to Create a Child Theme
mcorkum commented 6 years ago

I understand that most people wouldn't do this, however, many HTML e-mails have style comments to make exceptions for older browsers and crummy MS Office products. I've tried wrapping all of them in pre tags, as wpautop doesn't process those (https://core.trac.wordpress.org/browser/tags/4.9.8/src/wp-includes/formatting.php#L452), then replacing them with the give_email_message filter. It wasn't perfect and seemed like a lot of processing to just stop random p tags from being added.

Edit: See PR below for possible fix.

kevinwhoffman commented 6 years ago

Thanks @mcorkum for the suggestion and PR.

Closing as the give_email_disable_wpautop filter was merged in #3789 and will be available in the 2.3.0 release.

ravinderk commented 6 years ago

@kevinwhoffman I renamed filter to give_email_message_disable_wpautop for clarification.

ref: https://github.com/impress-org/give/blob/7c70f9374bd67dd64db76a335cebc01338446cb0/includes/emails/class-give-emails.php#L419