Created
December 25, 2017 14:15
-
-
Save hawkidoki/2d2e4af9d71f7386976afe6847380221 to your computer and use it in GitHub Desktop.
This file contains 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 | |
// ACF: Flexible Get | |
function hwk_acf_get_flexible(){ | |
$return = array(); | |
acf_enable_filter('local'); | |
foreach(acf_get_field_groups() as $group){ | |
if(isset($group['hwk_flexible_dynamique']) && !empty($group['hwk_flexible_dynamique'])) | |
$return[] = $group; | |
} | |
return $return; | |
} | |
// ACF: Layouts Get | |
function hwk_acf_get_layouts($value = false){ | |
$cache_key = 'hwk_acf_get_layouts'; | |
if(acf_isset_cache($cache_key)){ | |
$return = acf_get_cache($cache_key); | |
if($value){ | |
if(isset($return[$value])) | |
return $return[$value]; | |
else | |
return array(); | |
} | |
return $return; | |
} | |
$return = array(); | |
foreach(acf_get_field_groups() as $group){ | |
foreach($group['location'] as $location){ | |
foreach($location as $rule){ | |
if($rule['param'] == 'hwk_flexible_content_rule'){ | |
$return[$rule['value']][] = $group['key']; | |
break; | |
} | |
} | |
} | |
} | |
acf_set_cache($cache_key, $return); | |
if($value){ | |
if(isset($return[$value])) | |
return $return[$value]; | |
else | |
return array(); | |
} | |
return $return; | |
} | |
// ACF: Layouts Cache | |
add_action('acf/update_field_group', 'hwk_acf_get_layouts_delete_cache'); | |
function hwk_acf_get_layouts_delete_cache($group){ | |
acf_delete_cache('hwk_acf_get_layouts'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment