Last active
November 5, 2018 13:28
-
-
Save ideadude/dd9067488950474783d7fd860c5732b3 to your computer and use it in GitHub Desktop.
Set the $_REQUEST['level'] var early on specific URLs to help other PMPro Customizations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* We need to set $_REQUEST['level'] early on our | |
* sitewide sales pages to support other customizations. | |
* We can't use is_page because WP isn't fully setup yet. | |
* Update the $sitewide_sales_pages and $default_level_id as needed. | |
* Add to a custom plugin. | |
*/ | |
function set_request_level_on_sitewide_sales_pages() { | |
$sitewide_sales_pages = array( | |
'blackfriday', | |
'cybermonday', | |
'sitewide-sales-launch', | |
'summer-sale', | |
); | |
$default_level_id = 1; | |
// If it's already set, let's go with that. | |
if( !empty( $_REQUEST['level'] ) ) { | |
return; | |
} | |
foreach( $sitewide_sales_pages as $slug ) { | |
if( strpos( $_SERVER['REQUEST_URI'], '/' . $slug ) !== false ) { | |
$_REQUEST['level'] = $default_level_id; | |
define( 'IS_SITEWIDE_SALE', true); | |
} | |
} | |
} | |
add_action( 'init', 'set_request_level_on_sitewide_sales_pages', 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment