Last active
August 15, 2016 07:54
-
-
Save MaximeCulea/afdd68e67b7ff2f8efb4d51e636c689c to your computer and use it in GitHub Desktop.
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 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