Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #705745

    Frosting
    Participant

    Hi,
    I’m trying to add the following script to my site, using Cornerstone:

    <script type="text/javascript">
    	GITWidget.addGolfLogin({ width: 250, guid: '22c55abe-ac3e-4ce6-aed7-ca2a8074648a' });
    </script>
    

    I’m adding it in a tab content in “text” mode (not visual). I’m also adding the required script.js through functions.php in my child theme. (http://gitwidgets.golf.se/Widget/script.js)
    The script is loading a signin form to a golf service (signing in to “my golf id”).

    The problem is when I add the script above in Cornerstone, the form gets rendered and everything else disappears.
    http://cl.ly/3W363j3x0v0T

    I´ve tried updating my local environment to latest version of X and Cornerstone but problem remains.

    On my stage server I´m using:
    WordPress: 4.3.1
    X-Theme: 4.1.1
    Cornerstone: 1.0.6

    http://sorfjardensgk.f-dev.se/

    #705781

    Christopher
    Moderator

    Hi there,

    Please remove the code from text element and add it in raw content element.

    Hope it helps.

    #705851

    Frosting
    Participant

    Hi,
    no luck there. Same thing happens. Is there a way of adding the script through shortcode or javascript?

    #705928

    Christopher
    Moderator

    Hi there,

    Inside CS, you can add JS in raw content element. Upon checking your site I noticed you’re not fully updated please update theme and plugins.

    You can find the latest version numbers here: (http://theme.co/changelog/) Then you can compare them to what’s installed on your site.

    If you find anything to be out of date, you can review our update guide.

    Hope it helps.

    #754988

    Frosting
    Participant

    Hi again,
    The project has been on ice for a while but starting to reach deadline. I still have not got it to work properly. I’ve updated X-theme and Cornerstone to the latest versions but that doesn’t solve the problem. Any ideas on how to add the script without crashing Cornerstone?

    #755137

    Rupok
    Member

    Hi there,

    Thanks for updating. If your codes are correct and other related scripts loaded correctly then it should work within RAW Content. So make sure that the other dependency scripts loaded correctly in order to prevent JS errors that causing the issues.

    Cheers!

    #768374

    Frosting
    Participant
    This reply has been marked as private.
    #768655

    Zeshan
    Member

    Hi Frosting,

    You can try a conditional tag to avoid the script to be loading in Cornerstone preview. So your updated code would be:

    function load_script_content() {
      if ( ! isset($_GET['cornerstone']) && $_GET['cornerstone'] != 1 ) {
        return "<script type=\"text/javascript\">GITWidget.addGolfLogin({ width: 250, guid: '22c55abe-ac3e-4ce6-aed7-ca2a8074648a' });</script>";
      }
    }
    
    add_shortcode('custom_script', 'load_script_content');
    

    Thank you!

    #776620

    Frosting
    Participant

    Hi again,
    sorry but this didn´t do the trick. Cornerstone gets stuck in a loop. Any other way?

    #777359

    Paul R
    Moderator

    Hi Frosting,

    I check your functions.php file and didn’t see the code getting added to it.

    Please add this in your child theme’s functions.php (wp-content/themes/x-child/functions.php)

    
    function load_script_content() {
      if ( !isset($_GET['cornerstone']) && $_GET['cornerstone'] != 1 ) {
          ?>
        <script type="text/javascript">GITWidget.addGolfLogin({ width: 250, guid: '22c55abe-ac3e-4ce6-aed7-ca2a8074648a' });/script>
        <?php    
      }
    }
    add_shortcode('custom_script', 'load_script_content');
    

    Then add this in cornerstone

    
    [custom_script]
    

    http://screencast.com/t/JM4hPRYOnS

    Hope that helps