Skip to content

Commit 8a64e93

Browse files
authored
Merge pull request #22 from justcoded/feature/acf_fields
Theme based on ACF
2 parents ad36666 + b72ff73 commit 8a64e93

20 files changed

Lines changed: 210 additions & 554 deletions

app/Admin/Theme_Settings.php

Lines changed: 0 additions & 113 deletions
This file was deleted.

app/Fields/Employee_Fields.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Boilerplate\Theme\Fields;
4+
5+
use Boilerplate\Theme\Post_Type\Employee;
6+
use JustCoded\WP\Framework\ACF\ACF_Register;
7+
8+
class Employee_Fields extends ACF_Register {
9+
10+
/**
11+
* Init fields configuration method
12+
*/
13+
public function init() {
14+
$this->remove_content_editor( Employee::$ID );
15+
16+
$this->has(
17+
$this->build()
18+
->addSelect( 'level' )
19+
->addChoices([
20+
'' => '',
21+
'Junior' => 'Junior',
22+
'Middle' => 'Middle',
23+
'Senior' => 'Senior',
24+
])
25+
->setWidth( '50%' )
26+
->addText( 'position' )
27+
->setWidth( '50%' )
28+
->addTextarea( 'bio' )
29+
->setLocation( 'post_type', '==', Employee::$ID )
30+
);
31+
}
32+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Boilerplate\Theme\Fields\Modules;
4+
5+
use JustCoded\WP\Framework\ACF\ACF_Definition;
6+
7+
class Fields_Generic extends ACF_Definition {
8+
/**
9+
* Init fields configuration method
10+
*/
11+
public function init() {
12+
$this->has(
13+
$this->build( 'subtitle' )
14+
->addText( 'subtitle' ),
15+
16+
$this->build( 'color' )
17+
->addSelect( 'color' )
18+
->addChoice( 'red' )
19+
->addChoice( 'blue' )
20+
->addChoice( 'green' )
21+
->setDefaultValue( 'blue' )
22+
);
23+
}
24+
}

app/Fields/Modules/Module_Hero.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Boilerplate\Theme\Fields\Modules;
4+
5+
use JustCoded\WP\Framework\ACF\ACF_Definition;
6+
7+
class Module_Hero extends ACF_Definition {
8+
/**
9+
* Init fields configuration method
10+
*/
11+
public function init() {
12+
$this->has(
13+
$this->build( 'module_hero' )
14+
->addText( 'hero_title' )
15+
->addImage( 'hero_image' )
16+
->addWysiwyg( 'hero_text' )
17+
);
18+
}
19+
}

app/Fields/Page_Fields.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Boilerplate\Theme\Fields;
4+
5+
use Boilerplate\Theme\Fields\Modules\Fields_Generic;
6+
use Boilerplate\Theme\Fields\Modules\Module_Hero;
7+
use JustCoded\WP\Framework\ACF\ACF_Register;
8+
9+
class Page_Fields extends ACF_Register {
10+
11+
/**
12+
* Init fields configuration method
13+
*/
14+
public function init() {
15+
$this->has(
16+
$this->build()
17+
->addFields( Fields_Generic::get( 'subtitle' ) )
18+
->addFlexibleContent( 'sections' )
19+
->addLayout( Module_Hero::get() )
20+
->endFlexibleContent()
21+
->setLocation( 'post_type', '==', 'page' )
22+
);
23+
}
24+
}

app/Fields/Theme_Fields.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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( '&copy; ' . 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+
}

app/Fields/User_Fields.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
namespace Boilerplate\Theme\Fields;
3+
4+
use JustCoded\WP\Framework\ACF\ACF_Register;
5+
6+
class User_Fields extends ACF_Register {
7+
8+
/**
9+
* Init fields configuration method
10+
*/
11+
public function init() {
12+
$this->has(
13+
$this->build()
14+
->addImage( 'user_avatar' )
15+
->setGroupConfig( 'position', 'high' )
16+
->setLocation( 'user_form', '==', 'all' )
17+
);
18+
}
19+
}

app/Page_Builder/Row/Wide_Layout.php

Lines changed: 0 additions & 79 deletions
This file was deleted.

0 commit comments

Comments
 (0)