Support » Plugin: Jetpack by WordPress.com » Fatal Error with “Optimize your site for smartphones”

  • Resolved wpweaver

    (@wpweaver)


    The option
    “Optimize your site for smartphones”
    seems to have some sort of new behavior over the previous JstPack Mobile Theme.

    The current version breaks my theme (Weaver Xtreme with Premium Weaver Xtreme Plus plugin). This theme is already optimized for mobile display, but we find a significant number of users end up with the JetPack mobile / smartphone option which does not give optimal display.

    But now the option is generating a call to an “undefined” function because apparently the theme’s runtime library is not loaded, but the plugin is.

    Rather than trying to find the issue with JetPack, it would be preferable if my theme could detect and override that JetPack option. Is there an action or filter that would override JetPack’s use of the smartphone theme, or at least allow the theme to issue a warning.

    As I said, this did not used to happen, so something in the loading order has changed.

Viewing 1 replies (of 1 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    the option is generating a call to an “undefined” function because apparently the theme’s runtime library is not loaded, but the plugin is.

    When Jetpack’s Mobile Theme is loaded the desktop theme is not active anymore; a completely different theme is then in use on the site. As a result the functions your theme includes are not available to any plugin that may be installed on the site and trying to leverage those functions.

    I would recommend that you add a check in your plugin to make sure it doesn’t try to use functions that do not exist. That should also help your users who may switch to a different theme without deactivating the plugin first.

    If you think the problem is unrelated to the theme in use on the site, could you enable WP_DEBUG and let me know the error appearing in your logs when that Fatal error happens?

    Thanks!

    Rather than trying to find the issue with JetPack, it would be preferable if my theme could detect and override that JetPack option. Is there an action or filter that would override JetPack’s use of the smartphone theme, or at least allow the theme to issue a warning.

    I think we should aim to fix the issue with Jetpack, and I would recommend against deactivating specific Jetpack features without warning your users about it. Doing so could indeed create some confusion when users purposefully enable the Mobile Theme (which will be the case most of the time, since the feature isn’t enabled by default).

    Deactivating Jetpack’s Mobile Theme would be done like so:

    
    if (
    	// Is Jetpack installed and active?
    	class_exists( 'Jetpack' )
    	// Is the Mobile Theme module active?
    	&& Jetpack::is_module_active( 'minileven' )
    ) {
    	// Deactivate the module.
    	Jetpack::deactivate_module( 'minileven' );
    }
    

    You could then add a notice to let your users know that you’ve deactivated the feature.

Viewing 1 replies (of 1 total)
  • The topic ‘Fatal Error with “Optimize your site for smartphones”’ is closed to new replies.