[Launch your store] Add Coming Soon page templates (#46207)

* Add LYS store only coming soon contents

* fix conflict

* background color

* style login button

* styles

* possibly_update_coming_soon_page

* linting

* get_placeholder_page

* is_active_template

* Add changefile(s) from automation for the following project(s): woocommerce

* Fix lint issue

21 | WARNING | Possible useless method overriding detected (Generic.CodeAnalysis.UselessOverridingMethod.Found)

* Fix lint issue

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Paul Sealock 2024-04-08 20:15:36 +12:00 committed by GitHub
parent f9c4b284ce
commit 65294dd048
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 244 additions and 4 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: update
Comment: Expands unreleased feature

View File

@ -3,6 +3,7 @@
namespace Automattic\WooCommerce\Admin\Features;
use Automattic\WooCommerce\Admin\PageController;
use Automattic\WooCommerce\Blocks\Utils\BlockTemplateUtils;
/**
* Takes care of Launch Your Store related actions.
@ -38,7 +39,7 @@ class LaunchYourStore {
);
if ( isset( $_POST['woocommerce_store_pages_only'] ) ) {
$this->possibly_update_coming_soon_page_content( wc_clean( wp_unslash( $_POST['woocommerce_store_pages_only'] ) ) );
$this->possibly_update_coming_soon_page( wc_clean( wp_unslash( $_POST['woocommerce_store_pages_only'] ) ) );
}
$at_least_one_saved = false;
@ -63,7 +64,7 @@ class LaunchYourStore {
* @param string $next_store_pages_only The next store pages only setting.
* @return void
*/
public function possibly_update_coming_soon_page_content( $next_store_pages_only ) {
public function possibly_update_coming_soon_page( $next_store_pages_only ) {
$option_name = 'woocommerce_store_pages_only';
$current_store_pages_only = get_option( $option_name, null );
@ -93,6 +94,11 @@ class LaunchYourStore {
'post_content' => $next_page_content,
)
);
$template_id = 'yes' === $next_store_pages_only
? 'coming-soon-store-only'
: 'coming-soon-entire-site';
update_post_meta( $page_id, '_wp_page_template', $template_id );
}
}
@ -178,8 +184,8 @@ class LaunchYourStore {
_x( 'Coming Soon', 'Page title', 'woocommerce' ),
$store_pages_only ? $this->get_store_only_coming_soon_content() : $this->get_entire_site_coming_soon_content(),
);
// Make sure the page uses the no-title template. This only works for Twenty twenty-four and is temporary.
update_post_meta( $page_id, '_wp_page_template', 'page-no-title' );
$template_id = $store_pages_only ? 'coming-soon-store-only' : 'coming-soon-entire-site';
update_post_meta( $page_id, '_wp_page_template', $template_id );
// wc_create_page doesn't create options with autoload = yes.
// Since we'll querying the option on WooCommerce home,
// we should update the option to set autoload to yes.

View File

@ -8,6 +8,8 @@ use Automattic\WooCommerce\Blocks\Templates\MiniCartTemplate;
use Automattic\WooCommerce\Blocks\Templates\CartTemplate;
use Automattic\WooCommerce\Blocks\Templates\CheckoutTemplate;
use Automattic\WooCommerce\Blocks\Templates\CheckoutHeaderTemplate;
use Automattic\WooCommerce\Blocks\Templates\ComingSoonEntireSiteTemplate;
use Automattic\WooCommerce\Blocks\Templates\ComingSoonStoreOnlyTemplate;
use Automattic\WooCommerce\Blocks\Templates\OrderConfirmationTemplate;
use Automattic\WooCommerce\Blocks\Templates\ProductAttributeTemplate;
use Automattic\WooCommerce\Blocks\Templates\ProductCatalogTemplate;
@ -43,6 +45,8 @@ class BlockTemplatesRegistry {
ProductSearchResultsTemplate::SLUG => new ProductSearchResultsTemplate(),
CartTemplate::SLUG => new CartTemplate(),
CheckoutTemplate::SLUG => new CheckoutTemplate(),
ComingSoonEntireSiteTemplate::SLUG => new ComingSoonEntireSiteTemplate(),
ComingSoonStoreOnlyTemplate::SLUG => new ComingSoonStoreOnlyTemplate(),
OrderConfirmationTemplate::SLUG => new OrderConfirmationTemplate(),
SingleProductTemplate::SLUG => new SingleProductTemplate(),
);

View File

@ -0,0 +1,56 @@
<?php
namespace Automattic\WooCommerce\Blocks\Templates;
/**
* ComingSoonEntireSiteTemplate class.
*
* @internal
*/
class ComingSoonEntireSiteTemplate extends AbstractPageTemplate {
/**
* The slug of the template.
*
* @var string
*/
const SLUG = 'page-coming-soon-entire-site';
/**
* Returns the title of the template.
*
* @return string
*/
public function get_template_title() {
return _x( 'Page: Coming soon entire site', 'Template name', 'woocommerce' );
}
/**
* Returns the description of the template.
*
* @return string
*/
public function get_template_description() {
return __( 'Page template for Coming soon page when access is restricted for entire site.', 'woocommerce' );
}
/**
* Returns the page object assigned to this template/page.
*
* @return \WP_Post|null Post object or null.
*/
protected function get_placeholder_page() {
$page_id = get_option( 'woocommerce_coming_soon_page_id' );
return $page_id ? get_post( $page_id ) : null;
}
/**
* True when viewing the coming soon page.
*
* @return boolean
*/
protected function is_active_template() {
global $post;
$placeholder = $this->get_placeholder_page();
return null !== $placeholder && $post instanceof \WP_Post && $placeholder->post_name === $post->post_name;
}
}

View File

@ -0,0 +1,56 @@
<?php
namespace Automattic\WooCommerce\Blocks\Templates;
/**
* ComingSoonStoreOnlyTemplate class.
*
* @internal
*/
class ComingSoonStoreOnlyTemplate extends AbstractPageTemplate {
/**
* The slug of the template.
*
* @var string
*/
const SLUG = 'page-coming-soon-store-only';
/**
* Returns the title of the template.
*
* @return string
*/
public function get_template_title() {
return _x( 'Page: Coming soon store only', 'Template name', 'woocommerce' );
}
/**
* Returns the description of the template.
*
* @return string
*/
public function get_template_description() {
return __( 'Page template for Coming soon page when access is restricted for store pages.', 'woocommerce' );
}
/**
* Returns the page object assigned to this template/page.
*
* @return \WP_Post|null Post object or null.
*/
protected function get_placeholder_page() {
$page_id = get_option( 'woocommerce_coming_soon_page_id' );
return $page_id ? get_post( $page_id ) : null;
}
/**
* True when viewing the coming soon page.
*
* @return boolean
*/
protected function is_active_template() {
global $post;
$placeholder = $this->get_placeholder_page();
return null !== $placeholder && $post instanceof \WP_Post && $placeholder->post_name === $post->post_name;
}
}

View File

@ -298,6 +298,8 @@ class BlockTemplateUtils {
public static function get_template_paths( $template_type ) {
$wp_template_filenames = array(
'archive-product.html',
'coming-soon-entire-site.html',
'coming-soon-store-only.html',
'order-confirmation.html',
'page-cart.html',
'page-checkout.html',

View File

@ -0,0 +1,53 @@
<!-- wp:group {"align":"wide","style":{"spacing":{"padding":{"top":"20px","bottom":"20px"}},"color":{"background":"#bea0f2"}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group alignwide has-background" style="background-color:#bea0f2;padding-top:20px;padding-bottom:20px"><!-- wp:group {"align":"wide","layout":{"type":"flex","justifyContent":"space-between","flexWrap":"wrap"}} -->
<div class="wp-block-group alignwide"><!-- wp:group {"style":{"spacing":{"blockGap":"var:preset|spacing|20"},"layout":{"selfStretch":"fit","flexSize":null}},"layout":{"type":"flex"}} -->
<div class="wp-block-group"><!-- wp:site-logo {"width":60} /-->
<!-- wp:group {"style":{"spacing":{"blockGap":"0px"}}} -->
<div class="wp-block-group"><!-- wp:site-title {"level":0} /--></div>
<!-- /wp:group --></div>
<!-- /wp:group -->
<!-- wp:group {"layout":{"type":"flex","flexWrap":"nowrap"}} -->
<div class="wp-block-group"><!-- wp:social-links {"iconColor":"contrast","iconColorValue":"#111111","style":{"layout":{"selfStretch":"fit","flexSize":null}},"className":"is-style-logos-only"} -->
<ul class="wp-block-social-links has-icon-color is-style-logos-only"><!-- wp:social-link {"url":"admin@example.com","service":"linkedin"} /-->
<!-- wp:social-link {"url":"admin@example.com","service":"instagram"} /-->
<!-- wp:social-link {"url":"admin@example.com","service":"facebook"} /--></ul>
<!-- /wp:social-links -->
<!-- wp:loginout /--></div>
<!-- /wp:group --></div>
<!-- /wp:group --></div>
<!-- /wp:group -->
<!-- wp:spacer {"height":"25px"} -->
<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->
<!-- wp:post-content {"align":"wide"} /-->
<!-- wp:group {"style":{"spacing":{"padding":{"top":"var:preset|spacing|30","bottom":"var:preset|spacing|10"}}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group" style="padding-top:var(--wp--preset--spacing--30);padding-bottom:var(--wp--preset--spacing--10)"><!-- wp:group {"align":"wide","style":{"spacing":{"padding":{"top":"var:preset|spacing|30","bottom":"0"}}}} -->
<div class="wp-block-group alignwide" style="padding-top:var(--wp--preset--spacing--30);padding-bottom:0"><!-- wp:paragraph {"align":"center","style":{"elements":{"link":{"color":{"text":"var:preset|color|contrast"}}}},"textColor":"contrast-2","fontSize":"small"} -->
<p class="has-text-align-center has-contrast-2-color has-text-color has-link-color has-small-font-size">
Powered by
<a style="text-decoration: none;" href="https://woocommerce.com" rel="nofollow">WooCommerce</a>
</p>
<!-- /wp:paragraph --></div>
<!-- /wp:group --></div>
<!-- /wp:group -->
<style>
body.page-template-coming-soon-entire-site {
background-color: #bea0f2;
}
.page-template-coming-soon-entire-site .wp-block-loginout {
background-color: #000000;
padding: 7px 8px;
border-radius: 6px;
}
.page-template-coming-soon-entire-site .wp-block-loginout a {
color: #ffffff;
text-decoration: none;
line-height: 26px;
}
</style>

View File

@ -0,0 +1,3 @@
<!-- wp:template-part {"slug":"header","tagName":"header"} /-->
<!-- wp:post-content {"align":"wide"} /-->
<!-- wp:template-part {"slug":"footer","tagName":"footer"} /-->

View File

@ -0,0 +1,53 @@
<!-- wp:group {"align":"wide","style":{"spacing":{"padding":{"top":"20px","bottom":"20px"}},"color":{"background":"#bea0f2"}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group alignwide has-background" style="background-color:#bea0f2;padding-top:20px;padding-bottom:20px"><!-- wp:group {"align":"wide","layout":{"type":"flex","justifyContent":"space-between","flexWrap":"wrap"}} -->
<div class="wp-block-group alignwide"><!-- wp:group {"style":{"spacing":{"blockGap":"var:preset|spacing|20"},"layout":{"selfStretch":"fit","flexSize":null}},"layout":{"type":"flex"}} -->
<div class="wp-block-group"><!-- wp:site-logo {"width":60} /-->
<!-- wp:group {"style":{"spacing":{"blockGap":"0px"}}} -->
<div class="wp-block-group"><!-- wp:site-title {"level":0} /--></div>
<!-- /wp:group --></div>
<!-- /wp:group -->
<!-- wp:group {"layout":{"type":"flex","flexWrap":"nowrap"}} -->
<div class="wp-block-group"><!-- wp:social-links {"iconColor":"contrast","iconColorValue":"#111111","style":{"layout":{"selfStretch":"fit","flexSize":null}},"className":"is-style-logos-only"} -->
<ul class="wp-block-social-links has-icon-color is-style-logos-only"><!-- wp:social-link {"url":"admin@example.com","service":"linkedin"} /-->
<!-- wp:social-link {"url":"admin@example.com","service":"instagram"} /-->
<!-- wp:social-link {"url":"admin@example.com","service":"facebook"} /--></ul>
<!-- /wp:social-links -->
<!-- wp:loginout /--></div>
<!-- /wp:group --></div>
<!-- /wp:group --></div>
<!-- /wp:group -->
<!-- wp:spacer {"height":"25px"} -->
<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->
<!-- wp:post-content {"align":"wide"} /-->
<!-- wp:group {"style":{"spacing":{"padding":{"top":"var:preset|spacing|30","bottom":"var:preset|spacing|10"}}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group" style="padding-top:var(--wp--preset--spacing--30);padding-bottom:var(--wp--preset--spacing--10)"><!-- wp:group {"align":"wide","style":{"spacing":{"padding":{"top":"var:preset|spacing|30","bottom":"0"}}}} -->
<div class="wp-block-group alignwide" style="padding-top:var(--wp--preset--spacing--30);padding-bottom:0"><!-- wp:paragraph {"align":"center","style":{"elements":{"link":{"color":{"text":"var:preset|color|contrast"}}}},"textColor":"contrast-2","fontSize":"small"} -->
<p class="has-text-align-center has-contrast-2-color has-text-color has-link-color has-small-font-size">
Powered by
<a style="text-decoration: none;" href="https://woocommerce.com" rel="nofollow">WooCommerce</a>
</p>
<!-- /wp:paragraph --></div>
<!-- /wp:group --></div>
<!-- /wp:group -->
<style>
body.page-template-coming-soon-entire-site {
background-color: #bea0f2;
}
.page-template-coming-soon-entire-site .wp-block-loginout {
background-color: #000000;
padding: 7px 8px;
border-radius: 6px;
}
.page-template-coming-soon-entire-site .wp-block-loginout a {
color: #ffffff;
text-decoration: none;
line-height: 26px;
}
</style>

View File

@ -0,0 +1,3 @@
<!-- wp:template-part {"slug":"header","tagName":"header"} /-->
<!-- wp:post-content {"align":"wide"} /-->
<!-- wp:template-part {"slug":"footer","tagName":"footer"} /-->