General Ajax help: call breaks scripts for artwork and gallery

My radio station's theme, Vice, came with Ajax functionality to enable a site-wide audio player. Unfortunately, this is causing a few problems that I need help with.
1. The following scripts do not load when returning to the homepage via Ajax call
<script src="https://public.radio.co/embed/s510dd57df/artwork.js"></script>
<script src="https://public.radio.co/embed/s510dd57df/song.js"></script>
These scripts load album art and current track information near the top of the home page. I need them to always load on the homepage.
The scripts are located in "Dashboard > Modules > Home"

2. The same problem happens with the plug-in I am using for my Show Archive gallery. The Plug-in is called WP Masonry and is loaded via shortcode. The shortcode is located at "Dashboard > Modules > Show Archive"

3. I wanted 3 main menu options on every page, so I added the relevant links to header.php. This includes them on every page, but also means that they are not loaded via Ajax. How can I have them load via Ajax, so the audio player is not interrupted?

Thank you!

  • Adam Czajczyk

    Hello Eric,

    I hope you're well today and thank you for your question!

    I tried to visit your site to see how it works and check for issues that you described but it seems to be down currently. All I get is this 404 error:

    {"errors":[{"code":404,"message":"HTTP: "}]}

    Are you making any changes to your site or have you taken it down so it's not publicly available? Could you please take care of that and let me know when I can visit the site?

    Best regards,
    Adam

  • Dimitris

    Hey there Eric,

    hope you're doing good and sorry for the late reply here!

    I was able to access the backend of your website (which also should be visible by now in your hub page also https://premium.wpmudev.org/hub/my-websites/) and inspected its setup.

    1. I can see that you simply use some script tag inside post content. We may try couple of alternatives here that may surpass this, however it's not sure that is going to work with your theme:

    a. Use default WP way to enqueue scripts https://premium.wpmudev.org/blog/adding-scripts-and-styles-wordpress-enqueueing/
    For that you can use a snippet like the following in functions.php file of your child theme.

    add_action('wp_enqueue_scripts', 'my_assets');
    function my_assets() {
      wp_enqueue_script( 'radio-artwork', 'https://public.radio.co/embed/s510dd57df/artwork.js', array('jquery') );
      wp_enqueue_script( 'radio-songs', 'https://public.radio.co/embed/s510dd57df/song.js', array('jquery') );
    }

    b. Use header.php file instead to use scripts tags the way you currently use them, just insert those above the closing head element. It should be something like this

    <script src="https://public.radio.co/embed/s510dd57df/artwork.js"></script>
    <script src="https://public.radio.co/embed/s510dd57df/song.js"></script>
    </head>

    2. & 3.
    For those two points I'm afraid some custom work should be made in Masonry plugin and active theme, in case they don't provide an ajax functionality. This kind of custom work surpasses our support forums though, as it would require extended resources on our behalf. Having said that, you may have to hire a developer to build those for you. You can use our Jobs & Pros section for that (no WPMUDEV staff members included).

    Warm regards,
    Dimitris

  • Adam Czajczyk

    Hello Eric!

    There's some freelance "workforce" services around like e.g. Upwork or Freelancer.

    As for the price. It's difficult to estimate, really. One thing is that being out of freelance market (and we as a WPMU DEV staff do not offer any services of that kind neither via our our Job board nor via 3rd party services) makes it a bit hard to "stay in tune" with current market prices. More important part though is that it's also difficult to estimate what would be amount of work necessary. The person that will work for you would either know that because she/he has done something similar before or because she/he will be able to check and review your setup in order to give you a price :slight_smile:

    You may want though to ask other Members of our community for some help on reasonable pricing by asking that question on our "Members" forum :slight_smile:

    Best regards,
    Adam