true, '_builtin' => false)); $post_types = array_merge($post_types, $pts); return $post_types; } //adding in location options function acf_location_rules_types( $choices ){ $choices['Post']['cpt_template'] = __('Post Type Template','acf-cpt'); return $choices; } // function acf_add_cpt_list($choices){ $ctheme = wp_get_theme(); $ctheme->get_files( 'php', 1 ); $choices = array(); $files = (array) $ctheme->get_files( 'php', 1 ); foreach ( $files as $file => $full_path ) { $headers = get_file_data( $full_path, array( 'Template Name Posts' => 'Template Name Posts' ) ); if ( empty( $headers['Template Name Posts'] ) ) continue; $choices[ $file ] = $headers['Template Name Posts']; } return $choices; } function acf_location_rules_match_cpt_template( $match, $rule, $options ) { global $post; $current_template = get_post_meta($post->ID, 'custom_post_template',true); $selected_template = $rule['value']; if(!$current_template) return; if($rule['operator'] == "==") { $match = ( $current_template == $selected_template ); } elseif($rule['operator'] == "!=") { $match = ( $current_template != $selected_template ); } return $match; } function acf_cpt_javascript(){ wp_enqueue_script('acf_cpt', plugin_dir_url( __FILE__ ) . '/scripts/acf_cpt.js', array('jquery'), '0.2'); } function add_action ($action, $function = '', $priority = 10, $accepted_args = 1) { add_action ($action, array (&$this, $function == '' ? $action : $function), $priority, $accepted_args); } function add_filter ($filter, $function = '', $priority = 10, $accepted_args = 1){ add_filter ($filter, array (&$this, $function == '' ? $filter : $function), $priority, $accepted_args); } } $wp_plugin_template = new WP_cpttr(); ?>