<?php
// styles of child theme
function uni_child_theme_style() {

    wp_enqueue_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css' );

    wp_register_style( 'bxslider-styles', get_template_directory_uri() . '/css/bxslider.css', '4.2.3' );
    wp_enqueue_style( 'bxslider-styles');

    wp_register_style( 'ball-clip-rotate-styles', get_template_directory_uri() . '/css/ball-clip-rotate.css', '0.1.0' );
    wp_enqueue_style( 'ball-clip-rotate-styles');

    wp_register_style( 'fancybox-styles', get_template_directory_uri() . '/css/fancybox.css', '2.1.5' );
    wp_enqueue_style( 'fancybox-styles');

    wp_register_style( 'jscrollpane-styles', get_template_directory_uri() . '/css/jscrollpane.css', '2.1.5' );
    wp_enqueue_style( 'jscrollpane-styles');

    wp_register_style( 'selectric-styles', get_template_directory_uri() . '/css/selectric.css', '2.1.5' );
    wp_enqueue_style( 'selectric-styles' );

    if( class_exists( 'WooCommerce' ) ) {
        wp_register_style( 'asana-woocommerce-styles', get_template_directory_uri() . '/css/woocommerce-store.css', '1.6.3' );
        wp_enqueue_style( 'asana-woocommerce-styles' );
    }

    if( function_exists( 'ecwid_check_version' ) ) {
        wp_register_style( 'asana-ecwid-styles', get_template_directory_uri() . '/css/ecwid-store.css', '1.6.3' );
        wp_enqueue_style( 'asana-ecwid-styles' );
    }

    wp_register_style( 'unitheme-styles', get_template_directory_uri() . '/style.css', array('bxslider-styles', 'ball-clip-rotate-styles', 'fancybox-styles',
    'jscrollpane-styles', 'selectric-styles'), '1.6.3', 'all' );
    wp_enqueue_style( 'unitheme-styles' );

    if ( !ot_get_option( 'uni_color_schemes' ) ) {
        wp_register_style( 'unitheme-asana-scheme', get_template_directory_uri() . '/css/scheme-default.css', array('unitheme-styles'), '1.6.3', 'screen' );
        wp_enqueue_style( 'unitheme-asana-scheme' );
    } else {
        $sColourScheme = ot_get_option( 'uni_color_schemes' );
        wp_register_style( 'unitheme-asana-scheme', get_template_directory_uri() . '/css/scheme-'.$sColourScheme.'.css', array('unitheme-styles'), '1.6.3', 'screen' );
        wp_enqueue_style( 'unitheme-asana-scheme' );
    }

    wp_register_style( 'unitheme-adaptive', get_template_directory_uri() . '/css/adaptive.css', array('unitheme-styles'), '1.6.3', 'screen' );
    wp_enqueue_style( 'unitheme-adaptive' );

    wp_register_style( 'unitheme-asana-custom-scheme', get_stylesheet_directory_uri() . '/css/scheme-custom.css', array('unitheme-styles'), '1.6.3', 'screen' );
    wp_enqueue_style( 'unitheme-asana-custom-scheme' );

    wp_register_style( 'unitheme-child-styles', get_stylesheet_directory_uri() . '/style.css', array( 'unitheme-styles' ), '1.6.3', 'screen' );
    wp_enqueue_style( 'unitheme-child-styles' );
}
add_action( 'wp_enqueue_scripts', 'uni_child_theme_style' );

// after setup of the child theme
add_action( 'after_setup_theme', 'uni_theme_child_theme_setup' );
function uni_theme_child_theme_setup() {

    // Enable featured image
    add_theme_support( 'post-thumbnails');

    // Add default posts and comments RSS feed links to head
    add_theme_support( 'automatic-feed-links' );

    // translation files for the child theme
    load_child_theme_textdomain( 'asana-child', get_stylesheet_directory() . '/languages' );
}

// add the new role in the child theme
add_action('after_switch_theme', 'uni_theme_child_activation_func', 10);
function uni_theme_child_activation_func() {
    add_role( 'instructor', esc_html__('Instructor', 'asana'), array('read' => true) );
	$instructor = get_role('instructor');
	$instructor->add_cap('read');
    $instructor->add_cap('edit_published_posts');
    $instructor->add_cap('upload_files');
    $instructor->add_cap('publish_posts');
    $instructor->add_cap('delete_published_posts');
    $instructor->add_cap('edit_posts');
    $instructor->add_cap('delete_posts');
    update_option('posts_per_page', 9);
    flush_rewrite_rules();
}

// remove the new role on theme deactivation
add_action('switch_theme', 'uni_theme_child_deactivation_func');
function uni_theme_child_deactivation_func() {
    remove_role( 'instructor' );
}

/*
// email templates filter
add_filter( 'uni_asana_event_email_filter', 'uni_asana_child_email_templates', 10, 2 );
function uni_asana_child_email_templates( $sTemplateName, $sState ) {
    if ( $sState == 'guest' ) {
        return 'email/event-custom-guest.php';
    } else if ( $sState == 'admin' ) {
        return 'email/event-custom-admin.php';
    }
}

// choose option none
add_filter( 'uni_asana_show_option_none_variation_filter', 'uni_asana_show_option_none_variation_text', 10, 2 );
function uni_asana_show_option_none_variation_text( $sOriginalText, $sVariationName ) {
    return 'Options: ' . $sVariationName;
}

//
add_filter( 'uni_calendar_class_title_filter', 'uni_calendar_class_title_func', 10, 2 );
function uni_calendar_class_title_func( $sClassTitle, $oEvent ) {
    $aEventCustom = get_post_custom($oEvent->ID);
    if (  !empty($aEventCustom['_uni_event_user_id'][0]) ) {
        $oUser = get_user_by('id', $aEventCustom['_uni_event_user_id'][0]);
    }
    return $sClassTitle . ' (' . esc_html( $oUser->display_name ) . ')';
}
*/
?>