• Resolved grahammtbr

    (@grahammtbr)


    Would seem to be a JS not loading issue, as there’s nothing in the console, and no events in the inspector. I’ve tested the Tabs, Toggle, and Countdown block, and none are working on the frontend (the raw content shows, but nothing is hidden, expandable, etc.). They do work in the editor. I’ve disabled all plugins, and tried with Twenty-Twenty with the same results. WP 5.5.3

    • This topic was modified 4 years, 4 months ago by grahammtbr.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Munir Kamal

    (@munirkamal)

    Hi @grahammtbr

    That’s odd. I am guessing there seems to be a plugin you are using to optimize the JS on the frontend, that may be causing it? I read you tried by deactivating the plugins, but before that you should also purge your cache to make sure you are not looking at the cached version of your website.

    Let me know if that helps?

    Thread Starter grahammtbr

    (@grahammtbr)

    Hi Munir,

    There’s no cache, this is on a local development site (Docker, NGINX, PHP 7.4), and I did clear my browsers cache (tried both Firefox and Chrome). No plugins, and tried with Twenty Twenty, and Twenty Nineteen (and my own theme).

    Build.js is not being called on the frontend, I think that’s what’s missing. When I enqueue it it still doesn’t work, but console complains that lodash is not defined.

    Graham

    Plugin Author Munir Kamal

    (@munirkamal)

    Hey Graham,

    Ohh you are on a local host. Could you confirm you are using pretty permalinks and not that default “?p=123” kind of permalinks? I’ve head by another local host user that some issues were caused by that reason.

    Let me know.

    Regards,
    Munir

    Thread Starter grahammtbr

    (@grahammtbr)

    Yes, on localhost using pretty permalinks.

    Plugin Author Munir Kamal

    (@munirkamal)

    Ahh, That’s really odd. I just double checked it on my local host and on another computer (Local & Xampp), worked perfectly on both.

    There has to be something related to your local installation (my guess). Because the plugin works fine for me or for others (as I haven’t get this issue reported). ??

    Could you please test it on an online sandbox site? Like this service (tastewp .com) or any other.

    Let me know how may I help otherwise?

    Thread Starter grahammtbr

    (@grahammtbr)

    I can confirm it works on my staging & production server.

    My local install is from 10Up, https://10up.github.io/wp-local-docker-docs/, and it’s a fairly standard WordPress docker setup (and matches WP’s suggested NGINX settings). If the issue is with “pretty permalinks”, then it suggests an issue with locally hosted NGINX (as I’ve noticed this seems to be fairly different to Apache), so I did some digging…

    The issue is in /blocks/index.php.

    
    $wp_post = get_post(
    	url_to_postid("https://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']),
    	'_wpg_def_keyword',
    	true
    );
    

    I’m not a server expert, but as far as I can tell it should be,

    
    $wp_post = get_post(
    	url_to_postid("https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']),
    	'_wpg_def_keyword',
    	true
    );
    

    to work correctly with NGINX localhost.

    I read a bit of PHP docs and learnt SERVER_NAME will return the spoofed hostname by default under Apache2 unless spoofing is specifically turned off, which is probably why is works for some people, while NGINX returns ‘localhost’ instead of the hostfile domain name (and therefore wp_post returns a post ID of 0 and unsets the JS file).

    Making that change fixed my issues. I tested on a live site as well with no problems.

    Plugin Author Munir Kamal

    (@munirkamal)

    Hey @grahammtbr

    Thank you for testing and providing the details. I will look into this. ??

    mohammedeisa

    (@mohammedeisa)

    Hi @grahammtbr,

    This is a follow-up to your issue.

    I don’t think that Munir decided to implement the change you suggested in the Editor Plus code.

    Are you OK with a workaround for this issue?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Blocks not working on frontend only’ is closed to new replies.