• Resolved photoMaldives

    (@photomaldives)


    Hi Jeff.

    I spotted a weird error just now – WP backend, working on the GiveWP plugin, an error message breaks onto screen that seems to come from your plugin? >

    <div id="mceu_62" class="mce-widget mce-notification mce-notification-error mce-has-close mce-in"...
    
    Failed to initialize plugin: sdc_download

    Browser console error below >

    tinymce.min.js?ver=49110-20201110:2  Failed to initialize plugin: sdc_download ReferenceError: download_counter is not defined
        at t.<computed>.t.<computed>.init (tinymce.js?wp-mce-49110-20201110:14:13)
        at Ew (tinymce.min.js?ver=49110-20201110:2:330514)
        at Array.<anonymous> (tinymce.min.js?ver=49110-20201110:2:332223)
        at Object.jt [as each] (tinymce.min.js?ver=49110-20201110:2:29356)
        at Aw (tinymce.min.js?ver=49110-20201110:2:332173)
        at tN.<anonymous> (tinymce.min.js?ver=49110-20201110:2:333551)
        at Array.<anonymous> (tinymce.min.js?ver=49110-20201110:2:96969)
        at jt (tinymce.min.js?ver=49110-20201110:2:29356)
        at u (tinymce.min.js?ver=49110-20201110:2:96914)
        at n (tinymce.min.js?ver=49110-20201110:2:96402)

    Thanks, and keep up the great work. ??

Viewing 15 replies - 16 through 30 (of 35 total)
  • Plugin Author Jeff Starr

    (@specialk)

    Understood, let me know if any further issues. Thank you, @photomaldives.

    garrettm30

    (@garrettm30)

    I would like to join the discussion, as I am experiencing this issue, and I have seen a few others are as well. In my case, it is on the product translation screen that depends on both WooCommerce and WPML, the latter of which is paid. Another person posted it in a thread I was a part of, who was experiencing the issue with the plugin “Folders” by Premio. I have done some web searches and discovered a few other plugins not at all related to Simple Download Counter that are also getting similar reports. So far, the common denominator in all of these cases is that a third-party plugin uses tinymce in admin, and the file tinymce.min.js throws a client-side error regarding an undefined variable (“download_counter” in this case) for another plugin.

    In my case, the annoying part is that I am experiencing it on my production site but not the dev copy of the same site, so of course I can’t effectively hunt it down, and I appreciate that you can’t either without being able to reproduce it. Now I am trying to figure out what the difference is so maybe I can make a discovery that might lead to the solution

    In the meantime, I can appreciate that you can’t fix anything without repeatable steps. I will keep my eyes open, and if I see anything, I will come back here and let you know what I find. Meanwhile, at least in my case, it is just a minor annoyance only seen by me on backend that does not actually cause any issue.

    Plugin Author Jeff Starr

    (@specialk)

    Thank you for the report, @garrettm30. Standing by for any further news regarding this issue. Let me know how I can help.

    garrettm30

    (@garrettm30)

    I think I have something reproducible. I have created an entirely fresh site on local, installed your plugin and then installed Formidable Forms as another user mentioned elsewhere. Unlike that user, I have tested with the free version. Then with both plugins activated, I get the error when I go to edit a form, in this case, the included “Contact us” form.

    I saw you mention in still another thread that you thought it was Nginx, but note that I am running Apache on local (I use MAMP Pro) and still get the error.

    So what can I do to get this to you? For example, I could record a screen cast, or I can package up the site files and database and send that to you.

    Plugin Author Jeff Starr

    (@specialk)

    Thanks @garrettm30.

    As explained previously in this thread, if you can let me know the steps to repeat the issue on default WP, it would enable me to investigate asap. Just like:

    1. Install/activate plugin
    2. Do some steps
    3. Etc., until the issue happens

    That’s all I need to look into this asap.

    Sorry for the delay. I wanted to run through it again to make sure I am giving all of the steps.

    I am starting from an entirely fresh install with no other action but to log in as admin and go to the add plugin page. The environment is Apache with PHP 8.2.0, WordPress 6.4.3.

    1. Install and activate Simple Download Counter.
    2. Install and activate Formidable Forms (by Strategy11 Form Builder Team)
    3. Refresh (so as to update the sidebar menu).
    4. Go to the submenu item “Forms (Lite)” from the Formidable menu.
    5. Click on the “Contact Us” form. This goes to the edit form screen.

    At this point the error should manifest. About an inch or so from the left, there is a tall, very narrow error div with a light pink background. As it shows in this plugin, the space does not allow the message to appear except as one character per line. More importantly, there is an error in the JavaScript console that begins: “Failed to initialize plugin: sdc_download.”

    Note that I have no experience with Formidable Forms. I only chose this because it seems to be the easiest option for getting you something that is reproducible, much easier than trying to reproduce my situation. On my site, I get the same error in JS console with basically the same error div, except that for me the error div is given proper space and it appears 4 times, for there are four instances of tinymce on that page.

    Plugin Author Jeff Starr

    (@specialk)

    Thanks @garrettm30, I tried the steps on both PHP 8.1 and 8.2 but could not repeat any issue. This is with latest versions of both plugins running on default WordPress 6.4. So I am guessing the issue may be happening due to something further upstream on the server somewhere.

    That’s a real puzzler. Since the error occurs client-side (like onload or something, since the message pops up a little after the page loads), do you suppose it could be depending on something browser-related? I have tried it on Safari, Firefox, and Brave, all on macOS 14, and site that I set up following the steps above have manifested the error.

    Plugin Author Jeff Starr

    (@specialk)

    Sometimes little popup messages and other front-end items are called from the server via Ajax/REST/etc. So it most certainly could be related to server/config. As for browsers, I tested on latest Chrome. It could be browser-related, also could be something theme-related. I was testing with the default WP theme enabled.

    I think we can rule out theme in this case, because I never changed theme on this fresh install. I just double checked, and the active theme is Twenty Twenty Four.

    What about the locale for your test WP install? Mine is “en_US”. The JS error is “Can’t find variable: download_counter.” That variable appears only three times in your code that I can find. The only time it is server side is in a wp_localize_script() call, so maybe a different locale could be hiding the issue?

    Plugin Author Jeff Starr

    (@specialk)

    Yeah maybe, like always just need the steps and I’ll be glad to test any theory. I am testing on en_US locale so shouldn’t make a difference in this case.

    I’m afraid I am at a loss at why you aren’t seeing the problem. I think I and those before me have failed to adequately explain where to see the issue. But I believe I have found the problem. I hope I can explain this adequately.

    Summary: Your tinymce.js plugin gets loaded more broadly than your scripts get enqueued, and so on third-party pages where tinymce is used, only part of your code is loaded, and that is why there is the missing variable.

    Details:

    In your file inc/functions-shortcode.php, the function simple_download_counter_add_mce() includes the following at line 423:

    add_filter('mce_external_plugins', 'simple_download_counter_add_mce_plugin', 10);

    It is there that your file js/tinymce.js gets registered for use by tinymce. Note that this filter gets added in an action called at init and is not behind any conditions, so it gets added everywhere, frontend and backend.

    Now in your file inc/resources-enqueue.php, your scripts get enqueued inside of this condition at line?10:

    if ($hook === 'edit.php' || $hook === 'post.php' || $hook === 'post-new.php' || $hook === 'sdc_download_page_download-counter-settings')

    On the Formidable page I tried to send you to, tinymce gets loaded, and your plugin to tinymce gets loaded, but because the hook on that particular page is toplevel_page_formidable, your other scripts do not get loaded, especially js/settings.js where the needed variable download_counter is found.

    I believe therefore this problem should happen anywhere tinymce is used on pages other than edit, post, post-new, and sdc_download_page_download-counter-settings.

    I sure hope that’s the problem and I haven’t wasted your time after all. Thanks at least for looking into it.

    Plugin Author Jeff Starr

    (@specialk)

    Ah! yes that makes sense. I will add the same “if” conditions to the tinymce call, sounds like it should resolve the issue. Thanks for your help with this @garrettm30, very much appreciated.

    That’s a relief to finally get to the bottom of the issue. Thank you for working through it with me.

Viewing 15 replies - 16 through 30 (of 35 total)
  • You must be logged in to reply to this topic.