<?php
/* ======================================= */
/* Andaman Theme Functions */
/* ======================================= */
if ( ! isset( $content_width ) ) $content_width = 1140; /* pixels */

/* Makes theme available for translation. */
add_action('after_setup_theme', 'andaman_theme_setup');
function andaman_theme_setup(){

load_theme_textdomain( 'andaman', get_template_directory() . '/language' );
}


/*=======================================
  TGM Plugins Activations
=======================================*/
require_once get_template_directory() . '/framework/functions/tgma/class-tgm-plugin-activation.php';
add_action( 'tgmpa_register', 'andaman_register_required_plugins' );
function andaman_register_required_plugins() {

  $plugins = array(

    array(
      'name'            => esc_html__('Kirki Customizer', 'andaman'), // The plugin name
      'slug'            => 'kirki', // The plugin slug (typically the folder name)
      'required'        => true, // If false, the plugin is only 'recommended' instead of required
      'force_activation'=> false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch
    ),
     array(
      'name'            => esc_html__('WPBakery Page Builder', 'andaman'), // The plugin name
      'slug'            => 'js_composer', // The plugin slug (typically the folder name)
      'source'          => 'js_composer.zip',
      'required'        => true, // If false, the plugin is only 'recommended' instead of required
      'version'         => '5.6',
      'force_activation'=> false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch
    ),

    array(
      'name'            => esc_html__('Andaman Helper', 'andaman'), // The plugin name
      'slug'            => 'wp-andaman-plugins', // The plugin slug (typically the folder name)
      'source'          => 'wp-andaman-plugins.zip', // The plugin source
      'required'        => true, // If false, the plugin is only 'recommended' instead of required
      'version'         => '1.0.2', // E.g. 1.0.0. If set, the active plugin must be this version or higher, otherwise a notice is presented
      'force_activation'=> true, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch
    ),

    array(
      'name'            => esc_html__('Contact Form 7', 'andaman'), // 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'            => esc_html__('WP Instagram Widget', 'andaman'), // The plugin name
      'slug'            => 'wp-instagram-widget', // The plugin slug (typically the folder name)
      'required'        => false, // If false, the plugin is only 'recommended' instead of required
    ),

    array(
      'name'            => esc_html__('Envato Market', 'andaman'), // The plugin name
      'slug'            => 'envato-market', // The plugin slug (typically the folder name)
      'source'          => 'envato-market.zip',
      'version'         => '2.0.1',
      'required'        => false, // If false, the plugin is only 'recommended' instead of required
    ),

  );

  $config = array(
    'id'           => 'andaman',                 // Unique ID for hashing notices for multiple instances of TGMPA.
    'default_path' => get_template_directory() . '/framework/functions/tgma/plugins/',
    'menu'         => 'tgmpa-install-plugins',
    'parent_slug'  => 'themes.php',
    'capability'   => 'edit_theme_options',
    'has_notices'  => true,
    'dismissable'  => true,
    'dismiss_msg'  => '',
    'is_automatic' => true,
    'message'      => '',
  );

  tgmpa( $plugins, $config );
}

class AndamanTheme_VC {


  public function __construct() {

    // set hooks
    add_action( 'vc_before_init', array( $this, 'set_vc_as_bundled' ) );
    add_action( 'vc_build_admin_page', array( $this, 'remove_vc_core_widgets' ) );
    add_action( 'vc_load_shortcode', array( $this, 'remove_vc_core_widgets' ) );
    remove_action( 'admin_init', 'vc_page_welcome_redirect');
    remove_action( 'vc_activation_hook', 'vc_page_welcome_set_redirect');
  }


  /**
   * Setup VC as "bundled with theme"
   */
  public function set_vc_as_bundled() {
    if ( function_exists( 'vc_manager' ) ) {
      vc_manager()->disableUpdater( true );
      vc_manager()->setIsAsTheme( true );

    }
    vc_set_as_theme();
  }


  /**
   * Remove rude VC built-in elements
   */
  public function remove_vc_core_widgets() {
    vc_remove_element( 'vc_gallery' );
    vc_remove_element( 'vc_images_carousel' );
    vc_remove_element( 'vc_cta' );
    vc_remove_element( 'vc_posts_slider' );
  }

}
new AndamanTheme_VC();



/*-----------------------------------------------------------------------------------*/
/*  Andaman Includes
/*-----------------------------------------------------------------------------------*/

include( get_template_directory() . '/framework/functions/theme-options.php');
include( get_template_directory() . '/framework/functions/sidebars.php');
include( get_template_directory() . '/framework/functions/search-exclude/search-exclude.php');


/*-----------------------------------------------------------------------------------*/
/*  Andaman Register menu
/*-----------------------------------------------------------------------------------*/

if( !function_exists('andaman_register_menu') ) {
  function andaman_register_menu() {
    register_nav_menus(
      array(
      'menu' => esc_html__('Main Menu', 'andaman' ),
      'onepage-menu' => esc_html__('One Page Menu', 'andaman' ),
      'not-found-menu' => esc_html__('404 Error Menu', 'andaman' ),
      'footer-menu' => esc_html__('Footer Menu', 'andaman' )
      )
    );
  }
  add_action( 'init', 'andaman_register_menu' );
}

/*
|--------------------------------------------------------------------------
| Andaman More Remove
|--------------------------------------------------------------------------
*/

add_filter( 'the_content_more_link', 'andaman_modify_read_more_link' );
function andaman_modify_read_more_link() {
return '';
};


/*
|--------------------------------------------------------------------------
| Remove more link function
|--------------------------------------------------------------------------
*/

function andaman_excerpt_more( $more ) {
    return '...';
}
add_filter('excerpt_more', 'andaman_excerpt_more');

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

/*
|--------------------------------------------------------------------------
| Theme Stylesheets
|--------------------------------------------------------------------------
*/

function andaman_scripts_styles(){
  $theme_info = wp_get_theme();
  wp_enqueue_style('bootstrap', get_template_directory_uri() . '/assets/css/bootstrap.css', array(), $theme_info->get( 'Version' )); 
  wp_enqueue_style('andaman-fonts', andaman_fonts_url(), array(), null );
  wp_enqueue_style('andaman-style', get_stylesheet_uri(), array(), $theme_info->get( 'Version' )); 
  wp_enqueue_style('andaman-theme-style', get_template_directory_uri() . '/assets/css/theme-style.css', array(), $theme_info->get( 'Version' )); 
  wp_enqueue_style('fontawesome-icons', get_template_directory_uri() . '/assets/css/fontawesome.min.css', array(), $theme_info->get( 'Version' )); 
  wp_enqueue_style('ionicons-icons', get_template_directory_uri() . '/assets/css/flaticon.css', array(), $theme_info->get( 'Version' )); 
  wp_enqueue_style('owl-carousel', get_template_directory_uri() . '/assets/css/owl.carousel.css', array(), $theme_info->get( 'Version' )); 
  wp_enqueue_style('swipebox', get_template_directory_uri() . '/assets/css/swipebox.css', array(), $theme_info->get( 'Version' )); 
  wp_enqueue_style('animate', get_template_directory_uri() . '/assets/css/animate.css', array(), $theme_info->get( 'Version' )); 
  wp_enqueue_style('andaman-responsive', get_template_directory_uri() . '/assets/css/responsive.css', array(), $theme_info->get( 'Version' )); 

    $color = get_theme_mod('header_color_image');
    if ($color) {
      $custom_skin_css =
        ".intro-body:before { background: $color}\n" .
        ".tag_line_image .tag-body:before { background: $color}";
      wp_add_inline_style( 'andaman-responsive', "/* Custom CSS */\n $custom_skin_css" );
    }

    $site_color = get_theme_mod('site_colors');
    if ($site_color) {
      $custom_color_css =
        ".menu-transparent .navbar { background: $site_color}\n" .
        ".blog-button a:after { color: $site_color !important;}\n" .
        ".contacts-block i:before { color: $site_color !important;}\n" .
        ".video_slider_button i:before { color: $site_color !important;}\n" .
        ".twitter-block li:before { color: $site_color !important;}\n" .
        ".testimonial-block .testimonial-icon i { color: $site_color !important;}\n" .
        ".process-circle .process-circle-icon i:before { color: $site_color !important;}\n" .
        ".post-thumbnail .blog-heart i:before { color: $site_color !important;}\n" .
        ".hi-icon-effect .hi-icon { color: $site_color;}\n" .
        ".hi-icon-effect .hi-icon:before { color: $site_color !important;}\n" .
        ".soc-footer li i:before  { color: $site_color !important;}\n" .
        ".promo-block .title-p-line span.promo-icon i:before  { color: $site_color !important;}\n" .
        ".footer-copyright .love-info i:before  { color: $site_color !important;}\n" .
        ".post-set.sticky.has-post-thumbnail .post-hover:before  { color: $site_color !important;}\n" .
        ".contact-footer li i:before  { color: $site_color !important;}\n" .
        ".header.style2 .nav>li>a:hover  { color: $site_color;}\n" .
        ".scroll-top { background: $site_color}\n" .
        ".post-thumbnail .blog-heart:hover { background: $site_color}\n" .
        ".promo-block .title-p-line span.promo-line:after { border-color: $site_color}\n" .
        "blockquote { background: $site_color}\n" .
        ".pricing_tables_name { background: $site_color}\n" .
        ".andaman_pg_single span { background: $site_color}\n" .
        ".andaman_pg_single a:hover>span { background: $site_color}\n" .
        ".nav-links a:hover { background: $site_color}\n" .
        ".owl-dots .owl-dot span { background: $site_color}\n" .
        ".owl-dots .owl-dot.active span,.owl-dots .owl-dot:hover span { background: $site_color}\n" .
        ".nav-links a:hover { background: $site_color}\n" .
        ".current-cat .filter_button { color: $site_color; border-color: $site_color}\n" .
        ".filter_button:hover { color: $site_color;}\n" .
        ".portfolio-single-fields i { color: $site_color;}\n" .
        ".nav-links span.current { background: $site_color}\n" .
        ".team-image .team-social li a { background: $site_color}\n" .
        ".stats-icon { background: $site_color}\n" .
        ".service-read:after { color: $site_color !important;}\n" .
        ".stats-block.style2 span.stats-line { background: $site_color}\n" .
        ".promo-block .title-p-line span.promo-line { background: $site_color}\n" .
        ".instagram-pics li img { background: $site_color}\n" .
        ".process-circle .process-circle-num { background: $site_color}\n" .
        "#status>div { background: $site_color}\n" .
        ".btn-blue { background: $site_color}\n" .
        ".blog-main.tile .blog-wrap .post-meta li.category-tiles { background: $site_color}\n" .
        ".tagcloud a { background: $site_color}\n" .
        ".services-grid.minimal .hi-icon-effect .hi-icon { background: $site_color}\n" .
        ".pager li i { color: $site_color}\n" .
        ".button, html input[type='button'], input[type='reset'], input[type='submit'] { background: $site_color}\n" .
        "input:focus,textarea:focus { border-color: $site_color !important}\n" .
        ".stats-block.style2 span.stats-line:after { border-color: $site_color}\n" .
        ".process-circle-wrap span:after { border-color: $site_color}\n" .
        ".btn-border { border-color: $site_color; color: $site_color !important;}\n" .
        ".intro .carousel-indicators .active { background: $site_color}\n" .
        ".top_bar { background: $site_color}\n" .
        ".navbar-nav ul.sm-nowrap .current-menu-ancestor>a { color: $site_color}\n" .
        ".navbar-nav ul.sm-nowrap .current-menu-ancestor li.current-menu-item a { color: $site_color}\n" .
        ".navbar-nav ul.sm-nowrap li.current-menu-item>a { color: $site_color}\n" .
        ".burger_andaman_menu_overlay_normal .burger_andaman_main_menu .current-menu-parent>a, .burger_andaman_menu_overlay_normal .burger_andaman_main_menu .current-page-parent>a, .burger_andaman_menu_overlay_normal .burger_andaman_main_menu .current_page_parent>a { color: $site_color}\n" .
        ".burger_andaman_menu_overlay_normal .burger_andaman_main_menu li.menu-item-has-children>a.sub-active { color: $site_color}\n" .
        ".burger_andaman_menu_overlay_normal li.current-menu-item>a, .burger_andaman_menu_overlay_normal li.current-page-item>a { color: $site_color}\n" .
        ".andaman_cat_count { background: #f6f6f6}\n" .
        ".header .soc-top li.lang .lang-ul li:hover { background: #f6f6f6}\n" .
        ".navigation.pagination { background: #f6f6f6}\n" .
        ".pagination-line { background: #f6f6f6}\n" .
        ".navbar-custom .nav .dropdown-menu li a:hover { background: #f6f6f6; color: $site_color;}\n" .
        ".post-set.no-thumbnail.sticky.andaman_mas_item .content-block { background: #f6f6f6}\n" .
        ".chess-post { background: #f6f6f6}\n" .
        ".process-circle { background: #f6f6f6}\n" .
        ".nav-links a,.nav-links span { background: #f6f6f6}\n" .
        ".andaman_pg_single { background: #f6f6f6}\n" .
        ".post-set.no-thumbnail.sticky { background: #f6f6f6}\n" .
        ".black-search-table-cell input[name='s'] { background: #f6f6f6}\n" .
        "ul.post-meta li:after { background: $site_color}";
      wp_add_inline_style( 'andaman-responsive', "$custom_color_css" );
    }

    $color_text = get_theme_mod('header_color_image_title','#ffffff');
    if ($color_text) {
      $custom_skin_css_text =
        ".intro-body h1,.intro-body h2,.intro-body h3,.intro-body h4,.intro-body h5,.intro-body h6 { color: $color_text}\n" .
        ".tag-body h1,.tag-body h2,.tag-body h3,.tag-body h4,.tag-body h5,.tag-body h6 { color: $color_text}";
      wp_add_inline_style( 'andaman-responsive', "$custom_skin_css_text \n/* Custom CSS END */" );
    }

}
add_action( 'wp_enqueue_scripts', 'andaman_scripts_styles', 90 );




/*
|--------------------------------------------------------------------------
| Theme Scripts
|--------------------------------------------------------------------------
*/
if ( !function_exists( 'andaman_load_scripts' ) ) {
  function andaman_load_scripts() {

    $theme_info = wp_get_theme(); 

    wp_enqueue_script('bootstrap', get_template_directory_uri() . '/assets/js/bootstrap.min.js', array('jquery'), $theme_info->get( 'Version' ), true);
    wp_enqueue_script('viewportchecker', get_template_directory_uri() . '/assets/js/viewportchecker.js', array('jquery'), $theme_info->get( 'Version' ), true);
    wp_enqueue_script('jquery-fitvids',  get_template_directory_uri() . '/assets/js/jquery.fitvids.js', array('jquery'), $theme_info->get( 'Version' ), true);
    wp_enqueue_script('jquery-smartmenus', get_template_directory_uri() . '/assets/js/jquery.smartmenus.js', array('jquery'), $theme_info->get( 'Version' ), true);
    wp_enqueue_script('wow', get_template_directory_uri() . '/assets/js/wow.min.js', array('jquery'), $theme_info->get( 'Version' ), true);
    wp_enqueue_script('jquery-swipebox', get_template_directory_uri() . '/assets/js/jquery.swipebox.min.js', array('jquery'), $theme_info->get( 'Version' ), true);
    wp_enqueue_script('isotope-custom', get_template_directory_uri() . '/assets/js/isotope.pkgd.min.js', array('jquery'), $theme_info->get( 'Version' ), true);
    wp_enqueue_script('jquery-easing', get_template_directory_uri() . '/assets/js/jquery.easing.min.js', array('jquery'), $theme_info->get( 'Version' ), true);
    wp_enqueue_script('jquery-waypoints', get_template_directory_uri() . '/assets/js/jquery.waypoints.min.js', array('jquery'), $theme_info->get( 'Version' ), true);
    wp_enqueue_script('imagesloaded');
    wp_enqueue_script('sticky', get_template_directory_uri() . '/assets/js/jquery.sticky.js', array('jquery'), $theme_info->get( 'Version' ), true);
    wp_enqueue_script('jquery-malihu-pagescroll2id', get_template_directory_uri() . '/assets/js/jquery.malihu.PageScroll2id.js', array('jquery'), $theme_info->get( 'Version' ), true);
    wp_enqueue_script('jquery-countdown', get_template_directory_uri() . '/assets/js/jquery.countdown.min.js', array('jquery'), $theme_info->get( 'Version' ), true);
    wp_enqueue_script('owl-carousel', get_template_directory_uri() . '/assets/js/owl.carousel.min.js', array('jquery'), $theme_info->get( 'Version' ), true);
    if (get_theme_mod('andaman-sticky-footer')){wp_enqueue_script('sticky_footer', get_template_directory_uri() . '/assets/js/sticky-footer.js', array('jquery'), $theme_info->get( 'Version' ), true);}
    wp_enqueue_script('andaman-main', get_template_directory_uri() . '/assets/js/main.js', array('jquery'), $theme_info->get( 'Version' ), true);
    if(is_singular() && comments_open()) {wp_enqueue_script('comment-reply');}
  };
};
add_action('wp_enqueue_scripts', 'andaman_load_scripts');


function equip_admin() {
  $theme_info = wp_get_theme(); 
  wp_enqueue_style( 'andaman-admin-styles-css', get_template_directory_uri() . '/assets/css/admin/styles.css', array(), $theme_info->get( 'Version' )); 
};
add_action('admin_enqueue_scripts', 'equip_admin', 10000 );


/*
|--------------------------------------------------------------------------
| Andaman page menu
|--------------------------------------------------------------------------
*/

function andaman_page_menu_args( $args ) {
  if ( ! isset( $args['show_home'] ) )
    $args['show_home'] = true;
  return $args;
}
add_filter( 'wp_page_menu_args', 'andaman_page_menu_args' );

/*
|--------------------------------------------------------------------------
| Andaman content navigation
|--------------------------------------------------------------------------
*/

if ( ! function_exists( 'andaman_content_nav' ) ) :

function andaman_content_nav( $html_id ) {
  global $wp_query;

  if ( $wp_query->max_num_pages > 1 ) : ?>
    <nav id="<?php echo esc_attr($html_id) ?>" class="navigation" role="navigation">
      <div class="nav-previous"><?php next_posts_link( '<span class="meta-nav">&larr;</span>'.esc_html__('Older posts', 'andaman' ) ); ?></div>
      <div class="nav-next"><?php previous_posts_link( esc_html__( 'Newer posts', 'andaman' ) . '<span class="meta-nav">&rarr;</span>' ); ?></div>
    </nav>
  <?php endif;
}
endif;


/*
|--------------------------------------------------------------------------
| Andaman comments
|--------------------------------------------------------------------------
*/

if ( ! function_exists( 'andaman_comment' ) ) :
function andaman_comment( $comment, $args, $depth ) {
  $GLOBALS['comment'] = $comment;
  switch ( $comment->comment_type ) :
    case 'pingback' :
    case 'trackback' :
  ?>
  <li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">
    <p><?php esc_html_e( 'Pingback:', 'andaman' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( esc_html__( 'Edit', 'andaman' ), '<span class="edit-link">', '</span>' ); ?></p>
  <?php
      break;
    default :
    global $post;
  ?>
  <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
    <article id="comment-<?php comment_ID(); ?>" class="comment">
      <header class="comment-meta comment-author vcard">
        <?php
          echo get_avatar( $comment, 75 );
          printf( '<div class="author-card">%1$s</div>',
            get_comment_author_link(),
            ( $comment->user_id === $post->post_author ) ? '<span>' . esc_html__( 'Post author', 'andaman' ) . '</span>' : ''
          );
          printf( '<div class="comment-time">%3$s</div>',
            esc_url( get_comment_link( $comment->comment_ID ) ),
            get_comment_time( 'c' ),
            sprintf( esc_html__( '%1$s at %2$s', 'andaman' ), get_comment_date(), get_comment_time() )
          );
        ?>
      </header>

      <?php if ( '0' == $comment->comment_approved ) : ?>
        <p class="comment-awaiting-moderation"><?php esc_html_e( 'Your comment is awaiting moderation.', 'andaman' ); ?></p>
      <?php endif; ?>

      <section class="comment-content comment">
        <?php comment_text(); ?>
        <?php edit_comment_link( esc_html__( 'Edit', 'andaman' ), '<div class="edit-link">', '</div>' ); ?>
        <div class="reply">
          <?php comment_reply_link( array_merge( $args, array( 'reply_text' => esc_html__( 'Reply', 'andaman' ), 'after' => '', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
        </div><!-- .reply -->
      </section><!-- .comment-content -->
    </article><!-- #comment-## -->
  <?php
    break;
  endswitch; // end comment_type check
}
endif;

function is_blog() {
  global $post;
  $posttype = get_post_type( $post );
  return ( ( $posttype == 'post' ) && ( is_home() || is_single() || is_archive() || is_category() || is_tag() || is_author() ) ) ? true : false;
}

function andaman_fix_blog_link_on_cpt( $classes, $item, $args ) {
  if( !is_blog() ) {
    $blog_page_id = intval( get_option('page_for_posts') );
    if( $blog_page_id != 0 && $item->object_id == $blog_page_id )
      unset($classes[array_search('current_page_parent', $classes)]);
  }
  return $classes;
}
add_filter( 'nav_menu_css_class', 'andaman_fix_blog_link_on_cpt', 10, 3 );
/*
|--------------------------------------------------------------------------
| Andaman post types and functions
|--------------------------------------------------------------------------
*/

function andaman_setup() {
  add_theme_support( 'automatic-feed-links' );
  add_theme_support( "title-tag" );
  remove_theme_support( 'post-formats');
  add_theme_support( 'post-thumbnails' );
  set_post_thumbnail_size( 680, 9999 ); // Unlimited height, soft crop
}
add_action( 'after_setup_theme', 'andaman_setup' );


if ( ! function_exists( 'andaman_theme_build_tag' ) ):

  function andaman_theme_build_tag( $tag, $atts = array(), $content = null, $single = false ) {
    $single_tags = array( 'img' );
    if ( in_array( $tag, $single_tags ) ) {
      $single = true;
    }

    $html = "<{$tag} ";
    foreach ( $atts as $attr => $value ) {
      $attr  = esc_attr( $attr );
      $value = esc_attr( $value );
      $html  .= "{$attr}=\"{$value}\" ";
    }

    $html = trim( $html );

    if ( $single ) {
      $html .= " />";

      return $html;
    }

    $html .= ">" . $content . "</{$tag}>";

    return $html;
  }

endif;

if ( ! function_exists( 'andaman_theme_get_category' ) ) :

  function andaman_theme_get_category( $post_id = null ) {
    $category = get_the_category();
    if ( ! $category || empty( $category ) ) {
      return;
    }

    // Show the post's 'Primary' category, if this Yoast feature is available, & one is set
    if ( class_exists( 'WPSEO_Primary_Term' ) ) {
      $wpseo_primary_term = new WPSEO_Primary_Term( 'category', get_the_id() );
      $wpseo_primary_term = $wpseo_primary_term->get_primary_term();
      $term               = get_term( $wpseo_primary_term );
      if ( ! is_wp_error( $term ) ) { // Yoast Primary category
        $category_display = $term->name;
        $category_link    = get_category_link( $term->term_id );
      }
    }

    // Default, display the first category in WP's list of assigned categories
    if ( ! isset( $category_display, $category_link ) ) {
      $category_display = $category[0]->name;
      $category_link    = get_category_link( $category[0]->term_id );
    }

    // Display category
    echo andaman_theme_build_tag(
      'a',
      array(
        'href'  => $category_link,
        'class' => 'post-category'
      ),
      esc_html( $category_display )
    );
  }

endif;

/*-----------------------------------------------------------------------------------*/
/*  Connect Google Fonts
/*-----------------------------------------------------------------------------------*/


function andaman_fonts_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.
*/
$open_sans = _x( 'on', 'Open Sans font: on or off', 'andaman' );
$karla = _x( 'on', 'Karla font: on or off', 'andaman' );
 
if ( 'off' !== $open_sans || 'off' !== $karla) {
$font_families = array();
 
if ( 'off' !== $open_sans ) {
$font_families[] = 'Open Sans:300,300i,400,400i,600,600i,700,700i';
}

if ( 'off' !== $karla ) {
$font_families[] = 'Karla:400,400i,700,700i';
}

$query_args = array(
'family' => urlencode( implode( '|', $font_families ) ),
'subset' => urlencode( 'latin,latin-ext,cyrillic' ),
);
 
$fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
}
 
return esc_url_raw( $fonts_url );
}

/*-----------------------------------------------------------------------------------*/
/*  Other Functions
/*-----------------------------------------------------------------------------------*/

add_filter( 'wp_list_categories', 'andaman_add_span_cat_count' );
function andaman_add_span_cat_count( $links ) {
  $links = str_replace( '(', '<span class="andaman_cat_count">', $links );
  $links = str_replace( ')', '</span>', $links );

  return $links;
}

add_filter( 'get_archives_link', 'andaman_add_span_arch_count', 10, 6 );
function andaman_add_span_arch_count( $link_html, $url, $text, $format, $before, $after ) {
  if ( $format === 'html' ) {
    $after = preg_replace( '/^(.*)\((\d+)\)$/s', '$1<span class="andaman_cat_count">$2</span>', $after );
    return '<li>' . $before . andaman_theme_build_tag( 'a', array( 'href' => $url ), $text ) . $after . '</li>';
  } else {
    return $link_html;
  }
}

if(get_theme_mod('andaman_menu_select') == 'onepage')  { 
  function andaman_add_classes_a($atts, $item, $args) {
      $class = 'page-scroll';
      $atts['class'] = $class;
      return $atts;
  }
add_filter('nav_menu_link_attributes','andaman_add_classes_a', 10, 3 );
};

function andaman_MenuFallback ($args) {
  echo '<ul id="menu-all-pages" class="nav navbar-nav"><li class="menu-item menu-item-type-custom menu-item-object-custom current-menu-item current_page_item"><a href="'. get_home_url() .'">' . esc_html__('Home', 'andaman') . '</a></li>
</ul>';
}
function andaman_MenuFallback_not_found ($args) {
  echo '<ul id="menu-short" class="menu"><li ><a href="'. get_home_url() .'">' . esc_html__('Home', 'andaman') . '</a></li></ul>';
}
function andaman_MenuFallback_footer ($args) {
  echo '';
}
class Andaman_My_Walker_Nav_Menu extends Walker_Nav_Menu {
  function start_lvl(&$output, $depth = 0, $args = Array() ) {
    $indent = str_repeat("\t", $depth);
    $output .= "\n$indent<ul class=\"dropdown-menu\">\n";
  }
}