Created
February 23, 2017 07:11
-
-
Save adaptifyDesigns/cd35ebff10d39c12318fe89bd760912a to your computer and use it in GitHub Desktop.
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
<?php | |
/* ============================================================================= | |
Apply single-session-plan.php to all session plan post types: | |
Uses $session_plan_slugs global defined below | |
========================================================================== */ | |
add_filter( 'template_include', function( $template ) | |
{ | |
// session plan post types array: | |
global $session_plan_slugs; | |
// get current post type: | |
$post_type = get_post_type(); | |
if ( ! in_array( $post_type, $session_plan_slugs ) ) | |
{ | |
return $template; | |
} | |
return get_stylesheet_directory() . '/single-session-plan.php'; | |
}, 80); | |
// Session Plan CPT array. | |
// Each key represents the CPT slug, and must be 20 chars or less | |
// Each value represents the singular CPT label for WP Admin purposes | |
$session_plan_cpts = array( | |
'session-plan' => array( | |
'label' => 'Gym Session', | |
'current-month' => 'gyms', | |
'landing-page' => '/programs/gyms/', | |
'plan-name' => 'WUWO Gyms', | |
'products' => array( | |
'_apex' => 'WUWOgym_apex', | |
'_small' => 'WUWOgym_small', | |
'_peak' => 'WUWOgym_peak', | |
'_river' => 'WUWOgym_river', | |
'_sunrise' => 'WUWOgym_sunrise', | |
'_annual' => 'WUWOgym_annual' | |
), | |
), | |
'comp-session-plan' => array( | |
'label' => 'Competitor Session', | |
'current-month' => 'competitors', | |
'landing-page' => '/programs/competitors/', | |
'plan-name' => 'WUWO Competitors', | |
'products' => array( | |
'_apex' => 'WUWOcomp_apex', | |
'_small' => 'WUWOcomp_small', | |
'_peak' => 'WUWOcomp_peak', | |
'_river' => 'WUWOcomp_river', | |
'_sunrise' => 'WUWOcomp_sunrise', | |
'_annual' => 'WUWOcomp_annual' | |
), | |
), | |
'kids-session-plan' => array( | |
'label' => 'Kids Session', | |
'current-month' => 'kids', | |
'landing-page' => '/programs/kids/', | |
'plan-name' => 'WUWO Next Gen', | |
'products' => array( | |
'_apex' => 'WUWOkids_apex', | |
'_small' => 'WUWOkids_small', | |
'_peak' => 'WUWOkids_peak', | |
'_river' => 'WUWOkids_river', | |
'_sunrise' => 'WUWOkids_sunrise', | |
'_annual' => 'WUWOkids_annual' | |
), | |
), | |
'teens-session-plan' => array( | |
'label' => 'Teens Session', | |
'current-month' => 'teens', | |
'landing-page' => '/programs/kids/', | |
'plan-name' => 'WUWO Next Gen', | |
'products' => array( | |
'_apex' => 'WUWOkids_apex', | |
'_small' => 'WUWOkids_small', | |
'_peak' => 'WUWOkids_peak', | |
'_river' => 'WUWOkids_river', | |
'_sunrise' => 'WUWOkids_sunrise', | |
'_annual' => 'WUWOkids_annual' | |
), | |
), | |
); | |
// a list of just the slugs (keys of above array): | |
$session_plan_slugs = array_keys( $session_plan_cpts ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment