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 | |
add_filter('group_hwk_contenu_flexible_location', 'hwk_post_type_portfolio_contenu_flexible_location'); | |
function hwk_post_type_portfolio_contenu_flexible_location($location){ | |
$location[] = array( | |
array( | |
'param' => 'post_type', | |
'operator' => '==', | |
'value' => 'portfolio', | |
) | |
); |
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 | |
add_filter('group_hwk_contenu_flexible_location', 'hwk_post_type_portfolio_contenu_flexible_location_complexe'); | |
function hwk_post_type_portfolio_contenu_flexible_location_complexe($location){ | |
// OR | |
$location[] = array( | |
array( | |
'param' => 'post_type', | |
'operator' => '==', | |
'value' => 'portfolio', |
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 | |
add_action('acf/field_group/admin_head', 'hwk_acf_flexible_metabox'); | |
function hwk_acf_flexible_metabox(){ | |
global $field_group; | |
if(isset($field_group['hwk_flexible_dynamique']) && !empty($field_group['hwk_flexible_dynamique'])){ | |
add_meta_box('acf-field-group-layouts-flexible', __('Flexible Layouts', 'acf'), function(){ | |
global $field_group; | |
$group = $field_group; |
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 | |
add_action('acf/field_group/admin_head', 'hwk_acf_flexible_layout_metabox'); | |
function hwk_acf_flexible_layout_metabox(){ | |
global $field_group; | |
$match = false; | |
foreach($field_group['location'] as $location){ | |
foreach($location as $rule){ | |
if($rule['param'] == 'hwk_flexible_content_rule'){ | |
$match = true; |
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 | |
// ACF: Location Rules Types | |
add_filter('acf/location/rule_types', 'hwk_acf_flexible_location_rules_types'); | |
function hwk_acf_flexible_location_rules_types($choices){ | |
$choices['Basic']['hwk_flexible_content_rule'] = 'Contenu Flexible'; | |
return $choices; | |
} | |
// ACF: Location Rules Values | |
add_filter('acf/location/rule_values/hwk_flexible_content_rule', 'hwk_acf_flexible_location_rules_values', 99); |
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 | |
add_action('init', 'hwk_acf_flexible_create'); | |
function hwk_acf_flexible_create(){ | |
foreach(hwk_acf_get_flexible() as $parent){ | |
$parent_title = $parent['title']; | |
$parent_name = str_replace('-', '_', sanitize_title($parent['title'])); | |
$layouts = array(); |
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 | |
add_filter('acf/load_field/type=flexible_content', 'hwk_acf_flexible_filter'); | |
function hwk_acf_flexible_filter($field){ | |
if(!is_admin() || wp_doing_ajax() || get_post_type() == 'acf-field-group') | |
return $field; | |
$parent = _acf_get_field_group_by_key($field['parent']); | |
if(!isset($parent['hwk_flexible_dynamique']) || empty($parent['hwk_flexible_dynamique'])) | |
return $field; |
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 | |
// 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; | |
} |
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 | |
add_action('acf/input/admin_head', 'hwk_acf_flexible_head'); | |
function hwk_acf_flexible_head(){ ?> | |
<script type="text/javascript"> | |
jQuery(document).ready(function($){ | |
$('[data-name="hwk_hidden_parent"]').each(function(){ | |
$(this).closest('.acf-postbox').addClass('acf-hidden'); | |
}); | |
}); |