acf_options_page::validate_page()
Validates an Options Page settings array.
Метод класса: acf_options_page{}
Хуки из метода
Возвращает
Массив
.
Использование
$acf_options_page = new acf_options_page(); $acf_options_page->validate_page( $page );
- $page(массив|строка) (обязательный)
- The Options Page settings array or name.
Список изменений
С версии 5.5.8 | Введена. |
Код acf_options_page::validate_page() acf options page::validate page ACF 6.0.4
function validate_page( $page ) { // Allow empty arg to generate the default Options Page. if ( empty( $page ) ) { $page_title = __( 'Options', 'acf' ); $page = array( 'page_title' => $page_title, 'menu_title' => $page_title, 'menu_slug' => 'acf-options', ); // Allow string to define Options Page name. } elseif ( is_string( $page ) ) { $page_title = $page; $page = array( 'page_title' => $page_title, 'menu_title' => $page_title, ); } // Apply defaults. $page = wp_parse_args( $page, array( 'page_title' => '', 'menu_title' => '', 'menu_slug' => '', 'capability' => 'edit_posts', 'parent_slug' => '', 'position' => null, 'icon_url' => false, 'redirect' => true, 'post_id' => 'options', 'autoload' => false, 'update_button' => __( 'Update', 'acf' ), 'updated_message' => __( 'Options Updated', 'acf' ), ) ); // Allow compatibility for changed settings. $migrate = array( 'title' => 'page_title', 'menu' => 'menu_title', 'slug' => 'menu_slug', 'parent' => 'parent_slug', ); foreach ( $migrate as $old => $new ) { if ( ! empty( $page[ $old ] ) ) { $page[ $new ] = $page[ $old ]; } } // If no menu_title is set, use the page_title value. if ( empty( $page['menu_title'] ) ) { $page['menu_title'] = $page['page_title']; } // If no menu_slug is set, generate one using the menu_title value. if ( empty( $page['menu_slug'] ) ) { $page['menu_slug'] = 'acf-options-' . sanitize_title( $page['menu_title'] ); } // Standardize on position being either null or int. $page['position'] = is_numeric( $page['position'] ) ? (int) $page['position'] : null; /** * Filters the $page array after it has been validated. * * @since 5.5.8 * @param array $page The Options Page settings array. */ return apply_filters( 'acf/validate_options_page', $page ); }