How to remove an enqueued script that I can't find on any of my pages from functions.php? / How to edit functions.php?

I think I’m going crazy. I have a script in the footer that looks like this
<script type="text/javascript" id="inline-script-1-js-after">. Inside, there’s some JS code. I actually used that JS code before on one page, but it’s been deleted and I can’t find it anywhere on the site, but it’s still in the footer.

Is it possible that Pinegrow somehow automatically adds it? I’m not using any Code Snippet plugin.

I’m 99.99% sure that I’m the problem here, but I simply can’t find this code anywhere.

I’ve never seen Pinegrow add anything like that. Can you share a page that has it?

It looks like it’s added by Pinegrow interactions; I just didn’t recognize it…

wp_register_script( 'inline-script-1', '', [], '0.0.90', false );
    wp_enqueue_script( 'inline-script-1' );
    wp_add_inline_script( 'inline-script-1', '/* Pinegrow Interactions, do not remove */ (function () {
                try {
                    if (!document.documentElement.hasAttribute("data-pg-ia-disabled")) {
                        window.pgia_small_mq = typeof pgia_small_mq == "string" ? pgia_small_mq : "(max-width:767px)";
                        window.pgia_large_mq = typeof pgia_large_mq == "string" ? pgia_large_mq : "(min-width:768px)";
                        var style = document.createElement("style");
                        var pgcss = \'html:not(.pg-ia-no-preview) [data-pg-ia-hide=""] {opacity:0;visibility:hidden;}html:not(.pg-ia-no-preview) [data-pg-ia-show=""] {opacity:1;visibility:visible;display:block;}\';
                        if (document.documentElement.hasAttribute("data-pg-id") && document.documentElement.hasAttribute("data-pg-mobile")) {
                            pgia_small_mq = "(min-width:0)";
                            pgia_large_mq = "(min-width:99999px)";
                        }
                        pgcss += "@media " + pgia_small_mq + \'{ html:not(.pg-ia-no-preview) [data-pg-ia-hide="mobile"] {opacity:0;visibility:hidden;}html:not(.pg-ia-no-preview) [data-pg-ia-show="mobile"] {opacity:1;visibility:visible;display:block;}}\';
                        pgcss += "@media " + pgia_large_mq + \'{html:not(.pg-ia-no-preview) [data-pg-ia-hide="desktop"] {opacity:0;visibility:hidden;}html:not(.pg-ia-no-preview) [data-pg-ia-show="desktop"] {opacity:1;visibility:visible;display:block;}}\';
                        style.innerHTML = pgcss;
                        document.querySelector("head").appendChild(style);
                    }
                } catch (e) {
                    console && console.log(e);
                }
            })();');

@matjaz It turns out that the script is enqueued by Pinegrow in functions.php, but I don’t remember enqueuing anything. I used the code on one page inside <script> tags, but then it was deleted. Is there a way to somehow remove it from functions.php? Regenerating it didn’t help.

To add to this, Adryan is running the WordPress plugin. The desktop version doesn’t enqueue it unless you activate Interactions, but I suspect the plugin works a bit differently.

I’d like to clarify that the script doesn’t come from Interactions. The enqueued JS code was created by me, but it was only used inside <script> tags on a page and later deleted. Now the script is nowhere to be found, so I can’t remove the “enqueue” action.

Does “Clear the theme folder” and re-exporting with “Export the theme” help?

Here’s a screenshot from our docs.

image

I’m using the WP plugin.

Ohh yeah, Im guessing the menu options will be different for plugin, for eg, “Export the plugin”.

Ahh my apologies, you are not using the desktop app, rather Pinegrow wp plugin

Oh yeah, I exported the theme multiple times. I also tried to edit the functions.php file, but it gets reverted on each export.

Inline script tags (our own or automatically injected when activating interactions on the page), when exported, are automatically enqueued and added as inline script (in the desktop app, wondering if it’s different with wp plugin).

So, in your case, if you removed that <script type="text/javascript" id="inline-script-1-js-after"> tag from your page, then it should also be removed off the functions.php automatically, which doesn’t seems to. Did I understand this correctly?

The easiest way to fix this in the desktop app, is to clear the current theme/plugin folder PLUS also delete the local _pgexport folder, and do a fresh export.

image

I’m not sure about how to achieve the same in WP plugin, will probably wait for someone from the community to advise.

That said, the export should automatically add and remove inline-scripts, without the need to delete _pgexport, clear and re-export the theme/plugin. But, I will probably wait for WP pros in the community to confirm this.

I don’t see any way to do it in the WP plugin. I guess I have to wait for an email reply from support.

@adamslowe

Based on what I observe, the situation is more intricate. The project was initially developed using the desktop version and then transferred to the plugin.

@Adryan
Ongoing investigations.
Based on my initial findings, it may be beneficial to review/adjust (remove the unwanted things) the original project from Pinegrow desktop, then reimport it - as a new project - into the plugin with the necessary modifications.

I don’t think I ever used the desktop version for this project, though. I don’t have the Tailwind extension in the desktop version.

Then I’m deeply sorry if my first impression was wrong but was the project fully created within the plugin or did you import an existing HTML template to start the project?

I created it from scratch in Pinegrow plugin. It generated the boilerplate HTML code and then I pasted some Tailwind CSS sections.

Then I guess I was misled by the apparent complexity of the template content. Please accept my apologies for the initial (early morning) misunderstanding.

I will continue my investigations :wink:

No worries, I appreciate you taking the time to help :slight_smile:

SOLVED. Cause of the “bug” - the idiot behind the keyboard :wink: