Skip to content
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: update donation landing page #3109

Merged
merged 3 commits into from
May 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 40 additions & 15 deletions includes/class-donations.php
Original file line number Diff line number Diff line change
Expand Up @@ -801,35 +801,59 @@ public static function checkout_create_order_line_item( $item, $cart_item_key, $
public static function create_donation_page() {
$revenue_model = 'donations';

$intro = esc_html__( 'With the support of readers like you, we provide thoughtfully researched articles for a more informed and connected community. This is your chance to support credible, community-based, public-service journalism. Please join us!', 'newspack' );
$content_heading = esc_html__( 'Donation', 'newspack' );
$content = esc_html__( "Edit and add to this content to tell your publication's story and explain the benefits of becoming a member. This is a good place to mention any special member privileges, let people know that donations are tax-deductible, or provide any legal information.", 'newspack' );

$title = esc_html__( 'Support our publication', 'newspack' );
$intro = esc_html__( 'With the support of readers like you, we provide thoughtfully researched articles for a more informed and connected community. This is your chance to support credible, community-based, public-service journalism. Please join us!', 'newspack' );
$content = esc_html__( "Edit and add to this content to tell your publication's story and explain the benefits of becoming a member. This is a good place to mention any special member privileges, let people know that donations are tax-deductible, or provide any legal information.", 'newspack' );

$container_block = '
<!-- wp:cover {"url":"https://newspack.com/wp-content/uploads/2024/05/pexels-brotin-biswas-158640-518543-scaled.jpg","dimRatio":60,"overlayColor":"black","isUserOverlayColor":true,"minHeight":80,"minHeightUnit":"vh","align":"full","style":{"spacing":{"padding":{"top":"var:preset|spacing|80","bottom":"var:preset|spacing|80","left":"var:preset|spacing|80","right":"var:preset|spacing|80"}}},"layout":{"type":"constrained"}} -->
thomasguillot marked this conversation as resolved.
Show resolved Hide resolved
<div class="wp-block-cover alignfull" style="padding-top:var(--wp--preset--spacing--80);padding-right:var(--wp--preset--spacing--80);padding-bottom:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80);min-height:80vh">
<span aria-hidden="true" class="wp-block-cover__background has-black-background-color has-background-dim-60 has-background-dim"></span>
<img class="wp-block-cover__image-background" alt="" src="https://newspack.com/wp-content/uploads/2024/05/pexels-brotin-biswas-158640-518543-scaled.jpg" data-object-fit="cover"/>
<div class="wp-block-cover__inner-container">
<!-- wp:columns {"verticalAlignment":"center","align":"wide"} -->
<div class="wp-block-columns alignwide are-vertically-aligned-center">
<!-- wp:column {"verticalAlignment":"center"} -->
<div class="wp-block-column is-vertically-aligned-center">
%1$s
</div>
<!-- /wp:column -->
<!-- wp:column {"verticalAlignment":"center"} -->
<div class="wp-block-column is-vertically-aligned-center">
%2$s
</div>
<!-- /wp:column -->
</div>
<!-- /wp:columns -->
</div>
</div>
<!-- /wp:cover -->';
$heading_block = '
<!-- wp:heading -->
<h2>%s</h2>
<!-- /wp:heading -->';
$intro_block = '
<!-- wp:paragraph -->
<p>%s</p>
<!-- /wp:paragraph -->';
$content_heading_block = '
<!-- wp:heading -->
<h2>%s</h2>
<!-- /wp:heading -->';
$content_block = '
<!-- wp:paragraph -->
<p>%s</p>
<!-- /wp:paragraph -->';

$page_content = sprintf( $intro_block, $intro );
$column_content = sprintf( $heading_block, $title );
$column_content .= sprintf( $intro_block, $intro );
$column_content .= sprintf( $content_block, $content );

if ( 'donations' === $revenue_model ) {
$page_content .= self::get_donations_block();
$page_content = sprintf( $container_block, $column_content, self::get_donations_block() );
} elseif ( 'subscriptions' === $revenue_model ) {
$page_content .= self::get_subscriptions_block();
$page_content = sprintf( $container_block, $column_content, self::get_subscriptions_block() );
}
$page_content .= sprintf( $content_heading_block, $content_heading );
$page_content .= sprintf( $content_block, $content );

$page_args = [
'post_type' => 'page',
'post_title' => __( 'Support our publication', 'newspack' ),
'post_title' => $title,
'post_content' => $page_content,
'post_excerpt' => __( 'Support quality journalism by joining us today!', 'newspack' ),
'post_status' => 'draft',
Expand All @@ -841,6 +865,7 @@ public static function create_donation_page() {
if ( is_numeric( $page_id ) ) {
self::set_donation_page( $page_id );
update_post_meta( $page_id, '_wp_page_template', 'single-feature.php' );
update_post_meta( $page_id, 'newspack_hide_page_title', true );
}

return $page_id;
Expand Down Expand Up @@ -882,7 +907,7 @@ protected static function get_subscriptions_block() {
* @return string Raw block content.
*/
protected static function get_donations_block() {
$block = '<!-- wp:newspack-blocks/donate /-->';
$block = '<!-- wp:newspack-blocks/donate {"className":"is-style-alternate"} /-->';
return $block;
}

Expand Down