abstract-acf-legacy-location.php
1 year ago
abstract-acf-location.php
3 weeks ago
class-acf-location-attachment.php
3 weeks ago
class-acf-location-block.php
1 year ago
class-acf-location-comment.php
1 year ago
class-acf-location-current-user-role.php
3 weeks ago
class-acf-location-current-user.php
3 weeks ago
class-acf-location-nav-menu-item.php
1 year ago
class-acf-location-nav-menu.php
3 weeks 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
3 weeks ago
class-acf-location-page-type.php
3 weeks 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
3 weeks ago
class-acf-location-post-template.php
3 weeks ago
class-acf-location-post-type.php
3 weeks ago
class-acf-location-post.php
1 year ago
class-acf-location-taxonomy.php
3 weeks ago
class-acf-location-user-form.php
3 weeks ago
class-acf-location-user-role.php
3 weeks ago
class-acf-location-widget.php
1 year ago
index.php
1 year ago
class-acf-location-page-parent.php
71 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; // Exit if accessed directly |
| 5 | } |
| 6 | |
| 7 | if ( ! class_exists( 'ACF_Location_Page_Parent' ) ) : |
| 8 | |
| 9 | class ACF_Location_Page_Parent 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_parent'; |
| 21 | $this->label = __( 'Page Parent', '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 | |
| 40 | // Check screen args. |
| 41 | if ( isset( $screen['page_parent'] ) ) { |
| 42 | $page_parent = $screen['page_parent']; |
| 43 | } elseif ( isset( $screen['post_id'] ) ) { |
| 44 | $post = get_post( $screen['post_id'] ); |
| 45 | $page_parent = $post ? $post->post_parent : false; |
| 46 | } else { |
| 47 | return false; |
| 48 | } |
| 49 | |
| 50 | // Compare rule against $page_parent. |
| 51 | return $this->compare_to_rule( $page_parent, $rule ); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Returns an array of possible values for this rule type. |
| 56 | * |
| 57 | * @date 9/4/20 |
| 58 | * @since ACF 5.9.0 |
| 59 | * |
| 60 | * @param array $rule A location rule. |
| 61 | * @return array |
| 62 | */ |
| 63 | public function get_values( $rule ) { |
| 64 | return acf_get_location_type( 'page' )->get_values( $rule ); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | // Register. |
| 69 | acf_register_location_type( 'ACF_Location_Page_Parent' ); |
| 70 | endif; // class_exists check |
| 71 |