-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: enable public newsletter posts #272
Conversation
Adds a meta option to newsletter posts that allows specific newsletters to be publicly viewable on the site front-end. Currently uses the standard post template.
Enables archive apges for Newsletter CPT, but only display posts that are marked as publicly viewable.
Uses the 'newspack_newsletters_assess_has_disabled_popups' filter provided by the Campaigns plugin.
Previously, if a non-logged-in user tried to view a non-public newsletter post, the page would display as a 404 but the document title would still match the post title. This fixes that.
Moves the title filter above the template set, otherwise it won't work.
…etters into add/allow-public-newsletter-posts
Adds a check for publish status in the Constant Contact class before sending the newsletter, to match Mailchimp (so that we don't try to send a newsletter again if it's been published already and we're just updating the post). Also restores an error message in the Mailchimp class that got lost.
@adekbadek I just realized that the Post Inserter block isn't rendering anything on the front-end. Before I go down the rabbit hole of trying to make it work, is there something off the top of your head we can change to fix this? |
@dkoo, it can be rendered as in the email renderer. The block saves resulting markup in a |
…etters into add/allow-public-newsletter-posts
Adds a server-side render callback for the Posts Inserter so that it can show content on the front-end. Also updates the checkbox for the "disable ads" attribute to be a ToggleControl, to match the other toggleable UI elements from the plugin.
Thanks for the hint! I ended up using that attribute to just render the inner blocks via server-side callback. Added in 91b596c. |
- use lockPostAutosaving instead of dequeueing autosave script to disable autosave - change language of "published as a page" to "published as a post"
Addressed this in c15f2e6. The problem was that I was relying on WP core's This means that if you edit other post attributes or post content, the "Update" button won't be enabled, but it's still possible to make those edits, change the "public" setting, and then save all changes. Kind of an edge case since I don't see much of a use case for editing newsletter content after it has been sent, but I could also add a comparison of post content vs. edited post content if you think that's warranted. |
I agree it's an edge case, I'm fine with it staying that way |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thomasguillot, are you logged in as an admin user? If that's the case then newsletter posts will always be visible as a preview. Try viewing the same post in a new incognito window and see if the page still renders? |
Adds a checkbox option that lets editors decide whether Jetpack Related Posts should be enabled on single newsletter posts. Only shown if Related Posts module is active.
Oh ok yeah it work as expected then. But why will it always be visible as a preview if I specifically un-toggled the option? |
It's the only way I could think of that would allow editors to preview a single newsletter post without making it public. It more or less works the same way as a draft post, but since the newsletter is already "published" (a.k.a. sent) regardless of whether the post is marked as public, we can't use the WP publish status in the same way as we would use it in a regular post. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @dkoo -- makes sense 😊
# [1.9.0-alpha.1](v1.8.1...v1.9.0-alpha.1) (2020-08-20) ### Bug Fixes * button custom colors ([#301](#301)) ([8ebcf5d](8ebcf5d)) * first time set up flow ([c16d6bf](c16d6bf)) * pre-send info if no list set ([#297](#297)) ([f575d94](f575d94)) ### Features * enable public newsletter posts ([#272](#272)) ([ef90bf9](ef90bf9))
🎉 This PR is included in version 1.9.0-alpha.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
# [1.9.0](v1.8.1...v1.9.0) (2020-08-20) ### Bug Fixes * button custom colors ([#301](#301)) ([8ebcf5d](8ebcf5d)) * first time set up flow ([c16d6bf](c16d6bf)) * pre-send info if no list set ([#297](#297)) ([f575d94](f575d94)) ### Features * enable public newsletter posts ([#272](#272)) ([ef90bf9](ef90bf9))
🎉 This PR is included in version 1.9.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
All Submissions:
Changes proposed in this Pull Request:
Allows editors to mark sent/published newsletters as publicly viewable and creates an archive page for newsletter posts. If a published newsletter is publicly viewable, its single page is visible to all users. If not, it's visible as a preview only to logged-in WP admin users (drafts are also visible to logged-in admin users). Also hijacks the main query on the Newsletter archive pages and filters out any posts that are NOT marked as publicly viewable.
Further work required?
Posts Inserter block isn't rendering anything on the front-end—need to fix that before we mergefixed in 91b596cCurrently, newsletter ads are not rendered in the page view. I'm not sure this is necessary, but feel free to change my mind.
There might be some further design/front-end work needed on the theme side if we want the archive and single templates for newsletter posts to differ from regular articles (there is probably no need for a byline, or the sidebar widgets, for example). (cc @thomasguillot and/or @laurelfulford)
Maybe disable some interactions with other plugins—e.g. Jetpack Related Posts (this example done in this PR)
Closes #171.
Closes #214.
How to test the changes in this Pull Request:
Check out/build this branch, and flush permalinks. Go to Newsletters > All Newsletters in WP admin.
For any newsletters that have been sent, observe a new "Preview" link when hovering over the item in the post list:
Go to https://[YOUR SITE URL]/newsletter/ to view the newsletter archive page. Right now it should be empty while both logged in and not logged in (only posts explicitly marked as publicly viewable should appear on the archive page).
Edit the newsletter post. Observe a new toggle option in the Document settings sidebar, disabled by default:
Enable the setting. Observe that the previously disabled "Sent" button is now enabled and says "Update." Click "Update" to save the new setting.
Go back to the "All Newsletters" post list. Hover over the post and observe that there's now a "View" link instead of "Preview." Also observe that the "Sent" notice should now have an additional "Published as a page" note attached.
Refresh the archive page—now observe that your public post is listed while both logged in and not logged in.
Visit the newsletter post's single page. Observe that the public post is now visible while both logged in and not logged in.
Set up at least one campaign in the Newspack Campaigns plugin (can be either overlay or inline). Observe that the campaign will never render in the newsletter post's single page under any circumstances.
Edit the newsletter post again and disable the "Make newsletter page public?" setting, then save. Observe that the page is no longer visible in the archive or as a single page to non-logged-in users.
As a sanity check, create a new newsletter but DON'T send it. DO enable the "Make newsletter page public?" setting.
Other information: