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 | |
add_action('acf/render_field_group_settings', '_hwk_flexible_add_group_option', 10, 1); | |
function _hwk_flexible_add_group_option($group){ | |
acf_render_field_wrap(array( | |
'label' => __('Ajouter au contenu flexible', 'acf'), | |
'instructions' => __('Dossier de template par défaut', 'acf'), | |
'type' => 'checkbox', | |
'name' => 'hwk_flexible_content', | |
'prefix' => 'acf_field_group', | |
'value' => ((isset($group['hwk_flexible_content'])) ? 1 : 0), |
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
{ | |
"key": "group_5a3e6acab7fd0", | |
"title": "Mon Groupe", | |
"fields": false, | |
"location": [ | |
[ | |
{ | |
"param": "post_type", | |
"operator": "==", | |
"value": "post" |
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 | |
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 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_content_init'); | |
function hwk_acf_flexible_content_init(){ | |
hwk_acf_flexible_content_generate(array( | |
/** | |
* Contenu Flexible 1 (Simple) | |
* | |
* Filtres additionnels: | |
* group_hwk_contenu_flexible_layouts |
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 | |
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 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 | |
if(!function_exists('wp_parse_args_recursive')){ | |
function wp_parse_args_recursive($args, $default, $preserve_integer_keys = true){ | |
if (!is_array($default) && !is_object($default)) | |
return wp_parse_args($args, $default); | |
$is_object = ( is_object($args) || is_object($default) ); | |
$output = array(); | |
foreach(array($default, $args) as $elements){ |
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 | |
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 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 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 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; | |
} |
OlderNewer