oik-plugins
WordPress plugins and themes

Fatal error: Call to undefined function oik_require() in oik\admin\oik-header.inc on line 2

This post explains a problem with the oik-header plugin and the workaround that you can apply to fix it. It is applicable to the following message.
Fatal error: Call to undefined function oik_require() in oik\admin\oik-header.inc on line 2

Cause

This problem occurs in the WordPress admin pages when the oik-header plugin is activated but oik is not activated.

Response

As it’s a fatal error in the WordPress admin pages, the only way you can recover from this is to alter the files directly. On a hosted site this means using the control panel functionality or FTP.

Quick fix

  1. Access your server file using the control panel or FTP site
  2. Navigate to the wp-content/plugins/oik folder
  3. Rename or delete the file called oik-header.php
The next time you visit your WordPress dashboard the plugin will be deactivated automatically. Watch the video

Workaround

If you are able to edit the files on your server then this solution will enable you to continue to use the oik plugin’s custom header image functionality.
  • Edit the file oik/oik-header.php  Note: this is a different file from where the error occurred.
  • Move the last 3 non-blank lines from the end of the file to inside the oik_header_init() function.
  • Save the changes
The new function should look like this function oik_header_init() { if ( is_admin() ) { require_once( 'admin/oik-header.inc' ); } add_action( 'wp_footer', 'bw_page_header_style' ); } This should re-enable the admin pages. You should now activate the oik plugin.

Explanation

Most of the oik plugins are dependent upon the oik base functionality. The dependent functions assume that once oik has been loaded then they can use the oik functions. The error in the oik-header code was that the admin/oik-header.inc file would get loaded even when oik was not activated This meant that the oik_require() function could not be found. The problem would also occur if the oik-header plugin was being loaded before the oik plugin. oik-header would attempt to run code that had not been loaded. The fix is to move the is_admin() test into the initialisation logic that is only executed when oik has been loaded.

Apologies and excuses

I apologise for my code being the cause of this problem. I had not detected it since most of the time I have the oik-bwtrace plugin activated. oik-bwtrace loads oik_boot.inc which is the file that defines oik_require(). So even if I deactivate oik – which I often do to test the dependency checking of oik-nivo-slider and other plugins that depend upon oik – I hadn’t noticed it. Thanks to shkinfo and azurewitch for taking the time to report the problem in the WordPress forums.

Permanent fix

A permanent fix for this problem was delivered in oik version 1.16. You should not have to apply the workaround yourself, just update your version of oik.

5 Responses to Fatal error: Call to undefined function oik_require() in oik\admin\oik-header.inc on line 2

Leave a Reply

Information