Jump to content


This topic is now archived and is closed to further replies.


How to enter shortcode with Javascript

Recommended Posts


Hello, I have been trying to use a timeline plugin that is based on Javascript (it is called Chronos, based on VeriteCo JS Timeline). In the early versions of DMS2 this worked flawlessly (to my pleasant surprise as it did not work in DMS1 and I had to import it as an iframe). I don't know what might have changed that it doesn't work now. I tried MediaBox (and was told it does not work with Javascript), NextBox and SingleBits. None work - "Ooops, there may be an issue loading". Is it really impossible to make a Javascript shortcode work? It seems something so basic! I always presume that it must be me not looking in the right place though I have tried everything I could think of.

The last word was to use Hooks, but how do I go about doing that? I have the Hooker plugin but I'm at a loss how that can help me enter this shortcode. I tried to follow the Docs (http://docs.pagelines.com/advanced/hooks) but I cannot find the PL Customize plugin anywhere in the Store. Is there a way to add such a shortcode? Or hope that in future releases the conflict will disappear again?

Thank you for your help. 

Share this post

Link to post
Share on other sites



What do you mean by Javascript shortcode ?


If you want to include Javascript the best method is to enqueue the script using the WordPress function via a child theme. For more information see the WordPress codex - http://codex.wordpress.org/Function_Reference/wp_enqueue_script

Please search our forums, before posting!

Share this post

Link to post
Share on other sites

Dear Danny, 

it is an ordinary shortcode as far as I am concerned, it works in all the standard WordPress themes but not in DMS2. I called it a Javascript shortcode because I think that the plugin if puts in effect (or tries to do so) is based on Javascript. I replicated it on a site here:


I put the shortcode in a Nextbox. If I open the link while logged out, there are not problems either. But inside the Editor I cannot open the page it's on, there is an "Oooops" and the spinning wheel. 

So, considering that on the page it is working even within DMS2 and in all the generic WordPress themes I presume it is a conflict with the Editor. Can you see from the link what exactly it can be? And would there be a way around it? The possibility of only entering the shortcode at the last minute before logging out only occurs to me me now. That would be a way around. But something must be at fault (especially since I am convinced that it worked in a previous iteration of DMS, I distinctly remember how it did not used to work at first and then suddenly did - only to not work again now. But I may be wrong...).

Thank you for your help in this matter, I appreciate your help always. All in the service of weeding out conflicts, unless it is something just I am doing wrong...

Yours faithfully, Jan.



Share this post

Link to post
Share on other sites

P.P.S.: Pagelines troubleshoot guide advises to check Chrome - View - Developer - JavaScript Console. This is what it says:

Uncaught SyntaxError: Unexpected token ILLEGAL        (?page_id=20:336)
Uncaught TypeError: undefined is not a function          (pl.editor.js?ver=a079eb:39)

Share this post

Link to post
Share on other sites

Without knowing the actual shortcode text you are adding, I came up with this anyway:




Add it to wp-content/mu-plugins/chronos.php


Dont forget to edit it with the actual shortcodes

Share this post

Link to post
Share on other sites

Dear Simon,

thank you very much. Your code seems to get me tantalisingly close to where I want to be: I replaced [whatever] with [chronos id="805"] and then put the shortcode [safe_chronos] as well as just [safe_chronos  id="805"] (consecutively, for good measure). The "Ooops" and the red wheel are gone! But now it is just the shortcode itself that is showing, as text (to be seen here, under "Training Timeline": http://animatinglibraries.com/wordpress/?page_id=175).

Any ideas what could be amiss? If it is too hard don't worry. I will reconcile myself with sliding in the shortcode just before logging out of WordPress admin, having viewed it on Firefox before. A somewhat clumsy and roundabout way admittedly, but it seems to work, and there is only one instance of this timeline. Still, if a tweak in your code can put things right inside the Editor I'd of course be very happy indeed!

Thank you again for your effort. Yours faithfully, Jan.

Share this post

Link to post
Share on other sites

Dear Simon, you are right: I added the code (to htdocs/animatinglibraries/wordpress/wp-content/plugins/chronos/chronos.php as there was no "mu-plugins" plugins folder) but it did not upload to the server properly. Now it's there and it works like you described: When logged in it says "not doing this while editor is on" (but I can see it properly in a different browser where I am not logged in!), when logged out everything is there. Not perfect but perfectly practicable! Thank you so much. Just out of interest: Was this conflict inevitable? Would it always be like that with a Javascript-triggering shortcode like that? Anyway, my ghosts are chased away for now and I can go on timelining. Once again, I appreciate your support. Yours faithfully, Jan. 

Share this post

Link to post
Share on other sites

  • Similar Content

    • gstrahle
      By gstrahle+
      Is there anything that can possible be done to improve the loading performance of PageLines Platform and Elements?
      https://goldenstategreens.com/wp-content/plugins/pl-platform/engine/ui/js/common.js?ver=946207(180.5KiB) https://maps.gstatic.com/maps-api-v3/embed/js/36/11/init_embed.js(146.6KiB) https://maps.googleapis.com/maps/api/js?client=google-maps-embed&paint_origin=&libraries=geometry,search&v=3.exp&language=en_US®ion=us(99.3KiB) https://goldenstategreens.com/wp-includes/js/jquery/jquery.js?ver=1.12.4(87.0KiB) https://goldenstategreens.com/wp-content/plugins/pl-section-slider/flickity.js?ver=946207(48.2KiB) https://goldenstategreens.com/wp-content/plugins/pl-section-impulse/owl.js?ver=946207(35.3KiB) https://goldenstategreens.com/wp-content/plugins/pl-platform/engine/ui/js/site.js?ver=946207(18.8KiB) https://goldenstategreens.com/(17.5KiB of inline JavaScript) https://secure.gravatar.com/js/gprofiles.js?ver=2019Apraa(15.9KiB) https://goldenstategreens.com/wp-includes/js/jquery/ui/effect.min.js?ver=1.11.4(11.6KiB) https://goldenstategreens.com/wp-includes/js/jquery/ui/tabs.min.js?ver=1.11.4(9.6KiB) https://s0.wp.com/wp-content/js/devicepx-jetpack.js?ver=201917(9.4KiB) https://goldenstategreens.com/wp-content/plugins/pl-section-lax/parallax.min.js?ver=946207(7.8KiB) https://goldenstategreens.com/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1(7.7KiB) https://goldenstategreens.com/wp-includes/js/jquery/ui/accordion.min.js?ver=1.11.4(6.4KiB) https://goldenstategreens.com/wp-includes/js/jquery/ui/widget.min.js?ver=1.11.4(6.1KiB) https://goldenstategreens.com/wp-content/plugins/pl-section-meganav/superfish.js?ver=946207(4.4KiB) https://goldenstategreens.com/wp-includes/js/jquery/ui/core.min.js?ver=1.11.4(3.3KiB) https://goldenstategreens.com/wp-content/plugins/pl-section-meganav/meganav.js?ver=946207(2.2KiB) https://goldenstategreens.com/wp-content/plugins/pl-section-meganav/sticky.js?ver=946207(2.2KiB) https://goldenstategreens.com/wp-content/plugins/pl-section-impulse/impulse.js?ver=946207(1.7KiB) https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3355.356766011451!2d-117.21045368481853!3d32.75626678097826!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x80deaaeffa185a7f:0x6613dd77eb86c21!2sGolden+State+Greens!5e0!3m2!1sen!2sus!4v1552542527201(1.5KiB of inline JavaScript) https://goldenstategreens.com/wp-includes/js/wp-embed.min.js?ver=5.1.1(1.2KiB) https://goldenstategreens.com/wp-content/plugins/google-analyticator/external-tracking.min.js?ver=6.5.4(975B) https://goldenstategreens.com/wp-content/plugins/jetpack/modules/wpgroho.js?ver=5.1.1(716B) https://goldenstategreens.com/wp-content/plugins/jetpack/_inc/build/widgets/milestone/milestone.min.js?ver=20160520(488B) https://goldenstategreens.com/wp-content/plugins/pl-section-flicky-posts/js/script.js?ver=946207(469B) https://goldenstategreens.com/wp-content/plugins/jetpack/_inc/build/photon/photon.min.js?ver=20130122(395B) https://goldenstategreens.com/wp-content/plugins/pl-section-lax/lax.js?ver=946207(352B) https://goldenstategreens.com/wp-content/plugins/pl-section-slider/slider.js?ver=946207(319B)  
      We are working on site loading performance and would like to get a passing grade, and our load time down to 3 seconds.  We will be making updates to the content size to bring it down as well. Please let me know if there is anything that can be done to address the loading issues found here within PageLines Plugins.
    • IDdigital
      By IDdigital+
      A site of ours irregularly does not finish loading. The page in question is https://rw360.org/grievance-process/
      In Safari, I'll occasionally get the following error:
      [Error] TypeError: undefined is not an object (evaluating 'a.plModel.init')
          (anonymous function) (site.js:5:91)
          i (jquery.js:2:27455)
          add (jquery.js:2:27750)
          ready (jquery.js:2:29819)
          (anonymous function) (site.js:5)
          Global Code (site.js:5:3421)
      This seems to be a bug in PageLines as far as I can tell. Any suggestions or a fix coming?
    • Michael Kummer
      By Michael Kummer+
      Hi guys!
      I am using a plugin called Speed Booster Pack to speed up the load time of michaelkummer.com. One of the plugin settings, Minimize HTML and JavaScript causes an error that I only get with Pagelines. With other themes, such as WordPress' Twenty Seventeen, I do not get that error.
      I have reproduced the problem on my staging site and if you look at the JavaScript console, you will see the following error:
      SyntaxError: Unexpected end of script
      Any clue what PageLines may be doing differently to be contributing to this issue? I contacted the plugin developer and they, of course, pointed me to the theme developer
    • flourishdesignstudio
      By flourishdesignstudio+
      We are working on a site and the customers are complaining that the site loads too slowly. They contacted their host who mentioned that the Java Script is all loading at the beginning. Is it possible to delay the load of the less important Java Script until after the initial load to speed up the site? The goal is to load the page faster by minimizing the initial javascript calls.
      Are there any preferred plugins that you would recommend or does this end up causing excessive problems with plugins, etc.?
      Thanks for the help!
    • John Olsson
      By John Olsson+
      We're often working with ACF (https://www.advancedcustomfields.com/) that's great for user experience in the backend, 'cause we don't want out clients to be in the editor to much.
      So we want to be able to use shortcodes in the editor fields, regardless of section, THIS WOULD BE SO GREAT. Is there a way to fix this, it should open up som much more functionality.
      In ACF, the shortcode is for example: 
      [acf field="field_name"] ...for example, I want to att field_names value to display in a section, i understand I can make it in embed and so, but I want it in titles and options, the whole range.
      I know I can build my own sections, that we've done, but it's not very effective, and thats what PL5 is about.
      Any ideas on this, can Pagelines take this in the core? I guessing there are more than just ACF out there who can use this.