Skip to content

Instantly share code, notes, and snippets.

@Pross
Created July 30, 2014 19:42
Show Gist options
  • Select an option

  • Save Pross/6fc49eeb6cd5064d2909 to your computer and use it in GitHub Desktop.

Select an option

Save Pross/6fc49eeb6cd5064d2909 to your computer and use it in GitHub Desktop.
Add ACF support for DMS2
<?php
add_filter('acf/location/rule_types', 'acf_location_rules_types');
function acf_location_rules_types( $choices ) {
$choices['Page']['pagelinespage'] = 'Pagelines Page';
return $choices;
}
// Find pages
add_filter('acf/location/rule_values/pagelinespage', 'acf_location_rules_values_pagelinespage');
function acf_location_rules_values_pagelinespage( $choices ) {
//get a list of the pageline pages
$custom_template_handler = new PLCustomTemplates;
$templates = $custom_template_handler->get_all();
// format templates
foreach( $templates as $key => $data ) {
$choices[$key] = $data['name'];
}
return $choices;
}
//Then add the match rule
add_filter('acf/location/rule_match/pagelinespage', 'acf_location_rules_match_user', 10, 3);
function acf_location_rules_match_user( $match, $rule, $options )
{
$postid = $_REQUEST['post'];
$set = pl_meta( $postid, PL_SETTINGS );
$current = ( is_array( $set ) && isset( $set['live']['custom-map']['template']['ctemplate'] ) ) ? $set['live']['custom-map']['template']['ctemplate'] : '';
if( $current && $current == $rule['value'] )
return true;
return $match;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment