• Resolved ildomandatore

    (@ildomandatore)


    I should enter script code of a JS program, but it gives me error.

    I even tried to add;

    <script type="text/javascript">
    </script>

    And I get a serious error.

    Don't Panic
    The code snippet you are trying to save produced a fatal error on line 498:
    
    Return type of WP_Hook::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
    The previous version of the snippet is unchanged, and the rest of this site should be functioning normally as before.
    
    Please use the back button in your browser to return to the previous page and try to fix the code error. If you prefer, you can close this page and discard the changes you just made. No changes will be made to this site.

    I am a newbie on the JS and I am following this guide.
    https://github.com/ethanaobrien/emulatorjs

    I don’t know where to put the folders I add via FTP. I guess the part of the code with the DIVs should be added in the HTML of the affected page.

    But the script doesn’t want to start and I don’t understand why. I put the url of the game and did various tests. Even if I’m a beginner, I think something is missing or there is a serious problem.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    Code Snippets is (currently) only designed for working directly with PHP code. That does not mean that you can’t add HTML code like this, but you do need to tell WordPress exactly where you want it to go.

    For the example you gave, you could add a shortcode which contains this code, and then just insert that shortcode into a post:

    add_shortcode( 'emulatorjs', function () {
        ob_start();
        ?>
    
    <!-- code goes here -->
    
    <div style="width:640px;height:480px;max-width:100%">
      <div id="game"></div>
    </div>
    <script type="text/javascript">
        EJS_player = '#game';
        EJS_biosUrl = ''; // Url to Famicom Disk System bios
        EJS_gameUrl = ''; // Url to Game rom
        EJS_core = 'nes';
        EJS_lightgun = false; // Lightgun
        EJS_pathtodata = 'data/'; //path to all of the wasm and js files. MUST all be in the same directory!!
    </script>
    <script src="data/loader.js"></script>
    
        <?php
        return ob_get_clean();
    } );
    Thread Starter ildomandatore

    (@ildomandatore)

    I suspect there is something that is not going to be right; I only need the code for one page, because I’m going to put some more.

    Maybe you mean this;

    add_shortcode( 'emulatorjs', function () {
        ob_start();
        ?>
    
    <!-- code goes here -->
    
    <script type="text/javascript">
        EJS_player = '#game';
        EJS_biosUrl = ''; // Url to Famicom Disk System bios
        EJS_gameUrl = ''; // Url to Game rom
        EJS_core = 'nes';
        EJS_lightgun = false; // Lightgun
        EJS_pathtodata = 'data/'; //path to all of the wasm and js files. MUST all be in the same directory!!
    </script>
    <script src="data/loader.js"></script>
    
        <?php
        return ob_get_clean();
    } );
    • This reply was modified 4 years, 6 months ago by ildomandatore.
    Plugin Author Shea Bunge

    (@bungeshea)

    The actual HTML/JS code was just an example. Have you tried the snippet you posted to see if it works?

    Thread Starter ildomandatore

    (@ildomandatore)

    Yes I tried it and you don’t even see the loader.

    Thread Starter ildomandatore

    (@ildomandatore)

    I slightly modify the question; I should change the CSS on the page, but I get errors for the wrong syntax. With Givewp, they made me write code to put before and after my code.

    What should I write? I no longer have Givewp.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Scripts give fatal errors.’ is closed to new replies.