function jr_mt_theme($option)
{
    /*	The hooks that (indirectly) call this function are called repeatedly by WordPress, 
    		so do the checking once and store the values in a global array.
    		$jt_mt_theme['stylesheet'] - Stylesheet Name of Theme chosen
    		$jt_mt_theme['template'] - Template Name of Theme chosen
    		
    		Very important note:
    			- get_option( 'jr_mt_settings' ) ['ids']['theme'] is the Theme Subdirectory Name,
    			as opposed to the Template or Stylesheet Name for the Theme.
    			- likewise, the variable local variable $theme
    		These three different values for each Theme must be clearly separated, as all three usually
    		match, but do not have to, e.g. - Child Themes.
    	*/
    global $jr_mt_theme;
    if (!isset($jr_mt_theme)) {
        $jr_mt_theme = array();
    }
    if (!isset($jr_mt_theme[$option])) {
        $theme = jr_mt_chosen();
        $jr_mt_all_themes = jr_mt_all_themes();
        /*	Check to be sure that Theme is still installed.
        			If not:
        				return Everywhere theme if set and it exists,
        					otherwise, FALSE to indicate WordPress Active Theme.
        		*/
        if (FALSE !== $theme && !isset($jr_mt_all_themes[$theme])) {
            $settings = get_option('jr_mt_settings');
            $everything = $settings['current'];
            if ('' !== $everything && isset($jr_mt_all_themes[$everything])) {
                $theme = $everything;
            } else {
                $theme = FALSE;
            }
        }
        if (FALSE === $theme) {
            //	Get both at once, to save a repeat of this logic later:
            $jr_mt_theme['stylesheet'] = jr_mt_current_theme('stylesheet');
            $jr_mt_theme['template'] = jr_mt_current_theme('template');
        } else {
            $jr_mt_theme['stylesheet'] = $jr_mt_all_themes[$theme]->stylesheet;
            $jr_mt_theme['template'] = $jr_mt_all_themes[$theme]->template;
        }
        if (!is_admin()) {
            jr_mt_cookie('all', 'clean');
        }
    }
    $theme = $jr_mt_theme[$option];
    return $theme;
}
Example #2
0
function jr_mt_theme($option)
{
    /*	The hooks that (indirectly) call this function are called repeatedly by WordPress, 
    		so do the checking once and store the values in a global array.
    		$jt_mt_theme['stylesheet'] - Stylesheet Name of Theme chosen
    		$jt_mt_theme['template'] - Template Name of Theme chosen
    		
    		Very important note:
    			- get_option( 'jr_mt_settings' ) ['ids']['theme'] is the Theme Subdirectory Name,
    			as opposed to the Template or Stylesheet Name for the Theme.
    			- likewise, the variable local variable $theme
    		These three different values for each Theme must be clearly separated, as all three usually
    		match, but do not have to, e.g. - Child Themes.
    	*/
    $GLOBALS['jr_mt_cache'] = TRUE;
    global $jr_mt_theme;
    if (!isset($jr_mt_theme)) {
        $jr_mt_theme = array();
    }
    if (!isset($jr_mt_theme[$option])) {
        $theme = jr_mt_chosen();
        if ($theme === FALSE) {
            //	Get both at once, to save a repeat of this logic later:
            $jr_mt_theme['stylesheet'] = jr_mt_current_theme('stylesheet');
            $jr_mt_theme['template'] = jr_mt_current_theme('template');
        } else {
            $themes = wp_get_themes();
            $jr_mt_theme['stylesheet'] = $themes[$theme]->stylesheet;
            $jr_mt_theme['template'] = $themes[$theme]->template;
        }
    }
    $theme = $jr_mt_theme[$option];
    global $jr_mt_cache;
    if ($jr_mt_cache === FALSE) {
        unset($jr_mt_theme[$option]);
    }
    return $theme;
}