parent_page = 'options-general.php'; $this->prefix = $key; $this->capability = 'administrator'; $this->option_key = "{$key}-settings"; $this->init_action = "{$key}_settings"; $this->sanitize_action = "{$key}_on_sanitize"; // {sanitize_on_action}_{field_key} $this->sanitize_filter = "{$key}_sanitize"; // {sanitize_filter}_{field_key} $this->pages = []; $this->sections = []; $this->settings = []; add_action( 'init', [ $this, 'settings_init_hook' ] ); add_action( 'admin_menu', [ $this, 'register_pages' ] ); add_action( 'admin_init', [ $this, 'register_settings' ] ); } public function settings_init_hook() { do_action( $this->init_action ); } public function register_pages() { foreach ( $this->pages as $key => $name ) { add_submenu_page( $this->parent_page, $name, $name, $this->capability, $key, function () use ( $name, $key ) { ?>
'; echo esc_html( print_r( $this->get_settings(), true ) ); echo ''; } ?>