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

    georgewhoffman
    Participant

    Hi, I’m trying to embed the following code, which creates a form on the page. Because the submission form is only going on one page and because the code creates the form where the code is located, it needs to be on the page. I tried using both a raw code element and a text box.

    I had saved content, a couple of sections, rows, headlines, etc., saved, exited, worked fine, then I went in to add the JS. I paste the code into the element, then save. Cornerstone gives me the “success” message, but when I try to exit out of the page, I get the alert asking if I’m sure I want to leave the page with unsaved content. I have no choice, because the page is already “saved” so I exit. Every element on the page disappeared. Completely gone from Cornerstone.

    I searched the forum and it seems that the theme and Cornerstone allow adding inline JS. Some posts recommended deleting html comments, which I did. Any idea of how I can add this code (without the comments):

    <!-- Begin MySiteAuditor -->
    <script src="//cdn.mysiteauditor.com/audit-tool.js" type="text/javascript"></script>
    		
    <div id="seogroup-embed"  data-apikey="aadca896df13bb478e19608f25554ed6ce709641" data-language="english" data-type="slim" data-hex="#003058" data-hex-form="#F0F0F0" data-hex-text="#000"></div>
    <!-- End MySiteAuditor -->

    Page: https://codeificant.com/?page_id=652&cornerstone=1

    Login credentials by private reply.

    Thank you!

    #1318995

    georgewhoffman
    Participant
    This reply has been marked as private.
    #1319292

    Nabeel A
    Moderator

    Hi there,

    Thanks for writing in! You can go to http://cdn.mysiteauditor.com/audit-tool.js and copy the script from there and paste in your Cornerstone’s page Custom JS then you can add your HTML in a Raw Content element:

    <div id="seogroup-embed" data-apikey="aadca896df13bb478e19608f25554ed6ce709641" data-language="english" data-type="slim" data-hex="#003058" data-hex-form="#F0F0F0" data-hex-text="#000"></div>

    Let us know how this goes!

    #1319321

    georgewhoffman
    Participant

    I tried that — no luck.

    I opened the page in C-stone, inserted a section, row, headline, and the raw content element. Inside that, I just inserted an h3 tag with some text. Saved. Tubular! Exited C-stone, went back in. All good.

    I copied the JS into the Custom JS. Saved. Another success message. But when I tried to exit, I received the “unsaved content” alert popup. Cancelled that. Saved again. Another success message. This time I waited a couple of minutes, thinking maybe C-stone actually uploads the revised code after the save, tried to exit, same “are you sure you want to leave this page” alert. I said yes. Exited and re-entered C-stone. The JS was not present in the Custom JS.

    Then, as a final test, inside C-stone, I pasted the div text from your reply above, saved and exited then re-entered. As expected, the div is still there. It’s just gagging on the both the inline scripting and when placing the code in the Custom JS.

    Maybe there’s something else going on with my installation? Everything else is working great.

    #1319615

    georgewhoffman
    Participant

    Update: I tried the div + JS on another WP site, on the same server with the same configuration, using the Jupiter theme + Visual Composer page builder. The code worked fine on that one. Still no luck on this X+C-stone site, though.

    #1319849

    Rad
    Moderator

    Hi there,

    Javascript should work in raw element, but not in this case and it throws this,

    {"success":false,"data":{"message":"nonce verification failed."}}

    Maybe there is a restriction/security not to include script through POST data (ajax). It works in visual composer since it’s usually dependent on editor content (eg. shortcodes) which doesn’t need POST data request. The same issue happens when adding iframe but it’s blocked due to a security feature which sees it as XSS attack.

    To make it work, the javascript should be recognized by cornerstone as enqueue integration. Example, please add this code to your raw element

    <div id="seogroup-embed" data-apikey="aadca896df13bb478e19608f25554ed6ce709641" data-language="english" data-type="slim" data-hex="#003058" data-hex-form="#F0F0F0" data-hex-text="#000"></div>

    then add this code to your child theme’s functions.php

    function seogroup_embed_enqueue() {
    	wp_enqueue_script( 'seogroup-embed', '//cdn.mysiteauditor.com/audit-tool.js', false );
    }
    
    add_action( 'wp_enqueue_scripts', 'seogroup_embed_enqueue' );

    Thanks!