capability = $capability; return $this; } /** * @inheritDoc */ public function withSections( SectionsInterface $sections ): void { $this->sections = $sections; } /** * @inheritDoc */ public function forPage( PageInterface $page ): ViewPage { $this->page = $page; return $this; } /** * @return string */ private function getPageSlug() { return $this->page->getSlug(); } /** * @inheritDoc */ public function render( $view = '' ): void { $this->assertCurrentUserCanSeeThePage(); require $this->findView( $view ); } /** * The add_submenu_page callback */ private function findView( $file_name ) { if ( ! \is_readable( $file_name ) ) { return __DIR__ . self::DS . 'view' . self::DS . 'form.php'; } return $file_name; } /** * Prints out all settings sections added to a particular settings page * * Part of the Settings API. Use this in a settings page callback function * to output all the sections and fields that were added to that $page with * add_settings_section() and add_settings_field() * * @global array $wp_settings_sections Storage array of all settings sections added to admin pages * @global array $wp_settings_fields Storage array of settings fields and info about their pages/sections * @since 2.7.0 * * @param string $page The slug name of the page whose settings sections you want to output. */ private function doSettingsSections( $page ) { global $wp_settings_sections, $wp_settings_fields; if ( ! isset( $wp_settings_sections[ $page ] ) ) { return; } $count = 1; foreach ( (array) $wp_settings_sections[ $page ] as $section ) { echo '