Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #632484

    OK, so trying to edit avia.js – I’ve added to child theme in /js folder, and added this code to functions.php to make it include:
    https://kriesi.at/support/topic/use-avia-js-in-child-theme/

    Doesn’t seem to be working right though – in Chrome inspector ‘resources’ I see two avia.js being loaded now – the old one and the new one. The old one seems to be overwriting my edits!

    What I’m trying to achieve is to stop mobile scrolling to top on menu tap (thread is here – https://kriesi.at/support/topic/advanced-menu-toggle-on-desktop-seems-to-be-an-anchor-tag/#post-626159)
    … it’s one tiny edit to the js file.

    I have no idea about PHP syntax, so I have a feeling the functions.php is not working properly – can you take a look?

    <?php
    
    /*
    * Add your own functions here. You can also copy some of the theme functions into this file. 
    * WordPress will use those functions instead of the original functions then.
    */
    
    /* Register frontend javascripts */
    
    if(!is_admin())
    {
    	add_action('wp_enqueue_scripts', 'avia_register_child_frontend_scripts', 100);
    }
    
    function avia_register_child_frontend_scripts()
    {
    	$child_theme_url = get_stylesheet_directory_uri();
    
    	//register js
    	wp_register_script( 'avia-default-child', $child_theme_url.'/js/avia.js', array('jquery'), 1, false );
    	wp_enqueue_script( 'avia-default-child' );
    }
    
    // STOP SCROLL TO TOP ON MOBILE MENU
    function removeScrollToTop(){
    ?>
    <script>
         jQuery(document).scroll(function() {     
            jQuery("#advanced_menu_toggle").removeAttr("href");     
            jQuery("#advanced_menu_hide").removeAttr("href");        
        });
    </script>
    <?php
    }
    add_action('wp_head', 'removeScrollToTop');
    
    // INCLUDE OTHER CUSTOM FILES
    add_filter('avia_load_shortcodes', 'avia_include_shortcode_template', 15, 1);
    function avia_include_shortcode_template($paths)
    {
    	$template_url = get_stylesheet_directory();
        	array_unshift($paths, $template_url.'/shortcodes/');
    
    	return $paths;
    }
    
    // hide logo
    add_filter('avf_logo_subtext', 'kriesi_logo_addition');
    function kriesi_logo_addition($sub) {
        $sub .= "Bill Tribble";
        return $sub;
    }
    
    //set builder mode to debug
    add_action('avia_builder_mode', "builder_set_debug");
    function builder_set_debug()
    {
    	return "debug";
    }
    
    // TURN ON CUSTOM CLASSES
    add_theme_support('avia_template_builder_custom_css');
    
    // CHANGE MOBILE MENU ICON
    add_filter('avf_default_icons', function($icons) {
    	$icons['mobile_menu'] = array( 'font' =>'entypo-fontello', 'icon' => 'ue811');
    	return $icons;	
    }, 10, 1);
    
    add_filter('avf_portfolio_cpt_args','avia_add_portfolio_revision', 10, 1);
    function avia_add_portfolio_revision($args)
    {
      $args['supports'] = array('title','thumbnail','excerpt','editor','comments','revisions');
      return $args;
    }
    
    // PAUSE VIDEOS WHEN NOT IN VIEW
    wp_enqueue_script( 'isInViewport', get_bloginfo( 'stylesheet_directory' ) . '/js/isInViewport.js', array( 'jquery' ), CHILD_THEME_VERSION );
    
    // EDIT PASSWORD FORM TEXT
    
    function my_password_form() {
        global $post;
        $label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
        $o = '<div class="center-text"><form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" method="post">
        <p>
            ' . __( "Sorry, but this project is protected by a Non Disclosure Agreement (NDA). You'll need a password to see the case study - please " ) . '<a href="http://www.btribble.dev#contact">' . __("contact me" ) . '</a>' . __(" for&nbsp;access." ) . '
        </p>
        <label for="' . $label . '">' . __( "Password:" ) . ' </label><input name="post_password" id="' . $label . '" type="password" size="20" maxlength="20" /><input type="submit" name="Submit" value="' . esc_attr__( "Submit" ) . '" />
        </form></div>
        ';
        return $o;
    }
    add_filter( 'the_password_form', 'my_password_form' );
    ?>
    

    Any suggestions on how to fix this welcome! My aim is to stop the mobile menu scrolling to top when tapped.

    Thanks!

    • This topic was modified 8 years, 7 months ago by jomtones.
    #633526

    Hey jomtones,

    Thank you for using Enfold.

    Please replace the code with the following:

    function wp_change_aviajs() {
       wp_dequeue_script( 'avia-default' );
       wp_enqueue_script( 'avia-default-child', get_stylesheet_directory_uri().'/js/avia.js', array('jquery'), 2, true );
    }
    add_action( 'wp_print_scripts', 'wp_change_aviajs', 100 );

    Note that this modification isn’t update proof because you’re just relocating the current version of avia.js file in the child theme.

    Best regards,
    Ismael

    #636459

    Hi Ismael – thanks for this, but is there any update proof way to do this? Bit wary of making a modification I’d have to re-fix every time I update.

    #636460

    Also can you give me a tip as to where to add the code?

    Trying to add it to the above pasted code, but it doesn’t seem to be running – appears in theme header. Many thanks!

    #636790

    Hi,

    Does it works if you edit the file in the parent theme?

    Best regards,
    Josue

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.