-
AuthorPosts
-
April 4, 2017 at 11:10 am #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
April 5, 2017 at 8:00 am #772283Hey Jens,
What changes did you do to the file in question? Please try to be as specific as possible.
Best regards,
RikardApril 5, 2017 at 8:22 am #772299Hi 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,
JensApril 9, 2017 at 8:56 pm #775112Hi,
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,
VinayApril 10, 2017 at 12:31 pm #775399Hi Vinay,
that’s it! Thanks a lot!
Best regards,
JensApril 11, 2017 at 6:40 am #775818 -
AuthorPosts
- You must be logged in to reply to this topic.