Closed kimcoleman closed 11 months ago
I asked AI for help writing this code and here's what was output. This is not tested:
`/**
@param string $content Content of the current post. */ public static function the_content( $content ) { // See if any Sitewide Sale CPTs have this post ID set as the Landing Page. $sitewide_sale_id = get_post_meta( get_queried_object_id(), 'swsales_sitewide_sale_id', true );
// This isn't a landing page, return the content. if ( empty( $sitewide_sale_id ) ) { return $content; }
// Load the sale. $sitewide_sale = new SWSales_Sitewide_Sale(); $sale_found = $sitewide_sale->load_sitewide_sale( $sitewide_sale_id );
// The ID we have isn't a Sitewide Sale CPT, or no landing page template is set, return the content. $landing_template = $sitewide_sale->get_landing_page_template(); if ( ! $sale_found || empty( $landing_template ) ) { return $content; }
// Rest of the code remains the same...
// Our return string. $r = '';
// Build the return string. $r .= '
// Template specific filter only if we have a return string to adjust. if ( ! empty( $landing_template ) ) { $r = apply_filters( 'swsales_landing_pagecontent' . $landing_template, $r, $sitewide_sale ); }
// Filter for themes and plugins to modify the landing page content. $r = apply_filters( 'swsales_landing_page_content', $r, $landing_template );
$content = $r;
return $content; }`
This has been added to the latest dev
branch! 👍
Is your feature request related to a problem? Please describe. The code here will add sale period-specific divs that wrap the entire post_content of the associated Sale landing page.
https://github.com/strangerstudios/sitewide-sales/blob/dev/classes/class-swsales-landing-pages.php#L189-L241
This is not needed if the sale isn't using a template.
Describe the solution you'd like We should put a check in this logic to reference if the sale has a 'template' and, if not, return the content without the filter.
Additional context This is especially weird since the same landing page (e.g. the Membership Levels page as we use at PMPro) is used for multiple sales. When the sale is not actively running, that whole page remains wrapped in the post sale div. Not necessary.