abstract-acf-legacy-location.php
1 year ago
abstract-acf-location.php
1 year ago
class-acf-location-attachment.php
1 year ago
class-acf-location-block.php
1 year ago
class-acf-location-comment.php
1 year ago
class-acf-location-current-user-role.php
1 year ago
class-acf-location-current-user.php
1 year ago
class-acf-location-nav-menu-item.php
1 year ago
class-acf-location-nav-menu.php
1 year ago
class-acf-location-options-page.php
1 year ago
class-acf-location-page-parent.php
1 year ago
class-acf-location-page-template.php
1 year ago
class-acf-location-page-type.php
1 year ago
class-acf-location-page.php
1 year ago
class-acf-location-post-category.php
1 year ago
class-acf-location-post-format.php
1 year ago
class-acf-location-post-status.php
1 year ago
class-acf-location-post-taxonomy.php
1 year ago
class-acf-location-post-template.php
1 year ago
class-acf-location-post-type.php
1 year ago
class-acf-location-post.php
1 year ago
class-acf-location-taxonomy.php
1 year ago
class-acf-location-user-form.php
1 year ago
class-acf-location-user-role.php
1 year ago
class-acf-location-widget.php
1 year ago
index.php
1 year ago
class-acf-location-page.php
77 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; // Exit if accessed directly |
| 5 | } |
| 6 | |
| 7 | if ( ! class_exists( 'ACF_Location_Page' ) ) : |
| 8 | |
| 9 | class ACF_Location_Page extends ACF_Location { |
| 10 | |
| 11 | /** |
| 12 | * Initializes props. |
| 13 | * |
| 14 | * @date 5/03/2014 |
| 15 | * @since ACF 5.0.0 |
| 16 | * |
| 17 | * @return void |
| 18 | */ |
| 19 | public function initialize() { |
| 20 | $this->name = 'page'; |
| 21 | $this->label = __( 'Page', 'secure-custom-fields' ); |
| 22 | $this->category = 'page'; |
| 23 | $this->object_type = 'post'; |
| 24 | $this->object_subtype = 'page'; |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Matches the provided rule against the screen args returning a bool result. |
| 29 | * |
| 30 | * @date 9/4/20 |
| 31 | * @since ACF 5.9.0 |
| 32 | * |
| 33 | * @param array $rule The location rule. |
| 34 | * @param array $screen The screen args. |
| 35 | * @param array $field_group The field group settings. |
| 36 | * @return boolean |
| 37 | */ |
| 38 | public function match( $rule, $screen, $field_group ) { |
| 39 | return acf_get_location_type( 'post' )->match( $rule, $screen, $field_group ); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Returns an array of possible values for this rule type. |
| 44 | * |
| 45 | * @date 9/4/20 |
| 46 | * @since ACF 5.9.0 |
| 47 | * |
| 48 | * @param array $rule A location rule. |
| 49 | * @return array |
| 50 | */ |
| 51 | public function get_values( $rule ) { |
| 52 | $choices = array(); |
| 53 | |
| 54 | // Get grouped posts. |
| 55 | $groups = acf_get_grouped_posts( |
| 56 | array( |
| 57 | 'post_type' => array( 'page' ), |
| 58 | ) |
| 59 | ); |
| 60 | |
| 61 | // Get first group. |
| 62 | $posts = reset( $groups ); |
| 63 | |
| 64 | // Append to choices. |
| 65 | if ( $posts ) { |
| 66 | foreach ( $posts as $post ) { |
| 67 | $choices[ $post->ID ] = acf_get_post_title( $post ); |
| 68 | } |
| 69 | } |
| 70 | return $choices; |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | // Register. |
| 75 | acf_register_location_type( 'ACF_Location_Page' ); |
| 76 | endif; // class_exists check |
| 77 |