Created
July 30, 2014 19:42
-
-
Save Pross/6fc49eeb6cd5064d2909 to your computer and use it in GitHub Desktop.
Add ACF support for DMS2
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/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