Skip to content

Instantly share code, notes, and snippets.

@MaximeCulea
Last active August 15, 2016 07:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaximeCulea/afdd68e67b7ff2f8efb4d51e636c689c to your computer and use it in GitHub Desktop.
Save MaximeCulea/afdd68e67b7ff2f8efb4d51e636c689c to your computer and use it in GitHub Desktop.
<?php class BEA_ACF_Customizer_Plugin {
/**
* Register hooks
*/
public function __construct() {
add_filter( 'acf/fields/relationship/query/name=space_port_page', array( __CLASS__, 'space_port_page' ), 10, 3 );
add_filter( 'acf/fields/relationship/query/name=timeline_page', array( __CLASS__, 'timeline_page' ), 10, 3 );
}
/**
* Filter the pages to display only space port ones in ACF
*
* @author Maxime Culea
*
* @param $args
* @param $field
* @param $post_id
*
* @return mixed
*/
public static function space_port_page( $args, $field, $post_id ) {
if ( BEA_CPT_VEHICLE_NAME === get_post_type( $post_id ) ) {
$args['tax_query'][] = array(
'taxonomy' => BEA_TAX_PAGE_CATEGORY_NAME,
'field' => 'slug',
'terms' => 'space-port',
);
}
return $args;
}
/**
* Filter the pages to display only space port ones in ACF
*
* @author Maxime Culea
*
* @param $args
* @param $field
* @param $post_id
*
* @return mixed
*/
public static function timeline_page( $args, $field, $post_id ) {
if ( BEA_CPT_VEHICLE_NAME === get_post_type( $post_id ) ) {
$args['tax_query'][] = array(
'taxonomy' => BEA_TAX_PAGE_CATEGORY_NAME,
'field' => 'slug',
'terms' => 'timeline',
);
}
return $args;
}
}
new BEA_Acf_Customizer_Plugin();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment