12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- if ( ! defined( 'ABSPATH' ) ) {
- exit;
- }
- if ( ! class_exists( 'ACF_Location_Post_Category' ) ) :
- class ACF_Location_Post_Category extends ACF_Location {
-
- public function initialize() {
- $this->name = 'post_category';
- $this->label = __( 'Post Category', 'acf' );
- $this->category = 'post';
- $this->object_type = 'post';
- }
-
- public function match( $rule, $screen, $field_group ) {
- return acf_get_location_type( 'post_taxonomy' )->match( $rule, $screen, $field_group );
- }
-
- public function get_values( $rule ) {
- $choices = acf_get_taxonomy_terms( array( 'category' ) );
- if ( $choices ) {
- return reset( $choices );
- }
- return array();
- }
-
- public function get_object_subtype( $rule ) {
- return acf_get_location_type( 'post_taxonomy' )->get_object_subtype( $rule );
- }
- }
-
- acf_register_location_rule( 'ACF_Location_Post_Category' );
- endif;
|