/** * Add stylesheets to sliders set to display automatically * */ function FA_add_styles() { $sliders = FA_display(); if (!$sliders) { return; } foreach ($sliders as $slider_id) { $theme = FA_slider_options($slider_id, '_fa_lite_theme'); /** * This is for backwards compatibility. * Prior to V2.4, theme Classic was actually 2 different themes: Light and Dark. * If slideshow was set on either dark or lite theme, those themes should no longer exist. * If user saved them, we'll use them. If not, switch to classic. */ $load_classic = FA_should_load_classic($theme['active_theme']); if ($load_classic) { $theme = $load_classic; } // theme path and url $theme_path = FA_theme_path($theme['active_theme']); $theme_url = FA_theme_url($theme['active_theme']); // if theme folder doesn't exist, skip this slider if (!$theme_path) { continue; // bail out } // enqueue main stylesheet $stylesheet_handle = 'FA_style_' . $theme['active_theme']; $stylesheet_url = $theme_url . '/stylesheet.css'; wp_enqueue_style($stylesheet_handle, $stylesheet_url); // enqueue color stylesheet if (!empty($theme['active_theme_color'])) { $color_style_handle = $stylesheet_handle . '-' . $theme['active_theme_color']; $color_style_url = $theme_url . '/colors/' . $theme['active_theme_color']; wp_enqueue_style($color_style_handle, $color_style_url); } } }
/** * Themes backwards compatibility function. Based on theme name passed to it, * if theme is old dark or old light, verifies the existance of the themes. * * If dark of light is set, it will return an array with classic theme and appropriate * color stylesheet for it. * * @param string $theme - theme name * @return bool * @since 2.4.2 */ function FA_should_load_classic($theme) { if ('dark' == $theme || 'light' == $theme) { $check_theme_path = FA_theme_path($theme); // verifies folder existance // theme dark or light doesn't exist. Switch to classic if (!$check_theme_path) { $result = array('active_theme' => 'classic', 'active_theme_color' => $theme . '.css'); return $result; } } return false; }