General.php
47 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AC\Admin\Section; |
| 4 | |
| 5 | use AC\Admin\Section; |
| 6 | use AC\Renderable; |
| 7 | use AC\View; |
| 8 | |
| 9 | class General extends Section { |
| 10 | |
| 11 | const NAME = 'general'; |
| 12 | |
| 13 | /** |
| 14 | * @var Renderable[] |
| 15 | */ |
| 16 | private $options; |
| 17 | |
| 18 | public function __construct( array $options ) { |
| 19 | parent::__construct( self::NAME ); |
| 20 | |
| 21 | array_map( [ $this, 'add_option' ], $options ); |
| 22 | } |
| 23 | |
| 24 | public function add_option( Renderable $option ) { |
| 25 | $this->options[] = $option; |
| 26 | } |
| 27 | |
| 28 | public function render() { |
| 29 | $form = new View( [ |
| 30 | 'options' => $this->options, |
| 31 | ] ); |
| 32 | |
| 33 | $form->set_template( 'admin/page/settings-section-general' ); |
| 34 | |
| 35 | $view = new View( [ |
| 36 | 'title' => __( 'General Settings', 'codepress-admin-columns' ), |
| 37 | 'description' => __( 'Customize your Admin Columns settings.', 'codepress-admin-columns' ), |
| 38 | 'content' => $form->render(), |
| 39 | 'class' => 'general', |
| 40 | ] ); |
| 41 | |
| 42 | $view->set_template( 'admin/page/settings-section' ); |
| 43 | |
| 44 | return $view->render(); |
| 45 | } |
| 46 | |
| 47 | } |