File: /var/www/hbkconsultan_usr/data/www/hbkconsultancy.com/wp-content/themes/edubin/functions.php
<?php
/**
* Theme functions and definitions
*
* @package Edubin
*/
define('EDUBIN_DIR', trailingslashit(get_template_directory()));
define('EDUBIN_URI', trailingslashit(get_template_directory_uri()));
define( 'EDUBIN_THEME_VERSION', wp_get_theme()->get( 'Version') );
if ( ! defined( 'LP_COURSE_CPT' ) ) define( 'LP_COURSE_CPT', 'lp_course' );
/**
* Load Theme Dependencies
*/
require_once get_theme_file_path('/inc/theme-dependencies.php');
/*
* All elementor header
* return array
*/
function tpc_edubin_get_elementor_header($post_type = 'eb_header')
{
$options = array();
$options = ['0' => esc_html__('None', 'edubin-core')];
$wh_post = array('posts_per_page' => -1, 'post_type' => $post_type);
$wh_post_terms = get_posts($wh_post);
if (!empty($wh_post_terms) && !is_wp_error($wh_post_terms)) {
foreach ($wh_post_terms as $term) {
$options[$term->ID] = $term->post_title;
}
return $options;
}
}
/*
* All elementor footer
* return array
*/
function tpc_edubin_get_elementor_footer($post_type = 'eb_footer')
{
$options = array();
$options = ['0' => esc_html__('None', 'edubin-core')];
$wh_post = array('posts_per_page' => -1, 'post_type' => $post_type);
$wh_post_terms = get_posts($wh_post);
if (!empty($wh_post_terms) && !is_wp_error($wh_post_terms)) {
foreach ($wh_post_terms as $term) {
$options[$term->ID] = $term->post_title;
}
return $options;
}
}
add_action( 'wp_enqueue_scripts', 'enqueue_scripts_for_elementor_header' );
function enqueue_scripts_for_elementor_header() {
$header_slug = get_post_meta( get_the_ID(), '_edubin_tpc_mb_elementor_header', true );
if ( $post = get_page_by_path( $header_slug, OBJECT, 'eb_header' ) ) :
$header_id = $post->ID;
else:
$header_id = 0;
endif;
$footer_slug = get_post_meta( get_the_ID(), '_edubin_mb_elementor_footer', true );
if ( $post = get_page_by_path( $footer_slug, OBJECT, 'eb_footer' ) ) :
$footer_id = $post->ID;
else:
$footer_id = 0;
endif;
if ( $header_id || $footer_id ) {
if ( class_exists( '\Elementor\Core\Files\CSS\Post' ) ) {
$css_file = new \Elementor\Core\Files\CSS\Post( $header_id );
} elseif ( class_exists( '\Elementor\Post_CSS_File' ) ) {
$css_file = new \Elementor\Post_CSS_File( $header_id );
} elseif ( class_exists( '\Elementor\Post_CSS_File' ) ) {
$css_file = new \Elementor\Post_CSS_File( $footer_id );
} elseif ( class_exists( '\Elementor\Post_CSS_File' ) ) {
$css_file = new \Elementor\Post_CSS_File( $footer_id );
}
$css_file->enqueue();
}
}
if ( ! function_exists( 'edubin_masterstudy_course_class' ) ) :
function edubin_masterstudy_course_class( $default = array() ) {
$terms = get_the_terms( get_the_ID(), 'stm_lms_course_taxonomy' );
$terms_html = array();
if ( $terms ) :
foreach ( $terms as $term ) :
$terms_html[] = $term->slug;
endforeach;
endif;
$ams_classes = array_merge( $terms_html, $default );
$classes = apply_filters( 'edubin_masterstudy_course_class', $ams_classes );
post_class( $classes );
}
endif;