settings = [ 'version' => '1.1.0', 'url' => YMF_PLUGIN_URL, 'path' => YMF_PLUGIN_PATH, ]; // include field add_action( 'acf/include_field_types', [$this, 'include_field'] ); add_action( 'acf/register_fields', [$this, 'include_field'] ); // settings page add_action( 'admin_init', [$this, 'ymf_settings_init'] ); add_action( 'admin_menu', [$this, 'options_page'] ); } function include_field( $version = false ) { // support empty $version if ( ! $version ) { $version = 5; } // load textdomain load_plugin_textdomain( 'acf-yandex-map', false, plugin_basename( dirname( __FILE__ ) ) . '/lang' ); // include include_once( 'fields/class-acf-yandex-map-v' . $version . '.php' ); } function ymf_settings_init() { // Register a new setting for "ymf" page. register_setting( 'acf-yandex-map', 'ymf_options' ); // Register a new section in the "ymf" page. add_settings_section( 'ymf_section_developers', '', [$this, 'section_developers_callback'], 'acf-yandex-map' ); // Register a new field in the "ymf_section_developers" section, inside the "ymf" page. add_settings_field( 'ymf_field_api_key', // As of WP 4.6 this value is used only internally. // Use $args' label_for to populate the id inside the callback. __( 'Yandex api key', 'acf-yandex-map' ), [$this, 'field_api_key'], 'acf-yandex-map', 'ymf_section_developers', [ 'label_for' => 'ymf_field_api_key', 'class' => 'ymf_row', 'ymf_custom_data' => 'custom', ] ); } function section_developers_callback( $args ) { } function field_api_key( $args ) { // Get the value of the setting we've registered with register_setting() $options = get_option( 'ymf_options' ); ?>