How to Fix the get_plugin() Error on AyeCode Connect Screen?

At times, you might encounter an error of this nature on the AyeCode Connect screen: 

Another plugin is calling the get_plugins() function too early which may block updates. We can try to fix this by calling our filter first with a must use plugin.

This happens when the get_plugins() method is being called by another plugin too early. To fix this, you need to copy the code given below and paste it in a blank file: 

<?php
/**
* Plugin Name: AyeCode Connect - Early get_plugins filter
* Plugin URI: https://ayecode.io/ 
* Description: Fix the issue where another plugin is calling get_plugins() too early which disables future filters.
* Version: 1.0.0
* Author: AyeCode Ltd
* Author URI: https://ayecode.io/
* License: GPL-2.0+
* License: GNU General Public License v3 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Requires at least: 3.1
* Tested up to: 5.5
*/

/*
* Set a constant so we can check if the plugin is active. 
*/

define("AYECODE_CONNECT_GET_PLUGINS_FILTER_FIX",true);

/**
* If another plugin calls get_plugins() too early then some filters will not work, this adds our filter early.
*
* @param array $headers
*
* @return array
*/

function ayecode_connect_early_get_plugins_filter_fix( $headers = array() ) {
	$headers_extra = array(
	'UpdateURL' => 'Update URL',
	'UpdateID' => 'Update ID',
	);
	$all_headers = array_merge( $headers_extra, (array) $headers );
	return $all_headers;
}

add_filter( 'extra_plugin_headers', 'ayecode_connect_early_get_plugins_filter_fix' );

Thereafter, save the file as  ayecode-connect-filter-fix.php and then upload it to /wp-content/mu-plugins using your host's SFTP tool or via the cPanel File Manager. 

You can use any text editor, including NotePad to create the above file. Remember to save it with the .php extension. Furthermore, for instructions on how to upload a file, you should check with your web hosting provider. 

The get_plugin() error will be fixed after you have successfully uploaded the said file. 

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.