Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function pm_extra_mailster_endpoints($endpoints) {
- if(function_exists('mailster_option')) {
- $slugs = implode('|', (array) mailster_option('slugs', array('confirm', 'subscribe', 'unsubscribe', 'profile')));
- $endpoints .= "|{$slugs}";
- }
- return $endpoints;
- }
- add_filter('permalink_manager_endpoints', 'pm_extra_mailster_endpoints');
- function pm_detect_mailster_urls() {
- global $pm_query, $wp_query;
- if(!function_exists('mailster_option') || empty($pm_query['endpoint'])) {
- return;
- }
- // Get list of Mailster endpoints
- $slugs = (array) mailster_option('slugs', array('confirm', 'subscribe', 'unsubscribe', 'profile'));
- if(in_array($pm_query['endpoint'], $slugs)) {
- $wp_query->query_vars['_mailster_page'] = $pm_query['endpoint'];
- // Detect hash & extra parameter
- preg_match('/([a-f0-9]{32})?\/?([a-z0-9\/]*)/', $pm_query['endpoint_value'], $parts);
- $wp_query->query_vars['_mailster_hash'] = $parts[1];
- if(!empty($parts[2])) {
- $wp_query->query_vars['_mailster_extra'] = $parts[2];
- }
- }
- }
- add_action('wp', 'pm_detect_mailster_urls', 99);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement