File "template-functions.php"

Full Path: /home/adniftyx/public_html/credio/inc/template-functions.php
File size: 31.84 KB
MIME-type: text/x-php
Charset: utf-8

<?php
/**
 * @author  rs-theme
 */
function credio_body_classes( $classes ) {
  // Adds a class of hfeed to non-singular pages.
  if ( ! is_singular() ) {
    $classes[] = 'hfeed';
  }

  return $classes;
}
add_filter( 'body_class', 'credio_body_classes' );


function rs__reading_times_grids() {
    $post = get_post();
    $words = count(preg_split('/\s+/', strip_tags( $post->post_content )));
    $minutes = floor( $words / 800 );
    $seconds = floor( $words % 800 / ( 800 / 60 ) );
    if ( 1 <= $minutes ) {
        $rs__time = ($minutes == 1 ? '': $minutes . '' ) . ' '. ($seconds == 1 ? '' :  $seconds . '' );
    } else {
        $rs__time = $seconds . '';
    }
    return $rs__time;
}

/*
Smooth Scroll Class
*/
function credio_smooth_scroll_class( $classes ) {
  $scrollSmoother = !empty(get_theme_mod('rs_smooth_scroll_enable_disable'));
  if ( $scrollSmoother ) {
      $classes[] = 'rs-smoother-yes';
  }
  return $classes;
}

add_filter( 'body_class', 'credio_smooth_scroll_class' );

/**
 * Add a pingback url auto-discovery header for singularly identifiable articles.
 */
function credio_pingback_header() {
  if ( is_singular() && pings_open() ) {
    echo '<link rel="pingback" href="', esc_url( get_bloginfo( 'pingback_url' ) ), '">';
  }
}

add_action( 'wp_head', 'credio_pingback_header' );

/**  kses_allowed_html */

function credio_prefix_kses_allowed_html($tags, $context) {
  switch($context) {
    case 'credio': 
      $tags = array( 
        'a' => array('href' => array()),
        'b' => array()
      );
      return $tags;
    default: 
      return $tags;
  }
}

add_filter( 'wp_kses_allowed_html', 'credio_prefix_kses_allowed_html', 10, 2);

function credio_get_postTitleArray($postType = 'post' ) {
    $post_type_query  = new WP_Query(
        array (
            'post_type'      => $postType,
            'posts_per_page' => -1
        )
    );
    // we need the array of posts
    $posts_array      = $post_type_query->posts;
    // the key equals the ID, the value is the post_title
    if ( is_array($posts_array) ) {
        $post_title_array = wp_list_pluck($posts_array, 'post_title', 'ID' );
    }else {
      $post_title_array['default'] = esc_html__( 'Default', 'credio' );
    }
    return $post_title_array;
}

function credio_studio_fonts_url() {
    $font_url = '';    
    $credio_body_font = get_theme_mod('credio_body_font', 'Raleway, sans-serif');
    $credio_header_font = get_theme_mod('credio_header_font', 'Raleway, sans-serif');
    $credio_heading_font = get_theme_mod('credio_heading_font', 'Raleway, sans-serif');
    $credio_h1_font = get_theme_mod('credio_h1_font', 'Raleway, sans-serif');
    $credio_h2_font = get_theme_mod('credio_h2_font', 'Raleway, sans-serif');
    $credio_h3_font = get_theme_mod('credio_h3_font', 'Raleway, sans-serif');
    $credio_h4_font = get_theme_mod('credio_h4_font', 'Raleway, sans-serif');
    $credio_h5_font = get_theme_mod('credio_h5_font', 'Raleway, sans-serif');
    $credio_h6_font = get_theme_mod('credio_h6_font', 'Raleway, sans-serif');

    $font_families = array();

    if ( $credio_body_font !== 'Raleway, sans-serif' ) {
        $font_families[] = $credio_body_font;
    }

    if ( $credio_header_font !== 'Raleway, sans-serif' ) {
        $font_families[] = $credio_header_font;
    }

    if ( $credio_heading_font !== 'Raleway, sans-serif' ) {
        $font_families[] = $credio_heading_font;
    }

    if ( $credio_h1_font !== 'Raleway, sans-serif' ) {
        $font_families[] = $credio_h1_font;
    }

    if ( $credio_h2_font !== 'Raleway, sans-serif' ) {
        $font_families[] = $credio_h2_font;
    }

    if ( $credio_h3_font !== 'Raleway, sans-serif' ) {
        $font_families[] = $credio_h3_font;
    }

    if ( $credio_h4_font !== 'Raleway, sans-serif' ) {
        $font_families[] = $credio_h4_font;
    }

    if ( $credio_h5_font !== 'Raleway, sans-serif' ) {
        $font_families[] = $credio_h5_font;
    }

    if ( $credio_h6_font !== 'Raleway, sans-serif' ) {
        $font_families[] = $credio_h6_font;
    }

    if ( ! empty( $font_families ) ) {
        $font_url = add_query_arg( 'family', urlencode( implode( '|', $font_families ) . ':400,500,600,700&display=swap' ), "//fonts.googleapis.com/css" );
    } else {
        $font_url = add_query_arg( 'family', urlencode( 'Rubik:400,500,600,700&display=swap' ), "//fonts.googleapis.com/css" );
    }
    return $font_url;
}

/*
Enqueue scripts and styles.
*/

function credio_studio_scripts() {
    wp_enqueue_style( 'studio-fonts', credio_studio_fonts_url(), array(), '1.0.0' );
}
add_action( 'wp_enqueue_scripts', 'credio_studio_scripts' );

//Favicon Icon
function credio_site_icon() {
    if ( ! ( function_exists( 'has_site_icon' ) && has_site_icon() ) ) {          
    if(!empty(get_theme_mod('credio_favicon')))
    {?>
    <link rel="shortcut icon" type="image/x-icon" href="<?php echo esc_url(get_theme_mod('credio_favicon')); ?>"> 
  <?php 
    }
  }
}
add_filter('wp_head', 'credio_site_icon');

//excerpt for specific section
function credio_wpex_get_excerpt( $args = array() ) {
  // Defaults
  $defaults = array(
    'post'            => '',
    'length'          => 48,
    'readmore'        => false,
    'readmore_text'   => esc_html__( 'read more', 'credio' ),
    'readmore_after'  => '',
    'custom_excerpts' => true,
    'disable_more'    => false,
  );
  // Apply filters
  $defaults = apply_filters( 'credio_wpex_get_excerpt_defaults', $defaults );
  // Parse args
  $args = wp_parse_args( $args, $defaults );
  // Apply filters to args
  $args = apply_filters( 'credio_wpex_get_excerpt_args', $defaults );
  // Extract
  extract( $args );
  // Get global post data
  if ( ! $post ) {
    global $post;
  }

  // Get post ID
  $post_id = $post->ID;

  // Check for custom excerpt
  if ( $custom_excerpts && has_excerpt( $post_id ) ) {
    $output = $post->post_excerpt;
  }
  // No custom excerpt...so lets generate one
  else {
    // Readmore link
    $readmore_link = '<a href="' . get_permalink( $post_id ) . '" class="readmore">' . $readmore_text . $readmore_after . '</a>';
    // Check for more tag and return content if it exists
    if ( ! $disable_more && strpos( $post->post_content, '<!--more-->' ) ) {
      $output = apply_filters( 'the_content', get_the_content( $readmore_text . $readmore_after ) );
    }
    // No more tag defined so generate excerpt using wp_trim_words
    else {
      // Generate excerpt
      $output = wp_trim_words( strip_shortcodes( $post->post_content ), $length );
      // Add readmore to excerpt if enabled
      if ( $readmore ) {
        $output .= apply_filters( 'credio_wpex_readmore_link', $readmore_link );
      }

    }

  }
  // Apply filters and echo
  return apply_filters( 'credio_wpex_get_excerpt', $output );
}


//Demo content file include here

function credio_import_files() {
  return array(

    array(
      'import_file_name'           => 'Credit Repair Main Demo',
      'categories'                 => array( 'Multipages', 'Credit Repair' ),
      'import_file_url'            => 'https://rstheme.com/products/demo-data/credio/data/credit-repair/credio-content.xml',
      'import_widget_file_url'     => 'https://rstheme.com/products/demo-data/credio/data/credit-repair/credio-widgets.wie',      
      'import_customizer_file_url' => 'https://rstheme.com/products/demo-data/credio/data/credit-repair/credio-customizer.dat',       
      'import_preview_image_url'   => 'https://rstheme.com/products/demo-data/credio/screens/credit-repair/screenshot.png',   
      'import_notice'              => esc_html__( 'Caution: For importing demo data please click on "Import Demo Data" button. During demo data installation please do not refresh the page.', 'credio' ),
      'preview_url'                => 'https://credio.rstheme.com/credit-repair-demo/',
    ),        

    array(
      'import_file_name'           => 'Credit Repair Onepage Demo',
      'categories'                 => array( 'Onepages', 'Credit Repair' ),
      'import_file_url'            => 'https://rstheme.com/products/demo-data/credio/data/credit-repair/credio-content.xml',
      'import_widget_file_url'     => 'https://rstheme.com/products/demo-data/credio/data/credit-repair/credio-widgets.wie',      
      'import_customizer_file_url' => 'https://rstheme.com/products/demo-data/credio/data/credit-repair/credio-customizer.dat',       
      'import_preview_image_url'   => 'https://rstheme.com/products/demo-data/credio/screens/credit-repair/screenshot.png',   
      'import_notice'              => esc_html__( 'Caution: For importing demo data please click on "Import Demo Data" button. During demo data installation please do not refresh the page.', 'credio' ),
      'preview_url'                => 'https://credio.rstheme.com/credit-repair-demo/onepage/',
    ),      

    array(
      'import_file_name'           => 'Consulting Demo',
      'categories'                 => array( 'Multipages', 'Consulting' ),
      'import_file_url'            => 'https://rstheme.com/products/demo-data/credio/data/consulting/credio-content.xml',
      'import_widget_file_url'     => 'https://rstheme.com/products/demo-data/credio/data/consulting/credio-widgets.wie',      
      'import_customizer_file_url' => 'https://rstheme.com/products/demo-data/credio/data/consulting/credio-customizer.dat',       
      'import_preview_image_url'   => 'https://rstheme.com/products/demo-data/credio/screens/consulting/screenshot.png',   
      'import_notice'              => esc_html__( 'Caution: For importing demo data please click on "Import Demo Data" button. During demo data installation please do not refresh the page.', 'credio' ),
      'preview_url'                => 'https://credio.rstheme.com/consulting/',
    ),        

    array(
      'import_file_name'           => 'Consulting Onepage Demo',
      'categories'                 => array( 'Onepages', 'Consulting' ),
      'import_file_url'            => 'https://rstheme.com/products/demo-data/credio/data/consulting/credio-content.xml',
      'import_widget_file_url'     => 'https://rstheme.com/products/demo-data/credio/data/consulting/credio-widgets.wie',      
      'import_customizer_file_url' => 'https://rstheme.com/products/demo-data/credio/data/consulting/credio-customizer.dat',       
      'import_preview_image_url'   => 'https://rstheme.com/products/demo-data/credio/screens/consulting/screenshot.png',   
      'import_notice'              => esc_html__( 'Caution: For importing demo data please click on "Import Demo Data" button. During demo data installation please do not refresh the page.', 'credio' ),
      'preview_url'                => 'https://credio.rstheme.com/consulting/onepage/',
    ),       

    array(
      'import_file_name'           => 'Finance business Demo',
      'categories'                 => array( 'Multipages', 'Finance business' ),
      'import_file_url'            => 'https://rstheme.com/products/demo-data/credio/data/finance-business/credio-content.xml',
      'import_widget_file_url'     => 'https://rstheme.com/products/demo-data/credio/data/finance-business/credio-widgets.wie',      
      'import_customizer_file_url' => 'https://rstheme.com/products/demo-data/credio/data/finance-business/credio-customizer.dat',       
      'import_preview_image_url'   => 'https://rstheme.com/products/demo-data/credio/screens/finance-business/screenshot.png',   
      'import_notice'              => esc_html__( 'Caution: For importing demo data please click on "Import Demo Data" button. During demo data installation please do not refresh the page.', 'credio' ),
      'preview_url'                => 'https://credio.rstheme.com/finance-business-demo/',
    ),        

    array(
      'import_file_name'           => 'Finance business Onepage Demo',
      'categories'                 => array( 'Onepages', 'Finance business' ),
      'import_file_url'            => 'https://rstheme.com/products/demo-data/credio/data/finance-business/credio-content.xml',
      'import_widget_file_url'     => 'https://rstheme.com/products/demo-data/credio/data/finance-business/credio-widgets.wie',      
      'import_customizer_file_url' => 'https://rstheme.com/products/demo-data/credio/data/finance-business/credio-customizer.dat',       
      'import_preview_image_url'   => 'https://rstheme.com/products/demo-data/credio/screens/finance-business/screenshot.png',   
      'import_notice'              => esc_html__( 'Caution: For importing demo data please click on "Import Demo Data" button. During demo data installation please do not refresh the page.', 'credio' ),
      'preview_url'                => 'https://credio.rstheme.com/finance-business-demo/onepage/',
    ),  

    array(
      'import_file_name'           => 'Business Demo',
      'categories'                 => array( 'Multipages', 'Business' ),
      'import_file_url'            => 'https://rstheme.com/products/demo-data/credio/data/business/credio-content.xml',
      'import_widget_file_url'     => 'https://rstheme.com/products/demo-data/credio/data/business/credio-widgets.wie',      
      'import_customizer_file_url' => 'https://rstheme.com/products/demo-data/credio/data/business/credio-customizer.dat',       
      'import_preview_image_url'   => 'https://rstheme.com/products/demo-data/credio/screens/business/screenshot.png',   
      'import_notice'              => esc_html__( 'Caution: For importing demo data please click on "Import Demo Data" button. During demo data installation please do not refresh the page.', 'credio' ),
      'preview_url'                => 'https://credio.rstheme.com/business-demo/',
    ),        

    array(
      'import_file_name'           => 'Business Onepage Demo',
      'categories'                 => array( 'Onepages', 'Business' ),
      'import_file_url'            => 'https://rstheme.com/products/demo-data/credio/data/business/credio-content.xml',
      'import_widget_file_url'     => 'https://rstheme.com/products/demo-data/credio/data/business/credio-widgets.wie',      
      'import_customizer_file_url' => 'https://rstheme.com/products/demo-data/credio/data/business/credio-customizer.dat',       
      'import_preview_image_url'   => 'https://rstheme.com/products/demo-data/credio/screens/business/screenshot.png',   
      'import_notice'              => esc_html__( 'Caution: For importing demo data please click on "Import Demo Data" button. During demo data installation please do not refresh the page.', 'credio' ),
      'preview_url'                => 'https://credio.rstheme.com/business-demo/onepage/',
    ),     

    array(
      'import_file_name'           => 'Finance Demo',
      'categories'                 => array( 'Multipages', 'Finance' ),
      'import_file_url'            => 'https://rstheme.com/products/demo-data/credio/data/finance/credio-content.xml',
      'import_widget_file_url'     => 'https://rstheme.com/products/demo-data/credio/data/finance/credio-widgets.wie',      
      'import_customizer_file_url' => 'https://rstheme.com/products/demo-data/credio/data/finance/credio-customizer.dat',       
      'import_preview_image_url'   => 'https://rstheme.com/products/demo-data/credio/screens/finance/screenshot.png',   
      'import_notice'              => esc_html__( 'Caution: For importing demo data please click on "Import Demo Data" button. During demo data installation please do not refresh the page.', 'credio' ),
      'preview_url'                => 'https://credio.rstheme.com/finance-demo/',
    ),        

    array(
      'import_file_name'           => 'Finance Onepage Demo',
      'categories'                 => array( 'Onepages', 'Finance' ),
      'import_file_url'            => 'https://rstheme.com/products/demo-data/credio/data/finance/credio-content.xml',
      'import_widget_file_url'     => 'https://rstheme.com/products/demo-data/credio/data/finance/credio-widgets.wie',      
      'import_customizer_file_url' => 'https://rstheme.com/products/demo-data/credio/data/finance/credio-customizer.dat',       
      'import_preview_image_url'   => 'https://rstheme.com/products/demo-data/credio/screens/finance/screenshot.png',   
      'import_notice'              => esc_html__( 'Caution: For importing demo data please click on "Import Demo Data" button. During demo data installation please do not refresh the page.', 'credio' ),
      'preview_url'                => 'https://credio.rstheme.com/finance-demo/onepage/',
    ),  

    array(
      'import_file_name'           => 'Credit Repair 02 Demo',
      'categories'                 => array( 'Multipages', 'Credit Repair' ),
      'import_file_url'            => 'https://rstheme.com/products/demo-data/credio/data/credit-repair-02/credio-content.xml',
      'import_widget_file_url'     => 'https://rstheme.com/products/demo-data/credio/data/credit-repair-02/credio-widgets.wie',      
      'import_customizer_file_url' => 'https://rstheme.com/products/demo-data/credio/data/credit-repair-02/credio-customizer.dat',       
      'import_preview_image_url'   => 'https://rstheme.com/products/demo-data/credio/screens/credit-repair-02/screenshot.png',   
      'import_notice'              => esc_html__( 'Caution: For importing demo data please click on "Import Demo Data" button. During demo data installation please do not refresh the page.', 'credio' ),
      'preview_url'                => 'https://credio.rstheme.com/credit-repair-demo2/',
    ),        

    array(
      'import_file_name'           => 'Credit Repair 02 Onepage',
      'categories'                 => array( 'Onepages', 'Credit Repair' ),
      'import_file_url'            => 'https://rstheme.com/products/demo-data/credio/data/credit-repair-02/credio-content.xml',
      'import_widget_file_url'     => 'https://rstheme.com/products/demo-data/credio/data/credit-repair-02/credio-widgets.wie',      
      'import_customizer_file_url' => 'https://rstheme.com/products/demo-data/credio/data/credit-repair-02/credio-customizer.dat',       
      'import_preview_image_url'   => 'https://rstheme.com/products/demo-data/credio/screens/credit-repair-02/screenshot.png',   
      'import_notice'              => esc_html__( 'Caution: For importing demo data please click on "Import Demo Data" button. During demo data installation please do not refresh the page.', 'credio' ),
      'preview_url'                => 'https://credio.rstheme.com/credit-repair-demo2/onepage/',
    ), 

    array(
      'import_file_name'           => 'FinTech Demo',
      'categories'                 => array( 'Multipages', 'FinTech' ),
      'import_file_url'            => 'https://rstheme.com/products/demo-data/credio/data/fintech/credio-content.xml',
      'import_widget_file_url'     => 'https://rstheme.com/products/demo-data/credio/data/fintech/credio-widgets.wie',      
      'import_customizer_file_url' => 'https://rstheme.com/products/demo-data/credio/data/fintech/credio-customizer.dat',       
      'import_preview_image_url'   => 'https://rstheme.com/products/demo-data/credio/screens/fintech/screenshot.png',   
      'import_notice'              => esc_html__( 'Caution: For importing demo data please click on "Import Demo Data" button. During demo data installation please do not refresh the page.', 'credio' ),
      'preview_url'                => 'https://credio.rstheme.com/fintech-demo/',
    ),        

    array(
      'import_file_name'           => 'FinTech Onepage Demo',
      'categories'                 => array( 'Onepages', 'FinTech' ),
      'import_file_url'            => 'https://rstheme.com/products/demo-data/credio/data/fintech/credio-content.xml',
      'import_widget_file_url'     => 'https://rstheme.com/products/demo-data/credio/data/fintech/credio-widgets.wie',      
      'import_customizer_file_url' => 'https://rstheme.com/products/demo-data/credio/data/fintech/credio-customizer.dat',       
      'import_preview_image_url'   => 'https://rstheme.com/products/demo-data/credio/screens/fintech/screenshot.png',   
      'import_notice'              => esc_html__( 'Caution: For importing demo data please click on "Import Demo Data" button. During demo data installation please do not refresh the page.', 'credio' ),
      'preview_url'                => 'https://credio.rstheme.com/fintech-demo/onepage/',
    ), 

    array(
      'import_file_name'           => 'Finance Consulting Demo',
      'categories'                 => array( 'Multipages', 'Finance Consulting' ),
      'import_file_url'            => 'https://rstheme.com/products/demo-data/credio/data/finance-consulting/credio-content.xml',
      'import_widget_file_url'     => 'https://rstheme.com/products/demo-data/credio/data/finance-consulting/credio-widgets.wie',      
      'import_customizer_file_url' => 'https://rstheme.com/products/demo-data/credio/data/finance-consulting/credio-customizer.dat',       
      'import_preview_image_url'   => 'https://rstheme.com/products/demo-data/credio/screens/finance-consulting/screenshot.png',   
      'import_notice'              => esc_html__( 'Caution: For importing demo data please click on "Import Demo Data" button. During demo data installation please do not refresh the page.', 'credio' ),
      'preview_url'                => 'https://credio.rstheme.com/finance-consulting-demo/',
    ),        

    array(
      'import_file_name'           => 'Finance Consulting Onepage Demo',
      'categories'                 => array( 'Onepages', 'Finance Consulting' ),
      'import_file_url'            => 'https://rstheme.com/products/demo-data/credio/data/finance-consulting/credio-content.xml',
      'import_widget_file_url'     => 'https://rstheme.com/products/demo-data/credio/data/finance-consulting/credio-widgets.wie',      
      'import_customizer_file_url' => 'https://rstheme.com/products/demo-data/credio/data/finance-consulting/credio-customizer.dat',       
      'import_preview_image_url'   => 'https://rstheme.com/products/demo-data/credio/screens/finance-consulting/screenshot.png',   
      'import_notice'              => esc_html__( 'Caution: For importing demo data please click on "Import Demo Data" button. During demo data installation please do not refresh the page.', 'credio' ),
      'preview_url'                => 'https://credio.rstheme.com/finance-consulting-demo/onepage/',
    ),   


    array(
      'import_file_name'           => 'RTL Demo',
      'categories'                 => array( 'RTL Demo' ),
      'import_file_url'            => 'https://rstheme.com/products/demo-data/credio/data/rtl/credio-content.xml',
      'import_widget_file_url'     => 'https://rstheme.com/products/demo-data/credio/data/rtl/credio-widgets.wie',      
      'import_customizer_file_url' => 'https://rstheme.com/products/demo-data/credio/data/rtl/credio-customizer.dat',       
      'import_preview_image_url'   => 'https://rstheme.com/products/demo-data/credio/screens/rtl/screen.png',   
      'import_notice'              => esc_html__( 'Caution: For importing demo data please click on "Import Demo Data" button. During demo data installation please do not refresh the page.', 'credio' ),
      'preview_url'                => 'https://demo.rstheme.com/wordpress/credio/',
    ),    

   
    
  );
}

add_filter( 'pt-ocdi/import_files', 'credio_import_files' );


function credio_set_import_id(){
    if(isset( $_GET['import'] )) {
        $import_demo_id =(int) $_GET['import'];
        unset($_COOKIE['import_id']);
        if(!isset($_COOKIE['import_id'])) {
            setcookie('import_id', $import_demo_id, time()+3600); 
        }  
    }
}  

add_action( 'init', 'credio_set_import_id');


function credio_after_import_setup() {
  // Assign menus to their locations.
    $main_menu       = get_term_by( 'name', 'Main Menu', 'nav_menu' ); 
    $mobile_menu     = get_term_by( 'name', 'Responsive Menu', 'nav_menu' ); 
    $single_menu     = get_term_by( 'name', 'Onepage Menu', 'nav_menu' ); 

    set_theme_mod( 'nav_menu_locations', array(
          'menu-1' => $main_menu->term_id,        
          'menu-2' => $mobile_menu->term_id,        
          'menu-3' => $single_menu->term_id        
        )
    );


    if(isset($_COOKIE['import_id'])) {

        $selected= (int)$_COOKIE['import_id'];

        if($selected==0 || $selected==2 || $selected==4 || $selected==6 || $selected==8 || $selected==10 || $selected==12 || $selected==14 || $selected==16){
            $front_page_id = get_page_by_title( 'Home' ); 
        } else{
            $front_page_id = get_page_by_title( 'Onepage' ); 
        }

        $blog_page_id  = get_page_by_title( 'Blog' );

        update_option( 'show_on_front', 'page' );
        update_option( 'page_on_front', $front_page_id->ID );
        update_option( 'page_for_posts', $blog_page_id->ID );


        if(class_exists('RevSlider'))
        {
            if($selected==6 || $selected==7) {
                $slider = new RevSlider();
                ob_start();
                $slider->importSliderFromPost(true, true, get_template_directory()."/ocdi/sliders/business.zip");
                ob_get_clean();
            }  

            if($selected==14 || $selected==15) {
                $slider = new RevSlider();
                ob_start();
                $slider->importSliderFromPost(true, true, get_template_directory()."/ocdi/sliders/oil-gas.zip");
                ob_get_clean();
            }  

            if($selected==16) {
                $slider = new RevSlider();
                ob_start();
                $slider->importSliderFromPost(true, true, get_template_directory()."/ocdi/sliders/business-rtl.zip");
                $slider->importSliderFromPost(true, true, get_template_directory()."/ocdi/sliders/slider-rtl-1.zip");
                ob_get_clean();
            }               
           
        }

        if($selected==0 || $selected==1) {
            $import_kit_zip = get_parent_theme_file_path() . '/ocdi/kits/credit-repair/elementor-kit.zip';
            $import_export_module        = \Elementor\Plugin::$instance->app->get_component( 'import-export' );
            $import_settings['referrer'] = 'remote';
            $import_export_module->import_kit( $import_kit_zip, $import_settings );
        }

        if($selected==2 || $selected==3) {
            $import_kit_zip = get_parent_theme_file_path() . '/ocdi/kits/consulting/elementor-kit.zip';
            $import_export_module        = \Elementor\Plugin::$instance->app->get_component( 'import-export' );
            $import_settings['referrer'] = 'remote';
            $import_export_module->import_kit( $import_kit_zip, $import_settings );
        }

        if($selected==4 || $selected==5) {
            $import_kit_zip = get_parent_theme_file_path() . '/ocdi/kits/finance-business/elementor-kit.zip';
            $import_export_module        = \Elementor\Plugin::$instance->app->get_component( 'import-export' );
            $import_settings['referrer'] = 'remote';
            $import_export_module->import_kit( $import_kit_zip, $import_settings );
        }

        if($selected==6 || $selected==7) {
            $import_kit_zip = get_parent_theme_file_path() . '/ocdi/kits/business/elementor-kit.zip';
            $import_export_module        = \Elementor\Plugin::$instance->app->get_component( 'import-export' );
            $import_settings['referrer'] = 'remote';
            $import_export_module->import_kit( $import_kit_zip, $import_settings );
        }

        if($selected==8 || $selected==9) {
            $import_kit_zip = get_parent_theme_file_path() . '/ocdi/kits/finance/elementor-kit.zip';
            $import_export_module        = \Elementor\Plugin::$instance->app->get_component( 'import-export' );
            $import_settings['referrer'] = 'remote';
            $import_export_module->import_kit( $import_kit_zip, $import_settings );
        }        

        if($selected==10 || $selected==11) {
            $import_kit_zip = get_parent_theme_file_path() . '/ocdi/kits/credit-repair-02/elementor-kit.zip';
            $import_export_module        = \Elementor\Plugin::$instance->app->get_component( 'import-export' );
            $import_settings['referrer'] = 'remote';
            $import_export_module->import_kit( $import_kit_zip, $import_settings );
        }        

        if($selected==12 || $selected==13) {
            $import_kit_zip = get_parent_theme_file_path() . '/ocdi/fintech/elementor-kit.zip';
            $import_export_module        = \Elementor\Plugin::$instance->app->get_component( 'import-export' );
            $import_settings['referrer'] = 'remote';
            $import_export_module->import_kit( $import_kit_zip, $import_settings );
        }        

        if($selected==14 || $selected==15) {
            $import_kit_zip = get_parent_theme_file_path() . '/ocdi/finance-consulting/elementor-kit.zip';
            $import_export_module        = \Elementor\Plugin::$instance->app->get_component( 'import-export' );
            $import_settings['referrer'] = 'remote';
            $import_export_module->import_kit( $import_kit_zip, $import_settings );
        }        

        if($selected==16) {
            $import_kit_zip = get_parent_theme_file_path() . '/ocdi/kits/rtl/elementor-kit.zip';
            $import_export_module        = \Elementor\Plugin::$instance->app->get_component( 'import-export' );
            $import_settings['referrer'] = 'remote';
            $import_export_module->import_kit( $import_kit_zip, $import_settings );
        }

    }
    unset($_COOKIE['import_id']);

}
add_action( 'pt-ocdi/after_import', 'credio_after_import_setup' );


// Disables the block editor from managing widgets in the Gutenberg plugin.
add_filter( 'gutenberg_use_widgets_block_editor', '__return_false' );
// Disables the block editor from managing widgets.
add_filter( 'use_widgets_block_editor', '__return_false' );


/**
 * Mega Menu
 */
add_action('wp_nav_menu_item_custom_fields', function($item_id, $item) {
  $show_rs_mega_class = get_post_meta($item_id, '_show-credio-as-mega', true);
  ?>
    <p class="credio-show-as-button description description-wide">
        <label for="credio-menu-item-btns-<?php echo esc_attr ($item_id); ?>" >
          <input type="checkbox" 
            id="credio-menu-item-btns-<?php echo esc_attr ($item_id); ?>" 
            name="credio-menu-item-btns[<?php echo esc_attr ($item_id); ?>]" 
            <?php checked($show_rs_mega_class, true); ?> 
          /><?php echo esc_html__('Check Mega Menu', 'credio'); ?>
        </label>
    </p>
  <?php
}, 10, 2);

add_action('wp_update_nav_menu_item', function($menu_id, $credio_menu_item_db_id) {
  $credio_button_value = (isset($_POST['credio-menu-item-btns'][$credio_menu_item_db_id]) && $_POST['credio-menu-item-btns'][$credio_menu_item_db_id] === 'on') ? true : false;
  update_post_meta($credio_menu_item_db_id, '_show-credio-as-mega', $credio_button_value);
}, 10, 2);

add_filter('nav_menu_css_class', function($classes, $menu_item) {
    $show_rs_mega_class = get_post_meta($menu_item->ID, '_show-credio-as-mega', true);
    if ($show_rs_mega_class) {
        $classes[] = 'rs-mega-menu';
    }
    return $classes;
}, 10, 2);

//disable elementor default styles
update_option('elementor_disable_color_schemes', 'yes');
update_option('elementor_disable_typography_schemes', 'yes');

//Check Custom Post Types in Elementor Setting
function credio_custom_post_type_elementor_support() {
    // Custom post types you want to enable Elementor for
    $post_types = ['post', 'page', 'teams', 'testimonials', 'events', 'portfolios', 'elementor-rshf']; // Replace with your CPT slugs
    $existing_support = get_option('elementor_cpt_support', []);
    $merged = array_unique(array_merge($existing_support, $post_types));
    sort($merged);
    if ($merged !== $existing_support) {
        update_option('elementor_cpt_support', $merged);
    }
}
add_action( 'init', 'credio_custom_post_type_elementor_support' );


$licenseKey  = get_option("CredioWordPressTheme_lic_Key","");
if(empty($licenseKey)) :
    add_action( 'admin_notices', 'credio_admin_notice__success');
    function credio_admin_notice__success() {?>
        <div class="credio-notice notice notice-theme is-dismissible">
            <div class="credio-notice-intro">The Credio Theme must need to activate the purchase code. Without activation you will miss more features of the theme.  <a href="<?php echo esc_url(get_admin_url())?>/admin.php?page=credio">Active Now!</a></div>
        </div>
        <?php 
    } 
endif;