File: /mnt/data/dev/dev-dreamstour-wp/wp-content/themes/dreamstour/inc/add_js_css.php
<?php
add_action('wp_enqueue_scripts', 'dreamstour_theme_scripts_styles');
add_action( 'wp_print_scripts', 'dreamstour_dequeue_stylesandscripts_select2', 100 );
// Enqueue Google Fonts
function dreamstour_enqueue_google_fonts() {
wp_enqueue_style(
'dreamstour-google-fonts',
'https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@100;400;500;600;700&display=swap',
array(),
null
);
}
add_action('wp_enqueue_scripts', 'dreamstour_enqueue_google_fonts');
function dreamstour_theme_scripts_styles() {
/* Google Font */
wp_enqueue_style( 'dreamstour_fonts', dreamstour_customize_google_fonts(), array(), null );
// enqueue the javascript that performs in-link comment reply fanciness
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
/* Bootstrap Core JS */
wp_enqueue_script('bootstrap-new', DREAMSTOUR_URI.'/assets/js/bootstrap.bundle.min.js', array('jquery'),null,true);
wp_enqueue_script('wow', DREAMSTOUR_URI.'/assets/js/wow.min.js', array('jquery'),null,true);
wp_enqueue_script('meanmenu', DREAMSTOUR_URI.'/assets/js/jquery.meanmenu.min.js', array('jquery'),null,true);
/* Owl Carousel JS */
wp_enqueue_script('owl-carousel', DREAMSTOUR_URI.'/assets/plugins/owlcarousel/owl.carousel.min.js', array('jquery'),null,true);
wp_enqueue_script('resizesensor', DREAMSTOUR_URI.'/assets/plugins/theia-sticky-sidebar/ResizeSensor.js', array('jquery'),null,true);
wp_enqueue_script('theia-sticky-sidebar', DREAMSTOUR_URI.'/assets/plugins/theia-sticky-sidebar/theia-sticky-sidebar.js', array('jquery'),null,true);
/* Fancybox JS */
wp_enqueue_script('fancybox', DREAMSTOUR_URI.'/assets/plugins/fancybox/jquery.fancybox.min.js', array('jquery'),null,true);
wp_enqueue_script('theme-slick', DREAMSTOUR_URI.'/assets/plugins/slick/slick.min.js', array('jquery'),null,true);
/*counterup JS*/
wp_enqueue_script('counterup', DREAMSTOUR_URI.'/assets/js/jquery.counterup.min.js', array('jquery'),null,true);
wp_enqueue_script('waypoints', DREAMSTOUR_URI.'/assets/js/jquery.waypoints.min.js', array('jquery'),null,true);
wp_enqueue_script('moment', DREAMSTOUR_URI.'/assets/plugins/moment/moment.js', array('jquery'),null,true);
wp_enqueue_script('bootstrap-datetimepicker', DREAMSTOUR_URI.'/assets/js/bootstrap-datetimepicker.min.js', array('jquery'),null,true);
wp_enqueue_script('theme-select2', DREAMSTOUR_URI.'/assets/plugins/select2/js/select2.min.js', array('jquery'),null,true);
wp_enqueue_script('cursor', DREAMSTOUR_URI.'/assets/js/cursor.js', array('jquery'),null,true);
/* Custom Script JS */
if(is_rtl( )){
wp_enqueue_script('dreamstour_script-rtl', DREAMSTOUR_URI.'/assets/js/script-rtl.js', array('jquery'),null,true);
}
wp_enqueue_script('dreamstour_script', DREAMSTOUR_URI.'/assets/js/script.js', array('jquery'),null,true);
wp_enqueue_style('animate', DREAMSTOUR_URI.'/assets/css/animate.css', array(), null);
if(is_rtl( )){
wp_enqueue_style('bootstrap-rtl', DREAMSTOUR_URI.'/assets/css/bootstrap.rtl.min.css', array(), null);
}
wp_enqueue_style('bootstrap', DREAMSTOUR_URI.'/assets/css/bootstrap.min.css', array(), null);
/*Datepicker CSS */
wp_enqueue_style('bootstrap-datetimepicker', DREAMSTOUR_URI.'/assets/css/bootstrap-datetimepicker.min.css', array(), null);
/* Menu CSS */
wp_enqueue_style('meanmenu', DREAMSTOUR_URI.'/assets/css/meanmenu.css', array(), null);
/* Tabler Icon CSS */
wp_enqueue_style('tabler-icons', DREAMSTOUR_URI.'/assets/plugins/tabler-icons/tabler-icons.css', array(), null);
/*Fontawesome Icon CSS */
wp_enqueue_style('fontawesome', DREAMSTOUR_URI.'/assets/plugins/fontawesome/css/fontawesome.min.css', array(), null);
wp_enqueue_style('fontawesomeallmin', DREAMSTOUR_URI.'/assets/plugins/fontawesome/css/all.min.css', array(), null);
/*Fancybox Css */
wp_enqueue_style('fancybox', DREAMSTOUR_URI.'/assets/plugins/fancybox/jquery.fancybox.min.css', array(), null);
/* Owl carousel CSS */
wp_enqueue_style('owl-carousel', DREAMSTOUR_URI.'/assets/plugins/owlcarousel/owl.carousel.min.css', array(), null);
wp_enqueue_style('theme-slick', DREAMSTOUR_URI.'/assets/plugins/slick/slick.css', array(), null);
wp_enqueue_style('select2', DREAMSTOUR_URI.'/assets/plugins/select2/css/select2.min.css', array(), null);
/*Iconsax CSS */
wp_enqueue_style('iconsax', DREAMSTOUR_URI.'/assets/css/iconsax.css', array(), null);
/* Main CSS */
wp_enqueue_style('dreamstour-woocommerce', DREAMSTOUR_URI.'/assets/css/theme-woocommerce.css', array(), null);
wp_enqueue_style('dreamstour-default', DREAMSTOUR_URI.'/assets/css/theme-default.css', array(), null);
if(is_rtl( )){
wp_enqueue_style('dreamstour-theme-rtl', DREAMSTOUR_URI.'/assets/css/style-rtl.css', array(), null);
}
wp_enqueue_style('dreamstour-theme', DREAMSTOUR_URI.'/assets/css/style.css', array(), null);
wp_enqueue_style('dreamstour-custom', DREAMSTOUR_URI.'/assets/css/custom.css', array(), null);
wp_enqueue_style('dreamstour-custom2', DREAMSTOUR_URI.'/assets/css/custom2.css', array(), null);
if ( is_child_theme() ) {
wp_enqueue_style( 'parent_style', trailingslashit( get_template_directory_uri() ) . 'style.css', array(), null );
}
wp_enqueue_style( 'dreamstour_style', get_stylesheet_uri(), array(), null );
$custom_css = dreamstour_add_dynamic_styles();
wp_add_inline_style('dreamstour_style', $custom_css);
}
function dreamstour_enqueue_scripts() {
// Enqueue your main theme script
wp_enqueue_script(
'dreamstourtheme_script',
DREAMSTOUR_URI . '/assets/js/theme-script.js',
array('jquery'),
null,
true
);
// Localize (pass PHP data to JS)
wp_localize_script(
'dreamstourtheme_script',
'dreamstour_ajax_obj',
array(
'ajax_url' => admin_url('admin-ajax.php'),
'nonce' => wp_create_nonce('dreamstour_ajax_nonce'),
)
);
}
add_action('wp_enqueue_scripts', 'dreamstour_enqueue_scripts');
function dreamstour_dequeue_stylesandscripts_select2() {
if ( class_exists( 'woocommerce' ) ) {
wp_dequeue_style( 'select2' );
wp_deregister_style( 'select2' );
wp_dequeue_script( 'select2');
///wp_deregister_script('select2');
}
}
/* Google Font */
function dreamstour_customize_google_fonts() {
$fonts_url = '';
$body_font = get_theme_mod('body_font', 'Poppins');
$heading_font = get_theme_mod('heading_font', 'Teko');
$body_font_c = esc_html( 'on', $body_font.': on or off' );
$heading_font_c = esc_html( 'on', $heading_font.': on or off' );
if ( 'off' !== $body_font_c || 'off' !== $heading_font_c ) {
$font_families = array();
if ( 'off' !== $body_font_c && strpos($body_font,'dreamstourtheme_') === false ) {
$font_families[] = $body_font.':100,200,300,400,500,600,700,800,900"';
}
if ( 'off' !== $heading_font_c && strpos($heading_font,'dreamstourtheme_') === false ) {
$font_families[] = $heading_font.':100,200,300,400,500,600,700,800,900';
}
if($font_families != null){
$query_args = array(
'family' => urlencode( implode( '|', $font_families ) ),
'subset' => urlencode( 'latin,latin-ext' ),
);
$fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
}
}
return esc_url_raw( $fonts_url );
}
/************************************************************************************************/
/************************************************************************************************/
function dreamstour_hex2rgb($hex) {
$hex = str_replace("#", "", $hex);
if(strlen($hex) == 3) {
$r = hexdec(substr($hex,0,1).substr($hex,0,1));
$g = hexdec(substr($hex,1,1).substr($hex,1,1));
$b = hexdec(substr($hex,2,1).substr($hex,2,1));
} else {
$r = hexdec(substr($hex,0,2));
$g = hexdec(substr($hex,2,2));
$b = hexdec(substr($hex,4,2));
}
$rgb = array($r, $g, $b);
return $rgb; // returns an array with the rgb values
}