Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'wp_enqueue_scripts', 'dequeue_and_then_enqueue', 60 );
- function dequeue_and_then_enqueue() {
- // unload parent theme frontend
- wp_deregister_script( 'rubenz-components' );
- wp_dequeue_script( 'rubenz-components' );
- $enable_ajax = get_theme_mod( 'enable_ajax', false );
- $gmap = get_option( 'arts_gmap' );
- $main_script_deps = array( 'modernizr', 'jquery', 'isotope', 'imagesloaded' );
- $main_script_version = wp_get_theme()->get( 'Version' );
- $ajax_load_missing_scripts = get_theme_mod( 'ajax_load_missing_scripts', false );
- // Force load Google Maps script
- // on all the pages with AJAX turned on
- if ( $enable_ajax && ! $ajax_load_missing_scripts && isset( $gmap['key'] ) && ! empty( $gmap['key'] ) ) {
- wp_enqueue_script( 'googlemap', '//maps.googleapis.com/maps/api/js?key=' . $gmap['key'], array(), null, true );
- $main_script_deps [] = 'googlemap';
- }
- // Force load Elementor assets
- // on non-Elementor pages with AJAX turned on
- if ( class_exists( '\Elementor\Frontend' ) && ! arts_is_built_with_elementor() && $enable_ajax ) {
- \Elementor\Frontend::instance()->enqueue_scripts();
- }
- if ( $enable_ajax ) {
- wp_enqueue_script( 'barba', ARTS_THEME_URL . '/js/barba.umd.min.js', array( 'jquery' ), '2.0.0', true );
- $main_script_deps [] = 'barba';
- }
- if ( ! arts_is_elementor_feature_active( 'e_optimized_assets_loading' ) || arts_is_blog_page() ) {
- wp_enqueue_script( 'swiper', ARTS_THEME_URL . '/js/swiper.min.js', array( 'jquery' ), '4.4.1', true );
- $main_script_deps [] = 'swiper';
- }
- // load child theme custom frontend from /rubenz-child/js/components.js
- wp_enqueue_script( 'rubenz-components', get_stylesheet_directory_uri() . '/js/components.js', $main_script_deps, $main_script_version, true );
- }
Add Comment
Please, Sign In to add comment