123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- if ( ! defined( 'ABSPATH' ) ) {
- exit;
- }
- if ( ! class_exists( 'ACF_Location_Options_Page' ) ) :
- class ACF_Location_Options_Page extends ACF_Location {
-
- public function initialize() {
- $this->name = 'options_page';
- $this->label = __( 'Options Page', 'acf' );
- $this->category = 'forms';
- $this->object_type = 'option';
- }
-
- public function match( $rule, $screen, $field_group ) {
-
- if ( isset( $screen['options_page'] ) ) {
- $options_page = $screen['options_page'];
- } else {
- return false;
- }
-
- return $this->compare_to_rule( $options_page, $rule );
- }
-
- public function get_values( $rule ) {
- $choices = array();
-
- $pages = acf_get_options_pages();
- if ( $pages ) {
- foreach ( $pages as $page ) {
- $choices[ $page['menu_slug'] ] = $page['page_title'];
- }
- } else {
- $choices[''] = __( 'No options pages exist', 'acf' );
- }
-
- return $choices;
- }
- }
-
- acf_register_location_type( 'ACF_Location_Options_Page' );
- endif;
|