/**
 * Register StyleSheets
 */
function spyropress_register_stylesheets()
{
    $options = get_post_meta(get_the_ID(), '_page_options', true);
    // Web Fonts
    $gurl = 'http' . (is_ssl() ? 's' : '') . '://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800|Shadows+Into+Light';
    wp_enqueue_style('google-fonts', $gurl);
    // Libs CSS
    wp_enqueue_style('bootstrap', assets() . 'vendor/bootstrap/bootstrap.css');
    wp_enqueue_style('font-awesome', assets() . 'vendor/fontawesome/css/font-awesome.css');
    wp_enqueue_style('owl-carousel', assets() . 'vendor/owlcarousel/owl.carousel.min.css');
    wp_enqueue_style('owl-carousel-theme', assets() . 'vendor/owlcarousel/owl.theme.default.min.css');
    wp_enqueue_style('magnific-popup', assets() . 'vendor/magnific-popup/magnific-popup.css');
    wp_enqueue_style('jquery-isotope', assets() . 'vendor/isotope/jquery.isotope.css');
    wp_enqueue_style('nivoslider', assets() . 'vendor/nivo-slider/nivo-slider.css');
    wp_enqueue_style('nivo-theme', assets() . 'vendor/nivo-slider/themes/default/default.css');
    wp_enqueue_style('circle-flip-slideshow', assets() . 'vendor/circle-flip-slideshow/css/component.css');
    //if( isset( $options['rev_slider_skin'] ) && !is_str_contain( 'video', $options['rev_slider_skin'] ) ) {
    wp_enqueue_style('mediaelementplayer', assets() . 'vendor/mediaelement/mediaelementplayer.css');
    //}
    // Theme CSS
    wp_enqueue_style('theme', assets_css() . 'theme.css');
    wp_enqueue_style('theme-elements', assets_css() . 'theme-elements.css');
    wp_enqueue_style('theme-blog', assets_css() . 'theme-blog.css');
    if (current_theme_supports('woocommerce')) {
        wp_enqueue_style('theme-shop', assets_css() . 'theme-shop.css');
    }
    wp_enqueue_style('theme-spyropress', assets_css() . 'theme-spyropress.css');
    wp_enqueue_style('theme-animate', assets_css() . 'theme-animate.css');
    // Skin
    if (!current_theme_supports('theme-demo')) {
        wp_enqueue_style('skin', assets_css() . 'skins/' . get_setting('theme_skin', 'blue') . '.css');
    }
    wp_enqueue_style('main', child_url() . 'style.css');
    // Custom CSS
    wp_enqueue_style('custom-theme', child_url() . 'assets/css/custom.css', false);
    // Dynamic StyleSheet
    if (file_exists(dynamic_css_path() . 'dynamic.css')) {
        wp_enqueue_style('dynamic', dynamic_css_url() . 'dynamic.css', false, '2.0.0');
    }
    // Builder StyleSheet
    if (file_exists(dynamic_css_path() . 'builder.css')) {
        wp_enqueue_style('builder', dynamic_css_url() . 'builder.css', false, '2.0.0');
    }
    // modernizr
    wp_enqueue_script('modernizr', assets() . 'vendor/modernizr/modernizr.js', array('jquery'), '2.8.3', false);
}
function syrp_save_builder_css($builder_css = '')
{
    global $wp_filesystem;
    $url = wp_nonce_url('admin.php?page=spyropress-theme', 'spyropress-theme-options');
    $result = true;
    if (false === ($creds = request_filesystem_credentials($url))) {
        $result = false;
    }
    if (!WP_Filesystem($creds)) {
        $result = false;
    }
    $css_file = dynamic_css_path() . 'builder.css';
    if (!$wp_filesystem->is_writable($css_file)) {
        $result = false;
    }
    if ($result) {
        update_option('spyropress_builder_css', false);
        $wp_filesystem->put_contents($css_file, $builder_css);
    } else {
        update_option('spyropress_builder_css', $builder_css);
    }
}
function spyropress_save_dynamic_file($insertion)
{
    global $spyropress, $wp_filesystem;
    // check
    if (empty($insertion)) {
        return false;
    }
    // path to stylesheets
    $less_file = $spyropress->template_path . 'assets/css/dynamic.less';
    $css_file = dynamic_css_path() . 'dynamic.css';
    // no dir
    if (!$wp_filesystem->exists(dynamic_css_path())) {
        $wp_filesystem->mkdir(untrailingslashit(dynamic_css_path()));
    }
    if (!$wp_filesystem->is_readable($less_file) && !$wp_filesystem->is_writable($css_file)) {
        return false;
    }
    // get dynamic.css handler
    return $wp_filesystem->put_contents($css_file, $insertion);
}