Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Fetch theme options array
- global $ats_plugin;
- global $is_IE;
- // Initialize the main variables
- $ats_active = null;
- $the_theme = null;
- // We only want to run this fat chunk of logic on IE since it's IE with the issues
- if ( $is_IE ) {
- // Is a supported useragent active?
- function checkActive($data) {
- global $ats_active;
- $user_agent = $_SERVER['HTTP_USER_AGENT'];
- switch($user_agent) {
- case strpos($user_agent, 'MSIE 5') :
- if ($data['ie5_switch'] == 1 && !empty($data['ie5_theme'])) {
- $ats_active = 'ie5';
- };
- break;
- case strpos($user_agent, 'MSIE 6') :
- if ($data['ie6_switch'] == 1 && !empty($data['ie6_theme'])) {
- $ats_active = 'ie6';
- };
- break;
- case strpos($user_agent, 'MSIE 7') :
- if ($data['ie7_switch'] == 1 && !empty($data['ie7_theme'])) {
- $ats_active = 'ie7';
- };
- break;
- case strpos($user_agent, 'MSIE 8') :
- if ($data['ie8_switch'] == 1 && !empty($data['ie8_theme'])) {
- $ats_active = 'ie8';
- };
- break;
- case strpos($user_agent, 'MSIE 9') :
- if ($data['ie9_switch'] == 1 && !empty($data['ie9_theme'])) {
- $ats_active = 'ie9';
- };
- break;
- default :
- $ats_active = null;
- }
- // Dev Mode Overide
- if(current_user_can('manage_options') && $data['dev_mode'] == 1) {
- $ats_active = 1;
- }
- return $ats_active;
- }
- // Run active agents check
- checkActive($ats_plugin);
- if(!empty($ats_active)) {
- function change_theme() {
- global $ats_plugin;
- global $ats_active;
- global $the_theme;
- if(!empty($ats_plugin['ie5_theme'])) {$ie5 = $ats_plugin['ie5_theme'];} else {$ie5 = null;}
- if(!empty($ats_plugin['ie6_theme'])) {$ie6 = $ats_plugin['ie6_theme'];} else {$ie6 = null;}
- if(!empty($ats_plugin['ie7_theme'])) {$ie7 = $ats_plugin['ie7_theme'];} else {$ie7 = null;}
- if(!empty($ats_plugin['ie8_theme'])) {$ie8 = $ats_plugin['ie8_theme'];} else {$ie8 = null;}
- if(!empty($ats_plugin['ie9_theme'])) {$ie9 = $ats_plugin['ie9_theme'];} else {$ie9 = null;}
- $theme_key = array(
- 'ie5' => $ie5,
- 'ie6' => $ie6,
- 'ie7' => $ie7,
- 'ie8' => $ie8,
- 'ie9' => $ie9
- );
- // Only one value should return
- foreach ($theme_key as $browser => $selection ) {
- if ($ats_active == $browser) {
- $the_theme = $selection;
- }
- }
- // Add the dev mode override
- if( current_user_can('manage_options') && !empty($ats_plugin['dev_theme'])) {
- $the_theme = $ats_plugin['dev_theme'];
- }
- return $the_theme;
- }
- add_filter('template', 'change_theme');
- add_filter('option_template', 'change_theme');
- add_filter('option_stylesheet', 'change_theme');
- }
- }
- // For non-IE browsers, we check if the user is an admin and enable developer mode
- if ( !$is_IE && current_user_can('manage_options') ) {
- if($ats_plugin['dev_mode'] == 1 && !empty($ats_plugin['dev_theme'])) {
- $the_theme = $ats_plugin['dev_theme'];
- }
- function dev_theme() {
- global $the_theme;
- return $the_theme;
- }
- /* @todo if the theme is in developer mode, there should be a visual warning as a reminder */
- if ($ats_plugin['dev_mode'] == 1) {
- add_filter('template', 'dev_theme');
- add_filter('option_template', 'dev_theme');
- add_filter('option_stylesheet', 'dev_theme');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement