N
N
Nik Master2022-04-14 07:26:14
WordPress
Nik Master, 2022-04-14 07:26:14

Why is syntax error, unexpected 'if' (T_IF) plugin not activated?

When activated, the plugin gives a syntax error, unexpected 'if' (T_IF) error. Here in here complains about the first if in init().

public function __construct() {

    add_action( 'init', [ $this, 'i18n' ] );
        add_action( 'plugins_loaded', [ $this, 'init' ] );
        add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_scripts' ], 11 );

  }

public function init() {
        // Check if Elementor installed and activated
        if (! did_action( 'elementor/loaded')) {
            add_action( 'admin_notices', [ $this, 'admin_notice_missing_main_plugin' ] );
            return false;
     }
    
    	// Check for required Elementor version
        if (! version_compare( ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '>=')) {
            add_action( 'admin_notices', [ $this, 'admin_notice_minimum_elementor_version' ] );
            return false;
     }
    
    	// Check for required PHP version
        if (version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<')) {
            add_action( 'admin_notices', [ $this, 'admin_notice_minimum_php_version' ] );
            return false;
     }
    
     return true;
     }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2022-04-14
@Rsa97

There are no errors in this code. Perhaps they are higher.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question