Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #771653

    Hi,

    I’m using a child theme of the enfold theme. I modified the file ‘avia.js’ and put it into the child-themes js-folder. And of course, I modified the functions.php as it is described many times here in the forum.

    But if I do these changes, I can’t switch between the visual and the text editor (for posts or pages). And in the text editor there are no tools-buttons displayed anymore. If I undo these changes, everything works fine again.
    Because I need to switch between the two editors sometimes, the use of the modified avia.js in the child theme is not possible at the moment. But that’s not the solution …

    Does anyone know how to handle this problem?

    Regards, Jens

    #772283

    Hey Jens,

    What changes did you do to the file in question? Please try to be as specific as possible.

    Best regards,
    Rikard

    #772299

    Hi Rikard,

    I added the following code in the avia.js file at the bottom:

    jQuery(".home article.iconbox").each(function(){ 
        var theLink = jQuery(this).find("a").attr("href");
    	jQuery(this).on("click", function(){
    		window.location.href = theLink;
    	});
    })

    Here a link to the modified file: https://www.kirche-mswest.de/wp-content/themes/enfold-child/enfold-child/js/avia.js

    With every larger update of the theme I replaceds the file in the child-theme folder with the new version and added the code at the bottom. But some time ago the problem, told above, appeared and I figured out, that it correlates with the use of the avia.js in the child theme.

    For the use of the avia.js file in the child theme I used the following code in the functions.php:

    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 );

    Actually I’ve disabled this code in the functions.php and I use the avia.js file from the original theme folder without my own modification.

    I’d appreciate any help.

    Thanks and regards,
    Jens

    #775112

    Hi,

    You do not have to modify the avia.js file or even add it to the child theme.

    jQuery snippets can be added as custom functions in the child theme to functions.php file that comes with the child theme.

    Please try adding this at the very end of your themes / child themes functions.php file:

    /*----------------------------------------
    // Custom function
    //--------------------------------------*/
    
    function iconboxLink(){
    ?>
    <script>
     jQuery(document).ready(function() {              
          jQuery(".home article.iconbox").each(function(){ 
        var theLink = jQuery(this).find("a").attr("href");
    	jQuery(this).on("click", function(){
    		window.location.href = theLink;
    	});
    	})
     });          
    </script>
    <?php
    }
    add_action('wp_footer', 'iconboxLink');

    Best regards,
    Vinay

    #775399

    Hi Vinay,

    that’s it! Thanks a lot!

    Best regards,
    Jens

    #775818

    Hi Jens,

    Great, glad we could help. Please let us know if you should need any further help on the topic or if we can close it.

    Best regards,
    Rikard

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