Last active
December 22, 2016 01:57
-
-
Save ThatGuySam/4dc16dd40fa01690e5f6e3fca6954237 to your computer and use it in GitHub Desktop.
Fallback hook for Advanced Custom Fields to prevent missing function errors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//http://wordpress.stackexchange.com/questions/243168/providing-fallback-function-and-allow-override-by-plugin | |
function acf_fallback(){ | |
//https://www.advancedcustomfields.com/resources/#functions | |
$acf_functions = array( | |
'get_field', | |
'the_field', | |
); | |
// ACF Plugin fallback | |
//!is_plugin_active( 'advanced-custom-fields/acf.php' ) | |
if( !is_admin() && !function_exists('get_field') ){//!function_exists('get_field') | |
function get_field($field = '', $id = false) { | |
return false; | |
} | |
function the_field($field = '', $id = false) { | |
return false; | |
} | |
function have_rows($field = '', $id = false) { | |
return false; | |
} | |
function has_sub_field($field = '', $id = false) { | |
return false; | |
} | |
function get_sub_field($field = '', $id = false) { | |
return false; | |
} | |
function the_sub_field($field = '', $id = false) { | |
return false; | |
} | |
} | |
} | |
add_action( 'init', 'acf_fallback' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment