You do not have EventON main plugin, which is REQUIRED.

I recently came across a frustrating error whilst adding the Event On events calendar plugin and the Event On Weekly View add on to a client’s WordPress site. We purchased both the main Event On plugin and the Event On Weekly View add on. We were able to activate the main Event On plugin but the weekly view add on wasn’t allowing us to activate it despite a valid purchase code and it showing up as being activated in the Event On dashboard. We, annoyingly, kept getting the following error:

EventON WeeklyView is NOT active! - You do not have EventON main plugin, which is REQUIRED.

We tried deactivating and re-activating the plugins in different order to see if that did the trick. We tried deactivating and re-activating the license codes in different order to see if that did the trick. We tried deactivating and reactivating all of our plugins to see if that did the trick. Nothing was working. Not only was the error being thrown but the shortcodes that are associated with that add-on weren’t working.

So, we decided to take the extreme step of editing the add on plugin to get it to work. We figured out a super simple solution to this error message.

We are working with the Event On main plugin version 2.6.17 and the Event On weekly view add-on plugin version 1.0.11

Look at your Event On add on plugin’s core primary file. If you don’t know which file that is, it’s the file with the declaration of the WordPress plugin at the top. For example, we bought the weekly view add on, and the WordPress plugin registration/declaration code is at the top of the file called eventon-weekly-view.php and it looks like the following:

<?php
/*
 Plugin Name: EventON - Weekly View
 Plugin URI: http://www.myeventon.com/
 Description: Create a week view of events for EventON Calendar
 Author: Ashan Jay
 Version: 1.0.11
 Author URI: http://www.ashanjay.com/
 Requires at least: 4.0
 Tested up to: 4.9
 */

Now that we know the file we need to edit is the eventon-weekly-view.php, our next step is to figure out why the error message is being thrown. In our case, the issue is clearly with the class or global variable not existing at the top of the construct method in that file. Or, as described in the code’s comments, the “check if eventon exists with addon class” has failed.

public function __construct(){			
			// check if eventon exists with addon class
			if( !isset($GLOBALS['eventon']) || !class_exists('evo_addons') ){
				add_action('admin_notices', array($this, 'notice'));
				return false;			
			}

So, we need to figure out a way to ensure that EventOn exists with the add-on class so that that error is no longer thrown. In order to do this, we are simply going to include the main EventOn plugin’s core primary file. Again, you can identify this page as having the plugin declaration at the top. This file is called eventon.php and you can see the plugin declaration below.

/**
 * Plugin Name: EventON
 * Plugin URI: http://www.myeventon.com/
 * Description: A beautifully crafted minimal calendar experience
 * Version: 2.6.17
 * Author: AshanJay
 * Author URI: http://www.ashanjay.com
 * Requires at least: 4.0
 * Tested up to: 5.1
 * 
 * Text Domain: eventon
 * Domain Path: /lang/languages/
 * 
 * @package EventON
 * @category Core
 * @author AJDE
 * 
 */

So, we know that we want to include that core main plugin file in our core add on plugin, to prevent that error from displaying. We are going to be navigating from one plugin to another so we need to use the plugin_dir_path(__DIR__) function to get the base plugin path for the WordPress website (for example /var/www/website/wp-content/plugins). Then, to actually include the file we need to we’ll navigate to the primary EventOn plugin file and use the include_once PHP function to include that file. This looks like the code below:

include_once(plugin_dir_path( __DIR__ ). 'event-on/eventon.php' ); 

You then need to add that line to the top of your Event On add on’s construct method. This looks like the PHP code below:

	public function __construct(){			
			
			include_once(plugin_dir_path( __DIR__ ). 'event-on/eventon.php' );
			
			// check if eventon exists with addon class
			if( !isset($GLOBALS['eventon']) || !class_exists('evo_addons') ){
				add_action('admin_notices', array($this, 'notice'));
				return false;			
			}

Now, you’ll be able to take full advantage of your EventOn plugin and add on’s and, as a result, your add on’s shortcodes will start to work and you will no longer see that message!

Leave a Reply

Your email address will not be published. Required fields are marked *