acf_admin_options_page::admin_load
description
Метод класса: acf_admin_options_page{}
Хуки из метода
Возвращает
$post_id. (int)
Использование
$acf_admin_options_page = new acf_admin_options_page(); $acf_admin_options_page->admin_load();
Список изменений
| С версии 3.6 | Введена. |
Код acf_admin_options_page::admin_load() acf admin options page::admin load ACF 6.8.8
function admin_load() {
// globals
global $plugin_page;
// vars
$this->page = acf_get_options_page( $plugin_page );
// get post_id (allow lang modification)
$this->page['post_id'] = acf_get_valid_post_id( $this->page['post_id'] );
// verify and remove nonce
if ( acf_verify_nonce( 'options' ) ) {
// Restrict submitted values to fields belonging to field groups assigned to the current options page.
// phpcs:disable WordPress.Security.NonceVerification.Missing -- Verified above via acf_verify_nonce().
if ( isset( $_POST['acf'] ) && is_array( $_POST['acf'] ) ) {
$_POST['acf'] = $this->filter_options_page_field_values( $_POST['acf'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash -- Sanitized downstream; save pipeline expects slashed input.
}
// phpcs:enable WordPress.Security.NonceVerification.Missing
// save data
if ( acf_validate_save_post( true ) ) {
// set autoload
acf_update_setting( 'autoload', $this->page['autoload'] );
// save
acf_save_post( $this->page['post_id'] );
/**
* Fires after publishing a save on an options page.
*
* @since 6.1.7
*
* @param string|int $post_id The current id.
* @param string $menu_slug The current options page menu slug.
*/
do_action( 'acf/options_page/save', $this->page['post_id'], $this->page['menu_slug'] );
// redirect
wp_safe_redirect( add_query_arg( array( 'message' => '1' ) ) );
exit;
}
}
// load acf scripts
acf_enqueue_scripts();
// Localize options page slug for repeater pagination capability checks.
acf_localize_data( array( 'options_page_slug' => $this->page['menu_slug'] ) );
// actions
add_action( 'acf/input/admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
add_action( 'acf/input/admin_head', array( $this, 'admin_head' ) );
// add columns support
add_screen_option(
'layout_columns',
array(
'max' => 2,
'default' => 2,
)
);
}