Support » Plugin: WPML Widgets » Hey, I see WPML is not activated, please activate it before using WPML Widgets.

  • Resolved harolparamo

    (@harolparamo)


    Download Version 1.0.6

    This message appears to me when activating the plugin. If I disable the plugin, then the message does not appear. I have tried the installation in several ways: I have installed from wordpress, I have downloaded the plugin and installed by separate and installed, the compressed file. I have tried several methods, and the message still appears. What I can do?

    Thank you

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Jeroen Sormani

    (@sormano)

    Hi,

    There are several other topics to be found on this in the support forums, including the fix.

    https://wordpress.org/support/topic/hey-i-see-wpml-is-not-activated-please-activate-it-before-using-wpml-widgets/

    Cheers,
    Jeroen

    ierpe

    (@ierpe)

    Hi,

    A workaround is just to comment the first lines of your construct function :

    		// check if WPML is activated
    		if ( ! function_exists( 'is_plugin_active_for_network' ) ) :
    			require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
    		endif;
    
    		if ( ! in_array( 'sitepress-multilingual-cms/sitepress.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) :
    			if ( ! is_plugin_active_for_network( 'sitepress-multilingual-cms/sitepress.php' ) ) :
    				add_action( 'admin_notices', array( $this, 'wpml_nag_message' ) );
    				return;
    			endif;
    		endif;

    from the wpml-widgets.php

    I think it is silly to use such a real path since the wpml plugin names have been changing across versions, when you could just check for a “function_exists”, as described here on WPML forums : https://wpml.org/forums/topic/how-to-check-if-wpml-is-installed-and-active/

    if ( function_exists('icl_object_id') ) {
         //something
    }
    Plugin Author Jeroen Sormani

    (@sormano)

    Hi,

    A general recommendation is to not modify code within a plugin directly.

    The used name should be the official path to the WPML plugin, in some exceptional cases it could be a different one is used, but no official scenario.

    Using a function_exists check has its own drawbacks. Wish there was a better way for checking!

    Cheers,
    Jeroen

    A general recommendation is to not modify code within a plugin directly.

    I know… but in my case I had no choice :). Not really a problem though, we’re using the Bedrock stack and Git, so I’ll know if something’s changing during updates 🙂

    Using a function_exists check has its own drawbacks. Wish there was a better way for checking!

    True that, but in my case the function_exists would have worked, and your check did not, and it’s WPML’s recommandation to use the function_exists (Even though they don’t necessary have the best coding standard XD)

    Kind regards

    Plugin Author Jeroen Sormani

    (@sormano)

    Hah! So agreed with the last 😉

    I may change it to a function check, may actually work better in this case as they have mistakenly given their package the wrong name before.

    Just out of curiosity: Any reason why your folder name can’t be the official name? (sounds like thats the case for you)
    BR should not interfere with that part, right?

    Cheers,
    Jeroen

    Because of some custom payment plugin one of my customer is using, as of today we cannot not update the WPML plugins for compatibility reasons.

    In the near future this will change but I needed a plugin such as yours with the older WPML versions, that’s why I faced this problem 🙂

    Plugin Author Jeroen Sormani

    (@sormano)

    I’ve modified the check to be like this:

    
    if ( ! in_array( 'sitepress-multilingual-cms/sitepress.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) :
    	if ( ! is_plugin_active_for_network( 'sitepress-multilingual-cms/sitepress.php' ) ) :
    		if ( ! function_exists( 'icl_object_id' ) ) :
    			add_action( 'admin_notices', array( $this, 'wpml_nag_message' ) );
    			return;
    		endif;
    	endif;
    endif;
    

    https://github.com/JeroenSormani/WPML-Widgets/commit/8ef42006b82b98f855aba18c90c73520f461b0a4

    Given the advantages of both and prevents the disadvantages of switching completely. Not the most prettiest as it is pretty big, but it does work more gracefully in more scenarios like yours 🙂

    Will be available in the next update.

    Cheers,
    Jeroen

    Yes that would work. you could also put it all in one condition and not use 3 “if”…

    Actually, why do you even bother making this test…? People who install this plugin will have WPML installed or?

    Plugin Author Jeroen Sormani

    (@sormano)

    I know thats possible, I just don’t like to use it that way with big IFs (also don’t like it like this, but its a bit less 😉

    You’d be surprised (I know I am) for the number of people that try to install this without WPML..

    You’d be surprised (I know I am) for the number of people that try to install this without WPML..

    I see B-)

Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.