HEX
Server: Apache/2.4.34 (Red Hat) OpenSSL/1.0.2k-fips
System: Linux WORDPRESS 3.10.0-1160.118.1.el7.x86_64 #1 SMP Thu Apr 4 03:33:23 EDT 2024 x86_64
User: digital (1020)
PHP: 7.2.24
Disabled: NONE
Upload Files
File: /datos/www/expodubai.colombia.co/wp-content/themes/osapaOld/functions.php
<?php
/* * * Include TGM Plugin Activation ** */
require_once get_template_directory() . '/inc/includes/class-tgm-plugin-activation.php';

/* * * Theme Options ** */
require_once get_template_directory() . '/inc/register_sidebar.php';
require_once get_template_directory() . '/admin/base_options.php';
require_once get_template_directory() . '/admin/theme_options.php';

function osapa_setup() {
    /*Custom Gutenberg*/
    add_editor_style('editor-styles');
    add_editor_style( 'assets/css/style-editor.css' );
    add_theme_support( 'dark-editor-style' );
    add_theme_support( 'responsive-embeds' );
  // Add support for default block styles.
    add_theme_support( 'wp-block-styles' );
    // Add support for full and wide align images.
    add_theme_support( 'align-wide' );

    add_theme_support( 'editor-font-sizes', array(
        array(
            'name' => __( 'Small', 'osapa' ),
            'size' => 12,
            'slug' => 'small'
        ),
        array(
            'name' => __( 'Normal', 'osapa' ),
            'size' => 14,
            'slug' => 'normal'
        ),
        array(
            'name' => __( 'Large', 'osapa' ),
            'size' => 36,
            'slug' => 'large'
        ),
        array(
            'name' => __( 'Huge', 'osapa' ),
            'size' => 48,
            'slug' => 'huge'
        )
    ) );

    add_theme_support( 'editor-color-palette', array(
        array(
            'name' => __( 'strong magenta', 'osapa' ),
            'slug' => 'strong-magenta',
            'color' => '#a156b4',
        ),
        array(
            'name' => __( 'light grayish magenta', 'osapa' ),
            'slug' => 'light-grayish-magenta',
            'color' => '#d0a5db',
        ),
        array(
            'name' => __( 'very light gray', 'osapa' ),
            'slug' => 'very-light-gray',
            'color' => '#eee',
        ),
        array(
            'name' => __( 'very dark gray', 'osapa' ),
            'slug' => 'very-dark-gray',
            'color' => '#444',
        ),
    ) );

    /* Add editor-style.css file */
    add_editor_style();

    load_theme_textdomain('osapa');

    /* 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');

    add_image_size('osapa-featured-image', 2000, 1200, true);

    add_image_size('osapa-thumbnail-avatar', 100, 100, true);

    add_image_size('shop_custom', 170, 170, true);
    /* Set the default content width */
    $GLOBALS['content_width'] = 1200;

    /* Translation */
    load_theme_textdomain('osapa', get_template_directory() . '/languages');

    $locale = get_locale();
    $locale_file = get_template_directory() . "/languages/$locale.php";
    if (is_readable($locale_file)){
        require_once( $locale_file );
    }

    /* This theme uses wp_nav_menu() in two locations. */
    register_nav_menus(array(
        'primary' => esc_html__('Primary Navigation', 'osapa'),
    ));
    register_nav_menus(array(
        'second' => esc_html__('Second Navigation', 'osapa'),
    ));
    register_nav_menus(array(
        'vertical' => esc_html__('Vertical Navigation', 'osapa'),
    ));

    /*
     * Switch default core markup for search form, comment form, and comments
     * to output valid HTML5.
     */
    add_theme_support('html5', array(
        'comment-form',
        'comment-list',
        'gallery',
        'caption',
    ));

    /*
     * Enable support for Post Formats.
     */
    add_theme_support('post-formats', array('audio', 'gallery', 'quote', 'video'));

    // Add theme support for Custom Background
    $defaults = array(
        'default-color' => ''
        , 'default-image' => ''
    );
    add_theme_support('custom-background', $defaults);

    add_theme_support('woocommerce');

    add_theme_support( 'custom-header');
    // 
    add_editor_style( array( 'assets/css/editor-style.css', ftc_fonts_url() ) );

    // Define and register starter content to showcase the theme on new sites.
    $starter_content = array(
        'widgets' => array(
            // Place three core-defined widgets in the sidebar area.
            'sidebar-1' => array(
                'text_business_info',
                'search',
                'text_about',
            ),
            // Add the core-defined business info widget to the footer 1 area.
            'sidebar-2' => array(
                'text_business_info',
            ),
            // Put two core-defined widgets in the footer 2 area.
            'sidebar-3' => array(
                'text_about',
                'search',
            ),
        ),
        // Specify the core-defined pages to create and add custom thumbnails to some of them.
        'posts' => array(
            'home',
            'about' => array(
                'thumbnail' => '{{image-sandwich}}',
            ),
            'contact' => array(
                'thumbnail' => '{{image-espresso}}',
            ),
            'blog' => array(
                'thumbnail' => '{{image-coffee}}',
            ),
            'homepage-section' => array(
                'thumbnail' => '{{image-espresso}}',
            ),
        ),
        // Create the custom image attachments used as post thumbnails for pages.
        'attachments' => array(
            'image-espresso' => array(
                'post_title' => _x('Espresso', 'Theme starter content', 'osapa'),
                'file' => 'assets/images/espresso.jpg', // URL relative to the template directory.
            ),
            'image-sandwich' => array(
                'post_title' => _x('Sandwich', 'Theme starter content', 'osapa'),
                'file' => 'assets/images/sandwich.jpg',
            ),
            'image-coffee' => array(
                'post_title' => _x('Coffee', 'Theme starter content', 'osapa'),
                'file' => 'assets/images/coffee.jpg',
            ),
        ),
        // Default to a static front page and assign the front and posts pages.
        'options' => array(
            'show_on_front' => 'page',
            'page_on_front' => '{{home}}',
            'page_for_posts' => '{{blog}}',
        ),
        // Set the front page section theme mods to the IDs of the core-registered pages.
        'theme_mods' => array(
            'panel_1' => '{{homepage-section}}',
            'panel_2' => '{{about}}',
            'panel_3' => '{{blog}}',
            'panel_4' => '{{contact}}',
        ),
        // Set up nav menus for each of the two areas registered in the theme.
        'nav_menus' => array(
            // Assign a menu to the "top" location.
            'top' => array(
                'name' => __('Top Menu', 'osapa'),
                'items' => array(
                    'link_home', // Note that the core "home" page is actually a link in case a static front page is not used.
                    'page_about',
                    'page_blog',
                    'page_contact',
                ),
            ),
            // Assign a menu to the "social" location.
            'social' => array(
                'name' => __('Social Links Menu', 'osapa'),
                'items' => array(
                    'link_yelp',
                    'link_facebook',
                    'link_twitter',
                    'link_instagram',
                    'link_email',
                ),
            ),
        ),
    );

    /**
     * Filters Organico array of starter content.
     *
     * @since Organico 1.1
     *
     * @param array $starter_content Array of starter content.
     */
    $starter_content = apply_filters('ftc_starter_content', $starter_content);

    add_theme_support('starter-content', $starter_content);

}

add_action('after_setup_theme', 'osapa_setup');

function ftc_fonts_url() {
    $fonts_url = '';

    /**
     * Translators: If there are characters in your language that are not
     * supported by Libre Franklin, translate this to 'off'. Do not translate
     * into your own language.
     */
    $dosis = _x( 'on', 'Roboto font: on or off', 'osapa' );

    if ( 'off' !== $dosis ) {
        $font_families = array();

        $font_families[] = 'Roboto:400,500,700|Roboto Slab:400,700';

        $query_args = array(
            'family' => urlencode( implode( '|', $font_families ) )
        );

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

    return esc_url_raw( $fonts_url );
}


/* * * Register google font ** */
function osapa_register_google_font($iframe = false) {
    global $smof_data;
    $fonts = array();

    if ( isset($smof_data['ftc_body_font_enable_google_font']) && $smof_data['ftc_body_font_enable_google_font']) {
        $fonts[] = array(
            'name' => $smof_data['ftc_body_font_google']['font-family']
            , 'bold' => '300,400,500,600,700,800,900'
        );
    }

    if (isset($smof_data['ftc_secondary_body_font_enable_google_font']) && $smof_data['ftc_secondary_body_font_enable_google_font']) {
        $fonts[] = array(
            'name' => $smof_data['ftc_secondary_body_font_google']['font-family']
            , 'bold' => '300,400,500,600,700,800,900'
        );
    }
    if ( isset($smof_data['ftc_font_subtitle_google']) && $smof_data['ftc_font_subtitle_google']) {
        $fonts[] = array(
            'name' => $smof_data['ftc_font_subtitle_google']['font-family']
            , 'bold' => '300,400,500,600,700,800,900'
        );
    }
    

    /* Default fonts */
    $fonts[] = array(
        'name' => 'Lato'
        , 'bold' => '300,400,500,600,700,800,900'
    );

    $fonts[] = array(
        'name' => 'Raleway'
        , 'bold' => '300,400,500,600,700,800,900'
    );

    foreach ($fonts as $font) {
        osapa_load_google_font($font['name'], $font['bold'], $iframe);
    }
}

function osapa_load_google_font($font_name = '', $font_bold = '300,400,500,600,700,800,900', $iframe = false) {
    if (strlen($font_name) > 0) {
        $font_name_id = sanitize_title($font_name);

        $font_url = add_query_arg('family', urlencode($font_name . ':' . $font_bold . '&subset=latin,latin-ext'), '//fonts.googleapis.com/css');
        if (!$iframe) {
            wp_enqueue_style("font-{$font_name_id}", $font_url);
        } else {
            echo '<link rel="stylesheet" type="text/css" id="font_' . $font_name_id . '" media="all" href="' . esc_url($font_url) . '" />';
        }
    }
}

/**
 * Enqueue scripts and styles.
 */
function osapa_scripts() {
    global $smof_data, $osapa_page_datas;
    osapa_register_google_font();
    
    wp_deregister_style('font-awesome');
    wp_deregister_style('yith-wcwl-font-awesome');
    wp_enqueue_style('font-awesome', get_template_directory_uri() . '/assets/css/font-awesome.css');
    
    wp_enqueue_style('pe-icon-7-stroke', get_template_directory_uri() . '/assets/css/pe-icon-7-stroke.css');

    wp_enqueue_style('owl-carousel', get_template_directory_uri() . '/assets/css/owl.carousel.min.css');
    
    wp_enqueue_style( 'pretty-photo', get_template_directory_uri() . '/assets/css/prettyPhoto.css' );

    wp_enqueue_style( 'photoswipe', get_template_directory_uri() . '/assets/css/photoswipe/photoswipe.css' );

    wp_enqueue_style( 'photoswipe-default', get_template_directory_uri() . '/assets/css/photoswipe/default-skin/default-skin.css' );     
    wp_enqueue_style('editor-styles', get_template_directory_uri() . '/assets/css/style-editor.css');
    /* Theme stylesheet. */
    wp_enqueue_style('osapa-style', get_stylesheet_uri());

    wp_enqueue_style('osapa-default', get_template_directory_uri() . '/assets/css/default.css');

    wp_register_style('osapa-responsive', get_template_directory_uri() . '/assets/css/responsive.css');
    wp_enqueue_style('osapa-responsive');

    /* Enqueue scripts */
    wp_enqueue_script( 'infinite', get_template_directory_uri().'/assets/js/infinite-scroll.pkgd.min.js', array(), null, true);
    
    wp_enqueue_script('cookie', get_template_directory_uri().'/assets/js/jquery.cookie.min.js', array( 'jquery' ), null, true );
    wp_enqueue_script( 'owl-carousel', get_template_directory_uri().'/assets/js/owl.carousel.min.js', array(), null, true);

    /* Load Libraries*/
    wp_enqueue_script( 'ba-throttle-debounce', get_template_directory_uri().'/assets/js/jquery.ba-throttle-debounce.min.js', array(), null, true);
    wp_enqueue_script( 'hover-intent', get_template_directory_uri().'/assets/js/jquery.hover-intent.js', array(), null, true); 
    wp_enqueue_script( 'parallax', get_template_directory_uri().'/assets/js/jquery.parallax.js', array(), null, true);
    wp_enqueue_script( 'pretty-photo', get_template_directory_uri().'/assets/js/jquery.pretty-photo.min.js', array(), null, true);
    wp_enqueue_script( 'sticky', get_template_directory_uri() . '/assets/js/jquery.sticky.js' , array(), null, true );
    wp_enqueue_script( 'isotope', get_template_directory_uri().'/assets/js/isotope.min.js', array(), null, true);
    wp_enqueue_script( 'tween-lite', get_template_directory_uri().'/assets/js/tween-lite.min.js', array(), null, true); 
    wp_enqueue_script( 'tween-max', get_template_directory_uri().'/assets/js/tween-max.min.js', array(), null, true);
    wp_enqueue_script( 'waypoint', get_template_directory_uri().'/assets/js/waypoint.min.js', array(), null, true);
    wp_enqueue_script( 'countto', get_template_directory_uri().'/assets/js/jquery.countto.js', array(), null, true);  
    wp_enqueue_script( 'mb-ytplayer', get_template_directory_uri().'/assets/js/jquery.mb.ytplayer.js', array(), null, true);
    wp_enqueue_script('magnific-popup', get_template_directory_uri() . '/assets/js/jquery.magnific-popup.min.js', array(), null, true);
    wp_enqueue_script('threesixty', get_template_directory_uri() . '/assets/js/threesixty.min.js', array(), null, true);

    wp_enqueue_script( 'swipebox-min', get_template_directory_uri().'/assets/js/jquery.swipebox.min.js', array(), null, true);
    wp_enqueue_script( 'swipebox', get_template_directory_uri().'/assets/js/jquery.swipebox.js', array(), null, true);
    wp_enqueue_script('html5', get_template_directory_uri() . '/assets/js/html5.js', array(), '3.7.3');
    if( wp_is_mobile() ){
        wp_enqueue_script('mobile-js', get_template_directory_uri() . '/assets/js/mobile.js', array(), null, true);
    }
    wp_script_add_data('html5', 'conditional', 'lt IE 9');

    if (is_singular('product') && isset($smof_data['ftc_prod_thumbnails_style']) && $smof_data['ftc_prod_thumbnails_style'] == 'vertical') {
        wp_enqueue_script('jquery-caroufredsel', get_template_directory_uri() . '/assets/js/jquery.carou-fredsel-6.2.1.min.js', array(), null, true);
    }
    
    if (is_singular('product') && isset($smof_data['ftc_prod_cloudzoom']) &&  $smof_data['ftc_prod_cloudzoom']) {
        wp_enqueue_script('cloud-zoom', get_template_directory_uri() . '/assets/js/cloud-zoom.js', array('jquery'), null, true);
    }

    wp_enqueue_script('jquery-scrollto', get_template_directory_uri() . '/assets/js/jquery.scrollto.js', array('jquery'), '2.1.2', true);
    
    wp_enqueue_script('osapa-global', get_template_directory_uri() . '/assets/js/custom.js', array('jquery'), '1.0', true);

    if (defined('ICL_LANGUAGE_CODE')) {
        $ajax_uri = admin_url('admin-ajax.php?lang=' . ICL_LANGUAGE_CODE, 'relative');
    } else {
        $ajax_uri = admin_url('admin-ajax.php', 'relative');
    }

    $data = array(
        'ajax_uri' => $ajax_uri,
        '_ftc_enable_responsive' => isset($smof_data['ftc_responsive']) ? (int) $smof_data['ftc_responsive'] : 1,
        '_ftc_enable_ajax_search' => isset($smof_data['osapa_ajax_search']) ? (int) $smof_data['osapa_ajax_search'] : 1,
        '_ftc_enable_sticky_header' => isset($smof_data['ftc_enable_sticky_header']) ? (int)$smof_data['ftc_enable_sticky_header'] : 1
    );
    wp_localize_script('osapa-global', 'ftc_shortcode_params', $data);

    wp_enqueue_script('wc-add-to-cart-variation');

    if (is_singular() && comments_open() && get_option('thread_comments')) {
        wp_enqueue_script('comment-reply');
    }
}
add_action('wp_enqueue_scripts', 'osapa_scripts', 1000);

function ftc_register_custom_css() {
    ob_start();
    include_once get_template_directory() . '/inc/dynamic_style.php';
    $dynamic_css = ob_get_contents();
    ob_end_clean();
    wp_add_inline_style('osapa-style', $dynamic_css);

}

add_action('wp_enqueue_scripts', 'ftc_register_custom_css', 9999);

function update_woocommerce_version() {
    if(class_exists('WooCommerce')) {
        global $woocommerce;
        
        if(version_compare(get_option('woocommerce_db_version', null), $woocommerce->version, '!=')) {
            update_option('woocommerce_db_version', $woocommerce->version);
            
            if(! wc_update_product_lookup_tables_is_running()) {
                wc_update_product_lookup_tables();
            }
        }           
    }       
}
add_action('init', 'update_woocommerce_version');

/* * * Register Back End Scripts ** */

function ftc_register_admin_scripts() {
    wp_enqueue_media();
    wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/assets/css/font-awesome.css' );
    wp_enqueue_style('font-awesome');
    wp_register_style('ftc-admin-style', get_template_directory_uri() . '/assets/css/admin-style.css');
    wp_enqueue_style('ftc-admin-style');
    wp_register_style('ftc-theme-options', get_template_directory_uri() . '/admin/css/options.css');
    wp_enqueue_style('ftc-theme-options');
    wp_register_script('ftc-admin-script', get_template_directory_uri() . '/assets/js/admin-main.js', array('jquery'), null, true);
    wp_enqueue_script('ftc-admin-script');
}

add_action('admin_enqueue_scripts', 'ftc_register_admin_scripts');

/* * * Get excerpt ** */
if (!function_exists('osapa_the_excerpt_max_words')) {

    function osapa_the_excerpt_max_words($word_limit = -1, $post = '', $strip_tags = true, $extra_str = '', $echo = true) {
        if ($post) {
         if ( has_excerpt() ){
          $excerpt = get_the_excerpt();
      } else {
        $excerpt = get_the_content();
        $excerpt = apply_filters( 'the_content', $excerpt );
        $excerpt = str_replace( ']]>', ']]&gt;', $excerpt );
    }
} else {
    $excerpt = get_the_excerpt();
}

if ($strip_tags) {
    $excerpt = wp_strip_all_tags($excerpt);
    $excerpt = strip_shortcodes($excerpt);
}

if ($word_limit != -1)
    $result = osapa_string_limit_words($excerpt, $word_limit);
else
    $result = $excerpt;

$result .= $extra_str;

if ($echo) {
    print_r(do_shortcode($result));
}
return $result;
}
}

if (!function_exists('osapa_string_limit_words')) {
    function osapa_string_limit_words($string, $word_limit) {
        $words = explode(' ', $string, ($word_limit + 1));
        if (count($words) > $word_limit) {
            array_pop($words);
        }
        return implode(' ', $words);
    }
}


/* * * Page Layout Columns Class ** */
if (!function_exists('osapa_page_layout_columns_class')) {

    function osapa_page_layout_columns_class($page_column) {
        $data = array();

        if (empty($page_column)) {
            $page_column = '0-1-0';
        }

        $layout_config = explode('-', $page_column);
        $left_sidebar = (int) $layout_config[0];
        $right_sidebar = (int) $layout_config[2];
        $main_class = ($left_sidebar + $right_sidebar) == 2 ? 'col-sm-6 col-xs-12' : ( ($left_sidebar + $right_sidebar) == 1 ? 'col-sm-9 col-xs-12' : 'col-sm-12 col-xs-12' );

        $data['left_sidebar'] = $left_sidebar;
        $data['right_sidebar'] = $right_sidebar;
        $data['main_class'] = $main_class;
        $data['left_sidebar_class'] = 'col-sm-3 col-xs-12';
        $data['right_sidebar_class'] = 'col-sm-3 col-xs-12';

        return $data;
    }
}

/* * * Is Active WooCommmerce ** */
if (!function_exists('osapa_has_woocommerce')) {

    function osapa_has_woocommerce() {
        $_actived = apply_filters('active_plugins', get_option('active_plugins'));
        if (in_array("woocommerce/woocommerce.php", $_actived) && class_exists('woocommerce')) {
            return true;
        }
        return false;
    }
}

/* * * Include files in woo folder ** */
$file_names = array('functions', 'term', 'quickshop', 'grid_list_toggle', 'hooks');
foreach ($file_names as $file) {
    $file_path = get_template_directory() . '/inc/woo/' . $file . '.php';
    if (file_exists($file_path)) {
        require_once $file_path;
    }
}

/* Custom Sidebar */
add_action('sidebar_admin_page', 'osapa_custom_sidebar_form');

function osapa_custom_sidebar_form() {
    ?>
    <form action="<?php echo admin_url('widgets.php'); ?>" method="post" id="ftc-form-add-sidebar">
        <input type="text" name="sidebar_name" id="sidebar_name" placeholder="<?php esc_html_e('Custom Sidebar Name', 'osapa') ?>" />
        <button class="button-primary" id="ftc-add-sidebar"><?php esc_html_e('Add Sidebar', 'osapa') ?></button>
    </form>
    <?php
}

function osapa_get_custom_sidebars() {
    $option_name = 'osapa_custom_sidebars';
    $custom_sidebars = get_option($option_name);
    return is_array($custom_sidebars) ? $custom_sidebars : array();
}

add_action('wp_ajax_osapa_add_custom_sidebar', 'osapa_add_custom_sidebar');

function osapa_add_custom_sidebar() {
    check_ajax_referer( 'platform_security', 'security' );
    if (isset($_POST['sidebar_name'])) {
        $option_name = 'osapa_custom_sidebars';
        if (!get_option($option_name) || get_option($option_name) == '') {
            delete_option($option_name);
        }

        $sidebar_name = sanitize_text_field($_POST['sidebar_name']);

        if (get_option($option_name)) {
            $custom_sidebars = osapa_get_custom_sidebars();
            if (!in_array($sidebar_name, $custom_sidebars)) {
                $custom_sidebars[] = $sidebar_name;
            }
            $result1 = update_option($option_name, $custom_sidebars);
        } else {
            $custom_sidebars = array();
            $custom_sidebars[] = $sidebar_name;
            $result2 = add_option($option_name, $custom_sidebars);
        }

        if ($result1) {
            wp_die('Updated');
        } elseif ($result2) {
            wp_die('Added');
        } else {
            wp_die('Error');
        }
    }
    wp_die('');
}
function rocket_lazyload_exclude_class( $attributes ) {
    $attributes[] = 'class="thumbnail-blog wp-post-image"';
    $attributes[] = 'class="attachment-ftc_blog_shortcode_thumb size-ftc_blog_shortcode_thumb wp-post-image"';
    $attributes[] = 'class="attachment-ftc_brand_thumb size-ftc_brand_thumb wp-post-image"';

    return $attributes;
}
add_filter( 'rocket_lazyload_excluded_attributes', 'rocket_lazyload_exclude_class' );

add_action('wp_ajax_osapa_delete_custom_sidebar', 'osapa_delete_custom_sidebar');

function osapa_delete_custom_sidebar() {
    check_ajax_referer( 'platform_security', 'security' );
    if (isset($_POST['sidebar_name'])) {
        $option_name = 'osapa_custom_sidebars';
        $del_sidebar = trim($_POST['sidebar_name']);
        $custom_sidebars = osapa_get_custom_sidebars();
        foreach ($custom_sidebars as $key => $value) {
            if ($value == $del_sidebar) {
                unset($custom_sidebars[$key]);
                break;
            }
        }
        $custom_sidebars = array_values($custom_sidebars);
        update_option($option_name, $custom_sidebars);
        wp_die('Deleted');
    }
    wp_die('');
}

/* * * Require Advance Options ** */
require_once get_template_directory() . '/inc/theme_control.php';



/**
 * Additional features to allow styling of the templates.
 */
require get_parent_theme_file_path('/inc/template-functions.php');

/**
 * SVG icons functions and filters.
 */
require get_parent_theme_file_path('/inc/icon-functions.php');

/**
 * Filter by color.
 */
require get_parent_theme_file_path('/inc/filter_by_color_options.php');

/* * * Visual Composer plugin ** */
if (class_exists('Vc_Manager') && class_exists('WPBakeryVisualComposerAbstract')) {
    $file_names = array('vc_map', 'update_param');
    foreach ($file_names as $file) {
        $file_path = get_template_directory() . '/inc/vc_extension/' . $file . '.php';
        if (file_exists($file_path)) {
            require_once $file_path;
        }
    }
    vc_set_shortcodes_templates_dir(get_template_directory() . '/inc/vc_extension/templates');

    /* Disable VC Frontend Editor */
    vc_disable_frontend();
}




/* * * Favicon ** */
if (!function_exists('osapa_theme_favicon')) {

    function osapa_theme_favicon() {
        if (function_exists('wp_site_icon') && function_exists('has_site_icon') && has_site_icon()) {
            return;
        }
        global $smof_data;
        $favicon = isset($smof_data['ftc_favicon']['url']) ? esc_url($smof_data['ftc_favicon']['url']) : '';
        if (strlen($favicon) > 0):
            ?>
            <link rel="shortcut icon" href="<?php echo esc_url($favicon); ?>" />
            <?php
        endif;
    }

}

/* * * Logo ** */
if (!function_exists('osapa_theme_logo')) {

    function osapa_theme_logo() {
        global $smof_data;
        $logo_image = isset($smof_data['ftc_logo']['url']) ? esc_url($smof_data['ftc_logo']['url']) : '';
        $logo_text = isset($smof_data['ftc_text_logo']) ? stripslashes(esc_attr($smof_data['ftc_text_logo'])) : '';
        ?>
        <div class="logo">
            <a href="<?php echo esc_url(home_url('/')); ?>">
                <!-- Main logo -->
                <?php if (strlen($logo_image) > 0): ?>
                    <img src="<?php echo esc_url($logo_image); ?>" alt="<?php echo !empty($logo_text) ? esc_attr($logo_text) : get_bloginfo('name'); ?>" title="<?php echo !empty($logo_text) ? esc_attr($logo_text) : get_bloginfo('name'); ?>" class="normal-logo" />
                <?php endif; ?>

                <!-- Logo Text -->
                <?php
                if (strlen($logo_image) == 0) {
                    echo esc_html($logo_text);
                }
                ?>
            </a>
        </div>
        <?php
    }
}

/* * * Logo Mobile** */
if (!function_exists('osapa_theme_logo_mobile')) {

    function osapa_theme_logo_mobile() {
        global $smof_data;
        $logo_image = isset($smof_data['ftc_logo_mobile']['url']) ? esc_url($smof_data['ftc_logo_mobile']['url']) : '';
        $logo_text = isset($smof_data['ftc_text_logo']) ? stripslashes(esc_attr($smof_data['ftc_text_logo'])) : '';
        ?>

        <div class="logo">
            <a href="<?php echo esc_url(home_url('/')); ?>">
                <!-- Main logo -->
                <?php if (strlen($logo_image) > 0): ?>
                    <img src="<?php echo esc_url($logo_image); ?>" alt="<?php echo !empty($logo_text) ? esc_attr($logo_text) : get_bloginfo('name'); ?>" title="<?php echo !empty($logo_text) ? esc_attr($logo_text) : get_bloginfo('name'); ?>" class="normal-logo" />
                <?php endif; ?>

                <!-- Logo Text -->
                <?php
                if (strlen($logo_image) == 0) {
                    echo esc_html($logo_text);
                }
                ?>
            </a>
        </div>
        <?php
    }
}

/* * * Product Search Form by Category ** */
if (!function_exists('osapa_get_search_form_by_category')) {

    function osapa_get_search_form_by_category() {
        $search_for_product = osapa_has_woocommerce();
        if ($search_for_product) {
            $taxonomy = 'product_cat';
            $post_type = 'product';            
            $placeholder_text = esc_html__('Search ...', 'osapa');
        } else {
            $taxonomy = 'category';
            $post_type = 'post';
            $placeholder_text = esc_html__('Search', 'osapa');
        }

        $options = '<option value="">' . esc_html__('All categories', 'osapa') . '</option>';
        $options .= osapa_search_by_category_get_option_html($taxonomy, 0, 0);

        $rand = rand(0, 1000);
        $form = '<div class="ftc-search">
        <button class="fa fa-search search-button" type="submit" ></button>
        <form method="get" id="searchform' . $rand . '" action="' . esc_url(home_url('/')) . '">
        <select class="select-category" name="term">' . $options . '</select>
        <div class="ftc_search_ajax">
        <input type="text" value="' . get_search_query() . '" name="s" id="s' . $rand . '" placeholder="' . $placeholder_text . '" autocomplete="off" />

        <input type="hidden" name="post_type" value="' . $post_type . '" />
        <input type="hidden" name="taxonomy" value="' . $taxonomy . '" />


        </div>
        </form>
        </div>';

        print_r($form);
    }

}

if (!function_exists('osapa_search_by_category_get_option_html')) {

    function osapa_search_by_category_get_option_html($taxonomy = 'product_cat', $parent = 0, $level = 0) {
        $options = '';
        $spacing = '';
        for ($i = 0; $i < $level * 3; $i++) {
            $spacing .= '&nbsp;';
        }

        $args = array(
            'number' => ''
            , 'hide_empty' => 1
            , 'orderby' => 'name'
            , 'order' => 'asc'
            , 'parent' => $parent
        );

        $select = '';
        $categories = get_terms($taxonomy, $args);
        if (is_search() && isset($_GET['term']) && $_GET['term'] != '') {
            $select = $_GET['term'];
        }
        $level++;
        if (is_array($categories)) {
            foreach ($categories as $cat) {
                $options .= '<option value="' . $cat->slug . '" ' . selected($select, $cat->slug, false) . '>' . $spacing . $cat->name . '</option>';
                $options .= osapa_search_by_category_get_option_html($taxonomy, $cat->term_id, $level);
            }
        }

        return $options;
    }

}

/* Ajax search */
add_action('wp_ajax_osapa_ajax_search', 'osapa_ajax_search');
add_action('wp_ajax_nopriv_osapa_ajax_search', 'osapa_ajax_search');
if (!function_exists('osapa_ajax_search')) {

    function osapa_ajax_search() {
        check_ajax_referer( 'platform_security', 'security' );
        global $wpdb, $post, $smof_data;

        $search_for_product = osapa_has_woocommerce();
        if ($search_for_product) {
            $taxonomy = 'product_cat';
            $post_type = 'product';
        } else {
            $taxonomy = 'category';
            $post_type = 'post';
        }

        $num_result = isset($smof_data['osapa_ajax_search_number_result']) ? (int) $smof_data['osapa_ajax_search_number_result'] : 10;

        $search_string = sanitize_text_field($_POST['search_string']);
        $category = isset($_POST['category']) ? $_POST['category'] : '';

        $args = array(
            'post_type' => $post_type
            , 'post_status' => 'publish'
            , 's' => $search_string
            , 'posts_per_page' => $num_result
            ,'tax_query'        => array()
        );

        if ($search_for_product) {
            $args['meta_query'] = WC()->query->get_meta_query();
            $args['tax_query'] = WC()->query->get_tax_query();
        }

        if ($category != '') {
            $args['tax_query'] = array(
                array(
                    'taxonomy' => $taxonomy
                    , 'terms' => $category
                    , 'field' => 'slug'
                )
            );
        }

        $results = new WP_Query($args);

        if ($results->have_posts()) {
            $extra_class = '';
            if (isset($results->post_count, $results->found_posts) && $results->found_posts > $results->post_count) {
                $extra_class = 'view-all-results';
            }

            $html = '<ul class="ftc_list_search ' . $extra_class . '">';
            while ($results->have_posts()) {
                $results->the_post();
                $link = get_permalink($post->ID);

                $image = '';
                if ($post_type == 'product') {
                    $product = wc_get_product($post->ID);
                    $image = $product->get_image();
                } else if (has_post_thumbnail($post->ID)) {
                    $image = get_the_post_thumbnail($post->ID, 'thumbnail');
                }

                $html .= '<li>';
                $html .= '<div class="ftc-search-image">';
                $html .= '<a href="' . esc_url($link) . '">' . $image . '</a>';
                $html .= '</div>';
                $html .= '<div class="ftc-search-meta item-description">';
                $html .= '<a href="' . esc_url($link) . '" class="product_title product-name">' . osapa_search_highlight_string($post->post_title, $search_string) . '</a>';
                if ($post_type == 'product') {
                    if ($price_html = $product->get_price_html()) {
                        $html .= '<span class="price">' . $price_html . '</span>';
                    }
                }
                $html .= '</div>';
                $html .= '</li>';
            }
            $html .= '</ul>';

            if (isset($results->post_count, $results->found_posts) && $results->found_posts > $results->post_count) {
                $view_all_text = sprintf(esc_html__('View all %d results', 'osapa'), $results->found_posts);

                $html .= '<div class="view-all">';
                $html .= '<a href="#">' . $view_all_text . '</a>';
                $html .= '</div>';
            }

            wp_reset_postdata();

            $return = array();
            $return['html'] = $html;
            $return['search_string'] = $search_string;
            wp_die(json_encode($return));
        }
        else{
            $html = '<div class="no-item-search"><span class="error">'.esc_html__('No item found.', 'osapa').'</span></div>';
            $return = array();
            $return['html'] = $html;
            $return['search_string'] = $search_string;
            wp_die(json_encode($return));
        }

        wp_die('');
    }
}

if (!function_exists('osapa_search_highlight_string')) {

    function osapa_search_highlight_string($string, $search_string) {
        $new_string = '';
        $pos_left = stripos($string, $search_string);
        if ($pos_left !== false) {
            $pos_right = $pos_left + strlen($search_string);
            $new_string_right = substr($string, $pos_right);
            $search_string_insensitive = substr($string, $pos_left, strlen($search_string));
            $new_string_left = stristr($string, $search_string, true);
            $new_string = $new_string_left . '<span class="hightlight">' . $search_string_insensitive . '</span>' . $new_string_right;
        } else {
            $new_string = $string;
        }
        return $new_string;
    }

}

/* Match with ajax search results */
add_filter('woocommerce_get_catalog_ordering_args', 'osapa_woocommerce_get_catalog_ordering_args_filter');
if (!function_exists('osapa_woocommerce_get_catalog_ordering_args_filter')) {

    function osapa_woocommerce_get_catalog_ordering_args_filter($args) {
        global $smof_data;
        if (is_search() && !isset($_GET['orderby']) && get_option('woocommerce_default_catalog_orderby') == 'relevance' && isset($smof_data['osapa_ajax_search']) && $smof_data['osapa_ajax_search']) {
            $args['orderby'] = '';
            $args['order'] = '';
            $args['meta_key'] = '';
        }
        return $args;
    }
}

/* * * Social Sharing ** */
if (!function_exists('osapa_template_social_sharing')) {

    function osapa_template_social_sharing() {
        if (is_active_sidebar('product-detail-social-icon')) {
            dynamic_sidebar('product-detail-social-icon');
        }
    }

}
/** Show Page Slider **/
function osapa_show_page_slider(){
   global $osapa_page_datas;
   $revolution_exists = class_exists('RevSliderSlider');
   switch( $osapa_page_datas['ftc_page_slider'] ){
      case 'revslider':
      if( $revolution_exists && $osapa_page_datas['ftc_rev_slider'] ){
        $rev_db = new RevSliderDB();
        $response = $rev_db->fetch(RevSliderGlobals::$table_sliders, 'id='.$osapa_page_datas['ftc_rev_slider']);
        if( !empty($response) ){
           RevSliderOutput::putSlider($osapa_page_datas['ftc_rev_slider'], '');
       }
   }
   break;
   default:
   break;
}
}

/* * * Array Attribute Compare ** */
if (!function_exists('osapa_array_atts')) {

    function osapa_array_atts($pairs, $atts) {
        $atts = (array) $atts;
        $out = array();
        foreach ($pairs as $name => $default) {
            if (array_key_exists($name, $atts)) {
                if (is_array($atts[$name]) && is_array($default)) {
                    $out[$name] = osapa_array_atts($default, $atts[$name]);
                } else {
                    $out[$name] = $atts[$name];
                }
            } else {
                $out[$name] = $default;
            }
        }
        return $out;
    }

}

/* * * Breadcrumbs ** */
if (!function_exists('osapa_breadcrumbs')) {

    function osapa_breadcrumbs() {
        global $smof_data;

        $is_rtl = is_rtl() || ( isset($smof_data['ftc_enable_rtl']) && $smof_data['ftc_enable_rtl'] );

        if (osapa_has_woocommerce()) {
            if (function_exists('woocommerce_breadcrumb') && function_exists('is_woocommerce') && is_woocommerce()) {
                woocommerce_breadcrumb(array('wrap_before' => '<div class="ftc-breadcrumbs-content">', 'delimiter' => '<span>' . ($is_rtl ? '\\' : '/') . '</span>', 'wrap_after' => '</div>'));
                return;
            }
        }

        if (function_exists('bbp_breadcrumb') && function_exists('is_bbpress') && is_bbpress()) {
            $args = array(
                'before' => '<div class="ftc-breadcrumbs-content">'
                , 'after' => '</div>'
                , 'sep' => $is_rtl ? '\\' : '/'
                , 'sep_before' => '<span class="brn_arrow">'
                , 'sep_after' => '</span>'
                , 'current_before' => '<span class="current">'
                , 'current_after' => '</span>'
            );

            bbp_breadcrumb($args);
            /* Remove bbpress breadcrumbs */
            add_filter('bbp_no_breadcrumb', '__return_true', 999);
            return;
        }

        $delimiter = '<span class="brn_arrow">' . ($is_rtl ? '\\' : '/') . '</span>';

        $front_id = get_option('page_on_front');
        if (!empty($front_id)) {
            $home = get_the_title($front_id);
        } else {
            $home = esc_html__('Home', 'osapa');
        }
        $ar_title = array(
            'search' => esc_html__('Search results for ', 'osapa')
            , '404' => esc_html__('Error 404', 'osapa')
            , 'tagged' => esc_html__('Tagged ', 'osapa')
            , 'author' => esc_html__('Articles posted by ', 'osapa')
            , 'page' => esc_html__('Page', 'osapa')
            , 'portfolio' => esc_html__('Portfolio', 'osapa')
        );

        $before = '<span class="current">'; /* tag before the current crumb */
        $after = '</span>'; /* tag after the current crumb */
        global $wp_rewrite;
        $rewriteUrl = $wp_rewrite->using_permalinks();
        if (!is_home() && !is_front_page() || is_paged()) {

            echo '<div class="ftc-breadcrumbs-content">';

            global $post;
            $homeLink = esc_url(home_url('/'));
            echo '<a href="' . $homeLink . '">' . $home . '</a> ' . $delimiter . ' ';

            if (is_category()) {
                global $wp_query;
                $cat_obj = $wp_query->get_queried_object();
                $thisCat = $cat_obj->term_id;
                $thisCat = get_category($thisCat);
                $parentCat = get_category($thisCat->parent);
                if ($thisCat->parent != 0) {
                    echo get_category_parents($parentCat, true, ' ' . $delimiter . ' ');
                }
                print_r($before); print_r(single_cat_title('', false)); print_r($after);
            } elseif (is_search()) {
                print_r($before); print_r($ar_title['search'] . '"' . get_search_query() . '"'); print_r($after);
            } elseif (is_day()) {
                echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
                echo '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '">' . get_the_time('F') . '</a> ' . $delimiter . ' ';
                print_r($before); print_r(get_the_time('d')); print_r($after);
            } elseif (is_month()) {
                echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
                print_r($before); print_r(get_the_time('F')); print_r($after);
            } elseif (is_year()) {
                print_r($before); print_r(get_the_time('Y')); print_r($after);
            } elseif (is_single() && !is_attachment()) {
                if (get_post_type() != 'post') {
                    $post_type = get_post_type_object(get_post_type());
                    $slug = $post_type->rewrite;
                    $post_type_name = $post_type->labels->singular_name;
                    if (strcmp('Portfolio Item', $post_type->labels->singular_name) == 0) {
                        $post_type_name = $ar_title['portfolio'];
                    }
                    if ($rewriteUrl) {
                        echo '<a href="' . $homeLink . $slug['slug'] . '/">' . $post_type_name . '</a> ' . $delimiter . ' ';
                    } else {
                        echo '<a href="' . $homeLink . '?post_type=' . get_post_type() . '">' . $post_type_name . '</a> ' . $delimiter . ' ';
                    }

                    print_r($before); print_r(get_the_title()); print_r($after);
                } else {
                    $cat = get_the_category();
                    $cat = $cat[0];
                    echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
                    print_r($before); print_r(get_the_title()); print_r($after);
                }
            } elseif (!is_single() && !is_page() && get_post_type() != 'post' && !is_404()) {
                $post_type = get_post_type_object(get_post_type());
                $slug = $post_type->rewrite;
                $post_type_name = $post_type->labels->singular_name;
                if (strcmp('Portfolio Item', $post_type->labels->singular_name) == 0) {
                    $post_type_name = $ar_title['portfolio'];
                }
                if (is_tag()) {
                    print_r($before); print_r($ar_title['tagged'] . '"'); print_r(single_tag_title('', false) . '"'); print_r($after);
                } elseif (is_taxonomy_hierarchical(get_query_var('taxonomy'))) {
                    if ($rewriteUrl) {
                        echo '<a href="' . $homeLink . $slug['slug'] . '/">' . $post_type_name . '</a> ' . $delimiter . ' ';
                    } else {
                        echo '<a href="' . $homeLink . '?post_type=' . get_post_type() . '">' . $post_type_name . '</a> ' . $delimiter . ' ';
                    }

                    $curTaxanomy = get_query_var('taxonomy');
                    $curTerm = get_query_var('term');
                    $termNow = get_term_by('name', $curTerm, $curTaxanomy);
                    $pushPrintArr = array();
                    if ($termNow !== false) {
                        while ((int) $termNow->parent != 0) {
                            $parentTerm = get_term((int) $termNow->parent, get_query_var('taxonomy'));
                            array_push($pushPrintArr, '<a href="' . get_term_link((int) $parentTerm->term_id, $curTaxanomy) . '">' . $parentTerm->name . '</a> ' . $delimiter . ' ');
                            $curTerm = $parentTerm->name;
                            $termNow = get_term_by('name', $curTerm, $curTaxanomy);
                        }
                    }
                    $pushPrintArr = array_reverse($pushPrintArr);
                    array_push($pushPrintArr, $before . get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'))->name . $after);
                    echo implode($pushPrintArr);
                } else {
                    print_r($before) ; print_r($post_type_name) ; print_r($after);
                }
            } elseif (is_attachment()) {
                if ((int) $post->post_parent > 0) {
                    $parent = get_post($post->post_parent);
                    $cat = get_the_category($parent->ID);
                    if (count($cat) > 0) {
                        $cat = $cat[0];
                        echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
                    }
                    echo '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a> ' . $delimiter . ' ';
                }
                print_r($before); print_r(get_the_title()); print_r($after);
            } elseif (is_page() && !$post->post_parent) {
                print_r($before); print_r(get_the_title()); print_r($after);
            } elseif (is_page() && $post->post_parent) {
                $parent_id = $post->post_parent;
                $breadcrumbs = array();
                while ($parent_id) {
                    $page = get_post($parent_id);
                    $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
                    $parent_id = $page->post_parent;
                }
                $breadcrumbs = array_reverse($breadcrumbs);
                foreach ($breadcrumbs as $crumb)
                    print_r($crumb . ' '); print_r($delimiter . ' ');
                print_r($before); print_r(get_the_title()); print_r($after);
            } elseif (is_tag()) {
                print_r($before); print_r($ar_title['tagged'] . '"'); print_r(single_tag_title('', false) . '"'); print_r($after);
            } elseif (is_author()) {
                global $author;
                $userdata = get_userdata($author);
                print_r($before); print_r($ar_title['author']); print_r($userdata->display_name); print_r($after);
            } elseif (is_404()) {
                print_r($before); print_r($ar_title['404']); print_r($after);
            }

            if (get_query_var('paged')) {
                if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() || is_page_template() || is_post_type_archive() || is_archive()) {
                   print_r($before . ' (');
               }
               print_r($ar_title['page'] . ' '); print_r(get_query_var('paged'));
               if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() || is_page_template() || is_post_type_archive() || is_archive()) {
                echo ')' . $after;
            }
        } else {
            if (get_query_var('page')) {
                if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() || is_page_template() || is_post_type_archive() || is_archive()) {
                    print_r($before . ' (');
                }
                print_r($ar_title['page'] . ' '); print_r(get_query_var('page'));
                if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() || is_page_template() || is_post_type_archive() || is_archive()) {
                    echo ')' . $after;
                }
            }
        }
        echo '</div>';
    }

    wp_reset_postdata();
}

}

function osapa_breadcrumbs_title($show_breadcrumb = false, $show_page_title = false, $page_title = '', $extra_class_title = '') {
    global $smof_data, $post;
    if ($show_breadcrumb || $show_page_title) {
        $breadcrumb_bg = '';
        $bg_breadcrumbs = get_post_meta($post->ID, 'ftc_bg_breadcrumbs', true);
        if ( isset($smof_data['ftc_enable_breadcrumb_background_image']) && $smof_data['ftc_enable_breadcrumb_background_image']) {
            if(is_singular('post') && empty($bg_breadcrumbs) ){
                $breadcrumb_bg = esc_url($smof_data['ftc_bg_breadcrumbs_post']['url']);

            }else{
                $breadcrumb_bg = esc_url($smof_data['ftc_bg_breadcrumbs']['url']);
            }
        }


        $style = '';
        if ($breadcrumb_bg != '') {
            $style = 'style="background-image: url(' . $breadcrumb_bg . ')"';
            if (isset($smof_data['ftc_breadcrumb_bg_parallax']) && $smof_data['ftc_breadcrumb_bg_parallax']) {
                $extra_class .= ' ftc-breadcrumb-parallax';
            }
        }
        $no_br = 'ftc-breadcrumb';
        if(empty($breadcrumb_bg)){
            $no_br = 'no-ftc-breadcrumb';
        }
        echo '<div class="'.esc_attr($no_br).'" ' . $style . '><div class="container"><div class="ftc-breadcrumb-title">';
        if ($show_page_title) {
            echo '<h1 class="product_title page-title entry-title ' . $extra_class_title . '">' . $page_title . esc_url($bg_breadcrumbs). '</h1>';
        }
        if ($show_breadcrumb) {
            osapa_breadcrumbs();
        }
        echo '</div></div></div>';
    }
}

/* * * Product Lightbox  * * */
add_action( 'wp_footer', 'osapa_product_images_lightbox', 1000 );

if( ! function_exists( 'osapa_product_images_lightbox' ) ) {
    function osapa_product_images_lightbox(){
        get_template_part('woocommerce/single-product/photoswipe');
    }
}
if( ! function_exists( 'ftc_cookies_popup' ) ) {
    add_action( 'wp_footer', 'ftc_cookies_popup', 10 );

    function ftc_cookies_popup() {
        global $smof_data;
        if( isset($smof_data['cookies_info']) &&  ! $smof_data['cookies_info'] ) return;
        ?>

        <div class="ftc-cookies-popup">
            <div class="ftc-cookies-inner">
                <div class="cookies-info-text">
                    <a href="#" class="cookies-title">
                        <?php 
                        if( isset($smof_data['cookies_title']) && $smof_data['cookies_title'] != ''){
                            echo wp_kses_post(do_shortcode($smof_data['cookies_title']));
                        }
                        ?>
                    </a>
                    <?php 
                    if( isset($smof_data['cookies_text']) && $smof_data['cookies_text'] != ''){
                        echo wp_kses_post(do_shortcode($smof_data['cookies_text']));
                    }
                    ?>
                </div>
                <div class="cookies-buttons">
                    <a href="#" class="cookies-accept-btn"><?php esc_html_e( "Yes, I Accept" , 'osapa' ); ?></a>
                </div>
            </div>
        </div>
        
        <?php
    }
}
/* Header Mobile Navigation */
if( ! function_exists( 'ftc_header_mobile_navigation' ) ) {
    function ftc_header_mobile_navigation() {
        global $smof_data;
        ?>
        <?php if( !is_page_template('page-blank.php') ): ?>
            <div class="ftc-mobile-wrapper">

                <?php if( isset($smof_data['ftc_enable_search']) && $smof_data['ftc_enable_search'] ): ?>
                    <?php osapa_get_search_form_by_category(); ?>
                <?php endif; ?>
                <div class= "menu-text"> 
                    <button type="button" class="btn btn-toggle-canvas" data-toggle="offcanvas">
                        <i class="fa fa-close"></i>
                    </button>
                    <i class="fa fa-bars"></i>
                    <?php esc_html_e('Menu', 'osapa') ?>
                </div>

                <div class="mobile-menu-wrapper">
                    <?php
                    wp_nav_menu( array('theme_location' => 'primary', 'container_class' => 'mobile-nav-wrapper', 'menu_id' => 'primary-menu') );
                    ?>
                </div>
                <?php
                global $smof_data, $woocommerce;
                if ( isset($smof_data['ftc_mobile_layout']) && $smof_data['ftc_mobile_layout']): 
                    ?>
                    <div class="footer-mobile">
                        <div class="mobile-wishlist">
                            <?php if( class_exists('YITH_WCWL')): ?>
                                <div class="ftc-my-wishlist"><?php echo osapa_tini_wishlist(); ?></div>
                            <?php endif; ?>

                        </div>
                        <div class="mobile-account">
                            <?php 
                            $_user_logged = is_user_logged_in();
                            ob_start();
                            ?>
                            <a href="<?php echo esc_url(get_permalink(get_option('woocommerce_myaccount_page_id') ) ); ?>" title="<?php esc_html_e('Login','osapa'); ?>">
                                <i class="fa fa-user"></i>
                                <?php if ($_user_logged): ?>
                                    <?php esc_html_e('Account','osapa'); ?>
                                <?php endif; ?>
                                <?php if (!$_user_logged): ?>
                                    <?php esc_html_e('Login','osapa'); ?>
                                <?php endif; ?>
                            </a>
                        </div>
                    </div>
                <?php endif; ?>
            </div>
            <?php
        endif;
    }
}
if ( ! function_exists( 'osapa_popup_newsletter' ) ) {
    function osapa_popup_newsletter() {
        global $smof_data; 
        if(isset($smof_data['ftc_bg_popup_image']['url']) && !empty($smof_data['ftc_bg_popup_image']['url']))
            echo '<div class="popupshadow" style="display:none;"></div>';
        echo '<div class="newsletterpopup" style="display:none; background-image: url('. esc_url($smof_data['ftc_bg_popup_image']['url']) .')">';
        echo '<span class="close-popup"></span>
        <div class="wp-newletter">';
        dynamic_sidebar('popup-newletter');
        echo '</div>';
        echo '<span class="dont_show_popup"><input id="ftc_dont_show_again" type="checkbox"><label for="ftc_dont_show_again">' .esc_attr__('Don\'t show popup again', 'osapa'). '</label></span>';
        echo '</div>';
    }
}

/* Ajax nonce*/

add_action('wp_enqueue_scripts', 'ftc_ajax_platform_script_enqueue');
function ftc_ajax_platform_script_enqueue () {
    wp_enqueue_script(
        'platform',
        get_template_directory_uri(). '/assets/js/platform.js',
        array('jquery'), '1.0', true);

    wp_localize_script('platform', 'ftc_platform', array(
        'ajax_url' => admin_url('admin-ajax.php'),
        'ajax_nonce' => wp_create_nonce('platform_security')
    ));
}


/* * * Add header dynamic css ** */
add_action('wp_head', 'osapa_add_header_dynamic_css', 1000);
if (!function_exists('osapa_add_header_dynamic_css')) {

    function osapa_add_header_dynamic_css($is_iframe = false) {
        if (!$is_iframe) {
            return;
        }
        $upload_dir = wp_upload_dir();
        $filename_dir = trailingslashit($upload_dir['basedir']) . strtolower(str_replace(' ', '', wp_get_theme()->get('Name'))) . '.css';
        $filename = trailingslashit($upload_dir['baseurl']) . strtolower(str_replace(' ', '', wp_get_theme()->get('Name'))) . '.css';
        if (is_ssl()) {
            $filename = str_replace('http://', 'https://', $filename);
        }
        if (file_exists($filename_dir)) {
            wp_register_style('header_dynamic', $filename);
            wp_enqueue_style('header_dynamic');
        }
    }

}


/* Install Required Plugins */
add_action('tgmpa_register', 'osapa_register_required_plugins');

function osapa_register_required_plugins() {
    $plugin_dir_path = get_template_directory() . '/inc/plugins/';
    $ver = wp_get_theme(); 
    $version = $ver->get('Version');
    $domain = $ver->get('TextDomain');
    /**
     * 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(
        array(
            'name' => 'ThemeFTC', // The plugin name.
            'slug' => 'themeftc', // The plugin slug (typically the folder name).
            'source' => $plugin_dir_path . 'themeftc.zip', // The plugin source.
            'required' => true, // If false, the plugin is only 'recommended' instead of required.
            'version' => '1.1.2', // E.g. 1.0.0. If set, the active plugin must be this version or higher.
            '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.
        )
        , array(
            'name' => 'WooCommerce', // The plugin name.
            'slug' => 'woocommerce', // The plugin slug (typically the folder name).
            'source' => '', // The plugin source.
            'required' => false, // If false, the plugin is only 'recommended' instead of required.
        )
        , array(
            'name' => 'WPBakery Visual Composer', // The plugin name.
            'slug' => 'js_composer', // The plugin slug (typically the folder name).
            'source' => 'http://demo.themeftc.com/plugins/js_composer.zip', // The plugin source.
            'required' => true, // If false, the plugin is only 'recommended' instead of required.
            'version' => '6.1', // E.g. 1.0.0. If set, the active plugin must be this version or higher.
            '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.
        )
        , array(
            'name' => 'Revolution Slider', // The plugin name.
            'slug' => 'revslider', // The plugin slug (typically the folder name).
            'source' => 'http://demo.themeftc.com/plugins/revslider.zip', // The plugin source.
            'required' => false, // If false, the plugin is only 'recommended' instead of required.
            'version' => '6.1.7', // E.g. 1.0.0. If set, the active plugin must be this version or higher.
            '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.
        )
        ,array(
            'name' => 'FTC Importer', // The plugin name.
            'slug' => 'ftc_importer', // The plugin slug (typically the folder name).
            'source' => 'http://demo.themeftc.com/osapa-woo/content/ftc-importer-osapa-'.$version.'.zip', // The plugin source.
            'required' => true, // If false, the plugin is only 'recommended' instead of required.
            'version' => '1.1.3', // E.g. 1.0.0. If set, the active plugin must be this version or higher.
            '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.
        )
        , array(
            'name' => 'Mega Main Menu', // The plugin name.
            'slug' => 'mega_main_menu', // The plugin slug (typically the folder name).
            'source' => 'http://demo.themeftc.com/plugins/mega_main_menu.zip', // The plugin source.
            'required' => false, // If false, the plugin is only 'recommended' instead of required.
            'version' => '2.1.5', // E.g. 1.0.0. If set, the active plugin must be this version or higher.
            '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.
        ) 
        , array(
            'name' => 'Regenerate Thumbnails', // The plugin name.
            'slug' => 'regenerate-thumbnails', // The plugin slug (typically the folder name).
            'required' => false, // If false, the plugin is only 'recommended' instead of required.
        )

        , array(
            'name' => 'Contact Form 7', // The plugin name.
            'slug' => 'contact-form-7', // The plugin slug (typically the folder name).
            'required' => false, // If false, the plugin is only 'recommended' instead of required.
        )
        , array(
            'name'                => 'MailChimp for WordPress'
            ,'slug'               => 'mailchimp-for-wp'
            ,'required'           => false,
        )
        , array(
            'name' => 'YITH WooCommerce Wishlist', // The plugin name.
            'slug' => 'yith-woocommerce-wishlist', // The plugin slug (typically the folder name).
            'required' => false, // If false, the plugin is only 'recommended' instead of required.
        )
        , array(
            'name' => 'YITH WooCommerce Compare', // The plugin name.
            'slug' => 'yith-woocommerce-compare', // The plugin slug (typically the folder name).
            'required' => false, // If false, the plugin is only 'recommended' instead of required.
        )
        , array(
            'name' => 'Redux Framework',
            'slug' => 'redux-framework',
            'required' => false,
        )
        , array(
            'name' => 'YITH WooCommerce Ajax Product Filter', // The plugin name.
            'slug' => 'yith-woocommerce-ajax-navigation', // The plugin slug (typically the folder name).
            'required' => false, // If false, the plugin is only 'recommended' instead of required.
        )
        , array(
         'name' => 'Dokan Lite', // The plugin name.
            'slug' => 'dokan-lite', // The plugin slug (typically the folder name).
            'required' => false, // If false, the plugin is only 'recommended' instead of required.
        )
        , array(
            'name' => 'Woocommerce Variation Swatches', // The plugin name.
            'slug' => 'woo-variation-swatches', // The plugin slug (typically the folder name).
            'required' => false, // If false, the plugin is only 'recommended' instead of required.
        )
    );

    /*
     * 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.
     */
    $config = array(
        'id' => 'tgmpa', // Unique ID for hashing notices for multiple instances of TGMPA.
        'default_path' => '', // Default absolute path to bundled 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.
    );
    tgmpa($plugins, $config);
}
?>