123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- if ( ! defined( 'ABSPATH' ) ) {
- exit;
- }
- if ( ! class_exists( 'ACF_Location_Page' ) ) :
- class ACF_Location_Page extends ACF_Location {
-
- public function initialize() {
- $this->name = 'page';
- $this->label = __( 'Page', 'acf' );
- $this->category = 'page';
- $this->object_type = 'post';
- $this->object_subtype = 'page';
- }
-
- public function match( $rule, $screen, $field_group ) {
- return acf_get_location_type( 'post' )->match( $rule, $screen, $field_group );
- }
-
- public function get_values( $rule ) {
- $choices = array();
-
- $groups = acf_get_grouped_posts(
- array(
- 'post_type' => array( 'page' ),
- )
- );
-
- $posts = reset( $groups );
-
- if ( $posts ) {
- foreach ( $posts as $post ) {
- $choices[ $post->ID ] = acf_get_post_title( $post );
- }
- }
- return $choices;
- }
- }
-
- acf_register_location_type( 'ACF_Location_Page' );
- endif;
|