Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #829409
    kisschicken
    Participant

    I’ve added the following script to the appearance < custom < javascript to activate a localized accounting library but it keeps spitting out an “accounting not defined” error in the console.

    <script src=”/wp-content/themes/x-child/accounting.js”></script>

    <script type=”text/javascript”>
    // Library ready to use:
    accounting.formatMoney(5318008);
    </script>

    Any ideas? My site is https://pristineio.staging.wpengine.com.

    The js library is here: http://openexchangerates.github.io/accounting.js/#instructions

    #829842
    Zeshan
    Member

    Hi there,

    Thanks for writing in!

    You cannot add HTML script tags in “Custom > JavaScript” in the Customizer. Instead, in order to add this in your site, I’d advise that you setup a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.

    After that, add following code in your child theme’s functions.php file:

    // Adding Scripts Below <body> tag of the page
    // =============================================================================
    
    function scripts_inside_body() { ?>
      <script src="path/to/accounting.js"></script>
    
      <script type="text/javascript">
        // Library ready to use:
        accounting.formatMoney(5318008);
      </script>
    <?php }
    
    add_action('x_before_site_begin', 'scripts_inside_body');
    

    Thank you!

  • <script> jQuery(function($){ $("#no-reply-829409 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>