Support

Account

Home Forums General Issues Problem with function_exists() after 4.3.0 update

Solved

Problem with function_exists() after 4.3.0 update

  • I have a functionality plugin that uses the following to check for the get_field() function:

    if ( !function_exists( 'get_field' ) ) 
    	return;

    After updating ACF to 4.3.0, the function works as expected for functions.php. But for the functionality plugin, “!function_exists( ‘get_field’ )” returns true. Before the update it returned false.

    Even though “!function_exists( ‘get_field’ )” returns true, the get_field() function still works.

    I have the Gallery and Repeater Field add-ons installed. Deactivating these and all other plugins produced the same results.

    Any suggestions why function_exists() cannot find get_field() function outside of functions.php?

    Thanks

  • Hi @farmboy

    Does your plugin run before or after ACF?

    Thanks
    E

  • The plugin folder name starts with “custom”, so it should run after ACF. I’m assuming active plugins are loaded alphabetically by there folder name.

  • Hi @farmboy

    I think I know what the issue is.
    v4.3.0 used a hook called ‘plugins_loaded’ to then load in the API. This has now been reported as a bug and I have already removed the hook and updated the github version.

    A new 4.3.1 will be out soon including this fix and some others.

    Perhaps this will explain what is going on?

    Thanks
    E

  • Thanks for the update Elliot. This has also caused issues with several sites running on a theme that requires ACF:

    if(is_plugin_active('advanced-custom-fields/acf.php') == true && function_exists('get_field')) {
    
        include('myfile.php');
    
    }

    Looking forward to the new version soon! :]

  • Elliot,

    Yes that would seem to explain the issue. I appreciate you fixing the bug in the next release.

    Thanks Devin for reporting this issue as well.

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Problem with function_exists() after 4.3.0 update’ is closed to new replies.