- This topic has 12 replies, 3 voices, and was last updated 5 years, 2 months ago by
Tom.
-
AuthorPosts
-
March 26, 2018 at 3:06 pm #531708
Darcie
I’m setting up a radio station site and we’d like to use a player that gives me the following code to insert in the php before the </body> tag.
<!– place this code right before the </body> tag at the end of your page’s HTML code –>
<script type=”application/javascript”>if(window===top){var CE_Player=new Object({stationCallSign:’BREEZE’,position:’top’,autostart:false,playerlocation:’streamdb8web’,fullPlayer:’v8′});document.write(‘<script src=”http://streamdb8web.securenetsystems.net/ce/js/playerwidget.min.js?’+Math.random()+'”><\/script>’);}</script>I’ve successfully inserted it in the footer php, but nothing happens. I confess, I’m new to the whole script thing, so is there something I’m missing?
March 26, 2018 at 8:02 pm #531889Leo
StaffCustomer SupportHi there,
I would recommend using
wp_footer
instead of editing footer.php so it’s saved through updates:
https://docs.generatepress.com/article/hooks-overview/
https://docs.generatepress.com/article/wp_footer/March 27, 2018 at 7:10 am #532417Darcie
Ok. I’m not sure I’m doing this right, because it’s still not working.
I went to the GP Hooks section, chose wp_footer from the pull-down, and then inserted
add_action( ‘wp_footer’, ‘radio_player’);
function radio_player() { ?>
<script type=”application/javascript”>if(window===top){var CE_Player=new Object({stationCallSign:’BREEZE’,position:’top’,autostart:false,playerlocation:’streamdb8web’,fullPlayer:’v8′});document.write(‘<script src=”http://streamdb8web.securenetsystems.net/ce/js/playerwidget.min.js?’+Math.random()+'”><\/script>’);}</script>
<?php }I then selected “execute php” and hit “save hook.” Refreshed site, and nothing. What else do I do?
(I told you I was a complete novice…)
March 27, 2018 at 9:25 am #532690Leo
StaffCustomer SupportHmm try just this:
<script type=”application/javascript”>if(window===top){var CE_Player=new Object({stationCallSign:’BREEZE’,position:’top’,autostart:false,playerlocation:’streamdb8web’,fullPlayer:’v8′});document.write(‘<script src=”http://streamdb8web.securenetsystems.net/ce/js/playerwidget.min.js?’+Math.random()+'”><\/script>’);}</script>
March 27, 2018 at 9:47 am #532709Darcie
Thanks, but I inserted that into the hook and nothing happened still.
March 27, 2018 at 1:39 pm #532937Leo
StaffCustomer SupportThen it’s probably best to check with the source of the code/plugin developer to see if there are anything else you need to do.
March 29, 2018 at 2:26 am #534812Darcie
There has to be some sort of conflict with the theme’s code, since I have also tried embedding iframe code for a different radio player into the header, and that won’t work either. No help from the streaming developers.
March 29, 2018 at 8:48 am #535244Leo
StaffCustomer Support<iframe>
should go directly into the content.Are you sure there aren’t anything else you need to do after inserting the code into
wp_footer
?There shouldn’t be any conflicts on this part as GP simply adds the code you inserted.
Maybe try it with a twenty series themes?
March 30, 2018 at 2:29 am #535918Darcie
This is my problem. I did enter the code directly into the content. It didn’t do anything.
Also, I don’t see the script on the page code after I use the hook. I really think I’m not understanding how to use the hook.
March 30, 2018 at 8:58 am #536291Leo
StaffCustomer SupportHook just takes the code you added and doesn’t interfere with it or anything.
If it asked to place before the end of body then
wp_footer
is definitely the right spot.Where did you get the code? If the developer isn’t answering perhaps it’s no longer supported?
Can you try it with a twenty series theme and see if it works correctly?
April 2, 2018 at 2:56 am #538418Darcie
Just got the following response from the script developer:
Does your website have CORS enabled? I ask because of the following message that shows in the debugger, when I visit:
Blocked loading mixed active content “http://streamdb8web.securenetsystems.net/ce/js/playerwidget.min.js?0.43080983946222295”
What is CORS? Is it something I have control over?
April 2, 2018 at 7:58 am #538694Darcie
Added the revised script directly into the footer.php and it works fine. Clearly I’m not understanding the concept of hooks.
April 2, 2018 at 9:41 am #538820Tom
Lead DeveloperLead DeveloperPerhaps your server is messing up the code while it’s being saved.
Instead, use this code:
add_action( 'wp_footer', 'tu_add_radio_script' ); function tu_add_radio_script() { ?> <script type=”application/javascript”>if(window===top){var CE_Player=new Object({stationCallSign:’BREEZE’,position:’top’,autostart:false,playerlocation:’streamdb8web’,fullPlayer:’v8′});document.write(‘<script src=”http://streamdb8web.securenetsystems.net/ce/js/playerwidget.min.js?’+Math.random()+'”><\/script>’);}</script> <?php }
Add it using one of these methods, instead of GP Hooks: https://docs.generatepress.com/article/adding-php/
-
AuthorPosts
- You must be logged in to reply to this topic.