|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Boilerplate\Theme\Fields; |
| 4 | + |
| 5 | +use JustCoded\WP\Framework\ACF\ACF_Register; |
| 6 | + |
| 7 | +class Theme_Fields extends ACF_Register { |
| 8 | + |
| 9 | + /** |
| 10 | + * Init fields configuration method |
| 11 | + */ |
| 12 | + public function init() { |
| 13 | + $this->add_options_page( 'Theme options' ); |
| 14 | + |
| 15 | + $this->has( |
| 16 | + $this->build() |
| 17 | + ->addTab( 'General' ) |
| 18 | + ->addFields( $this->general_tab() ) |
| 19 | + ->addTab( 'Socials Links' ) |
| 20 | + ->addFields( $this->socials_tab() ) |
| 21 | + ->addTab( '404 Page' ) |
| 22 | + ->addFields( $this->page_404_tab() ) |
| 23 | + ->setLocation( 'options_page', '==', 'acf-options-theme-options' ) |
| 24 | + ); |
| 25 | + } |
| 26 | + |
| 27 | + protected function general_tab() { |
| 28 | + return $this->build( 'general_options' ) |
| 29 | + ->addText( 'copyright_text' ) |
| 30 | + ->setDefaultValue( '© ' . date( 'Y' ) . '. All rights reserved.' ) |
| 31 | + ->getRootContext(); |
| 32 | + } |
| 33 | + |
| 34 | + protected function socials_tab() { |
| 35 | + return $this->build( 'socials_options' ) |
| 36 | + ->addText( 'social_fb', [ 'label' => 'Facebook Page' ] ) |
| 37 | + ->setDefaultValue( 'http://facebook.com/my-page' ) |
| 38 | + ->addText( 'social_twitter', [ 'label' => 'Twitter account' ] ) |
| 39 | + ->setDefaultValue( 'http://twitter.com/@some-username' ) |
| 40 | + ->addText( 'social_gplus', [ 'label' => 'Google+' ] ) |
| 41 | + ->setDefaultValue( 'https://plus.google.com/-unique-profile-id-' ) |
| 42 | + ->getRootContext(); |
| 43 | + } |
| 44 | + |
| 45 | + protected function page_404_tab() { |
| 46 | + return $this->build( '404_options' ) |
| 47 | + ->addText( 'page_404_title', [ 'label' => '404 Page Title' ] ) |
| 48 | + ->addWysiwyg( 'page_404_content', [ 'label' => '404 Page Content' ] ) |
| 49 | + ->getRootContext(); |
| 50 | + } |
| 51 | +} |
0 commit comments