MOON
Server: Apache
System: Linux server.netcommlabs.in 3.10.0-1160.83.1.el7.x86_64 #1 SMP Wed Jan 25 16:41:43 UTC 2023 x86_64
User: dermova (1051)
PHP: 5.4.45
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/dermova/www/india/wp-content/themes/ri-colias/included/theme-function/rit-function.php
<?php
/**
 * Theme function
 *
 * Theme URI: https://rivertheme.com
 * Author:  River theme
 *
 */

/* VARIABLE DEFINITIONS ============================================================================================= */
if(!defined('RIT_TEMPLATE_PATH')){
    define('RIT_TEMPLATE_PATH', get_template_directory());
}
if(!defined('RIT_INCLUDES_PATH')) {
    define('RIT_INCLUDES_PATH', RIT_TEMPLATE_PATH . '/included');
}
if(!defined('RIT_TEMPLATE_PATH')) {
    define('RIT_LOCAL_PATH', get_template_directory_uri());
}

if (!function_exists('RIT_CUSTOM_CONTENT')) {
    function RIT_CUSTOM_CONTENT() {
        include_once(RIT_INCLUDES_PATH . '/rit_header.php');
    }
    add_action('init', 'RIT_CUSTOM_CONTENT', 0);
}

/*  Setup Theme ===================================================================================================== */
add_action( 'after_setup_theme', 'river_theme_setup' );
if ( ! function_exists( 'river_theme_setup' ) ) :
    function river_theme_setup() {
        load_theme_textdomain( 'ri-colias', get_template_directory() . '/languages' );

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

        //  Let WordPress manage the document title.
        add_theme_support( 'title-tag' );

        //  Enable support for Post Thumbnails on posts and pages.
        add_theme_support( 'post-thumbnails' );
        set_post_thumbnail_size( 825, 510, true );

        add_image_size( 'thumb-image', 600, 450, true);

        //Enable support for Post Formats.
        add_theme_support( 'html5', array(
            'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
        ) );
        add_theme_support( 'post-formats', array(
            'aside', 'image', 'video', 'quote', 'link', 'gallery', 'status', 'audio', 'chat'
        ) );

        add_theme_support( 'custom-header' );

        add_theme_support( 'custom-background' );

        add_theme_support( "title-tag" );

        add_theme_support( 'woocommerce' );

    }
endif; // river_theme_setup
/* Skin ==============================================================================================================*/

if(!function_exists('rit_skins')){
    function rit_skins() {
        global  $post,$wp_query;
        $currentSkin = get_theme_mod('rit_skins','style-default');
        if(is_page()){
            $currentSkin=get_post_meta($post->ID, 'page_skins',true);
            if($currentSkin == 'global' || ($currentSkin =='')){
                $currentSkin = get_theme_mod('rit_skins','style-default');
            }
        }
        return $currentSkin;
    }
}
/* Config menu =======================================================================================================*/
if(!function_exists('rit_topbar_config')){
    function rit_topbar_config() {
        global  $post,$wp_query;
        $configTopbar = get_theme_mod('rit_topbar_config','');
        if(isset($configTopbar) & $configTopbar == '0'){
            $configTopbar='hidden';
        }
        return $configTopbar;
    }
}

if(!function_exists('rit_config_menu')){
    function rit_config_menu() {
        global  $post,$wp_query;
        $configMenu = get_theme_mod('rit_menu_config','');
        if(is_page()){
            $configMenu=get_post_meta($post->ID, 'menu_config',true);
        }
        if(isset($configMenu) & $configMenu == '1'){
            $configMenu='menu-full';
        }
        return $configMenu;
    }
}

if(!function_exists('rit_keep_menu')){
    function rit_keep_menu() {
        global  $post,$wp_query;
        $configMenu = get_theme_mod('rit_menu_keep','');
        if(is_page()){
            $configMenu=get_post_meta($post->ID, 'menu_keep',true);
        }
        if(isset($configMenu) & $configMenu == '1'){
            $configMenu='keep-header';
        }
        return $configMenu;
    }
}
if(!function_exists('rit_menu_transparent')){
    function rit_menu_transparent() {
        global  $post,$wp_query;
        $menutransparent="";
        if(is_page()){
            $menutransparent=get_post_meta($post->ID, 'menu_transparent',true);
            if(isset($menutransparent) & $menutransparent == '1'){
                $menutransparent='menu-transparent';
            }
        }
        return $menutransparent;
    }
}
if(!function_exists('rit_menu_topbar')){
    function rit_menu_topbar() {
        global  $post,$wp_query;
        $menu_topbar="";
        if(is_page()){
            $menu_topbar=get_post_meta($post->ID, 'menu_topbar',true);
            if(isset($menu_topbar) & $menu_topbar == '0'){
                $menu_topbar='topbar-hiden';
            }
            else{
                $menu_topbar="topbar-show";
            }
        }
        return $menu_topbar;
    }
}

function ri_font_url() {
    $fonts_url = '';

    /* Translators: If there are characters in your language that are not
    * supported by Lora, translate this to 'off'. Do not translate
    * into your own language.
    */
    $lato = _x( 'on', 'Lato font: on or off', 'ri-colias' );

    $droid_serif = _x( 'on', 'Droid Serif font: on or off', 'ri-colias' );

    $montserrat = _x( 'on', 'Droid Serif font: on or off', 'ri-colias' );

    $raleway = _x( 'on', 'Raleway font: on or off', 'ri-colias' );

    if ( 'off' !== $lato || 'off' !== $droid_serif || 'off' !== $raleway || 'off' !== $montserrat ) {
        $font_families = array();

        if ( 'off' !== $lato ) {
            $font_families[] = 'Lato:300,400,700,900,300italic';
        }

        if ( 'off' !== $droid_serif ) {
            $font_families[] = 'Droid Serif:400,400italic';
        }
        if ( 'off' !== $raleway ) {
            $font_families[] = 'Raleway:300,400,600,700,800,300italic';
        }
        if ( 'off' !== $montserrat ) {
            $font_families[] = 'Montserrat:400,700';
        }


        $query_args = array(
            'family' => urlencode( implode( '|', $font_families ) ),
            'subset' => urlencode( 'latin,latin-ext' ),
        );

        $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
    }

    return esc_url_raw( $fonts_url );
}
/* LOAD Front-end SCRIPTS  ========================================================================================== */
add_action( 'wp_enqueue_scripts', 'river_theme_scripts' );
function river_theme_scripts() {
    /*  RIT add require css  */

    // Add  fonts, used in the main stylesheet.
    wp_enqueue_style( 'river_fonts', ri_font_url(), array(), null );

    if(is_rtl()){
        wp_enqueue_style('bootstrap',get_template_directory_uri().'/css/bootstrap-rtl.css', false, null);
    }else{
        wp_enqueue_style('bootstrap',get_template_directory_uri().'/css/bootstrap.css', false, null);
    }

    wp_enqueue_style( 'font-awesome', get_template_directory_uri(). '/css/font-awesome.css', false, null );

    wp_enqueue_style( 'owl.carousel', get_template_directory_uri(). '/css/owl.carousel.css', false, null );

    wp_enqueue_style( 'owl.theme', get_template_directory_uri(). '/css/owl.theme.css', false, null );

    wp_enqueue_style( 'RIT_MAIN', get_template_directory_uri(). '/style.css', false, null );

    $currentSkin = str_replace('','',rit_skins() );
    wp_enqueue_style('RIT_MAIN_CSS', get_template_directory_uri().'/css/'.$currentSkin.'.css' );


    /*  RIT add require js  */

    wp_enqueue_script( 'jquery', get_template_directory_uri().'/js/jquery.min.js');

    //register html5 js
    wp_enqueue_script( 'html5', get_template_directory_uri().'/js/html5.js');

    //register bootstrap js
    wp_enqueue_script( 'bootstrap', get_template_directory_uri().'/js/bootstrap.js');

    //register imagesloaded js
    wp_enqueue_script( 'imagesloaded', get_template_directory_uri().'/js/imagesloaded.js');

    //register isotope.pkgd.min js
    wp_enqueue_script( 'isotope.pkgd.min', get_template_directory_uri().'/js/isotope.pkgd.min.js');

    //register parallax js
    wp_enqueue_script( 'parallax', get_template_directory_uri().'/js/parallax.js');

    //register isotope-init js
    wp_enqueue_script( 'isotope-init', get_template_directory_uri().'/js/isotope-init.js');

    //register owl.carousel js
    wp_enqueue_script('owl.carousel', get_template_directory_uri() . '/js/owl.carousel.js');

    //register rit-woocommerces js
    wp_enqueue_script( 'rit-woocommerces', get_template_directory_uri().'/js/rit-woocommerces.js');


    wp_enqueue_style('RIT_MASTERSLIDER_CSS', get_template_directory_uri() . '/assets/masterslider/css/masterslider.main.min.css');

    wp_enqueue_script   ('RIT_MASTERSLIDER_JS', get_template_directory_uri() . '/assets/masterslider/js/masterslider.min.js');

    //register tabs responsive  js
    wp_enqueue_script   ('RIT_easyResponsiveTabs_JS', get_template_directory_uri() . '/assets/easyResponsiveTabs/easyResponsiveTabs.js');

    wp_enqueue_style   ('RIT_easyResponsiveTabs_CSS', get_template_directory_uri() . '/assets/easyResponsiveTabs/easy-responsive-tabs.css');

    wp_enqueue_script('Slicknav', get_template_directory_uri() . '/js/jquery.slicknav.min.js');

    wp_enqueue_style   ('Slicknav', get_template_directory_uri() . '/css/slicknav.css');



    //register bx slider  js
    wp_enqueue_script('RIT_JS_BX', get_template_directory_uri() . '/assets/bxslider/jquery.bxslider.min.js');

    // Load our main stylesheet.
    //    wp_enqueue_style( 'river_theme-style', get_stylesheet_uri() );

    // Load the Internet Explorer specific stylesheet.
    wp_enqueue_style( 'river_theme-ie', get_template_directory_uri() . '/css/ie.css', array( 'river_theme-style' ), '20141010' );
    wp_style_add_data( 'river_theme-ie', 'conditional', 'lt IE 9' );

    // Load the Internet Explorer 7 specific stylesheet.
    wp_enqueue_style( 'river_theme-ie7', get_template_directory_uri() . '/css/ie7.css', array( 'river_theme-style' ), '20141010' );
    wp_style_add_data( 'river_theme-ie7', 'conditional', 'lt IE 8' );


    wp_enqueue_script( 'river_theme-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20141010', true );

    if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
        wp_enqueue_script( 'comment-reply' );
    }

    if ( is_singular() && wp_attachment_is_image() ) {
        wp_enqueue_script( 'river_theme-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20141010' );
    }
    // RIT JS include
    wp_enqueue_script('RIT_JS_THEME', get_template_directory_uri() . '/js/rit.js');
}

/* LOAD Back-end SCRIPTS============================================================================================= */
add_action('admin_init', 'rit_admin_scripts');
function rit_admin_scripts() {
    wp_enqueue_script('admin-functions', get_template_directory_uri() . '/js/rit-admin.js', 'jquery', '1.0', TRUE);
}

/* Register the required plugins    ================================================================================= */
add_action( 'tgmpa_register', 'my_theme_register_required_plugins' );

/**
 * Register the required plugins for this theme.
 *
 * In this example, we register two plugins - one included with the TGMPA library
 * and one from the .org repo.
 *
 * The variable passed to tgmpa_register_plugins() should be an array of plugin
 * arrays.
 *
 * This function is hooked into tgmpa_init, which is fired within the
 * TGM_Plugin_Activation class constructor.
 */
function my_theme_register_required_plugins() {
    /*
     * Array of plugin arrays. Required keys are name and slug.
     * If the source is NOT from the .org repo, then source is also required.
     */
    $plugins = array(

        /* This is an example of how to include a plugin pre-packaged with a theme.
        array(
            'name'               => 'TGM Example Plugin', // The plugin name.
            'slug'               => 'tgm-example-plugin', // The plugin slug (typically the folder name).
            'source'             => get_stylesheet_directory() . '/lib/plugins/tgm-example-plugin.zip', // The plugin source.
            'required'           => true, // If false, the plugin is only 'recommended' instead of required.
            'version'            => '', // E.g. 1.0.0. If set, the active plugin must be this version or higher. If the plugin version is higher than the plugin version installed, the user will be notified to update the plugin.
            'force_activation'   => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch.
            'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins.
            'external_url'       => '', // If set, overrides default API URL and points to an external URL.
        ),*/

        //Contact form 7
        array(
            'name'      => 'Contact Form 7',
            'slug'      => 'contact-form-7',
            'required'  => true,
        ),

        //Image Widget
        array(
            'name'      => 'Image Widget',
            'slug'      => 'image-widget',
            'required'  => true,
        ),
        //MailChimp for WordPress
        array(
            'name'      => 'MailChimp for WordPress ',
            'slug'      => 'mailchimp-for-wp',
            'required'  => true,
        ),
        //Max Mega Menu
        array(
            'name'      => 'Max Mega Menu',
            'slug'      => 'megamenu',
            'required'  => true,
        ),
        //Revolution slider
        array(
            'name'      => 'Revolution slider',
            'slug'      => 'revslider',
            'source'    =>  get_stylesheet_directory() . '/lib/plugins/revslider.zip',
            'required'  => true,
        ),
        //Rit-core
        array(
            'name'      => 'RiverTheme Core',
            'slug'      => 'rit-core', //plugin name
            'source'    => get_stylesheet_directory() . '/lib/plugins/rit-core.zip', // The plugin source.
            'required'  => true,
        ),
        //WPBakery Visual Composer
        array(
            'name'      => 'WPBakery Visual Compose',
            'slug'      => 'js_composer',
            'source'    => get_stylesheet_directory() . '/lib/plugins/js_composer.zip', // The plugin source.
            'required'  => true,
        ),
        //Vafour
        array(
            'name'      => 'Vafour',
            'slug'      => 'vafpress-post-formats-ui-develop',
            'source'    => get_stylesheet_directory() . '/lib/plugins/vafpress-post-formats-ui-develop.zip', // The plugin source.
            'required'  => true,
        ),
        //woocommerce
        array(
            'name'      => 'WooCommerce',
            'slug'      => 'woocommerce',
            'required'  => true,
        ),
        //WooCommerce Currency Switcher
        array(
            'name'      => 'WooCommerce Currency Switcher',
            'slug'      => 'woocommerce-currency-switcher',
            'source'    => get_stylesheet_directory() . '/lib/plugins/woocommerce-currency-switcher.zip', // The plugin source.
            'required'  => true,
        ),
        //YITH WooCommerce Compare
        array(
            'name'      => 'YITH WooCommerce Compare ',
            'slug'      => 'yith-woocommerce-compare',
            'required'  => true,
        ),
        //YITH WooCommerce Quick View
        array(
            'name'      => 'YITH WooCommerce Quick View',
            'slug'      => 'yith-woocommerce-quick-view',
            'required'  => true,
        ),
        //YITH WooCommerce Wishlist
        array(
            'name'      => 'YITH WooCommerce Wishlist',
            'slug'      => 'yith-woocommerce-wishlist',
            'required'  => true,
        ),
        //YITH WooCommerce Zoom Magnifier
        array(
            'name'      => 'YITH WooCommerce Zoom Magnifier',
            'slug'      => 'yith-woocommerce-zoom-magnifier',
            'required'  => true,
        )

    );

    /*
     * Array of configuration settings. Amend each line as needed.
     *
     * TGMPA will start providing localized text strings soon. If you already have translations of our standard
     * strings available, please help us make TGMPA even better by giving us access to these translations or by
     * sending in a pull-request with .po file(s) with the translations.
     *
     * Only uncomment the strings in the config array if you want to customize the strings.
     *
     * Some of the strings are wrapped in a sprintf(), so see the comments at the
     * end of each line for what each argument will be.
     */
    $config = array(
        'id'           => 'tgmpa',                 // Unique ID for hashing notices for multiple instances of TGMPA.
        'default_path' => '',                      // Default absolute path to pre-packaged plugins.
        'menu'         => 'tgmpa-install-plugins', // Menu slug.
        'parent_slug'  => 'themes.php',            // Parent menu slug.
        'capability'   => 'edit_theme_options',    // Capability needed to view plugin install page, should be a capability associated with the parent menu used.
        'has_notices'  => true,                    // Show admin notices or not.
        'dismissable'  => true,                    // If false, a user cannot dismiss the nag message.
        'dismiss_msg'  => '',                      // If 'dismissable' is false, this message will be output at top of nag.
        'is_automatic' => false,                   // Automatically activate plugins after installation or not.
        'message'      => '',                      // Message to output right before the plugins table.
        'strings'      => array(
            'page_title'                      => esc_html__( 'Install Required Plugins', 'theme-slug' ),
            'menu_title'                      => esc_html__( 'Install Plugins', 'theme-slug' ),
            'installing'                      => esc_html__( 'Installing Plugin: %s', 'theme-slug' ), // %s = plugin name.
            'oops'                            => esc_html__( 'Something went wrong with the plugin API.', 'theme-slug' ),
            'notice_can_install_required'     => _n_noop(
                'This theme requires the following plugin: %1$s.',
                'This theme requires the following plugins: %1$s.',
                'theme-slug'
            ), // %1$s = plugin name(s).
            'notice_can_install_recommended'  => _n_noop(
                'This theme recommends the following plugin: %1$s.',
                'This theme recommends the following plugins: %1$s.',
                'theme-slug'
            ), // %1$s = plugin name(s).
            'notice_cannot_install'           => _n_noop(
                'Sorry, but you do not have the correct permissions to install the %1$s plugin.',
                'Sorry, but you do not have the correct permissions to install the %1$s plugins.',
                'theme-slug'
            ), // %1$s = plugin name(s).
            'notice_ask_to_update'            => _n_noop(
                'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.',
                'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.',
                'theme-slug'
            ), // %1$s = plugin name(s).
            'notice_ask_to_update_maybe'      => _n_noop(
                'There is an update available for: %1$s.',
                'There are updates available for the following plugins: %1$s.',
                'theme-slug'
            ), // %1$s = plugin name(s).
            'notice_cannot_update'            => _n_noop(
                'Sorry, but you do not have the correct permissions to update the %1$s plugin.',
                'Sorry, but you do not have the correct permissions to update the %1$s plugins.',
                'theme-slug'
            ), // %1$s = plugin name(s).
            'notice_can_activate_required'    => _n_noop(
                'The following required plugin is currently inactive: %1$s.',
                'The following required plugins are currently inactive: %1$s.',
                'theme-slug'
            ), // %1$s = plugin name(s).
            'notice_can_activate_recommended' => _n_noop(
                'The following recommended plugin is currently inactive: %1$s.',
                'The following recommended plugins are currently inactive: %1$s.',
                'theme-slug'
            ), // %1$s = plugin name(s).
            'notice_cannot_activate'          => _n_noop(
                'Sorry, but you do not have the correct permissions to activate the %1$s plugin.',
                'Sorry, but you do not have the correct permissions to activate the %1$s plugins.',
                'theme-slug'
            ), // %1$s = plugin name(s).
            'install_link'                    => _n_noop(
                'Begin installing plugin',
                'Begin installing plugins',
                'theme-slug'
            ),
            'update_link' 					  => _n_noop(
                'Begin updating plugin',
                'Begin updating plugins',
                'theme-slug'
            ),
            'activate_link'                   => _n_noop(
                'Begin activating plugin',
                'Begin activating plugins',
                'theme-slug'
            ),
            'return'                          => esc_html__( 'Return to Required Plugins Installer', 'theme-slug' ),
            'plugin_activated'                => esc_html__( 'Plugin activated successfully.', 'theme-slug' ),
            'activated_successfully'          => esc_html__( 'The following plugin was activated successfully:', 'theme-slug' ),
            'plugin_already_active'           => esc_html__( 'No action taken. Plugin %1$s was already active.', 'theme-slug' ),  // %1$s = plugin name(s).
            'plugin_needs_higher_version'     => esc_html__( 'Plugin not activated. A higher version of %s is needed for this theme. Please update the plugin.', 'theme-slug' ),  // %1$s = plugin name(s).
            'complete'                        => esc_html__( 'All plugins installed and activated successfully. %1$s', 'theme-slug' ), // %s = dashboard link.
            'contact_admin'                   => esc_html__( 'Please contact the administrator of this site for help.', 'tgmpa' ),

            'nag_type'                        => 'updated', // Determines admin notice type - can only be 'updated', 'update-nag' or 'error'.
        )
    );

    tgmpa( $plugins, $config );

}
/**
 * Custom template tags for this theme.
 */
require get_template_directory() . '/included/templates/template-tags.php';

/*  Include Shortcode =============================================================================================== */

require_once(RIT_INCLUDES_PATH . '/shortcode/shortcode.php');

/*  Include Customizer ============================================================================================== */
require_once(RIT_INCLUDES_PATH . '/customize/customize-style.php');

require_once(RIT_INCLUDES_PATH . '/customize/customize.php');



/*  Include Widgets ================================================================================================= */

require_once(RIT_INCLUDES_PATH . '/widgets/contact-info.php');

require_once(RIT_INCLUDES_PATH . '/widgets/support.php');

require_once(RIT_INCLUDES_PATH . '/widgets/service.php');

require_once(RIT_INCLUDES_PATH . '/widgets/social.php');

require_once(RIT_INCLUDES_PATH . '/widgets/recent-post.php');

require_once(RIT_INCLUDES_PATH . '/widgets/search.php');

// Author Link Social
function rit_social_author( $contactmethods ) {

    $contactmethods['twitter']   = 'Twitter Username';
    $contactmethods['facebook']  = 'Facebook Username';
    $contactmethods['google']    = 'Google Plus Username';
    $contactmethods['tumblr']    = 'Tumblr Username';
    $contactmethods['instagram'] = 'Instagram Username';
    $contactmethods['pinterest'] = 'Pinterest Username';

    return $contactmethods;
}
add_filter('user_contactmethods','rit_social_author',10,1);

// Substring
if(!function_exists('rit_substring')) {
    function rit_substring($string, $number)
    {
        if (strlen($string) <= $number) {
            return $string;
        } else {
            $new_string = substr($string, 0, $number);
            return $new_string;
        }
    }
}

// Sub String Content
if(!function_exists('rit_content')) {
    function rit_content($limit)
    {
        $content = explode(' ', get_the_content(), $limit);
        if (count($content) >= $limit) {
            array_pop($content);
            $content = implode(" ", $content) . '...';
        } else {
            $content = implode(" ", $content) . '';
        }
        $content = preg_replace('/\[.+\]/', '', $content);
        $content = apply_filters('the_content', $content);
        $content = str_replace(']]>', ']]&gt;', $content);
        return $content;
    }
}


// List Google Font
if(!function_exists('rit_googlefont')){
    function rit_googlefont(){
        $listGoogleFont = file_get_contents(RIT_TEMPLATE_PATH . '/assets/googlefont/googlefont.json');
        if($listGoogleFont){
            $gfont = json_decode($listGoogleFont);
            $fontarray = $gfont->items;
            $options = array();
            foreach($fontarray as $font){
                $options[$font->family] = $font->family;
            }
            return $options;
        }
        return null;
    }
}

// Category
if(!function_exists('sp_category')) {
    function sp_category($separator)
    {
        $first_time = 1;
        foreach ((get_the_category()) as $category) {
            if ($first_time == 1) {
                echo '<a href="' . get_category_link($category->term_id) . '" title="' . sprintf(__("View all posts in %s", "RIT"), $category->name) . '" ' . '>' . $category->name . '</a>';
                $first_time = 0;
            } else {
                echo esc_attr($separator) . '<a href="' . get_category_link($category->term_id) . '" title="' . sprintf(__("View all posts in %s", "RIT"), $category->name) . '" ' . '>' . $category->name . '</a>';
            }
        }
    }
}


// -------------------- Register Navigation --------------------- //
register_nav_menus( array(
    'primary_navigation'    => esc_html__( 'Primary Navigation', 'ri-colias' ),
    'top_navigation'        => esc_html__( 'Top Navigation', 'ri-colias' ),
    'bottom_navigation'     => esc_html__( 'Bottom Navigation', 'ri-colias' ),
) );
// -------------------- Register Sidebar --------------------- //

if ( function_exists('register_sidebar') ) {

    register_sidebar( array(
        'name'          => esc_html__( 'Widget Header ', 'ri-colias' ),
        'id'            => 'header-top',
        'description'   => esc_html__( 'Add widgets here to appear in your header .', 'ri-colias' ),
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget'  => '</aside>',
        'before_title'  => '<h2 class="widget-title">',
        'after_title'   => '</h2>',
    ) );
    register_sidebar( array(
        'name'          => esc_html__( 'Widget Header Center', 'ri-colias' ),
        'id'            => 'header-center',
        'description'   => esc_html__( 'Add widgets here to appear in your header .', 'ri-colias' ),
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget'  => '</aside>',
        'before_title'  => '<h2 class="widget-title">',
        'after_title'   => '</h2>',
    ) );

    register_sidebar( array(
        'name'          => esc_html__( 'Sidebar 1', 'ri-colias' ),
        'id'            => 'sidebar-1',
        'description'   => esc_html__( 'Add widgets here to appear in your sidebar.', 'ri-colias' ),
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget'  => '</aside>',
        'before_title'  => '<h2 class="widget-title">',
        'after_title'   => '</h2>',
    ) );

    register_sidebar(array(
        'name' => 'Sidebar 2',
        'id'   => 'sidebar-2',
        'before_widget' => '<div id="%1$s" class="widget %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h4 class="widget-title">',
        'after_title' => '</h4>',
    ));
    register_sidebar(array(
        'name' => 'Sidebar 3',
        'id'   => 'sidebar-3',
        'before_widget' => '<div id="%1$s" class="widget %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h4 class="widget-title">',
        'after_title' => '</h4>',
    ));
    register_sidebar(array(
        'name' => 'Sidebar 4',
        'id'   => 'sidebar-4',
        'before_widget' => '<div id="%1$s" class="widget %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h4 class="widget-title">',
        'after_title' => '</h4>',
    ));
    register_sidebar(array(
        'name' => 'Footer Top',
        'id'   => 'footer-top',
        'before_widget' => '<div id="%1$s" class="widget first %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h4 class="widget-title">',
        'after_title' => '</h4>',
    ));
    register_sidebar(array(
        'name' => 'Footer 1',
        'id'   => 'footer-1',
        'before_widget' => '<div id="%1$s" class="widget first %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h4 class="widget-title">',
        'after_title' => '</h4>',
    ));
    register_sidebar(array(
        'name' => 'Footer 2',
        'id'   => 'footer-2',
        'before_widget' => '<div id="%1$s" class="widget %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h4 class="widget-title">',
        'after_title' => '</h4>',
    ));
    register_sidebar(array(
        'name' => 'Footer 3',
        'id'   => 'footer-3',
        'before_widget' => '<div id="%1$s" class="widget last %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h4 class="widget-title">',
        'after_title' => '</h4>',
    ));
    register_sidebar(array(
        'name' => 'Footer 4',
        'id'   => 'footer-4',
        'before_widget' => '<div id="%1$s" class="widget last %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h4 class="widget-title">',
        'after_title' => '</h4>',
    ));
    register_sidebar(array(
        'name' => 'Footer 5 (footer style 2)',
        'id'   => 'footer-5',
        'before_widget' => '<div id="%1$s" class="widget last %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h4 class="widget-title">',
        'after_title' => '</h4>',
    ));
    register_sidebar(array(
        'name' => 'Footer 6 (footer style 3)',
        'id'   => 'footer-6',
        'before_widget' => '<div id="%1$s" class="widget last %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h4 class="widget-title">',
        'after_title' => '</h4>',
    ));
    register_sidebar(array(
        'name' => 'Custom Link Topbar Left',
        'id'   => 'custom-topbar-left',
        'before_widget' => '<div id="%1$s" class="widget last %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h4 class="widget-title">',
        'after_title' => '</h4>',
    ));
    register_sidebar(array(
        'name' => 'Custom Link Topbar Right',
        'id'   => 'custom-topbar-right',
        'before_widget' => '<div id="%1$s" class="widget last %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h4 class="widget-title">',
        'after_title' => '</h4>',
    ));
}



// List Sidebar
if(!function_exists('rit_sidebar')) {

    function rit_sidebar()
    {
        global $wp_registered_sidebars;

        $sidebar_options = array();

        foreach ($wp_registered_sidebars as $sidebar) {
            $sidebar_options[$sidebar['id']] = $sidebar['name'];
        }

        return $sidebar_options;
    }
}
/* SET SIDEBAR GLOBAL
    ================================================== */
function ct_set_sidebar_global($sidebar_config) {
    global $sf_sidebar_config;
    if (($sidebar_config == "left-sidebar") || ($sidebar_config == "right-sidebar")) {
        $sf_sidebar_config = 'one-sidebar';
    } else if ($sidebar_config == "both-sidebars") {
        $sf_sidebar_config = 'both-sidebars';
    } else {
        $sf_sidebar_config = 'no-sidebars';
    }
}


if (!function_exists('array_insert_before')) :
    function array_insert_before($key, array &$array, $new_key, $new_value) {
        if (array_key_exists($key, $array)) {
            $new = array();
            foreach ($array as $k => $value) {
                if ($k === $key) {
                    $new[$new_key] = $new_value;
                }
                $new[$k] = $value;
            }
            return $new;
        }
        return false;
    }
endif;

if (!function_exists('array_insert_after')) :
    function array_insert_after($key, &$array, $new_key, $new_value) {
        if (array_key_exists($key, $array)) {
            $new = array();
            foreach ($array as $k => $value) {
                $new[$k] = $value;
                if ($k === $key) {
                    $new[$new_key] = $new_value;
                }
            }
            return $new;
        }
        return false;
    }
endif;

if (!function_exists('rit_add_url_parameters')):
    function rit_add_url_parameters($url, $name, $value) {
        $url_data = parse_url(str_replace('#038;', '&', $url));
        if (!isset($url_data["query"]))
            $url_data["query"]="";

        $params = array();
        parse_str($url_data['query'], $params);
        $params[$name] = $value;
        $url_data['query'] = http_build_query($params);
        return rit_build_url($url_data);
    }
endif;

if (!function_exists('rit_remove_url_parameters')):
    function rit_remove_url_parameters($url, $name) {
        $url_data = parse_url(str_replace('#038;', '&', $url));
        if (!isset($url_data["query"]))
            $url_data["query"]="";

        $params = array();
        parse_str($url_data['query'], $params);
        $params[$name] = "";
        $url_data['query'] = http_build_query($params);
        return rit_build_url($url_data);
    }
endif;

if (!function_exists('rit_build_url')):
    function rit_build_url($url_data) {
        $url="";
        if (isset($url_data['host'])) {
            $url .= $url_data['scheme'] . '://';
            if (isset($url_data['user'])) {
                $url .= $url_data['user'];
                if (isset($url_data['pass']))
                    $url .= ':' . $url_data['pass'];
                $url .= '@';
            }
            $url .= $url_data['host'];
            if (isset($url_data['port']))
                $url .= ':' . $url_data['port'];
        }
        if (isset($url_data['path']))
            $url .= $url_data['path'];
        if (isset($url_data['query']))
            $url .= '?' . $url_data['query'];
        if (isset($url_data['fragment']))
            $url .= '#' . $url_data['fragment'];

        return str_replace('#038;', '&', $url);
    }
endif;

function rit_get_blank_image() {
    return 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
}

if (!function_exists('array2json')):
    function array2json($arr) {
        if(function_exists('json_encode')) return json_encode($arr); //Lastest versions of PHP already has this functionality.
        $parts = array();
        $is_list = false;

        //Find out if the given array is a numerical array
        $keys = array_keys($arr);
        $max_length = count($arr)-1;
        if(($keys[0] == 0) and ($keys[$max_length] == $max_length)) {//See if the first key is 0 and last key is length - 1
            $is_list = true;
            for($i=0; $i<count($keys); $i++) { //See if each key correspondes to its position
                if($i != $keys[$i]) { //A key fails at position check.
                    $is_list = false; //It is an associative array.
                    break;
                }
            }
        }

        foreach($arr as $key=>$value) {
            if(is_array($value)) { //Custom handling for arrays
                if($is_list) $parts[] = array2json($value); /* :RECURSION: */
                else $parts[] = '"' . $key . '":' . array2json($value); /* :RECURSION: */
            } else {
                $str = '';
                if(!$is_list) $str = '"' . $key . '":';

                //Custom handling for multiple data types
                if(is_numeric($value)) $str .= $value; //Numbers
                elseif($value === false) $str .= 'false'; //The booleans
                elseif($value === true) $str .= 'true';
                else $str .= '"' . addslashes($value) . '"'; //All other things

                $parts[] = $str;
            }
        }
        $json = implode(',',$parts);

        if($is_list) return '[' . $json . ']';//Return numerical JSON
        return '{' . $json . '}';//Return associative JSON
    }
endif;

function rit_generate_rand() {
    $validCharacters = 'abcdefghijklmnopqrstuvwxyz0123456789';
    $rand = '';
    $length = 32;
    for ($n = 1; $n < $length; $n++) {
        $whichCharacter = rand(0, strlen($validCharacters)-1);
        $rand .= $validCharacters{$whichCharacter};
    }

    return $rand;
}

if ( ! function_exists( 'rit_is_ajax' ) ) {
    function rit_is_ajax() {

        if ( defined( 'DOING_AJAX' ) ) {
            return true;
        }

        return ( isset( $_SERVER[ 'HTTP_X_REQUESTED_WITH' ] ) && mb_strtolower( $_SERVER[ 'HTTP_X_REQUESTED_WITH' ] ) == 'xmlhttprequest' ) ? true : false;
    }
}
//Language
function rit_language_selector() {
    if ( in_array( 'sitepress-multilingual-cms/sitepress.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
        $languages = icl_get_languages('skip_missing=0&orderby=code');
        if(!empty($languages)){
            $active="";
            echo '<div id ="language-switch">';
            foreach($languages as $language){
                if($language['active']==1){
                    echo'<div  data-toggle="dropdown" class="dropdown-toggle" data-animation="500">';

                    if($language['country_flag_url']){
                        if(!$language['active']) echo '<a href="'.$language['url'].'">';
                        echo '<img src="'.$language['country_flag_url'].'" height="12" alt="'.$language['language_code'].'" width="18" />';
                        if(!$language['active']) echo '</a>';
                    }
                    if(!$language['active']) echo '<a href="'.$language['url'].'">';
                    echo icl_disp_language($language['native_name'], $language['translated_name']);
                    if(!$language['active']) echo '</a>';
                    echo '<i class="fa fa-angle-down"></i>';
                    echo '</div>';
                }

            }
            echo '<ul class="dropdown-menu">';
            foreach($languages as $l){
                echo '<li>';
                if($l['country_flag_url']){
                    if(!$l['active']) echo '<a href="'.$l['url'].'">';
                    echo '<img src="'.$l['country_flag_url'].'" height="12" alt="'.$l['language_code'].'" width="18" />';
                    if(!$l['active']) echo '</a>';
                }
                if(!$l['active']) echo '<a href="'.$l['url'].'">';
                echo icl_disp_language($l['native_name'], $l['translated_name']);
                if(!$l['active']) echo '</a>';
                echo '</li>';
            }
            echo '</ul></div>';
        }
    }
    else{?>
        <div id ="language-switch">
            <div  data-toggle="dropdown" class="dropdown-toggle"  data-delay="300">
                <a href="">
                    <img width="18" height="12" alt="en" src="<?php echo THEME_PATH; ?>/images/flags/gb.png">
                    <span class="icl_lang_sel_current"><?php echo esc_html__('English', 'ri-colias'); ?></span>
                    <i class="fa fa-angle-down"></i>
                </a>
            </div>
            <ul class="dropdown-menu">
                <li>
                    <a href="#" class="ltr-en">
                        <img width="18" height="12" alt="en" src="<?php echo THEME_PATH; ?>/images/flags/gb.png">
                        <span class="icl_lang_sel_current"><?php echo esc_html__('English', 'ri-colias'); ?></span>
                    </a>
                </li>
                <li>
                    <a class="rtl-ar" href="#">
                        <img width="18" height="12" alt="ar" src="<?php echo THEME_PATH; ?>/images/flags/ar.png">
                        <span class="icl_lang_sel_current"><?php echo esc_html__('Arabic', 'ri-colias'); ?></span>
                    </a>
                </li>
            </ul>
        </div>
    <?php }
}

/* THUMBNAIL SIZES ================================================================================================== */
set_post_thumbnail_size( 220, 150, true);
add_image_size( 'wrapper-thumb-cat', 1170, 376, true);
add_image_size( 'thumb-image', 600, 450, true);
add_image_size( 'related-image', 270, 152, true);
add_image_size( 'recent-image', 370, 200, true);
add_image_size( 'blog-sidebar', 90, 70, true);
add_image_size( 'shop_thumbnail', 100, 100, true);
add_image_size( 'cat_banner', 277, 420, true);

/* Config Sidebar =================================================================================================== */
function rit_layout($layout_sidebar){
    global $sidebar_left,$sidebar_right,$layout_sidebar;

    //config in the post single
    if($layout_sidebar == 'left'){
        $sidebar_left = true;
        $sidebar_right = false;
    }
    else if($layout_sidebar == 'right'){
        $sidebar_right = true;
        $sidebar_left = false;
    }
    else if($layout_sidebar == 'both'){
        $sidebar_left = true;
        $sidebar_right = true;
    }
    else {
        $sidebar_left = false;
        $sidebar_right = false;
    }

}

function rit_sidebar_config() {
    global $post,$wp_query,$layout_sidebar,$sidebar_left,$sidebar_right,$sidebar_left_inner,$sidebar_right_inner,$style_sidebar;
    $layout_sidebar = $sidebar_left = $sidebar_right = $sidebar_left_inner= $sidebar_right_inner = '';

    $style_sidebar  = get_theme_mod('rit_site_style_sidebar','style-default');

    if(is_single()){
        $layout_sidebar = get_post_meta($post->ID, 'layout_sidebar',false);

        if( isset($layout_sidebar) && !empty($layout_sidebar)){
            rit_layout($layout_sidebar);
            $sidebar_left_inner = get_post_meta($post->ID, 'post_left_sidebar',false);
            $sidebar_right_inner = get_post_meta($post->ID, 'post_right_sidebar',false);
        }
        else{
            $sidebar_left = get_theme_mod('sidebar_single_left',false);
            $sidebar_right = get_theme_mod('sidebar_single_right',false);
            $sidebar_left_inner = get_theme_mod('sidebar_single_left_inner');
            $sidebar_right_inner = get_theme_mod('sidebar_single_right_inner');
        }
    }

    if( is_category() || is_archive() ){
        $sidebar_left  = get_theme_mod('sidebar_cat_left',false);
        $sidebar_right = get_theme_mod('sidebar_cat_right',false);
        $sidebar_left_inner = get_theme_mod('sidebar_cat_left_inner','sidebar-1');
        $sidebar_right_inner = get_theme_mod('sidebar_cat_right_inner','sidebar-1');
    }

    if(is_page()){
        $page_id = $wp_query->get_queried_object_id();

        $layout_sidebar = get_post_meta($page_id, 'layout_sidebar', false);
        if( isset($layout_sidebar) && !empty($layout_sidebar)){
            rit_layout($layout_sidebar);
        }
        else{
            $sidebar_left = get_theme_mod('sidebar_page_left',false);
            $sidebar_right = get_theme_mod('sidebar_page_right',false);
        }

        $page_left_sidebar = get_post_meta($page_id, 'sidebar_page_left', false);
        if(isset($page_left_sidebar) && !empty($page_left_sidebar) ){
            $sidebar_left_inner = get_post_meta($page_id, 'post_left_sidebar', false);
        }
        else{
            $sidebar_left_inner = get_theme_mod('rit_sidebar_left_inner','sidebar-1');
        }

        $page_right_sidebar = get_post_meta($page_id, 'sidebar_page_right', false);
        if(isset($page_right_sidebar) && !empty($page_right_sidebar) ){
            $sidebar_right_inner = get_post_meta($page_id, 'post_right_sidebar', false);
        }
        else{
            $sidebar_right_inner = get_theme_mod('rit_sidebar_right_inner','sidebar-1');
        }
    }

    if( is_post_type_archive('product') || is_tax( 'product_cat' ) || is_tax('product_tag') ){
        $sidebar_left   = get_theme_mod('rit_woo_list_sidebar_left',false);
        $sidebar_right  = get_theme_mod('rit_woo_list_sidebar_right',false);

        $sidebar_left_inner   = get_theme_mod('rit_woo_list_sidebar_left_inner');
        $sidebar_right_inner  = get_theme_mod('rit_woo_list_sidebar_right_inner');

    }
    if( function_exists('is_product') && is_product()){
        $sidebar_right  = get_theme_mod('rit_woo_single_sidebar_right',false);
        $sidebar_left   = get_theme_mod('rit_woo_single_sidebar_left',false);

        $sidebar_left_inner   = get_theme_mod('rit_woo_single_sidebar_left_inner');
        $sidebar_right_inner   = get_theme_mod('rit_woo_single_sidebar_right_inner');

    }


}

/* Ajax Url ==========================================================================================================*/
add_action('wp_head','rit_framework_ajax_url',15);
function rit_framework_ajax_url() {
    ?>
    <script type="text/javascript">
        var ajaxurl = '<?php echo esc_url( admin_url('admin-ajax.php') ); ?>';
    </script>
<?php
}

function rit_comment_form($arg,$class='btn-primary',$id='submit'){
    ob_start();
    comment_form($arg);
    $form = ob_get_clean();
    echo str_replace('id="submit"','id="'.$id.'" class="btn '.$class.'"', $form);
}

function rit_list_comments($comment, $args, $depth){
    $path = RIT_INCLUDES_PATH . '/templates/list_comments.php';
    if( is_file($path) ) require ($path);
}